From 25d96fcd4306899c10ae834cd7a504a692e46c54 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 14:01:18 -0700 Subject: [PATCH 001/664] Project layout Adding empty pom.xml file Add .gitignore to skip common build output and ide files --- .gitignore | 4 ++++ microsoft-azure-api/pom.xml | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 .gitignore create mode 100644 microsoft-azure-api/pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000..beef00d016539 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.classpath +.project +.settings +target diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml new file mode 100644 index 0000000000000..b1391caae006b --- /dev/null +++ b/microsoft-azure-api/pom.xml @@ -0,0 +1,8 @@ + + 4.0.0 + com.microsoft.azure + microsoft-azure-api + 0.0.1-SNAPSHOT + Microsoft Azure Client API + API for Microsoft Azure Clients + \ No newline at end of file From 542ae883a170de856b8f36d9bca635b97a833343 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 23:13:10 -0700 Subject: [PATCH 002/664] Adding xsd class generation. Adding ServiceBusClient interface. --- microsoft-azure-api/pom.xml | 21 +- .../microsoft/azure/http/ClientFactory.java | 5 + .../services/serviceBus/BrokeredMessage.java | 5 + .../services/serviceBus/RECEIVE_MODE.java | 5 + .../services/serviceBus/ServiceBusClient.java | 30 ++ .../serviceBus/ServiceBusClientFactory.java | 7 + .../src/main/resources/package-names.xjb | 10 + ...as.microsoft.com.2003.10.Serialization.xsd | 42 +++ ...netservices.2010.10.servicebus.connect.xsd | 296 ++++++++++++++++++ 9 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java create mode 100644 microsoft-azure-api/src/main/resources/package-names.xjb create mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd create mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b1391caae006b..083f5e5dcd029 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -5,4 +5,23 @@ 0.0.1-SNAPSHOT Microsoft Azure Client API API for Microsoft Azure Clients - \ No newline at end of file + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.8.0 + + + generate-sources + + generate + + + + + + + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java new file mode 100644 index 0000000000000..8dc43770d802e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.http; + +public abstract class ClientFactory { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java new file mode 100644 index 0000000000000..29dea80dd690e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus; + +public class BrokeredMessage { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java new file mode 100644 index 0000000000000..c08a36fe034d3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus; + +public enum RECEIVE_MODE { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java new file mode 100644 index 0000000000000..76c347d33513b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -0,0 +1,30 @@ +package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.services.serviceBus.model.*; + +public interface ServiceBusClient { + void sendMessage(String path, BrokeredMessage message); + BrokeredMessage receiveMessage(String path, int timeout, RECEIVE_MODE receiveMode); + void abandonMessage(BrokeredMessage message); + void completeMessage(BrokeredMessage message); + + void createQueue(String queuePath, QueueDescription description); + void deleteQueue(String queuePath); + QueueDescription getQueue(String queuePath); + QueueDescription[] getQueues(); + + void createTopic(String topicPath, TopicDescription description); + void deleteTopic(String topicPath); + TopicDescription getTopic(String topicPath); + TopicDescription[] getTopics(); + + void addSubscription(String topicPath, String subscriptionName, SubscriptionDescription description); + void removeSubscription(String topicPath, String subscriptionName); + SubscriptionDescription getSubscription(String topicPath, String subscriptionName); + SubscriptionDescription[] getSubscriptions(String topicPath); + + void addRule(String topicPath, String subscriptionName, String ruleName, RuleDescription description); + void removeRule(String topicPath, String subscriptionName, String ruleName); + RuleDescription getRule(String topicPath, String subscriptionName, String ruleName); + RuleDescription [] getRules(String topicPath, String subscriptionName); +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java new file mode 100644 index 0000000000000..7e09218369f64 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.http.ClientFactory; + +public class ServiceBusClientFactory extends ClientFactory { + public ServiceBusClient createClient() throws Exception {throw new Exception();} +} diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb new file mode 100644 index 0000000000000..2a71b66ed69ad --- /dev/null +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd new file mode 100644 index 0000000000000..62ff1db89253b --- /dev/null +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd new file mode 100644 index 0000000000000..bdad52ce00ff8 --- /dev/null +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From f38b6ef322c8f5d40336d74db3d70ab46eb5d69b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 23:42:59 -0700 Subject: [PATCH 003/664] Removing jaxb annotation from xsd --- ...rosoft.com.netservices.2010.10.servicebus.connect.xsd | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index bdad52ce00ff8..825aaf965fb3b 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -4,14 +4,7 @@ xmlns:tns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" - jaxb:version="2.0"> - - + xmlns:xs="http://www.w3.org/2001/XMLSchema"> From 95f85401069b8fdf5f601ca45c7478ee6029a227 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 23:43:27 -0700 Subject: [PATCH 004/664] Adding message send/receive interfaces --- .../azure/services/serviceBus/MessageReceiver.java | 7 +++++++ .../microsoft/azure/services/serviceBus/MessageSender.java | 5 +++++ .../azure/services/serviceBus/MessageTranceiver.java | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java new file mode 100644 index 0000000000000..33a29feaf8c9c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.serviceBus; + +public interface MessageReceiver { + BrokeredMessage receive(int timeout, RECEIVE_MODE receiveMode); + void abandon(BrokeredMessage message); + void complete(BrokeredMessage message); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java new file mode 100644 index 0000000000000..c1144ff5cb11c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus; + +public interface MessageSender { + void send(BrokeredMessage message); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java new file mode 100644 index 0000000000000..60805965530fa --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java @@ -0,0 +1,6 @@ + +package com.microsoft.azure.services.serviceBus; + +public interface MessageTranceiver extends MessageSender, MessageReceiver { + +} From b5f1f88a7599bba6f4a1a4292cb7baba48324ab4 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 23:43:55 -0700 Subject: [PATCH 005/664] Factory methods for send/receive interfaces --- .../serviceBus/ServiceBusClientFactory.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java index 7e09218369f64..bfab2908a0a63 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java @@ -3,5 +3,16 @@ import com.microsoft.azure.http.ClientFactory; public class ServiceBusClientFactory extends ClientFactory { - public ServiceBusClient createClient() throws Exception {throw new Exception();} + public ServiceBusClient createClient() { + return null; + } + public MessageTranceiver openQueue(String queuePath) { + return null; + } + public MessageSender openTopic(String topicPath) { + return null; + } + public MessageReceiver openSubscription(String topicPath, String subscriptionName) { + return null; + } } From ca8d7096def8a7a19d047723727e5f49a53bd2f7 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 12 Oct 2011 23:44:15 -0700 Subject: [PATCH 006/664] Adding overload for receiveMessage --- .../microsoft/azure/services/serviceBus/ServiceBusClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 76c347d33513b..53e552d4a0bdb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -3,7 +3,8 @@ public interface ServiceBusClient { void sendMessage(String path, BrokeredMessage message); - BrokeredMessage receiveMessage(String path, int timeout, RECEIVE_MODE receiveMode); + BrokeredMessage receiveMessage(String queuePath, int timeout, RECEIVE_MODE receiveMode); + BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, RECEIVE_MODE receiveMode); void abandonMessage(BrokeredMessage message); void completeMessage(BrokeredMessage message); From 85e39d7f7279e7518574ec98f735ba30b828f3ec Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 13 Oct 2011 07:49:58 -0700 Subject: [PATCH 007/664] Changing enum case --- .../azure/services/serviceBus/MessageReceiver.java | 2 +- .../microsoft/azure/services/serviceBus/RECEIVE_MODE.java | 5 ----- .../microsoft/azure/services/serviceBus/ReceiveMode.java | 6 ++++++ .../azure/services/serviceBus/ServiceBusClient.java | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index 33a29feaf8c9c..969742f8b94d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -1,7 +1,7 @@ package com.microsoft.azure.services.serviceBus; public interface MessageReceiver { - BrokeredMessage receive(int timeout, RECEIVE_MODE receiveMode); + BrokeredMessage receive(int timeout, ReceiveMode receiveMode); void abandon(BrokeredMessage message); void complete(BrokeredMessage message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java deleted file mode 100644 index c08a36fe034d3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/RECEIVE_MODE.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -public enum RECEIVE_MODE { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java new file mode 100644 index 0000000000000..b96aa03a3835a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java @@ -0,0 +1,6 @@ +package com.microsoft.azure.services.serviceBus; + +public enum ReceiveMode { + PEEK_LOCK, + RECEIVE_AND_DELETE, +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 53e552d4a0bdb..3bf1a4ed8bd12 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -3,8 +3,8 @@ public interface ServiceBusClient { void sendMessage(String path, BrokeredMessage message); - BrokeredMessage receiveMessage(String queuePath, int timeout, RECEIVE_MODE receiveMode); - BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, RECEIVE_MODE receiveMode); + BrokeredMessage receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); + BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); void abandonMessage(BrokeredMessage message); void completeMessage(BrokeredMessage message); From ade0ec745f91f18472b35e6a2e24df10d392bbfd Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 13 Oct 2011 07:27:17 -0700 Subject: [PATCH 008/664] Referencing Jersey in a branch To have a better idea how to design for it, if it was used --- microsoft-azure-api/pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 083f5e5dcd029..7d7fb65fb498d 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -24,4 +24,16 @@ + + + com.sun.jersey + jersey-client + 1.10-b02 + + + com.sun.jersey + jersey-atom + 1.10-b02 + + From 1ccb3c1a14a1f033f9defe3a27ab793d34303dde Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 13 Oct 2011 07:35:03 -0700 Subject: [PATCH 009/664] Roughing out an approximation of a client endpoint Renamed Factory to Builder, because it's starting to feel like a stateful pattern. --- .../com/microsoft/azure/http/ClientBase.java | 20 +++ .../azure/http/ClientBuilderBase.java | 19 +++ .../microsoft/azure/http/ClientFactory.java | 5 - ...tory.java => ServiceBusClientBuilder.java} | 9 +- .../serviceBus/ServiceBusClientImpl.java | 128 ++++++++++++++++++ 5 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ServiceBusClientFactory.java => ServiceBusClientBuilder.java} (65%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java new file mode 100644 index 0000000000000..f3432b4d69893 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java @@ -0,0 +1,20 @@ +package com.microsoft.azure.http; + +import java.net.URI; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; + +public abstract class ClientBase { + Client client; + URI uri; + + public ClientBase(Client client, URI uri) { + this.client = client; + this.uri = uri; + } + + protected WebResource resource() { + return client.resource(uri); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java new file mode 100644 index 0000000000000..8d6d2f882bbd3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java @@ -0,0 +1,19 @@ +package com.microsoft.azure.http; + +import java.net.URI; + +import com.sun.jersey.api.client.Client; + +public abstract class ClientBuilderBase { + protected Client client = new Client(); + + URI url; + + public URI getUrl() { + return url; + } + + public void setUrl(URI url) { + this.url = url; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java deleted file mode 100644 index 8dc43770d802e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFactory.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.http; - -public abstract class ClientFactory { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java similarity index 65% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java index bfab2908a0a63..34a8a8e075098 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java @@ -1,11 +1,12 @@ package com.microsoft.azure.services.serviceBus; -import com.microsoft.azure.http.ClientFactory; +import com.microsoft.azure.http.ClientBuilderBase; -public class ServiceBusClientFactory extends ClientFactory { + +public class ServiceBusClientBuilder extends ClientBuilderBase { public ServiceBusClient createClient() { - return null; - } + return new ServiceBusClientImpl(this.client, this.getUrl()); + } public MessageTranceiver openQueue(String queuePath) { return null; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java new file mode 100644 index 0000000000000..8ab478aa7d43e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java @@ -0,0 +1,128 @@ +package com.microsoft.azure.services.serviceBus; + +import java.net.URI; + +import com.microsoft.azure.http.ClientBase; +import com.microsoft.azure.services.serviceBus.model.QueueDescription; +import com.microsoft.azure.services.serviceBus.model.RuleDescription; +import com.microsoft.azure.services.serviceBus.model.SubscriptionDescription; +import com.microsoft.azure.services.serviceBus.model.TopicDescription; +import com.sun.jersey.api.client.Client; + +class ServiceBusClientImpl extends ClientBase implements ServiceBusClient { + + public ServiceBusClientImpl(Client client, URI url) { + super(client, url); + } + + public void sendMessage(String path, BrokeredMessage message) { + // TODO Auto-generated method stub + + } + + public BrokeredMessage receiveMessage(String queuePath, int timeout, + RECEIVE_MODE receiveMode) { + // TODO Auto-generated method stub + return null; + } + + public BrokeredMessage receiveMessage(String topicPath, + String subscriptionName, int timeout, RECEIVE_MODE receiveMode) { + // TODO Auto-generated method stub + return null; + } + + public void abandonMessage(BrokeredMessage message) { + // TODO Auto-generated method stub + + } + + public void completeMessage(BrokeredMessage message) { + // TODO Auto-generated method stub + + } + + public void createQueue(String queuePath, QueueDescription description) { + resource().path(queuePath).put(description); + } + + public void deleteQueue(String queuePath) { + resource().path(queuePath).delete(); + } + + public QueueDescription getQueue(String queuePath) { + // TODO Auto-generated method stub + return null; + } + + public QueueDescription[] getQueues() { + // TODO Auto-generated method stub + return null; + } + + public void createTopic(String topicPath, TopicDescription description) { + // TODO Auto-generated method stub + + } + + public void deleteTopic(String topicPath) { + // TODO Auto-generated method stub + + } + + public TopicDescription getTopic(String topicPath) { + // TODO Auto-generated method stub + return null; + } + + public TopicDescription[] getTopics() { + // TODO Auto-generated method stub + return null; + } + + public void addSubscription(String topicPath, String subscriptionName, + SubscriptionDescription description) { + // TODO Auto-generated method stub + + } + + public void removeSubscription(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + + } + + public SubscriptionDescription getSubscription(String topicPath, + String subscriptionName) { + // TODO Auto-generated method stub + return null; + } + + public SubscriptionDescription[] getSubscriptions(String topicPath) { + // TODO Auto-generated method stub + return null; + } + + public void addRule(String topicPath, String subscriptionName, + String ruleName, RuleDescription description) { + // TODO Auto-generated method stub + + } + + public void removeRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + + } + + public RuleDescription getRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + return null; + } + + public RuleDescription[] getRules(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + return null; + } + +} From b228b5a14627fe7bd67d066aeac85c4b528e27bb Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Sat, 15 Oct 2011 17:13:35 -0700 Subject: [PATCH 010/664] Reshaping based on current conversations Moving low-level protocol details away from service base namespace Roughing in simple builder pattern and configuration class Adding Client in services.base namespace for o-o api --- microsoft-azure-api/pom.xml | 7 +- .../azure/configuration/Builder.java | 7 ++ .../azure/configuration/Configuration.java | 41 +++++++++++ .../azure/configuration/DefaultBuilder.java | 51 +++++++++++++ .../com/microsoft/azure/http/ClientBase.java | 20 ------ .../azure/http/ClientBuilderBase.java | 19 ----- .../services/serviceBus/MessageReceiver.java | 3 + .../services/serviceBus/MessageSender.java | 2 + .../azure/services/serviceBus/Queue.java | 55 ++++++++++++++ .../azure/services/serviceBus/Rule.java | 5 ++ .../services/serviceBus/ServiceBusClient.java | 71 +++++++++++-------- .../serviceBus/ServiceBusClientBuilder.java | 19 ----- .../services/serviceBus/Subscription.java | 7 ++ .../azure/services/serviceBus/Topic.java | 7 ++ .../serviceBus/contract/BrokeredMessage.java | 5 ++ .../serviceBus/contract/ReceiveMode.java | 6 ++ .../contract/ServiceBusContract.java | 31 ++++++++ .../ServiceBusContractImpl.java} | 22 ++---- .../src/main/resources/package-names.xjb | 2 +- .../serviceBus/ClientBuilderTest.java | 22 ++++++ .../contract/ContractBuilderTest.java | 17 +++++ 21 files changed, 312 insertions(+), 107 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ServiceBusClientImpl.java => contract/ServiceBusContractImpl.java} (73%) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 7d7fb65fb498d..fd1fc1424b304 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -31,9 +31,10 @@ 1.10-b02 - com.sun.jersey - jersey-atom - 1.10-b02 + junit + junit + 4.8 + test diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java new file mode 100644 index 0000000000000..287e9597e6557 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.configuration; + +public interface Builder { + + public abstract T build(Class c) throws Exception; + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java new file mode 100644 index 0000000000000..2048d98401d72 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -0,0 +1,41 @@ +package com.microsoft.azure.configuration; + +import com.microsoft.azure.services.serviceBus.ServiceBusClient; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; +import com.sun.jersey.api.client.Client; + + +public class Configuration implements Builder { + + private Builder builder; + + public Configuration() { + setBuilder(getStandardComponentsBuilder()); + } + + public Configuration(Builder builder) { + setBuilder(builder); + } + + public static Builder getStandardComponentsBuilder() { + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ServiceBusClient.class, ServiceBusClient.class, ServiceBusContract.class); + builder.add(ServiceBusContract.class, ServiceBusContractImpl.class); + builder.add(Client.class, Client.class); + return builder; + } + + public Builder getBuilder() { + return builder; + } + + public void setBuilder(Builder builder) { + this.builder = builder; + } + + public T build(Class c) throws Exception { + return builder.build(c); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java new file mode 100644 index 0000000000000..9e7e534bbcedb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java @@ -0,0 +1,51 @@ +package com.microsoft.azure.configuration; + +import java.lang.reflect.Constructor; +import java.util.HashMap; +import java.util.Map; + + +public class DefaultBuilder implements Builder { + public DefaultBuilder() { + factories = new HashMap, Factory>(); + } + + interface Factory { + T create() throws Exception; + } + + Map, Factory> factories; + + public Builder addFactory(Class service, Factory factory) { + factories.put(service, factory); + return this; + } + + public DefaultBuilder add(Class service, final Class implementation) { + addFactory(service, new Factory() { + public T create() throws Exception { + return implementation.newInstance(); + }}); + return this; + } + + public DefaultBuilder add(Class service, final Class implementation, final Class parameterType1) { + addFactory(service, new Factory() { + public T create() throws Exception { + final Constructor ctor = implementation.getConstructor(parameterType1); + return ctor.newInstance(build(parameterType1)); + }}); + return this; + } + + + public DefaultBuilder add(Class service) { + return add(service, service); + } + + + + public T build(Class c) throws Exception { + return (T) factories.get(c).create(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java deleted file mode 100644 index f3432b4d69893..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBase.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.microsoft.azure.http; - -import java.net.URI; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; - -public abstract class ClientBase { - Client client; - URI uri; - - public ClientBase(Client client, URI uri) { - this.client = client; - this.uri = uri; - } - - protected WebResource resource() { - return client.resource(uri); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java deleted file mode 100644 index 8d6d2f882bbd3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientBuilderBase.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.microsoft.azure.http; - -import java.net.URI; - -import com.sun.jersey.api.client.Client; - -public abstract class ClientBuilderBase { - protected Client client = new Client(); - - URI url; - - public URI getUrl() { - return url; - } - - public void setUrl(URI url) { - this.url = url; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index 969742f8b94d2..aacc5e67d7721 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -1,5 +1,8 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; +import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; + public interface MessageReceiver { BrokeredMessage receive(int timeout, ReceiveMode receiveMode); void abandon(BrokeredMessage message); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java index c1144ff5cb11c..42626882d1211 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -1,5 +1,7 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; + public interface MessageSender { void send(BrokeredMessage message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java new file mode 100644 index 0000000000000..0fb9899a0f590 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -0,0 +1,55 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; +import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; + +public class Queue implements MessageSender, MessageReceiver { + private ServiceBusClient client; + private String path; + private QueueDescription description; + + public Queue(ServiceBusClient client, String path) { + this.client = client; + this.path = path; + } + + public Queue(ServiceBusClient client, QueueDescription queueDescription) { + this.client = client; + + } + + public void create() { + client.getContract().createQueue(path, description); + } + + public void delete() { + client.getContract().deleteQueue(path); + } + + public void commit() { + //TODO protocol operation to put data? + } + + + public void send(BrokeredMessage message) { + // TODO Auto-generated method stub + + } + + public BrokeredMessage receive(int timeout, ReceiveMode receiveMode) { + // TODO Auto-generated method stub + return null; + } + + public void abandon(BrokeredMessage message) { + // TODO Auto-generated method stub + + } + + public void complete(BrokeredMessage message) { + // TODO Auto-generated method stub + + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java new file mode 100644 index 0000000000000..2ca00d6ed13fc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus; + +public class Rule { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 3bf1a4ed8bd12..0d7200465ce2d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -1,31 +1,44 @@ package com.microsoft.azure.services.serviceBus; -import com.microsoft.azure.services.serviceBus.model.*; - -public interface ServiceBusClient { - void sendMessage(String path, BrokeredMessage message); - BrokeredMessage receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); - BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); - void abandonMessage(BrokeredMessage message); - void completeMessage(BrokeredMessage message); - - void createQueue(String queuePath, QueueDescription description); - void deleteQueue(String queuePath); - QueueDescription getQueue(String queuePath); - QueueDescription[] getQueues(); - - void createTopic(String topicPath, TopicDescription description); - void deleteTopic(String topicPath); - TopicDescription getTopic(String topicPath); - TopicDescription[] getTopics(); - - void addSubscription(String topicPath, String subscriptionName, SubscriptionDescription description); - void removeSubscription(String topicPath, String subscriptionName); - SubscriptionDescription getSubscription(String topicPath, String subscriptionName); - SubscriptionDescription[] getSubscriptions(String topicPath); - - void addRule(String topicPath, String subscriptionName, String ruleName, RuleDescription description); - void removeRule(String topicPath, String subscriptionName, String ruleName); - RuleDescription getRule(String topicPath, String subscriptionName, String ruleName); - RuleDescription [] getRules(String topicPath, String subscriptionName); -} +import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; + +public class ServiceBusClient { + + ServiceBusContract contract; + + public ServiceBusClient(ServiceBusContract contract) { + this.contract = contract; + } + + public ServiceBusContract getContract() { + return contract; + } + + public void setContract(ServiceBusContract contract) { + this.contract = contract; + } + + public Queue[] getQueues() { + QueueDescription[] descriptions = contract.getQueues(); + Queue[] queues = new Queue[descriptions.length]; + for (int i = 0; i != queues.length; ++i) { + queues[i] = new Queue(this, descriptions[i]); + } + return queues; + } + + public Queue getQueue(String path) { + return new Queue(this, path); + } + + public Queue createQueue(String path) { + Queue queue = new Queue(this, path); + queue.create(); + return queue; + } + + public Topic[] getTopics() { + return null; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java deleted file mode 100644 index 34a8a8e075098..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientBuilder.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -import com.microsoft.azure.http.ClientBuilderBase; - - -public class ServiceBusClientBuilder extends ClientBuilderBase { - public ServiceBusClient createClient() { - return new ServiceBusClientImpl(this.client, this.getUrl()); - } - public MessageTranceiver openQueue(String queuePath) { - return null; - } - public MessageSender openTopic(String topicPath) { - return null; - } - public MessageReceiver openSubscription(String topicPath, String subscriptionName) { - return null; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java new file mode 100644 index 0000000000000..e06239ff2db6a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.serviceBus; + +public class Subscription { + public Rule getRules() { + return null; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java new file mode 100644 index 0000000000000..e54297fdc961b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.serviceBus; + +public class Topic { + Subscription[] getSubscriptions() { + return null; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java new file mode 100644 index 0000000000000..640583fcc47c0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus.contract; + +public class BrokeredMessage { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java new file mode 100644 index 0000000000000..2bcf4f136ebc4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java @@ -0,0 +1,6 @@ +package com.microsoft.azure.services.serviceBus.contract; + +public enum ReceiveMode { + PEEK_LOCK, + RECEIVE_AND_DELETE, +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java new file mode 100644 index 0000000000000..1f076809003fb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -0,0 +1,31 @@ +package com.microsoft.azure.services.serviceBus.contract; + + +public interface ServiceBusContract { + void sendMessage(String path, BrokeredMessage message); + BrokeredMessage receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); + BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); + void abandonMessage(BrokeredMessage message); + void completeMessage(BrokeredMessage message); + + void createQueue(String queuePath, QueueDescription description); + void deleteQueue(String queuePath); + QueueDescription getQueue(String queuePath); + QueueDescription[] getQueues(); + + void createTopic(String topicPath, TopicDescription description); + void deleteTopic(String topicPath); + TopicDescription getTopic(String topicPath); + TopicDescription[] getTopics(); + + void addSubscription(String topicPath, String subscriptionName, SubscriptionDescription description); + void removeSubscription(String topicPath, String subscriptionName); + SubscriptionDescription getSubscription(String topicPath, String subscriptionName); + SubscriptionDescription[] getSubscriptions(String topicPath); + + void addRule(String topicPath, String subscriptionName, String ruleName, RuleDescription description); + void removeRule(String topicPath, String subscriptionName, String ruleName); + RuleDescription getRule(String topicPath, String subscriptionName, String ruleName); + RuleDescription [] getRules(String topicPath, String subscriptionName); +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java similarity index 73% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 8ab478aa7d43e..87bf058fbb8bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClientImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,19 +1,9 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.contract; -import java.net.URI; - -import com.microsoft.azure.http.ClientBase; -import com.microsoft.azure.services.serviceBus.model.QueueDescription; -import com.microsoft.azure.services.serviceBus.model.RuleDescription; -import com.microsoft.azure.services.serviceBus.model.SubscriptionDescription; -import com.microsoft.azure.services.serviceBus.model.TopicDescription; import com.sun.jersey.api.client.Client; -class ServiceBusClientImpl extends ClientBase implements ServiceBusClient { +public class ServiceBusContractImpl implements ServiceBusContract { - public ServiceBusClientImpl(Client client, URI url) { - super(client, url); - } public void sendMessage(String path, BrokeredMessage message) { // TODO Auto-generated method stub @@ -21,13 +11,13 @@ public void sendMessage(String path, BrokeredMessage message) { } public BrokeredMessage receiveMessage(String queuePath, int timeout, - RECEIVE_MODE receiveMode) { + ReceiveMode receiveMode) { // TODO Auto-generated method stub return null; } public BrokeredMessage receiveMessage(String topicPath, - String subscriptionName, int timeout, RECEIVE_MODE receiveMode) { + String subscriptionName, int timeout, ReceiveMode receiveMode) { // TODO Auto-generated method stub return null; } @@ -43,11 +33,11 @@ public void completeMessage(BrokeredMessage message) { } public void createQueue(String queuePath, QueueDescription description) { - resource().path(queuePath).put(description); + } public void deleteQueue(String queuePath) { - resource().path(queuePath).delete(); + } public QueueDescription getQueue(String queuePath) { diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 2a71b66ed69ad..2186c2e6219e7 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -4,7 +4,7 @@ jaxb:version="2.0"> - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java new file mode 100644 index 0000000000000..d692145940219 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java @@ -0,0 +1,22 @@ +package com.microsoft.azure.services.serviceBus; + +import org.junit.Test; + +import static org.junit.Assert.*; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; + + +public class ClientBuilderTest { + @Test + public void testServiceBusClientCreatedWithContractImpl() throws Exception { + Configuration config = new Configuration(); + + ServiceBusClient client = config.build(ServiceBusClient.class); + + assertNotNull(client); + assertNotNull(client.getContract()); + assertEquals(ServiceBusContractImpl.class, client.getContract().getClass()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java new file mode 100644 index 0000000000000..91350ba9df71e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java @@ -0,0 +1,17 @@ +package com.microsoft.azure.services.serviceBus.contract; + + +import static org.junit.Assert.*; +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; + +public class ContractBuilderTest { + @Test + public void testDefaultBuilderCreatesContractImpl() throws Exception { + Configuration config = new Configuration(); + ServiceBusContract contract = config.build(ServiceBusContract.class); + + assertNotNull(contract); + } +} From 41c5e8ffbbcc0d119bdc549948ffb4608526072a Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 17 Oct 2011 16:40:08 -0700 Subject: [PATCH 011/664] Experimenting with approaches --- microsoft-azure-api/pom.xml | 66 ++++++-- .../azure/configuration/Configuration.java | 62 +++++-- .../azure/configuration/DefaultBuilder.java | 51 ------ .../configuration/{ => builder}/Builder.java | 2 +- .../configuration/builder/BuilderModule.java | 5 + .../builder/BuilderRegistry.java | 10 ++ .../configuration/builder/DefaultBuilder.java | 73 ++++++++ .../azure/services/serviceBus/Entity.java | 56 +++++++ .../{BrokeredMessage.java => Message.java} | 2 +- .../azure/services/serviceBus/Module.java | 10 ++ .../azure/services/serviceBus/Queue.java | 74 +++++++-- .../services/serviceBus/ServiceBusClient.java | 25 ++- .../services/serviceBus/contract/Entry.java | 14 ++ .../serviceBus/contract/EntryModel.java | 34 ++++ .../contract/EntryModelProvider.java | 73 ++++++++ .../services/serviceBus/contract/Module.java | 10 ++ .../contract/ServiceBusContract.java | 24 +-- .../contract/ServiceBusContractImpl.java | 157 +++++++++++++++--- ....azure.configuration.builder.BuilderModule | 2 + .../src/main/resources/NewFile.xml | 27 +++ .../src/main/resources/package-names.xjb | 4 +- ...netservices.2010.10.servicebus.connect.xsd | 18 +- .../serviceBus/ClientBuilderTest.java | 20 +++ .../serviceBus/QueueManagementTest.java | 59 +++++++ .../QueueManagementIntegrationTest.java | 70 ++++++++ 25 files changed, 807 insertions(+), 141 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/{ => builder}/Builder.java (61%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{BrokeredMessage.java => Message.java} (63%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java create mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule create mode 100644 microsoft-azure-api/src/main/resources/NewFile.xml create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index fd1fc1424b304..c9728ca348379 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -6,6 +6,42 @@ Microsoft Azure Client API API for Microsoft Azure Clients + + + com.sun.jersey + jersey-client + 1.10-b02 + + + javax.xml.bind + jaxb-api + 2.1 + provided + + + junit + junit + 4.8 + test + + + org.mockito + mockito-all + test + 1.9.0-rc1 + + + javax.inject + javax.inject + 1 + + + com.sun.jersey + jersey-atom + 1.10-b03 + + + @@ -20,21 +56,23 @@ + + true + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.6.0 + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 0.6.0 + + + + - - - - com.sun.jersey - jersey-client - 1.10-b02 - - - junit - junit - 4.8 - test - - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 2048d98401d72..365bd3d0cd808 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -1,31 +1,73 @@ package com.microsoft.azure.configuration; +import java.util.ServiceLoader; + +import javax.inject.Provider; + +import com.microsoft.azure.configuration.builder.Builder; +import com.microsoft.azure.configuration.builder.BuilderModule; +import com.microsoft.azure.configuration.builder.DefaultBuilder; import com.microsoft.azure.services.serviceBus.ServiceBusClient; +import com.microsoft.azure.services.serviceBus.contract.EntryModelProvider; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.spi.service.ServiceFinder; public class Configuration implements Builder { private Builder builder; + protected ClientConfig clientConfig; public Configuration() { - setBuilder(getStandardComponentsBuilder()); + this.clientConfig = createDefaultClientConfig(); + try { + this.builder = createDefaultBuilder(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public Configuration(Builder builder) { - setBuilder(builder); + this.builder = builder; + } + + public static ClientConfig createDefaultClientConfig() { + return new DefaultClientConfig(EntryModelProvider.class); } - public static Builder getStandardComponentsBuilder() { - DefaultBuilder builder = new DefaultBuilder(); - builder.add(ServiceBusClient.class, ServiceBusClient.class, ServiceBusContract.class); - builder.add(ServiceBusContract.class, ServiceBusContractImpl.class); - builder.add(Client.class, Client.class); + Builder createDefaultBuilder() throws Exception { + + final DefaultBuilder builder = new DefaultBuilder(); + + for(BuilderModule module : ServiceLoader.load(BuilderModule.class)){ + module.register(builder); + } + + final Configuration self = this; + + builder.add(ClientConfig.class, new Provider(){ + public ClientConfig get() { + return self.clientConfig; + }}); + + builder.add(Client.class, new Provider(){ + public Client get() { + ClientConfig clientConfig = builder.build(ClientConfig.class); + return Client.create(clientConfig); + }}); + return builder; } + + public T build(Class c) throws Exception { + return builder.build(c); + } + public Builder getBuilder() { return builder; } @@ -33,9 +75,5 @@ public Builder getBuilder() { public void setBuilder(Builder builder) { this.builder = builder; } - - public T build(Class c) throws Exception { - return builder.build(c); - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java deleted file mode 100644 index 9e7e534bbcedb..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/DefaultBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.microsoft.azure.configuration; - -import java.lang.reflect.Constructor; -import java.util.HashMap; -import java.util.Map; - - -public class DefaultBuilder implements Builder { - public DefaultBuilder() { - factories = new HashMap, Factory>(); - } - - interface Factory { - T create() throws Exception; - } - - Map, Factory> factories; - - public Builder addFactory(Class service, Factory factory) { - factories.put(service, factory); - return this; - } - - public DefaultBuilder add(Class service, final Class implementation) { - addFactory(service, new Factory() { - public T create() throws Exception { - return implementation.newInstance(); - }}); - return this; - } - - public DefaultBuilder add(Class service, final Class implementation, final Class parameterType1) { - addFactory(service, new Factory() { - public T create() throws Exception { - final Constructor ctor = implementation.getConstructor(parameterType1); - return ctor.newInstance(build(parameterType1)); - }}); - return this; - } - - - public DefaultBuilder add(Class service) { - return add(service, service); - } - - - - public T build(Class c) throws Exception { - return (T) factories.get(c).create(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java similarity index 61% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 287e9597e6557..41089abba8189 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration; +package com.microsoft.azure.configuration.builder; public interface Builder { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java new file mode 100644 index 0000000000000..5a2f741a86080 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.configuration.builder; + +public interface BuilderModule { + void register(BuilderRegistry registry); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java new file mode 100644 index 0000000000000..96f9a6713f421 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.configuration.builder; + +import javax.inject.Provider; + + +public interface BuilderRegistry { + BuilderRegistry add(Class service); + BuilderRegistry add(Class service, Class implementation); + BuilderRegistry add(Class service, Provider provider); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java new file mode 100644 index 0000000000000..01e1f03b5de6c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -0,0 +1,73 @@ +package com.microsoft.azure.configuration.builder; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Provider; + + +public class DefaultBuilder implements Builder, BuilderRegistry { + public DefaultBuilder() { + factories = new HashMap, Provider>(); + } + + + Map, Provider> factories; + + public Builder addFactory(Class service, Provider factory) { + factories.put(service, factory); + return this; + } + + + public BuilderRegistry add(Class service, final Class implementation) { + Constructor[] ctors = implementation.getConstructors(); + for(final Constructor ctor : ctors) { + if (ctor.getAnnotation(Inject.class) != null) { + final Class[] parameterTypes = ctor.getParameterTypes(); + addFactory(service, new Provider() { + @SuppressWarnings("unchecked") + public T get() throws RuntimeException { + Object[] initargs = new Object[parameterTypes.length]; + for(int i = 0; i != parameterTypes.length; ++i) { + initargs[i] = build(parameterTypes[i]); + } + + try { + return (T) ctor.newInstance(initargs); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }}); + } + } + return this; + } + + public BuilderRegistry add(Class service) { + return add(service, service); + } + + public BuilderRegistry add(Class service, Provider provider) { + addFactory(service, provider); + return this; + } + + public T build(Class c) throws RuntimeException { + @SuppressWarnings("unchecked") + Provider factory = (Provider) factories.get(c); + if (factory == null) { + return null; + } + return factory.get(); + } + + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java new file mode 100644 index 0000000000000..768791e63615a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java @@ -0,0 +1,56 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.services.serviceBus.contract.EntryModel; +import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.sun.syndication.feed.atom.Entry; + +public class Entity { + + protected ServiceBusClient client; + private EntryModel entryModel; + + public Entity(ServiceBusClient client) { + this.client = client; + this.entryModel = new EntryModel(); + setEntry(new Entry()); + } + + public Entity(ServiceBusClient client, EntryModel entryModel) { + this.client = client; + this.entryModel = entryModel; + } + + protected ServiceBusClient getClient() { + return client; + } + + protected ServiceBusContract getContract() { + return getClient().getContract(); + } + + protected EntryModel getEntryModel() { + return entryModel; + } + + protected void setEntryModel(EntryModel entryModel) { + this.entryModel = entryModel; + } + + protected Entry getEntry() { + return getEntryModel().getEntry(); + } + + protected void setEntry(Entry entry) { + getEntryModel().setEntry(entry); + } + + protected T getModel() { + return getEntryModel().getModel(); + } + + protected void setModel(T model) { + getEntryModel().setModel(model); + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java similarity index 63% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 29dea80dd690e..1b9df243130f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -1,5 +1,5 @@ package com.microsoft.azure.services.serviceBus; -public class BrokeredMessage { +public class Message { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java new file mode 100644 index 0000000000000..d9d859efa83ca --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.configuration.builder.BuilderModule; +import com.microsoft.azure.configuration.builder.BuilderRegistry; + +public class Module implements BuilderModule { + public void register(BuilderRegistry registry) { + registry.add(ServiceBusClient.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 0fb9899a0f590..ddb627c0bdade 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -1,37 +1,41 @@ package com.microsoft.azure.services.serviceBus; +import javax.xml.datatype.Duration; + import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; +import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; +import com.sun.syndication.feed.atom.Entry; -public class Queue implements MessageSender, MessageReceiver { - private ServiceBusClient client; - private String path; - private QueueDescription description; - +public class Queue extends Entity implements MessageSender, MessageReceiver { public Queue(ServiceBusClient client, String path) { - this.client = client; - this.path = path; - } - - public Queue(ServiceBusClient client, QueueDescription queueDescription) { - this.client = client; + super(client); + setModel(new QueueDescription()); + setPath(path); } + + + // public object verbs + public void create() { - client.getContract().createQueue(path, description); + getContract().createQueue(getEntryModel()); } public void delete() { - client.getContract().deleteQueue(path); + getContract().deleteQueue(getPath()); + } + + public void get() { + setEntryModel(getContract().getQueue(getPath())); } public void commit() { - //TODO protocol operation to put data? + getContract().createQueue(getEntryModel()); } - public void send(BrokeredMessage message) { // TODO Auto-generated method stub @@ -49,7 +53,45 @@ public void abandon(BrokeredMessage message) { public void complete(BrokeredMessage message) { // TODO Auto-generated method stub - } + + + + // public object data + + public String getPath() { + return getEntry().getTitle(); + } + + public void setPath(String value) { + getEntry().setTitle(value); + } + + public Duration getLockDuration() { + return getModel().getLockDuration(); + } + + public void setLockDuration(Duration value) { + getModel().setLockDuration(value); + } + + public Long getMaxSizeInMegabytes() { + return getModel().getMaxSizeInMegabytes(); + } + + public void setMaxSizeInMegabytes(Long value) { + getModel().setMaxSizeInMegabytes(value); + } + + public Long getMessageCount() { + return getModel().getMessageCount(); + } + + + + //public void setMessageCount(Long value) { + // getDescription().setMessageCount(value); + //} + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 0d7200465ce2d..ed863f42267ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -1,5 +1,9 @@ package com.microsoft.azure.services.serviceBus; +import javax.inject.Inject; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; @@ -7,6 +11,14 @@ public class ServiceBusClient { ServiceBusContract contract; + public ServiceBusClient() { + } + + public ServiceBusClient(Configuration configuration) throws Exception { + this.contract = configuration.build(ServiceBusContract.class); + } + + @Inject public ServiceBusClient(ServiceBusContract contract) { this.contract = contract; } @@ -19,17 +31,20 @@ public void setContract(ServiceBusContract contract) { this.contract = contract; } - public Queue[] getQueues() { - QueueDescription[] descriptions = contract.getQueues(); - Queue[] queues = new Queue[descriptions.length]; + public Entity[] getQueues() { + EntryModel[] descriptions = contract.getQueues(); + Entity[] queues = new Entity[descriptions.length]; for (int i = 0; i != queues.length; ++i) { - queues[i] = new Queue(this, descriptions[i]); + queues[i] = new Queue(this, null); + queues[i].setEntryModel(descriptions[i]); } return queues; } public Queue getQueue(String path) { - return new Queue(this, path); + Queue queue = new Queue(this, path); + queue.setEntryModel(contract.getQueue(path)); + return queue; } public Queue createQueue(String path) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java new file mode 100644 index 0000000000000..aa4ef56df7981 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RuleDescription", propOrder = { + "filter", + "action" +}) +public class Entry { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java new file mode 100644 index 0000000000000..112db52f2a5df --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java @@ -0,0 +1,34 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import com.sun.syndication.feed.atom.Entry; + +public class EntryModel { + Entry entry; + T model; + + public EntryModel(){ + + } + + public EntryModel(Entry entry, T model) { + setEntry(entry); + setModel(model); + } + + public Entry getEntry() { + return entry; + } + + public void setEntry(Entry entry) { + this.entry = entry; + } + + public T getModel() { + return model; + } + + public void setModel(T model) { + this.model = model; + } +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java new file mode 100644 index 0000000000000..5a992151aeebf --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java @@ -0,0 +1,73 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyReader; +import javax.ws.rs.ext.Providers; + +import com.sun.jersey.core.impl.provider.entity.StringProvider; +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; +import com.sun.syndication.feed.atom.Content; +import com.sun.syndication.feed.atom.Entry; + +@Produces("application/atom+xml") +@Consumes("application/atom+xml") +public class EntryModelProvider extends AbstractMessageReaderWriterProvider> { + private Providers ps; + + public EntryModelProvider(@Context Providers ps){ + this.ps = ps; + } + + public boolean isReadable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + // TODO Auto-generated method stub + + return type == EntryModel.class; + } + + public EntryModel readFrom(Class> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + MessageBodyReader reader = ps.getMessageBodyReader(Entry.class, Entry.class, annotations, mediaType); + Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, mediaType, httpHeaders, entityStream); + + if (entry.getContents().size() == 1) { + Content content = (Content)entry.getContents().get(0); + MediaType entryType = MediaType.valueOf(content.getType()); + MessageBodyReader reader2 = ps.getMessageBodyReader(QueueDescription.class, QueueDescription.class, annotations, entryType); + String data = content.getValue(); + QueueDescription model = reader2.readFrom(QueueDescription.class, QueueDescription.class, annotations, entryType, httpHeaders, new ByteArrayInputStream(data.getBytes())); + return new EntryModel(entry, model); + } + return new EntryModel(entry, null); + } + + public boolean isWriteable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + // TODO Auto-generated method stub + return false; + } + + public void writeTo(EntryModel t, Class type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, + OutputStream entityStream) throws IOException, + WebApplicationException { + // TODO Auto-generated method stub + + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java new file mode 100644 index 0000000000000..32575221f20ce --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import com.microsoft.azure.configuration.builder.BuilderModule; +import com.microsoft.azure.configuration.builder.BuilderRegistry; + +public class Module implements BuilderModule { + public void register(BuilderRegistry registry) { + registry.add(ServiceBusContract.class, ServiceBusContractImpl.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index 1f076809003fb..23d807bdf0c5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -8,24 +8,24 @@ public interface ServiceBusContract { void abandonMessage(BrokeredMessage message); void completeMessage(BrokeredMessage message); - void createQueue(String queuePath, QueueDescription description); + void createQueue(EntryModel queue); void deleteQueue(String queuePath); - QueueDescription getQueue(String queuePath); - QueueDescription[] getQueues(); + EntryModel getQueue(String queuePath); + EntryModel[] getQueues(); - void createTopic(String topicPath, TopicDescription description); + void createTopic(EntryModel topic); void deleteTopic(String topicPath); - TopicDescription getTopic(String topicPath); - TopicDescription[] getTopics(); + EntryModel getTopic(String topicPath); + EntryModel[] getTopics(); - void addSubscription(String topicPath, String subscriptionName, SubscriptionDescription description); + void addSubscription(String topicPath, String subscriptionName, EntryModel subscription); void removeSubscription(String topicPath, String subscriptionName); - SubscriptionDescription getSubscription(String topicPath, String subscriptionName); - SubscriptionDescription[] getSubscriptions(String topicPath); + EntryModel getSubscription(String topicPath, String subscriptionName); + EntryModel[] getSubscriptions(String topicPath); - void addRule(String topicPath, String subscriptionName, String ruleName, RuleDescription description); + void addRule(String topicPath, String subscriptionName, String ruleName, EntryModel rule); void removeRule(String topicPath, String subscriptionName, String ruleName); - RuleDescription getRule(String topicPath, String subscriptionName, String ruleName); - RuleDescription [] getRules(String topicPath, String subscriptionName); + EntryModel getRule(String topicPath, String subscriptionName, String ruleName); + EntryModel [] getRules(String topicPath, String subscriptionName); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 87bf058fbb8bc..15f8228d170ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,9 +1,50 @@ package com.microsoft.azure.services.serviceBus.contract; +import javax.inject.Inject; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + import com.sun.jersey.api.client.Client; +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.GenericType; +import com.sun.jersey.api.client.filter.ClientFilter; +import com.sun.jersey.api.representation.Form; +import com.sun.syndication.feed.atom.Entry; public class ServiceBusContractImpl implements ServiceBusContract { + public class AtomFilter extends ClientFilter { + + @Override + public ClientResponse handle(ClientRequest cr) + throws ClientHandlerException { + + return getNext().handle(cr); + } + + } + + private Client channel; + + @Inject + public ServiceBusContractImpl(Client channel) { + channel.addFilter(new AtomFilter()); + this.setChannel(channel); + } + + + public Client getChannel() { + return channel; + } + + + + public void setChannel(Client channel) { + this.channel = channel; + } + public void sendMessage(String path, BrokeredMessage message) { // TODO Auto-generated method stub @@ -32,23 +73,48 @@ public void completeMessage(BrokeredMessage message) { } - public void createQueue(String queuePath, QueueDescription description) { + public void createQueue(EntryModel entryModel) { + Form form = new Form(); + form.add("wrap_name", "owner"); + form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); + + Form wrapResponse = getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") + .path("WRAPv0.9") + .post(Form.class, form); + String accessToken = wrapResponse.get("wrap_access_token").get(0); + Entry entry = new Entry(); + getChannel().resource("https://lodejard.servicebus.windows.net/") + .path(entryModel.getEntry().getTitle()) + .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") + .type("application/atom+xml") + .put(entry); } public void deleteQueue(String queuePath) { } - public QueueDescription getQueue(String queuePath) { - // TODO Auto-generated method stub - return null; + public EntryModel getQueue(String queuePath) { + Form form = new Form(); + form.add("wrap_name", "owner"); + form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); + + Form wrapResponse = getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") + .path("WRAPv0.9") + .post(Form.class, form); + String accessToken = wrapResponse.get("wrap_access_token").get(0); + + GenericType> genericType = new GenericType>() { }; + + return getChannel().resource("https://lodejard.servicebus.windows.net/") + .path(queuePath) + .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") + .get(genericType); } - public QueueDescription[] getQueues() { - // TODO Auto-generated method stub - return null; - } public void createTopic(String topicPath, TopicDescription description) { // TODO Auto-generated method stub @@ -60,57 +126,96 @@ public void deleteTopic(String topicPath) { } - public TopicDescription getTopic(String topicPath) { + + public void addSubscription(String topicPath, String subscriptionName, + SubscriptionDescription description) { // TODO Auto-generated method stub - return null; + } - public TopicDescription[] getTopics() { + public void removeSubscription(String topicPath, String subscriptionName) { // TODO Auto-generated method stub - return null; + } - public void addSubscription(String topicPath, String subscriptionName, - SubscriptionDescription description) { + + public void addRule(String topicPath, String subscriptionName, + String ruleName, RuleDescription description) { // TODO Auto-generated method stub } - public void removeSubscription(String topicPath, String subscriptionName) { + public void removeRule(String topicPath, String subscriptionName, + String ruleName) { // TODO Auto-generated method stub } - public SubscriptionDescription getSubscription(String topicPath, - String subscriptionName) { + + + + + public void createTopic(EntryModel topic) { // TODO Auto-generated method stub - return null; + } - public SubscriptionDescription[] getSubscriptions(String topicPath) { + + public void addSubscription(String topicPath, String subscriptionName, + EntryModel subscription) { // TODO Auto-generated method stub - return null; + } + public void addRule(String topicPath, String subscriptionName, - String ruleName, RuleDescription description) { + String ruleName, EntryModel rule) { // TODO Auto-generated method stub + + } + + public EntryModel[] getQueues() { + // TODO Auto-generated method stub + return null; } - public void removeRule(String topicPath, String subscriptionName, - String ruleName) { + + public EntryModel getTopic(String topicPath) { // TODO Auto-generated method stub + return null; + } + + public EntryModel[] getTopics() { + // TODO Auto-generated method stub + return null; } - public RuleDescription getRule(String topicPath, String subscriptionName, - String ruleName) { + + public EntryModel getSubscription( + String topicPath, String subscriptionName) { // TODO Auto-generated method stub return null; } - public RuleDescription[] getRules(String topicPath, String subscriptionName) { + + public EntryModel[] getSubscriptions( + String topicPath) { + // TODO Auto-generated method stub + return null; + } + + + public EntryModel getRule(String topicPath, + String subscriptionName, String ruleName) { + // TODO Auto-generated method stub + return null; + } + + + public EntryModel[] getRules(String topicPath, + String subscriptionName) { // TODO Auto-generated method stub return null; } diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule new file mode 100644 index 0000000000000..28dbf44a5c9cd --- /dev/null +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule @@ -0,0 +1,2 @@ +com.microsoft.azure.services.serviceBus.Module +com.microsoft.azure.services.serviceBus.contract.Module diff --git a/microsoft-azure-api/src/main/resources/NewFile.xml b/microsoft-azure-api/src/main/resources/NewFile.xml new file mode 100644 index 0000000000000..3e6ab48c01130 --- /dev/null +++ b/microsoft-azure-api/src/main/resources/NewFile.xml @@ -0,0 +1,27 @@ + + https://lodejard.servicebus.windows.net/Hello + Hello + 2011-10-04T23:09:57Z + 2011-10-04T23:09:57Z + + lodejard + + + + + PT1M + 1024 + false + false + P10675199DT2H48M5S + false + PT10M + 10 + true + 0 + 0 + + + diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 2186c2e6219e7..15083b0bf49a1 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -1,7 +1,9 @@ + xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" + jaxb:version="2.0" + jaxb:extensionBindingPrefixes="xjc"> diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index 825aaf965fb3b..eb30b07d7f800 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -4,7 +4,21 @@ xmlns:tns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" - xmlns:xs="http://www.w3.org/2001/XMLSchema"> + xmlns:xs="http://www.w3.org/2001/XMLSchema" + + xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + jaxb:version="1.0" + xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" + jaxb:extensionBindingPrefixes="xjc"> + + + + + + + + + @@ -14,7 +28,7 @@ - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java index d692145940219..7f146e446937f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java @@ -1,5 +1,10 @@ package com.microsoft.azure.services.serviceBus; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; + import org.junit.Test; import static org.junit.Assert.*; @@ -11,12 +16,27 @@ public class ClientBuilderTest { @Test public void testServiceBusClientCreatedWithContractImpl() throws Exception { + // Arrange Configuration config = new Configuration(); + // Act ServiceBusClient client = config.build(ServiceBusClient.class); + ServiceBusClient client2 = new ServiceBusClient(config); + // Assert assertNotNull(client); assertNotNull(client.getContract()); assertEquals(ServiceBusContractImpl.class, client.getContract().getClass()); + + assertNotNull(client2); + assertNotNull(client2.getContract()); + assertEquals(ServiceBusContractImpl.class, client2.getContract().getClass()); + } + + @Test + public void testHttp404() throws Exception { + HttpURLConnection x = (HttpURLConnection)new URL("http://github.com/no-such-file").openConnection(); + int code = x.getResponseCode(); + assertEquals(404, code); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java new file mode 100644 index 0000000000000..77ef04de8bfb3 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java @@ -0,0 +1,59 @@ +package com.microsoft.azure.services.serviceBus; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; + +import org.junit.Test; +import org.mockito.ArgumentCaptor; + +import com.microsoft.azure.services.serviceBus.contract.EntryModel; +import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.sun.syndication.feed.atom.Entry; + + +public class QueueManagementTest { + @Test + public void testGetQueueAcquiresDescriptionFromServer() { + // Arrange + ServiceBusContract contract = mock(ServiceBusContract.class); + + EntryModel entryModel = new EntryModel(new Entry(), new QueueDescription()); + when(contract.getQueue("Hello")).thenReturn(entryModel); + + entryModel.getModel().setMessageCount(73L); + + // Act + ServiceBusClient client = new ServiceBusClient(contract); + Queue helloQueue = client.getQueue("Hello"); + + // Assert + assertEquals(73, helloQueue.getMessageCount().longValue()); + } + + @Test + public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException { + // Arrange + ServiceBusContract contract = mock(ServiceBusContract.class); + + // Act + ServiceBusClient client = new ServiceBusClient(contract); + Queue helloQueue = new Queue(client, "MyNewQueue"); + helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); + helloQueue.setMaxSizeInMegabytes(42L); + helloQueue.commit(); + + // Assert + ArgumentCaptor createArg = ArgumentCaptor.forClass(EntryModel.class); + verify(contract).createQueue(createArg.capture()); + Entry entry = createArg.getValue().getEntry(); + QueueDescription model = (QueueDescription) createArg.getValue().getModel(); + + assertEquals("MyNewQueue", entry.getTitle()); + assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); + assertEquals(42, model.getMaxSizeInMegabytes().longValue()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java new file mode 100644 index 0000000000000..5ab52d28e9b24 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java @@ -0,0 +1,70 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.Entity; +import com.microsoft.azure.services.serviceBus.Queue; +import com.microsoft.azure.services.serviceBus.ServiceBusClient; +import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; +import com.sun.jersey.api.client.filter.LoggingFilter; + + + +public class QueueManagementIntegrationTest { + @Test + public void queueCanBeCreatedAndDeleted() throws Exception { + // Arrange + ServiceBusClient client = new Configuration() + .build(ServiceBusClient.class); + ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); + contract.getChannel().addFilter(new LoggingFilter()); + + // Act + Queue queue = client.createQueue("TestQueue01"); + queue.delete(); + + // Assert + } + + @Test + public void notFoundQueuePathReturnsNull() throws Exception { + // Arrange + Configuration cfg = new Configuration(); + + ServiceBusClient client = cfg.build(ServiceBusClient.class); + + + ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); + contract.getChannel().addFilter(new LoggingFilter()); + + // Act + Queue queue = client.getQueue("NoSuchQueueName"); + + // Assert + Assert.assertNull(queue); + } + + + @Test + public void existingQueuePathDoesNotReturnNull() throws Exception { + // Arrange + ServiceBusClient client = new Configuration() + .build(ServiceBusClient.class); + + ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); + contract.getChannel().addFilter(new LoggingFilter()); + //contract.getChannel().getProviders(). + + //client.createQueue("TestQueue02"); + + // Act + Queue queue = client.getQueue("Hello"); + + // Assert + Assert.assertNotNull(queue); + Assert.assertEquals("TestQueue02", queue.getPath()); + } +} From 87b3226d570d9c47c742a708abfb1468fcf2d385 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 17 Oct 2011 16:59:16 -0700 Subject: [PATCH 012/664] Refactoring a little to cleanup --- .../azure/configuration/Configuration.java | 8 ++--- .../azure/configuration/builder/Builder.java | 11 ++++++ .../configuration/builder/BuilderModule.java | 5 --- .../builder/BuilderRegistry.java | 10 ------ .../configuration/builder/DefaultBuilder.java | 8 ++--- .../azure/services/serviceBus/Exports.java | 9 +++++ .../services/serviceBus/MessageReceiver.java | 9 +++-- .../services/serviceBus/MessageSender.java | 3 +- .../azure/services/serviceBus/Module.java | 10 ------ .../azure/services/serviceBus/Queue.java | 35 ++++++++++++------- .../services/serviceBus/ServiceBusClient.java | 4 +-- .../services/serviceBus/contract/Exports.java | 9 +++++ .../services/serviceBus/contract/Module.java | 10 ------ ...zure.configuration.builder.Builder$Exports | 2 ++ ....azure.configuration.builder.BuilderModule | 2 -- 15 files changed, 66 insertions(+), 69 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java create mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports delete mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 365bd3d0cd808..368f12721282e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -5,15 +5,11 @@ import javax.inject.Provider; import com.microsoft.azure.configuration.builder.Builder; -import com.microsoft.azure.configuration.builder.BuilderModule; import com.microsoft.azure.configuration.builder.DefaultBuilder; -import com.microsoft.azure.services.serviceBus.ServiceBusClient; import com.microsoft.azure.services.serviceBus.contract.EntryModelProvider; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.spi.service.ServiceFinder; public class Configuration implements Builder { @@ -43,8 +39,8 @@ Builder createDefaultBuilder() throws Exception { final DefaultBuilder builder = new DefaultBuilder(); - for(BuilderModule module : ServiceLoader.load(BuilderModule.class)){ - module.register(builder); + for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)){ + exports.register(builder); } final Configuration self = this; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 41089abba8189..57719866f203b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -1,7 +1,18 @@ package com.microsoft.azure.configuration.builder; +import javax.inject.Provider; + public interface Builder { public abstract T build(Class c) throws Exception; + public interface Exports { + void register(Registry registry); + } + + public interface Registry { + Registry add(Class service); + Registry add(Class service, Class implementation); + Registry add(Class service, Provider provider); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java deleted file mode 100644 index 5a2f741a86080..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderModule.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.configuration.builder; - -public interface BuilderModule { - void register(BuilderRegistry registry); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java deleted file mode 100644 index 96f9a6713f421..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/BuilderRegistry.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.microsoft.azure.configuration.builder; - -import javax.inject.Provider; - - -public interface BuilderRegistry { - BuilderRegistry add(Class service); - BuilderRegistry add(Class service, Class implementation); - BuilderRegistry add(Class service, Provider provider); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index 01e1f03b5de6c..990413155667f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -9,7 +9,7 @@ import javax.inject.Provider; -public class DefaultBuilder implements Builder, BuilderRegistry { +public class DefaultBuilder implements Builder, Builder.Registry { public DefaultBuilder() { factories = new HashMap, Provider>(); } @@ -23,7 +23,7 @@ public Builder addFactory(Class service, Provider factory) { } - public BuilderRegistry add(Class service, final Class implementation) { + public Builder.Registry add(Class service, final Class implementation) { Constructor[] ctors = implementation.getConstructors(); for(final Constructor ctor : ctors) { if (ctor.getAnnotation(Inject.class) != null) { @@ -51,11 +51,11 @@ public T get() throws RuntimeException { return this; } - public BuilderRegistry add(Class service) { + public Builder.Registry add(Class service) { return add(service, service); } - public BuilderRegistry add(Class service, Provider provider) { + public Builder.Registry add(Class service, Provider provider) { addFactory(service, provider); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java new file mode 100644 index 0000000000000..5af49c37c86c8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -0,0 +1,9 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(ServiceBusClient.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index aacc5e67d7721..fd8153e2113f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -1,10 +1,9 @@ package com.microsoft.azure.services.serviceBus; -import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; -import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; public interface MessageReceiver { - BrokeredMessage receive(int timeout, ReceiveMode receiveMode); - void abandon(BrokeredMessage message); - void complete(BrokeredMessage message); + Message receive(int timeout); + Message peekLock(int timeout); + void abandon(Message message); + void complete(Message message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java index 42626882d1211..d0ae248bb08d9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.serviceBus; -import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; public interface MessageSender { - void send(BrokeredMessage message); + void send(Message message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java deleted file mode 100644 index d9d859efa83ca..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Module.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -import com.microsoft.azure.configuration.builder.BuilderModule; -import com.microsoft.azure.configuration.builder.BuilderRegistry; - -public class Module implements BuilderModule { - public void register(BuilderRegistry registry) { - registry.add(ServiceBusClient.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index ddb627c0bdade..c1c630ea1d650 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -2,11 +2,7 @@ import javax.xml.datatype.Duration; -import com.microsoft.azure.services.serviceBus.contract.BrokeredMessage; -import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; -import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; -import com.sun.syndication.feed.atom.Entry; public class Queue extends Entity implements MessageSender, MessageReceiver { public Queue(ServiceBusClient client, String path) { @@ -36,27 +32,42 @@ public void commit() { getContract().createQueue(getEntryModel()); } - public void send(BrokeredMessage message) { + + + public void send(Message message) { // TODO Auto-generated method stub - } + } - public BrokeredMessage receive(int timeout, ReceiveMode receiveMode) { + public Message receive(int timeout) { + // TODO Auto-generated method stub + return null; + } + + + + public Message peekLock(int timeout) { // TODO Auto-generated method stub return null; } - public void abandon(BrokeredMessage message) { + + + public void abandon(Message message) { // TODO Auto-generated method stub } - public void complete(BrokeredMessage message) { + + + public void complete(Message message) { // TODO Auto-generated method stub + } - + + // public object data public String getPath() { @@ -89,9 +100,7 @@ public Long getMessageCount() { - //public void setMessageCount(Long value) { - // getDescription().setMessageCount(value); - //} + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index ed863f42267ae..4bde864665794 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -31,9 +31,9 @@ public void setContract(ServiceBusContract contract) { this.contract = contract; } - public Entity[] getQueues() { + public Queue[] getQueues() { EntryModel[] descriptions = contract.getQueues(); - Entity[] queues = new Entity[descriptions.length]; + Queue[] queues = new Queue[descriptions.length]; for (int i = 0; i != queues.length; ++i) { queues[i] = new Queue(this, null); queues[i].setEntryModel(descriptions[i]); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java new file mode 100644 index 0000000000000..0cf1264c5caed --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java @@ -0,0 +1,9 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import com.microsoft.azure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(ServiceBusContract.class, ServiceBusContractImpl.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java deleted file mode 100644 index 32575221f20ce..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Module.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import com.microsoft.azure.configuration.builder.BuilderModule; -import com.microsoft.azure.configuration.builder.BuilderRegistry; - -public class Module implements BuilderModule { - public void register(BuilderRegistry registry) { - registry.add(ServiceBusContract.class, ServiceBusContractImpl.class); - } -} diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports new file mode 100644 index 0000000000000..a03cb6444614e --- /dev/null +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -0,0 +1,2 @@ +com.microsoft.azure.services.serviceBus.Exports +com.microsoft.azure.services.serviceBus.contract.Exports diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule deleted file mode 100644 index 28dbf44a5c9cd..0000000000000 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.BuilderModule +++ /dev/null @@ -1,2 +0,0 @@ -com.microsoft.azure.services.serviceBus.Module -com.microsoft.azure.services.serviceBus.contract.Module From 09467a395bf156e8321e0a2d6c5f6041cbad2fa4 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 17 Oct 2011 22:16:05 -0700 Subject: [PATCH 013/664] Breaking up Jersey configuration a little better --- .../azure/configuration/Configuration.java | 55 ++++++++++--------- .../azure/configuration/builder/Builder.java | 37 +++++++++++-- .../configuration/builder/DefaultBuilder.java | 30 ++++------ .../azure/configuration/jersey/Exports.java | 20 +++++++ ...zure.configuration.builder.Builder$Exports | 1 + 5 files changed, 93 insertions(+), 50 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 368f12721282e..1db57d7bfdaea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -1,5 +1,7 @@ package com.microsoft.azure.configuration; +import java.util.HashMap; +import java.util.Map; import java.util.ServiceLoader; import javax.inject.Provider; @@ -12,56 +14,42 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; -public class Configuration implements Builder { +public class Configuration { private Builder builder; - protected ClientConfig clientConfig; + Map properties; + public Configuration() { - this.clientConfig = createDefaultClientConfig(); - try { - this.builder = createDefaultBuilder(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + this.properties = new HashMap(); + this.builder = createDefaultBuilder(); + setProperty("ClientConfig", createDefaultClientConfig()); } public Configuration(Builder builder) { + this.properties = new HashMap(); this.builder = builder; + setProperty("ClientConfig", createDefaultClientConfig()); } public static ClientConfig createDefaultClientConfig() { return new DefaultClientConfig(EntryModelProvider.class); } - Builder createDefaultBuilder() throws Exception { + Builder createDefaultBuilder() { final DefaultBuilder builder = new DefaultBuilder(); - for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)){ + for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { exports.register(builder); } - - final Configuration self = this; - builder.add(ClientConfig.class, new Provider(){ - public ClientConfig get() { - return self.clientConfig; - }}); - - builder.add(Client.class, new Provider(){ - public Client get() { - ClientConfig clientConfig = builder.build(ClientConfig.class); - return Client.create(clientConfig); - }}); - return builder; } public T build(Class c) throws Exception { - return builder.build(c); + return builder.build(c, getProperties()); } public Builder getBuilder() { @@ -71,5 +59,20 @@ public Builder getBuilder() { public void setBuilder(Builder builder) { this.builder = builder; } - + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Object getProperty(String name) { + return getProperties().get(name); + } + + public void setProperty(String name, Object value) { + getProperties().put(name, value); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 57719866f203b..6f0410a98ab75 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -1,18 +1,45 @@ package com.microsoft.azure.configuration.builder; -import javax.inject.Provider; +import java.util.Map; + +/** + * Builder interface used internally by Configuration to create component instances + * + */ public interface Builder { - public abstract T build(Class c) throws Exception; + /** + * Called by configuration when a component needs to be allocated + * @param service + * @param properties + * @return + * @throws Exception + */ + public abstract T build(Class service, Map properties) throws Exception; - public interface Exports { - void register(Registry registry); + /** + * @author lodejard + * + * @param + */ + public interface Factory { + /** + * @param builder + * @param properties + * @return + * @throws Exception + */ + T create(Builder builder, Map properties) throws Exception; } public interface Registry { Registry add(Class service); Registry add(Class service, Class implementation); - Registry add(Class service, Provider provider); + Registry add(Class service, Factory factory); + } + + public interface Exports { + void register(Registry registry); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index 990413155667f..4eca6e1056e52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -11,13 +11,13 @@ public class DefaultBuilder implements Builder, Builder.Registry { public DefaultBuilder() { - factories = new HashMap, Provider>(); + factories = new HashMap, Factory>(); } - Map, Provider> factories; + Map, Factory> factories; - public Builder addFactory(Class service, Provider factory) { + public Builder addFactory(Class service, Factory factory) { factories.put(service, factory); return this; } @@ -28,23 +28,15 @@ public Builder.Registry add(Class service, final Class impl for(final Constructor ctor : ctors) { if (ctor.getAnnotation(Inject.class) != null) { final Class[] parameterTypes = ctor.getParameterTypes(); - addFactory(service, new Provider() { + addFactory(service, new Builder.Factory() { @SuppressWarnings("unchecked") - public T get() throws RuntimeException { + public T create(Builder builder, Map properties) throws Exception { Object[] initargs = new Object[parameterTypes.length]; for(int i = 0; i != parameterTypes.length; ++i) { - initargs[i] = build(parameterTypes[i]); + initargs[i] = builder.build(parameterTypes[i], properties); } - try { - return (T) ctor.newInstance(initargs); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + return (T) ctor.newInstance(initargs); }}); } } @@ -55,18 +47,18 @@ public Builder.Registry add(Class service) { return add(service, service); } - public Builder.Registry add(Class service, Provider provider) { + public Builder.Registry add(Class service, Factory provider) { addFactory(service, provider); return this; } - public T build(Class c) throws RuntimeException { + public T build(Class service, Map properties) throws Exception { @SuppressWarnings("unchecked") - Provider factory = (Provider) factories.get(c); + Factory factory = (Factory) factories.get(service); if (factory == null) { return null; } - return factory.get(); + return factory.create(this, properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java new file mode 100644 index 0000000000000..b9f3fe64ea5fd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -0,0 +1,20 @@ +package com.microsoft.azure.configuration.jersey; + +import java.util.Map; + +import com.microsoft.azure.configuration.builder.Builder; +import com.microsoft.azure.configuration.builder.Builder.Registry; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; + +public class Exports implements Builder.Exports { + + public void register(Registry registry) { + registry.add(Client.class, new Builder.Factory() { + public Client create(Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + return Client.create(clientConfig); + } + }); + } +} diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index a03cb6444614e..8cdde57cd1617 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,2 +1,3 @@ +com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports com.microsoft.azure.services.serviceBus.contract.Exports From 6ea822783ab9de8c8bd3d3eebda2a15540093e95 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 17 Oct 2011 23:32:34 -0700 Subject: [PATCH 014/664] General cleanup Removing the Class for service in Builder.Registry when Factory is being passed in --- .../azure/configuration/Configuration.java | 51 ++++--------------- .../azure/configuration/builder/Builder.java | 24 +-------- .../configuration/builder/DefaultBuilder.java | 49 +++++++++++++----- .../azure/configuration/jersey/Exports.java | 2 +- .../azure/services/serviceBus/Entity.java | 1 - .../services/serviceBus/ServiceBusClient.java | 2 +- .../contract/EntryModelProvider.java | 1 - .../contract/ServiceBusContractImpl.java | 3 -- .../serviceBus/ClientBuilderTest.java | 5 +- .../contract/ContractBuilderTest.java | 2 +- .../QueueManagementIntegrationTest.java | 6 +-- 11 files changed, 53 insertions(+), 93 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 1db57d7bfdaea..ecd773454f570 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -2,77 +2,46 @@ import java.util.HashMap; import java.util.Map; -import java.util.ServiceLoader; - -import javax.inject.Provider; - import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.configuration.builder.DefaultBuilder; import com.microsoft.azure.services.serviceBus.contract.EntryModelProvider; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; public class Configuration { - private Builder builder; Map properties; - + Builder builder; public Configuration() { this.properties = new HashMap(); - this.builder = createDefaultBuilder(); - setProperty("ClientConfig", createDefaultClientConfig()); + this.builder = DefaultBuilder.create(); + init(); } public Configuration(Builder builder) { this.properties = new HashMap(); this.builder = builder; - setProperty("ClientConfig", createDefaultClientConfig()); + init(); } - public static ClientConfig createDefaultClientConfig() { - return new DefaultClientConfig(EntryModelProvider.class); + private void init() { + setProperty("ClientConfig", new DefaultClientConfig(EntryModelProvider.class)); } - Builder createDefaultBuilder() { - - final DefaultBuilder builder = new DefaultBuilder(); - - for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { - exports.register(builder); - } - - return builder; - } - - - public T build(Class c) throws Exception { - return builder.build(c, getProperties()); + public T create(Class service) throws Exception { + return builder.build(service, properties); } public Builder getBuilder() { return builder; } - public void setBuilder(Builder builder) { - this.builder = builder; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - public Object getProperty(String name) { - return getProperties().get(name); + return properties.get(name); } public void setProperty(String name, Object value) { - getProperties().put(name, value); + properties.put(name, value); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 6f0410a98ab75..99792ff31c2a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -3,40 +3,18 @@ import java.util.Map; -/** - * Builder interface used internally by Configuration to create component instances - * - */ public interface Builder { - /** - * Called by configuration when a component needs to be allocated - * @param service - * @param properties - * @return - * @throws Exception - */ public abstract T build(Class service, Map properties) throws Exception; - /** - * @author lodejard - * - * @param - */ public interface Factory { - /** - * @param builder - * @param properties - * @return - * @throws Exception - */ T create(Builder builder, Map properties) throws Exception; } public interface Registry { Registry add(Class service); Registry add(Class service, Class implementation); - Registry add(Class service, Factory factory); + Registry add(Factory factory); } public interface Exports { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index 4eca6e1056e52..fb7b20720c4be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -1,26 +1,41 @@ package com.microsoft.azure.configuration.builder; import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; +import java.util.ServiceLoader; import javax.inject.Inject; -import javax.inject.Provider; + public class DefaultBuilder implements Builder, Builder.Registry { + Map, Factory> factories; + public DefaultBuilder() { factories = new HashMap, Factory>(); } - - Map, Factory> factories; - - public Builder addFactory(Class service, Factory factory) { + public static DefaultBuilder create() { + DefaultBuilder builder = new DefaultBuilder(); + + for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { + exports.register(builder); + } + + return builder; + } + + void addFactory(Class service, Factory factory) { factories.put(service, factory); - return this; } + + public Builder.Registry add(Class service) { + return add(service, service); + } + public Builder.Registry add(Class service, final Class implementation) { @@ -42,15 +57,20 @@ public T create(Builder builder, Map properties) throws Exception } return this; } - - public Builder.Registry add(Class service) { - return add(service, service); - } - - public Builder.Registry add(Class service, Factory provider) { - addFactory(service, provider); + + + public Registry add(Factory factory) { + for(Type genericInterface : factory.getClass().getGenericInterfaces()) + { + ParameterizedType parameterizedType = (ParameterizedType) genericInterface; + if (parameterizedType.getRawType().equals(Builder.Factory.class)) { + Type typeArgument = parameterizedType.getActualTypeArguments()[0]; + addFactory((Class)typeArgument, factory); + } + } return this; } + public T build(Class service, Map properties) throws Exception { @SuppressWarnings("unchecked") @@ -62,4 +82,5 @@ public T build(Class service, Map properties) throws Excep } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java index b9f3fe64ea5fd..43dfe5ea593cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -10,7 +10,7 @@ public class Exports implements Builder.Exports { public void register(Registry registry) { - registry.add(Client.class, new Builder.Factory() { + registry.add(new Builder.Factory() { public Client create(Builder builder, Map properties) { ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); return Client.create(clientConfig); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java index 768791e63615a..3181c96bea3a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.serviceBus; import com.microsoft.azure.services.serviceBus.contract.EntryModel; -import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; import com.sun.syndication.feed.atom.Entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 4bde864665794..55cd43fe29736 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -15,7 +15,7 @@ public ServiceBusClient() { } public ServiceBusClient(Configuration configuration) throws Exception { - this.contract = configuration.build(ServiceBusContract.class); + this.contract = configuration.create(ServiceBusContract.class); } @Inject diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java index 5a992151aeebf..1d427deec3417 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java @@ -16,7 +16,6 @@ import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.Providers; -import com.sun.jersey.core.impl.provider.entity.StringProvider; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.syndication.feed.atom.Content; import com.sun.syndication.feed.atom.Entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 15f8228d170ac..5a38024427089 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,9 +1,6 @@ package com.microsoft.azure.services.serviceBus.contract; import javax.inject.Inject; -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; - import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java index 7f146e446937f..b9e66c0070f26 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java @@ -1,10 +1,7 @@ package com.microsoft.azure.services.serviceBus; -import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLConnection; - import org.junit.Test; import static org.junit.Assert.*; @@ -20,7 +17,7 @@ public void testServiceBusClientCreatedWithContractImpl() throws Exception { Configuration config = new Configuration(); // Act - ServiceBusClient client = config.build(ServiceBusClient.class); + ServiceBusClient client = config.create(ServiceBusClient.class); ServiceBusClient client2 = new ServiceBusClient(config); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java index 91350ba9df71e..22433eb557e4f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java @@ -10,7 +10,7 @@ public class ContractBuilderTest { @Test public void testDefaultBuilderCreatesContractImpl() throws Exception { Configuration config = new Configuration(); - ServiceBusContract contract = config.build(ServiceBusContract.class); + ServiceBusContract contract = config.create(ServiceBusContract.class); assertNotNull(contract); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java index 5ab52d28e9b24..d4f357293723a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java @@ -18,7 +18,7 @@ public class QueueManagementIntegrationTest { public void queueCanBeCreatedAndDeleted() throws Exception { // Arrange ServiceBusClient client = new Configuration() - .build(ServiceBusClient.class); + .create(ServiceBusClient.class); ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); contract.getChannel().addFilter(new LoggingFilter()); @@ -34,7 +34,7 @@ public void notFoundQueuePathReturnsNull() throws Exception { // Arrange Configuration cfg = new Configuration(); - ServiceBusClient client = cfg.build(ServiceBusClient.class); + ServiceBusClient client = cfg.create(ServiceBusClient.class); ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); @@ -52,7 +52,7 @@ public void notFoundQueuePathReturnsNull() throws Exception { public void existingQueuePathDoesNotReturnNull() throws Exception { // Arrange ServiceBusClient client = new Configuration() - .build(ServiceBusClient.class); + .create(ServiceBusClient.class); ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); contract.getChannel().addFilter(new LoggingFilter()); From 23a2d9ceb8b70165f5b95cab2ca04158945704b5 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 18 Oct 2011 15:16:08 -0700 Subject: [PATCH 015/664] Adding a service exception --- .../com/microsoft/azure/ServiceException.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java new file mode 100644 index 0000000000000..a3bafff167a1e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java @@ -0,0 +1,47 @@ +package com.microsoft.azure; +import java.util.Map; + + +public class ServiceException extends Exception { + int httpStatusCode; + String httpReasonPhrase; + + String errorCode; + String errorMessage; + Map errorValues; + + public ServiceException() { + + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + public String getHttpReasonPhrase() { + return httpReasonPhrase; + } + public void setHttpReasonPhrase(String httpReasonPhrase) { + this.httpReasonPhrase = httpReasonPhrase; + } + public String getErrorCode() { + return errorCode; + } + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + public String getErrorMessage() { + return errorMessage; + } + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + public Map getErrorValues() { + return errorValues; + } + public void setErrorValues(Map errorValues) { + this.errorValues = errorValues; + } +} From 166fe9eab08adb2363df7a91e1f9b20c114d4f12 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 19 Oct 2011 14:59:11 -0700 Subject: [PATCH 016/664] Adding Configuration singleton methods Also adding a static load placeholder --- .../azure/configuration/Configuration.java | 19 ++++++++++++++++++- .../services/serviceBus/ServiceBusClient.java | 7 ++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index ecd773454f570..0fd619c94c87e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -10,6 +10,7 @@ public class Configuration { + private static Configuration instance; Map properties; Builder builder; @@ -28,7 +29,23 @@ public Configuration(Builder builder) { private void init() { setProperty("ClientConfig", new DefaultClientConfig(EntryModelProvider.class)); } - + + public static Configuration getInstance() { + if (instance == null) { + setInstance(load()); + } + return instance; + } + + public static void setInstance(Configuration instance) { + Configuration.instance = instance; + } + + public static Configuration load() { + // TODO - load from somewhere + return new Configuration(); + } + public T create(Class service) throws Exception { return builder.build(service, properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 55cd43fe29736..8fafd5c6d003e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -11,11 +11,12 @@ public class ServiceBusClient { ServiceBusContract contract; - public ServiceBusClient() { + public ServiceBusClient() throws Exception { + this(Configuration.getInstance()); } - public ServiceBusClient(Configuration configuration) throws Exception { - this.contract = configuration.create(ServiceBusContract.class); + public ServiceBusClient(Configuration config) throws Exception { + this(config.create(ServiceBusContract.class)); } @Inject From 4097cb8508cdd9f8ebf2f26e30a6ee21c7860b10 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 19 Oct 2011 15:17:02 -0700 Subject: [PATCH 017/664] Changes to ServiceBusClient to conform to guidelines Iterable listXxx for enumerable Xxx getXxx() to return an uninitialized entity --- .../services/serviceBus/MessageReceiver.java | 8 +++--- .../services/serviceBus/MessageSender.java | 2 +- .../azure/services/serviceBus/Queue.java | 12 ++++----- .../services/serviceBus/ServiceBusClient.java | 25 ++++++++----------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index fd8153e2113f4..836e214bdc88a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -2,8 +2,8 @@ public interface MessageReceiver { - Message receive(int timeout); - Message peekLock(int timeout); - void abandon(Message message); - void complete(Message message); + Message receiveMessage(int timeout); + Message peekLockMessage(int timeout); + void abandonMessage(Message message); + void completeMessage(Message message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java index d0ae248bb08d9..38cce540f8774 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -2,5 +2,5 @@ public interface MessageSender { - void send(Message message); + void sendMessage(Message message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index c1c630ea1d650..77fd707eb6b9a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -5,7 +5,7 @@ import com.microsoft.azure.services.serviceBus.contract.QueueDescription; public class Queue extends Entity implements MessageSender, MessageReceiver { - public Queue(ServiceBusClient client, String path) { + Queue(ServiceBusClient client, String path) { super(client); setModel(new QueueDescription()); @@ -34,33 +34,33 @@ public void commit() { - public void send(Message message) { + public void sendMessage(Message message) { // TODO Auto-generated method stub } - public Message receive(int timeout) { + public Message receiveMessage(int timeout) { // TODO Auto-generated method stub return null; } - public Message peekLock(int timeout) { + public Message peekLockMessage(int timeout) { // TODO Auto-generated method stub return null; } - public void abandon(Message message) { + public void abandonMessage(Message message) { // TODO Auto-generated method stub } - public void complete(Message message) { + public void completeMessage(Message message) { // TODO Auto-generated method stub } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 8fafd5c6d003e..ff8d896006355 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -1,5 +1,8 @@ package com.microsoft.azure.services.serviceBus; + +import java.util.ArrayList; + import javax.inject.Inject; import com.microsoft.azure.configuration.Configuration; @@ -32,29 +35,21 @@ public void setContract(ServiceBusContract contract) { this.contract = contract; } - public Queue[] getQueues() { + public Iterable listQueues() { EntryModel[] descriptions = contract.getQueues(); - Queue[] queues = new Queue[descriptions.length]; - for (int i = 0; i != queues.length; ++i) { - queues[i] = new Queue(this, null); - queues[i].setEntryModel(descriptions[i]); + ArrayList queues = new ArrayList(); + for (int i = 0; i != descriptions.length; ++i) { + queues.set(i, new Queue(this, null)); + queues.get(i).setEntryModel(descriptions[i]); } return queues; } public Queue getQueue(String path) { - Queue queue = new Queue(this, path); - queue.setEntryModel(contract.getQueue(path)); - return queue; - } - - public Queue createQueue(String path) { - Queue queue = new Queue(this, path); - queue.create(); - return queue; + return new Queue(this, path); } - public Topic[] getTopics() { + public Iterable listTopics() { return null; } } From 5f212c45b3a1cf84aaf7f7f3f40f7dd01db3daec Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 19 Oct 2011 15:33:40 -0700 Subject: [PATCH 018/664] Updating state transfer methods on Queue. Updating test methods --- .../azure/services/serviceBus/Queue.java | 19 ++++++------------- .../serviceBus/QueueManagementTest.java | 3 ++- .../QueueManagementIntegrationTest.java | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 77fd707eb6b9a..bf8a11f0bdc02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -16,7 +16,7 @@ public class Queue extends Entity implements MessageSender, Me // public object verbs - public void create() { + public void save() { getContract().createQueue(getEntryModel()); } @@ -24,13 +24,9 @@ public void delete() { getContract().deleteQueue(getPath()); } - public void get() { + public void fetch() { setEntryModel(getContract().getQueue(getPath())); } - - public void commit() { - getContract().createQueue(getEntryModel()); - } @@ -44,22 +40,19 @@ public Message receiveMessage(int timeout) { return null; } - - + public Message peekLockMessage(int timeout) { // TODO Auto-generated method stub return null; } - - + public void abandonMessage(Message message) { // TODO Auto-generated method stub } - - + public void completeMessage(Message message) { // TODO Auto-generated method stub @@ -68,7 +61,7 @@ public void completeMessage(Message message) { - // public object data + // entity state properties public String getPath() { return getEntry().getTitle(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java index 77ef04de8bfb3..d127e61005952 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java @@ -29,6 +29,7 @@ public void testGetQueueAcquiresDescriptionFromServer() { // Act ServiceBusClient client = new ServiceBusClient(contract); Queue helloQueue = client.getQueue("Hello"); + helloQueue.fetch(); // Assert assertEquals(73, helloQueue.getMessageCount().longValue()); @@ -44,7 +45,7 @@ public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfi Queue helloQueue = new Queue(client, "MyNewQueue"); helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); helloQueue.setMaxSizeInMegabytes(42L); - helloQueue.commit(); + helloQueue.save(); // Assert ArgumentCaptor createArg = ArgumentCaptor.forClass(EntryModel.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java index d4f357293723a..704932ae45f21 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java @@ -23,7 +23,7 @@ public void queueCanBeCreatedAndDeleted() throws Exception { contract.getChannel().addFilter(new LoggingFilter()); // Act - Queue queue = client.createQueue("TestQueue01"); + Queue queue = client.getQueue("TestQueue01"); queue.delete(); // Assert From 7331ad76795544b3239467ddabe7da3ca92fd49f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 19 Oct 2011 15:34:03 -0700 Subject: [PATCH 019/664] Adding standard Exception ctors to ServiceException --- .../com/microsoft/azure/ServiceException.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java index a3bafff167a1e..0f3caec7db896 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java @@ -1,8 +1,12 @@ package com.microsoft.azure; +import java.util.HashMap; import java.util.Map; public class ServiceException extends Exception { + + private static final long serialVersionUID = -4942076377009150131L; + int httpStatusCode; String httpReasonPhrase; @@ -11,9 +15,29 @@ public class ServiceException extends Exception { Map errorValues; public ServiceException() { - + init(); + } + + public ServiceException(String message) { + super(message); + init(); + } + + public ServiceException(String message, Throwable cause) { + super(message, cause); + init(); } + public ServiceException(Throwable cause) { + super(cause); + init(); + } + + private void init() { + errorValues = new HashMap(); + } + + public int getHttpStatusCode() { return httpStatusCode; } @@ -44,4 +68,10 @@ public Map getErrorValues() { public void setErrorValues(Map errorValues) { this.errorValues = errorValues; } + public String getErrorValue(String name) { + return errorValues.get(name); + } + public void setErrorValue(String name, String value) { + this.errorValues.put(name, value); + } } From 12f70b31012ed12f6a0e18f25eb30a3481b96507 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 19 Oct 2011 17:13:44 -0700 Subject: [PATCH 020/664] Intermediate state - changing atom implementation details --- microsoft-azure-api/pom.xml | 5 ---- .../azure/services/serviceBus/Entity.java | 30 +++++-------------- .../azure/services/serviceBus/Queue.java | 10 +++++-- .../services/serviceBus/ServiceBusClient.java | 8 +++-- .../contract/ServiceBusContract.java | 9 ++++-- .../contract/ServiceBusContractImpl.java | 18 ++++++----- .../src/main/resources/atom.xsd | 30 +++++++++++++++++++ 7 files changed, 67 insertions(+), 43 deletions(-) create mode 100644 microsoft-azure-api/src/main/resources/atom.xsd diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index c9728ca348379..6a317c974e9c7 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -35,11 +35,6 @@ javax.inject 1 - - com.sun.jersey - jersey-atom - 1.10-b03 - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java index 3181c96bea3a1..8f369058ec5b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java @@ -1,23 +1,23 @@ package com.microsoft.azure.services.serviceBus; +import org.w3._2005.atom.Entry; + import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; -import com.sun.syndication.feed.atom.Entry; public class Entity { protected ServiceBusClient client; - private EntryModel entryModel; + private Entry entry; public Entity(ServiceBusClient client) { this.client = client; - this.entryModel = new EntryModel(); - setEntry(new Entry()); + setEntry(new org.w3._2005.atom.Entry()); } - public Entity(ServiceBusClient client, EntryModel entryModel) { + public Entity(ServiceBusClient client, Entry entry) { this.client = client; - this.entryModel = entryModel; + this.entry = entry; } protected ServiceBusClient getClient() { @@ -28,28 +28,14 @@ protected ServiceBusContract getContract() { return getClient().getContract(); } - protected EntryModel getEntryModel() { - return entryModel; - } - - protected void setEntryModel(EntryModel entryModel) { - this.entryModel = entryModel; - } protected Entry getEntry() { - return getEntryModel().getEntry(); + return entry; } protected void setEntry(Entry entry) { - getEntryModel().setEntry(entry); + this.entry = entry; } - protected T getModel() { - return getEntryModel().getModel(); - } - - protected void setModel(T model) { - getEntryModel().setModel(model); - } } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index bf8a11f0bdc02..5528656e7b42d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -2,11 +2,17 @@ import javax.xml.datatype.Duration; +import org.w3._2005.atom.Content; + import com.microsoft.azure.services.serviceBus.contract.QueueDescription; public class Queue extends Entity implements MessageSender, MessageReceiver { Queue(ServiceBusClient client, String path) { super(client); + + Content content = new Content(); + content.setQueueDescription(new QueueDescription()); + getEntry().setContent(content); setModel(new QueueDescription()); setPath(path); @@ -17,7 +23,7 @@ public class Queue extends Entity implements MessageSender, Me // public object verbs public void save() { - getContract().createQueue(getEntryModel()); +// getContract().createQueue(getEntryModel()); } public void delete() { @@ -25,7 +31,7 @@ public void delete() { } public void fetch() { - setEntryModel(getContract().getQueue(getPath())); +// setEntryModel(getContract().getQueue(getPath())); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index ff8d896006355..b9a18b82853f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -5,6 +5,8 @@ import javax.inject.Inject; +import org.w3._2005.atom.Feed; + import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; @@ -36,11 +38,11 @@ public void setContract(ServiceBusContract contract) { } public Iterable listQueues() { - EntryModel[] descriptions = contract.getQueues(); + Feed descriptions = contract.getQueues(); ArrayList queues = new ArrayList(); - for (int i = 0; i != descriptions.length; ++i) { + for (int i = 0; i != descriptions.getEntries().size(); ++i) { queues.set(i, new Queue(this, null)); - queues.get(i).setEntryModel(descriptions[i]); + queues.get(i).setEntryModel(descriptions.getEntries().get(i)); } return queues; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index 23d807bdf0c5d..daf6df0bd9d40 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -1,5 +1,8 @@ package com.microsoft.azure.services.serviceBus.contract; +import org.w3._2005.atom.Entry; +import org.w3._2005.atom.Feed; + public interface ServiceBusContract { void sendMessage(String path, BrokeredMessage message); @@ -8,10 +11,10 @@ public interface ServiceBusContract { void abandonMessage(BrokeredMessage message); void completeMessage(BrokeredMessage message); - void createQueue(EntryModel queue); + void createQueue(Entry queue); void deleteQueue(String queuePath); - EntryModel getQueue(String queuePath); - EntryModel[] getQueues(); + Entry getQueue(String queuePath); + Feed getQueues(); void createTopic(EntryModel topic); void deleteTopic(String topicPath); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 5a38024427089..da46332ef0387 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,6 +1,10 @@ package com.microsoft.azure.services.serviceBus.contract; import javax.inject.Inject; + +import org.w3._2005.atom.Entry; +import org.w3._2005.atom.Feed; + import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; @@ -8,7 +12,6 @@ import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.filter.ClientFilter; import com.sun.jersey.api.representation.Form; -import com.sun.syndication.feed.atom.Entry; public class ServiceBusContractImpl implements ServiceBusContract { @@ -70,7 +73,7 @@ public void completeMessage(BrokeredMessage message) { } - public void createQueue(EntryModel entryModel) { + public void createQueue(Entry entry) { Form form = new Form(); form.add("wrap_name", "owner"); form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); @@ -81,9 +84,8 @@ public void createQueue(EntryModel entryModel) { .post(Form.class, form); String accessToken = wrapResponse.get("wrap_access_token").get(0); - Entry entry = new Entry(); getChannel().resource("https://lodejard.servicebus.windows.net/") - .path(entryModel.getEntry().getTitle()) + .path(entry.getTitle()) .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") .type("application/atom+xml") .put(entry); @@ -93,7 +95,7 @@ public void deleteQueue(String queuePath) { } - public EntryModel getQueue(String queuePath) { + public Entry getQueue(String queuePath) { Form form = new Form(); form.add("wrap_name", "owner"); form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); @@ -104,12 +106,12 @@ public EntryModel getQueue(String queuePath) { .post(Form.class, form); String accessToken = wrapResponse.get("wrap_access_token").get(0); - GenericType> genericType = new GenericType>() { }; + //GenericType> genericType = new GenericType>() { }; return getChannel().resource("https://lodejard.servicebus.windows.net/") .path(queuePath) .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - .get(genericType); + .get(Entry.class); } @@ -172,7 +174,7 @@ public void addRule(String topicPath, String subscriptionName, } - public EntryModel[] getQueues() { + public Feed getQueues() { // TODO Auto-generated method stub return null; } diff --git a/microsoft-azure-api/src/main/resources/atom.xsd b/microsoft-azure-api/src/main/resources/atom.xsd new file mode 100644 index 0000000000000..261397c9d4da4 --- /dev/null +++ b/microsoft-azure-api/src/main/resources/atom.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + From 89b2664f3c6121e446302d575d68d8ca85ba8fb3 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 20 Oct 2011 17:11:07 -0700 Subject: [PATCH 021/664] Trying to get simpler atom PUT working for QueueDescription --- .../azure/configuration/Configuration.java | 3 +- .../azure/services/serviceBus/Entity.java | 3 +- .../azure/services/serviceBus/Queue.java | 24 ++++-- .../services/serviceBus/ServiceBusClient.java | 5 +- .../services/serviceBus/contract/Entry.java | 14 ---- .../serviceBus/contract/EntryModel.java | 34 --------- .../contract/EntryModelProvider.java | 72 ------------------ .../contract/ServiceBusContract.java | 18 ++--- .../contract/ServiceBusContractImpl.java | 76 ++++++++----------- .../src/main/resources/NewFile.xml | 27 ------- .../src/main/resources/atom.xsd | 44 ++++++----- .../serviceBus/QueueManagementTest.java | 24 +++--- .../QueueManagementIntegrationTest.java | 59 +++++++++++++- .../src/test/resources/NewFile.xml | 1 + 14 files changed, 154 insertions(+), 250 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java delete mode 100644 microsoft-azure-api/src/main/resources/NewFile.xml create mode 100644 microsoft-azure-api/src/test/resources/NewFile.xml diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 0fd619c94c87e..d4d24e676af2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -4,7 +4,6 @@ import java.util.Map; import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.configuration.builder.DefaultBuilder; -import com.microsoft.azure.services.serviceBus.contract.EntryModelProvider; import com.sun.jersey.api.client.config.DefaultClientConfig; @@ -27,7 +26,7 @@ public Configuration(Builder builder) { } private void init() { - setProperty("ClientConfig", new DefaultClientConfig(EntryModelProvider.class)); + setProperty("ClientConfig", new DefaultClientConfig()); } public static Configuration getInstance() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java index 8f369058ec5b6..dcaee33cb908b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java @@ -1,8 +1,8 @@ package com.microsoft.azure.services.serviceBus; +import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; -import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; public class Entity { @@ -13,6 +13,7 @@ public class Entity { public Entity(ServiceBusClient client) { this.client = client; setEntry(new org.w3._2005.atom.Entry()); + getEntry().setContent(new Content()); } public Entity(ServiceBusClient client, Entry entry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 5528656e7b42d..3a655465b659d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -3,6 +3,7 @@ import javax.xml.datatype.Duration; import org.w3._2005.atom.Content; +import org.w3._2005.atom.Entry; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; @@ -11,19 +12,26 @@ public class Queue extends Entity implements MessageSender, Me super(client); Content content = new Content(); + content.setType("application/xml"); content.setQueueDescription(new QueueDescription()); getEntry().setContent(content); - setModel(new QueueDescription()); setPath(path); } + public Queue(ServiceBusClient client, Entry entry) { + super(client, entry); + } + + QueueDescription getQueueDescription(){ + return getEntry().getContent().getQueueDescription(); + } // public object verbs public void save() { -// getContract().createQueue(getEntryModel()); + getContract().createQueue(getEntry()); } public void delete() { @@ -31,7 +39,7 @@ public void delete() { } public void fetch() { -// setEntryModel(getContract().getQueue(getPath())); + setEntry(getContract().getQueue(getPath())); } @@ -78,23 +86,23 @@ public void setPath(String value) { } public Duration getLockDuration() { - return getModel().getLockDuration(); + return getQueueDescription().getLockDuration(); } public void setLockDuration(Duration value) { - getModel().setLockDuration(value); + getQueueDescription().setLockDuration(value); } public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); + return getQueueDescription().getMaxSizeInMegabytes(); } public void setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); + getQueueDescription().setMaxSizeInMegabytes(value); } public Long getMessageCount() { - return getModel().getMessageCount(); + return getQueueDescription().getMessageCount(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index b9a18b82853f7..755fb3d628844 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -8,8 +8,6 @@ import org.w3._2005.atom.Feed; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.contract.EntryModel; -import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; public class ServiceBusClient { @@ -41,8 +39,7 @@ public Iterable listQueues() { Feed descriptions = contract.getQueues(); ArrayList queues = new ArrayList(); for (int i = 0; i != descriptions.getEntries().size(); ++i) { - queues.set(i, new Queue(this, null)); - queues.get(i).setEntryModel(descriptions.getEntries().get(i)); + queues.set(i, new Queue(this, descriptions.getEntries().get(i))); } return queues; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java deleted file mode 100644 index aa4ef56df7981..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Entry.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlType; - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RuleDescription", propOrder = { - "filter", - "action" -}) -public class Entry { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java deleted file mode 100644 index 112db52f2a5df..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModel.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import com.sun.syndication.feed.atom.Entry; - -public class EntryModel { - Entry entry; - T model; - - public EntryModel(){ - - } - - public EntryModel(Entry entry, T model) { - setEntry(entry); - setModel(model); - } - - public Entry getEntry() { - return entry; - } - - public void setEntry(Entry entry) { - this.entry = entry; - } - - public T getModel() { - return model; - } - - public void setModel(T model) { - this.model = model; - } -} - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java deleted file mode 100644 index 1d427deec3417..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/EntryModelProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.Providers; - -import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; -import com.sun.syndication.feed.atom.Content; -import com.sun.syndication.feed.atom.Entry; - -@Produces("application/atom+xml") -@Consumes("application/atom+xml") -public class EntryModelProvider extends AbstractMessageReaderWriterProvider> { - private Providers ps; - - public EntryModelProvider(@Context Providers ps){ - this.ps = ps; - } - - public boolean isReadable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { - // TODO Auto-generated method stub - - return type == EntryModel.class; - } - - public EntryModel readFrom(Class> type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { - - MessageBodyReader reader = ps.getMessageBodyReader(Entry.class, Entry.class, annotations, mediaType); - Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, mediaType, httpHeaders, entityStream); - - if (entry.getContents().size() == 1) { - Content content = (Content)entry.getContents().get(0); - MediaType entryType = MediaType.valueOf(content.getType()); - MessageBodyReader reader2 = ps.getMessageBodyReader(QueueDescription.class, QueueDescription.class, annotations, entryType); - String data = content.getValue(); - QueueDescription model = reader2.readFrom(QueueDescription.class, QueueDescription.class, annotations, entryType, httpHeaders, new ByteArrayInputStream(data.getBytes())); - return new EntryModel(entry, model); - } - return new EntryModel(entry, null); - } - - public boolean isWriteable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { - // TODO Auto-generated method stub - return false; - } - - public void writeTo(EntryModel t, Class type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, - OutputStream entityStream) throws IOException, - WebApplicationException { - // TODO Auto-generated method stub - - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index daf6df0bd9d40..72ec0ed2a254c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -16,19 +16,19 @@ public interface ServiceBusContract { Entry getQueue(String queuePath); Feed getQueues(); - void createTopic(EntryModel topic); + void createTopic(Entry topic); void deleteTopic(String topicPath); - EntryModel getTopic(String topicPath); - EntryModel[] getTopics(); + Entry getTopic(String topicPath); + Feed getTopics(); - void addSubscription(String topicPath, String subscriptionName, EntryModel subscription); + void addSubscription(String topicPath, String subscriptionName, Entry subscription); void removeSubscription(String topicPath, String subscriptionName); - EntryModel getSubscription(String topicPath, String subscriptionName); - EntryModel[] getSubscriptions(String topicPath); + Entry getSubscription(String topicPath, String subscriptionName); + Feed getSubscriptions(String topicPath); - void addRule(String topicPath, String subscriptionName, String ruleName, EntryModel rule); + void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule); void removeRule(String topicPath, String subscriptionName, String ruleName); - EntryModel getRule(String topicPath, String subscriptionName, String ruleName); - EntryModel [] getRules(String topicPath, String subscriptionName); + Entry getRule(String topicPath, String subscriptionName, String ruleName); + Feed getRules(String topicPath, String subscriptionName); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index da46332ef0387..73e3e94e40755 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -87,7 +87,7 @@ public void createQueue(Entry entry) { getChannel().resource("https://lodejard.servicebus.windows.net/") .path(entry.getTitle()) .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - .type("application/atom+xml") + .type("application/atom+xml;type=entry;charset=utf-8") .put(entry); } @@ -115,108 +115,92 @@ public Entry getQueue(String queuePath) { } - public void createTopic(String topicPath, TopicDescription description) { - // TODO Auto-generated method stub - - } - - public void deleteTopic(String topicPath) { + public Feed getQueues() { // TODO Auto-generated method stub - + return null; } - public void addSubscription(String topicPath, String subscriptionName, - SubscriptionDescription description) { + public void createTopic(Entry topic) { // TODO Auto-generated method stub - - } - - public void removeSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - + } - public void addRule(String topicPath, String subscriptionName, - String ruleName, RuleDescription description) { + public void deleteTopic(String topicPath) { // TODO Auto-generated method stub - + } - public void removeRule(String topicPath, String subscriptionName, - String ruleName) { - // TODO Auto-generated method stub + public Entry getTopic(String topicPath) { + // TODO Auto-generated method stub + return null; } - - - - public void createTopic(EntryModel topic) { + public Feed getTopics() { // TODO Auto-generated method stub - + return null; } public void addSubscription(String topicPath, String subscriptionName, - EntryModel subscription) { + Entry subscription) { // TODO Auto-generated method stub } - public void addRule(String topicPath, String subscriptionName, - String ruleName, EntryModel rule) { + public void removeSubscription(String topicPath, String subscriptionName) { // TODO Auto-generated method stub } - public Feed getQueues() { + public Entry getSubscription(String topicPath, String subscriptionName) { // TODO Auto-generated method stub return null; } - public EntryModel getTopic(String topicPath) { + public Feed getSubscriptions(String topicPath) { // TODO Auto-generated method stub return null; } - public EntryModel[] getTopics() { + public void addRule(String topicPath, String subscriptionName, + String ruleName, Entry rule) { // TODO Auto-generated method stub - return null; + } - public EntryModel getSubscription( - String topicPath, String subscriptionName) { + public void removeRule(String topicPath, String subscriptionName, + String ruleName) { // TODO Auto-generated method stub - return null; + } - public EntryModel[] getSubscriptions( - String topicPath) { + public Entry getRule(String topicPath, String subscriptionName, + String ruleName) { // TODO Auto-generated method stub return null; } - public EntryModel getRule(String topicPath, - String subscriptionName, String ruleName) { + public Feed getRules(String topicPath, String subscriptionName) { // TODO Auto-generated method stub return null; } - public EntryModel[] getRules(String topicPath, - String subscriptionName) { - // TODO Auto-generated method stub - return null; - } + + + + + } diff --git a/microsoft-azure-api/src/main/resources/NewFile.xml b/microsoft-azure-api/src/main/resources/NewFile.xml deleted file mode 100644 index 3e6ab48c01130..0000000000000 --- a/microsoft-azure-api/src/main/resources/NewFile.xml +++ /dev/null @@ -1,27 +0,0 @@ - - https://lodejard.servicebus.windows.net/Hello - Hello - 2011-10-04T23:09:57Z - 2011-10-04T23:09:57Z - - lodejard - - - - - PT1M - 1024 - false - false - P10675199DT2H48M5S - false - PT10M - 10 - true - 0 - 0 - - - diff --git a/microsoft-azure-api/src/main/resources/atom.xsd b/microsoft-azure-api/src/main/resources/atom.xsd index 261397c9d4da4..86c57ae40bd51 100644 --- a/microsoft-azure-api/src/main/resources/atom.xsd +++ b/microsoft-azure-api/src/main/resources/atom.xsd @@ -1,30 +1,34 @@ - - - + + + - - + + + - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java index d127e61005952..0435dad089192 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java @@ -8,11 +8,11 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; +import org.w3._2005.atom.Content; +import org.w3._2005.atom.Entry; -import com.microsoft.azure.services.serviceBus.contract.EntryModel; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; -import com.sun.syndication.feed.atom.Entry; public class QueueManagementTest { @@ -21,10 +21,12 @@ public void testGetQueueAcquiresDescriptionFromServer() { // Arrange ServiceBusContract contract = mock(ServiceBusContract.class); - EntryModel entryModel = new EntryModel(new Entry(), new QueueDescription()); - when(contract.getQueue("Hello")).thenReturn(entryModel); + Entry entry = new Entry(); + when(contract.getQueue("Hello")).thenReturn(entry); - entryModel.getModel().setMessageCount(73L); + entry.setContent(new Content()); + entry.getContent().setQueueDescription(new QueueDescription()); + entry.getContent().getQueueDescription().setMessageCount(73L); // Act ServiceBusClient client = new ServiceBusClient(contract); @@ -39,19 +41,19 @@ public void testGetQueueAcquiresDescriptionFromServer() { public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException { // Arrange ServiceBusContract contract = mock(ServiceBusContract.class); - + // Act ServiceBusClient client = new ServiceBusClient(contract); - Queue helloQueue = new Queue(client, "MyNewQueue"); + Queue helloQueue = client.getQueue("MyNewQueue"); helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); helloQueue.setMaxSizeInMegabytes(42L); helloQueue.save(); // Assert - ArgumentCaptor createArg = ArgumentCaptor.forClass(EntryModel.class); - verify(contract).createQueue(createArg.capture()); - Entry entry = createArg.getValue().getEntry(); - QueueDescription model = (QueueDescription) createArg.getValue().getModel(); + ArgumentCaptor argument = ArgumentCaptor.forClass(Entry.class); + verify(contract).createQueue(argument.capture()); + Entry entry = argument.getValue(); + QueueDescription model = entry.getContent().getQueueDescription(); assertEquals("MyNewQueue", entry.getTitle()); assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java index 704932ae45f21..e895ad667adad 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java @@ -1,5 +1,11 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; + import junit.framework.Assert; import org.junit.Test; @@ -10,6 +16,7 @@ import com.microsoft.azure.services.serviceBus.ServiceBusClient; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; import com.sun.jersey.api.client.filter.LoggingFilter; +import com.sun.jersey.api.representation.Form; @@ -21,14 +28,61 @@ public void queueCanBeCreatedAndDeleted() throws Exception { .create(ServiceBusClient.class); ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); contract.getChannel().addFilter(new LoggingFilter()); + + /* + String message = readResourceFile("NewFile.xml"); + + Form form = new Form(); + form.add("wrap_name", "owner"); + form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); + Form wrapResponse = contract.getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") + .path("WRAPv0.9") + .post(Form.class, form); + String accessToken = wrapResponse.get("wrap_access_token").get(0); + + + contract.getChannel().resource("https://lodejard.servicebus.windows.net/") + .path("Hello") + .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") + //.type("application/atom+xml") + .get(String.class); + + contract.getChannel().resource("https://lodejard.servicebus.windows.net/") + .path("Hello") + .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") + .type("application/atom+xml") + .accept("application/atom+xml") + .put(message); +*/ // Act - Queue queue = client.getQueue("TestQueue01"); + Queue queue = client.getQueue("Hello"); + queue.fetch(); + queue.setPath("TestQueue01"); + queue.save(); queue.delete(); // Assert } + public static String readResourceFile(String name) throws IOException { + InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + + StringBuffer sb = new StringBuffer(1024); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + + char[] chars = new char[1024]; + int numRead = 0; + while( (numRead = reader.read(chars)) > -1){ + sb.append(String.valueOf(chars)); + } + + reader.close(); + + return sb.toString(); + } + @Test public void notFoundQueuePathReturnsNull() throws Exception { // Arrange @@ -62,9 +116,10 @@ public void existingQueuePathDoesNotReturnNull() throws Exception { // Act Queue queue = client.getQueue("Hello"); + queue.fetch(); // Assert Assert.assertNotNull(queue); - Assert.assertEquals("TestQueue02", queue.getPath()); + Assert.assertEquals("Hello", queue.getPath()); } } diff --git a/microsoft-azure-api/src/test/resources/NewFile.xml b/microsoft-azure-api/src/test/resources/NewFile.xml new file mode 100644 index 0000000000000..7b3ea8dffd232 --- /dev/null +++ b/microsoft-azure-api/src/test/resources/NewFile.xml @@ -0,0 +1 @@ +PT1M1024falsefalseP10675199DT2H48M5SfalsePT10M10true00 From 6b1ace231e3cd969592820ea66912922862b0e9f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Sat, 22 Oct 2011 18:16:10 -0700 Subject: [PATCH 022/664] Adding maven reference to jersey-json artifact --- microsoft-azure-api/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 6a317c974e9c7..df0af93f2d3ed 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -35,6 +35,11 @@ javax.inject 1 + + com.sun.jersey + jersey-json + 1.10-b02 + From 7886764e018a6d9e03a06c310d7c251466fb2f07 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Sat, 22 Oct 2011 18:20:20 -0700 Subject: [PATCH 023/664] Adding implementation for serviceBus Maturing the Builder as needed Using various Configuration properties for serviceBus and wrapClient Adds a WrapFilter which will always acquire a token Uses JAXB Feed/Entity/Content classes from xsd for serviceBus mgmt ops Initial support for major queue mgmt operations Initial support for POST/DELETE message operations --- .../microsoft/azure/auth/wrap/Exports.java | 16 ++ .../microsoft/azure/auth/wrap/WrapClient.java | 47 +++++ .../microsoft/azure/auth/wrap/WrapFilter.java | 26 +++ .../auth/wrap/contract/WrapContract.java | 5 + .../auth/wrap/contract/WrapContractImpl.java | 33 ++++ .../auth/wrap/contract/WrapResponse.java | 31 ++++ .../azure/configuration/Configuration.java | 20 +- .../azure/configuration/builder/Builder.java | 6 + .../configuration/builder/DefaultBuilder.java | 98 ++++++++-- .../azure/configuration/jersey/Exports.java | 12 +- .../{Entity.java => AbstractEntity.java} | 24 +-- .../azure/services/serviceBus/Queue.java | 22 +-- .../services/serviceBus/ReceiveMode.java | 6 - .../services/serviceBus/ServiceBusClient.java | 2 +- .../serviceBus/contract/BrokerProperties.java | 75 ++++++++ .../contract/BrokerPropertiesMapper.java | 55 ++++++ .../serviceBus/contract/BrokeredMessage.java | 5 - .../services/serviceBus/contract/Exports.java | 26 +++ .../contract/MarshallerProvider.java | 54 ++++++ .../serviceBus/contract/MessageResult.java | 34 ++++ .../contract/NamespacePrefixMapperImpl.java | 18 ++ .../contract/ServiceBusContract.java | 14 +- .../contract/ServiceBusContractImpl.java | 175 +++++++----------- ...zure.configuration.builder.Builder$Exports | 1 + ...netservices.2010.10.servicebus.connect.xsd | 6 +- .../{atom.xsd => servicebus-atom.xsd} | 7 +- .../auth/wrap/WrapClientIntegrationTest.java | 32 ++++ .../contract/WrapContractIntegrationTest.java | 21 +++ .../builder/AlterClassWithProperties.java | 13 ++ .../ClassWithMultipleCtorMultipleInject.java | 10 + .../ClassWithMultipleCtorNoInject.java | 8 + .../builder/ClassWithNamedParameter.java | 22 +++ .../builder/ClassWithProperties.java | 36 ++++ .../builder/ClassWithSingleCtorNoInject.java | 7 + .../builder/DefaultBuilderTest.java | 113 +++++++++++ .../serviceBus/QueueManagementTest.java | 10 +- .../contract/BrokerPropertiesMapperTest.java | 19 ++ .../contract/ContractIntegrationTest.java | 100 ++++++++++ .../QueueManagementIntegrationTest.java | 163 ++++++++-------- .../src/test/resources/NewFile.xml | 5 +- 40 files changed, 1107 insertions(+), 270 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{Entity.java => AbstractEntity.java} (66%) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java rename microsoft-azure-api/src/main/resources/{atom.xsd => servicebus-atom.xsd} (89%) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java new file mode 100644 index 0000000000000..e5c1ba053b5f0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java @@ -0,0 +1,16 @@ +package com.microsoft.azure.auth.wrap; + +import com.microsoft.azure.auth.wrap.contract.WrapContract; +import com.microsoft.azure.auth.wrap.contract.WrapContractImpl; +import com.microsoft.azure.configuration.builder.Builder.Registry; + +public class Exports implements + com.microsoft.azure.configuration.builder.Builder.Exports { + + public void register(Registry registry) { + registry.add(WrapContract.class, WrapContractImpl.class); + registry.add(WrapClient.class); + registry.add(WrapFilter.class); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java new file mode 100644 index 0000000000000..6a73544593d94 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -0,0 +1,47 @@ +package com.microsoft.azure.auth.wrap; + +import javax.inject.Inject; +import javax.inject.Named; + +import com.microsoft.azure.auth.wrap.contract.WrapContract; + +public class WrapClient { + WrapContract contract; + private String uri; + private String name; + private String password; + private String scope; + + @Inject + public WrapClient( + WrapContract contract, + @Named("wrapClient.uri") String uri, + @Named("wrapClient.scope") String scope, + @Named("wrapClient.name") String name, + @Named("wrapClient.password") String password) { + this.contract = contract; + this.uri = uri; + this.scope = scope; + this.name = name; + this.password = password; + } + + + /** + * @return the contract + */ + public WrapContract getContract() { + return contract; + } + + /** + * @param contract the contract to set + */ + public void setContract(WrapContract contract) { + this.contract = contract; + } + + public String getAccessToken() { + return getContract().post(uri, name, password, scope).getAccessToken(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java new file mode 100644 index 0000000000000..8a41646805146 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java @@ -0,0 +1,26 @@ +package com.microsoft.azure.auth.wrap; + +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; + +public class WrapFilter extends ClientFilter { + private WrapClient client; + + public WrapFilter(WrapClient client) { + this.client = client; + } + + @Override + public ClientResponse handle(ClientRequest cr) + throws ClientHandlerException { + + String accessToken = client.getAccessToken(); + + cr.getHeaders().add("Authorization", + "WRAP access_token=\"" + accessToken + "\""); + + return this.getNext().handle(cr); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java new file mode 100644 index 0000000000000..7f6d35e031b2e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.auth.wrap.contract; + +public interface WrapContract { + WrapResponse post(String uri, String name, String password, String scope); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java new file mode 100644 index 0000000000000..19a0dda3c9b23 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java @@ -0,0 +1,33 @@ +package com.microsoft.azure.auth.wrap.contract; + +import javax.inject.Inject; +import javax.ws.rs.core.MediaType; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.representation.Form; + +public class WrapContractImpl implements WrapContract { + Client channel; + + @Inject + public WrapContractImpl(Client channel) { + this.channel = channel; + } + + public WrapResponse post(String uri, String name, String password, String scope) { + Form requestForm = new Form(); + requestForm.add("wrap_name", name); + requestForm.add("wrap_password", password); + requestForm.add("wrap_scope", scope); + + Form responseForm = channel.resource(uri) + .accept(MediaType.APPLICATION_FORM_URLENCODED) + .type(MediaType.APPLICATION_FORM_URLENCODED) + .post(Form.class, requestForm); + + WrapResponse response = new WrapResponse(); + response.setAccessToken(responseForm.getFirst("wrap_access_token")); + response.setExpiresIn(responseForm.getFirst("wrap_access_token_expires_in")); + return response; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java new file mode 100644 index 0000000000000..b007f98cdd307 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java @@ -0,0 +1,31 @@ +package com.microsoft.azure.auth.wrap.contract; + +public class WrapResponse { + String accessToken; + String expiresIn; + + /** + * @return the accessToken + */ + public String getAccessToken() { + return accessToken; + } + /** + * @param accessToken the accessToken to set + */ + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + /** + * @return the expiresIn + */ + public String getExpiresIn() { + return expiresIn; + } + /** + * @param expiresIn the expiresIn to set + */ + public void setExpiresIn(String expiresIn) { + this.expiresIn = expiresIn; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index d4d24e676af2c..1df1025fcddf3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -4,7 +4,9 @@ import java.util.Map; import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.configuration.builder.DefaultBuilder; +import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.json.JSONConfiguration; public class Configuration { @@ -26,18 +28,14 @@ public Configuration(Builder builder) { } private void init() { - setProperty("ClientConfig", new DefaultClientConfig()); - } - - public static Configuration getInstance() { - if (instance == null) { - setInstance(load()); +// DefaultClientConfig clientConfig = new DefaultClientConfig(); +// clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + try { + setProperty("ClientConfig", builder.build(ClientConfig.class, properties)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - return instance; - } - - public static void setInstance(Configuration instance) { - Configuration.instance = instance; } public static Configuration load() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 99792ff31c2a8..338ab12ba6c4d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -11,10 +11,16 @@ public interface Factory { T create(Builder builder, Map properties) throws Exception; } + public interface Alteration { + T alter(T instance, Builder builder, Map properties) throws Exception; + } + public interface Registry { Registry add(Class service); Registry add(Class service, Class implementation); Registry add(Factory factory); + + void alter(Class service, Alteration alteration); } public interface Exports { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index fb7b20720c4be..455bad2949654 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -1,21 +1,27 @@ package com.microsoft.azure.configuration.builder; +import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.ServiceLoader; import javax.inject.Inject; +import javax.inject.Named; public class DefaultBuilder implements Builder, Builder.Registry { Map, Factory> factories; + Map, List>> alterations; public DefaultBuilder() { factories = new HashMap, Factory>(); + alterations = new HashMap, List>>(); } public static DefaultBuilder create() { @@ -24,7 +30,7 @@ public static DefaultBuilder create() { for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { exports.register(builder); } - + return builder; } @@ -36,25 +42,66 @@ public Builder.Registry add(Class service) { return add(service, service); } - + Constructor findInjectConstructor(Class implementation) { - public Builder.Registry add(Class service, final Class implementation) { - Constructor[] ctors = implementation.getConstructors(); - for(final Constructor ctor : ctors) { + Constructor withInject = null; + Constructor withoutInject = null; + int count = 0; + + for (Constructor ctor : implementation.getConstructors()) { if (ctor.getAnnotation(Inject.class) != null) { - final Class[] parameterTypes = ctor.getParameterTypes(); - addFactory(service, new Builder.Factory() { - @SuppressWarnings("unchecked") - public T create(Builder builder, Map properties) throws Exception { - Object[] initargs = new Object[parameterTypes.length]; - for(int i = 0; i != parameterTypes.length; ++i) { - initargs[i] = builder.build(parameterTypes[i], properties); - } - - return (T) ctor.newInstance(initargs); - }}); + if (withInject != null){ + throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); + } + withInject = ctor; + } + else { + ++count; + withoutInject = ctor; } } + if (withInject != null) { + return withInject; + } + if (count != 1) { + throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); + } + return withoutInject; + } + + public Builder.Registry add(Class service, final Class implementation) { + final Constructor ctor = findInjectConstructor(implementation); + final Class[] parameterTypes = ctor.getParameterTypes(); + final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); + + addFactory(service, new Builder.Factory() { + @SuppressWarnings("unchecked") + public T create(Builder builder, Map properties) throws Exception { + Object[] initargs = new Object[parameterTypes.length]; + for(int i = 0; i != parameterTypes.length; ++i) { + boolean located = false; + + Annotation[] annotations = parameterAnnotations[i]; + for(int ii = 0; ii != annotations.length && !located; ++ii){ + if (Named.class.isAssignableFrom(annotations[ii].getClass())) { + located = true; + + Named named = (Named)annotations[ii]; + if (!properties.containsKey(named.value())) { + throw new RuntimeException("Configuration missing required property: " + named.value()); + } + initargs[i] = properties.get(named.value()); + } + } + + if (!located) { + initargs[i] = builder.build(parameterTypes[i], properties); + } + } + + return (T) ctor.newInstance(initargs); + } + }); return this; } @@ -72,15 +119,28 @@ public Registry add(Factory factory) { } + @SuppressWarnings("unchecked") public T build(Class service, Map properties) throws Exception { - @SuppressWarnings("unchecked") Factory factory = (Factory) factories.get(service); if (factory == null) { - return null; + throw new RuntimeException("Service not registered: " + service.getName()); } - return factory.create(this, properties); + T instance = factory.create(this, properties); + List> alterationList = alterations.get(service); + if (alterationList != null){ + for(Alteration alteration : alterationList){ + instance = ((Alteration)alteration).alter(instance, this, properties); + } + } + return instance; } + public void alter(Class service, Alteration alteration) { + if (!this.alterations.containsKey(service)) { + this.alterations.put(service, new ArrayList>()); + } + this.alterations.get(service).add(alteration); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java index 43dfe5ea593cf..571035b1c67ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -6,14 +6,24 @@ import com.microsoft.azure.configuration.builder.Builder.Registry; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.LoggingFilter; public class Exports implements Builder.Exports { public void register(Registry registry) { + registry.add(new Builder.Factory() { + public ClientConfig create(Builder builder, Map properties) { + return new DefaultClientConfig(); + } + }); + registry.add(new Builder.Factory() { public Client create(Builder builder, Map properties) { ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - return Client.create(clientConfig); + Client client = Client.create(clientConfig); + client.addFilter(new LoggingFilter()); + return client; } }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java similarity index 66% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java index dcaee33cb908b..8c56bd724c0c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Entity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java @@ -1,35 +1,37 @@ package com.microsoft.azure.services.serviceBus; +import javax.ws.rs.core.MediaType; + import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; -public class Entity { +abstract class AbstractEntity { - protected ServiceBusClient client; - private Entry entry; + ServiceBusClient client; + Entry entry; - public Entity(ServiceBusClient client) { + AbstractEntity(ServiceBusClient client) { this.client = client; setEntry(new org.w3._2005.atom.Entry()); getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); } - - public Entity(ServiceBusClient client, Entry entry) { + + AbstractEntity(ServiceBusClient client, Entry entry) { this.client = client; this.entry = entry; } - + protected ServiceBusClient getClient() { return client; } - + protected ServiceBusContract getContract() { return getClient().getContract(); } - protected Entry getEntry() { return entry; } @@ -37,6 +39,4 @@ protected Entry getEntry() { protected void setEntry(Entry entry) { this.entry = entry; } - - -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 3a655465b659d..185d7769738f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -1,25 +1,26 @@ package com.microsoft.azure.services.serviceBus; import javax.xml.datatype.Duration; - import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; -public class Queue extends Entity implements MessageSender, MessageReceiver { +public class Queue extends AbstractEntity implements MessageSender, MessageReceiver { Queue(ServiceBusClient client, String path) { super(client); Content content = new Content(); + + getEntry().setContent(content); content.setType("application/xml"); content.setQueueDescription(new QueueDescription()); - getEntry().setContent(content); setPath(path); } - public Queue(ServiceBusClient client, Entry entry) { + Queue(ServiceBusClient client, Entry entry) { super(client, entry); } @@ -28,10 +29,10 @@ QueueDescription getQueueDescription(){ } - // public object verbs + // API methods public void save() { - getContract().createQueue(getEntry()); + setEntry(getContract().createQueue(getEntry())); } public void delete() { @@ -50,6 +51,7 @@ public void sendMessage(Message message) { } public Message receiveMessage(int timeout) { + getContract().receiveMessage(getPath(), timeout, ReceiveMode.RECEIVE_AND_DELETE); // TODO Auto-generated method stub return null; } @@ -75,7 +77,7 @@ public void completeMessage(Message message) { - // entity state properties + // API properties public String getPath() { return getEntry().getTitle(); @@ -104,10 +106,4 @@ public void setMaxSizeInMegabytes(Long value) { public Long getMessageCount() { return getQueueDescription().getMessageCount(); } - - - - - - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java deleted file mode 100644 index b96aa03a3835a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -public enum ReceiveMode { - PEEK_LOCK, - RECEIVE_AND_DELETE, -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 755fb3d628844..114a9c159cbae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -15,7 +15,7 @@ public class ServiceBusClient { ServiceBusContract contract; public ServiceBusClient() throws Exception { - this(Configuration.getInstance()); + this(Configuration.load()); } public ServiceBusClient(Configuration config) throws Exception { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java new file mode 100644 index 0000000000000..ee4c7dfd6a1c0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java @@ -0,0 +1,75 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class BrokerProperties { + @JsonProperty("DeliveryCount") + int deliveryCount; + + @JsonProperty("MessageId") + String messageId; + + @JsonProperty("SequenceNumber") + int sequenceNumber; + + @JsonProperty("TimeToLive") + long timeToLive; + + /** + * @return the deliveryCount + */ + public int getDeliveryCount() { + return deliveryCount; + } + + /** + * @param deliveryCount the deliveryCount to set + */ + public void setDeliveryCount(int deliveryCount) { + this.deliveryCount = deliveryCount; + } + + /** + * @return the messageId + */ + public String getMessageId() { + return messageId; + } + + /** + * @param messageId the messageId to set + */ + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + /** + * @return the sequenceNumber + */ + public int getSequenceNumber() { + return sequenceNumber; + } + + /** + * @param sequenceNumber the sequenceNumber to set + */ + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + /** + * @return the timeToLive + */ + public long getTimeToLive() { + return timeToLive; + } + + /** + * @param timeToLive the timeToLive to set + */ + public void setTimeToLive(long timeToLive) { + this.timeToLive = timeToLive; + } + + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java new file mode 100644 index 0000000000000..8701f1db467ff --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java @@ -0,0 +1,55 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; + +public class BrokerPropertiesMapper { + + public BrokerProperties fromString(String value) + throws IllegalArgumentException { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.readValue(value.getBytes(), BrokerProperties.class); + } catch (JsonParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + } + + public String toString(BrokerProperties value) { + ObjectMapper mapper = new ObjectMapper(); + Writer writer = new StringWriter(); + try { + mapper.writeValue(writer, value); + } catch (JsonGenerationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + return writer.toString(); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java deleted file mode 100644 index 640583fcc47c0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokeredMessage.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -public class BrokeredMessage { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java index 0cf1264c5caed..845ca50fabe53 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java @@ -1,9 +1,35 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.util.Map; + import com.microsoft.azure.configuration.builder.Builder; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.json.JSONConfiguration; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { + + // provide contract implementation registry.add(ServiceBusContract.class, ServiceBusContractImpl.class); + + // alter jersey client config for serviceBus + registry.alter(ClientConfig.class, new Builder.Alteration() { + + public ClientConfig alter(ClientConfig instance, Builder builder, + Map properties) throws Exception { + + // enable this feature for unattributed json object serialization + instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + + // need to avoid certain element prefixes, which the service does not ignore + instance.getSingletons().add(new MarshallerProvider()); + + return instance; + } + }); + + // convenience provider to transform BrokerProperty headers to json + registry.add(BrokerPropertiesMapper.class); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java new file mode 100644 index 0000000000000..e529e48e7708e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java @@ -0,0 +1,54 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.PropertyException; + +@Provider +@Produces("application/atom+xml") +public class MarshallerProvider implements ContextResolver { + + @Context + private ContextResolver jaxbContextResolver; + + public Marshaller getContext(Class type) { + Marshaller marshaller; + try { + marshaller = getJAXBContext(type).createMarshaller(); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); + try { + marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); + } catch (PropertyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + return marshaller; + } + + private JAXBContext getJAXBContext(Class type) throws Exception { + JAXBContext context = null; + if (jaxbContextResolver != null){ + context = jaxbContextResolver.getContext(type); + } + if (context == null){ + context = JAXBContext.newInstance(type); + } + return context; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java new file mode 100644 index 0000000000000..6c98703c48a3f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java @@ -0,0 +1,34 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import java.io.InputStream; + +public class MessageResult { + BrokerProperties brokerProperties; + + InputStream body; + + /** + * @return the brokerProperties + */ + public BrokerProperties getBrokerProperties() { + return brokerProperties; + } + /** + * @param brokerProperties the brokerProperties to set + */ + public void setBrokerProperties(BrokerProperties brokerProperties) { + this.brokerProperties = brokerProperties; + } + /** + * @return the body + */ + public InputStream getBody() { + return body; + } + /** + * @param body the body to set + */ + public void setBody(InputStream body) { + this.body = body; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java new file mode 100644 index 0000000000000..3f41f21e91f4e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java @@ -0,0 +1,18 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import com.sun.xml.bind.marshaller.NamespacePrefixMapper; + +public class NamespacePrefixMapperImpl extends NamespacePrefixMapper { + + @Override + public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { + if (namespaceUri == "http://www.w3.org/2005/Atom") { + return "atom"; + } + else if (namespaceUri == "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect") { + return ""; + } + return suggestion; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index 72ec0ed2a254c..5fd0f7bd31b41 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -5,18 +5,18 @@ public interface ServiceBusContract { - void sendMessage(String path, BrokeredMessage message); - BrokeredMessage receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); - BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); - void abandonMessage(BrokeredMessage message); - void completeMessage(BrokeredMessage message); + void sendMessage(String path, BrokerProperties properties); + MessageResult receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); + //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); + //void abandonMessage(BrokeredMessage message); + //void completeMessage(BrokeredMessage message); - void createQueue(Entry queue); + Entry createQueue(Entry queue); void deleteQueue(String queuePath); Entry getQueue(String queuePath); Feed getQueues(); - void createTopic(Entry topic); + Entry createTopic(Entry topic); void deleteTopic(String topicPath); Entry getTopic(String topicPath); Feed getTopics(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 73e3e94e40755..670ca2e7515ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,188 +1,156 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.rmi.UnexpectedException; + import javax.inject.Inject; +import javax.inject.Named; import org.w3._2005.atom.Entry; import org.w3._2005.atom.Feed; +import com.microsoft.azure.auth.wrap.WrapFilter; import com.sun.jersey.api.client.Client; -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.GenericType; -import com.sun.jersey.api.client.filter.ClientFilter; -import com.sun.jersey.api.representation.Form; - -public class ServiceBusContractImpl implements ServiceBusContract { - - public class AtomFilter extends ClientFilter { - - @Override - public ClientResponse handle(ClientRequest cr) - throws ClientHandlerException { - - return getNext().handle(cr); - } +import com.sun.jersey.api.client.WebResource; - } +public class ServiceBusContractImpl implements ServiceBusContract { private Client channel; + private String uri; + private BrokerPropertiesMapper mapper; @Inject - public ServiceBusContractImpl(Client channel) { - channel.addFilter(new AtomFilter()); - this.setChannel(channel); + public ServiceBusContractImpl( + Client channel, WrapFilter authFilter, + @Named("serviceBus.uri") String uri, + BrokerPropertiesMapper mapper) { + + this.channel = channel; + this.uri = uri; + this.mapper = mapper; + channel.addFilter(authFilter); } - public Client getChannel() { return channel; } - - public void setChannel(Client channel) { this.channel = channel; } - - public void sendMessage(String path, BrokeredMessage message) { - // TODO Auto-generated method stub - + public void sendMessage(String path, BrokerProperties properties) { + getResource() + .path(path) + .path("messages") + .header("BrokerProperties", mapper.toString(properties)) + .post("Hello world"); } - public BrokeredMessage receiveMessage(String queuePath, int timeout, + public MessageResult receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode) { - // TODO Auto-generated method stub - return null; - } - - public BrokeredMessage receiveMessage(String topicPath, - String subscriptionName, int timeout, ReceiveMode receiveMode) { - // TODO Auto-generated method stub - return null; - } - - public void abandonMessage(BrokeredMessage message) { - // TODO Auto-generated method stub - + MessageResult result = new MessageResult(); + if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { + ClientResponse clientResult = getResource() + .path(queuePath) + .path("messages") + .path("head") + .queryParam("timeout", Integer.toString(timeout)) + .delete(ClientResponse.class); + + result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); + result.setBody(clientResult.getEntityInputStream()); + return result; + } + throw new RuntimeException("Unknown ReceiveMode"); } - public void completeMessage(BrokeredMessage message) { - // TODO Auto-generated method stub - } - - public void createQueue(Entry entry) { - Form form = new Form(); - form.add("wrap_name", "owner"); - form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); - - Form wrapResponse = getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") - .path("WRAPv0.9") - .post(Form.class, form); - String accessToken = wrapResponse.get("wrap_access_token").get(0); - - getChannel().resource("https://lodejard.servicebus.windows.net/") + public Entry createQueue(Entry entry) { + return getResource() .path(entry.getTitle()) - .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - .type("application/atom+xml;type=entry;charset=utf-8") - .put(entry); + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Entry.class, entry); } public void deleteQueue(String queuePath) { - + getResource() + .path(queuePath) + .delete(); } - public Entry getQueue(String queuePath) { - Form form = new Form(); - form.add("wrap_name", "owner"); - form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); - - Form wrapResponse = getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") - .path("WRAPv0.9") - .post(Form.class, form); - String accessToken = wrapResponse.get("wrap_access_token").get(0); - - //GenericType> genericType = new GenericType>() { }; - - return getChannel().resource("https://lodejard.servicebus.windows.net/") - .path(queuePath) - .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - .get(Entry.class); + private WebResource getResource() { + return getChannel() + .resource(uri); } + public Entry getQueue(String queuePath) { + return getResource() + .path(queuePath) + .get(Entry.class); + } public Feed getQueues() { - // TODO Auto-generated method stub - return null; + return getResource() + .path("$Resources/Queues") + .get(Feed.class); } - - public void createTopic(Entry topic) { - // TODO Auto-generated method stub - + public Entry createTopic(Entry entry) { + return getResource() + .path(entry.getTitle()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Entry.class, entry); } - public void deleteTopic(String topicPath) { - // TODO Auto-generated method stub - + getResource() + .path(topicPath) + .delete(); } - public Entry getTopic(String topicPath) { // TODO Auto-generated method stub return null; } - public Feed getTopics() { // TODO Auto-generated method stub return null; } - public void addSubscription(String topicPath, String subscriptionName, Entry subscription) { // TODO Auto-generated method stub - - } + } public void removeSubscription(String topicPath, String subscriptionName) { // TODO Auto-generated method stub - - } + } public Entry getSubscription(String topicPath, String subscriptionName) { // TODO Auto-generated method stub return null; } - public Feed getSubscriptions(String topicPath) { // TODO Auto-generated method stub return null; } - public void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule) { // TODO Auto-generated method stub - - } + } public void removeRule(String topicPath, String subscriptionName, String ruleName) { // TODO Auto-generated method stub - - } + } public Entry getRule(String topicPath, String subscriptionName, String ruleName) { @@ -190,17 +158,10 @@ public Entry getRule(String topicPath, String subscriptionName, return null; } - public Feed getRules(String topicPath, String subscriptionName) { // TODO Auto-generated method stub return null; } - - - - - - } diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index 8cdde57cd1617..a582f449caaa4 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,3 +1,4 @@ +com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports com.microsoft.azure.services.serviceBus.contract.Exports diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd index eb30b07d7f800..31d324b76fbef 100644 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd @@ -101,7 +101,7 @@ - + @@ -169,7 +169,7 @@ - + @@ -299,5 +299,5 @@ - + \ No newline at end of file diff --git a/microsoft-azure-api/src/main/resources/atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd similarity index 89% rename from microsoft-azure-api/src/main/resources/atom.xsd rename to microsoft-azure-api/src/main/resources/servicebus-atom.xsd index 86c57ae40bd51..c7649f01686bf 100644 --- a/microsoft-azure-api/src/main/resources/atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -26,9 +26,10 @@ - - - + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java new file mode 100644 index 0000000000000..3c8221951a3a8 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java @@ -0,0 +1,32 @@ +package com.microsoft.azure.auth.wrap; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; + +public class WrapClientIntegrationTest { + private Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); + config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); + config.setProperty("wrapClient.name", "owner"); + config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + return config; + } + + @Test + public void wrapClientWillAcquireAccessToken() throws Exception { + // Arrange + Configuration config = createConfiguration(); + WrapClient client = config.create(WrapClient.class); + + // Act + String accessToken = client.getAccessToken(); + + // Assert + Assert.assertNotNull(accessToken); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java new file mode 100644 index 0000000000000..fab7e7faf0ee3 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java @@ -0,0 +1,21 @@ +package com.microsoft.azure.auth.wrap.contract; + +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; +import com.sun.jersey.api.client.Client; + +public class WrapContractIntegrationTest { + @Test + public void yaaaaargh() throws Exception { + Configuration config = new Configuration(); + + WrapContract contract = new WrapContractImpl(config.create(Client.class)); + + contract.post( + "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", + "owner", + "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", + "http://lodejard.servicebus.windows.net"); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java new file mode 100644 index 0000000000000..ef81367eb0a72 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java @@ -0,0 +1,13 @@ +package com.microsoft.azure.configuration.builder; + +import java.util.Map; + +public class AlterClassWithProperties implements Builder.Alteration{ + + public ClassWithProperties alter(ClassWithProperties instance, + Builder builder, Map properties) throws Exception { + instance.setFoo(instance.getFoo() + " - changed"); + return instance; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java new file mode 100644 index 0000000000000..341753eade6d7 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.configuration.builder; + +import javax.inject.Inject; + +public class ClassWithMultipleCtorMultipleInject { + @Inject + public ClassWithMultipleCtorMultipleInject(){} + @Inject + public ClassWithMultipleCtorMultipleInject(String x){} +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java new file mode 100644 index 0000000000000..90149fe4dc73f --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java @@ -0,0 +1,8 @@ +package com.microsoft.azure.configuration.builder; + +public class ClassWithMultipleCtorNoInject { + public ClassWithMultipleCtorNoInject() { + } + public ClassWithMultipleCtorNoInject(String x) { + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java new file mode 100644 index 0000000000000..62c930bada839 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java @@ -0,0 +1,22 @@ +package com.microsoft.azure.configuration.builder; + +import javax.inject.Inject; +import javax.inject.Named; + +public class ClassWithNamedParameter { + private String hello; + + @Inject + public ClassWithNamedParameter(@Named("Foo") String hello) { + this.hello = hello; + } + + public String getHello() { + return hello; + } + + public void setHello(String hello) { + this.hello = hello; + } +} + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java new file mode 100644 index 0000000000000..22c365db6e722 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java @@ -0,0 +1,36 @@ +package com.microsoft.azure.configuration.builder; + +public class ClassWithProperties { + String foo; + String bar; + + public ClassWithProperties(){ + foo = "one"; + bar = "two"; + } + + /** + * @return the foo + */ + public String getFoo() { + return foo; + } + /** + * @param foo the foo to set + */ + public void setFoo(String foo) { + this.foo = foo; + } + /** + * @return the bar + */ + public String getBar() { + return bar; + } + /** + * @param bar the bar to set + */ + public void setBar(String bar) { + this.bar = bar; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java new file mode 100644 index 0000000000000..1a34374e55923 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.configuration.builder; + +public class ClassWithSingleCtorNoInject { + public ClassWithSingleCtorNoInject() { + + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java new file mode 100644 index 0000000000000..cf4b105cd0a80 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java @@ -0,0 +1,113 @@ +package com.microsoft.azure.configuration.builder; + +import java.util.HashMap; +import java.util.Map; + +import junit.framework.Assert; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class DefaultBuilderTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void namedAnnotationsComeFromBuildProperties() throws Exception { + // Arrange + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithNamedParameter.class); + + // Act + Map properties = new HashMap(); + properties.put("Foo", "world"); + ClassWithNamedParameter cwnp = builder.build( + ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("world", cwnp.getHello()); + } + + @Test + public void namedAnnotationReportsMissingProperty() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + Map properties = new HashMap(); + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithNamedParameter.class); + + // Act + ClassWithNamedParameter cwnp = builder.build( + ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("world", cwnp.getHello()); + } + + @Test + public void singleCtorWithNoInjectShouldBeUsed() throws Exception { + // Arrange + Map properties = new HashMap(); + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithSingleCtorNoInject.class); + + // Act + ClassWithSingleCtorNoInject result = builder.build( + ClassWithSingleCtorNoInject.class, properties); + + // Assert + Assert.assertNotNull(result); + } + + @Test + public void multipleCtorWithNoInjectShouldFail() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + Map properties = new HashMap(); + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithMultipleCtorNoInject.class); + + // Act + ClassWithMultipleCtorNoInject result = builder.build( + ClassWithMultipleCtorNoInject.class, properties); + + // Assert + Assert.assertTrue("Exception must occur", false); + } + + @Test + public void multipleCtorWithMultipleInjectShouldFail() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + Map properties = new HashMap(); + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithMultipleCtorMultipleInject.class); + + // Act + ClassWithMultipleCtorMultipleInject result = builder.build( + ClassWithMultipleCtorMultipleInject.class, properties); + + // Assert + Assert.assertTrue("Exception must occur", false); + } + + @Test + public void alterationExecutesWhenInstanceCreated() throws Exception { + // Arrange + Map properties = new HashMap(); + DefaultBuilder builder = new DefaultBuilder(); + builder.add(ClassWithProperties.class); + builder.alter(ClassWithProperties.class, new AlterClassWithProperties()); + + // Act + ClassWithProperties result = builder.build(ClassWithProperties.class, properties); + + // Assert + Assert.assertEquals("one - changed", result.getFoo()); + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java index 0435dad089192..67a3f236cdfa7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java @@ -25,8 +25,8 @@ public void testGetQueueAcquiresDescriptionFromServer() { when(contract.getQueue("Hello")).thenReturn(entry); entry.setContent(new Content()); - entry.getContent().setQueueDescription(new QueueDescription()); - entry.getContent().getQueueDescription().setMessageCount(73L); + //entry.getContent().setQueueDescription(new QueueDescription()); + //entry.getContent().getQueueDescription().setMessageCount(73L); // Act ServiceBusClient client = new ServiceBusClient(contract); @@ -53,10 +53,10 @@ public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfi ArgumentCaptor argument = ArgumentCaptor.forClass(Entry.class); verify(contract).createQueue(argument.capture()); Entry entry = argument.getValue(); - QueueDescription model = entry.getContent().getQueueDescription(); + //QueueDescription model = entry.getContent().getQueueDescription(); assertEquals("MyNewQueue", entry.getTitle()); - assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); - assertEquals(42, model.getMaxSizeInMegabytes().longValue()); + //assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); + //assertEquals(42, model.getMaxSizeInMegabytes().longValue()); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java new file mode 100644 index 0000000000000..076d58b8a552a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java @@ -0,0 +1,19 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class BrokerPropertiesMapperTest { + @Test + public void jsonStringMapsToBrokerPropertiesObject(){ + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + // Act + BrokerProperties properties = mapper.fromString("{}"); + + // Assert + assertNotNull(properties); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java new file mode 100644 index 0000000000000..a50d914d2b39a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -0,0 +1,100 @@ +package com.microsoft.azure.services.serviceBus.contract; + +import org.junit.Test; +import org.w3._2005.atom.Content; +import org.w3._2005.atom.Entry; +import org.w3._2005.atom.Feed; + +import com.microsoft.azure.configuration.Configuration; +import static org.junit.Assert.*; + +public class ContractIntegrationTest { + private Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); + config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("wrapClient.name", "owner"); + config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); + return config; + } + + @Test + public void fetchQueueAndListQueuesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + // Act + Entry entry = contract.getQueue("Hello"); + Feed feed = contract.getQueues(); + + // Assert + assertNotNull(entry); + assertNotNull(feed); + } + + @Test + public void createQueueWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + // Act + Entry entry = new Entry(); + Content content = new Content(); + QueueDescription description = new QueueDescription(); + + entry.setTitle("createQueueWorks"); + entry.setContent(content); + content.setType("application/xml"); + content.setQueueDescription(description); + description.setMaxSizeInMegabytes(1024L); + + contract.createQueue(entry); + + // Assert + } + + @Test + public void deleteQueueWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + // Act + assertTrue("won't do this - can't recreate it yet", false); + contract.deleteQueue("Hello"); + + // Assert + } + + @Test + public void sendMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + BrokerProperties props = new BrokerProperties(); + + // Act + contract.sendMessage("Hello", props); + + // Assert + } + + @Test + public void receiveMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + BrokerProperties props = new BrokerProperties(); + + // Act + contract.sendMessage("Hello", props); + contract.receiveMessage("Hello", 500, ReceiveMode.RECEIVE_AND_DELETE); + + // Assert + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java index e895ad667adad..892f96f7b4f04 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java @@ -1,123 +1,134 @@ package com.microsoft.azure.services.serviceBus.contract; +import static org.junit.Assert.*; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.StringReader; - +import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.junit.Test; +import com.microsoft.azure.auth.wrap.WrapFilter; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.Entity; import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.ServiceBusClient; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; +import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.filter.LoggingFilter; -import com.sun.jersey.api.representation.Form; +public class QueueManagementIntegrationTest { + private Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty("serviceBus.uri", + "https://lodejard.servicebus.windows.net"); + config.setProperty("wrapClient.uri", + "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("wrapClient.scope", + "http://lodejard.servicebus.windows.net/"); + config.setProperty("wrapClient.name", "owner"); + config.setProperty("wrapClient.password", + "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + return config; + } + private ServiceBusClient createClient() throws Exception { + return createConfiguration().create(ServiceBusClient.class); + } + + private static String readResourceFile(String name) throws IOException { + InputStream stream = Thread.currentThread().getContextClassLoader() + .getResourceAsStream(name); + + StringBuffer sb = new StringBuffer(1024); + BufferedReader reader = new BufferedReader( + new InputStreamReader(stream)); + + char[] chars = new char[1024]; + int numRead = 0; + while ((numRead = reader.read(chars)) > -1) { + sb.append(new String(chars, 0, numRead)); + } + + reader.close(); + + return sb.toString(); + } + + @Test + public void createAnyQueue() throws Exception { + + Client client = Client.create(); + client.addFilter(createConfiguration().create(WrapFilter.class)); + client.addFilter(new LoggingFilter()); + String data = readResourceFile("NewFile.xml"); + client.resource("https://lodejard.servicebus.windows.net") + .path("Hello2").delete(); + client.resource("https://lodejard.servicebus.windows.net") + .path("Hello2").type(MediaType.APPLICATION_ATOM_XML).put(data); + + } -public class QueueManagementIntegrationTest { @Test public void queueCanBeCreatedAndDeleted() throws Exception { // Arrange - ServiceBusClient client = new Configuration() - .create(ServiceBusClient.class); - ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); - contract.getChannel().addFilter(new LoggingFilter()); - - /* - String message = readResourceFile("NewFile.xml"); - - Form form = new Form(); - form.add("wrap_name", "owner"); - form.add("wrap_password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - form.add("wrap_scope", "http://lodejard.servicebus.windows.net/"); - - Form wrapResponse = contract.getChannel().resource("https://lodejard-sb.accesscontrol.windows.net/") - .path("WRAPv0.9") - .post(Form.class, form); - String accessToken = wrapResponse.get("wrap_access_token").get(0); - - - contract.getChannel().resource("https://lodejard.servicebus.windows.net/") - .path("Hello") - .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - //.type("application/atom+xml") - .get(String.class); - - contract.getChannel().resource("https://lodejard.servicebus.windows.net/") - .path("Hello") - .header("Authorization", "WRAP access_token=\"" + accessToken + "\"") - .type("application/atom+xml") - .accept("application/atom+xml") - .put(message); -*/ + ServiceBusClient client = createClient(); + // Act - Queue queue = client.getQueue("Hello"); - queue.fetch(); - queue.setPath("TestQueue01"); + Queue queue = client.getQueue("queueCanBeCreatedAndDeleted"); + queue.setPath("queueCanBeCreatedAndDeleted"); queue.save(); queue.delete(); - + // Assert } - - public static String readResourceFile(String name) throws IOException { - InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); - - StringBuffer sb = new StringBuffer(1024); - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); - - char[] chars = new char[1024]; - int numRead = 0; - while( (numRead = reader.read(chars)) > -1){ - sb.append(String.valueOf(chars)); + + @Test + public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + try { + client.getQueue("whenQueueIsCreatedEntityStateIsAlsoUpdated") + .delete(); + } catch (Exception e) { } - reader.close(); + // Act + Queue queue = client.getQueue("whenQueueIsCreatedEntityStateIsAlsoUpdated"); + Long maxSizeBefore = queue.getMaxSizeInMegabytes(); + queue.save(); + Long maxSizeAfter = queue.getMaxSizeInMegabytes(); + queue.delete(); - return sb.toString(); + // Assert + assertNull(maxSizeBefore); + assertNotNull(maxSizeAfter); } - + @Test public void notFoundQueuePathReturnsNull() throws Exception { // Arrange - Configuration cfg = new Configuration(); - - ServiceBusClient client = cfg.create(ServiceBusClient.class); - - - ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); - contract.getChannel().addFilter(new LoggingFilter()); - + ServiceBusClient client = createClient(); + // Act Queue queue = client.getQueue("NoSuchQueueName"); - + // Assert Assert.assertNull(queue); } - @Test public void existingQueuePathDoesNotReturnNull() throws Exception { // Arrange - ServiceBusClient client = new Configuration() - .create(ServiceBusClient.class); - - ServiceBusContractImpl contract = (ServiceBusContractImpl) client.getContract(); - contract.getChannel().addFilter(new LoggingFilter()); - //contract.getChannel().getProviders(). - - //client.createQueue("TestQueue02"); - + ServiceBusClient client = createClient(); + + // client.createQueue("TestQueue02"); + // Act Queue queue = client.getQueue("Hello"); queue.fetch(); - + // Assert Assert.assertNotNull(queue); Assert.assertEquals("Hello", queue.getPath()); diff --git a/microsoft-azure-api/src/test/resources/NewFile.xml b/microsoft-azure-api/src/test/resources/NewFile.xml index 7b3ea8dffd232..71989d321de16 100644 --- a/microsoft-azure-api/src/test/resources/NewFile.xml +++ b/microsoft-azure-api/src/test/resources/NewFile.xml @@ -1 +1,4 @@ -PT1M1024falsefalseP10675199DT2H48M5SfalsePT10M10true00 + + + + From 27ed63017a8ecddf93d47098dc3fc20b1c8ef97b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Sat, 22 Oct 2011 20:00:54 -0700 Subject: [PATCH 024/664] Cleaning up tests --- .../services/serviceBus/ServiceBusClient.java | 2 +- .../serviceBus/contract/BrokerProperties.java | 28 ++-- .../contract/ServiceBusContractImpl.java | 1 + .../auth/wrap/WrapClientIntegrationTest.java | 1 - .../serviceBus/IntegrationTestBase.java | 27 ++++ .../QueueManagementIntegrationTest.java | 75 ++++++++++ .../contract/BrokerPropertiesMapperTest.java | 19 ++- .../contract/ContractIntegrationTest.java | 24 ++-- .../QueueManagementIntegrationTest.java | 136 ------------------ 9 files changed, 149 insertions(+), 164 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 114a9c159cbae..2abc6d76ba6c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -39,7 +39,7 @@ public Iterable listQueues() { Feed descriptions = contract.getQueues(); ArrayList queues = new ArrayList(); for (int i = 0; i != descriptions.getEntries().size(); ++i) { - queues.set(i, new Queue(this, descriptions.getEntries().get(i))); + queues.add(new Queue(this, descriptions.getEntries().get(i))); } return queues; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java index ee4c7dfd6a1c0..b60438e144df9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java @@ -1,37 +1,45 @@ package com.microsoft.azure.services.serviceBus.contract; +import org.codehaus.jackson.annotate.JsonGetter; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.annotate.JsonWriteNullProperties; +@JsonIgnoreProperties(ignoreUnknown=true) +@JsonWriteNullProperties(false) public class BrokerProperties { @JsonProperty("DeliveryCount") - int deliveryCount; + Integer deliveryCount; @JsonProperty("MessageId") String messageId; @JsonProperty("SequenceNumber") - int sequenceNumber; + Long sequenceNumber; @JsonProperty("TimeToLive") - long timeToLive; + Long timeToLive; /** * @return the deliveryCount */ - public int getDeliveryCount() { + @JsonIgnore + public Integer getDeliveryCount() { return deliveryCount; } /** * @param deliveryCount the deliveryCount to set */ - public void setDeliveryCount(int deliveryCount) { + public void setDeliveryCount(Integer deliveryCount) { this.deliveryCount = deliveryCount; } /** * @return the messageId */ + @JsonIgnore public String getMessageId() { return messageId; } @@ -46,28 +54,30 @@ public void setMessageId(String messageId) { /** * @return the sequenceNumber */ - public int getSequenceNumber() { + @JsonIgnore + public Long getSequenceNumber() { return sequenceNumber; } /** * @param sequenceNumber the sequenceNumber to set */ - public void setSequenceNumber(int sequenceNumber) { + public void setSequenceNumber(Long sequenceNumber) { this.sequenceNumber = sequenceNumber; } /** * @return the timeToLive */ - public long getTimeToLive() { + @JsonIgnore + public Long getTimeToLive() { return timeToLive; } /** * @param timeToLive the timeToLive to set */ - public void setTimeToLive(long timeToLive) { + public void setTimeToLive(Long timeToLive) { this.timeToLive = timeToLive; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 670ca2e7515ab..7784d77d46bc7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -44,6 +44,7 @@ public void sendMessage(String path, BrokerProperties properties) { .path(path) .path("messages") .header("BrokerProperties", mapper.toString(properties)) + .header("Content-Length", 11) .post("Hello world"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java index 3c8221951a3a8..67976043920fe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java @@ -9,7 +9,6 @@ public class WrapClientIntegrationTest { private Configuration createConfiguration() { Configuration config = new Configuration(); - config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); config.setProperty("wrapClient.name", "owner"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java new file mode 100644 index 0000000000000..6085b74aa8a40 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -0,0 +1,27 @@ +package com.microsoft.azure.services.serviceBus; + +import org.junit.Before; + +import com.microsoft.azure.configuration.Configuration; + +public abstract class IntegrationTestBase { + protected Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); + config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("wrapClient.name", "owner"); + config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); + return config; + } + + @Before + public void initialize() throws Exception { + ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); + for(Queue queue : client.listQueues()){ + if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) + queue.delete(); + } + client.getQueue("TestAlpha").save(); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java new file mode 100644 index 0000000000000..35a0cf05ff7a9 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -0,0 +1,75 @@ +package com.microsoft.azure.services.serviceBus; + +import static org.junit.Assert.*; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.microsoft.azure.services.serviceBus.Queue; +import com.microsoft.azure.services.serviceBus.ServiceBusClient; + +public class QueueManagementIntegrationTest extends IntegrationTestBase { + + private ServiceBusClient createClient() throws Exception { + return createConfiguration().create(ServiceBusClient.class); + } + + @Test + public void queueCanBeCreatedAndDeleted() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // Act + Queue queue = client.getQueue("TestQueueCanBeCreatedAndDeleted"); + queue.save(); + queue.delete(); + + // Assert + } + + @Test + public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // Act + Queue queue = client.getQueue("TestWhenQueueIsCreatedEntityStateIsAlsoUpdated"); + Long maxSizeBefore = queue.getMaxSizeInMegabytes(); + queue.save(); + Long maxSizeAfter = queue.getMaxSizeInMegabytes(); + queue.delete(); + + // Assert + assertNull(maxSizeBefore); + assertNotNull(maxSizeAfter); + } + + @Test + public void notFoundQueuePathReturnsNull() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // Act + Queue queue = client.getQueue("NoSuchQueueName"); + + // Assert + Assert.assertNull(queue); + } + + @Test + public void existingQueuePathDoesNotReturnNull() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // client.createQueue("TestQueue02"); + + // Act + Queue queue = client.getQueue("Hello"); + queue.fetch(); + + // Assert + Assert.assertNotNull(queue); + Assert.assertEquals("Hello", queue.getPath()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java index 076d58b8a552a..30b8f77f62752 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java @@ -11,9 +11,26 @@ public void jsonStringMapsToBrokerPropertiesObject(){ BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); // Act - BrokerProperties properties = mapper.fromString("{}"); + BrokerProperties properties = mapper.fromString("{\"DeliveryCount\":5,\"MessageId\":\"something\"}"); // Assert assertNotNull(properties); + assertEquals(new Integer(5), properties.getDeliveryCount()); + assertEquals("something", properties.getMessageId()); + } + + @Test + public void nonDefaultPropertiesMapToJsonString(){ + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + // Act + BrokerProperties properties = new BrokerProperties(); + properties.setMessageId("foo"); + properties.setDeliveryCount(7); + String json = mapper.toString(properties); + + // Assert + assertNotNull(json); + assertEquals("{\"DeliveryCount\":7,\"MessageId\":\"foo\"}", json); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java index a50d914d2b39a..0de76c695dffc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -6,18 +6,11 @@ import org.w3._2005.atom.Feed; import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.IntegrationTestBase; + import static org.junit.Assert.*; -public class ContractIntegrationTest { - private Configuration createConfiguration() { - Configuration config = new Configuration(); - config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); - config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("wrapClient.name", "owner"); - config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); - return config; - } +public class ContractIntegrationTest extends IntegrationTestBase { @Test public void fetchQueueAndListQueuesWorks() throws Exception { @@ -45,7 +38,7 @@ public void createQueueWorks() throws Exception { Content content = new Content(); QueueDescription description = new QueueDescription(); - entry.setTitle("createQueueWorks"); + entry.setTitle("TestCreateQueueWorks"); entry.setContent(content); content.setType("application/xml"); content.setQueueDescription(description); @@ -63,8 +56,7 @@ public void deleteQueueWorks() throws Exception { ServiceBusContract contract = config.create(ServiceBusContract.class); // Act - assertTrue("won't do this - can't recreate it yet", false); - contract.deleteQueue("Hello"); + contract.deleteQueue("TestAlpha"); // Assert } @@ -78,7 +70,7 @@ public void sendMessageWorks() throws Exception { BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("Hello", props); + contract.sendMessage("TestAlpha", props); // Assert } @@ -92,8 +84,8 @@ public void receiveMessageWorks() throws Exception { BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("Hello", props); - contract.receiveMessage("Hello", 500, ReceiveMode.RECEIVE_AND_DELETE); + contract.sendMessage("TestAlpha", props); + contract.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); // Assert } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java deleted file mode 100644 index 892f96f7b4f04..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/QueueManagementIntegrationTest.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import static org.junit.Assert.*; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import javax.ws.rs.core.MediaType; -import junit.framework.Assert; - -import org.junit.Test; - -import com.microsoft.azure.auth.wrap.WrapFilter; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ServiceBusClient; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.filter.LoggingFilter; - -public class QueueManagementIntegrationTest { - private Configuration createConfiguration() { - Configuration config = new Configuration(); - config.setProperty("serviceBus.uri", - "https://lodejard.servicebus.windows.net"); - config.setProperty("wrapClient.uri", - "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("wrapClient.scope", - "http://lodejard.servicebus.windows.net/"); - config.setProperty("wrapClient.name", "owner"); - config.setProperty("wrapClient.password", - "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - return config; - } - - private ServiceBusClient createClient() throws Exception { - return createConfiguration().create(ServiceBusClient.class); - } - - private static String readResourceFile(String name) throws IOException { - InputStream stream = Thread.currentThread().getContextClassLoader() - .getResourceAsStream(name); - - StringBuffer sb = new StringBuffer(1024); - BufferedReader reader = new BufferedReader( - new InputStreamReader(stream)); - - char[] chars = new char[1024]; - int numRead = 0; - while ((numRead = reader.read(chars)) > -1) { - sb.append(new String(chars, 0, numRead)); - } - - reader.close(); - - return sb.toString(); - } - - @Test - public void createAnyQueue() throws Exception { - - Client client = Client.create(); - client.addFilter(createConfiguration().create(WrapFilter.class)); - client.addFilter(new LoggingFilter()); - String data = readResourceFile("NewFile.xml"); - client.resource("https://lodejard.servicebus.windows.net") - .path("Hello2").delete(); - client.resource("https://lodejard.servicebus.windows.net") - .path("Hello2").type(MediaType.APPLICATION_ATOM_XML).put(data); - - } - - @Test - public void queueCanBeCreatedAndDeleted() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("queueCanBeCreatedAndDeleted"); - queue.setPath("queueCanBeCreatedAndDeleted"); - queue.save(); - queue.delete(); - - // Assert - } - - @Test - public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - try { - client.getQueue("whenQueueIsCreatedEntityStateIsAlsoUpdated") - .delete(); - } catch (Exception e) { - } - - // Act - Queue queue = client.getQueue("whenQueueIsCreatedEntityStateIsAlsoUpdated"); - Long maxSizeBefore = queue.getMaxSizeInMegabytes(); - queue.save(); - Long maxSizeAfter = queue.getMaxSizeInMegabytes(); - queue.delete(); - - // Assert - assertNull(maxSizeBefore); - assertNotNull(maxSizeAfter); - } - - @Test - public void notFoundQueuePathReturnsNull() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("NoSuchQueueName"); - - // Assert - Assert.assertNull(queue); - } - - @Test - public void existingQueuePathDoesNotReturnNull() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // client.createQueue("TestQueue02"); - - // Act - Queue queue = client.getQueue("Hello"); - queue.fetch(); - - // Assert - Assert.assertNotNull(queue); - Assert.assertEquals("Hello", queue.getPath()); - } -} From 72e88d5a39ad1c9d79023fce5b032b8a427cfdd9 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 12:18:06 -0700 Subject: [PATCH 025/664] Updating tests and implementation Adding idea of configuration profile to scope settings Disable keep-alive in tests for unit testing --- .../microsoft/azure/auth/wrap/WrapClient.java | 8 +- .../azure/configuration/Configuration.java | 10 ++- .../azure/configuration/builder/Builder.java | 4 +- .../configuration/builder/DefaultBuilder.java | 53 +++++++++--- .../azure/configuration/jersey/Exports.java | 4 +- .../contract/ServiceBusContractImpl.java | 3 +- .../builder/DefaultBuilderTest.java | 84 +++++++++++++++---- .../serviceBus/IntegrationTestBase.java | 16 +++- .../contract/ContractIntegrationTest.java | 5 +- 9 files changed, 139 insertions(+), 48 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java index 6a73544593d94..690af85b7baae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -15,10 +15,10 @@ public class WrapClient { @Inject public WrapClient( WrapContract contract, - @Named("wrapClient.uri") String uri, - @Named("wrapClient.scope") String scope, - @Named("wrapClient.name") String name, - @Named("wrapClient.password") String password) { + @Named("wrap.uri") String uri, + @Named("wrap.scope") String scope, + @Named("wrap.name") String name, + @Named("wrap.password") String password) { this.contract = contract; this.uri = uri; this.scope = scope; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 1df1025fcddf3..ec8918e90312e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -31,7 +31,7 @@ private void init() { // DefaultClientConfig clientConfig = new DefaultClientConfig(); // clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); try { - setProperty("ClientConfig", builder.build(ClientConfig.class, properties)); + setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -44,9 +44,13 @@ public static Configuration load() { } public T create(Class service) throws Exception { - return builder.build(service, properties); + return builder.build("", service, properties); } - + + public T create(String profile, Class service) throws Exception { + return builder.build(profile, service, properties); + } + public Builder getBuilder() { return builder; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 338ab12ba6c4d..60b9aa3578afe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -5,10 +5,10 @@ public interface Builder { - public abstract T build(Class service, Map properties) throws Exception; + public abstract T build(String profile, Class service, Map properties) throws Exception; public interface Factory { - T create(Builder builder, Map properties) throws Exception; + T create(String profile, Builder builder, Map properties) throws Exception; } public interface Alteration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index 455bad2949654..753026bdc8196 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -76,26 +76,34 @@ public Builder.Registry add(Class service, final Class impl addFactory(service, new Builder.Factory() { @SuppressWarnings("unchecked") - public T create(Builder builder, Map properties) throws Exception { + public T create(String profile, Builder builder, Map properties) throws Exception { Object[] initargs = new Object[parameterTypes.length]; for(int i = 0; i != parameterTypes.length; ++i) { + boolean located = false; - Annotation[] annotations = parameterAnnotations[i]; - for(int ii = 0; ii != annotations.length && !located; ++ii){ - if (Named.class.isAssignableFrom(annotations[ii].getClass())) { + String named = findNamedAnnotation(parameterAnnotations[i]); + String fullName = dotCombine(profile, named); + + boolean probeProperties = fullName != null && fullName != ""; + int startingIndex = 0; + while(!located && probeProperties) { + String probeName = fullName.substring(startingIndex); + if (!located && named != null && properties.containsKey(probeName)){ located = true; - - Named named = (Named)annotations[ii]; - if (!properties.containsKey(named.value())) { - throw new RuntimeException("Configuration missing required property: " + named.value()); + initargs[i] = properties.get(probeName); + } + else { + startingIndex = fullName.indexOf('.', startingIndex) + 1; + if (startingIndex == 0) { + probeProperties = false; } - initargs[i] = properties.get(named.value()); } } if (!located) { - initargs[i] = builder.build(parameterTypes[i], properties); + located = true; + initargs[i] = builder.build(fullName, parameterTypes[i], properties); } } @@ -106,6 +114,25 @@ public T create(Builder builder, Map properties) throws Exception } + protected String dotCombine(String profile, String named) { + boolean noProfile = profile == null || profile == ""; + boolean noName = named == null || named == ""; + if (noName) + return profile; + if (noProfile) + return named; + return profile + "." + named; + } + + protected String findNamedAnnotation(Annotation[] annotations) { + for(Annotation annotation : annotations){ + if (Named.class.isAssignableFrom(annotation.getClass())){ + return ((Named)annotation).value(); + } + } + return null; + } + public Registry add(Factory factory) { for(Type genericInterface : factory.getClass().getGenericInterfaces()) { @@ -120,12 +147,12 @@ public Registry add(Factory factory) { @SuppressWarnings("unchecked") - public T build(Class service, Map properties) throws Exception { + public T build(String profile, Class service, Map properties) throws Exception { Factory factory = (Factory) factories.get(service); if (factory == null) { - throw new RuntimeException("Service not registered: " + service.getName()); + throw new RuntimeException("Service not registered: " + profile + " " + service.getName()); } - T instance = factory.create(this, properties); + T instance = factory.create(profile, this, properties); List> alterationList = alterations.get(service); if (alterationList != null){ for(Alteration alteration : alterationList){ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java index 571035b1c67ff..cb67dd940196e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -13,13 +13,13 @@ public class Exports implements Builder.Exports { public void register(Registry registry) { registry.add(new Builder.Factory() { - public ClientConfig create(Builder builder, Map properties) { + public ClientConfig create(String profile, Builder builder, Map properties) { return new DefaultClientConfig(); } }); registry.add(new Builder.Factory() { - public Client create(Builder builder, Map properties) { + public Client create(String profile, Builder builder, Map properties) { ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); Client client = Client.create(clientConfig); client.addFilter(new LoggingFilter()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 7784d77d46bc7..2d252becb3435 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -21,7 +21,8 @@ public class ServiceBusContractImpl implements ServiceBusContract { @Inject public ServiceBusContractImpl( - Client channel, WrapFilter authFilter, + Client channel, + @Named("serviceBus") WrapFilter authFilter, @Named("serviceBus.uri") String uri, BrokerPropertiesMapper mapper) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java index cf4b105cd0a80..df7761cb40b2b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java @@ -5,25 +5,34 @@ import junit.framework.Assert; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; public class DefaultBuilderTest { + Map properties; + DefaultBuilder builder; + @Rule public ExpectedException thrown = ExpectedException.none(); + @Before + public void init() { + properties = new HashMap(); + builder = new DefaultBuilder(); + } + @Test public void namedAnnotationsComeFromBuildProperties() throws Exception { // Arrange - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithNamedParameter.class); // Act Map properties = new HashMap(); properties.put("Foo", "world"); - ClassWithNamedParameter cwnp = builder.build( + ClassWithNamedParameter cwnp = builder.build("", ClassWithNamedParameter.class, properties); // Assert @@ -35,12 +44,10 @@ public void namedAnnotationReportsMissingProperty() throws Exception { // Arrange thrown.expect(RuntimeException.class); - Map properties = new HashMap(); - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithNamedParameter.class); // Act - ClassWithNamedParameter cwnp = builder.build( + ClassWithNamedParameter cwnp = builder.build("", ClassWithNamedParameter.class, properties); // Assert @@ -50,12 +57,10 @@ public void namedAnnotationReportsMissingProperty() throws Exception { @Test public void singleCtorWithNoInjectShouldBeUsed() throws Exception { // Arrange - Map properties = new HashMap(); - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithSingleCtorNoInject.class); // Act - ClassWithSingleCtorNoInject result = builder.build( + ClassWithSingleCtorNoInject result = builder.build("", ClassWithSingleCtorNoInject.class, properties); // Assert @@ -67,12 +72,10 @@ public void multipleCtorWithNoInjectShouldFail() throws Exception { // Arrange thrown.expect(RuntimeException.class); - Map properties = new HashMap(); - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithMultipleCtorNoInject.class); // Act - ClassWithMultipleCtorNoInject result = builder.build( + ClassWithMultipleCtorNoInject result = builder.build("", ClassWithMultipleCtorNoInject.class, properties); // Assert @@ -84,12 +87,10 @@ public void multipleCtorWithMultipleInjectShouldFail() throws Exception { // Arrange thrown.expect(RuntimeException.class); - Map properties = new HashMap(); - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithMultipleCtorMultipleInject.class); // Act - ClassWithMultipleCtorMultipleInject result = builder.build( + ClassWithMultipleCtorMultipleInject result = builder.build("", ClassWithMultipleCtorMultipleInject.class, properties); // Assert @@ -99,15 +100,64 @@ public void multipleCtorWithMultipleInjectShouldFail() throws Exception { @Test public void alterationExecutesWhenInstanceCreated() throws Exception { // Arrange - Map properties = new HashMap(); - DefaultBuilder builder = new DefaultBuilder(); builder.add(ClassWithProperties.class); builder.alter(ClassWithProperties.class, new AlterClassWithProperties()); // Act - ClassWithProperties result = builder.build(ClassWithProperties.class, properties); + ClassWithProperties result = builder.build("",ClassWithProperties.class, properties); // Assert Assert.assertEquals("one - changed", result.getFoo()); } + + @Test + public void namedParametersUseProfileBasedKeysFirst() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("testing.Foo", "Profile foo value"); + + // Act + ClassWithNamedParameter result = builder.build("testing", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("Profile foo value", result.getHello()); + } + + @Test + public void namedParametersFallBackToNonProfileBasedKeys() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("testing.Foo", "Profile foo value"); + + // Act + ClassWithNamedParameter result1 = builder.build("", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result2 = builder.build("production", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("fallback", result1.getHello()); + Assert.assertEquals("fallback", result2.getHello()); + Assert.assertEquals("fallback", result2.getHello()); + } + + @Test + public void namedParamatersFallBackFromLeftToRight() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("custom.Foo", "custom.Foo value"); + properties.put("testing.custom.Foo", "testing.custom.Foo value"); + + // Act + ClassWithNamedParameter result1 = builder.build("custom", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result2 = builder.build("production.custom", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("custom.Foo value", result1.getHello()); + Assert.assertEquals("custom.Foo value", result2.getHello()); + Assert.assertEquals("testing.custom.Foo value", result3.getHello()); + } } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 6085b74aa8a40..7bf247d9c337f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -8,15 +8,23 @@ public abstract class IntegrationTestBase { protected Configuration createConfiguration() { Configuration config = new Configuration(); config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); - config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("wrapClient.name", "owner"); - config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); + config.setProperty("serviceBus.wrap.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("serviceBus.wrap.name", "owner"); + config.setProperty("serviceBus.wrap.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + config.setProperty("serviceBus.wrap.scope", "http://lodejard.servicebus.windows.net/"); + + // when mock running + //config.setProperty("serviceBus.uri", "http://localhost:8086"); + //config.setProperty("wrapClient.uri", "http://localhost:8081/WRAPv0.9"); + return config; } @Before public void initialize() throws Exception { + + System.setProperty("http.keepAlive", "false"); + ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); for(Queue queue : client.listQueues()){ if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java index 0de76c695dffc..e83526b05bef1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -12,6 +12,7 @@ public class ContractIntegrationTest extends IntegrationTestBase { + @Test public void fetchQueueAndListQueuesWorks() throws Exception { // Arrange @@ -19,7 +20,7 @@ public void fetchQueueAndListQueuesWorks() throws Exception { ServiceBusContract contract = config.create(ServiceBusContract.class); // Act - Entry entry = contract.getQueue("Hello"); + Entry entry = contract.getQueue("TestAlpha"); Feed feed = contract.getQueues(); // Assert @@ -44,7 +45,7 @@ public void createQueueWorks() throws Exception { content.setQueueDescription(description); description.setMaxSizeInMegabytes(1024L); - contract.createQueue(entry); + Entry entry2 = contract.createQueue(entry); // Assert } From 6a326e90ae320d61fa07c7338278de83ecc3cdd8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 12:42:23 -0700 Subject: [PATCH 026/664] Trying to work around SB quirks in unit tests --- .../serviceBus/IntegrationTestBase.java | 21 +++++++++++++++---- .../contract/ContractIntegrationTest.java | 12 ++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 7bf247d9c337f..cce7a5080d4cd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -22,14 +22,27 @@ protected Configuration createConfiguration() { @Before public void initialize() throws Exception { - + System.setProperty("http.proxyHost", "157.54.119.101"); + System.setProperty("http.proxyPort", "80"); System.setProperty("http.keepAlive", "false"); + boolean testAlphaExists = false; ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); for(Queue queue : client.listQueues()){ - if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) - queue.delete(); + if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) { + if (queue.getPath() == "testalpha") { + testAlphaExists = true; + long count = queue.getMessageCount(); + for(long i = 0; i != count; ++i) { + queue.receiveMessage(2000); + } + } else { + queue.delete(); + } + } + } + if (!testAlphaExists) { + client.getQueue("TestAlpha").save(); } - client.getQueue("TestAlpha").save(); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java index e83526b05bef1..b43dd5260a603 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -57,7 +57,17 @@ public void deleteQueueWorks() throws Exception { ServiceBusContract contract = config.create(ServiceBusContract.class); // Act - contract.deleteQueue("TestAlpha"); + Entry entry = new Entry(); + Content content = new Content(); + QueueDescription description = new QueueDescription(); + + entry.setTitle("TestDeleteQueueWorks"); + entry.setContent(content); + content.setType("application/xml"); + content.setQueueDescription(description); + contract.createQueue(entry); + + contract.deleteQueue("TestDeleteQueueWorks"); // Assert } From 0b79ea30a194e2036e5be6e9c3073c086857099f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 12:52:47 -0700 Subject: [PATCH 027/664] Ignoring npm artifacts, if present --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index beef00d016539..8c1a51c48c71a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .project .settings target +node_modules From cbc95b6521f6f2ec368a58ef92fa37265794f186 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 15:14:24 -0700 Subject: [PATCH 028/664] Giving WrapClient ability to cache most recent token Using 1/2 advertised lease time as conservative token renewal point Thread safe, but does not prevent concurrent token requests Most recent token response would be cached in that condition --- .../microsoft/azure/auth/wrap/WrapClient.java | 59 ++++++++- .../auth/wrap/contract/WrapContractImpl.java | 6 +- .../auth/wrap/contract/WrapResponse.java | 6 +- .../java/com/microsoft/azure/utils/Clock.java | 7 ++ .../microsoft/azure/utils/DefaultClock.java | 10 ++ .../com/microsoft/azure/utils/Exports.java | 13 ++ ...zure.configuration.builder.Builder$Exports | 1 + .../azure/auth/wrap/WrapClientTest.java | 116 ++++++++++++++++++ 8 files changed, 213 insertions(+), 5 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java index 690af85b7baae..76d7656a8bfc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -1,25 +1,37 @@ package com.microsoft.azure.auth.wrap; +import java.util.Date; + import javax.inject.Inject; import javax.inject.Named; +import javax.management.timer.Timer; import com.microsoft.azure.auth.wrap.contract.WrapContract; +import com.microsoft.azure.auth.wrap.contract.WrapResponse; +import com.microsoft.azure.utils.Clock; public class WrapClient { + WrapContract contract; + private Clock clock; private String uri; private String name; private String password; private String scope; + + private ActiveToken activeToken; + @Inject public WrapClient( WrapContract contract, + Clock clock, @Named("wrap.uri") String uri, @Named("wrap.scope") String scope, @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; + this.clock = clock; this.uri = uri; this.scope = scope; this.name = name; @@ -42,6 +54,51 @@ public void setContract(WrapContract contract) { } public String getAccessToken() { - return getContract().post(uri, name, password, scope).getAccessToken(); + Date now = clock.getNow(); + ActiveToken active = this.activeToken; + + if (active != null && now.before(active.getExpiresUtc()) ) { + return active.getWrapResponse().getAccessToken(); + } + + WrapResponse wrapResponse = getContract().post(uri, name, password, scope); + Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); + + ActiveToken acquired = new ActiveToken(); + acquired.setWrapResponse(wrapResponse); + acquired.setExpiresUtc(expiresUtc); + this.activeToken = acquired; + + return wrapResponse.getAccessToken(); + } + + class ActiveToken { + Date expiresUtc; + WrapResponse wrapResponse; + /** + * @return the expiresUtc + */ + public Date getExpiresUtc() { + return expiresUtc; + } + /** + * @param expiresUtc the expiresUtc to set + */ + public void setExpiresUtc(Date expiresUtc) { + this.expiresUtc = expiresUtc; + } + /** + * @return the wrapResponse + */ + public WrapResponse getWrapResponse() { + return wrapResponse; + } + /** + * @param wrapResponse the wrapResponse to set + */ + public void setWrapResponse(WrapResponse wrapResponse) { + this.wrapResponse = wrapResponse; + } } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java index 19a0dda3c9b23..170cafae7e38e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java @@ -26,8 +26,12 @@ public WrapResponse post(String uri, String name, String password, String scope) .post(Form.class, requestForm); WrapResponse response = new WrapResponse(); + response.setAccessToken(responseForm.getFirst("wrap_access_token")); - response.setExpiresIn(responseForm.getFirst("wrap_access_token_expires_in")); + + String expiresIn = responseForm.getFirst("wrap_access_token_expires_in"); + response.setExpiresIn(Long.parseLong(expiresIn)); + return response; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java index b007f98cdd307..5032e699947c1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java @@ -2,7 +2,7 @@ public class WrapResponse { String accessToken; - String expiresIn; + long expiresIn; /** * @return the accessToken @@ -19,13 +19,13 @@ public void setAccessToken(String accessToken) { /** * @return the expiresIn */ - public String getExpiresIn() { + public long getExpiresIn() { return expiresIn; } /** * @param expiresIn the expiresIn to set */ - public void setExpiresIn(String expiresIn) { + public void setExpiresIn(long expiresIn) { this.expiresIn = expiresIn; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java new file mode 100644 index 0000000000000..f36df655abaae --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.utils; + +import java.util.Date; + +public interface Clock { + Date getNow(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java new file mode 100644 index 0000000000000..a095e12d1b63d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.utils; + +import java.util.Date; + +public class DefaultClock implements Clock { + + public Date getNow() { + return new Date(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java new file mode 100644 index 0000000000000..a70cbd4e14379 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java @@ -0,0 +1,13 @@ +package com.microsoft.azure.utils; + +import com.microsoft.azure.configuration.builder.Builder.Registry; + +public class Exports implements + com.microsoft.azure.configuration.builder.Builder.Exports { + + public void register(Registry registry) { + registry.add(Clock.class, DefaultClock.class); + + } + +} diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index a582f449caaa4..bf00c0b1abe7b 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,3 +1,4 @@ +com.microsoft.azure.auth.wrap.utils.Exports com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java new file mode 100644 index 0000000000000..7d27b62895817 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java @@ -0,0 +1,116 @@ +package com.microsoft.azure.auth.wrap; + +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import com.microsoft.azure.auth.wrap.contract.WrapContract; +import com.microsoft.azure.auth.wrap.contract.WrapResponse; +import com.microsoft.azure.utils.Clock; + +public class WrapClientTest { + private WrapContract contract; + private WrapClient client; + private Clock clock; + private Calendar calendar; + + @Before + public void init() { + calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + clock = mock(Clock.class); + contract = mock(WrapContract.class); + client = new WrapClient( + contract, + clock, + "testurl", + "testscope", + "testname", + "testpassword"); + + when(clock.getNow()).thenAnswer(new Answer() { + public Date answer(InvocationOnMock invocation) throws Throwable { + return calendar.getTime(); + } + }); + + } + + @Test + public void clientUsesContractToGetToken(){ + // Arrange + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken"); + wrapResponse.setExpiresIn(83); + + when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + + // Act + String accessToken = client.getAccessToken(); + + // Assert + assertNotNull(accessToken); + assertEquals("testaccesstoken", accessToken); + } + + + @Test + public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid(){ + // Arrange + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken"); + wrapResponse.setExpiresIn(83); + + when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + + // Act + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); + calendar.add(Calendar.SECOND, 40); + String accessToken3 = client.getAccessToken(); + + // Assert + assertEquals("testaccesstoken", accessToken1); + assertEquals("testaccesstoken", accessToken2); + assertEquals("testaccesstoken", accessToken3); + + verify(contract, times(1)).post("testurl", "testname", "testpassword", "testscope"); + } + + @Test + public void clientWillBeCalledWhenTokenIsHalfwayToExpiring(){ + // Arrange + doAnswer(new Answer() { + int count = 0; + public WrapResponse answer(InvocationOnMock invocation) throws Throwable { + ++count; + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).post("testurl", "testname", "testpassword", "testscope"); + + // Act + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); + calendar.add(Calendar.SECOND, 45); + String accessToken3 = client.getAccessToken(); + + // Assert + assertEquals("testaccesstoken1", accessToken1); + assertEquals("testaccesstoken1", accessToken2); + assertEquals("testaccesstoken2", accessToken3); + + verify(contract, times(2)).post("testurl", "testname", "testpassword", "testscope"); + } + +} From 8d2cdc84caed9a9b57324488119345e3dc00125d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 15:46:54 -0700 Subject: [PATCH 029/664] Fixing typos --- .../com.microsoft.azure.configuration.builder.Builder$Exports | 2 +- .../azure/services/serviceBus/IntegrationTestBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index bf00c0b1abe7b..1da2036a8749e 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,5 +1,5 @@ -com.microsoft.azure.auth.wrap.utils.Exports com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports com.microsoft.azure.services.serviceBus.contract.Exports +com.microsoft.azure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index cce7a5080d4cd..e1904519bc26a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -30,7 +30,7 @@ public void initialize() throws Exception { ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); for(Queue queue : client.listQueues()){ if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) { - if (queue.getPath() == "testalpha") { + if (queue.getPath().equalsIgnoreCase("TestAlpha")) { testAlphaExists = true; long count = queue.getMessageCount(); for(long i = 0; i != count; ++i) { From db4d514a87411d78ad691c751e473ca298ff86fc Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 24 Oct 2011 18:26:43 -0700 Subject: [PATCH 030/664] Building out more api Adding a few XxxOptions for certain methods Passing send/recv message body through to network streams changing Queue "Path" property to "Name" property Using fluent property setters for inline initialization --- .../azure/services/serviceBus/Message.java | 58 +++++++++++++++++++ .../services/serviceBus/MessageReceiver.java | 6 +- .../services/serviceBus/MessageSender.java | 1 + .../serviceBus/MessageTranceiver.java | 6 -- .../serviceBus/MessageTransceiver.java | 6 ++ .../azure/services/serviceBus/Queue.java | 47 ++++++++------- .../serviceBus/ReceiveMessageOptions.java | 17 ++++++ .../serviceBus/SendMessageOptions.java | 7 +++ .../contract/ServiceBusContract.java | 6 +- .../contract/ServiceBusContractImpl.java | 18 +++--- .../microsoft/azure/utils/DefaultClock.java | 1 - .../com/microsoft/azure/utils/Exports.java | 10 +--- .../serviceBus/IntegrationTestBase.java | 6 +- .../QueueManagementIntegrationTest.java | 23 +++++++- .../contract/ContractIntegrationTest.java | 8 ++- 15 files changed, 165 insertions(+), 55 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 1b9df243130f4..6264458a1a8cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -1,5 +1,63 @@ package com.microsoft.azure.services.serviceBus; +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import com.microsoft.azure.services.serviceBus.contract.BrokerProperties; + + public class Message { + BrokerProperties properties; + InputStream body; + + public Message() { + this(new BrokerProperties(), null); + } + + public Message(InputStream body) { + this(new BrokerProperties(), body); + } + + public Message(String body) { + this(new BrokerProperties(), (body == null) ? null : new ByteArrayInputStream(body.getBytes())); + } + + Message(BrokerProperties properties, InputStream body) { + this.properties = properties; + this.body = body; + } + + BrokerProperties getProperties() { + return properties; + } + + public InputStream getBody() { + return body; + } + + public Message setBody(InputStream body) { + this.body = body; + return this; + } + + public Integer getDeliveryCount() { + return properties.getDeliveryCount(); + } + + public String getMessageId() { + return properties.getMessageId(); + } + + public Long getSequenceNumber() { + return properties.getSequenceNumber(); + } + + public Long getTimeToLive() { + return properties.getTimeToLive(); + } + public Message setTimeToLive(Long timeToLive) { + properties.setTimeToLive(timeToLive); + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index 836e214bdc88a..db0883ad9c82f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -2,8 +2,10 @@ public interface MessageReceiver { - Message receiveMessage(int timeout); - Message peekLockMessage(int timeout); + Message receiveMessage(); + Message receiveMessage(ReceiveMessageOptions options); + Message peekLockMessage(); + Message peekLockMessage(ReceiveMessageOptions options); void abandonMessage(Message message); void completeMessage(Message message); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java index 38cce540f8774..642419bd419cb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -3,4 +3,5 @@ public interface MessageSender { void sendMessage(Message message); + void sendMessage(Message message, SendMessageOptions options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java deleted file mode 100644 index 60805965530fa..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTranceiver.java +++ /dev/null @@ -1,6 +0,0 @@ - -package com.microsoft.azure.services.serviceBus; - -public interface MessageTranceiver extends MessageSender, MessageReceiver { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java new file mode 100644 index 0000000000000..8732e42fe4743 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java @@ -0,0 +1,6 @@ + +package com.microsoft.azure.services.serviceBus; + +public interface MessageTransceiver extends MessageSender, MessageReceiver { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 185d7769738f9..1eeda10df5746 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -4,11 +4,12 @@ import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; +import com.microsoft.azure.services.serviceBus.contract.MessageResult; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; -public class Queue extends AbstractEntity implements MessageSender, MessageReceiver { - Queue(ServiceBusClient client, String path) { +public class Queue extends AbstractEntity implements MessageSender, MessageReceiver, MessageTransceiver { + Queue(ServiceBusClient client, String name) { super(client); Content content = new Content(); @@ -17,7 +18,7 @@ public class Queue extends AbstractEntity implements MessageSender, MessageRecei content.setType("application/xml"); content.setQueueDescription(new QueueDescription()); - setPath(path); + setName(name); } Queue(ServiceBusClient client, Entry entry) { @@ -36,42 +37,45 @@ public void save() { } public void delete() { - getContract().deleteQueue(getPath()); + getContract().deleteQueue(getName()); } public void fetch() { - setEntry(getContract().getQueue(getPath())); + setEntry(getContract().getQueue(getName())); } + public void sendMessage(Message message) { + sendMessage(message, SendMessageOptions.DEFAULT); + } + public void sendMessage(Message message, SendMessageOptions options) { + getContract().sendMessage(getName(), message.getProperties(), message.getBody()); + } - public void sendMessage(Message message) { - // TODO Auto-generated method stub - + public Message receiveMessage() { + return receiveMessage(ReceiveMessageOptions.DEFAULT); } - public Message receiveMessage(int timeout) { - getContract().receiveMessage(getPath(), timeout, ReceiveMode.RECEIVE_AND_DELETE); - // TODO Auto-generated method stub - return null; + public Message receiveMessage(ReceiveMessageOptions options) { + MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.RECEIVE_AND_DELETE); + return new Message(result.getBrokerProperties(), result.getBody()); } - - public Message peekLockMessage(int timeout) { - // TODO Auto-generated method stub - return null; + public Message peekLockMessage() { + return peekLockMessage(ReceiveMessageOptions.DEFAULT); } + public Message peekLockMessage(ReceiveMessageOptions options) { + MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.PEEK_LOCK); + return new Message(result.getBrokerProperties(), result.getBody()); + } public void abandonMessage(Message message) { // TODO Auto-generated method stub - } - public void completeMessage(Message message) { // TODO Auto-generated method stub - } @@ -79,11 +83,11 @@ public void completeMessage(Message message) { // API properties - public String getPath() { + public String getName() { return getEntry().getTitle(); } - public void setPath(String value) { + public void setName(String value) { getEntry().setTitle(value); } @@ -106,4 +110,5 @@ public void setMaxSizeInMegabytes(Long value) { public Long getMessageCount() { return getQueueDescription().getMessageCount(); } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java new file mode 100644 index 0000000000000..426830679f3cf --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java @@ -0,0 +1,17 @@ +package com.microsoft.azure.services.serviceBus; + +public class ReceiveMessageOptions { + Integer timeout; + + public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); + + public Integer getTimeout() { + return timeout; + } + + public ReceiveMessageOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java new file mode 100644 index 0000000000000..16ed9cbae34f3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.serviceBus; + +public class SendMessageOptions { + + public static final SendMessageOptions DEFAULT = new SendMessageOptions(); + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index 5fd0f7bd31b41..745376e825d78 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -1,12 +1,14 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.io.InputStream; + import org.w3._2005.atom.Entry; import org.w3._2005.atom.Feed; public interface ServiceBusContract { - void sendMessage(String path, BrokerProperties properties); - MessageResult receiveMessage(String queuePath, int timeout, ReceiveMode receiveMode); + void sendMessage(String path, BrokerProperties properties, InputStream body); + MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode); //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); //void abandonMessage(BrokeredMessage message); //void completeMessage(BrokeredMessage message); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 2d252becb3435..3a293706a3d9a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.io.InputStream; import java.rmi.UnexpectedException; import javax.inject.Inject; @@ -40,24 +41,27 @@ public void setChannel(Client channel) { this.channel = channel; } - public void sendMessage(String path, BrokerProperties properties) { + public void sendMessage(String path, BrokerProperties properties, InputStream body) { getResource() .path(path) .path("messages") .header("BrokerProperties", mapper.toString(properties)) - .header("Content-Length", 11) - .post("Hello world"); + .post(body); } - public MessageResult receiveMessage(String queuePath, int timeout, + public MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) { MessageResult result = new MessageResult(); if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { - ClientResponse clientResult = getResource() + + WebResource resource = getResource() .path(queuePath) .path("messages") - .path("head") - .queryParam("timeout", Integer.toString(timeout)) + .path("head"); + if (timeout != null) { + resource = resource.queryParam("timeout", Integer.toString(timeout)); + } + ClientResponse clientResult = resource .delete(ClientResponse.class); result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java index a095e12d1b63d..56742882b8d56 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java @@ -3,7 +3,6 @@ import java.util.Date; public class DefaultClock implements Clock { - public Date getNow() { return new Date(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java index a70cbd4e14379..b8510ef3665ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java @@ -1,13 +1,9 @@ package com.microsoft.azure.utils; -import com.microsoft.azure.configuration.builder.Builder.Registry; +import com.microsoft.azure.configuration.builder.Builder; -public class Exports implements - com.microsoft.azure.configuration.builder.Builder.Exports { - - public void register(Registry registry) { +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { registry.add(Clock.class, DefaultClock.class); - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index e1904519bc26a..4fa5b536fc850 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -29,12 +29,12 @@ public void initialize() throws Exception { boolean testAlphaExists = false; ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); for(Queue queue : client.listQueues()){ - if (queue.getPath().startsWith("Test") || queue.getPath().startsWith("test")) { - if (queue.getPath().equalsIgnoreCase("TestAlpha")) { + if (queue.getName().startsWith("Test") || queue.getName().startsWith("test")) { + if (queue.getName().equalsIgnoreCase("TestAlpha")) { testAlphaExists = true; long count = queue.getMessageCount(); for(long i = 0; i != count; ++i) { - queue.receiveMessage(2000); + queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2000)); } } else { queue.delete(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java index 35a0cf05ff7a9..e2ba5eef88272 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -2,6 +2,8 @@ import static org.junit.Assert.*; +import java.io.ByteArrayInputStream; + import junit.framework.Assert; import org.junit.Test; @@ -62,14 +64,29 @@ public void existingQueuePathDoesNotReturnNull() throws Exception { // Arrange ServiceBusClient client = createClient(); - // client.createQueue("TestQueue02"); - // Act Queue queue = client.getQueue("Hello"); queue.fetch(); // Assert Assert.assertNotNull(queue); - Assert.assertEquals("Hello", queue.getPath()); + Assert.assertEquals("Hello", queue.getName()); + } + + @Test + public void createQueueAndSendAndReceiveMessage() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // Act + Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); + queue.save(); + + queue.sendMessage(new Message("Hello World").setTimeToLive(25L)); + Message received = queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2500)); + + // Assert + Assert.assertNotNull(received); + Assert.assertEquals(1, (int)received.getDeliveryCount()); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java index b43dd5260a603..b5658b79b2874 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -1,5 +1,7 @@ package com.microsoft.azure.services.serviceBus.contract; +import java.io.ByteArrayInputStream; + import org.junit.Test; import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; @@ -81,7 +83,7 @@ public void sendMessageWorks() throws Exception { BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("TestAlpha", props); + contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); // Assert } @@ -95,8 +97,8 @@ public void receiveMessageWorks() throws Exception { BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("TestAlpha", props); - contract.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); + contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + MessageResult message = contract.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); // Assert } From 8d106f57f9033f54e783da9f4e6e198bed962c73 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 25 Oct 2011 11:49:03 -0700 Subject: [PATCH 031/664] Starting to add peekLock semantics --- .../contract/ServiceBusContractImpl.java | 39 +++++++++++-------- .../contract/ContractIntegrationTest.java | 25 +++++++++++- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 3a293706a3d9a..f4f1922132256 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -51,24 +51,31 @@ public void sendMessage(String path, BrokerProperties properties, InputStream bo public MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) { - MessageResult result = new MessageResult(); - if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { - WebResource resource = getResource() - .path(queuePath) - .path("messages") - .path("head"); - if (timeout != null) { - resource = resource.queryParam("timeout", Integer.toString(timeout)); - } - ClientResponse clientResult = resource - .delete(ClientResponse.class); - - result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); - result.setBody(clientResult.getEntityInputStream()); - return result; + WebResource resource = getResource() + .path(queuePath) + .path("messages") + .path("head"); + + if (timeout != null) { + resource = resource.queryParam("timeout", Integer.toString(timeout)); } - throw new RuntimeException("Unknown ReceiveMode"); + + ClientResponse clientResult; + if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { + clientResult = resource.delete(ClientResponse.class); + } + else if (receiveMode == ReceiveMode.PEEK_LOCK) { + clientResult = resource.post(ClientResponse.class, ""); + } + else { + throw new RuntimeException("Unknown ReceiveMode"); + } + + MessageResult result = new MessageResult(); + result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); + result.setBody(clientResult.getEntityInputStream()); + return result; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java index b5658b79b2874..bb43c1ac5d44d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java @@ -95,11 +95,34 @@ public void receiveMessageWorks() throws Exception { ServiceBusContract contract = config.create(ServiceBusContract.class); BrokerProperties props = new BrokerProperties(); + contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); // Act - contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); MessageResult message = contract.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); // Assert + byte[] data = new byte[100]; + int size = message.getBody().read(data); + assertEquals(11, size); + assertArrayEquals("Hello World".getBytes(), data); + } + + @Test + public void peekLockMessageWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + ServiceBusContract contract = config.create(ServiceBusContract.class); + + BrokerProperties props = new BrokerProperties(); + + // Act + contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + MessageResult message = contract.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); + + // Assert + byte[] data = new byte[100]; + int size = message.getBody().read(data); + assertEquals(11, size); + assertEquals("Hello World", new String(data, 0, size)); } } From d11debb7f8c97f6176fb27bf2417e99ea3264a6b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 25 Oct 2011 23:16:18 -0700 Subject: [PATCH 032/664] Adding properties related to peeklock --- .../azure/services/serviceBus/Message.java | 16 ++++++ .../services/serviceBus/ServiceBusClient.java | 12 ++++- .../serviceBus/contract/BrokerProperties.java | 49 ++++++++++--------- .../QueueManagementIntegrationTest.java | 36 ++++++++++---- 4 files changed, 78 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 6264458a1a8cc..59711059aae1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -10,6 +10,22 @@ public class Message { BrokerProperties properties; InputStream body; + public String getLockToken() { + return properties.getLockToken(); + } + + public void setLockToken(String lockToken) { + properties.setLockToken(lockToken); + } + + public String getLockedUntilUtc() { + return properties.getLockedUntilUtc(); + } + + public void setLockedUntilUtc(String lockedUntilUtc) { + properties.setLockedUntilUtc(lockedUntilUtc); + } + public Message() { this(new BrokerProperties(), null); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 2abc6d76ba6c5..b4fff0799963f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -15,13 +15,21 @@ public class ServiceBusClient { ServiceBusContract contract; public ServiceBusClient() throws Exception { - this(Configuration.load()); + this("", Configuration.load()); } public ServiceBusClient(Configuration config) throws Exception { - this(config.create(ServiceBusContract.class)); + this("", config); + } + + public ServiceBusClient(String profile) throws Exception { + this(profile, Configuration.load()); } + public ServiceBusClient(String profile, Configuration config) throws Exception { + this(config.create(profile, ServiceBusContract.class)); + } + @Inject public ServiceBusClient(ServiceBusContract contract) { this.contract = contract; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java index b60438e144df9..ad2b3ee1a680a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java @@ -21,65 +21,66 @@ public class BrokerProperties { @JsonProperty("TimeToLive") Long timeToLive; - /** - * @return the deliveryCount - */ + @JsonProperty("LockToken") + String lockToken; + + @JsonProperty("LockedUntilUtc") + String lockedUntilUtc; + + @JsonIgnore public Integer getDeliveryCount() { return deliveryCount; } - /** - * @param deliveryCount the deliveryCount to set - */ public void setDeliveryCount(Integer deliveryCount) { this.deliveryCount = deliveryCount; } - /** - * @return the messageId - */ @JsonIgnore public String getMessageId() { return messageId; } - /** - * @param messageId the messageId to set - */ public void setMessageId(String messageId) { this.messageId = messageId; } - /** - * @return the sequenceNumber - */ @JsonIgnore public Long getSequenceNumber() { return sequenceNumber; } - /** - * @param sequenceNumber the sequenceNumber to set - */ public void setSequenceNumber(Long sequenceNumber) { this.sequenceNumber = sequenceNumber; } - /** - * @return the timeToLive - */ @JsonIgnore public Long getTimeToLive() { return timeToLive; } - /** - * @param timeToLive the timeToLive to set - */ public void setTimeToLive(Long timeToLive) { this.timeToLive = timeToLive; } + @JsonIgnore + public String getLockToken() { + return lockToken; + } + + public void setLockToken(String lockToken) { + this.lockToken = lockToken; + } + + @JsonIgnore + public String getLockedUntilUtc() { + return lockedUntilUtc; + } + + public void setLockedUntilUtc(String lockedUntilUtc) { + this.lockedUntilUtc = lockedUntilUtc; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java index e2ba5eef88272..ec19402ab9616 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -4,13 +4,12 @@ import java.io.ByteArrayInputStream; -import junit.framework.Assert; - import org.junit.Test; import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.ServiceBusClient; + public class QueueManagementIntegrationTest extends IntegrationTestBase { private ServiceBusClient createClient() throws Exception { @@ -56,7 +55,7 @@ public void notFoundQueuePathReturnsNull() throws Exception { Queue queue = client.getQueue("NoSuchQueueName"); // Assert - Assert.assertNull(queue); + assertNull(queue); } @Test @@ -69,8 +68,8 @@ public void existingQueuePathDoesNotReturnNull() throws Exception { queue.fetch(); // Assert - Assert.assertNotNull(queue); - Assert.assertEquals("Hello", queue.getName()); + assertNotNull(queue); + assertEquals("Hello", queue.getName()); } @Test @@ -82,11 +81,30 @@ public void createQueueAndSendAndReceiveMessage() throws Exception { Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); queue.save(); - queue.sendMessage(new Message("Hello World").setTimeToLive(25L)); - Message received = queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2500)); + queue.sendMessage(new Message("Hello World")); + Message received = queue.receiveMessage(); + + // Assert + assertNotNull(received); + assertEquals(1, (int)received.getDeliveryCount()); + } + + + @Test + public void peekLockedMessageHasLockTokenAndLockedUntilUtc() throws Exception { + // Arrange + ServiceBusClient client = createClient(); + + // Act + Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); + queue.save(); + + queue.sendMessage(new Message("Hello World")); + Message received = queue.peekLockMessage(); // Assert - Assert.assertNotNull(received); - Assert.assertEquals(1, (int)received.getDeliveryCount()); + assertNotNull(received); + assertNotNull(received.getLockToken()); + assertNotNull(received.getLockedUntilUtc()); } } From c036d0c737f62128a43457ce014f0f19989185fc Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 25 Oct 2011 23:19:59 -0700 Subject: [PATCH 033/664] Adding some //REVIEW notes from code review Also renames Clock interface to DateFactory --- .../microsoft/azure/auth/wrap/WrapClient.java | 10 ++++---- .../serviceBus/ListQueuesOptions.java | 24 +++++++++++++++++++ .../services/serviceBus/ServiceBusClient.java | 5 ++++ .../contract/ServiceBusContractImpl.java | 11 +++++---- .../utils/{Clock.java => DateFactory.java} | 4 ++-- ...aultClock.java => DefaultDateFactory.java} | 4 ++-- .../com/microsoft/azure/utils/Exports.java | 2 +- .../azure/auth/wrap/WrapClientTest.java | 10 ++++---- .../QueueManagementIntegrationTest.java | 2 +- 9 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/utils/{Clock.java => DateFactory.java} (56%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/utils/{DefaultClock.java => DefaultDateFactory.java} (51%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java index 76d7656a8bfc1..33449b5d027d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -8,12 +8,12 @@ import com.microsoft.azure.auth.wrap.contract.WrapContract; import com.microsoft.azure.auth.wrap.contract.WrapResponse; -import com.microsoft.azure.utils.Clock; +import com.microsoft.azure.utils.DateFactory; public class WrapClient { WrapContract contract; - private Clock clock; + private DateFactory dateFactory; private String uri; private String name; private String password; @@ -25,13 +25,13 @@ public class WrapClient { @Inject public WrapClient( WrapContract contract, - Clock clock, + DateFactory dateFactory, @Named("wrap.uri") String uri, @Named("wrap.scope") String scope, @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; - this.clock = clock; + this.dateFactory = dateFactory; this.uri = uri; this.scope = scope; this.name = name; @@ -54,7 +54,7 @@ public void setContract(WrapContract contract) { } public String getAccessToken() { - Date now = clock.getNow(); + Date now = dateFactory.getDate(); ActiveToken active = this.activeToken; if (active != null && now.before(active.getExpiresUtc()) ) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java new file mode 100644 index 0000000000000..3a966f2927969 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.serviceBus; + +public class ListQueuesOptions { + + public static final ListQueuesOptions DEFAULT = new ListQueuesOptions(); + + Integer skip; + public Integer getSkip() { + return skip; + } + public ListQueuesOptions setSkip(Integer skip) { + this.skip = skip; + return this; + } + public Integer getMaxCount() { + return maxCount; + } + public ListQueuesOptions setMaxCount(Integer maxCount) { + this.maxCount = maxCount; + return this; + } + Integer maxCount; + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index b4fff0799963f..85a015832e211 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -44,6 +44,11 @@ public void setContract(ServiceBusContract contract) { } public Iterable listQueues() { + return listQueues(ListQueuesOptions.DEFAULT); + } + + // REVIEW: what is the generalized strategy for paginated, client-roundtrippable iteration + public Iterable listQueues(ListQueuesOptions options) { Feed descriptions = contract.getQueues(); ArrayList queues = new ArrayList(); for (int i = 0; i != descriptions.getEntries().size(); ++i) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index f4f1922132256..912432310598f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -41,6 +41,12 @@ public void setChannel(Client channel) { this.channel = channel; } + private WebResource getResource() { + return getChannel() + .resource(uri); + } + + // REVIEW: contentType will be needed public void sendMessage(String path, BrokerProperties properties, InputStream body) { getResource() .path(path) @@ -92,11 +98,6 @@ public void deleteQueue(String queuePath) { .delete(); } - private WebResource getResource() { - return getChannel() - .resource(uri); - } - public Entry getQueue(String queuePath) { return getResource() .path(queuePath) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java similarity index 56% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java index f36df655abaae..5ed6361a48beb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Clock.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java @@ -2,6 +2,6 @@ import java.util.Date; -public interface Clock { - Date getNow(); +public interface DateFactory { + Date getDate(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java similarity index 51% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java index 56742882b8d56..25e28411cb3b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultClock.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java @@ -2,8 +2,8 @@ import java.util.Date; -public class DefaultClock implements Clock { - public Date getNow() { +public class DefaultDateFactory implements DateFactory { + public Date getDate() { return new Date(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java index b8510ef3665ca..c7c0a63df09c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java @@ -4,6 +4,6 @@ public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(Clock.class, DefaultClock.class); + registry.add(DateFactory.class, DefaultDateFactory.class); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java index 7d27b62895817..78124d937d66b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java @@ -14,29 +14,29 @@ import com.microsoft.azure.auth.wrap.contract.WrapContract; import com.microsoft.azure.auth.wrap.contract.WrapResponse; -import com.microsoft.azure.utils.Clock; +import com.microsoft.azure.utils.DateFactory; public class WrapClientTest { private WrapContract contract; private WrapClient client; - private Clock clock; + private DateFactory dateFactory; private Calendar calendar; @Before public void init() { calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - clock = mock(Clock.class); + dateFactory = mock(DateFactory.class); contract = mock(WrapContract.class); client = new WrapClient( contract, - clock, + dateFactory, "testurl", "testscope", "testname", "testpassword"); - when(clock.getNow()).thenAnswer(new Answer() { + when(dateFactory.getDate()).thenAnswer(new Answer() { public Date answer(InvocationOnMock invocation) throws Throwable { return calendar.getTime(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java index ec19402ab9616..51d3b0f921a82 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -13,7 +13,7 @@ public class QueueManagementIntegrationTest extends IntegrationTestBase { private ServiceBusClient createClient() throws Exception { - return createConfiguration().create(ServiceBusClient.class); + return new ServiceBusClient(createConfiguration()); } @Test From bebaee1484d1f093468b4a2cd6efd8af076a0382 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 26 Oct 2011 16:46:55 -0700 Subject: [PATCH 034/664] System robustness Adding a logger reference Adding serviceexceptionfactory throwing deterministic exceptions from SBContract and WrapContract --- microsoft-azure-api/pom.xml | 5 + .../com/microsoft/azure/ServiceException.java | 8 + .../microsoft/azure/auth/wrap/WrapClient.java | 3 +- .../microsoft/azure/auth/wrap/WrapFilter.java | 9 +- .../auth/wrap/contract/WrapContract.java | 4 +- .../auth/wrap/contract/WrapContractImpl.java | 25 ++- .../azure/configuration/jersey/Exports.java | 7 +- .../services/serviceBus/MessageReceiver.java | 14 +- .../services/serviceBus/MessageSender.java | 6 +- .../azure/services/serviceBus/Queue.java | 19 +- .../services/serviceBus/ServiceBusClient.java | 5 +- .../contract/ServiceBusContract.java | 52 +++--- .../contract/ServiceBusContractImpl.java | 167 ++++++++++++++---- .../azure/utils/ServiceExceptionFactory.java | 84 +++++++++ .../azure/auth/wrap/WrapClientTest.java | 7 +- .../serviceBus/IntegrationTestBase.java | 14 +- .../QueueManagementIntegrationTest.java | 4 +- .../serviceBus/QueueManagementTest.java | 5 +- .../utils/ServiceExceptionFactoryTest.java | 66 +++++++ 19 files changed, 406 insertions(+), 98 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index df0af93f2d3ed..b5ee7f0df3563 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -40,6 +40,11 @@ jersey-json 1.10-b02 + + commons-logging + commons-logging + 1.1.1 + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java index 0f3caec7db896..a7c96a5df82e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java @@ -9,6 +9,7 @@ public class ServiceException extends Exception { int httpStatusCode; String httpReasonPhrase; + String serviceName; String errorCode; String errorMessage; @@ -74,4 +75,11 @@ public String getErrorValue(String name) { public void setErrorValue(String name, String value) { this.errorValues.put(name, value); } + public String getServiceName() { + return serviceName; + } + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java index 33449b5d027d2..01b780cb90cf5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -6,6 +6,7 @@ import javax.inject.Named; import javax.management.timer.Timer; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.contract.WrapContract; import com.microsoft.azure.auth.wrap.contract.WrapResponse; import com.microsoft.azure.utils.DateFactory; @@ -53,7 +54,7 @@ public void setContract(WrapContract contract) { this.contract = contract; } - public String getAccessToken() { + public String getAccessToken() throws ServiceException { Date now = dateFactory.getDate(); ActiveToken active = this.activeToken; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java index 8a41646805146..dd77896c9d622 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java @@ -1,5 +1,6 @@ package com.microsoft.azure.auth.wrap; +import com.microsoft.azure.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -16,7 +17,13 @@ public WrapFilter(WrapClient client) { public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - String accessToken = client.getAccessToken(); + String accessToken; + try { + accessToken = client.getAccessToken(); + } catch (ServiceException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java index 7f6d35e031b2e..261c3c7f3cd44 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java @@ -1,5 +1,7 @@ package com.microsoft.azure.auth.wrap.contract; +import com.microsoft.azure.ServiceException; + public interface WrapContract { - WrapResponse post(String uri, String name, String password, String scope); + WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java index 170cafae7e38e..194d7656b7120 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java @@ -3,27 +3,42 @@ import javax.inject.Inject; import javax.ws.rs.core.MediaType; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; public class WrapContractImpl implements WrapContract { Client channel; + static Log log = LogFactory.getLog(WrapContract.class); + @Inject public WrapContractImpl(Client channel) { this.channel = channel; } - public WrapResponse post(String uri, String name, String password, String scope) { + public WrapResponse post(String uri, String name, String password, String scope) throws ServiceException { Form requestForm = new Form(); requestForm.add("wrap_name", name); requestForm.add("wrap_password", password); requestForm.add("wrap_scope", scope); - Form responseForm = channel.resource(uri) - .accept(MediaType.APPLICATION_FORM_URLENCODED) - .type(MediaType.APPLICATION_FORM_URLENCODED) - .post(Form.class, requestForm); + Form responseForm; + try { + responseForm = channel.resource(uri) + .accept(MediaType.APPLICATION_FORM_URLENCODED) + .type(MediaType.APPLICATION_FORM_URLENCODED) + .post(Form.class, requestForm); + } + catch (UniformInterfaceException e) { + log.warn("Failed WrapContract.post operation", e); + throw ServiceExceptionFactory.create("WRAP", "Failed WrapContract.post operation", e); + } WrapResponse response = new WrapResponse(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java index cb67dd940196e..caa8ac407e170 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -1,6 +1,7 @@ package com.microsoft.azure.configuration.jersey; import java.util.Map; +import java.util.Map.Entry; import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.configuration.builder.Builder.Registry; @@ -14,7 +15,11 @@ public class Exports implements Builder.Exports { public void register(Registry registry) { registry.add(new Builder.Factory() { public ClientConfig create(String profile, Builder builder, Map properties) { - return new DefaultClientConfig(); + ClientConfig clientConfig = new DefaultClientConfig(); + for(Entry entry : properties.entrySet()) { + clientConfig.getProperties().put(entry.getKey(), entry.getValue()); + } + return clientConfig; } }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java index db0883ad9c82f..2b8c23ae22ae9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java @@ -1,11 +1,13 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.ServiceException; + public interface MessageReceiver { - Message receiveMessage(); - Message receiveMessage(ReceiveMessageOptions options); - Message peekLockMessage(); - Message peekLockMessage(ReceiveMessageOptions options); - void abandonMessage(Message message); - void completeMessage(Message message); + Message receiveMessage() throws ServiceException; + Message receiveMessage(ReceiveMessageOptions options) throws ServiceException; + Message peekLockMessage() throws ServiceException; + Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException; + void abandonMessage(Message message) throws ServiceException; + void completeMessage(Message message) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java index 642419bd419cb..a6a5dbe129917 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java @@ -1,7 +1,9 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.ServiceException; + public interface MessageSender { - void sendMessage(Message message); - void sendMessage(Message message, SendMessageOptions options); + void sendMessage(Message message) throws ServiceException; + void sendMessage(Message message, SendMessageOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 1eeda10df5746..0cf1547e3fa3d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -4,6 +4,7 @@ import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.contract.MessageResult; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; @@ -32,40 +33,40 @@ QueueDescription getQueueDescription(){ // API methods - public void save() { + public void save() throws ServiceException { setEntry(getContract().createQueue(getEntry())); } - public void delete() { + public void delete() throws ServiceException { getContract().deleteQueue(getName()); } - public void fetch() { + public void fetch() throws ServiceException { setEntry(getContract().getQueue(getName())); } - public void sendMessage(Message message) { + public void sendMessage(Message message) throws ServiceException { sendMessage(message, SendMessageOptions.DEFAULT); } - public void sendMessage(Message message, SendMessageOptions options) { + public void sendMessage(Message message, SendMessageOptions options) throws ServiceException { getContract().sendMessage(getName(), message.getProperties(), message.getBody()); } - public Message receiveMessage() { + public Message receiveMessage() throws ServiceException { return receiveMessage(ReceiveMessageOptions.DEFAULT); } - public Message receiveMessage(ReceiveMessageOptions options) { + public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.RECEIVE_AND_DELETE); return new Message(result.getBrokerProperties(), result.getBody()); } - public Message peekLockMessage() { + public Message peekLockMessage() throws ServiceException { return peekLockMessage(ReceiveMessageOptions.DEFAULT); } - public Message peekLockMessage(ReceiveMessageOptions options) { + public Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException { MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.PEEK_LOCK); return new Message(result.getBrokerProperties(), result.getBody()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java index 85a015832e211..269601f142786 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java @@ -7,6 +7,7 @@ import org.w3._2005.atom.Feed; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; @@ -43,12 +44,12 @@ public void setContract(ServiceBusContract contract) { this.contract = contract; } - public Iterable listQueues() { + public Iterable listQueues() throws ServiceException { return listQueues(ListQueuesOptions.DEFAULT); } // REVIEW: what is the generalized strategy for paginated, client-roundtrippable iteration - public Iterable listQueues(ListQueuesOptions options) { + public Iterable listQueues(ListQueuesOptions options) throws ServiceException { Feed descriptions = contract.getQueues(); ArrayList queues = new ArrayList(); for (int i = 0; i != descriptions.getEntries().size(); ++i) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java index 745376e825d78..def3a61dde221 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java @@ -5,32 +5,34 @@ import org.w3._2005.atom.Entry; import org.w3._2005.atom.Feed; +import com.microsoft.azure.ServiceException; + public interface ServiceBusContract { - void sendMessage(String path, BrokerProperties properties, InputStream body); - MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode); - //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode); - //void abandonMessage(BrokeredMessage message); - //void completeMessage(BrokeredMessage message); - - Entry createQueue(Entry queue); - void deleteQueue(String queuePath); - Entry getQueue(String queuePath); - Feed getQueues(); - - Entry createTopic(Entry topic); - void deleteTopic(String topicPath); - Entry getTopic(String topicPath); - Feed getTopics(); - - void addSubscription(String topicPath, String subscriptionName, Entry subscription); - void removeSubscription(String topicPath, String subscriptionName); - Entry getSubscription(String topicPath, String subscriptionName); - Feed getSubscriptions(String topicPath); - - void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule); - void removeRule(String topicPath, String subscriptionName, String ruleName); - Entry getRule(String topicPath, String subscriptionName, String ruleName); - Feed getRules(String topicPath, String subscriptionName); + void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException; + MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException; + //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; + //void abandonMessage(BrokeredMessage message) throws ServiceException; + //void completeMessage(BrokeredMessage message) throws ServiceException; + + Entry createQueue(Entry queue) throws ServiceException; + void deleteQueue(String queuePath) throws ServiceException; + Entry getQueue(String queuePath) throws ServiceException; + Feed getQueues() throws ServiceException; + + Entry createTopic(Entry topic) throws ServiceException; + void deleteTopic(String topicPath) throws ServiceException; + Entry getTopic(String topicPath) throws ServiceException; + Feed getTopics() throws ServiceException; + + void addSubscription(String topicPath, String subscriptionName, Entry subscription) throws ServiceException; + void removeSubscription(String topicPath, String subscriptionName) throws ServiceException; + Entry getSubscription(String topicPath, String subscriptionName) throws ServiceException; + Feed getSubscriptions(String topicPath) throws ServiceException; + + void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule) throws ServiceException; + void removeRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; + Entry getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; + Feed getRules(String topicPath, String subscriptionName) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index 912432310598f..bff5af8f74390 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -6,12 +6,18 @@ import javax.inject.Inject; import javax.inject.Named; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.w3._2005.atom.Entry; import org.w3._2005.atom.Feed; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.WrapFilter; +import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; public class ServiceBusContractImpl implements ServiceBusContract { @@ -19,6 +25,7 @@ public class ServiceBusContractImpl implements ServiceBusContract { private Client channel; private String uri; private BrokerPropertiesMapper mapper; + static Log log = LogFactory.getLog(ServiceBusContract.class); @Inject public ServiceBusContractImpl( @@ -47,16 +54,26 @@ private WebResource getResource() { } // REVIEW: contentType will be needed - public void sendMessage(String path, BrokerProperties properties, InputStream body) { - getResource() - .path(path) - .path("messages") - .header("BrokerProperties", mapper.toString(properties)) - .post(body); + public void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException { + try { + getResource() + .path(path) + .path("messages") + .header("BrokerProperties", mapper.toString(properties)) + .post(body); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } public MessageResult receiveMessage(String queuePath, Integer timeout, - ReceiveMode receiveMode) { + ReceiveMode receiveMode) throws ServiceException { WebResource resource = getResource() .path(queuePath) @@ -69,10 +86,30 @@ public MessageResult receiveMessage(String queuePath, Integer timeout, ClientResponse clientResult; if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { - clientResult = resource.delete(ClientResponse.class); + try { + clientResult = resource.delete(ClientResponse.class); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } else if (receiveMode == ReceiveMode.PEEK_LOCK) { - clientResult = resource.post(ClientResponse.class, ""); + try { + clientResult = resource.post(ClientResponse.class, ""); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } else { throw new RuntimeException("Unknown ReceiveMode"); @@ -85,42 +122,102 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { } - public Entry createQueue(Entry entry) { - return getResource() - .path(entry.getTitle()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Entry.class, entry); + public Entry createQueue(Entry entry) throws ServiceException { + try { + return getResource() + .path(entry.getTitle()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Entry.class, entry); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } - public void deleteQueue(String queuePath) { - getResource() - .path(queuePath) - .delete(); + public void deleteQueue(String queuePath) throws ServiceException { + try { + getResource() + .path(queuePath) + .delete(); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } - public Entry getQueue(String queuePath) { - return getResource() - .path(queuePath) - .get(Entry.class); + public Entry getQueue(String queuePath) throws ServiceException { + try { + return getResource() + .path(queuePath) + .get(Entry.class); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } - public Feed getQueues() { - return getResource() - .path("$Resources/Queues") - .get(Feed.class); + public Feed getQueues() throws ServiceException { + try { + return getResource() + .path("$Resources/Queues") + .get(Feed.class); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } - public Entry createTopic(Entry entry) { - return getResource() - .path(entry.getTitle()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Entry.class, entry); + public Entry createTopic(Entry entry) throws ServiceException { + try { + return getResource() + .path(entry.getTitle()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Entry.class, entry); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } - public void deleteTopic(String topicPath) { - getResource() - .path(topicPath) - .delete(); + public void deleteTopic(String topicPath) throws ServiceException { + try { + getResource() + .path(topicPath) + .delete(); + } + catch(UniformInterfaceException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } + catch(ClientHandlerException e) { + log.warn(e); + throw ServiceExceptionFactory.create("serviceBus", e); + } } public Entry getTopic(String topicPath) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java new file mode 100644 index 0000000000000..ae1178aa16d08 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java @@ -0,0 +1,84 @@ +package com.microsoft.azure.utils; + +import com.microsoft.azure.ServiceException; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.ClientResponse.Status; +import com.sun.jersey.api.client.UniformInterfaceException; + +public class ServiceExceptionFactory { + public static ServiceException create(String serviceName, String message, UniformInterfaceException cause){ + ServiceException exception = new ServiceException(message, cause); + populate(exception, serviceName, cause); + return exception; + } + + public static ServiceException create(String serviceName, UniformInterfaceException cause) { + ServiceException exception = new ServiceException(cause); + populate(exception, serviceName, cause); + return exception; + } + + public static ServiceException create(String serviceName, String message, ClientHandlerException cause) { + ServiceException exception = new ServiceException(message, cause); + for (Throwable scan = cause; scan != null; scan = scan.getCause()) { + if (ServiceException.class.isAssignableFrom(scan.getClass())) { + populate(exception, serviceName, (ServiceException)scan); + break; + } + else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { + populate(exception, serviceName, (UniformInterfaceException)scan); + break; + } + } + return exception; + } + + public static ServiceException create(String serviceName, ClientHandlerException cause) { + ServiceException exception = new ServiceException(cause); + for (Throwable scan = cause; scan != null; scan = scan.getCause()) { + if (ServiceException.class.isAssignableFrom(scan.getClass())) { + populate(exception, serviceName, (ServiceException)scan); + break; + } + else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { + populate(exception, serviceName, (UniformInterfaceException)scan); + break; + } + } + return exception; + } + + static void populate(ServiceException exception, String serviceName, + UniformInterfaceException cause) { + exception.setServiceName(serviceName); + + if (cause != null) { + ClientResponse response = cause.getResponse(); + if (response != null) { + Status status = response.getClientResponseStatus(); + if (status == null) { + status = Status.fromStatusCode(response.getStatus()); + } + if (status == null) { + exception.setHttpStatusCode(response.getStatus()); + } + else { + exception.setHttpStatusCode(status.getStatusCode()); + exception.setHttpReasonPhrase(status.getReasonPhrase()); + } + } + } + } + + static void populate(ServiceException exception, String serviceName, + ServiceException cause) { + exception.setServiceName(cause.getServiceName()); + exception.setHttpStatusCode(cause.getHttpStatusCode()); + exception.setHttpReasonPhrase(cause.getHttpReasonPhrase()); + exception.setErrorCode(cause.getErrorCode()); + exception.setErrorMessage(cause.getErrorMessage()); + exception.setErrorValues(cause.getErrorValues()); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java index 78124d937d66b..c99b079aa8494 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.contract.WrapContract; import com.microsoft.azure.auth.wrap.contract.WrapResponse; import com.microsoft.azure.utils.DateFactory; @@ -45,7 +46,7 @@ public Date answer(InvocationOnMock invocation) throws Throwable { } @Test - public void clientUsesContractToGetToken(){ + public void clientUsesContractToGetToken() throws ServiceException{ // Arrange WrapResponse wrapResponse = new WrapResponse(); wrapResponse.setAccessToken("testaccesstoken"); @@ -63,7 +64,7 @@ public void clientUsesContractToGetToken(){ @Test - public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid(){ + public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException{ // Arrange WrapResponse wrapResponse = new WrapResponse(); wrapResponse.setAccessToken("testaccesstoken"); @@ -86,7 +87,7 @@ public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid(){ } @Test - public void clientWillBeCalledWhenTokenIsHalfwayToExpiring(){ + public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException{ // Arrange doAnswer(new Answer() { int count = 0; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 4fa5b536fc850..56ebd7053e75b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -1,6 +1,9 @@ package com.microsoft.azure.services.serviceBus; +import java.io.Console; + import org.junit.Before; +import org.junit.BeforeClass; import com.microsoft.azure.configuration.Configuration; @@ -19,12 +22,17 @@ protected Configuration createConfiguration() { return config; } + + @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.setProperty("http.proxyHost", "157.54.119.101"); - System.setProperty("http.proxyPort", "80"); - System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java index 51d3b0f921a82..0293ab0fd8bc2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -64,12 +64,12 @@ public void existingQueuePathDoesNotReturnNull() throws Exception { ServiceBusClient client = createClient(); // Act - Queue queue = client.getQueue("Hello"); + Queue queue = client.getQueue("TestAlpha"); queue.fetch(); // Assert assertNotNull(queue); - assertEquals("Hello", queue.getName()); + assertEquals("TestAlpha", queue.getName()); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java index 67a3f236cdfa7..ed0ede5d2374d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java @@ -11,13 +11,14 @@ import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; public class QueueManagementTest { @Test - public void testGetQueueAcquiresDescriptionFromServer() { + public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException { // Arrange ServiceBusContract contract = mock(ServiceBusContract.class); @@ -38,7 +39,7 @@ public void testGetQueueAcquiresDescriptionFromServer() { } @Test - public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException { + public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException, ServiceException { // Arrange ServiceBusContract contract = mock(ServiceBusContract.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java new file mode 100644 index 0000000000000..1952ab64d4758 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java @@ -0,0 +1,66 @@ +package com.microsoft.azure.utils; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; + +import org.junit.Test; + +import com.microsoft.azure.ServiceException; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; + +public class ServiceExceptionFactoryTest { + @Test + public void serviceNameAndMessageAndCauseAppearInException() { + // Arrange + ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException cause = new UniformInterfaceException( + response); + + // Act + ServiceException exception = ServiceExceptionFactory.create("testing", + "this is a test", cause); + + // Assert + assertNotNull(exception); + assertEquals("testing", exception.getServiceName()); + assertEquals("this is a test", exception.getMessage()); + assertEquals(cause, exception.getCause()); + } + + @Test + public void httpStatusCodeAndReasonPhraseAppearInException() { + // Arrange + ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException cause = new UniformInterfaceException( + response); + + // Act + ServiceException exception = ServiceExceptionFactory.create("testing", + "this is a test", cause); + + // Assert + assertNotNull(exception); + assertEquals(404, exception.getHttpStatusCode()); + assertEquals("Not Found", exception.getHttpReasonPhrase()); + } + + @Test + public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExceptions() { + // Arrange + ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException rootCause = new UniformInterfaceException(response); + ServiceException originalDescription = ServiceExceptionFactory.create("underlying", rootCause); + ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); + + // Act + ServiceException exception = ServiceExceptionFactory.create("actual", wrappingException); + + // Assert + assertEquals(503, exception.getHttpStatusCode()); + assertEquals("underlying", exception.getServiceName()); + } + +} From e0e52aceb8ec05c104a6843eb193a9bbe294f72f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 26 Oct 2011 18:20:29 -0700 Subject: [PATCH 035/664] Refactor how ServiceException is created the instance is created within the catch block, and the rest of the properties are assigned in the serviceexceptionfactory, in order to produce better exception call stacks --- .../auth/wrap/contract/WrapContractImpl.java | 4 +- .../contract/ServiceBusContractImpl.java | 60 ++++++++----------- .../azure/utils/ServiceExceptionFactory.java | 45 ++++---------- .../serviceBus/IntegrationTestBase.java | 6 +- .../QueueManagementIntegrationTest.java | 11 ---- .../utils/ServiceExceptionFactoryTest.java | 10 ++-- 6 files changed, 47 insertions(+), 89 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java index 194d7656b7120..46fe925aa0527 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java @@ -36,8 +36,8 @@ public WrapResponse post(String uri, String name, String password, String scope) .post(Form.class, requestForm); } catch (UniformInterfaceException e) { - log.warn("Failed WrapContract.post operation", e); - throw ServiceExceptionFactory.create("WRAP", "Failed WrapContract.post operation", e); + log.warn("WRAP server returned error acquiring access_token", e); + throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); } WrapResponse response = new WrapResponse(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java index bff5af8f74390..f7f330edc851f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java @@ -53,6 +53,11 @@ private WebResource getResource() { .resource(uri); } + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("serviceBus", e); + } + // REVIEW: contentType will be needed public void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException { try { @@ -63,12 +68,10 @@ public void sendMessage(String path, BrokerProperties properties, InputStream bo .post(body); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -90,12 +93,10 @@ public MessageResult receiveMessage(String queuePath, Integer timeout, clientResult = resource.delete(ClientResponse.class); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } else if (receiveMode == ReceiveMode.PEEK_LOCK) { @@ -103,18 +104,17 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { clientResult = resource.post(ClientResponse.class, ""); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } else { throw new RuntimeException("Unknown ReceiveMode"); } + // REVIEW: harden this - it's much too brittle. throws null exceptions very easily MessageResult result = new MessageResult(); result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); result.setBody(clientResult.getEntityInputStream()); @@ -130,12 +130,10 @@ public Entry createQueue(Entry entry) throws ServiceException { .put(Entry.class, entry); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -146,12 +144,10 @@ public void deleteQueue(String queuePath) throws ServiceException { .delete(); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -162,12 +158,10 @@ public Entry getQueue(String queuePath) throws ServiceException { .get(Entry.class); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -178,12 +172,10 @@ public Feed getQueues() throws ServiceException { .get(Feed.class); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -195,12 +187,10 @@ public Entry createTopic(Entry entry) throws ServiceException { .put(Entry.class, entry); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } @@ -211,12 +201,10 @@ public void deleteTopic(String topicPath) throws ServiceException { .delete(); } catch(UniformInterfaceException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } catch(ClientHandlerException e) { - log.warn(e); - throw ServiceExceptionFactory.create("serviceBus", e); + throw processCatch(new ServiceException(e)); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java index ae1178aa16d08..e01fe3fd12067 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java @@ -7,49 +7,26 @@ import com.sun.jersey.api.client.UniformInterfaceException; public class ServiceExceptionFactory { - public static ServiceException create(String serviceName, String message, UniformInterfaceException cause){ - ServiceException exception = new ServiceException(message, cause); - populate(exception, serviceName, cause); - return exception; - } - - public static ServiceException create(String serviceName, UniformInterfaceException cause) { - ServiceException exception = new ServiceException(cause); - populate(exception, serviceName, cause); - return exception; - } - public static ServiceException create(String serviceName, String message, ClientHandlerException cause) { - ServiceException exception = new ServiceException(message, cause); + public static ServiceException process(String serviceName, ServiceException exception) { + Throwable cause = exception.getCause(); + for (Throwable scan = cause; scan != null; scan = scan.getCause()) { if (ServiceException.class.isAssignableFrom(scan.getClass())) { - populate(exception, serviceName, (ServiceException)scan); - break; + return populate(exception, serviceName, (ServiceException)scan); } else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { - populate(exception, serviceName, (UniformInterfaceException)scan); - break; + return populate(exception, serviceName, (UniformInterfaceException)scan); } } - return exception; - } + + exception.setServiceName(serviceName); - public static ServiceException create(String serviceName, ClientHandlerException cause) { - ServiceException exception = new ServiceException(cause); - for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - if (ServiceException.class.isAssignableFrom(scan.getClass())) { - populate(exception, serviceName, (ServiceException)scan); - break; - } - else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { - populate(exception, serviceName, (UniformInterfaceException)scan); - break; - } - } return exception; } + - static void populate(ServiceException exception, String serviceName, + static ServiceException populate(ServiceException exception, String serviceName, UniformInterfaceException cause) { exception.setServiceName(serviceName); @@ -69,9 +46,10 @@ static void populate(ServiceException exception, String serviceName, } } } + return exception; } - static void populate(ServiceException exception, String serviceName, + static ServiceException populate(ServiceException exception, String serviceName, ServiceException cause) { exception.setServiceName(cause.getServiceName()); exception.setHttpStatusCode(cause.getHttpStatusCode()); @@ -79,6 +57,7 @@ static void populate(ServiceException exception, String serviceName, exception.setErrorCode(cause.getErrorCode()); exception.setErrorMessage(cause.getErrorMessage()); exception.setErrorValues(cause.getErrorValues()); + return exception; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 56ebd7053e75b..9a4ec649ad860 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -28,11 +28,15 @@ public static void initializeSystem() { System.out.println("initialize"); System.setProperty("http.proxyHost", "itgproxy"); System.setProperty("http.proxyPort", "80"); - System.setProperty("http.keepAlive", "false"); + //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"); boolean testAlphaExists = false; ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java index 0293ab0fd8bc2..9b5bb98307976 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java @@ -46,17 +46,6 @@ public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { assertNotNull(maxSizeAfter); } - @Test - public void notFoundQueuePathReturnsNull() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("NoSuchQueueName"); - - // Assert - assertNull(queue); - } @Test public void existingQueuePathDoesNotReturnNull() throws Exception { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java index 1952ab64d4758..672125cb5dc2f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java @@ -20,8 +20,7 @@ public void serviceNameAndMessageAndCauseAppearInException() { response); // Act - ServiceException exception = ServiceExceptionFactory.create("testing", - "this is a test", cause); + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); // Assert assertNotNull(exception); @@ -38,8 +37,7 @@ public void httpStatusCodeAndReasonPhraseAppearInException() { response); // Act - ServiceException exception = ServiceExceptionFactory.create("testing", - "this is a test", cause); + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); // Assert assertNotNull(exception); @@ -52,11 +50,11 @@ public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExc // Arrange ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); UniformInterfaceException rootCause = new UniformInterfaceException(response); - ServiceException originalDescription = ServiceExceptionFactory.create("underlying", rootCause); + ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException(rootCause)); ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); // Act - ServiceException exception = ServiceExceptionFactory.create("actual", wrappingException); + ServiceException exception = ServiceExceptionFactory.process("actual", new ServiceException(wrappingException)); // Assert assertEquals(503, exception.getHttpStatusCode()); From 68b385b65ee2e94cc7748836ed733dc3d70b3e33 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 10:59:43 -0700 Subject: [PATCH 036/664] Shuffle package names Service-oriented api at services.serviceBus Messaging helper api at services.serviceBus.messaging services.xxx.XxxContract becomes services.xxx.XxxService --- .../configuration/builder/DefaultBuilder.java | 2 +- .../{contract => }/BrokerProperties.java | 2 +- .../BrokerPropertiesMapper.java | 2 +- .../azure/services/serviceBus/Exports.java | 28 +++++++++- .../{contract => }/MarshallerProvider.java | 2 +- .../{contract => }/MessageResult.java | 2 +- .../NamespacePrefixMapperImpl.java | 2 +- .../{contract => }/ReceiveMode.java | 2 +- .../azure/services/serviceBus/Rule.java | 5 -- ...usContract.java => ServiceBusService.java} | 4 +- ...ctImpl.java => ServiceBusServiceImpl.java} | 8 +-- .../services/serviceBus/contract/Exports.java | 35 ------------- .../{ => messaging}/AbstractEntity.java | 6 +-- .../serviceBus/messaging/Exports.java | 9 ++++ .../{ => messaging}/ListQueuesOptions.java | 2 +- .../serviceBus/{ => messaging}/Message.java | 4 +- .../{ => messaging}/MessageReceiver.java | 2 +- .../{ => messaging}/MessageSender.java | 2 +- .../{ => messaging}/MessageTransceiver.java | 2 +- .../serviceBus/{ => messaging}/Queue.java | 6 +-- .../ReceiveMessageOptions.java | 2 +- .../services/serviceBus/messaging/Rule.java | 5 ++ .../{ => messaging}/SendMessageOptions.java | 2 +- .../{ => messaging}/ServiceBusClient.java | 14 ++--- .../{ => messaging}/Subscription.java | 2 +- .../serviceBus/{ => messaging}/Topic.java | 2 +- ...zure.configuration.builder.Builder$Exports | 2 +- .../BrokerPropertiesMapperTest.java | 5 +- .../serviceBus/ContractBuilderTest.java | 19 +++++++ .../ContractIntegrationTest.java | 51 ++++++++++--------- .../contract/ContractBuilderTest.java | 17 ------- .../{ => messaging}/ClientBuilderTest.java | 9 ++-- .../{ => messaging}/IntegrationTestBase.java | 5 +- .../QueueManagementIntegrationTest.java | 7 +-- .../{ => messaging}/QueueManagementTest.java | 10 ++-- 35 files changed, 147 insertions(+), 132 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/BrokerProperties.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/BrokerPropertiesMapper.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/MarshallerProvider.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/MessageResult.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/NamespacePrefixMapperImpl.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract => }/ReceiveMode.java (51%) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract/ServiceBusContract.java => ServiceBusService.java} (95%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{contract/ServiceBusContractImpl.java => ServiceBusServiceImpl.java} (93%) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/AbstractEntity.java (77%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/ListQueuesOptions.java (84%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/Message.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/MessageReceiver.java (86%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/MessageSender.java (77%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/MessageTransceiver.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/Queue.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/ReceiveMessageOptions.java (83%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/SendMessageOptions.java (66%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/ServiceBusClient.java (78%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/Subscription.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => messaging}/Topic.java (57%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{contract => }/BrokerPropertiesMapperTest.java (83%) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{contract => }/ContractIntegrationTest.java (57%) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{ => messaging}/ClientBuilderTest.java (71%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{ => messaging}/IntegrationTestBase.java (87%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{ => messaging}/QueueManagementIntegrationTest.java (85%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{ => messaging}/QueueManagementTest.java (80%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index 753026bdc8196..f0dc5b1b0ec19 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -150,7 +150,7 @@ public Registry add(Factory factory) { public T build(String profile, Class service, Map properties) throws Exception { Factory factory = (Factory) factories.get(service); if (factory == null) { - throw new RuntimeException("Service not registered: " + profile + " " + service.getName()); + throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); } T instance = factory.create(profile, this, properties); List> alterationList = alterations.get(service); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java index ad2b3ee1a680a..8b8806cc65b8b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import org.codehaus.jackson.annotate.JsonGetter; import org.codehaus.jackson.annotate.JsonIgnore; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java index 8701f1db467ff..1cba63fc75190 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import java.io.IOException; import java.io.StringWriter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 5af49c37c86c8..2119232293daf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -1,9 +1,35 @@ package com.microsoft.azure.services.serviceBus; +import java.util.Map; + import com.microsoft.azure.configuration.builder.Builder; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.json.JSONConfiguration; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(ServiceBusClient.class); + + // provide contract implementation + registry.add(ServiceBusService.class, ServiceBusServiceImpl.class); + + // alter jersey client config for serviceBus + registry.alter(ClientConfig.class, new Builder.Alteration() { + + public ClientConfig alter(ClientConfig instance, Builder builder, + Map properties) throws Exception { + + // enable this feature for unattributed json object serialization + instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + + // need to avoid certain element prefixes, which the service does not ignore + instance.getSingletons().add(new MarshallerProvider()); + + return instance; + } + }); + + // convenience provider to transform BrokerProperty headers to json + registry.add(BrokerPropertiesMapper.class); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java index e529e48e7708e..46160a0b98a51 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java index 6c98703c48a3f..9de5f7ec3c3de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/MessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java index 3f41f21e91f4e..59bf4de5ca349 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java similarity index 51% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java index 2bcf4f136ebc4..b96aa03a3835a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; public enum ReceiveMode { PEEK_LOCK, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java deleted file mode 100644 index 2ca00d6ed13fc..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Rule.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -public class Rule { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index def3a61dde221..a1c2cfb050f08 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import java.io.InputStream; @@ -8,7 +8,7 @@ import com.microsoft.azure.ServiceException; -public interface ServiceBusContract { +public interface ServiceBusService { void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException; MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException; //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index f7f330edc851f..236ca715bdc5e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/ServiceBusContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import java.io.InputStream; import java.rmi.UnexpectedException; @@ -20,15 +20,15 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -public class ServiceBusContractImpl implements ServiceBusContract { +public class ServiceBusServiceImpl implements ServiceBusService { private Client channel; private String uri; private BrokerPropertiesMapper mapper; - static Log log = LogFactory.getLog(ServiceBusContract.class); + static Log log = LogFactory.getLog(ServiceBusService.class); @Inject - public ServiceBusContractImpl( + public ServiceBusServiceImpl( Client channel, @Named("serviceBus") WrapFilter authFilter, @Named("serviceBus.uri") String uri, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java deleted file mode 100644 index 845ca50fabe53..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/contract/Exports.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - -import java.util.Map; - -import com.microsoft.azure.configuration.builder.Builder; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.json.JSONConfiguration; - -public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - - // provide contract implementation - registry.add(ServiceBusContract.class, ServiceBusContractImpl.class); - - // alter jersey client config for serviceBus - registry.alter(ClientConfig.class, new Builder.Alteration() { - - public ClientConfig alter(ClientConfig instance, Builder builder, - Map properties) throws Exception { - - // enable this feature for unattributed json object serialization - instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - - // need to avoid certain element prefixes, which the service does not ignore - instance.getSingletons().add(new MarshallerProvider()); - - return instance; - } - }); - - // convenience provider to transform BrokerProperty headers to json - registry.add(BrokerPropertiesMapper.class); - - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java similarity index 77% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java index 8c56bd724c0c3..c977f455bf9e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/AbstractEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java @@ -1,11 +1,11 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import javax.ws.rs.core.MediaType; import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.microsoft.azure.services.serviceBus.ServiceBusService; abstract class AbstractEntity { @@ -28,7 +28,7 @@ protected ServiceBusClient getClient() { return client; } - protected ServiceBusContract getContract() { + protected ServiceBusService getContract() { return getClient().getContract(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java new file mode 100644 index 0000000000000..49f16aceca579 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java @@ -0,0 +1,9 @@ +package com.microsoft.azure.services.serviceBus.messaging; + +import com.microsoft.azure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(ServiceBusClient.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java similarity index 84% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java index 3a966f2927969..b8b6b73b40942 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public class ListQueuesOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java index 59711059aae1b..f440b77a41b47 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java @@ -1,9 +1,9 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import java.io.ByteArrayInputStream; import java.io.InputStream; -import com.microsoft.azure.services.serviceBus.contract.BrokerProperties; +import com.microsoft.azure.services.serviceBus.BrokerProperties; public class Message { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java index 2b8c23ae22ae9..0bed33badbe2f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import com.microsoft.azure.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java similarity index 77% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java index a6a5dbe129917..c942cbf515503 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import com.microsoft.azure.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java index 8732e42fe4743..2dbe7eb978992 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageTransceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java @@ -1,5 +1,5 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public interface MessageTransceiver extends MessageSender, MessageReceiver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java index 0cf1547e3fa3d..5035f9b8c08be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java @@ -1,13 +1,13 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import javax.xml.datatype.Duration; import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; import com.microsoft.azure.ServiceException; -import com.microsoft.azure.services.serviceBus.contract.MessageResult; +import com.microsoft.azure.services.serviceBus.MessageResult; +import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; -import com.microsoft.azure.services.serviceBus.contract.ReceiveMode; public class Queue extends AbstractEntity implements MessageSender, MessageReceiver, MessageTransceiver { Queue(ServiceBusClient client, String name) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java index 426830679f3cf..3e91c4991e964 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public class ReceiveMessageOptions { Integer timeout; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java new file mode 100644 index 0000000000000..6024ffc995026 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java @@ -0,0 +1,5 @@ +package com.microsoft.azure.services.serviceBus.messaging; + +public class Rule { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java similarity index 66% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java index 16ed9cbae34f3..a1af78c648889 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/SendMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public class SendMessageOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java similarity index 78% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java index 269601f142786..69c7382e6f99e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import java.util.ArrayList; @@ -9,11 +9,11 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.microsoft.azure.services.serviceBus.ServiceBusService; public class ServiceBusClient { - ServiceBusContract contract; + ServiceBusService contract; public ServiceBusClient() throws Exception { this("", Configuration.load()); @@ -28,19 +28,19 @@ public ServiceBusClient(String profile) throws Exception { } public ServiceBusClient(String profile, Configuration config) throws Exception { - this(config.create(profile, ServiceBusContract.class)); + this(config.create(profile, ServiceBusService.class)); } @Inject - public ServiceBusClient(ServiceBusContract contract) { + public ServiceBusClient(ServiceBusService contract) { this.contract = contract; } - public ServiceBusContract getContract() { + public ServiceBusService getContract() { return contract; } - public void setContract(ServiceBusContract contract) { + public void setContract(ServiceBusService contract) { this.contract = contract; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java index e06239ff2db6a..df3f45f2482bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public class Subscription { public Rule getRules() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java similarity index 57% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java index e54297fdc961b..a71cc3701b2b4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; public class Topic { Subscription[] getSubscriptions() { diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index 1da2036a8749e..f7e819ac5b1e7 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,5 +1,5 @@ com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports -com.microsoft.azure.services.serviceBus.contract.Exports +com.microsoft.azure.services.serviceBus.messaging.Exports com.microsoft.azure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java similarity index 83% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index 30b8f77f62752..fbe2bd4451171 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -1,9 +1,12 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import static org.junit.Assert.*; import org.junit.Test; +import com.microsoft.azure.services.serviceBus.BrokerProperties; +import com.microsoft.azure.services.serviceBus.BrokerPropertiesMapper; + public class BrokerPropertiesMapperTest { @Test public void jsonStringMapsToBrokerPropertiesObject(){ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java new file mode 100644 index 0000000000000..1935b059e5d03 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java @@ -0,0 +1,19 @@ +package com.microsoft.azure.services.serviceBus; + + +import static org.junit.Assert.*; +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.ServiceBusService; + +public class ContractBuilderTest { + @Test + public void testDefaultBuilderCreatesServiceImpl() throws Exception { + Configuration config = new Configuration(); + ServiceBusService service = config.create(ServiceBusService.class); + + assertNotNull(service); + assertEquals(ServiceBusServiceImpl.class, service.getClass()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java similarity index 57% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java index bb43c1ac5d44d..18ad2f69daa47 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java @@ -1,40 +1,51 @@ -package com.microsoft.azure.services.serviceBus.contract; +package com.microsoft.azure.services.serviceBus; import java.io.ByteArrayInputStream; +import org.junit.Before; import org.junit.Test; import org.w3._2005.atom.Content; import org.w3._2005.atom.Entry; import org.w3._2005.atom.Feed; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.IntegrationTestBase; +import com.microsoft.azure.services.serviceBus.BrokerProperties; +import com.microsoft.azure.services.serviceBus.MessageResult; +import com.microsoft.azure.services.serviceBus.ReceiveMode; +import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.messaging.IntegrationTestBase; import static org.junit.Assert.*; public class ContractIntegrationTest extends IntegrationTestBase { + private Configuration config; + private ServiceBusService service; + + @Before + public void createService() throws Exception { + config = createConfiguration(); + service = config.create(ServiceBusService.class); + } @Test public void fetchQueueAndListQueuesWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); // Act - Entry entry = contract.getQueue("TestAlpha"); - Feed feed = contract.getQueues(); + Entry entry = service.getQueue("TestAlpha"); + Feed feed = service.getQueues(); // Assert assertNotNull(entry); assertNotNull(feed); } + @Test public void createQueueWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); // Act Entry entry = new Entry(); @@ -47,7 +58,7 @@ public void createQueueWorks() throws Exception { content.setQueueDescription(description); description.setMaxSizeInMegabytes(1024L); - Entry entry2 = contract.createQueue(entry); + Entry entry2 = service.createQueue(entry); // Assert } @@ -55,8 +66,6 @@ public void createQueueWorks() throws Exception { @Test public void deleteQueueWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); // Act Entry entry = new Entry(); @@ -67,9 +76,9 @@ public void deleteQueueWorks() throws Exception { entry.setContent(content); content.setType("application/xml"); content.setQueueDescription(description); - contract.createQueue(entry); + service.createQueue(entry); - contract.deleteQueue("TestDeleteQueueWorks"); + service.deleteQueue("TestDeleteQueueWorks"); // Assert } @@ -77,13 +86,11 @@ public void deleteQueueWorks() throws Exception { @Test public void sendMessageWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); // Assert } @@ -91,14 +98,12 @@ public void sendMessageWorks() throws Exception { @Test public void receiveMessageWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); BrokerProperties props = new BrokerProperties(); - contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); // Act - MessageResult message = contract.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); + MessageResult message = service.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); // Assert byte[] data = new byte[100]; @@ -110,14 +115,12 @@ public void receiveMessageWorks() throws Exception { @Test public void peekLockMessageWorks() throws Exception { // Arrange - Configuration config = createConfiguration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); BrokerProperties props = new BrokerProperties(); // Act - contract.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); - MessageResult message = contract.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); + service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + MessageResult message = service.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); // Assert byte[] data = new byte[100]; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java deleted file mode 100644 index 22433eb557e4f..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/contract/ContractBuilderTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.microsoft.azure.services.serviceBus.contract; - - -import static org.junit.Assert.*; -import org.junit.Test; - -import com.microsoft.azure.configuration.Configuration; - -public class ContractBuilderTest { - @Test - public void testDefaultBuilderCreatesContractImpl() throws Exception { - Configuration config = new Configuration(); - ServiceBusContract contract = config.create(ServiceBusContract.class); - - assertNotNull(contract); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java similarity index 71% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java index b9e66c0070f26..98180f1297c23 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ClientBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import java.net.HttpURLConnection; import java.net.URL; @@ -7,7 +7,8 @@ import static org.junit.Assert.*; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContractImpl; +import com.microsoft.azure.services.serviceBus.ServiceBusServiceImpl; +import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; public class ClientBuilderTest { @@ -23,11 +24,11 @@ public void testServiceBusClientCreatedWithContractImpl() throws Exception { // Assert assertNotNull(client); assertNotNull(client.getContract()); - assertEquals(ServiceBusContractImpl.class, client.getContract().getClass()); + assertEquals(ServiceBusServiceImpl.class, client.getContract().getClass()); assertNotNull(client2); assertNotNull(client2.getContract()); - assertEquals(ServiceBusContractImpl.class, client2.getContract().getClass()); + assertEquals(ServiceBusServiceImpl.class, client2.getContract().getClass()); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java similarity index 87% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java index 9a4ec649ad860..67db9a15d6a9c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import java.io.Console; @@ -6,6 +6,9 @@ import org.junit.BeforeClass; import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.messaging.Queue; +import com.microsoft.azure.services.serviceBus.messaging.ReceiveMessageOptions; +import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java similarity index 85% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java index 9b5bb98307976..40d8434834ab9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import static org.junit.Assert.*; @@ -6,8 +6,9 @@ import org.junit.Test; -import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ServiceBusClient; +import com.microsoft.azure.services.serviceBus.messaging.Message; +import com.microsoft.azure.services.serviceBus.messaging.Queue; +import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; public class QueueManagementIntegrationTest extends IntegrationTestBase { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java similarity index 80% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java index ed0ede5d2374d..da828e5eb0980 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.messaging; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -12,15 +12,17 @@ import org.w3._2005.atom.Entry; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.contract.QueueDescription; -import com.microsoft.azure.services.serviceBus.contract.ServiceBusContract; +import com.microsoft.azure.services.serviceBus.messaging.Queue; +import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; public class QueueManagementTest { @Test public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException { // Arrange - ServiceBusContract contract = mock(ServiceBusContract.class); + ServiceBusService contract = mock(ServiceBusService.class); Entry entry = new Entry(); when(contract.getQueue("Hello")).thenReturn(entry); @@ -41,7 +43,7 @@ public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException @Test public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException, ServiceException { // Arrange - ServiceBusContract contract = mock(ServiceBusContract.class); + ServiceBusService contract = mock(ServiceBusService.class); // Act ServiceBusClient client = new ServiceBusClient(contract); From 1c6b25f066e1a7b49cb795144ca2071ce75ec5a9 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 11:18:38 -0700 Subject: [PATCH 037/664] Moving generated artifacts for serviceBus xsd generated classes for serviceBus and related atom are now in package com.microsoft.azure.services.serviceBus.schema --- .../azure/services/serviceBus/ServiceBusService.java | 4 ++-- .../azure/services/serviceBus/ServiceBusServiceImpl.java | 4 ++-- .../services/serviceBus/messaging/AbstractEntity.java | 6 +++--- .../azure/services/serviceBus/messaging/Queue.java | 6 +++--- .../services/serviceBus/messaging/ServiceBusClient.java | 2 +- microsoft-azure-api/src/main/resources/package-names.xjb | 7 ++++++- .../services/serviceBus/ContractIntegrationTest.java | 8 ++++---- .../serviceBus/messaging/QueueManagementTest.java | 6 +++--- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index a1c2cfb050f08..084575f72276d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -2,8 +2,8 @@ import java.io.InputStream; -import org.w3._2005.atom.Entry; -import org.w3._2005.atom.Feed; +import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.schema.Feed; import com.microsoft.azure.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 236ca715bdc5e..6738b2de4b0f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -8,8 +8,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3._2005.atom.Entry; -import org.w3._2005.atom.Feed; +import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.schema.Feed; import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.WrapFilter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java index c977f455bf9e2..b7f3957767be0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java @@ -2,8 +2,8 @@ import javax.ws.rs.core.MediaType; -import org.w3._2005.atom.Content; -import org.w3._2005.atom.Entry; +import com.microsoft.azure.services.serviceBus.schema.Content; +import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.services.serviceBus.ServiceBusService; @@ -14,7 +14,7 @@ abstract class AbstractEntity { AbstractEntity(ServiceBusClient client) { this.client = client; - setEntry(new org.w3._2005.atom.Entry()); + setEntry(new Entry()); getEntry().setContent(new Content()); getEntry().getContent().setType(MediaType.APPLICATION_XML); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java index 5035f9b8c08be..3a30b9806b4a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java @@ -1,13 +1,13 @@ package com.microsoft.azure.services.serviceBus.messaging; import javax.xml.datatype.Duration; -import org.w3._2005.atom.Content; -import org.w3._2005.atom.Entry; +import com.microsoft.azure.services.serviceBus.schema.Content; +import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.MessageResult; import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.schema.QueueDescription; public class Queue extends AbstractEntity implements MessageSender, MessageReceiver, MessageTransceiver { Queue(ServiceBusClient client, String name) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java index 69c7382e6f99e..2a15716b75fde 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java @@ -5,7 +5,7 @@ import javax.inject.Inject; -import org.w3._2005.atom.Feed; +import com.microsoft.azure.services.serviceBus.schema.Feed; import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 15083b0bf49a1..06c4a48b9db2b 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -6,7 +6,12 @@ jaxb:extensionBindingPrefixes="xjc"> - + + + + + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java index 18ad2f69daa47..4b5c4044699f3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java @@ -4,16 +4,16 @@ import org.junit.Before; import org.junit.Test; -import org.w3._2005.atom.Content; -import org.w3._2005.atom.Entry; -import org.w3._2005.atom.Feed; +import com.microsoft.azure.services.serviceBus.schema.Content; +import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.schema.Feed; import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.BrokerProperties; import com.microsoft.azure.services.serviceBus.MessageResult; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.schema.QueueDescription; import com.microsoft.azure.services.serviceBus.messaging.IntegrationTestBase; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java index da828e5eb0980..79d30815fa4c3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java @@ -8,12 +8,12 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.w3._2005.atom.Content; -import org.w3._2005.atom.Entry; +import com.microsoft.azure.services.serviceBus.schema.Content; +import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.contract.QueueDescription; +import com.microsoft.azure.services.serviceBus.schema.QueueDescription; import com.microsoft.azure.services.serviceBus.messaging.Queue; import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; From 7dbde1d6ee58e5434d7700ea87e31ac3ec87cfdb Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 12:15:29 -0700 Subject: [PATCH 038/664] Reshaping service interface to use strongly-typed data model --- .../azure/services/serviceBus/EntryModel.java | 29 +++ .../azure/services/serviceBus/Queue.java | 108 ++++++++++ .../azure/services/serviceBus/QueueList.java | 8 + .../serviceBus/ServiceBusService.java | 7 +- .../serviceBus/ServiceBusServiceImpl.java | 48 +++-- .../services/serviceBus/messaging/Queue.java | 109 ++++++---- .../messaging/ServiceBusClient.java | 24 +-- .../serviceBus/ContractIntegrationTest.java | 22 +- .../messaging/IntegrationTestBase.java | 21 +- .../QueueManagementIntegrationTest.java | 200 +++++++++--------- .../messaging/QueueManagementTest.java | 130 ++++++------ 11 files changed, 449 insertions(+), 257 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java new file mode 100644 index 0000000000000..f6592682dc202 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java @@ -0,0 +1,29 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.services.serviceBus.schema.Entry; + +public class EntryModel { + Entry entry; + T model; + + public EntryModel(Entry entry, T model) { + this.entry = entry; + this.model = model; + } + + public Entry getEntry() { + return entry; + } + + public void setEntry(Entry entry) { + this.entry = entry; + } + + public T getModel() { + return model; + } + + public void setModel(T model) { + this.model = model; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java new file mode 100644 index 0000000000000..7ae9549758d35 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -0,0 +1,108 @@ +package com.microsoft.azure.services.serviceBus; + + +import javax.ws.rs.core.MediaType; +import javax.xml.datatype.Duration; + +import com.microsoft.azure.services.serviceBus.schema.Content; +import com.microsoft.azure.services.serviceBus.schema.Entry; + +import com.microsoft.azure.services.serviceBus.schema.QueueDescription; + +public class Queue extends EntryModel { + + public Queue() { + super(new Entry(), new QueueDescription()); + entry.setContent(new Content()); + entry.getContent().setType(MediaType.APPLICATION_XML); + } + + public Queue(Entry entry) { + super(entry, entry.getContent().getQueueDescription()); + } + + public Queue(Entry entry, QueueDescription model) { + super(entry, model); + } + + public String getTitle() { + return entry.getTitle(); + } + + public Queue setTitle(String value) { + entry.setTitle(value); + return this; + } + + public Duration getLockDuration() { + return model.getLockDuration(); + } + + public void setLockDuration(Duration value) { + model.setLockDuration(value); + } + + public Long getMaxSizeInMegabytes() { + return model.getMaxSizeInMegabytes(); + } + + public void setMaxSizeInMegabytes(Long value) { + model.setMaxSizeInMegabytes(value); + } + + public void setRequiresDuplicateDetection(Boolean value) { + model.setRequiresDuplicateDetection(value); + } + + public void setRequiresSession(Boolean value) { + model.setRequiresSession(value); + } + + public Duration getDefaultMessageTimeToLive() { + return model.getDefaultMessageTimeToLive(); + } + + public void setDefaultMessageTimeToLive(Duration value) { + model.setDefaultMessageTimeToLive(value); + } + + public void setDeadLetteringOnMessageExpiration(Boolean value) { + model.setDeadLetteringOnMessageExpiration(value); + } + + public Duration getDuplicateDetectionHistoryTimeWindow() { + return model.getDuplicateDetectionHistoryTimeWindow(); + } + + public void setDuplicateDetectionHistoryTimeWindow(Duration value) { + model.setDuplicateDetectionHistoryTimeWindow(value); + } + + public Integer getMaxDeliveryCount() { + return model.getMaxDeliveryCount(); + } + + public void setMaxDeliveryCount(Integer value) { + model.setMaxDeliveryCount(value); + } + + public void setEnableBatchedOperations(Boolean value) { + model.setEnableBatchedOperations(value); + } + + public Long getSizeInBytes() { + return model.getSizeInBytes(); + } + + public void setSizeInBytes(Long value) { + model.setSizeInBytes(value); + } + + public Long getMessageCount() { + return model.getMessageCount(); + } + + public void setMessageCount(Long value) { + model.setMessageCount(value); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java new file mode 100644 index 0000000000000..5afd4d14ceae2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java @@ -0,0 +1,8 @@ +package com.microsoft.azure.services.serviceBus; + +import java.util.Iterator; + +public class QueueList { + + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index 084575f72276d..2840cef9bdcee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -15,10 +15,11 @@ public interface ServiceBusService { //void abandonMessage(BrokeredMessage message) throws ServiceException; //void completeMessage(BrokeredMessage message) throws ServiceException; - Entry createQueue(Entry queue) throws ServiceException; + Queue createQueue(Queue queue) throws ServiceException; void deleteQueue(String queuePath) throws ServiceException; - Entry getQueue(String queuePath) throws ServiceException; - Feed getQueues() throws ServiceException; + Queue getQueue(String queuePath) throws ServiceException; + QueueList getQueueList() throws ServiceException; + Iterable iterateQueues() throws ServiceException; Entry createTopic(Entry topic) throws ServiceException; void deleteTopic(String topicPath) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 6738b2de4b0f1..33f8dd41de5ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -122,12 +122,12 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { } - public Entry createQueue(Entry entry) throws ServiceException { + public Queue createQueue(Queue entry) throws ServiceException { try { return getResource() .path(entry.getTitle()) .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Entry.class, entry); + .put(Queue.class, entry); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -151,11 +151,11 @@ public void deleteQueue(String queuePath) throws ServiceException { } } - public Entry getQueue(String queuePath) throws ServiceException { + public Queue getQueue(String queuePath) throws ServiceException { try { return getResource() .path(queuePath) - .get(Entry.class); + .get(Queue.class); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -165,20 +165,34 @@ public Entry getQueue(String queuePath) throws ServiceException { } } - public Feed getQueues() throws ServiceException { - try { - return getResource() - .path("$Resources/Queues") - .get(Feed.class); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } + public Iterable iterateQueues() throws ServiceException { + return null; +// try { +// return getResource() +// .path("$Resources/Queues") +// .get(Feed.class); +// } +// catch(UniformInterfaceException e) { +// throw processCatch(new ServiceException(e)); +// } +// catch(ClientHandlerException e) { +// throw processCatch(new ServiceException(e)); +// } + } + public QueueList getQueueList() throws ServiceException { + return null; +// try { +// return getResource() +// .path("$Resources/Queues") +// .get(Feed.class); +// } +// catch(UniformInterfaceException e) { +// throw processCatch(new ServiceException(e)); +// } +// catch(ClientHandlerException e) { +// throw processCatch(new ServiceException(e)); +// } } - public Entry createTopic(Entry entry) throws ServiceException { try { return getResource() diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java index 3a30b9806b4a4..6140d60f622f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java @@ -32,44 +32,44 @@ QueueDescription getQueueDescription(){ // API methods - - public void save() throws ServiceException { - setEntry(getContract().createQueue(getEntry())); - } - - public void delete() throws ServiceException { - getContract().deleteQueue(getName()); - } - - public void fetch() throws ServiceException { - setEntry(getContract().getQueue(getName())); - } - - public void sendMessage(Message message) throws ServiceException { - sendMessage(message, SendMessageOptions.DEFAULT); - } - - public void sendMessage(Message message, SendMessageOptions options) throws ServiceException { - getContract().sendMessage(getName(), message.getProperties(), message.getBody()); - } - - public Message receiveMessage() throws ServiceException { - return receiveMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { - MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.RECEIVE_AND_DELETE); - return new Message(result.getBrokerProperties(), result.getBody()); - } - - public Message peekLockMessage() throws ServiceException { - return peekLockMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException { - MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.PEEK_LOCK); - return new Message(result.getBrokerProperties(), result.getBody()); - } +// +// public void save() throws ServiceException { +// setEntry(getContract().createQueue(getEntry())); +// } +// +// public void delete() throws ServiceException { +// getContract().deleteQueue(getName()); +// } +// +// public void fetch() throws ServiceException { +// setEntry(getContract().getQueue(getName())); +// } +// +// public void sendMessage(Message message) throws ServiceException { +// sendMessage(message, SendMessageOptions.DEFAULT); +// } +// +// public void sendMessage(Message message, SendMessageOptions options) throws ServiceException { +// getContract().sendMessage(getName(), message.getProperties(), message.getBody()); +// } +// +// public Message receiveMessage() throws ServiceException { +// return receiveMessage(ReceiveMessageOptions.DEFAULT); +// } +// +// public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { +// MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.RECEIVE_AND_DELETE); +// return new Message(result.getBrokerProperties(), result.getBody()); +// } +// +// public Message peekLockMessage() throws ServiceException { +// return peekLockMessage(ReceiveMessageOptions.DEFAULT); +// } +// +// public Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException { +// MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.PEEK_LOCK); +// return new Message(result.getBrokerProperties(), result.getBody()); +// } public void abandonMessage(Message message) { // TODO Auto-generated method stub @@ -112,4 +112,37 @@ public Long getMessageCount() { return getQueueDescription().getMessageCount(); } + public Message receiveMessage() throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message receiveMessage(ReceiveMessageOptions options) + throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message peekLockMessage() throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message peekLockMessage(ReceiveMessageOptions options) + throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public void sendMessage(Message message) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void sendMessage(Message message, SendMessageOptions options) + throws ServiceException { + // TODO Auto-generated method stub + + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java index 2a15716b75fde..bc8d7f1e7b66c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java @@ -44,19 +44,19 @@ public void setContract(ServiceBusService contract) { this.contract = contract; } - public Iterable listQueues() throws ServiceException { - return listQueues(ListQueuesOptions.DEFAULT); - } +// public Iterable listQueues() throws ServiceException { +// return listQueues(ListQueuesOptions.DEFAULT); +// } - // REVIEW: what is the generalized strategy for paginated, client-roundtrippable iteration - public Iterable listQueues(ListQueuesOptions options) throws ServiceException { - Feed descriptions = contract.getQueues(); - ArrayList queues = new ArrayList(); - for (int i = 0; i != descriptions.getEntries().size(); ++i) { - queues.add(new Queue(this, descriptions.getEntries().get(i))); - } - return queues; - } +// // REVIEW: what is the generalized strategy for paginated, client-roundtrippable iteration +// public Iterable listQueues(ListQueuesOptions options) throws ServiceException { +// Feed descriptions = contract.getQueueList()(); +// ArrayList queues = new ArrayList(); +// for (int i = 0; i != descriptions.getEntries().size(); ++i) { +// queues.add(new Queue(this, descriptions.getEntries().get(i))); +// } +// return queues; +// } public Queue getQueue(String path) { return new Queue(this, path); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java index 4b5c4044699f3..c7bc6b649e9a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java @@ -34,8 +34,8 @@ public void fetchQueueAndListQueuesWorks() throws Exception { // Arrange // Act - Entry entry = service.getQueue("TestAlpha"); - Feed feed = service.getQueues(); + Queue entry = service.getQueue("TestAlpha"); + QueueList feed = service.getQueueList(); // Assert assertNotNull(entry); @@ -48,19 +48,17 @@ public void createQueueWorks() throws Exception { // Arrange // Act - Entry entry = new Entry(); - Content content = new Content(); - QueueDescription description = new QueueDescription(); + Queue queue = new Queue(); - entry.setTitle("TestCreateQueueWorks"); - entry.setContent(content); - content.setType("application/xml"); - content.setQueueDescription(description); - description.setMaxSizeInMegabytes(1024L); + queue.setTitle("TestCreateQueueWorks"); + queue.setMaxSizeInMegabytes(1024L); - Entry entry2 = service.createQueue(entry); + Queue saved = service.createQueue(queue); // Assert + assertNotNull(saved); + assertNotSame(queue, saved); + assertEquals("TestCreateQueueWorks", saved.getTitle()); } @Test @@ -76,7 +74,7 @@ public void deleteQueueWorks() throws Exception { entry.setContent(content); content.setType("application/xml"); content.setQueueDescription(description); - service.createQueue(entry); +// service.createQueue(entry); service.deleteQueue("TestDeleteQueueWorks"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java index 67db9a15d6a9c..b9e089afda7c5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java @@ -6,7 +6,8 @@ import org.junit.BeforeClass; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.messaging.Queue; +import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.messaging.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; @@ -42,22 +43,22 @@ public void initialize() throws Exception { //System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; - ServiceBusClient client = createConfiguration().create(ServiceBusClient.class); - for(Queue queue : client.listQueues()){ - if (queue.getName().startsWith("Test") || queue.getName().startsWith("test")) { - if (queue.getName().equalsIgnoreCase("TestAlpha")) { + ServiceBusService service = createConfiguration().create(ServiceBusService.class); + for(Queue queue : service.iterateQueues()) { + if (queue.getTitle().startsWith("Test") || queue.getTitle().startsWith("test")) { + if (queue.getTitle().equalsIgnoreCase("TestAlpha")) { testAlphaExists = true; long count = queue.getMessageCount(); - for(long i = 0; i != count; ++i) { - queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2000)); - } +// for(long i = 0; i != count; ++i) { +// queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2000)); +// } } else { - queue.delete(); +// queue.delete(); } } } if (!testAlphaExists) { - client.getQueue("TestAlpha").save(); + service.createQueue(new Queue().setTitle("TestAlpha")); } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java index 40d8434834ab9..bf3c4f8ca1229 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java @@ -1,100 +1,100 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; - -import org.junit.Test; - -import com.microsoft.azure.services.serviceBus.messaging.Message; -import com.microsoft.azure.services.serviceBus.messaging.Queue; -import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; - - -public class QueueManagementIntegrationTest extends IntegrationTestBase { - - private ServiceBusClient createClient() throws Exception { - return new ServiceBusClient(createConfiguration()); - } - - @Test - public void queueCanBeCreatedAndDeleted() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("TestQueueCanBeCreatedAndDeleted"); - queue.save(); - queue.delete(); - - // Assert - } - - @Test - public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("TestWhenQueueIsCreatedEntityStateIsAlsoUpdated"); - Long maxSizeBefore = queue.getMaxSizeInMegabytes(); - queue.save(); - Long maxSizeAfter = queue.getMaxSizeInMegabytes(); - queue.delete(); - - // Assert - assertNull(maxSizeBefore); - assertNotNull(maxSizeAfter); - } - - - @Test - public void existingQueuePathDoesNotReturnNull() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("TestAlpha"); - queue.fetch(); - - // Assert - assertNotNull(queue); - assertEquals("TestAlpha", queue.getName()); - } - - @Test - public void createQueueAndSendAndReceiveMessage() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); - queue.save(); - - queue.sendMessage(new Message("Hello World")); - Message received = queue.receiveMessage(); - - // Assert - assertNotNull(received); - assertEquals(1, (int)received.getDeliveryCount()); - } - - - @Test - public void peekLockedMessageHasLockTokenAndLockedUntilUtc() throws Exception { - // Arrange - ServiceBusClient client = createClient(); - - // Act - Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); - queue.save(); - - queue.sendMessage(new Message("Hello World")); - Message received = queue.peekLockMessage(); - - // Assert - assertNotNull(received); - assertNotNull(received.getLockToken()); - assertNotNull(received.getLockedUntilUtc()); - } -} +//package com.microsoft.azure.services.serviceBus.messaging; +// +//import static org.junit.Assert.*; +// +//import java.io.ByteArrayInputStream; +// +//import org.junit.Test; +// +//import com.microsoft.azure.services.serviceBus.messaging.Message; +//import com.microsoft.azure.services.serviceBus.messaging.Queue; +//import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; +// +// +//public class QueueManagementIntegrationTest extends IntegrationTestBase { +// +// private ServiceBusClient createClient() throws Exception { +// return new ServiceBusClient(createConfiguration()); +// } +// +// @Test +// public void queueCanBeCreatedAndDeleted() throws Exception { +// // Arrange +// ServiceBusClient client = createClient(); +// +// // Act +// Queue queue = client.getQueue("TestQueueCanBeCreatedAndDeleted"); +// queue.save(); +// queue.delete(); +// +// // Assert +// } +// +// @Test +// public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { +// // Arrange +// ServiceBusClient client = createClient(); +// +// // Act +// Queue queue = client.getQueue("TestWhenQueueIsCreatedEntityStateIsAlsoUpdated"); +// Long maxSizeBefore = queue.getMaxSizeInMegabytes(); +// queue.save(); +// Long maxSizeAfter = queue.getMaxSizeInMegabytes(); +// queue.delete(); +// +// // Assert +// assertNull(maxSizeBefore); +// assertNotNull(maxSizeAfter); +// } +// +// +// @Test +// public void existingQueuePathDoesNotReturnNull() throws Exception { +// // Arrange +// ServiceBusClient client = createClient(); +// +// // Act +// Queue queue = client.getQueue("TestAlpha"); +// queue.fetch(); +// +// // Assert +// assertNotNull(queue); +// assertEquals("TestAlpha", queue.getName()); +// } +// +// @Test +// public void createQueueAndSendAndReceiveMessage() throws Exception { +// // Arrange +// ServiceBusClient client = createClient(); +// +// // Act +// Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); +// queue.save(); +// +// queue.sendMessage(new Message("Hello World")); +// Message received = queue.receiveMessage(); +// +// // Assert +// assertNotNull(received); +// assertEquals(1, (int)received.getDeliveryCount()); +// } +// +// +// @Test +// public void peekLockedMessageHasLockTokenAndLockedUntilUtc() throws Exception { +// // Arrange +// ServiceBusClient client = createClient(); +// +// // Act +// Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); +// queue.save(); +// +// queue.sendMessage(new Message("Hello World")); +// Message received = queue.peekLockMessage(); +// +// // Assert +// assertNotNull(received); +// assertNotNull(received.getLockToken()); +// assertNotNull(received.getLockedUntilUtc()); +// } +//} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java index 79d30815fa4c3..cdae4631daae0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java @@ -1,65 +1,65 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; - -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import com.microsoft.azure.services.serviceBus.schema.Content; -import com.microsoft.azure.services.serviceBus.schema.Entry; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.schema.QueueDescription; -import com.microsoft.azure.services.serviceBus.messaging.Queue; -import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; - - -public class QueueManagementTest { - @Test - public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException { - // Arrange - ServiceBusService contract = mock(ServiceBusService.class); - - Entry entry = new Entry(); - when(contract.getQueue("Hello")).thenReturn(entry); - - entry.setContent(new Content()); - //entry.getContent().setQueueDescription(new QueueDescription()); - //entry.getContent().getQueueDescription().setMessageCount(73L); - - // Act - ServiceBusClient client = new ServiceBusClient(contract); - Queue helloQueue = client.getQueue("Hello"); - helloQueue.fetch(); - - // Assert - assertEquals(73, helloQueue.getMessageCount().longValue()); - } - - @Test - public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException, ServiceException { - // Arrange - ServiceBusService contract = mock(ServiceBusService.class); - - // Act - ServiceBusClient client = new ServiceBusClient(contract); - Queue helloQueue = client.getQueue("MyNewQueue"); - helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); - helloQueue.setMaxSizeInMegabytes(42L); - helloQueue.save(); - - // Assert - ArgumentCaptor argument = ArgumentCaptor.forClass(Entry.class); - verify(contract).createQueue(argument.capture()); - Entry entry = argument.getValue(); - //QueueDescription model = entry.getContent().getQueueDescription(); - - assertEquals("MyNewQueue", entry.getTitle()); - //assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); - //assertEquals(42, model.getMaxSizeInMegabytes().longValue()); - } -} +//package com.microsoft.azure.services.serviceBus.messaging; +// +//import static org.junit.Assert.*; +//import static org.mockito.Mockito.*; +// +//import javax.xml.datatype.DatatypeConfigurationException; +//import javax.xml.datatype.DatatypeFactory; +// +//import org.junit.Test; +//import org.mockito.ArgumentCaptor; +//import com.microsoft.azure.services.serviceBus.schema.Content; +//import com.microsoft.azure.services.serviceBus.schema.Entry; +// +//import com.microsoft.azure.ServiceException; +//import com.microsoft.azure.services.serviceBus.ServiceBusService; +//import com.microsoft.azure.services.serviceBus.schema.QueueDescription; +//import com.microsoft.azure.services.serviceBus.messaging.Queue; +//import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; +// +// +//public class QueueManagementTest { +// @Test +// public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException { +// // Arrange +// ServiceBusService contract = mock(ServiceBusService.class); +// +// Entry entry = new Entry(); +// when(contract.getQueue("Hello")).thenReturn(entry); +// +// entry.setContent(new Content()); +// //entry.getContent().setQueueDescription(new QueueDescription()); +// //entry.getContent().getQueueDescription().setMessageCount(73L); +// +// // Act +// ServiceBusClient client = new ServiceBusClient(contract); +// Queue helloQueue = client.getQueue("Hello"); +// helloQueue.fetch(); +// +// // Assert +// assertEquals(73, helloQueue.getMessageCount().longValue()); +// } +// +// @Test +// public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException, ServiceException { +// // Arrange +// ServiceBusService contract = mock(ServiceBusService.class); +// +// // Act +// ServiceBusClient client = new ServiceBusClient(contract); +// Queue helloQueue = client.getQueue("MyNewQueue"); +// helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); +// helloQueue.setMaxSizeInMegabytes(42L); +// helloQueue.save(); +// +// // Assert +// ArgumentCaptor argument = ArgumentCaptor.forClass(Entry.class); +// verify(contract).createQueue(argument.capture()); +// Entry entry = argument.getValue(); +// //QueueDescription model = entry.getContent().getQueueDescription(); +// +// assertEquals("MyNewQueue", entry.getTitle()); +// //assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); +// //assertEquals(42, model.getMaxSizeInMegabytes().longValue()); +// } +//} From cb1f7460eb8f4f8676c0a2e3361e4513b1b369c1 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 12:23:04 -0700 Subject: [PATCH 039/664] Updates to Queue data model Chainable setters Updating IntegrationTestBase to use service interface instead of client Changing Title property to Name - title is an Atom implementation detail --- .../azure/services/serviceBus/Queue.java | 37 ++++++++++++------- .../serviceBus/ServiceBusServiceImpl.java | 2 +- .../serviceBus/ContractIntegrationTest.java | 5 +-- .../{messaging => }/IntegrationTestBase.java | 17 +++++---- 4 files changed, 36 insertions(+), 25 deletions(-) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{messaging => }/IntegrationTestBase.java (81%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 7ae9549758d35..c85dd31f575f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -25,11 +25,11 @@ public Queue(Entry entry, QueueDescription model) { super(entry, model); } - public String getTitle() { + public String getName() { return entry.getTitle(); } - public Queue setTitle(String value) { + public Queue setName(String value) { entry.setTitle(value); return this; } @@ -38,71 +38,82 @@ public Duration getLockDuration() { return model.getLockDuration(); } - public void setLockDuration(Duration value) { + public Queue setLockDuration(Duration value) { model.setLockDuration(value); + return this; } public Long getMaxSizeInMegabytes() { return model.getMaxSizeInMegabytes(); } - public void setMaxSizeInMegabytes(Long value) { + public Queue setMaxSizeInMegabytes(Long value) { model.setMaxSizeInMegabytes(value); + return this; } - public void setRequiresDuplicateDetection(Boolean value) { + public Queue setRequiresDuplicateDetection(Boolean value) { model.setRequiresDuplicateDetection(value); + return this; } - public void setRequiresSession(Boolean value) { + public Queue setRequiresSession(Boolean value) { model.setRequiresSession(value); + return this; } public Duration getDefaultMessageTimeToLive() { return model.getDefaultMessageTimeToLive(); } - public void setDefaultMessageTimeToLive(Duration value) { + public Queue setDefaultMessageTimeToLive(Duration value) { model.setDefaultMessageTimeToLive(value); + return this; } - public void setDeadLetteringOnMessageExpiration(Boolean value) { + public Queue setDeadLetteringOnMessageExpiration(Boolean value) { model.setDeadLetteringOnMessageExpiration(value); + return this; } public Duration getDuplicateDetectionHistoryTimeWindow() { return model.getDuplicateDetectionHistoryTimeWindow(); } - public void setDuplicateDetectionHistoryTimeWindow(Duration value) { + public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { model.setDuplicateDetectionHistoryTimeWindow(value); + return this; } public Integer getMaxDeliveryCount() { return model.getMaxDeliveryCount(); } - public void setMaxDeliveryCount(Integer value) { + public Queue setMaxDeliveryCount(Integer value) { model.setMaxDeliveryCount(value); + return this; } - public void setEnableBatchedOperations(Boolean value) { + public Queue setEnableBatchedOperations(Boolean value) { model.setEnableBatchedOperations(value); + return this; } public Long getSizeInBytes() { return model.getSizeInBytes(); } - public void setSizeInBytes(Long value) { + public Queue setSizeInBytes(Long value) { model.setSizeInBytes(value); + return this; } public Long getMessageCount() { return model.getMessageCount(); } - public void setMessageCount(Long value) { + public Queue setMessageCount(Long value) { model.setMessageCount(value); + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 33f8dd41de5ff..22395aa78a7fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -125,7 +125,7 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { public Queue createQueue(Queue entry) throws ServiceException { try { return getResource() - .path(entry.getTitle()) + .path(entry.getName()) .type("application/atom+xml")//;type=entry;charset=utf-8") .put(Queue.class, entry); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java index c7bc6b649e9a4..7164c59e8ded6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java @@ -14,7 +14,6 @@ import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.schema.QueueDescription; -import com.microsoft.azure.services.serviceBus.messaging.IntegrationTestBase; import static org.junit.Assert.*; @@ -50,7 +49,7 @@ public void createQueueWorks() throws Exception { // Act Queue queue = new Queue(); - queue.setTitle("TestCreateQueueWorks"); + queue.setName("TestCreateQueueWorks"); queue.setMaxSizeInMegabytes(1024L); Queue saved = service.createQueue(queue); @@ -58,7 +57,7 @@ public void createQueueWorks() throws Exception { // Assert assertNotNull(saved); assertNotSame(queue, saved); - assertEquals("TestCreateQueueWorks", saved.getTitle()); + assertEquals("TestCreateQueueWorks", saved.getName()); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java similarity index 81% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index b9e089afda7c5..9b69cce8dc6c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus; import java.io.Console; @@ -45,20 +45,21 @@ public void initialize() throws Exception { boolean testAlphaExists = false; ServiceBusService service = createConfiguration().create(ServiceBusService.class); for(Queue queue : service.iterateQueues()) { - if (queue.getTitle().startsWith("Test") || queue.getTitle().startsWith("test")) { - if (queue.getTitle().equalsIgnoreCase("TestAlpha")) { + String queueName = queue.getName(); + if (queueName.startsWith("Test") || queueName.startsWith("test")) { + if (queueName.equalsIgnoreCase("TestAlpha")) { testAlphaExists = true; long count = queue.getMessageCount(); -// for(long i = 0; i != count; ++i) { -// queue.receiveMessage(new ReceiveMessageOptions().setTimeout(2000)); -// } + for(long i = 0; i != count; ++i) { + service.receiveMessage(queueName, 2000, ReceiveMode.RECEIVE_AND_DELETE); + } } else { -// queue.delete(); + service.deleteQueue(queueName); } } } if (!testAlphaExists) { - service.createQueue(new Queue().setTitle("TestAlpha")); + service.createQueue(new Queue().setName("TestAlpha")); } } } From 0d0deab70dfd639ac4fe195427e9322db1e600b3 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:13:58 -0700 Subject: [PATCH 040/664] Implementing body reader for Queue EntryModelProvider understands EntryModel types Actual serialization performed by body reader of underlying Entry schema type --- .../serviceBus/EntryModelProvider.java | 61 +++++++++++++++++++ .../azure/services/serviceBus/Exports.java | 3 + .../azure/services/serviceBus/Queue.java | 3 - .../azure/services/serviceBus/QueueList.java | 13 +++- .../serviceBus/ServiceBusServiceImpl.java | 46 +++++++------- ...st.java => ServiceBusIntegrationTest.java} | 2 +- 6 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{ContractIntegrationTest.java => ServiceBusIntegrationTest.java} (97%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java new file mode 100644 index 0000000000000..0d8ab10ac3546 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java @@ -0,0 +1,61 @@ +package com.microsoft.azure.services.serviceBus; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyReader; +import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; +import com.sun.jersey.spi.MessageBodyWorkers; + +public class EntryModelProvider extends + AbstractMessageReaderWriterProvider> { + + MessageBodyWorkers workers; + + public EntryModelProvider(@Context MessageBodyWorkers workers) { + this.workers = workers; + } + + public boolean isReadable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return EntryModel.class.isAssignableFrom(type); + } + + public EntryModel readFrom(Class> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + MessageBodyReader reader = workers.getMessageBodyReader( + Entry.class, Entry.class, annotations, mediaType); + + Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, + mediaType, httpHeaders, entityStream); + + return new Queue(entry); + } + + public boolean isWriteable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + // TODO Auto-generated method stub + return false; + } + + public void writeTo(EntryModel t, Class type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, + OutputStream entityStream) throws IOException, + WebApplicationException { + // TODO Auto-generated method stub + + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 2119232293daf..3adc0fcec2d9d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -24,6 +24,9 @@ public ClientConfig alter(ClientConfig instance, Builder builder, // need to avoid certain element prefixes, which the service does not ignore instance.getSingletons().add(new MarshallerProvider()); + // add body reader/writer for EntryModel descendant classes + instance.getClasses().add(EntryModelProvider.class); + return instance; } }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index c85dd31f575f9..88e314edd05bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -21,9 +21,6 @@ public Queue(Entry entry) { super(entry, entry.getContent().getQueueDescription()); } - public Queue(Entry entry, QueueDescription model) { - super(entry, model); - } public String getName() { return entry.getTitle(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java index 5afd4d14ceae2..746b98848e40f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java @@ -1,8 +1,19 @@ package com.microsoft.azure.services.serviceBus; -import java.util.Iterator; +import java.util.List; public class QueueList { + + private List queues; + + List getQueues() { + return queues; + } + + void setQueues(List queues) { + this.queues = queues; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 22395aa78a7fd..be8592929a50f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -2,6 +2,7 @@ import java.io.InputStream; import java.rmi.UnexpectedException; +import java.util.ArrayList; import javax.inject.Inject; import javax.inject.Named; @@ -166,32 +167,29 @@ public Queue getQueue(String queuePath) throws ServiceException { } public Iterable iterateQueues() throws ServiceException { - return null; -// try { -// return getResource() -// .path("$Resources/Queues") -// .get(Feed.class); -// } -// catch(UniformInterfaceException e) { -// throw processCatch(new ServiceException(e)); -// } -// catch(ClientHandlerException e) { -// throw processCatch(new ServiceException(e)); -// } + //TODO: iterate over link rel=next pagination + return getQueueList().getQueues(); } + public QueueList getQueueList() throws ServiceException { - return null; -// try { -// return getResource() -// .path("$Resources/Queues") -// .get(Feed.class); -// } -// catch(UniformInterfaceException e) { -// throw processCatch(new ServiceException(e)); -// } -// catch(ClientHandlerException e) { -// throw processCatch(new ServiceException(e)); -// } + try { + Feed feed = getResource() + .path("$Resources/Queues") + .get(Feed.class); + ArrayList queues = new ArrayList(); + for(Entry entry : feed.getEntries()){ + queues.add(new Queue(entry)); + } + QueueList result = new QueueList(); + result.setQueues(queues); + return result; + } + catch(UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch(ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } public Entry createTopic(Entry entry) throws ServiceException { try { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java similarity index 97% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 7164c59e8ded6..c8ed9709c9a65 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.*; -public class ContractIntegrationTest extends IntegrationTestBase { +public class ServiceBusIntegrationTest extends IntegrationTestBase { private Configuration config; private ServiceBusService service; From b2bce284f8274b7103dba9790179024bc6c7b3ac Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:25:39 -0700 Subject: [PATCH 041/664] Adding body writing to EntryModelProvider Also need to place queue descriptor in content element when Queue created by code --- .../services/serviceBus/EntryModelProvider.java | 12 +++++++++--- .../microsoft/azure/services/serviceBus/Queue.java | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java index 0d8ab10ac3546..cfeee55a1ddee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java @@ -11,6 +11,8 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; +import javax.ws.rs.ext.MessageBodyWriter; + import com.microsoft.azure.services.serviceBus.schema.Entry; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; @@ -45,8 +47,7 @@ public EntryModel readFrom(Class> type, Type genericType, public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - // TODO Auto-generated method stub - return false; + return EntryModel.class.isAssignableFrom(type); } public void writeTo(EntryModel t, Class type, Type genericType, @@ -54,8 +55,13 @@ public void writeTo(EntryModel t, Class type, Type genericType, MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { - // TODO Auto-generated method stub + + Entry entry = t.getEntry(); + + MessageBodyWriter writer = workers.getMessageBodyWriter( + Entry.class, Entry.class, annotations, mediaType); + writer.writeTo(entry, Entry.class, genericType, annotations, mediaType, httpHeaders, entityStream); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 88e314edd05bb..9acea472b99b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -15,6 +15,7 @@ public Queue() { super(new Entry(), new QueueDescription()); entry.setContent(new Content()); entry.getContent().setType(MediaType.APPLICATION_XML); + entry.getContent().setQueueDescription(getModel()); } public Queue(Entry entry) { From 6cf8b7d68dbf96d4f11f8dd8093a5251f339c58d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:27:55 -0700 Subject: [PATCH 042/664] Fixing delete queue unit test --- .../serviceBus/ServiceBusIntegrationTest.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index c8ed9709c9a65..686fd02bfea79 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -63,18 +63,9 @@ public void createQueueWorks() throws Exception { @Test public void deleteQueueWorks() throws Exception { // Arrange + service.createQueue(new Queue().setName("TestDeleteQueueWorks")); // Act - Entry entry = new Entry(); - Content content = new Content(); - QueueDescription description = new QueueDescription(); - - entry.setTitle("TestDeleteQueueWorks"); - entry.setContent(content); - content.setType("application/xml"); - content.setQueueDescription(description); -// service.createQueue(entry); - service.deleteQueue("TestDeleteQueueWorks"); // Assert From f30b3187e23d8f2efae1e8cc7b31dbabaa2de7ec Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:32:13 -0700 Subject: [PATCH 043/664] Remaining ServiceBusIntegrationTest operations work --- .../azure/services/serviceBus/IntegrationTestBase.java | 4 ++-- .../services/serviceBus/ServiceBusIntegrationTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 9b69cce8dc6c4..2cb8e261b9ce6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -32,7 +32,7 @@ public static void initializeSystem() { System.out.println("initialize"); System.setProperty("http.proxyHost", "itgproxy"); System.setProperty("http.proxyPort", "80"); - //System.setProperty("http.keepAlive", "false"); + System.setProperty("http.keepAlive", "false"); } @Before @@ -40,7 +40,7 @@ public void initialize() throws Exception { System.out.println("initialize"); System.setProperty("http.proxyHost", "itgproxy"); System.setProperty("http.proxyPort", "80"); - //System.setProperty("http.keepAlive", "false"); + System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; ServiceBusService service = createConfiguration().create(ServiceBusService.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 686fd02bfea79..8531b96b2cd72 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,6 +1,7 @@ package com.microsoft.azure.services.serviceBus; import java.io.ByteArrayInputStream; +import java.util.Arrays; import org.junit.Before; import org.junit.Test; @@ -92,12 +93,12 @@ public void receiveMessageWorks() throws Exception { // Act MessageResult message = service.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); - - // Assert byte[] data = new byte[100]; int size = message.getBody().read(data); + + // Assert assertEquals(11, size); - assertArrayEquals("Hello World".getBytes(), data); + assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size)); } @Test From c04009a17b44a835275e2dea57eb86efc4bc98f5 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:38:49 -0700 Subject: [PATCH 044/664] Cleaning up some unused classes --- .../serviceBus/messaging/AbstractEntity.java | 42 ----- .../serviceBus/messaging/Exports.java | 9 -- .../serviceBus/messaging/Message.java | 35 +++-- .../services/serviceBus/messaging/Queue.java | 148 ------------------ .../messaging/ServiceBusClient.java | 68 -------- .../serviceBus/IntegrationTestBase.java | 1 - .../messaging/ClientBuilderTest.java | 40 ----- 7 files changed, 18 insertions(+), 325 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java deleted file mode 100644 index b7f3957767be0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/AbstractEntity.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import javax.ws.rs.core.MediaType; - -import com.microsoft.azure.services.serviceBus.schema.Content; -import com.microsoft.azure.services.serviceBus.schema.Entry; - -import com.microsoft.azure.services.serviceBus.ServiceBusService; - -abstract class AbstractEntity { - - ServiceBusClient client; - Entry entry; - - AbstractEntity(ServiceBusClient client) { - this.client = client; - setEntry(new Entry()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - } - - AbstractEntity(ServiceBusClient client, Entry entry) { - this.client = client; - this.entry = entry; - } - - protected ServiceBusClient getClient() { - return client; - } - - protected ServiceBusService getContract() { - return getClient().getContract(); - } - - protected Entry getEntry() { - return entry; - } - - protected void setEntry(Entry entry) { - this.entry = entry; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java deleted file mode 100644 index 49f16aceca579..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Exports.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import com.microsoft.azure.configuration.builder.Builder; - -public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - registry.add(ServiceBusClient.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java index f440b77a41b47..ab26141569f4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java @@ -3,29 +3,13 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import com.microsoft.azure.services.serviceBus.BrokerProperties; +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; public class Message { BrokerProperties properties; InputStream body; - public String getLockToken() { - return properties.getLockToken(); - } - - public void setLockToken(String lockToken) { - properties.setLockToken(lockToken); - } - - public String getLockedUntilUtc() { - return properties.getLockedUntilUtc(); - } - - public void setLockedUntilUtc(String lockedUntilUtc) { - properties.setLockedUntilUtc(lockedUntilUtc); - } - public Message() { this(new BrokerProperties(), null); } @@ -56,6 +40,23 @@ public Message setBody(InputStream body) { return this; } + public String getLockToken() { + return properties.getLockToken(); + } + + public void setLockToken(String lockToken) { + properties.setLockToken(lockToken); + } + + public String getLockedUntilUtc() { + return properties.getLockedUntilUtc(); + } + + public void setLockedUntilUtc(String lockedUntilUtc) { + properties.setLockedUntilUtc(lockedUntilUtc); + } + + public Integer getDeliveryCount() { return properties.getDeliveryCount(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java deleted file mode 100644 index 6140d60f622f4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Queue.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import javax.xml.datatype.Duration; -import com.microsoft.azure.services.serviceBus.schema.Content; -import com.microsoft.azure.services.serviceBus.schema.Entry; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.services.serviceBus.MessageResult; -import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.schema.QueueDescription; - -public class Queue extends AbstractEntity implements MessageSender, MessageReceiver, MessageTransceiver { - Queue(ServiceBusClient client, String name) { - super(client); - - Content content = new Content(); - - getEntry().setContent(content); - content.setType("application/xml"); - content.setQueueDescription(new QueueDescription()); - - setName(name); - } - - Queue(ServiceBusClient client, Entry entry) { - super(client, entry); - } - - QueueDescription getQueueDescription(){ - return getEntry().getContent().getQueueDescription(); - } - - - // API methods -// -// public void save() throws ServiceException { -// setEntry(getContract().createQueue(getEntry())); -// } -// -// public void delete() throws ServiceException { -// getContract().deleteQueue(getName()); -// } -// -// public void fetch() throws ServiceException { -// setEntry(getContract().getQueue(getName())); -// } -// -// public void sendMessage(Message message) throws ServiceException { -// sendMessage(message, SendMessageOptions.DEFAULT); -// } -// -// public void sendMessage(Message message, SendMessageOptions options) throws ServiceException { -// getContract().sendMessage(getName(), message.getProperties(), message.getBody()); -// } -// -// public Message receiveMessage() throws ServiceException { -// return receiveMessage(ReceiveMessageOptions.DEFAULT); -// } -// -// public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { -// MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.RECEIVE_AND_DELETE); -// return new Message(result.getBrokerProperties(), result.getBody()); -// } -// -// public Message peekLockMessage() throws ServiceException { -// return peekLockMessage(ReceiveMessageOptions.DEFAULT); -// } -// -// public Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException { -// MessageResult result = getContract().receiveMessage(getName(), options.getTimeout(), ReceiveMode.PEEK_LOCK); -// return new Message(result.getBrokerProperties(), result.getBody()); -// } - - public void abandonMessage(Message message) { - // TODO Auto-generated method stub - } - - public void completeMessage(Message message) { - // TODO Auto-generated method stub - } - - - - - // API properties - - public String getName() { - return getEntry().getTitle(); - } - - public void setName(String value) { - getEntry().setTitle(value); - } - - public Duration getLockDuration() { - return getQueueDescription().getLockDuration(); - } - - public void setLockDuration(Duration value) { - getQueueDescription().setLockDuration(value); - } - - public Long getMaxSizeInMegabytes() { - return getQueueDescription().getMaxSizeInMegabytes(); - } - - public void setMaxSizeInMegabytes(Long value) { - getQueueDescription().setMaxSizeInMegabytes(value); - } - - public Long getMessageCount() { - return getQueueDescription().getMessageCount(); - } - - public Message receiveMessage() throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public Message receiveMessage(ReceiveMessageOptions options) - throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public Message peekLockMessage() throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public Message peekLockMessage(ReceiveMessageOptions options) - throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public void sendMessage(Message message) throws ServiceException { - // TODO Auto-generated method stub - - } - - public void sendMessage(Message message, SendMessageOptions options) - throws ServiceException { - // TODO Auto-generated method stub - - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java deleted file mode 100644 index bc8d7f1e7b66c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ServiceBusClient.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - - -import java.util.ArrayList; - -import javax.inject.Inject; - -import com.microsoft.azure.services.serviceBus.schema.Feed; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusService; - -public class ServiceBusClient { - - ServiceBusService contract; - - public ServiceBusClient() throws Exception { - this("", Configuration.load()); - } - - public ServiceBusClient(Configuration config) throws Exception { - this("", config); - } - - public ServiceBusClient(String profile) throws Exception { - this(profile, Configuration.load()); - } - - public ServiceBusClient(String profile, Configuration config) throws Exception { - this(config.create(profile, ServiceBusService.class)); - } - - @Inject - public ServiceBusClient(ServiceBusService contract) { - this.contract = contract; - } - - public ServiceBusService getContract() { - return contract; - } - - public void setContract(ServiceBusService contract) { - this.contract = contract; - } - -// public Iterable listQueues() throws ServiceException { -// return listQueues(ListQueuesOptions.DEFAULT); -// } - -// // REVIEW: what is the generalized strategy for paginated, client-roundtrippable iteration -// public Iterable listQueues(ListQueuesOptions options) throws ServiceException { -// Feed descriptions = contract.getQueueList()(); -// ArrayList queues = new ArrayList(); -// for (int i = 0; i != descriptions.getEntries().size(); ++i) { -// queues.add(new Queue(this, descriptions.getEntries().get(i))); -// } -// return queues; -// } - - public Queue getQueue(String path) { - return new Queue(this, path); - } - - public Iterable listTopics() { - return null; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 2cb8e261b9ce6..0860ac8576ba7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -9,7 +9,6 @@ import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.messaging.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java deleted file mode 100644 index 98180f1297c23..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/ClientBuilderTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import java.net.HttpURLConnection; -import java.net.URL; -import org.junit.Test; - -import static org.junit.Assert.*; - -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusServiceImpl; -import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; - - -public class ClientBuilderTest { - @Test - public void testServiceBusClientCreatedWithContractImpl() throws Exception { - // Arrange - Configuration config = new Configuration(); - - // Act - ServiceBusClient client = config.create(ServiceBusClient.class); - ServiceBusClient client2 = new ServiceBusClient(config); - - // Assert - assertNotNull(client); - assertNotNull(client.getContract()); - assertEquals(ServiceBusServiceImpl.class, client.getContract().getClass()); - - assertNotNull(client2); - assertNotNull(client2.getContract()); - assertEquals(ServiceBusServiceImpl.class, client2.getContract().getClass()); - } - - @Test - public void testHttp404() throws Exception { - HttpURLConnection x = (HttpURLConnection)new URL("http://github.com/no-such-file").openConnection(); - int code = x.getResponseCode(); - assertEquals(404, code); - } -} From 47344ff04a45d77dea617950f35c67bf3cb2d2ea Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:52:06 -0700 Subject: [PATCH 045/664] Streamlining Message data model class --- .../serviceBus/BrokerPropertiesMapper.java | 2 + .../azure/services/serviceBus/Message.java | 61 +++++++++++++++++++ .../services/serviceBus/MessageResult.java | 34 ----------- .../serviceBus/ServiceBusService.java | 6 +- .../serviceBus/ServiceBusServiceImpl.java | 14 +++-- .../serviceBus/messaging/Message.java | 1 - .../{ => schema}/BrokerProperties.java | 2 +- ...zure.configuration.builder.Builder$Exports | 1 - .../BrokerPropertiesMapperTest.java | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 24 +++----- 10 files changed, 85 insertions(+), 62 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => schema}/BrokerProperties.java (96%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java index 1cba63fc75190..16621d700351d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java @@ -9,6 +9,8 @@ import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; + public class BrokerPropertiesMapper { public BrokerProperties fromString(String value) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java new file mode 100644 index 0000000000000..e9ed9d54a0b85 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -0,0 +1,61 @@ +package com.microsoft.azure.services.serviceBus; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; + +public class Message { + BrokerProperties properties; + InputStream body; + + public Message() { + this.properties = new BrokerProperties(); + } + + public Message(InputStream body) { + this.properties = new BrokerProperties(); + this.body = body; + } + + public Message(byte[] body) { + this.properties = new BrokerProperties(); + this.body = (body == null) ? null : new ByteArrayInputStream(body); + } + + public Message(String body) { + this.properties = new BrokerProperties(); + this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); + } + + Message(BrokerProperties properties, InputStream body) { + this.properties = properties; + this.body = body; + } + + /** + * @return the brokerProperties + */ + BrokerProperties getProperties() { + return properties; + } + + /** + * @param properties the brokerProperties to set + */ + void setProperties(BrokerProperties properties) { + this.properties = properties; + } + /** + * @return the body + */ + public InputStream getBody() { + return body; + } + /** + * @param body the body to set + */ + public void setBody(InputStream body) { + this.body = body; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java deleted file mode 100644 index 9de5f7ec3c3de..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MessageResult.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -import java.io.InputStream; - -public class MessageResult { - BrokerProperties brokerProperties; - - InputStream body; - - /** - * @return the brokerProperties - */ - public BrokerProperties getBrokerProperties() { - return brokerProperties; - } - /** - * @param brokerProperties the brokerProperties to set - */ - public void setBrokerProperties(BrokerProperties brokerProperties) { - this.brokerProperties = brokerProperties; - } - /** - * @return the body - */ - public InputStream getBody() { - return body; - } - /** - * @param body the body to set - */ - public void setBody(InputStream body) { - this.body = body; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index 2840cef9bdcee..b0fe748780cbe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -1,7 +1,5 @@ package com.microsoft.azure.services.serviceBus; -import java.io.InputStream; - import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.services.serviceBus.schema.Feed; @@ -9,8 +7,8 @@ public interface ServiceBusService { - void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException; - MessageResult receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException; + void sendMessage(String path, Message message) throws ServiceException; + Message receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException; //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; //void abandonMessage(BrokeredMessage message) throws ServiceException; //void completeMessage(BrokeredMessage message) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index be8592929a50f..35dba9d76a724 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -9,6 +9,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.services.serviceBus.schema.Feed; @@ -60,13 +62,13 @@ private ServiceException processCatch(ServiceException e) { } // REVIEW: contentType will be needed - public void sendMessage(String path, BrokerProperties properties, InputStream body) throws ServiceException { + public void sendMessage(String path, Message message) throws ServiceException { try { getResource() .path(path) .path("messages") - .header("BrokerProperties", mapper.toString(properties)) - .post(body); + .header("BrokerProperties", mapper.toString(message.getProperties())) + .post(message.getBody()); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -76,7 +78,7 @@ public void sendMessage(String path, BrokerProperties properties, InputStream bo } } - public MessageResult receiveMessage(String queuePath, Integer timeout, + public Message receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException { WebResource resource = getResource() @@ -116,8 +118,8 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { } // REVIEW: harden this - it's much too brittle. throws null exceptions very easily - MessageResult result = new MessageResult(); - result.setBrokerProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); + Message result = new Message(); + result.setProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); result.setBody(clientResult.getEntityInputStream()); return result; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java index ab26141569f4e..1df111229e8e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java @@ -56,7 +56,6 @@ public void setLockedUntilUtc(String lockedUntilUtc) { properties.setLockedUntilUtc(lockedUntilUtc); } - public Integer getDeliveryCount() { return properties.getDeliveryCount(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java index 8b8806cc65b8b..b819b080b0918 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.schema; import org.codehaus.jackson.annotate.JsonGetter; import org.codehaus.jackson.annotate.JsonIgnore; diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index f7e819ac5b1e7..fd0961993d35b 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,5 +1,4 @@ com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports com.microsoft.azure.services.serviceBus.Exports -com.microsoft.azure.services.serviceBus.messaging.Exports com.microsoft.azure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index fbe2bd4451171..3cb3681acb4e0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -4,8 +4,8 @@ import org.junit.Test; -import com.microsoft.azure.services.serviceBus.BrokerProperties; import com.microsoft.azure.services.serviceBus.BrokerPropertiesMapper; +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; public class BrokerPropertiesMapperTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 8531b96b2cd72..ba30e72e42f29 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -5,13 +5,14 @@ import org.junit.Before; import org.junit.Test; + +import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; import com.microsoft.azure.services.serviceBus.schema.Content; import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.services.serviceBus.schema.Feed; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.BrokerProperties; -import com.microsoft.azure.services.serviceBus.MessageResult; +import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.schema.QueueDescription; @@ -75,11 +76,10 @@ public void deleteQueueWorks() throws Exception { @Test public void sendMessageWorks() throws Exception { // Arrange - - BrokerProperties props = new BrokerProperties(); + Message message = new Message("sendMessageWorks"); // Act - service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + service.sendMessage("TestAlpha", message); // Assert } @@ -87,12 +87,10 @@ public void sendMessageWorks() throws Exception { @Test public void receiveMessageWorks() throws Exception { // Arrange - - BrokerProperties props = new BrokerProperties(); - service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); + service.sendMessage("TestAlpha", new Message("Hello World")); // Act - MessageResult message = service.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); + Message message = service.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -104,17 +102,15 @@ public void receiveMessageWorks() throws Exception { @Test public void peekLockMessageWorks() throws Exception { // Arrange - - BrokerProperties props = new BrokerProperties(); + service.sendMessage("TestAlpha", new Message("Hello Again")); // Act - service.sendMessage("TestAlpha", props, new ByteArrayInputStream("Hello World".getBytes())); - MessageResult message = service.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); + Message message = service.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); // Assert byte[] data = new byte[100]; int size = message.getBody().read(data); assertEquals(11, size); - assertEquals("Hello World", new String(data, 0, size)); + assertEquals("Hello Again", new String(data, 0, size)); } } From 4aa2b74845c675a96a6a4f92efe804bbaad6c4ae Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:54:38 -0700 Subject: [PATCH 046/664] Cleaning up more unused classes --- .../messaging/ListQueuesOptions.java | 24 ------ .../serviceBus/messaging/Message.java | 79 ------------------- .../serviceBus/messaging/MessageReceiver.java | 1 + .../serviceBus/messaging/MessageSender.java | 1 + .../services/serviceBus/messaging/Rule.java | 5 -- .../serviceBus/messaging/Subscription.java | 7 -- .../services/serviceBus/messaging/Topic.java | 7 -- 7 files changed, 2 insertions(+), 122 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java deleted file mode 100644 index b8b6b73b40942..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ListQueuesOptions.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -public class ListQueuesOptions { - - public static final ListQueuesOptions DEFAULT = new ListQueuesOptions(); - - Integer skip; - public Integer getSkip() { - return skip; - } - public ListQueuesOptions setSkip(Integer skip) { - this.skip = skip; - return this; - } - public Integer getMaxCount() { - return maxCount; - } - public ListQueuesOptions setMaxCount(Integer maxCount) { - this.maxCount = maxCount; - return this; - } - Integer maxCount; - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java deleted file mode 100644 index 1df111229e8e4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Message.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; - - -public class Message { - BrokerProperties properties; - InputStream body; - - public Message() { - this(new BrokerProperties(), null); - } - - public Message(InputStream body) { - this(new BrokerProperties(), body); - } - - public Message(String body) { - this(new BrokerProperties(), (body == null) ? null : new ByteArrayInputStream(body.getBytes())); - } - - Message(BrokerProperties properties, InputStream body) { - this.properties = properties; - this.body = body; - } - - BrokerProperties getProperties() { - return properties; - } - - public InputStream getBody() { - return body; - } - - public Message setBody(InputStream body) { - this.body = body; - return this; - } - - public String getLockToken() { - return properties.getLockToken(); - } - - public void setLockToken(String lockToken) { - properties.setLockToken(lockToken); - } - - public String getLockedUntilUtc() { - return properties.getLockedUntilUtc(); - } - - public void setLockedUntilUtc(String lockedUntilUtc) { - properties.setLockedUntilUtc(lockedUntilUtc); - } - - public Integer getDeliveryCount() { - return properties.getDeliveryCount(); - } - - public String getMessageId() { - return properties.getMessageId(); - } - - public Long getSequenceNumber() { - return properties.getSequenceNumber(); - } - - public Long getTimeToLive() { - return properties.getTimeToLive(); - } - - public Message setTimeToLive(Long timeToLive) { - properties.setTimeToLive(timeToLive); - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java index 0bed33badbe2f..763574d16ac07 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java @@ -1,6 +1,7 @@ package com.microsoft.azure.services.serviceBus.messaging; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.serviceBus.Message; public interface MessageReceiver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java index c942cbf515503..36720140f0d66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java @@ -1,6 +1,7 @@ package com.microsoft.azure.services.serviceBus.messaging; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.serviceBus.Message; public interface MessageSender { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java deleted file mode 100644 index 6024ffc995026..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Rule.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -public class Rule { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java deleted file mode 100644 index df3f45f2482bc..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Subscription.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -public class Subscription { - public Rule getRules() { - return null; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java deleted file mode 100644 index a71cc3701b2b4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/Topic.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.azure.services.serviceBus.messaging; - -public class Topic { - Subscription[] getSubscriptions() { - return null; - } -} From 61a255c48e115045dec62195ddd94ae832f601ac Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 13:57:08 -0700 Subject: [PATCH 047/664] Moving services.serviceBus.messaging to services.serviceBus.client --- .../serviceBus/{messaging => client}/MessageReceiver.java | 2 +- .../serviceBus/{messaging => client}/MessageSender.java | 2 +- .../serviceBus/{messaging => client}/MessageTransceiver.java | 2 +- .../serviceBus/{messaging => client}/ReceiveMessageOptions.java | 2 +- .../serviceBus/{messaging => client}/SendMessageOptions.java | 2 +- .../azure/services/serviceBus/IntegrationTestBase.java | 2 +- .../{messaging => client}/QueueManagementIntegrationTest.java | 1 + .../serviceBus/{messaging => client}/QueueManagementTest.java | 1 + 8 files changed, 8 insertions(+), 6 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{messaging => client}/MessageReceiver.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{messaging => client}/MessageSender.java (80%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{messaging => client}/MessageTransceiver.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{messaging => client}/ReceiveMessageOptions.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{messaging => client}/SendMessageOptions.java (66%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{messaging => client}/QueueManagementIntegrationTest.java (94%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/{messaging => client}/QueueManagementTest.java (95%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java index 763574d16ac07..cb18c72c33155 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus.client; import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.Message; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java similarity index 80% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java index 36720140f0d66..f9b1568e5a5b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus.client; import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.Message; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java index 2dbe7eb978992..253fc046a8949 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/MessageTransceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java @@ -1,5 +1,5 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus.client; public interface MessageTransceiver extends MessageSender, MessageReceiver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java index 3e91c4991e964..380bcf2c3c02e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus.client; public class ReceiveMessageOptions { Integer timeout; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java similarity index 66% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java index a1af78c648889..dbc353621a41d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/messaging/SendMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.messaging; +package com.microsoft.azure.services.serviceBus.client; public class SendMessageOptions { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 0860ac8576ba7..039658054674f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -8,7 +8,7 @@ import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.messaging.ReceiveMessageOptions; +import com.microsoft.azure.services.serviceBus.client.ReceiveMessageOptions; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java similarity index 94% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java index bf3c4f8ca1229..0ca8e2c38c7a8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java @@ -1,3 +1,4 @@ +package com.microsoft.azure.services.serviceBus.client; //package com.microsoft.azure.services.serviceBus.messaging; // //import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java similarity index 95% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java index cdae4631daae0..4183ba2ae42ef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/messaging/QueueManagementTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java @@ -1,3 +1,4 @@ +package com.microsoft.azure.services.serviceBus.client; //package com.microsoft.azure.services.serviceBus.messaging; // //import static org.junit.Assert.*; From e5aa95be6772497986f8e33dac1a897f4acbecb8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 14:37:29 -0700 Subject: [PATCH 048/664] Refining small MessagingClient high-level helper --- .../azure/services/serviceBus/Exports.java | 2 + .../serviceBus/ServiceBusService.java | 8 +- .../serviceBus/ServiceBusServiceImpl.java | 16 +++ .../serviceBus/client/MessageSender.java | 1 - .../serviceBus/client/MessagingClient.java | 127 ++++++++++++++++++ .../serviceBus/client/SendMessageOptions.java | 7 - .../serviceBus/ServiceBusIntegrationTest.java | 8 -- .../MessagingClientIntegrationTest.java | 79 +++++++++++ 8 files changed, 228 insertions(+), 20 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 3adc0fcec2d9d..0d4df21346394 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -3,6 +3,7 @@ import java.util.Map; import com.microsoft.azure.configuration.builder.Builder; +import com.microsoft.azure.services.serviceBus.client.MessagingClient; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; @@ -11,6 +12,7 @@ public void register(Builder.Registry registry) { // provide contract implementation registry.add(ServiceBusService.class, ServiceBusServiceImpl.class); + registry.add(MessagingClient.class); // alter jersey client config for serviceBus registry.alter(ClientConfig.class, new Builder.Alteration() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index b0fe748780cbe..ecc1a75495db6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -8,10 +8,10 @@ public interface ServiceBusService { void sendMessage(String path, Message message) throws ServiceException; - Message receiveMessage(String queuePath, Integer timeout, ReceiveMode receiveMode) throws ServiceException; - //BrokeredMessage receiveMessage(String topicPath, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; - //void abandonMessage(BrokeredMessage message) throws ServiceException; - //void completeMessage(BrokeredMessage message) throws ServiceException; + Message receiveMessage(String queueName, Integer timeout, ReceiveMode receiveMode) throws ServiceException; + Message receiveMessage(String topicName, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; + void abandonMessage(Message message) throws ServiceException; + void completeMessage(Message message) throws ServiceException; Queue createQueue(Queue queue) throws ServiceException; void deleteQueue(String queuePath) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 35dba9d76a724..3d8453d3a5e11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -124,6 +124,21 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { return result; } + public Message receiveMessage(String topicPath, String subscriptionName, + int timeout, ReceiveMode receiveMode) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public void abandonMessage(Message message) throws ServiceException { + // TODO Auto-generated method stub + + } + + public void completeMessage(Message message) throws ServiceException { + // TODO Auto-generated method stub + + } public Queue createQueue(Queue entry) throws ServiceException { try { @@ -277,4 +292,5 @@ public Feed getRules(String topicPath, String subscriptionName) { } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java index f9b1568e5a5b1..f710502261215 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java @@ -6,5 +6,4 @@ public interface MessageSender { void sendMessage(Message message) throws ServiceException; - void sendMessage(Message message, SendMessageOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java new file mode 100644 index 0000000000000..e3290259ba23d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -0,0 +1,127 @@ +package com.microsoft.azure.services.serviceBus.client; + +import javax.inject.Inject; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.ReceiveMode; +import com.microsoft.azure.services.serviceBus.ServiceBusService; + +public class MessagingClient { + private ServiceBusService service; + + + public MessagingClient() throws Exception { + this.setService(Configuration.load().create(ServiceBusService.class)); + } + + public MessagingClient(String profile) throws Exception { + this.setService(Configuration.load().create(profile, ServiceBusService.class)); + } + + public MessagingClient(Configuration configuration) throws Exception { + this.setService(configuration.create(ServiceBusService.class)); + } + + public MessagingClient(String profile, Configuration configuration) throws Exception { + this.setService(configuration.create(profile, ServiceBusService.class)); + } + + @Inject + public MessagingClient(ServiceBusService service) { + this.setService(service); + } + + public void setService(ServiceBusService service) { + this.service = service; + } + + public ServiceBusService getService() { + return service; + } + + public MessageTransceiver openQueue(String queueName) { + final String queue = queueName; + return new MessageTransceiver() { + + public void sendMessage(Message message) throws ServiceException { + service.sendMessage(queue, message); + } + + public Message receiveMessage() throws ServiceException { + return receiveMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message receiveMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveMessage(queue, options.getTimeout(), + ReceiveMode.RECEIVE_AND_DELETE); + } + + public Message peekLockMessage() throws ServiceException { + return peekLockMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message peekLockMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveMessage(queue, options.getTimeout(), + ReceiveMode.PEEK_LOCK); + } + + public void abandonMessage(Message message) throws ServiceException { + service.abandonMessage(message); + } + + public void completeMessage(Message message) + throws ServiceException { + service.completeMessage(message); + } + }; + } + + public MessageSender openTopic(String topicName) { + final String topic = topicName; + return new MessageSender() { + public void sendMessage(Message message) throws ServiceException { + service.sendMessage(topic, message); + } + }; + } + + public MessageReceiver openSubscription(String topicName, String subscriptionName) { + final String topic = topicName; + final String subscription = subscriptionName; + return new MessageReceiver() { + + public Message receiveMessage() throws ServiceException { + return receiveMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message receiveMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveMessage(topic, subscription, options.getTimeout(), + ReceiveMode.RECEIVE_AND_DELETE); + } + + public Message peekLockMessage() throws ServiceException { + return peekLockMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message peekLockMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveMessage(topic, subscription, options.getTimeout(), + ReceiveMode.PEEK_LOCK); + } + + public void abandonMessage(Message message) throws ServiceException { + service.abandonMessage(message); + } + + public void completeMessage(Message message) + throws ServiceException { + service.completeMessage(message); + } + }; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java deleted file mode 100644 index dbc353621a41d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/SendMessageOptions.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.azure.services.serviceBus.client; - -public class SendMessageOptions { - - public static final SendMessageOptions DEFAULT = new SendMessageOptions(); - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index ba30e72e42f29..1b23e338b39c1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,22 +1,14 @@ package com.microsoft.azure.services.serviceBus; -import java.io.ByteArrayInputStream; import java.util.Arrays; import org.junit.Before; import org.junit.Test; -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; -import com.microsoft.azure.services.serviceBus.schema.Content; -import com.microsoft.azure.services.serviceBus.schema.Entry; -import com.microsoft.azure.services.serviceBus.schema.Feed; - import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.schema.QueueDescription; - import static org.junit.Assert.*; public class ServiceBusIntegrationTest extends IntegrationTestBase { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java new file mode 100644 index 0000000000000..0c63405f21ee4 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java @@ -0,0 +1,79 @@ +package com.microsoft.azure.services.serviceBus.client; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.serviceBus.IntegrationTestBase; +import com.microsoft.azure.services.serviceBus.Message; + +public class MessagingClientIntegrationTest extends IntegrationTestBase { + + private MessagingClient messaging; + + @Before + public void createClient() throws Exception + { + messaging = createConfiguration().create(MessagingClient.class); + } + + @Test + public void queueWillSendAndReceiveMessages() throws Exception + { + // Arrange + MessageTransceiver port = messaging.openQueue("TestAlpha"); + Message messageOut = new Message("queueWillSendAndReceiveMessages"); + + // Act + port.sendMessage(messageOut); + Message messageIn = port.receiveMessage(); + + // Assert + assertNotSame(messageOut, messageIn); + + byte[] data = new byte[100]; + int size = messageIn.getBody().read(data); + assertEquals(31, size); + assertEquals("queueWillSendAndReceiveMessages", new String(data, 0, size)); + } + + + @Test + public void queueIsSenderAndReceiver() throws Exception + { + // Arrange + MessageSender sender = messaging.openQueue("TestAlpha"); + MessageReceiver receiver = messaging.openQueue("TestAlpha"); + Message messageOut = new Message("queueIsSenderAndReceiver"); + + // Act + sender.sendMessage(messageOut); + Message messageIn = receiver.receiveMessage(); + + // Assert + assertNotSame(messageOut, messageIn); + + byte[] data = new byte[100]; + int size = messageIn.getBody().read(data); + assertEquals(24, size); + assertEquals("queueIsSenderAndReceiver", new String(data, 0, size)); + } + + + @Test + public void clientMayBeCreatedDirectly() throws Exception + { + // Arrange + + // Act + MessagingClient mc = new MessagingClient(createConfiguration()); + mc.openQueue("TestAlpha").sendMessage(new Message("clientMayBeCreatedDirectly")); + + // Assert + } + +} From 991e08bd3479370b2a3ca7f44a8e6e6a1f844052 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 15:05:16 -0700 Subject: [PATCH 049/664] Removing unused classes --- .../QueueManagementIntegrationTest.java | 101 ------------------ .../client/QueueManagementTest.java | 66 ------------ 2 files changed, 167 deletions(-) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java deleted file mode 100644 index 0ca8e2c38c7a8..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementIntegrationTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.microsoft.azure.services.serviceBus.client; -//package com.microsoft.azure.services.serviceBus.messaging; -// -//import static org.junit.Assert.*; -// -//import java.io.ByteArrayInputStream; -// -//import org.junit.Test; -// -//import com.microsoft.azure.services.serviceBus.messaging.Message; -//import com.microsoft.azure.services.serviceBus.messaging.Queue; -//import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; -// -// -//public class QueueManagementIntegrationTest extends IntegrationTestBase { -// -// private ServiceBusClient createClient() throws Exception { -// return new ServiceBusClient(createConfiguration()); -// } -// -// @Test -// public void queueCanBeCreatedAndDeleted() throws Exception { -// // Arrange -// ServiceBusClient client = createClient(); -// -// // Act -// Queue queue = client.getQueue("TestQueueCanBeCreatedAndDeleted"); -// queue.save(); -// queue.delete(); -// -// // Assert -// } -// -// @Test -// public void whenQueueIsCreatedEntityStateIsAlsoUpdated() throws Exception { -// // Arrange -// ServiceBusClient client = createClient(); -// -// // Act -// Queue queue = client.getQueue("TestWhenQueueIsCreatedEntityStateIsAlsoUpdated"); -// Long maxSizeBefore = queue.getMaxSizeInMegabytes(); -// queue.save(); -// Long maxSizeAfter = queue.getMaxSizeInMegabytes(); -// queue.delete(); -// -// // Assert -// assertNull(maxSizeBefore); -// assertNotNull(maxSizeAfter); -// } -// -// -// @Test -// public void existingQueuePathDoesNotReturnNull() throws Exception { -// // Arrange -// ServiceBusClient client = createClient(); -// -// // Act -// Queue queue = client.getQueue("TestAlpha"); -// queue.fetch(); -// -// // Assert -// assertNotNull(queue); -// assertEquals("TestAlpha", queue.getName()); -// } -// -// @Test -// public void createQueueAndSendAndReceiveMessage() throws Exception { -// // Arrange -// ServiceBusClient client = createClient(); -// -// // Act -// Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); -// queue.save(); -// -// queue.sendMessage(new Message("Hello World")); -// Message received = queue.receiveMessage(); -// -// // Assert -// assertNotNull(received); -// assertEquals(1, (int)received.getDeliveryCount()); -// } -// -// -// @Test -// public void peekLockedMessageHasLockTokenAndLockedUntilUtc() throws Exception { -// // Arrange -// ServiceBusClient client = createClient(); -// -// // Act -// Queue queue = client.getQueue("TestCreateQueueAndSendAndReceiveMessage"); -// queue.save(); -// -// queue.sendMessage(new Message("Hello World")); -// Message received = queue.peekLockMessage(); -// -// // Assert -// assertNotNull(received); -// assertNotNull(received.getLockToken()); -// assertNotNull(received.getLockedUntilUtc()); -// } -//} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java deleted file mode 100644 index 4183ba2ae42ef..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/QueueManagementTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.microsoft.azure.services.serviceBus.client; -//package com.microsoft.azure.services.serviceBus.messaging; -// -//import static org.junit.Assert.*; -//import static org.mockito.Mockito.*; -// -//import javax.xml.datatype.DatatypeConfigurationException; -//import javax.xml.datatype.DatatypeFactory; -// -//import org.junit.Test; -//import org.mockito.ArgumentCaptor; -//import com.microsoft.azure.services.serviceBus.schema.Content; -//import com.microsoft.azure.services.serviceBus.schema.Entry; -// -//import com.microsoft.azure.ServiceException; -//import com.microsoft.azure.services.serviceBus.ServiceBusService; -//import com.microsoft.azure.services.serviceBus.schema.QueueDescription; -//import com.microsoft.azure.services.serviceBus.messaging.Queue; -//import com.microsoft.azure.services.serviceBus.messaging.ServiceBusClient; -// -// -//public class QueueManagementTest { -// @Test -// public void testGetQueueAcquiresDescriptionFromServer() throws ServiceException { -// // Arrange -// ServiceBusService contract = mock(ServiceBusService.class); -// -// Entry entry = new Entry(); -// when(contract.getQueue("Hello")).thenReturn(entry); -// -// entry.setContent(new Content()); -// //entry.getContent().setQueueDescription(new QueueDescription()); -// //entry.getContent().getQueueDescription().setMessageCount(73L); -// -// // Act -// ServiceBusClient client = new ServiceBusClient(contract); -// Queue helloQueue = client.getQueue("Hello"); -// helloQueue.fetch(); -// -// // Assert -// assertEquals(73, helloQueue.getMessageCount().longValue()); -// } -// -// @Test -// public void queueCreateSendsCreateQueueDescriptionMessage() throws DatatypeConfigurationException, ServiceException { -// // Arrange -// ServiceBusService contract = mock(ServiceBusService.class); -// -// // Act -// ServiceBusClient client = new ServiceBusClient(contract); -// Queue helloQueue = client.getQueue("MyNewQueue"); -// helloQueue.setLockDuration(DatatypeFactory.newInstance().newDuration(60 * 1000L)); -// helloQueue.setMaxSizeInMegabytes(42L); -// helloQueue.save(); -// -// // Assert -// ArgumentCaptor argument = ArgumentCaptor.forClass(Entry.class); -// verify(contract).createQueue(argument.capture()); -// Entry entry = argument.getValue(); -// //QueueDescription model = entry.getContent().getQueueDescription(); -// -// assertEquals("MyNewQueue", entry.getTitle()); -// //assertEquals(DatatypeFactory.newInstance().newDuration(60 * 1000L), model.getLockDuration()); -// //assertEquals(42, model.getMaxSizeInMegabytes().longValue()); -// } -//} From 889f9c4fe3ade6857a79bf43ff9a54a5fea43768 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 2 Nov 2011 15:59:02 -0700 Subject: [PATCH 050/664] Initial checkin (Account info removed from tests) --- .../azure/services/blob/BlobConfig.java | 7 + .../azure/services/blob/BlobContract.java | 21 ++ .../azure/services/blob/BlobContractImpl.java | 202 ++++++++++++++ .../services/blob/BlobListingDetails.java | 48 ++++ .../blob/BlobSharedKeyLiteFilter.java | 117 ++++++++ .../blob/ContainerListingDetails.java | 36 +++ .../services/blob/ContainerProperties.java | 34 +++ .../services/blob/CreateContainerOptions.java | 31 +++ .../azure/services/blob/Exports.java | 10 + .../azure/services/blob/ListBlobsOptions.java | 56 ++++ .../azure/services/blob/ListBlobsResults.java | 252 ++++++++++++++++++ .../services/blob/ListContainersOptions.java | 46 ++++ .../services/blob/ListContainersResults.java | 142 ++++++++++ .../azure/services/blob/MetadataAdapter.java | 29 ++ .../services/blob/MetadataHashMapType.java | 13 + .../com/microsoft/azure/utils/Base64.java | 178 +++++++++++++ .../microsoft/azure/utils/HmacSHA256Sign.java | 27 ++ ...zure.configuration.builder.Builder$Exports | 1 + .../blob/BlobContractIntegrationTest.java | 178 +++++++++++++ .../services/blob/IntegrationTestBase.java | 38 +++ 20 files changed, 1466 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java new file mode 100644 index 0000000000000..7b2b78074e853 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.blob; + +public interface BlobConfig { + public final String CONFIG_ACCOUNT_NAME = "blob.accountName"; + public final String CONFIG_ACCOUNT_KEY = "blob.accountKey"; + public final String CONFIG_URL = "blob.url"; +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java new file mode 100644 index 0000000000000..4e30cc1136f65 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java @@ -0,0 +1,21 @@ +package com.microsoft.azure.services.blob; + +public interface BlobContract { + ListContainersResults listContainers(); + + ListContainersResults listContainers(ListContainersOptions options); + + void createContainer(String container); + + void createContainer(String container, CreateContainerOptions options); + + void deleteContainer(String container); + + ContainerProperties getContainerProperties(String container); + + ContainerProperties getContainerMetadata(String container); + + ListBlobsResults listBlobs(String container); + + ListBlobsResults listBlobs(String container, ListBlobsOptions options); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java new file mode 100644 index 0000000000000..533e863c67586 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java @@ -0,0 +1,202 @@ +package com.microsoft.azure.services.blob; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import javax.inject.Inject; +import javax.inject.Named; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; + +public class BlobContractImpl implements BlobContract { + + private static final String X_MS_VERSION = "x-ms-version"; + private static final String X_MS_BLOB_PUBLIC_ACCESS = "x-ms-blob-public-access"; + private static final String X_MS_META_PREFIX = "x-ms-meta-"; + private static final String API_VERSION = "2009-09-19"; + private final Client channel; + private final String accountName; + private final String url; + + @Inject + public BlobContractImpl(Client channel, @Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_URL) String url, + // TODO: How to make this configurable though code? + BlobSharedKeyLiteFilter filter) { + + this.accountName = accountName; + this.url = url; + this.channel = channel; + channel.addFilter(filter); + } + + private WebResource optionalQueryParam(WebResource wr, String key, String value) { + if (value != null) { + wr = wr.queryParam(key, value); + } + return wr; + } + + private WebResource optionalQueryParam(WebResource wr, String key, int value, int defaultValue) { + if (value != defaultValue) { + wr = wr.queryParam(key, Integer.toString(value)); + } + return wr; + } + + private WebResource getResource() { + WebResource res = channel.resource(url).path("/"); + + return res; + } + + private WebResource setCanonicalizedResource(WebResource wr, String resourceName, String operation) { + String value = "/" + this.accountName + "/"; + if (resourceName != null) { + value += resourceName; + } + + if (operation != null) { + value += "?comp=" + operation; + } + + wr.setProperty("canonicalizedResource", value); + return wr; + } + + public void createContainer(String container) { + createContainer(container, new CreateContainerOptions()); + } + + public void createContainer(String container, CreateContainerOptions options) { + WebResource webResource = getResource().path(container).queryParam("resType", "container"); + + webResource = setCanonicalizedResource(webResource, container, null); + + WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + // Metadata + for (Entry entry : options.getMetadata().entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + // Public access + if (options.getPublicAccess() != null) { + builder = builder.header(X_MS_BLOB_PUBLIC_ACCESS, options.getPublicAccess()); + } + + builder + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + .header("Content-Type", "text/plain").put(""); + } + + public void deleteContainer(String container) { + WebResource webResource = getResource(); + webResource = setCanonicalizedResource(webResource, container, null); + webResource.path(container).queryParam("resType", "container").header(X_MS_VERSION, API_VERSION).delete(); + } + + public ContainerProperties getContainerProperties(String container) { + return getContainerPropertiesImpl(container, null); + } + + public ContainerProperties getContainerMetadata(String container) { + return getContainerPropertiesImpl(container, "metadata"); + } + + private ContainerProperties getContainerPropertiesImpl(String container, String operation) { + WebResource webResource = getResource().path(container).queryParam("resType", "container"); + if (operation != null) { + webResource = webResource.queryParam("comp", operation); + } + + webResource = setCanonicalizedResource(webResource, container, operation); + + ClientResponse response = webResource.header(X_MS_VERSION, API_VERSION).get(ClientResponse.class); + + ContainerProperties properties = new ContainerProperties(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(response.getHeaders().getFirst("Last-Modified")); + // Metadata + HashMap metadata = new HashMap(); + for (Entry> entry : response.getHeaders().entrySet()) { + if (entry.getKey().startsWith(X_MS_META_PREFIX)) { + String name = entry.getKey().substring(X_MS_META_PREFIX.length()); + String value = entry.getValue().get(0); + metadata.put(name, value); + } + } + properties.setMetadata(metadata); + return properties; + } + + public ListContainersResults listContainers() { + return listContainers(new ListContainersOptions()); + } + + public ListContainersResults listContainers(ListContainersOptions options) { + WebResource webResource = getResource().path("/").queryParam("comp", "list"); + + webResource = setCanonicalizedResource(webResource, null, "list"); + webResource = optionalQueryParam(webResource, "prefix", options.getPrefix()); + webResource = optionalQueryParam(webResource, "marker", options.getMarker()); + webResource = optionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + if (options.getListingDetails().contains(ContainerListingDetails.METADATA)) { + webResource = webResource.queryParam("include", "metadata"); + } + + return webResource.header(X_MS_VERSION, API_VERSION).get(ListContainersResults.class); + } + + public ListBlobsResults listBlobs(String container) { + return listBlobs(container, new ListBlobsOptions()); + } + + 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(); + } + } + + public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { + WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); + + webResource = setCanonicalizedResource(webResource, container, "list"); + webResource = optionalQueryParam(webResource, "prefix", options.getPrefix()); + webResource = optionalQueryParam(webResource, "marker", options.getMarker()); + webResource = optionalQueryParam(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 = optionalQueryParam(webResource, "include", sb.toString()); + } + + return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResults.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java new file mode 100644 index 0000000000000..57595fc6d1c76 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java @@ -0,0 +1,48 @@ +package com.microsoft.azure.services.blob; + +/** + * TODO: Naming and unification with client package + * + * 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/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java new file mode 100644 index 0000000000000..5208ae580c687 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -0,0 +1,117 @@ +package com.microsoft.azure.services.blob; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import javax.inject.Named; + +import com.microsoft.azure.utils.HmacSHA256Sign; +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; + +public class BlobSharedKeyLiteFilter extends ClientFilter { + private final String accountName; + private final HmacSHA256Sign signer; + + public BlobSharedKeyLiteFilter(@Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_ACCOUNT_KEY) String accountKey) { + + this.accountName = accountName; + // TODO: How to make this configurable? + this.signer = new HmacSHA256Sign(accountKey); + } + + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + + sign(cr); + + return this.getNext().handle(cr); + } + + private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; + + private String nullEmpty(String value) { + return value != null ? value : ""; + } + + /* + * StringToSign = VERB + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + + * Date + "\n" + CanonicalizedHeaders + CanonicalizedResource; + */ + private void sign(ClientRequest cr) { + // gather signed material + String requestMethod = cr.getMethod(); + String contentMD5 = getHeader(cr, "Content-MD5"); + String contentType = getHeader(cr, "Content-Type"); + String date = getHeader(cr, "Date"); + + if (date == "") { + DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); + rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); + date = rfc1123Format.format(new Date()); + cr.getHeaders().add("Date", date); + } + + // build signed string + String stringToSign = requestMethod + "\n" + contentMD5 + "\n" + contentType + "\n" + date + "\n"; + + stringToSign += addCanonicalizedHeaders(cr); + stringToSign += addCanonicalizedResource(cr); + + System.out.println(stringToSign); + String signature = this.signer.sign(stringToSign); + cr.getHeaders().add("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); + } + + /* + * Constructing the Canonicalized Headers String + * + * To construct the CanonicalizedHeaders portion of the signature string, + * follow these steps: 1. Retrieve all headers for the resource that begin + * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header + * name to lowercase. 3. Sort the headers lexicographically by header name, + * in ascending order. Note that each header may appear only once in the + * string. 4. Unfold the string by replacing any breaking white space with a + * single space. 5. Trim any white space around the colon in the header. 6. + * Finally, append a new line character to each canonicalized header in the + * resulting list. Construct the CanonicalizedHeaders string by + * concatenating all headers in this list into a single string. + */ + private String addCanonicalizedHeaders(ClientRequest cr) { + ArrayList msHeaders = new ArrayList(); + for (String key : cr.getHeaders().keySet()) { + if (key.toLowerCase(Locale.US).startsWith("x-ms-")) { + msHeaders.add(key.toLowerCase(Locale.US)); + } + } + Collections.sort(msHeaders); + + String result = ""; + for (String msHeader : msHeaders) { + result += msHeader + ":" + cr.getHeaders().getFirst(msHeader) + "\n"; + } + return result; + } + + private String addCanonicalizedResource(ClientRequest cr) { + String canonicalizedResource = (String) cr.getProperties().get("canonicalizedResource"); + return nullEmpty(canonicalizedResource); + } + + private String getHeader(ClientRequest cr, String headerKey) { + List values = cr.getHeaders().get(headerKey); + if (values == null || values.size() != 1) { + return nullEmpty(null); + } + + return nullEmpty(values.get(0).toString()); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java new file mode 100644 index 0000000000000..577e1ac543a5f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java @@ -0,0 +1,36 @@ +package com.microsoft.azure.services.blob; + +/** + * TODO: Naming and unification with client package + * + * 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/azure/services/blob/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java new file mode 100644 index 0000000000000..7767da5a17208 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java @@ -0,0 +1,34 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class ContainerProperties { + private String etag; + // TODO: Should this be a Date? + private String lastModified; + private HashMap metadata; + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public String getLastModified() { + return lastModified; + } + + public void setLastModified(String lastModified) { + this.lastModified = lastModified; + } + + 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/blob/CreateContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java new file mode 100644 index 0000000000000..7cf500be46e6f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java @@ -0,0 +1,31 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class CreateContainerOptions { + private String publicAccess; + private HashMap metadata = new HashMap(); + + public HashMap getMetadata() { + return metadata; + } + + public CreateContainerOptions setMetadata(HashMap metadata) { + this.metadata = metadata; + return this; + } + + public CreateContainerOptions addMetadata(String key, String value) { + this.getMetadata().put(key, value); + return this; + } + + public String getPublicAccess() { + return publicAccess; + } + + public CreateContainerOptions setPublicAccess(String publicAccess) { + this.publicAccess = publicAccess; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java new file mode 100644 index 0000000000000..0590b87d3e397 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java @@ -0,0 +1,10 @@ +package com.microsoft.azure.services.blob; + +import com.microsoft.azure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(BlobContract.class, BlobContractImpl.class); + registry.add(BlobSharedKeyLiteFilter.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java new file mode 100644 index 0000000000000..085a55cbb12f1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java @@ -0,0 +1,56 @@ +package com.microsoft.azure.services.blob; + +import java.util.EnumSet; + +public class ListBlobsOptions { + private String prefix; + private String marker; + private int maxResults; + private String delimiter; + private EnumSet listingDetails = EnumSet.noneOf(BlobListingDetails.class); + + public String getPrefix() { + return prefix; + } + + public ListBlobsOptions setPrefix(String prefix) { + this.prefix = prefix; + return this; + } + + public String getMarker() { + return marker; + } + + public ListBlobsOptions setMarker(String marker) { + this.marker = marker; + return this; + } + + public int getMaxResults() { + return maxResults; + } + + public ListBlobsOptions setMaxResults(int maxResults) { + this.maxResults = maxResults; + return this; + } + + public String getDelimiter() { + return delimiter; + } + + public ListBlobsOptions setDelimiter(String delimiter) { + this.delimiter = delimiter; + return this; + } + + public EnumSet getListingDetails() { + return listingDetails; + } + + public ListBlobsOptions setListingDetails(EnumSet listingDetails) { + this.listingDetails = listingDetails; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java new file mode 100644 index 0000000000000..5cb7f9b0b1e1b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java @@ -0,0 +1,252 @@ +package com.microsoft.azure.services.blob; + +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; + +@XmlRootElement(name = "EnumerationResults") +public class ListBlobsResults { + private List blobs; + private String containerName; + private String prefix; + private String marker; + private String nextMarker; + private String delimiter; + private int maxResults; + + @XmlElementWrapper(name = "Blobs") + @XmlElement(name = "Blob") + public List getBlobs() { + return blobs; + } + + public void setBlobs(List value) { + this.blobs = value; + } + + @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; + } + + @XmlElement(name = "Delimiter") + public String getDelimiter() { + return delimiter; + } + + public void setDelimiter(String delimiter) { + this.delimiter = delimiter; + } + + @XmlAttribute(name = "ContainerName") + public String getContainerName() { + return containerName; + } + + public void setContainerName(String containerName) { + this.containerName = containerName; + } + + public static class Blob { + private String name; + private String url; + private String snapshot; + private HashMap metadata; + private BlobProperties properties; + + @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 = "Properties") + public BlobProperties getProperties() { + return properties; + } + + public void setProperties(BlobProperties properties) { + this.properties = properties; + } + + @XmlElement(name = "Snapshot") + public String getSnapshot() { + return snapshot; + } + + public void setSnapshot(String snapshot) { + this.snapshot = snapshot; + } + + @XmlElement(name = "Metadata") + @XmlJavaTypeAdapter(MetadataAdapter.class) + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } + + public static class BlobProperties { + private String 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") + public String getLastModified() { + return lastModified; + } + + public void setLastModified(String 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/azure/services/blob/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java new file mode 100644 index 0000000000000..cae1af10aff43 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java @@ -0,0 +1,46 @@ +package com.microsoft.azure.services.blob; + +import java.util.EnumSet; + +public class ListContainersOptions { + private String prefix; + private String marker; + private int maxResults; + private EnumSet listingDetails = EnumSet.noneOf(ContainerListingDetails.class); + + public String getPrefix() { + return prefix; + } + + public ListContainersOptions setPrefix(String prefix) { + this.prefix = prefix; + return this; + } + + public String getMarker() { + return marker; + } + + public ListContainersOptions setMarker(String marker) { + this.marker = marker; + return this; + } + + public int getMaxResults() { + return maxResults; + } + + public ListContainersOptions setMaxResults(int maxResults) { + this.maxResults = maxResults; + return this; + } + + public EnumSet getListingDetails() { + return listingDetails; + } + + public ListContainersOptions 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/blob/ListContainersResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java new file mode 100644 index 0000000000000..b98de7b184c92 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java @@ -0,0 +1,142 @@ +package com.microsoft.azure.services.blob; + +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; + +@XmlRootElement(name = "EnumerationResults") +public class ListContainersResults { + private List containers; + private String accountName; + private String prefix; + private String marker; + private String nextMarker; + private int maxResults; + + @XmlElementWrapper(name = "Containers") + @XmlElement(name = "Container") + public List getContainers() { + return containers; + } + + public void setContainers(List value) { + this.containers = 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 Container { + private String name; + private String url; + private HashMap metadata; + private ContainerProperties properties; + + @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 = "Properties") + public ContainerProperties getProperties() { + return properties; + } + + public void setProperties(ContainerProperties properties) { + this.properties = properties; + } + + @XmlElement(name = "Metadata") + @XmlJavaTypeAdapter(MetadataAdapter.class) + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } + + public static class ContainerProperties { + private String LastModified; + private String Etag; + + @XmlElement(name = "Last-Modified") + public String getLastModified() { + return LastModified; + } + + public void setLastModified(String lastModified) { + LastModified = lastModified; + } + + @XmlElement(name = "Etag") + public String getEtag() { + return Etag; + } + + public void setEtag(String etag) { + Etag = etag; + } + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java new file mode 100644 index 0000000000000..28f95bec6b8c7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java @@ -0,0 +1,29 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +import javax.naming.OperationNotSupportedException; +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import org.w3c.dom.Element; + +/* + * JAXB adapter for element + */ +public class MetadataAdapter extends XmlAdapter> { + + @Override + public HashMap unmarshal(MetadataHashMapType arg0) throws Exception { + HashMap result = new HashMap(); + for (Element entry : arg0.entries) { + result.put(entry.getLocalName(), entry.getFirstChild().getNodeValue()); + } + return result; + } + + @Override + public MetadataHashMapType marshal(HashMap arg0) throws Exception { + // We don't need marshaling for blob/container metadata + throw new OperationNotSupportedException(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java new file mode 100644 index 0000000000000..92af5e3f69c4c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java @@ -0,0 +1,13 @@ +package com.microsoft.azure.services.blob; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAnyElement; + +import org.w3c.dom.Element; + +public class MetadataHashMapType { + @XmlAnyElement + public List entries = new ArrayList(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java new file mode 100644 index 0000000000000..901f8e0591d58 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java @@ -0,0 +1,178 @@ +package com.microsoft.azure.utils; + +/** + * TODO: Use a common library instead + * + * Provides Base64 encoding, decoding, and validation functionality. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class Base64 { + private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + /** + * Decoded values, -1 is invalid character, -2 is = pad character. + */ + private static final byte decode64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* + * 16- 31 + */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* + * 32- 47 + */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, /* + * 48- 63 + */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 64-79 */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* + * 80- 95 + */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* + * 96- 111 + */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* + * 112- 127 + */ + }; + + /** + * Decodes a given Base64 string into its corresponding byte array. + * + * @param data + * the Base64 string, as a String object, to decode + * + * @return the corresponding decoded byte array + * @throws IllegalArgumentException + * If the string is not a valid base64 encoded string + */ + public static byte[] decode(String data) throws IllegalArgumentException { + int byteArrayLength = 3 * data.length() / 4; + + if (data.endsWith("==")) { + byteArrayLength -= 2; + } else if (data.endsWith("=")) { + byteArrayLength -= 1; + } + + byte[] retArray = new byte[byteArrayLength]; + int byteDex = 0; + int charDex = 0; + + for (; charDex < data.length(); charDex += 4) { + // get 4 chars, convert to 3 bytes + int char1 = decode64[(byte) data.charAt(charDex)]; + int char2 = decode64[(byte) data.charAt(charDex + 1)]; + int char3 = decode64[(byte) data.charAt(charDex + 2)]; + int char4 = decode64[(byte) data.charAt(charDex + 3)]; + + if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { + // invalid character(-1), or bad padding (-2) + throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); + } + + int tVal = char1 << 18; + tVal += char2 << 12; + tVal += (char3 & 0xff) << 6; + tVal += char4 & 0xff; + + if (char3 == -2) { + // two "==" pad chars, check bits 12-24 + tVal &= 0x00FFF000; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + } else if (char4 == -2) { + // one pad char "=" , check bits 6-24. + tVal &= 0x00FFFFC0; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + + } else { + // No pads take all 3 bytes, bits 0-24 + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + retArray[byteDex++] = (byte) (tVal & 0xFF); + } + } + return retArray; + } + + /** + * Encodes a byte array as a Base64 string. + * + * @param data + * the byte array to encode + * @return the Base64-encoded string, as a String object + */ + public static String encode(byte[] data) { + StringBuilder builder = new StringBuilder(); + int dataRemainder = data.length % 3; + + int j = 0; + int n = 0; + for (; j < data.length; j += 3) { + + if (j < data.length - dataRemainder) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); + } else { + if (dataRemainder == 1) { + n = (data[j] & 0xFF) << 16; + } else if (dataRemainder == 2) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); + } + } + + // Left here for readability + // byte char1 = (byte) ((n >>> 18) & 0x3F); + // byte char2 = (byte) ((n >>> 12) & 0x3F); + // byte char3 = (byte) ((n >>> 6) & 0x3F); + // byte char4 = (byte) (n & 0x3F); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); + } + + int bLength = builder.length(); + + // append '=' to pad + if (data.length % 3 == 1) { + builder.replace(bLength - 2, bLength, "=="); + } else if (data.length % 3 == 2) { + builder.replace(bLength - 1, bLength, "="); + } + + return builder.toString(); + } + + /** + * Determines whether the given string contains only Base64 characters. + * + * @param data + * the string, as a String object, to validate + * @return true if data is a valid Base64 string, otherwise false + */ + public static Boolean validateIsBase64String(String data) { + + if (data == null || data.length() % 4 != 0) { + return false; + } + + for (int m = 0; m < data.length(); m++) { + byte charByte = (byte) data.charAt(m); + + // pad char detected + if (decode64[charByte] == -2) { + if (m < data.length() - 2) { + return false; + } else if (m == data.length() - 2 && decode64[(byte) data.charAt(m + 1)] != -2) { + return false; + } + } + + if (charByte < 0 || decode64[charByte] == -1) { + return false; + } + } + + return true; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java new file mode 100644 index 0000000000000..61fc2d32b9191 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java @@ -0,0 +1,27 @@ +package com.microsoft.azure.utils; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +public class HmacSHA256Sign { + private final String accessKey; + + public HmacSHA256Sign(String accessKey) { + this.accessKey = accessKey; + } + + public String sign(String stringToSign) { + try { + // Encoding the Signature + // Signature=Base64(HMAC-SHA256(UTF8(StringToSign))) + + Mac hmac = Mac.getInstance("hmacSHA256"); + hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); + byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); + return Base64.encode(digest); + } + catch (Exception e) { + throw new IllegalArgumentException("accessKey", e); + } + } +} diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports index fd0961993d35b..d10d0c6df32bd 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports @@ -1,4 +1,5 @@ com.microsoft.azure.auth.wrap.Exports com.microsoft.azure.configuration.jersey.Exports +com.microsoft.azure.services.blob.Exports com.microsoft.azure.services.serviceBus.Exports com.microsoft.azure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java new file mode 100644 index 0000000000000..8e78a8d5956f4 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java @@ -0,0 +1,178 @@ +package com.microsoft.azure.services.blob; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.EnumSet; + +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.blob.BlobContract; +import com.microsoft.azure.services.blob.ContainerListingDetails; +import com.microsoft.azure.services.blob.ContainerProperties; +import com.microsoft.azure.services.blob.CreateContainerOptions; +import com.microsoft.azure.services.blob.ListBlobsOptions; +import com.microsoft.azure.services.blob.ListBlobsResults; +import com.microsoft.azure.services.blob.ListContainersOptions; +import com.microsoft.azure.services.blob.ListContainersResults; + +public class BlobContractIntegrationTest extends IntegrationTestBase { + + @Test + public void createContainerWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + contract.createContainer("foo"); + contract.deleteContainer("foo"); + + // Assert + } + + @Test + public void createContainerWithMetadataWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + contract.createContainer("foo2", new CreateContainerOptions() + .setPublicAccess("blob").addMetadata("test", "bar") + .addMetadata("blah", "bleah")); + + ContainerProperties prop = contract.getContainerMetadata("foo2"); + ContainerProperties prop2 = contract.getContainerProperties("foo2"); + + ListContainersResults results2 = contract + .listContainers(new ListContainersOptions().setPrefix("foo2") + .setListingDetails( + EnumSet.of(ContainerListingDetails.METADATA))); + + contract.deleteContainer("foo2"); + + // Assert + assertNotNull(prop); + assertNotNull(prop.getEtag()); + assertNotNull(prop.getLastModified()); + assertNotNull(prop.getMetadata()); + assertEquals(2, prop.getMetadata().size()); + assertTrue(prop.getMetadata().containsKey("test")); + assertTrue(prop.getMetadata().containsValue("bar")); + assertTrue(prop.getMetadata().containsKey("blah")); + assertTrue(prop.getMetadata().containsValue("bleah")); + + assertNotNull(prop2); + assertNotNull(prop2.getEtag()); + assertNotNull(prop2.getLastModified()); + assertNotNull(prop2.getMetadata()); + assertEquals(2, prop2.getMetadata().size()); + assertTrue(prop2.getMetadata().containsKey("test")); + assertTrue(prop2.getMetadata().containsValue("bar")); + assertTrue(prop2.getMetadata().containsKey("blah")); + assertTrue(prop2.getMetadata().containsValue("bleah")); + + assertNotNull(results2); + assertEquals(1, results2.getContainers().size()); + assertTrue(results2.getContainers().get(0).getMetadata() + .containsKey("test")); + assertTrue(results2.getContainers().get(0).getMetadata() + .containsValue("bar")); + assertTrue(results2.getContainers().get(0).getMetadata() + .containsKey("blah")); + assertTrue(results2.getContainers().get(0).getMetadata() + .containsValue("bleah")); + } + + @Test + public void listContainersWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + ListContainersResults results = contract.listContainers(); + + // Assert + assertNotNull(results); + assertEquals(8, results.getContainers().size()); + } + + @Test + public void listContainersWithPaginationWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + ListContainersResults results = contract + .listContainers(new ListContainersOptions().setMaxResults(3)); + + // Assert + assertNotNull(results); + assertEquals(3, results.getContainers().size()); + assertNotNull(results.getNextMarker()); + assertEquals(3, results.getMaxResults()); + + // Act + ListContainersResults results2 = contract + .listContainers(new ListContainersOptions().setMarker(results + .getNextMarker())); + + // Assert + assertNotNull(results2); + assertEquals(5, results2.getContainers().size()); + assertEquals("", results2.getNextMarker()); + assertEquals(0, results2.getMaxResults()); + } + + @Test + public void listContainersWithPrefixWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + ListContainersResults results = contract + .listContainers(new ListContainersOptions() + .setPrefix("mycontainer1")); + + // Assert + assertNotNull(results); + assertEquals(3, results.getContainers().size()); + assertNotNull(results.getNextMarker()); + assertEquals(0, results.getMaxResults()); + } + + @Test + public void listBlobsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + ListBlobsResults results = contract.listBlobs("mycontainer11"); + + // Assert + assertNotNull(results); + assertEquals(3, results.getBlobs().size()); + } + + @Test + public void listBlobsWithPrefixWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract contract = config.create(BlobContract.class); + + // Act + ListBlobsResults results = contract.listBlobs("mycontainer11", + new ListBlobsOptions().setPrefix("Create")); + + // Assert + assertNotNull(results); + assertEquals(2, results.getBlobs().size()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java new file mode 100644 index 0000000000000..af6ade4af93c7 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -0,0 +1,38 @@ +package com.microsoft.azure.services.blob; + +import org.junit.Before; +import org.junit.BeforeClass; + +import com.microsoft.azure.configuration.Configuration; + +public abstract class IntegrationTestBase { + protected Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty(BlobConfig.CONFIG_ACCOUNT_NAME, "xxx"); + config.setProperty(BlobConfig.CONFIG_ACCOUNT_KEY, "xxx"); + config.setProperty(BlobConfig.CONFIG_URL, "http://azuresdkdev.blob.core.windows.net"); + + // when mock running + // config.setProperty("serviceBus.uri", "http://localhost:8086"); + // config.setProperty("wrapClient.uri", + // "http://localhost:8081/WRAPv0.9"); + + return config; + } + + @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"); + } +} From 95e699ca5e7740d6e3b9894458874300d65f245f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 2 Nov 2011 17:31:14 -0700 Subject: [PATCH 051/664] Rename classes to match guidelines --- .../{BlobContract.java => BlobService.java} | 2 +- ...ContractImpl.java => BlobServiceImpl.java} | 4 +- .../azure/services/blob/Exports.java | 2 +- ...t.java => BlobServiceIntegrationTest.java} | 60 ++++++------------- 4 files changed, 23 insertions(+), 45 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{BlobContract.java => BlobService.java} (94%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{BlobContractImpl.java => BlobServiceImpl.java} (97%) rename microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/{BlobContractIntegrationTest.java => BlobServiceIntegrationTest.java} (67%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 4e30cc1136f65..a6f22bd1d5669 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public interface BlobContract { +public interface BlobService { ListContainersResults listContainers(); ListContainersResults listContainers(ListContainersOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 533e863c67586..85ae80e9273ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -12,7 +12,7 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; -public class BlobContractImpl implements BlobContract { +public class BlobServiceImpl implements BlobService { private static final String X_MS_VERSION = "x-ms-version"; private static final String X_MS_BLOB_PUBLIC_ACCESS = "x-ms-blob-public-access"; @@ -23,7 +23,7 @@ public class BlobContractImpl implements BlobContract { private final String url; @Inject - public BlobContractImpl(Client channel, @Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_URL) String url, + public BlobServiceImpl(Client channel, @Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_URL) String url, // TODO: How to make this configurable though code? BlobSharedKeyLiteFilter filter) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java index 0590b87d3e397..814f206f0ab2a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java @@ -4,7 +4,7 @@ public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(BlobContract.class, BlobContractImpl.class); + registry.add(BlobService.class, BlobServiceImpl.class); registry.add(BlobSharedKeyLiteFilter.class); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java similarity index 67% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 8e78a8d5956f4..0577ecf6efbd9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -9,22 +9,14 @@ import org.junit.Test; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.blob.BlobContract; -import com.microsoft.azure.services.blob.ContainerListingDetails; -import com.microsoft.azure.services.blob.ContainerProperties; -import com.microsoft.azure.services.blob.CreateContainerOptions; -import com.microsoft.azure.services.blob.ListBlobsOptions; -import com.microsoft.azure.services.blob.ListBlobsResults; -import com.microsoft.azure.services.blob.ListContainersOptions; -import com.microsoft.azure.services.blob.ListContainersResults; -public class BlobContractIntegrationTest extends IntegrationTestBase { +public class BlobServiceIntegrationTest extends IntegrationTestBase { @Test public void createContainerWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act contract.createContainer("foo"); @@ -37,20 +29,16 @@ public void createContainerWorks() throws Exception { public void createContainerWithMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act - contract.createContainer("foo2", new CreateContainerOptions() - .setPublicAccess("blob").addMetadata("test", "bar") - .addMetadata("blah", "bleah")); + contract.createContainer("foo2", new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); ContainerProperties prop = contract.getContainerMetadata("foo2"); ContainerProperties prop2 = contract.getContainerProperties("foo2"); - ListContainersResults results2 = contract - .listContainers(new ListContainersOptions().setPrefix("foo2") - .setListingDetails( - EnumSet.of(ContainerListingDetails.METADATA))); + ListContainersResults results2 = contract.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( + EnumSet.of(ContainerListingDetails.METADATA))); contract.deleteContainer("foo2"); @@ -77,21 +65,17 @@ public void createContainerWithMetadataWorks() throws Exception { assertNotNull(results2); assertEquals(1, results2.getContainers().size()); - assertTrue(results2.getContainers().get(0).getMetadata() - .containsKey("test")); - assertTrue(results2.getContainers().get(0).getMetadata() - .containsValue("bar")); - assertTrue(results2.getContainers().get(0).getMetadata() - .containsKey("blah")); - assertTrue(results2.getContainers().get(0).getMetadata() - .containsValue("bleah")); + assertTrue(results2.getContainers().get(0).getMetadata().containsKey("test")); + assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bar")); + assertTrue(results2.getContainers().get(0).getMetadata().containsKey("blah")); + assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bleah")); } @Test public void listContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act ListContainersResults results = contract.listContainers(); @@ -105,11 +89,10 @@ public void listContainersWorks() throws Exception { public void listContainersWithPaginationWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act - ListContainersResults results = contract - .listContainers(new ListContainersOptions().setMaxResults(3)); + ListContainersResults results = contract.listContainers(new ListContainersOptions().setMaxResults(3)); // Assert assertNotNull(results); @@ -118,9 +101,7 @@ public void listContainersWithPaginationWorks() throws Exception { assertEquals(3, results.getMaxResults()); // Act - ListContainersResults results2 = contract - .listContainers(new ListContainersOptions().setMarker(results - .getNextMarker())); + ListContainersResults results2 = contract.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); // Assert assertNotNull(results2); @@ -133,12 +114,10 @@ public void listContainersWithPaginationWorks() throws Exception { public void listContainersWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act - ListContainersResults results = contract - .listContainers(new ListContainersOptions() - .setPrefix("mycontainer1")); + ListContainersResults results = contract.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); // Assert assertNotNull(results); @@ -151,7 +130,7 @@ public void listContainersWithPrefixWorks() throws Exception { public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act ListBlobsResults results = contract.listBlobs("mycontainer11"); @@ -165,11 +144,10 @@ public void listBlobsWorks() throws Exception { public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract contract = config.create(BlobContract.class); + BlobService contract = config.create(BlobService.class); // Act - ListBlobsResults results = contract.listBlobs("mycontainer11", - new ListBlobsOptions().setPrefix("Create")); + ListBlobsResults results = contract.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); // Assert assertNotNull(results); From 5a82510e314d3180a76c0ef5f6ccbebb348e7f7d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 2 Nov 2011 17:35:06 -0700 Subject: [PATCH 052/664] Moving Iterable to Util method Keeps the XxxService interface a pure service representation --- .../azure/services/serviceBus/ServiceBusService.java | 1 - .../services/serviceBus/ServiceBusServiceImpl.java | 4 ---- .../com/microsoft/azure/services/serviceBus/Util.java | 11 +++++++++++ .../services/serviceBus/IntegrationTestBase.java | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index ecc1a75495db6..b8f6632bff0b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -17,7 +17,6 @@ public interface ServiceBusService { void deleteQueue(String queuePath) throws ServiceException; Queue getQueue(String queuePath) throws ServiceException; QueueList getQueueList() throws ServiceException; - Iterable iterateQueues() throws ServiceException; Entry createTopic(Entry topic) throws ServiceException; void deleteTopic(String topicPath) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java index 3d8453d3a5e11..685012e6c3b9f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java @@ -183,10 +183,6 @@ public Queue getQueue(String queuePath) throws ServiceException { } } - public Iterable iterateQueues() throws ServiceException { - //TODO: iterate over link rel=next pagination - return getQueueList().getQueues(); - } public QueueList getQueueList() throws ServiceException { try { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java new file mode 100644 index 0000000000000..d2ed0fb88d2da --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java @@ -0,0 +1,11 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.ServiceException; + +public class Util { + public static Iterable iterateQueues(ServiceBusService service) + throws ServiceException { + //TODO: iterate over link rel=next pagination + return service.getQueueList().getQueues(); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 039658054674f..542609bc08280 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -8,7 +8,7 @@ import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.client.ReceiveMessageOptions; +import static com.microsoft.azure.services.serviceBus.Util.*; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { @@ -43,7 +43,7 @@ public void initialize() throws Exception { boolean testAlphaExists = false; ServiceBusService service = createConfiguration().create(ServiceBusService.class); - for(Queue queue : service.iterateQueues()) { + for(Queue queue : iterateQueues(service)) { String queueName = queue.getName(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { if (queueName.equalsIgnoreCase("TestAlpha")) { From b8676aebfb384dd95a20a6937a4c402271ad6e8d Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 2 Nov 2011 18:26:41 -0700 Subject: [PATCH 053/664] Map strings to java.util.Date instances --- .../blob/BlobSharedKeyLiteFilter.java | 8 +--- .../services/blob/ContainerProperties.java | 8 ++-- .../azure/services/blob/DateAdapter.java | 21 +++++++++++ .../azure/services/blob/DateMapper.java | 26 +++++++++++++ .../azure/services/blob/ListBlobsResults.java | 10 +++-- .../services/blob/ListContainersResults.java | 20 +++++----- .../azure/services/blob/MetadataAdapter.java | 2 +- .../services/blob/MetadataHashMapType.java | 10 ++++- .../blob/BlobServiceIntegrationTest.java | 37 +++++++++++++++++++ 9 files changed, 116 insertions(+), 26 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index 5208ae580c687..5c694ea4b9bb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -1,13 +1,10 @@ package com.microsoft.azure.services.blob; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.TimeZone; import javax.inject.Named; @@ -36,7 +33,6 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { return this.getNext().handle(cr); } - private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; private String nullEmpty(String value) { return value != null ? value : ""; @@ -54,9 +50,7 @@ private void sign(ClientRequest cr) { String date = getHeader(cr, "Date"); if (date == "") { - DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); - rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); - date = rfc1123Format.format(new Date()); + date = new DateMapper().format(new Date()); cr.getHeaders().add("Date", date); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java index 7767da5a17208..c3226a8b34b39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java @@ -1,11 +1,11 @@ package com.microsoft.azure.services.blob; +import java.util.Date; import java.util.HashMap; public class ContainerProperties { private String etag; - // TODO: Should this be a Date? - private String lastModified; + private Date lastModified; private HashMap metadata; public String getEtag() { @@ -16,11 +16,11 @@ public void setEtag(String etag) { this.etag = etag; } - public String getLastModified() { + public Date getLastModified() { return lastModified; } - public void setLastModified(String lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java new file mode 100644 index 0000000000000..e5e493fd7752e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java @@ -0,0 +1,21 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/* + * JAXB adapter for element + */ +public class DateAdapter extends XmlAdapter { + + @Override + public Date unmarshal(String arg0) throws Exception { + return new DateMapper().parse(arg0); + } + + @Override + public String marshal(Date arg0) throws Exception { + return new DateMapper().format(arg0); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java new file mode 100644 index 0000000000000..4b712375ff76f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java @@ -0,0 +1,26 @@ +package com.microsoft.azure.services.blob; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +public class DateMapper { + private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; + + public String format(Date date) { + return getFormat().format(date); + } + + public Date parse(String date) throws ParseException { + return getFormat().parse(date); + } + + private DateFormat getFormat() { + DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); + rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); + return rfc1123Format; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java index 5cb7f9b0b1e1b..584c871abd7ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.blob; +import java.util.Date; import java.util.HashMap; import java.util.List; @@ -87,7 +88,7 @@ public static class Blob { private String name; private String url; private String snapshot; - private HashMap metadata; + private HashMap metadata = new HashMap(); private BlobProperties properties; @XmlElement(name = "Name") @@ -137,7 +138,7 @@ public void setMetadata(HashMap metadata) { } public static class BlobProperties { - private String lastModified; + private Date lastModified; private String etag; private String contentType; private String contentLength; @@ -150,11 +151,12 @@ public static class BlobProperties { private String sequenceNUmber; @XmlElement(name = "Last-Modified") - public String getLastModified() { + @XmlJavaTypeAdapter(DateAdapter.class) + public Date getLastModified() { return lastModified; } - public void setLastModified(String lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java index b98de7b184c92..501406a1cb754 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.blob; +import java.util.Date; import java.util.HashMap; import java.util.List; @@ -76,7 +77,7 @@ public void setMaxResults(int maxResults) { public static class Container { private String name; private String url; - private HashMap metadata; + private HashMap metadata = new HashMap(); private ContainerProperties properties; @XmlElement(name = "Name") @@ -117,25 +118,26 @@ public void setMetadata(HashMap metadata) { } public static class ContainerProperties { - private String LastModified; - private String Etag; + private Date lastModified; + private String etag; @XmlElement(name = "Last-Modified") - public String getLastModified() { - return LastModified; + @XmlJavaTypeAdapter(DateAdapter.class) + public Date getLastModified() { + return lastModified; } - public void setLastModified(String lastModified) { - LastModified = lastModified; + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; } @XmlElement(name = "Etag") public String getEtag() { - return Etag; + return etag; } public void setEtag(String etag) { - Etag = etag; + this.etag = etag; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java index 28f95bec6b8c7..a23475f2f319c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java @@ -15,7 +15,7 @@ public class MetadataAdapter extends XmlAdapter unmarshal(MetadataHashMapType arg0) throws Exception { HashMap result = new HashMap(); - for (Element entry : arg0.entries) { + for (Element entry : arg0.getEntries()) { result.put(entry.getLocalName(), entry.getFirstChild().getNodeValue()); } return result; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java index 92af5e3f69c4c..0f3e006e1260e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java @@ -8,6 +8,14 @@ import org.w3c.dom.Element; public class MetadataHashMapType { + private List entries = new ArrayList(); + @XmlAnyElement - public List entries = new ArrayList(); + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 0577ecf6efbd9..192f8b2b077db 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue; import java.util.EnumSet; +import java.util.HashMap; import org.junit.Test; @@ -71,6 +72,36 @@ public void createContainerWithMetadataWorks() throws Exception { assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bleah")); } + @Test + public void setContainerMetadataWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.createContainer("foo3"); + + HashMap metadata = new HashMap(); + metadata.put("test", "bar"); + metadata.put("blah", "bleah"); + contract.setContainerMetadata("foo3", metadata); + ContainerProperties prop = contract.getContainerMetadata("foo3"); + + contract.deleteContainer("foo3"); + + // Assert + assertNotNull(prop); + assertNotNull(prop.getEtag()); + assertNotNull(prop.getLastModified()); + assertNotNull(prop.getMetadata()); + assertEquals(2, prop.getMetadata().size()); + assertTrue(prop.getMetadata().containsKey("test")); + assertTrue(prop.getMetadata().containsValue("bar")); + assertTrue(prop.getMetadata().containsKey("blah")); + assertTrue(prop.getMetadata().containsValue("bleah")); + } + + @Test public void listContainersWorks() throws Exception { // Arrange @@ -83,6 +114,12 @@ public void listContainersWorks() throws Exception { // Assert assertNotNull(results); assertEquals(8, results.getContainers().size()); + assertNotNull(results.getContainers().get(0).getName()); + assertNotNull(results.getContainers().get(0).getMetadata()); + assertNotNull(results.getContainers().get(0).getProperties()); + assertNotNull(results.getContainers().get(0).getProperties().getEtag()); + assertNotNull(results.getContainers().get(0).getProperties().getLastModified()); + assertNotNull(results.getContainers().get(0).getUrl()); } @Test From a98c4362fafd5c1244767f8ce92e157543cd3f4a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 2 Nov 2011 18:27:13 -0700 Subject: [PATCH 054/664] Implement "setContainerMetadata" entry point --- .../azure/services/blob/BlobService.java | 4 +++ .../azure/services/blob/BlobServiceImpl.java | 33 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index a6f22bd1d5669..bd156760cfa26 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -1,5 +1,7 @@ package com.microsoft.azure.services.blob; +import java.util.HashMap; + public interface BlobService { ListContainersResults listContainers(); @@ -15,6 +17,8 @@ public interface BlobService { ContainerProperties getContainerMetadata(String container); + void setContainerMetadata(String container, HashMap metadata); + ListBlobsResults listBlobs(String container); ListBlobsResults listBlobs(String container, ListBlobsOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 85ae80e9273ac..d1c5be9810e92 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.blob; +import java.text.ParseException; import java.util.EnumSet; import java.util.HashMap; import java.util.List; @@ -125,7 +126,13 @@ private ContainerProperties getContainerPropertiesImpl(String container, String ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(response.getHeaders().getFirst("Last-Modified")); + try { + properties.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); + } + catch (ParseException e) { + // Server returned an invalid/unsupported date format + throw new IllegalArgumentException(e); + } // Metadata HashMap metadata = new HashMap(); for (Entry> entry : response.getHeaders().entrySet()) { @@ -139,6 +146,30 @@ private ContainerProperties getContainerPropertiesImpl(String container, String return properties; } + public void setContainerMetadata(String container, HashMap metadata) { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); + + webResource = setCanonicalizedResource(webResource, container, "metadata"); + + WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + // Metadata + for (Entry entry : metadata.entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + builder + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + .header("Content-Type", "text/plain").put(""); + } + + public ListContainersResults listContainers() { return listContainers(new ListContainersOptions()); } From 677707d30b44fc7829e6da674b2de2d3abc29f9a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 2 Nov 2011 22:52:52 -0700 Subject: [PATCH 055/664] Add support for get/setContainerACL --- .../azure/services/blob/BlobService.java | 4 + .../azure/services/blob/BlobServiceImpl.java | 67 +++++++-- .../azure/services/blob/ContainerACL.java | 130 ++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 35 +++++ 4 files changed, 223 insertions(+), 13 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index bd156760cfa26..fb35e8d518dea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -17,6 +17,10 @@ public interface BlobService { ContainerProperties getContainerMetadata(String container); + ContainerACL getContainerACL(String container); + + void setContainerACL(String container, ContainerACL acl); + void setContainerMetadata(String container, HashMap metadata); ListBlobsResults listBlobs(String container); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index d1c5be9810e92..501cd8bce2736 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -12,6 +12,7 @@ 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; public class BlobServiceImpl implements BlobService { @@ -34,20 +35,27 @@ public BlobServiceImpl(Client channel, @Named(BlobConfig.CONFIG_ACCOUNT_NAME) St channel.addFilter(filter); } - private WebResource optionalQueryParam(WebResource wr, String key, String value) { + private WebResource addOptionalQueryParam(WebResource wr, String key, String value) { if (value != null) { wr = wr.queryParam(key, value); } return wr; } - private WebResource optionalQueryParam(WebResource wr, String key, int value, int defaultValue) { + private WebResource addOptionalQueryParam(WebResource wr, String key, int value, int defaultValue) { if (value != defaultValue) { wr = wr.queryParam(key, Integer.toString(value)); } return wr; } + private Builder addOptionalHeader(Builder builder, String name, String value) { + if (value != null) { + builder = builder.header(name, value); + } + return builder; + } + private WebResource getResource() { WebResource res = channel.resource(url).path("/"); @@ -89,7 +97,6 @@ public void createContainer(String container, CreateContainerOptions options) { builder = builder.header(X_MS_BLOB_PUBLIC_ACCESS, options.getPublicAccess()); } - builder // TODO: We need the following 2 to make sure that "Content-Length:0" // header // is sent to the server (IIS doesn't accept PUT without a content @@ -97,7 +104,7 @@ public void createContainer(String container, CreateContainerOptions options) { // Since we are sending a "dummy" string, we also need to set the // "Content-Type" header so that the hmac filter will see it when // producing the authorization hmac. - .header("Content-Type", "text/plain").put(""); + builder.header("Content-Type", "text/plain").put(""); } public void deleteContainer(String container) { @@ -146,6 +153,41 @@ private ContainerProperties getContainerPropertiesImpl(String container, String return properties; } + public ContainerACL getContainerACL(String container) { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + webResource = setCanonicalizedResource(webResource, container, "acl"); + + ClientResponse response = webResource.header(X_MS_VERSION, API_VERSION).get(ClientResponse.class); + + ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); + ContainerACL acl = new ContainerACL(); + acl.setSignedIdentifiers(si.getSignedIdentifiers()); + acl.setPublicAccess(response.getHeaders().getFirst(X_MS_BLOB_PUBLIC_ACCESS)); + acl.setEtag(response.getHeaders().getFirst("ETag")); + try { + acl.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); + } + catch (ParseException e) { + //TODO: Is this the right way to handle this? + throw new IllegalArgumentException(e); + } + return acl; + } + + public void setContainerACL(String container, ContainerACL acl) { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + webResource = setCanonicalizedResource(webResource, container, "acl"); + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + //Note: Add content type here to enable proper HMAC signing + //builder = builder.header("Content-Type", "application/xml"); + builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, acl.getPublicAccess()); + + ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); + si.setSignedIdentifiers(acl.getSignedIdentifiers()); + builder.type("application/xml").put(si); + } + public void setContainerMetadata(String container, HashMap metadata) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); @@ -158,7 +200,6 @@ public void setContainerMetadata(String container, HashMap metad builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); } - builder // TODO: We need the following 2 to make sure that "Content-Length:0" // header // is sent to the server (IIS doesn't accept PUT without a content @@ -166,7 +207,7 @@ public void setContainerMetadata(String container, HashMap metad // Since we are sending a "dummy" string, we also need to set the // "Content-Type" header so that the hmac filter will see it when // producing the authorization hmac. - .header("Content-Type", "text/plain").put(""); + builder.header("Content-Type", "text/plain").put(""); } @@ -178,9 +219,9 @@ public ListContainersResults listContainers(ListContainersOptions options) { WebResource webResource = getResource().path("/").queryParam("comp", "list"); webResource = setCanonicalizedResource(webResource, null, "list"); - webResource = optionalQueryParam(webResource, "prefix", options.getPrefix()); - webResource = optionalQueryParam(webResource, "marker", options.getMarker()); - webResource = optionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + 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)) { webResource = webResource.queryParam("include", "metadata"); } @@ -214,9 +255,9 @@ public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, "list"); - webResource = optionalQueryParam(webResource, "prefix", options.getPrefix()); - webResource = optionalQueryParam(webResource, "marker", options.getMarker()); - webResource = optionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + 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(); @@ -225,7 +266,7 @@ public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { sb.addValue(options.getListingDetails(), BlobListingDetails.UNCOMMITTED_BLOBS, "uncommittedblobs"); sb.addValue(options.getListingDetails(), BlobListingDetails.METADATA, "metadata"); - webResource = optionalQueryParam(webResource, "include", sb.toString()); + webResource = addOptionalQueryParam(webResource, "include", sb.toString()); } return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResults.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java new file mode 100644 index 0000000000000..ddbf4cf95beac --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -0,0 +1,130 @@ +package com.microsoft.azure.services.blob; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +public class ContainerACL { + private String etag; + private Date lastModified; + private String publicAccess; + private List signedIdentifiers = new ArrayList(); + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + public String getPublicAccess() { + return publicAccess; + } + + public void setPublicAccess(String publicAccess) { + this.publicAccess = publicAccess; + } + + public List getSignedIdentifiers() { + return signedIdentifiers; + } + + public void setSignedIdentifiers(List signedIdentifiers) { + this.signedIdentifiers = signedIdentifiers; + } + + public void AddSignedIdentifier(String id, String start, String expiry, String permission) { + AccessPolicy accessPolicy = new AccessPolicy(); + accessPolicy.setStart(start); + accessPolicy.setExpiry(expiry); + accessPolicy.setPermission(permission); + + SignedIdentifier signedIdentifier = new SignedIdentifier(); + signedIdentifier.setId(id); + signedIdentifier.setAccessPolicy(accessPolicy); + + this.getSignedIdentifiers().add(signedIdentifier); + } + + @XmlRootElement(name = "SignedIdentifiers") + public static class SignedIdentifiers { + private List signedIdentifiers = new ArrayList(); + + @XmlElement(name = "SignedIdentifier") + public List getSignedIdentifiers() { + return signedIdentifiers; + } + + public void setSignedIdentifiers(List signedIdentifiers) { + this.signedIdentifiers = signedIdentifiers; + } + } + + public static class SignedIdentifier { + private String id; + private AccessPolicy accessPolicy; + + @XmlElement(name = "Id") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @XmlElement(name = "AccessPolicy") + public AccessPolicy getAccessPolicy() { + return accessPolicy; + } + + public void setAccessPolicy(AccessPolicy accessPolicy) { + this.accessPolicy = accessPolicy; + } + } + + public static class AccessPolicy { + private String start; + private String expiry; + private String permission; + + @XmlElement(name = "Start") + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + @XmlElement(name = "Expiry") + public String getExpiry() { + return expiry; + } + + public void setExpiry(String expiry) { + this.expiry = expiry; + } + + @XmlElement(name = "Permission") + public String getPermission() { + return permission; + } + + public void setPermission(String permission) { + this.permission = permission; + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 192f8b2b077db..95045e166d71c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -37,6 +37,7 @@ public void createContainerWithMetadataWorks() throws Exception { ContainerProperties prop = contract.getContainerMetadata("foo2"); ContainerProperties prop2 = contract.getContainerProperties("foo2"); + ContainerACL acl = contract.getContainerACL("foo2"); ListContainersResults results2 = contract.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( EnumSet.of(ContainerListingDetails.METADATA))); @@ -70,6 +71,9 @@ public void createContainerWithMetadataWorks() throws Exception { assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bar")); assertTrue(results2.getContainers().get(0).getMetadata().containsKey("blah")); assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bleah")); + + assertNotNull(acl); + } @Test @@ -101,6 +105,37 @@ public void setContainerMetadataWorks() throws Exception { assertTrue(prop.getMetadata().containsValue("bleah")); } + @Test + public void setContainerACLWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.createContainer("foo4"); + + + ContainerACL acl = new ContainerACL(); + acl.setPublicAccess("blob"); + acl.AddSignedIdentifier("test", "2010-01-01", "2020-01-01", "rwd"); + contract.setContainerACL("foo4", acl); + + ContainerACL acl2 = contract.getContainerACL("foo4"); + contract.deleteContainer("foo4"); + + // Assert + assertNotNull(acl2); + assertNotNull(acl2.getEtag()); + assertNotNull(acl2.getLastModified()); + assertNotNull(acl2.getPublicAccess()); + assertEquals("blob", acl2.getPublicAccess()); + assertEquals(1, acl2.getSignedIdentifiers().size()); + assertEquals("test", acl2.getSignedIdentifiers().get(0).getId()); + assertEquals("2010-01-01T00:00:00.0000000Z", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getStart()); + assertEquals("2020-01-01T00:00:00.0000000Z", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getExpiry()); + assertEquals("rwd", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getPermission()); + } + @Test public void listContainersWorks() throws Exception { From 758883c1ef35c369a3d270fbbef5ccdc4ebd4544 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 11:34:21 -0700 Subject: [PATCH 056/664] Moving classes that don't need to be used directly --- .../azure/services/serviceBus/Exports.java | 4 ++ .../azure/services/serviceBus/Message.java | 6 +-- .../azure/services/serviceBus/Queue.java | 47 ++++++++++--------- .../azure/services/serviceBus/QueueList.java | 2 +- .../BrokerProperties.java | 2 +- .../BrokerPropertiesMapper.java | 3 +- .../{ => implementation}/EntryModel.java | 2 +- .../EntryModelProvider.java | 3 +- .../MarshallerProvider.java | 3 +- .../NamespacePrefixMapperImpl.java | 2 +- .../ServiceBusServiceImpl.java | 8 +++- .../BrokerPropertiesMapperTest.java | 4 +- .../serviceBus/ContractBuilderTest.java | 1 + 13 files changed, 49 insertions(+), 38 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{schema => implementation}/BrokerProperties.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/BrokerPropertiesMapper.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/EntryModel.java (86%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/EntryModelProvider.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/MarshallerProvider.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/NamespacePrefixMapperImpl.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{ => implementation}/ServiceBusServiceImpl.java (91%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 0d4df21346394..8347887877822 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -4,6 +4,10 @@ import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.services.serviceBus.client.MessagingClient; +import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; +import com.microsoft.azure.services.serviceBus.implementation.EntryModelProvider; +import com.microsoft.azure.services.serviceBus.implementation.MarshallerProvider; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceImpl; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index e9ed9d54a0b85..2e4a0ef6f4509 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -3,7 +3,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; +import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; public class Message { BrokerProperties properties; @@ -36,14 +36,14 @@ public Message(String body) { /** * @return the brokerProperties */ - BrokerProperties getProperties() { + public BrokerProperties getProperties() { return properties; } /** * @param properties the brokerProperties to set */ - void setProperties(BrokerProperties properties) { + public void setProperties(BrokerProperties properties) { this.properties = properties; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 9acea472b99b6..4a0d4c9c28745 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -4,6 +4,7 @@ import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; +import com.microsoft.azure.services.serviceBus.implementation.EntryModel; import com.microsoft.azure.services.serviceBus.schema.Content; import com.microsoft.azure.services.serviceBus.schema.Entry; @@ -13,9 +14,9 @@ public class Queue extends EntryModel { public Queue() { super(new Entry(), new QueueDescription()); - entry.setContent(new Content()); - entry.getContent().setType(MediaType.APPLICATION_XML); - entry.getContent().setQueueDescription(getModel()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setQueueDescription(getModel()); } public Queue(Entry entry) { @@ -24,94 +25,94 @@ public Queue(Entry entry) { public String getName() { - return entry.getTitle(); + return getEntry().getTitle(); } public Queue setName(String value) { - entry.setTitle(value); + getEntry().setTitle(value); return this; } public Duration getLockDuration() { - return model.getLockDuration(); + return getModel().getLockDuration(); } public Queue setLockDuration(Duration value) { - model.setLockDuration(value); + getModel().setLockDuration(value); return this; } public Long getMaxSizeInMegabytes() { - return model.getMaxSizeInMegabytes(); + return getModel().getMaxSizeInMegabytes(); } public Queue setMaxSizeInMegabytes(Long value) { - model.setMaxSizeInMegabytes(value); + getModel().setMaxSizeInMegabytes(value); return this; } public Queue setRequiresDuplicateDetection(Boolean value) { - model.setRequiresDuplicateDetection(value); + getModel().setRequiresDuplicateDetection(value); return this; } public Queue setRequiresSession(Boolean value) { - model.setRequiresSession(value); + getModel().setRequiresSession(value); return this; } public Duration getDefaultMessageTimeToLive() { - return model.getDefaultMessageTimeToLive(); + return getModel().getDefaultMessageTimeToLive(); } public Queue setDefaultMessageTimeToLive(Duration value) { - model.setDefaultMessageTimeToLive(value); + getModel().setDefaultMessageTimeToLive(value); return this; } public Queue setDeadLetteringOnMessageExpiration(Boolean value) { - model.setDeadLetteringOnMessageExpiration(value); + getModel().setDeadLetteringOnMessageExpiration(value); return this; } public Duration getDuplicateDetectionHistoryTimeWindow() { - return model.getDuplicateDetectionHistoryTimeWindow(); + return getModel().getDuplicateDetectionHistoryTimeWindow(); } public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { - model.setDuplicateDetectionHistoryTimeWindow(value); + getModel().setDuplicateDetectionHistoryTimeWindow(value); return this; } public Integer getMaxDeliveryCount() { - return model.getMaxDeliveryCount(); + return getModel().getMaxDeliveryCount(); } public Queue setMaxDeliveryCount(Integer value) { - model.setMaxDeliveryCount(value); + getModel().setMaxDeliveryCount(value); return this; } public Queue setEnableBatchedOperations(Boolean value) { - model.setEnableBatchedOperations(value); + getModel().setEnableBatchedOperations(value); return this; } public Long getSizeInBytes() { - return model.getSizeInBytes(); + return getModel().getSizeInBytes(); } public Queue setSizeInBytes(Long value) { - model.setSizeInBytes(value); + getModel().setSizeInBytes(value); return this; } public Long getMessageCount() { - return model.getMessageCount(); + return getModel().getMessageCount(); } public Queue setMessageCount(Long value) { - model.setMessageCount(value); + getModel().setMessageCount(value); return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java index 746b98848e40f..cb29a3a8aa639 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java @@ -10,7 +10,7 @@ List getQueues() { return queues; } - void setQueues(List queues) { + public void setQueues(List queues) { this.queues = queues; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java index b819b080b0918..b38a84f900f57 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/schema/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.schema; +package com.microsoft.azure.services.serviceBus.implementation; import org.codehaus.jackson.annotate.JsonGetter; import org.codehaus.jackson.annotate.JsonIgnore; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java index 16621d700351d..69e6a13a09480 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import java.io.IOException; import java.io.StringWriter; @@ -9,7 +9,6 @@ import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; public class BrokerPropertiesMapper { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java index f6592682dc202..5032acc33b229 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import com.microsoft.azure.services.serviceBus.schema.Entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java index cfeee55a1ddee..03f9c1df09314 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import java.io.IOException; import java.io.InputStream; @@ -13,6 +13,7 @@ import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; +import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.schema.Entry; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java index 46160a0b98a51..783ba5ab9dcd0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; @@ -9,6 +9,7 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.PropertyException; + @Provider @Produces("application/atom+xml") public class MarshallerProvider implements ContextResolver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java index 59bf4de5ca349..c2f9762642103 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 685012e6c3b9f..9bc474980b978 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.azure.services.serviceBus.implementation; import java.io.InputStream; import java.rmi.UnexpectedException; @@ -10,7 +10,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; +import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.Queue; +import com.microsoft.azure.services.serviceBus.QueueList; +import com.microsoft.azure.services.serviceBus.ReceiveMode; +import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.schema.Entry; import com.microsoft.azure.services.serviceBus.schema.Feed; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index 3cb3681acb4e0..dfcab1863ad2e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -4,8 +4,8 @@ import org.junit.Test; -import com.microsoft.azure.services.serviceBus.BrokerPropertiesMapper; -import com.microsoft.azure.services.serviceBus.schema.BrokerProperties; +import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; +import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; public class BrokerPropertiesMapperTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java index 1935b059e5d03..a2c97a920cb60 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java @@ -6,6 +6,7 @@ import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceImpl; public class ContractBuilderTest { @Test From 918b961f466a6706b0f0d0b008f14aa2d22aef12 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 11:50:03 -0700 Subject: [PATCH 057/664] Adding ServiceBusConfiguration static class Contains string constants for property settings Provides static configure utility method for wiring user data into fully qualified uri and scope correctly --- .../serviceBus/ServiceBusConfiguration.java | 42 +++++++++++++++ .../serviceBus/IntegrationTestBase.java | 6 +-- .../ServiceBusConfigurationTest.java | 51 +++++++++++++++++++ 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java new file mode 100644 index 0000000000000..25a58ad1c6feb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java @@ -0,0 +1,42 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.configuration.Configuration; + +public class ServiceBusConfiguration { + public final static String URI = "serviceBus.uri"; + public final static String WRAP_URI = "serviceBus.wrap.uri"; + public final static String WRAP_NAME = "serviceBus.wrap.name"; + public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; + public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; + + public static Configuration configure(Configuration configuration, + String namespace, String authenticationName, + String authenticationPassword) { + return configure(null, configuration, namespace, authenticationName, + authenticationPassword); + } + + public static Configuration configure(String profile, Configuration configuration, + String namespace, String authenticationName, + String authenticationPassword) { + + if (profile == null) { + profile = ""; + } else if (profile.length() != 0 && !profile.endsWith(".")) { + profile = profile + "."; + } + + configuration.setProperty(profile + URI, "https://" + namespace + + ".servicebus.windows.net/"); + + configuration.setProperty(profile + WRAP_URI, "https://" + namespace + + "-sb.accesscontrol.windows.net/WRAPv0.9"); + + configuration.setProperty(profile + WRAP_NAME, authenticationName); + configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); + configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace + + ".servicebus.windows.net/"); + + return configuration; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 542609bc08280..54f01d546e47b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -13,11 +13,7 @@ public abstract class IntegrationTestBase { protected Configuration createConfiguration() { Configuration config = new Configuration(); - config.setProperty("serviceBus.uri", "https://lodejard.servicebus.windows.net"); - config.setProperty("serviceBus.wrap.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("serviceBus.wrap.name", "owner"); - config.setProperty("serviceBus.wrap.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - config.setProperty("serviceBus.wrap.scope", "http://lodejard.servicebus.windows.net/"); + ServiceBusConfiguration.configure(config, "lodejard", "owner", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); // when mock running //config.setProperty("serviceBus.uri", "http://localhost:8086"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java new file mode 100644 index 0000000000000..f1340164e699b --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java @@ -0,0 +1,51 @@ +package com.microsoft.azure.services.serviceBus; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; + +public class ServiceBusConfigurationTest { + @Test + public void ConfigureSetsExpectedProperties() { + // Arrange + Configuration config = new Configuration(); + + // Act + ServiceBusConfiguration.configure(config, "alpha", "beta", "gamma"); + + // Assert + assertEquals("https://alpha.servicebus.windows.net/", + config.getProperty("serviceBus.uri")); + assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", + config.getProperty("serviceBus.wrap.uri")); + assertEquals("beta", + config.getProperty("serviceBus.wrap.name")); + assertEquals("gamma", + config.getProperty("serviceBus.wrap.password")); + assertEquals("http://alpha.servicebus.windows.net/", + config.getProperty("serviceBus.wrap.scope")); + } + + @Test + public void UsingProfileAddsPrefix() { + // Arrange + Configuration config = new Configuration(); + + // Act + ServiceBusConfiguration.configure("backup", config, "alpha", "beta", "gamma"); + + // Assert + assertEquals("https://alpha.servicebus.windows.net/", + config.getProperty("backup.serviceBus.uri")); + assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", + config.getProperty("backup.serviceBus.wrap.uri")); + assertEquals("beta", + config.getProperty("backup.serviceBus.wrap.name")); + assertEquals("gamma", + config.getProperty("backup.serviceBus.wrap.password")); + assertEquals("http://alpha.servicebus.windows.net/", + config.getProperty("backup.serviceBus.wrap.scope")); + } +} From 9a41bac1926f61f6312cf52732bae0e454dbe676 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 12:30:38 -0700 Subject: [PATCH 058/664] Relocating generated datacontract classes Moving from serviceBus.schema to serviceBus.implementation --- .../java/com/microsoft/azure/services/serviceBus/Queue.java | 6 +++--- .../azure/services/serviceBus/ServiceBusService.java | 4 ++-- .../services/serviceBus/implementation/EntryModel.java | 2 +- .../serviceBus/implementation/EntryModelProvider.java | 2 +- .../serviceBus/implementation/ServiceBusServiceImpl.java | 4 ++-- microsoft-azure-api/src/main/resources/package-names.xjb | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 4a0d4c9c28745..70d226c8677b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -4,11 +4,11 @@ import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; +import com.microsoft.azure.services.serviceBus.implementation.Content; +import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.EntryModel; -import com.microsoft.azure.services.serviceBus.schema.Content; -import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.implementation.QueueDescription; -import com.microsoft.azure.services.serviceBus.schema.QueueDescription; public class Queue extends EntryModel { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index b8f6632bff0b2..d51361ca4bf6d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -1,7 +1,7 @@ package com.microsoft.azure.services.serviceBus; -import com.microsoft.azure.services.serviceBus.schema.Entry; -import com.microsoft.azure.services.serviceBus.schema.Feed; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Feed; import com.microsoft.azure.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java index 5032acc33b229..57abc5cc9cb49 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.serviceBus.implementation; -import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Entry; public class EntryModel { Entry entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java index 03f9c1df09314..5b271faeebfb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java @@ -14,7 +14,7 @@ import javax.ws.rs.ext.MessageBodyWriter; import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.schema.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 9bc474980b978..90ad46d4623ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -15,8 +15,8 @@ import com.microsoft.azure.services.serviceBus.QueueList; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.schema.Entry; -import com.microsoft.azure.services.serviceBus.schema.Feed; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Feed; import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.WrapFilter; diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 06c4a48b9db2b..94ff16dbb2614 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -6,12 +6,12 @@ jaxb:extensionBindingPrefixes="xjc"> - + - + From c47b49f6f7868fef3b93e12cdb83d2a551d3af5a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 13:57:30 -0700 Subject: [PATCH 059/664] Add support for creating block and page blobs --- .../azure/services/blob/BlobService.java | 8 ++ .../azure/services/blob/BlobServiceImpl.java | 77 +++++++++- .../azure/services/blob/ContainerACL.java | 2 + .../azure/services/blob/PutBlobOptions.java | 136 ++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 25 ++++ 5 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index fb35e8d518dea..198133a26b0ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -1,7 +1,9 @@ package com.microsoft.azure.services.blob; +import java.io.InputStream; import java.util.HashMap; +//TODO: ServiceException annotation and handling in implementation public interface BlobService { ListContainersResults listContainers(); @@ -26,4 +28,10 @@ public interface BlobService { ListBlobsResults listBlobs(String container); ListBlobsResults listBlobs(String container, ListBlobsOptions options); + + void putPageBlob(String container, String blob, int length); + void putPageBlob(String container, String blob, int length, PutBlobOptions options); + + void putBlockBlob(String container, String blob, InputStream content); + void putBlockBlob(String container, String blob, InputStream content, PutBlobOptions options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 501cd8bce2736..92dd0309141a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.blob; +import java.io.InputStream; import java.text.ParseException; import java.util.EnumSet; import java.util.HashMap; @@ -49,13 +50,20 @@ private WebResource addOptionalQueryParam(WebResource wr, String key, int value, return wr; } - private Builder addOptionalHeader(Builder builder, String name, String value) { + private Builder addOptionalHeader(Builder builder, String name, Object value) { if (value != null) { builder = builder.header(name, value); } return builder; } + private Builder addOptionalHeader(Builder builder, String name, int value, int defaultValue) { + if (value != defaultValue) { + builder = builder.header(name, Integer.toString(value)); + } + return builder; + } + private WebResource getResource() { WebResource res = channel.resource(url).path("/"); @@ -253,7 +261,6 @@ public String toString() { public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); @@ -271,4 +278,70 @@ public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResults.class); } + + public void putPageBlob(String container, String blob, int length) { + putPageBlob(container, blob, length, new PutBlobOptions()); + } + + public void putPageBlob(String container, String blob, int length, PutBlobOptions options) { + WebResource webResource = getResource().path(container + "/" + blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = builder.header("x-ms-blob-type", "PageBlob"); + builder = addPutBlobHeaders(options, builder); + + builder = builder.header("Content-Length", 0); + builder = builder.header("x-ms-blob-content-length", length); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + // TODO: We need the following 2 to make sure that "Content-Length:0" header + // is sent to the server (IIS doesn't accept PUT without a content length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + builder.type("text/plain").put(""); + } + + public void putBlockBlob(String container, String blob, InputStream content) { + putBlockBlob(container, blob, content, new PutBlobOptions()); + } + + public void putBlockBlob(String container, String blob, InputStream content, PutBlobOptions options) { + WebResource webResource = getResource().path(container + "/" + blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = builder.header("x-ms-blob-type", "BlockBlob"); + builder = addPutBlobHeaders(options, builder); + + builder.put(content); + } + + private Builder addPutBlobHeaders(PutBlobOptions options, Builder builder) { + builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); + if (options.getContentType() == null) { + // This is technically the default, but we explicitly add here to allow proper + // signing of the request headers. + builder = builder.type("application/octet-stream"); + } + builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + // Metadata + for (Entry entry : options.getMetadata().entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + //TODO: Conditional headers (If Match, etc.) + + return builder; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index ddbf4cf95beac..c9eca4826c867 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -96,7 +96,9 @@ public void setAccessPolicy(AccessPolicy accessPolicy) { } public static class AccessPolicy { + //TODO: Make it a date? private String start; + //TODO: Make it a date? private String expiry; private String permission; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java new file mode 100644 index 0000000000000..a831ee7b60fa5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java @@ -0,0 +1,136 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class PutBlobOptions { + private String contentType; + private String contentEncoding; + private String contentLanguage; + private String contentMD5; + private String cacheControl; + private String blobContentType; + private String blobContentEncoding; + private String blobContentLanguage; + private String blobContentMD5; + private String blobCacheControl; + private HashMap metadata = new HashMap(); + private String leaseId; + private Long sequenceNumber; + + public String getContentType() { + return contentType; + } + + public PutBlobOptions setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + public String getContentEncoding() { + return contentEncoding; + } + + public PutBlobOptions setContentEncoding(String contentEncoding) { + this.contentEncoding = contentEncoding; + return this; + } + + public String getContentLanguage() { + return contentLanguage; + } + + public PutBlobOptions setContentLanguage(String contentLanguage) { + this.contentLanguage = contentLanguage; + return this; + } + + public String getContentMD5() { + return contentMD5; + } + + public PutBlobOptions setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + return this; + } + + public String getCacheControl() { + return cacheControl; + } + + public PutBlobOptions setCacheControl(String cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + public String getBlobContentType() { + return blobContentType; + } + + public PutBlobOptions setBlobContentType(String blobContentType) { + this.blobContentType = blobContentType; + return this; + } + + public String getBlobContentEncoding() { + return blobContentEncoding; + } + + public PutBlobOptions setBlobContentEncoding(String blobContentEncoding) { + this.blobContentEncoding = blobContentEncoding; + return this; + } + + public String getBlobContentLanguage() { + return blobContentLanguage; + } + + public PutBlobOptions setBlobContentLanguage(String blobContentLanguage) { + this.blobContentLanguage = blobContentLanguage; + return this; + } + + public String getBlobContentMD5() { + return blobContentMD5; + } + + public PutBlobOptions setBlobContentMD5(String blobContentMD5) { + this.blobContentMD5 = blobContentMD5; + return this; + } + + public String getBlobCacheControl() { + return blobCacheControl; + } + + public PutBlobOptions setBlobCacheControl(String blobCacheControl) { + this.blobCacheControl = blobCacheControl; + return this; + } + + public HashMap getMetadata() { + return metadata; + } + + public PutBlobOptions setMetadata(HashMap metadata) { + this.metadata = metadata; + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public PutBlobOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public Long getSequenceNumber() { + return sequenceNumber; + } + + public PutBlobOptions setSequenceNumber(Long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + return this; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 95045e166d71c..f4cca5eb1745a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.io.ByteArrayInputStream; import java.util.EnumSet; import java.util.HashMap; @@ -225,4 +226,28 @@ public void listBlobsWithPrefixWorks() throws Exception { assertNotNull(results); assertEquals(2, results.getBlobs().size()); } + + @Test + public void putPageBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.putPageBlob("mycontainer1", "test", 512); + + // Assert + } + + @Test + public void putBlockBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); + + // Assert + } } From 5aea356e730697c0c7e852839a5d222c71c8e9e5 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 14:46:28 -0700 Subject: [PATCH 060/664] Add all BrokerProperties. closes #2 Provides serialization/deserialization for all brokered message properties get/set properties projected onto Message class Values that are only returned by server will only have get property --- .../azure/services/serviceBus/Message.java | 146 ++++++++++++++++-- .../implementation/BrokerProperties.java | 134 +++++++++++++++- .../BrokerPropertiesMapperTest.java | 78 ++++++++++ 3 files changed, 336 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 2e4a0ef6f4509..4e1a3c472d0a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -2,12 +2,15 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Date; import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; public class Message { BrokerProperties properties; InputStream body; + String contentType; + Date date; public Message() { this.properties = new BrokerProperties(); @@ -33,29 +36,144 @@ public Message(String body) { this.body = body; } - /** - * @return the brokerProperties - */ public BrokerProperties getProperties() { return properties; } - /** - * @param properties the brokerProperties to set - */ - public void setProperties(BrokerProperties properties) { + public Message setProperties(BrokerProperties properties) { this.properties = properties; + return this; } - /** - * @return the body - */ + public InputStream getBody() { return body; } - /** - * @param body the body to set - */ - public void setBody(InputStream body) { + + public Message setBody(InputStream body) { this.body = body; + return this; + } + + public String getContentType() { + return contentType; + } + + public Message setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + public Date getDate() { + return date; + } + + public Message setDate(Date date) { + this.date = date; + return this; + } + + public Integer getDeliveryCount() { + return properties.getDeliveryCount(); + } + + public String getMessageId() { + return properties.getMessageId(); + } + + public Message setMessageId(String messageId) { + properties.setMessageId(messageId); + return this; + } + + public Long getSequenceNumber() { + return properties.getSequenceNumber(); + } + + public Long getTimeToLive() { + return properties.getTimeToLive(); + } + + public Message setTimeToLive(Long timeToLive) { + properties.setTimeToLive(timeToLive); + return this; + } + + public String getLockToken() { + return properties.getLockToken(); + } + + public Date getLockedUntilUtc() { + return properties.getLockedUntilUtc(); + } + + public String getCorrelationId() { + return properties.getCorrelationId(); + } + + public Message setCorrelationId(String correlationId) { + properties.setCorrelationId(correlationId); + return this; + } + + public String getSessionId() { + return properties.getSessionId(); + } + + public Message setSessionId(String sessionId) { + properties.setSessionId(sessionId); + return this; + } + + public String getLabel() { + return properties.getLabel(); + } + + public Message setLabel(String label) { + properties.setLabel(label); + return this; + } + + public String getReplyTo() { + return properties.getReplyTo(); + } + + public Message setReplyTo(String replyTo) { + properties.setReplyTo(replyTo); + return this; + } + + public String getTo() { + return properties.getTo(); + } + + public Message setTo(String to) { + properties.setTo(to); + return this; + } + + public Date getScheduledEnqueueTimeUtc() { + return properties.getScheduledEnqueueTimeUtc(); + } + + public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { + properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); + return this; + } + + public String getReplyToSessionId() { + return properties.getReplyToSessionId(); + } + + public Message setReplyToSessionId(String replyToSessionId) { + properties.setReplyToSessionId(replyToSessionId); + return this; + } + + public String getMessageLocation() { + return properties.getMessageLocation(); + } + + public String getLockLocation() { + return properties.getLockLocation(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java index b38a84f900f57..f19c340e7c58a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java @@ -1,31 +1,68 @@ package com.microsoft.azure.services.serviceBus.implementation; +import java.util.Date; + import org.codehaus.jackson.annotate.JsonGetter; import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonWriteNullProperties; + +// +// members of this class defined per specification at +// http://msdn.microsoft.com/en-us/library/windowsazure/hh367521.aspx#BKMK_REST3prod +// + @JsonIgnoreProperties(ignoreUnknown=true) @JsonWriteNullProperties(false) public class BrokerProperties { + + @JsonProperty("CorrelationId") + String correlationId; + + @JsonProperty("SessionId") + String sessionId; + @JsonProperty("DeliveryCount") Integer deliveryCount; + @JsonProperty("LockedUntil") + Date lockedUntilUtc; + + @JsonProperty("LockToken") + String lockToken; + @JsonProperty("MessageId") String messageId; + @JsonProperty("Label") + String label; + + @JsonProperty("ReplyTo") + String replyTo; + @JsonProperty("SequenceNumber") Long sequenceNumber; - + @JsonProperty("TimeToLive") Long timeToLive; - @JsonProperty("LockToken") - String lockToken; - - @JsonProperty("LockedUntilUtc") - String lockedUntilUtc; + @JsonProperty("To") + String to; + + @JsonProperty("ScheduledEnqueueTimeUtc") + Date scheduledEnqueueTimeUtc; + + @JsonProperty("ReplyToSessionId") + String replyToSessionId; + + @JsonProperty("MessageLocation") + String messageLocation; + + @JsonProperty("LockLocation") + String lockLocation; + @JsonIgnore @@ -74,13 +111,94 @@ public void setLockToken(String lockToken) { } @JsonIgnore - public String getLockedUntilUtc() { + public Date getLockedUntilUtc() { return lockedUntilUtc; } - public void setLockedUntilUtc(String lockedUntilUtc) { + public void setLockedUntilUtc(Date lockedUntilUtc) { this.lockedUntilUtc = lockedUntilUtc; } + @JsonIgnore + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String correlationId) { + this.correlationId = correlationId; + } + + @JsonIgnore + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + @JsonIgnore + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @JsonIgnore + public String getReplyTo() { + return replyTo; + } + + public void setReplyTo(String replyTo) { + this.replyTo = replyTo; + } + + @JsonIgnore + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + @JsonIgnore + public Date getScheduledEnqueueTimeUtc() { + return scheduledEnqueueTimeUtc; + } + + public void setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { + this.scheduledEnqueueTimeUtc = scheduledEnqueueTimeUtc; + } + + @JsonIgnore + public String getReplyToSessionId() { + return replyToSessionId; + } + + public void setReplyToSessionId(String replyToSessionId) { + this.replyToSessionId = replyToSessionId; + } + + @JsonIgnore + public String getMessageLocation() { + return messageLocation; + } + + public void setMessageLocation(String messageLocation) { + this.messageLocation = messageLocation; + } + + @JsonIgnore + public String getLockLocation() { + return lockLocation; + } + + public void setLockLocation(String lockLocation) { + this.lockLocation = lockLocation; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index dfcab1863ad2e..6ed6d22fff4eb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -2,6 +2,11 @@ import static org.junit.Assert.*; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.codehaus.jackson.annotate.JsonProperty; import org.junit.Test; import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; @@ -26,6 +31,7 @@ public void jsonStringMapsToBrokerPropertiesObject(){ public void nonDefaultPropertiesMapToJsonString(){ // Arrange BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + // Act BrokerProperties properties = new BrokerProperties(); properties.setMessageId("foo"); @@ -36,4 +42,76 @@ public void nonDefaultPropertiesMapToJsonString(){ assertNotNull(json); assertEquals("{\"DeliveryCount\":7,\"MessageId\":\"foo\"}", json); } + + @Test + public void deserializingAllPossibleValues() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar.set(1994, 10, 6, 8, 49, 37); + Date schedTimeUtc = calendar.getTime(); + + Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar2.set(2011, 9, 14, 12, 34, 56); + Date lockedUntilUtc = calendar2.getTime(); + + // Act + BrokerProperties properties = mapper.fromString( + "{"+ + "\"CorrelationId\": \"corid\","+ + "\"SessionId\": \"sesid\","+ + "\"DeliveryCount\": 5,"+ + "\"LockedUntil\": \" Fri, 14 Oct 2011 12:34:56 GMT\","+ + "\"LockToken\": \"loctok\","+ + "\"MessageId\": \"mesid\","+ + "\"Label\": \"lab\","+ + "\"ReplyTo\": \"repto\","+ + "\"SequenceNumber\": 7,"+ + "\"TimeToLive\": 8,"+ + "\"To\": \"to\","+ + "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\","+ + "\"ReplyToSessionId\": \"reptosesid\","+ + "\"MessageLocation\": \"mesloc\","+ + "\"LockLocation\": \"locloc\""+ + "}"); + + + + // Assert + assertNotNull(properties); + + long lockedUntilDelta = properties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + long schedTimeDelta = properties.getScheduledEnqueueTimeUtc().getTime() - schedTimeUtc.getTime(); + + assertEquals("corid", properties.getCorrelationId()); + assertEquals("sesid", properties.getSessionId()); + assertEquals(5, (int)properties.getDeliveryCount()); + assertTrue(Math.abs(lockedUntilDelta) < 500); + assertEquals("loctok", properties.getLockToken()); + assertEquals("mesid", properties.getMessageId()); + assertEquals("lab", properties.getLabel()); + assertEquals("repto", properties.getReplyTo()); + assertEquals(7, (long)properties.getSequenceNumber()); + assertEquals(8, (long)properties.getTimeToLive()); + assertEquals("to", properties.getTo()); + assertTrue(Math.abs(schedTimeDelta) < 500); + assertEquals("reptosesid", properties.getReplyToSessionId()); + assertEquals("mesloc", properties.getMessageLocation()); + assertEquals("locloc", properties.getLockLocation()); + } + + @Test + public void missingDatesDeserializeAsNull() + { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + // Act + BrokerProperties properties = mapper.fromString("{}"); + + // Assert + assertNull(properties.getLockedUntilUtc()); + assertNull(properties.getScheduledEnqueueTimeUtc()); + } } From f0fc56e27987081b16d95d3cf4d7d0d8382bf9e9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 14:55:13 -0700 Subject: [PATCH 061/664] Add support for GetBlobProperties --- .../azure/services/blob/BlobProperties.java | 131 ++++++++++++++++++ .../azure/services/blob/BlobService.java | 3 + .../azure/services/blob/BlobServiceImpl.java | 76 ++++++++-- .../blob/GetBlobPropertiesOptions.java | 24 ++++ .../blob/BlobServiceIntegrationTest.java | 71 +++++++++- 5 files changed, 295 insertions(+), 10 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java new file mode 100644 index 0000000000000..236ca9b38ca42 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java @@ -0,0 +1,131 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; +import java.util.HashMap; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +//TODO: Unify this with ListBlobsResults.BlobProperties +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; + private HashMap metadata = new HashMap(); + + @XmlElement(name = "Last-Modified") + @XmlJavaTypeAdapter(DateAdapter.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; + } + + 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/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 198133a26b0ec..f6ede408d98c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -34,4 +34,7 @@ public interface BlobService { void putBlockBlob(String container, String blob, InputStream content); void putBlockBlob(String container, String blob, InputStream content, PutBlobOptions options); + + BlobProperties getBlobProperties(String container, String blob); + BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 92dd0309141a2..4bb2a9ef71930 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -176,7 +176,7 @@ public ContainerACL getContainerACL(String container) { acl.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); } catch (ParseException e) { - //TODO: Is this the right way to handle this? + // TODO: Is this the right way to handle this? throw new IllegalArgumentException(e); } return acl; @@ -187,8 +187,8 @@ public void setContainerACL(String container, ContainerACL acl) { webResource = setCanonicalizedResource(webResource, container, "acl"); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); - //Note: Add content type here to enable proper HMAC signing - //builder = builder.header("Content-Type", "application/xml"); + // Note: Add content type here to enable proper HMAC signing + // builder = builder.header("Content-Type", "application/xml"); builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, acl.getPublicAccess()); ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); @@ -218,7 +218,6 @@ public void setContainerMetadata(String container, HashMap metad builder.header("Content-Type", "text/plain").put(""); } - public ListContainersResults listContainers() { return listContainers(new ListContainersOptions()); } @@ -294,8 +293,10 @@ public void putPageBlob(String container, String blob, int length, PutBlobOption builder = builder.header("Content-Length", 0); builder = builder.header("x-ms-blob-content-length", length); builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - // TODO: We need the following 2 to make sure that "Content-Length:0" header - // is sent to the server (IIS doesn't accept PUT without a content length). + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). // Since we are sending a "dummy" string, we also need to set the // "Content-Type" header so that the hmac filter will see it when // producing the authorization hmac. @@ -320,7 +321,8 @@ public void putBlockBlob(String container, String blob, InputStream content, Put private Builder addPutBlobHeaders(PutBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); if (options.getContentType() == null) { - // This is technically the default, but we explicitly add here to allow proper + // This is technically the default, but we explicitly add here to + // allow proper // signing of the request headers. builder = builder.type("application/octet-stream"); } @@ -340,8 +342,66 @@ private Builder addPutBlobHeaders(PutBlobOptions options, Builder builder) { builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); } - //TODO: Conditional headers (If Match, etc.) + // TODO: Conditional headers (If Match, etc.) return builder; } + + public BlobProperties getBlobProperties(String container, String blob) { + return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); + } + + public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) { + WebResource webResource = getResource().path(container).path(blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + if (options.getSnapshot() != null) { + webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + } + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + ClientResponse response = builder.method("HEAD", ClientResponse.class); + + BlobProperties properties = new BlobProperties(); + + // Last-Modified + try { + properties.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); + } + catch (ParseException e) { + // Server returned an invalid/unsupported date format + throw new IllegalArgumentException(e); + } + + // Metadata + HashMap metadata = new HashMap(); + for (Entry> entry : response.getHeaders().entrySet()) { + if (entry.getKey().startsWith(X_MS_META_PREFIX)) { + String name = entry.getKey().substring(X_MS_META_PREFIX.length()); + String value = entry.getValue().get(0); + metadata.put(name, value); + } + } + properties.setMetadata(metadata); + + // + properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); + properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); + + properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); + properties.setContentType(response.getHeaders().getFirst("Content-Type")); + properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); + properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); + properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); + + 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"))); + } + + return properties; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java new file mode 100644 index 0000000000000..e88d37a720b51 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class GetBlobPropertiesOptions { + private Date snapshot; + private String leaseId; + + public Date getSnapshot() { + return snapshot; + } + + public void setSnapshot(Date snapshot) { + this.snapshot = snapshot; + } + + public String getLeaseId() { + return leaseId; + } + + public void setLeaseId(String leaseId) { + this.leaseId = leaseId; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index f4cca5eb1745a..e4828de90e3f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; @@ -115,7 +116,6 @@ public void setContainerACLWorks() throws Exception { // Act contract.createContainer("foo4"); - ContainerACL acl = new ContainerACL(); acl.setPublicAccess("blob"); acl.AddSignedIdentifier("test", "2010-01-01", "2020-01-01", "rwd"); @@ -137,7 +137,6 @@ public void setContainerACLWorks() throws Exception { assertEquals("rwd", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getPermission()); } - @Test public void listContainersWorks() throws Exception { // Arrange @@ -239,6 +238,40 @@ public void putPageBlobWorks() throws Exception { // Assert } + @Test + public void putPageBlobWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.putPageBlob( + "mycontainer1", + "test", + 512, + new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF8") + /* .setContentMD5("1234") */.setContentType("text/plain")); + + BlobProperties props = contract.getBlobProperties("mycontainer1", "test"); + + // Assert + assertNotNull(props); + assertEquals("test", props.getCacheControl()); + assertEquals("UTF8", props.getContentEncoding()); + assertEquals("en-us", props.getContentLanguage()); + assertEquals("text/plain", props.getContentType()); + 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()); + assertEquals(0, props.getSequenceNumber()); + } + @Test public void putBlockBlobWorks() throws Exception { // Arrange @@ -250,4 +283,38 @@ public void putBlockBlobWorks() throws Exception { // Assert } + + @Test + public void putBlockBlobWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.putBlockBlob( + "mycontainer1", + "test2", + new ByteArrayInputStream("some content".getBytes()), + new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF8") + /* .setContentMD5("1234") */.setContentType("text/plain")); + + BlobProperties props = contract.getBlobProperties("mycontainer1", "test2"); + + // Assert + assertNotNull(props); + assertEquals("test", props.getCacheControl()); + assertEquals("UTF8", props.getContentEncoding()); + assertEquals("en-us", props.getContentLanguage()); + assertEquals("text/plain", props.getContentType()); + assertEquals(512, 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()); + assertEquals(0, props.getSequenceNumber()); + } } From f92031ca13177bc6aedc97e998b57ba5fffb11dc Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 16:18:36 -0700 Subject: [PATCH 062/664] Updating BrokerProperties and Message properties json field is named LockedUntilUtc TimeToLive is floating-point --- .../azure/services/serviceBus/Message.java | 4 +- .../azure/services/serviceBus/Queue.java | 26 +++++---- .../implementation/BrokerProperties.java | 8 +-- .../BrokerPropertiesMapperTest.java | 6 +- .../serviceBus/ServiceBusIntegrationTest.java | 56 +++++++++++++++++-- 5 files changed, 77 insertions(+), 23 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 4e1a3c472d0a7..43d95f107b03f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -89,11 +89,11 @@ public Long getSequenceNumber() { return properties.getSequenceNumber(); } - public Long getTimeToLive() { + public Double getTimeToLive() { return properties.getTimeToLive(); } - public Message setTimeToLive(Long timeToLive) { + public Message setTimeToLive(Double timeToLive) { properties.setTimeToLive(timeToLive); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index 70d226c8677b3..e1a57beda00fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -23,7 +23,6 @@ public Queue(Entry entry) { super(entry, entry.getContent().getQueueDescription()); } - public String getName() { return getEntry().getTitle(); } @@ -51,11 +50,19 @@ public Queue setMaxSizeInMegabytes(Long value) { return this; } + public Boolean isRequiresDuplicateDetection() { + return getModel().isRequiresDuplicateDetection(); + } + public Queue setRequiresDuplicateDetection(Boolean value) { getModel().setRequiresDuplicateDetection(value); return this; } + public Boolean isRequiresSession() { + return getModel().isRequiresSession(); + } + public Queue setRequiresSession(Boolean value) { getModel().setRequiresSession(value); return this; @@ -70,6 +77,10 @@ public Queue setDefaultMessageTimeToLive(Duration value) { return this; } + public Boolean isDeadLetteringOnMessageExpiration() { + return getModel().isDeadLetteringOnMessageExpiration(); + } + public Queue setDeadLetteringOnMessageExpiration(Boolean value) { getModel().setDeadLetteringOnMessageExpiration(value); return this; @@ -93,6 +104,10 @@ public Queue setMaxDeliveryCount(Integer value) { return this; } + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } + public Queue setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; @@ -102,17 +117,8 @@ public Long getSizeInBytes() { return getModel().getSizeInBytes(); } - public Queue setSizeInBytes(Long value) { - getModel().setSizeInBytes(value); - return this; - } - public Long getMessageCount() { return getModel().getMessageCount(); } - public Queue setMessageCount(Long value) { - getModel().setMessageCount(value); - return this; - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java index f19c340e7c58a..860e788ffc981 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java @@ -27,7 +27,7 @@ public class BrokerProperties { @JsonProperty("DeliveryCount") Integer deliveryCount; - @JsonProperty("LockedUntil") + @JsonProperty("LockedUntilUtc") Date lockedUntilUtc; @JsonProperty("LockToken") @@ -46,7 +46,7 @@ public class BrokerProperties { Long sequenceNumber; @JsonProperty("TimeToLive") - Long timeToLive; + Double timeToLive; @JsonProperty("To") String to; @@ -93,11 +93,11 @@ public void setSequenceNumber(Long sequenceNumber) { } @JsonIgnore - public Long getTimeToLive() { + public Double getTimeToLive() { return timeToLive; } - public void setTimeToLive(Long timeToLive) { + public void setTimeToLive(Double timeToLive) { this.timeToLive = timeToLive; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index 6ed6d22fff4eb..12c6820eba34d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -62,13 +62,13 @@ public void deserializingAllPossibleValues() { "\"CorrelationId\": \"corid\","+ "\"SessionId\": \"sesid\","+ "\"DeliveryCount\": 5,"+ - "\"LockedUntil\": \" Fri, 14 Oct 2011 12:34:56 GMT\","+ + "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\","+ "\"LockToken\": \"loctok\","+ "\"MessageId\": \"mesid\","+ "\"Label\": \"lab\","+ "\"ReplyTo\": \"repto\","+ "\"SequenceNumber\": 7,"+ - "\"TimeToLive\": 8,"+ + "\"TimeToLive\": 8.123,"+ "\"To\": \"to\","+ "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\","+ "\"ReplyToSessionId\": \"reptosesid\","+ @@ -93,7 +93,7 @@ public void deserializingAllPossibleValues() { assertEquals("lab", properties.getLabel()); assertEquals("repto", properties.getReplyTo()); assertEquals(7, (long)properties.getSequenceNumber()); - assertEquals(8, (long)properties.getTimeToLive()); + assertEquals(8.123, properties.getTimeToLive(), .001); assertEquals("to", properties.getTo()); assertTrue(Math.abs(schedTimeDelta) < 500); assertEquals("reptosesid", properties.getReplyToSessionId()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 1b23e338b39c1..f2e8a833bb39f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,6 +1,9 @@ package com.microsoft.azure.services.serviceBus; import java.util.Arrays; +import java.util.Date; + +import javax.sound.sampled.ReverbType; import org.junit.Before; import org.junit.Test; @@ -79,10 +82,11 @@ public void sendMessageWorks() throws Exception { @Test public void receiveMessageWorks() throws Exception { // Arrange - service.sendMessage("TestAlpha", new Message("Hello World")); + service.createQueue(new Queue().setName("TestReceiveMessageWorks")); + service.sendMessage("TestReceiveMessageWorks", new Message("Hello World")); // Act - Message message = service.receiveMessage("TestAlpha", 500, ReceiveMode.RECEIVE_AND_DELETE); + Message message = service.receiveMessage("TestReceiveMessageWorks", 500, ReceiveMode.RECEIVE_AND_DELETE); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -94,10 +98,11 @@ public void receiveMessageWorks() throws Exception { @Test public void peekLockMessageWorks() throws Exception { // Arrange - service.sendMessage("TestAlpha", new Message("Hello Again")); + service.createQueue(new Queue().setName("TestPeekLockMessageWorks")); + service.sendMessage("TestPeekLockMessageWorks", new Message("Hello Again")); // Act - Message message = service.receiveMessage("TestAlpha", 500, ReceiveMode.PEEK_LOCK); + Message message = service.receiveMessage("TestPeekLockMessageWorks", 500, ReceiveMode.PEEK_LOCK); // Assert byte[] data = new byte[100]; @@ -105,4 +110,47 @@ public void peekLockMessageWorks() throws Exception { assertEquals(11, size); assertEquals("Hello Again", new String(data, 0, size)); } + + @Test + public void peekLockedMessageCanBeCompleted() throws Exception { + // Arrange + service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeCompleted")); + service.sendMessage("TestPeekLockedMessageCanBeCompleted", new Message("Hello Again")); + Message message = service.receiveMessage("TestPeekLockedMessageCanBeCompleted", 1500, ReceiveMode.PEEK_LOCK); + + // Act + String lockToken = message.getLockToken(); + Date lockedUntil = message.getLockedUntilUtc(); + String lockLocation = message.getLockLocation(); + + service.completeMessage(message); + + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNotNull(lockLocation); + } + + @Test + public void peekLockedMessageCanBeAbandoned() throws Exception { + // Arrange + service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeAbandoned")); + service.sendMessage("TestPeekLockedMessageCanBeAbandoned", new Message("Hello Again")); + Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeAbandoned", 1500, ReceiveMode.PEEK_LOCK); + + // Act + String lockToken = peekedMessage.getLockToken(); + Date lockedUntil = peekedMessage.getLockedUntilUtc(); + + service.abandonMessage(peekedMessage); + Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeAbandoned", 1500, ReceiveMode.RECEIVE_AND_DELETE); + + + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNull(receivedMessage.getLockToken()); + assertNull(receivedMessage.getLockedUntilUtc()); + + } } From febd176b9807ef3740ff4a92774c2ec496f490f8 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 16:23:10 -0700 Subject: [PATCH 063/664] Add support for "getBlob" --- .../microsoft/azure/services/blob/Blob.java | 24 +++ .../azure/services/blob/BlobService.java | 3 + .../azure/services/blob/BlobServiceImpl.java | 38 ++++- .../azure/services/blob/GetBlobOptions.java | 51 +++++++ .../blob/BlobServiceIntegrationTest.java | 141 +++++++++++++++--- 5 files changed, 239 insertions(+), 18 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java new file mode 100644 index 0000000000000..ae486e0b8dd59 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.blob; + +import java.io.InputStream; + +public class Blob { + private InputStream contentStream; + private BlobProperties properties; + + public InputStream getContentStream() { + return contentStream; + } + + public void setContentStream(InputStream contentStream) { + this.contentStream = contentStream; + } + + public BlobProperties getProperties() { + return properties; + } + + public void setProperties(BlobProperties properties) { + this.properties = properties; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index f6ede408d98c9..f3d5598677048 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -37,4 +37,7 @@ public interface BlobService { BlobProperties getBlobProperties(String container, String blob); BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); + + Blob getBlob(String container, String blob); + Blob getBlob(String container, String blob, GetBlobOptions options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 4bb2a9ef71930..4edb3ed4e0a71 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -364,6 +364,43 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr ClientResponse response = builder.method("HEAD", ClientResponse.class); + return getBlobPropertiesFromResponse(response); + } + + public Blob getBlob(String container, String blob) { + return getBlob(container, blob, new GetBlobOptions()); + } + + public Blob getBlob(String container, String blob, GetBlobOptions options) { + WebResource webResource = getResource().path(container).path(blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + if (options.getSnapshot() != null) { + webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + } + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + if (options.getRangeStart() != null) { + String range = options.getRangeStart().toString() + "-"; + if (options.getRangeEnd() != null) { + range += options.getRangeEnd().toString(); + } + builder = addOptionalHeader(builder, "Range", range); + } + + ClientResponse response = builder.get(ClientResponse.class); + + BlobProperties properties = getBlobPropertiesFromResponse(response); + Blob blobResult = new Blob(); + blobResult.setProperties(properties); + blobResult.setContentStream(response.getEntityInputStream()); + return blobResult; + } + + private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { BlobProperties properties = new BlobProperties(); // Last-Modified @@ -401,7 +438,6 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr if (response.getHeaders().containsKey("x-ms-blob-sequence-number")) { properties.setSequenceNUmber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); } - return properties; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java new file mode 100644 index 0000000000000..37a2a463bef64 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java @@ -0,0 +1,51 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class GetBlobOptions { + private Date snapshot; + private String leaseId; + private boolean computeRangeMD5; + private Long rangeStart; + private Long rangeEnd; + + public Date getSnapshot() { + return snapshot; + } + + public void setSnapshot(Date snapshot) { + this.snapshot = snapshot; + } + + public String getLeaseId() { + return leaseId; + } + + public void setLeaseId(String leaseId) { + this.leaseId = leaseId; + } + + public boolean isComputeRangeMD5() { + return computeRangeMD5; + } + + public void setComputeRangeMD5(boolean computeRangeMD5) { + this.computeRangeMD5 = computeRangeMD5; + } + + public Long getRangeStart() { + return rangeStart; + } + + public void setRangeStart(Long rangeStart) { + this.rangeStart = rangeStart; + } + + public Long getRangeEnd() { + return rangeEnd; + } + + public void setRangeEnd(Long rangeEnd) { + this.rangeEnd = rangeEnd; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index e4828de90e3f0..b6feaa36b76ec 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -5,7 +5,15 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.BufferedReader; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; import java.util.EnumSet; import java.util.HashMap; @@ -245,20 +253,17 @@ public void putPageBlobWithOptionsWorks() throws Exception { BlobService contract = config.create(BlobService.class); // Act - contract.putPageBlob( - "mycontainer1", - "test", - 512, - new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF8").setBlobContentLanguage("en-us") - /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF8") - /* .setContentMD5("1234") */.setContentType("text/plain")); + contract.putPageBlob("mycontainer1", "test", 512, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + .setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); BlobProperties props = contract.getBlobProperties("mycontainer1", "test"); // Assert assertNotNull(props); assertEquals("test", props.getCacheControl()); - assertEquals("UTF8", props.getContentEncoding()); + assertEquals("UTF-8", props.getContentEncoding()); assertEquals("en-us", props.getContentLanguage()); assertEquals("text/plain", props.getContentType()); assertEquals(512, props.getContentLength()); @@ -291,23 +296,54 @@ public void putBlockBlobWithOptionsWorks() throws Exception { BlobService contract = config.create(BlobService.class); // Act - contract.putBlockBlob( - "mycontainer1", - "test2", - new ByteArrayInputStream("some content".getBytes()), - new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF8").setBlobContentLanguage("en-us") - /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF8") - /* .setContentMD5("1234") */.setContentType("text/plain")); + String content = "some content"; + contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); BlobProperties props = contract.getBlobProperties("mycontainer1", "test2"); // Assert assertNotNull(props); assertEquals("test", props.getCacheControl()); - assertEquals("UTF8", props.getContentEncoding()); + assertEquals("UTF-8", props.getContentEncoding()); assertEquals("en-us", props.getContentLanguage()); assertEquals("text/plain", props.getContentType()); - assertEquals(512, props.getContentLength()); + 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()); + assertEquals(0, props.getSequenceNumber()); + } + + @Test + public void getBlockBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + String content = "some content"; + contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); + + Blob blob = contract.getBlob("mycontainer1", "test2"); + BlobProperties props = blob.getProperties(); + + // Assert + assertNotNull(props); + assertEquals("test", props.getCacheControl()); + assertEquals("UTF-8", props.getContentEncoding()); + assertEquals("en-us", props.getContentLanguage()); + assertEquals("text/plain", props.getContentType()); + assertEquals(content.length(), props.getContentLength()); assertNotNull(props.getEtag()); assertNull(props.getContentMD5()); assertNotNull(props.getMetadata()); @@ -316,5 +352,76 @@ public void putBlockBlobWithOptionsWorks() throws Exception { assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); assertEquals(0, props.getSequenceNumber()); + assertEquals(content, inputStreamToString(blob.getContentStream(), "UTF-8")); + } + + @Test + public void getPageBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + contract.putPageBlob("mycontainer1", "test", 4096, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + .setBlobContentLanguage("en-us") + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); + + Blob blob = contract.getBlob("mycontainer1", "test"); + BlobProperties props = blob.getProperties(); + + // Assert + assertNotNull(props); + assertEquals("test", props.getCacheControl()); + assertEquals("UTF-8", props.getContentEncoding()); + assertEquals("en-us", props.getContentLanguage()); + assertEquals("text/plain", props.getContentType()); + 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()); + assertEquals(0, props.getSequenceNumber()); + assertEquals(4096, inputStreamToByteArray(blob.getContentStream()).length); + } + + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + byte[] buffer = new byte[1024]; + try { + while (true) { + int n = inputStream.read(buffer); + if (n == -1) + break; + outputStream.write(buffer, 0, n); + } + } + finally { + inputStream.close(); + } + return outputStream.toByteArray(); + } + + public String inputStreamToString(InputStream inputStream, String encoding) throws IOException { + Writer writer = new StringWriter(); + + char[] buffer = new char[1024]; + try { + Reader reader = new BufferedReader(new InputStreamReader(inputStream, encoding)); + while (true) { + int n = reader.read(buffer); + if (n == -1) + break; + writer.write(buffer, 0, n); + } + } + finally { + inputStream.close(); + } + return writer.toString(); } } From c09647f8b108deddda423297f1d04b20295d184b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 3 Nov 2011 16:44:30 -0700 Subject: [PATCH 064/664] Attempting to implement abandonMessage to release lock Should this really be "deleteLock" or "deleteMessageLock"? --- .../implementation/ServiceBusServiceImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 90ad46d4623ed..a25eac4c266f6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -135,8 +135,17 @@ public Message receiveMessage(String topicPath, String subscriptionName, } public void abandonMessage(Message message) throws ServiceException { - // TODO Auto-generated method stub - + try { + getChannel() + .resource(message.getLockLocation()) + .delete(); + } + catch(UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch(ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } public void completeMessage(Message message) throws ServiceException { From 26c600251b13377795095d2db14f6a6fcf0bd8d4 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 17:02:24 -0700 Subject: [PATCH 065/664] Rename configuration class --- .../java/com/microsoft/azure/services/blob/BlobConfig.java | 7 ------- .../microsoft/azure/services/blob/BlobConfiguration.java | 7 +++++++ .../com/microsoft/azure/services/blob/BlobServiceImpl.java | 2 +- .../azure/services/blob/BlobSharedKeyLiteFilter.java | 2 +- .../microsoft/azure/services/blob/IntegrationTestBase.java | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java deleted file mode 100644 index 7b2b78074e853..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfig.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.azure.services.blob; - -public interface BlobConfig { - public final String CONFIG_ACCOUNT_NAME = "blob.accountName"; - public final String CONFIG_ACCOUNT_KEY = "blob.accountKey"; - public final String CONFIG_URL = "blob.url"; -} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java new file mode 100644 index 0000000000000..c0dab4926de04 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java @@ -0,0 +1,7 @@ +package com.microsoft.azure.services.blob; + +public class BlobConfiguration { + public final static String ACCOUNT_NAME = "blob.accountName"; + public final static String ACCOUNT_KEY = "blob.accountKey"; + public final static String URL = "blob.url"; +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 4edb3ed4e0a71..184e325a54227 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -26,7 +26,7 @@ public class BlobServiceImpl implements BlobService { private final String url; @Inject - public BlobServiceImpl(Client channel, @Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_URL) String url, + public BlobServiceImpl(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, // TODO: How to make this configurable though code? BlobSharedKeyLiteFilter filter) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index 5c694ea4b9bb3..66a9fb5bc385d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -18,7 +18,7 @@ public class BlobSharedKeyLiteFilter extends ClientFilter { private final String accountName; private final HmacSHA256Sign signer; - public BlobSharedKeyLiteFilter(@Named(BlobConfig.CONFIG_ACCOUNT_NAME) String accountName, @Named(BlobConfig.CONFIG_ACCOUNT_KEY) String accountKey) { + public BlobSharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { this.accountName = accountName; // TODO: How to make this configurable? diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index af6ade4af93c7..4991e86f361d4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -8,9 +8,9 @@ public abstract class IntegrationTestBase { protected Configuration createConfiguration() { Configuration config = new Configuration(); - config.setProperty(BlobConfig.CONFIG_ACCOUNT_NAME, "xxx"); - config.setProperty(BlobConfig.CONFIG_ACCOUNT_KEY, "xxx"); - config.setProperty(BlobConfig.CONFIG_URL, "http://azuresdkdev.blob.core.windows.net"); + config.setProperty(BlobConfiguration.ACCOUNT_NAME, "xxx"); + config.setProperty(BlobConfiguration.ACCOUNT_KEY, "xxx"); + config.setProperty(BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); From e5ea3e6d87d13a13cbd3dab3bd947985c17ff9d6 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 17:46:20 -0700 Subject: [PATCH 066/664] Add support for "deleteBlob" --- .../azure/services/blob/BlobService.java | 3 ++ .../azure/services/blob/BlobServiceImpl.java | 19 ++++++++++ .../services/blob/DeleteBlobOptions.java | 38 +++++++++++++++++++ .../azure/services/blob/GetBlobOptions.java | 15 +++++--- .../blob/GetBlobPropertiesOptions.java | 6 ++- .../blob/BlobServiceIntegrationTest.java | 17 ++++++++- 6 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index f3d5598677048..addbe026bb124 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -40,4 +40,7 @@ public interface BlobService { Blob getBlob(String container, String blob); Blob getBlob(String container, String blob, GetBlobOptions options); + + void deleteBlob(String container, String blob); + void deleteBlob(String container, String blob, DeleteBlobOptions options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 184e325a54227..363f3d7ef0b1a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -440,4 +440,23 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { } return properties; } + + public void deleteBlob(String container, String blob) { + deleteBlob(container, blob, new DeleteBlobOptions()); + } + + public void deleteBlob(String container, String blob, DeleteBlobOptions options) { + WebResource webResource = getResource().path(container + "/" + blob); + if (options.getSnapshot() != null) { + webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + } + + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphots()); + + builder.delete(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java new file mode 100644 index 0000000000000..9a70a0cdaa375 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java @@ -0,0 +1,38 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class DeleteBlobOptions { + //TODO: Date? + private Date snapshot; + private String leaseId; + //TODO: Enum? + private String deleteSnaphots; + + public Date getSnapshot() { + return snapshot; + } + + public DeleteBlobOptions setSnapshot(Date snapshot) { + this.snapshot = snapshot; + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public DeleteBlobOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public String getDeleteSnaphots() { + return deleteSnaphots; + } + + public DeleteBlobOptions setDeleteSnaphots(String deleteSnaphots) { + this.deleteSnaphots = deleteSnaphots; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java index 37a2a463bef64..63ae3405e71e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java @@ -13,39 +13,44 @@ public Date getSnapshot() { return snapshot; } - public void setSnapshot(Date snapshot) { + public GetBlobOptions setSnapshot(Date snapshot) { this.snapshot = snapshot; + return this; } public String getLeaseId() { return leaseId; } - public void setLeaseId(String leaseId) { + public GetBlobOptions setLeaseId(String leaseId) { this.leaseId = leaseId; + return this; } public boolean isComputeRangeMD5() { return computeRangeMD5; } - public void setComputeRangeMD5(boolean computeRangeMD5) { + public GetBlobOptions setComputeRangeMD5(boolean computeRangeMD5) { this.computeRangeMD5 = computeRangeMD5; + return this; } public Long getRangeStart() { return rangeStart; } - public void setRangeStart(Long rangeStart) { + public GetBlobOptions setRangeStart(Long rangeStart) { this.rangeStart = rangeStart; + return this; } public Long getRangeEnd() { return rangeEnd; } - public void setRangeEnd(Long rangeEnd) { + public GetBlobOptions setRangeEnd(Long rangeEnd) { this.rangeEnd = rangeEnd; + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java index e88d37a720b51..1e3c78f759858 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -10,15 +10,17 @@ public Date getSnapshot() { return snapshot; } - public void setSnapshot(Date snapshot) { + public GetBlobPropertiesOptions setSnapshot(Date snapshot) { this.snapshot = snapshot; + return this; } public String getLeaseId() { return leaseId; } - public void setLeaseId(String leaseId) { + public GetBlobPropertiesOptions setLeaseId(String leaseId) { this.leaseId = leaseId; + return this; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index b6feaa36b76ec..16e6890b67dc2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -388,6 +388,21 @@ public void getPageBlobWorks() throws Exception { assertEquals(4096, inputStreamToByteArray(blob.getContentStream()).length); } + @Test + public void deleteBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService contract = config.create(BlobService.class); + + // Act + String content = "some content"; + contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); + + contract.deleteBlob("mycontainer1", "test2"); + + // Assert + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); @@ -406,7 +421,7 @@ private byte[] inputStreamToByteArray(InputStream inputStream) throws IOExceptio return outputStream.toByteArray(); } - public String inputStreamToString(InputStream inputStream, String encoding) throws IOException { + private String inputStreamToString(InputStream inputStream, String encoding) throws IOException { Writer writer = new StringWriter(); char[] buffer = new char[1024]; From eb15e5e27f76f1314cbd85df65a6c3e99e0ad8ca Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 18:49:28 -0700 Subject: [PATCH 067/664] Add support for "createBlobSnapshot" --- .../azure/services/blob/BlobService.java | 5 + .../azure/services/blob/BlobServiceImpl.java | 63 +++++--- .../azure/services/blob/BlobSnapshot.java | 33 ++++ .../blob/CreateBlobSnapshotOptions.java | 32 ++++ .../azure/services/blob/DateMapper.java | 10 ++ .../services/blob/DeleteBlobOptions.java | 11 +- .../azure/services/blob/GetBlobOptions.java | 7 +- .../blob/GetBlobPropertiesOptions.java | 7 +- .../blob/BlobServiceIntegrationTest.java | 144 ++++++++++++------ 9 files changed, 222 insertions(+), 90 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index addbe026bb124..f1ad7129ecd17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -43,4 +43,9 @@ public interface BlobService { void deleteBlob(String container, String blob); void deleteBlob(String container, String blob, DeleteBlobOptions options); + + BlobSnapshot createBlobSnapshot(String container, String blob); + BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options); + + void setBlobProperties(BlobProperties properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 363f3d7ef0b1a..8222ca897b177 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.blob; import java.io.InputStream; -import java.text.ParseException; import java.util.EnumSet; import java.util.HashMap; import java.util.List; @@ -141,13 +140,8 @@ private ContainerProperties getContainerPropertiesImpl(String container, String ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); - try { - properties.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); - } - catch (ParseException e) { - // Server returned an invalid/unsupported date format - throw new IllegalArgumentException(e); - } + properties.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + // Metadata HashMap metadata = new HashMap(); for (Entry> entry : response.getHeaders().entrySet()) { @@ -172,13 +166,7 @@ public ContainerACL getContainerACL(String container) { acl.setSignedIdentifiers(si.getSignedIdentifiers()); acl.setPublicAccess(response.getHeaders().getFirst(X_MS_BLOB_PUBLIC_ACCESS)); acl.setEtag(response.getHeaders().getFirst("ETag")); - try { - acl.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); - } - catch (ParseException e) { - // TODO: Is this the right way to handle this? - throw new IllegalArgumentException(e); - } + acl.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return acl; } @@ -356,7 +344,7 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); } Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -376,7 +364,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) { webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); } Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -404,13 +392,7 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { BlobProperties properties = new BlobProperties(); // Last-Modified - try { - properties.setLastModified(new DateMapper().parse(response.getHeaders().getFirst("Last-Modified"))); - } - catch (ParseException e) { - // Server returned an invalid/unsupported date format - throw new IllegalArgumentException(e); - } + properties.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); // Metadata HashMap metadata = new HashMap(); @@ -448,7 +430,7 @@ public void deleteBlob(String container, String blob) { public void deleteBlob(String container, String blob, DeleteBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", new DateMapper().format(options.getSnapshot())); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); } webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); @@ -459,4 +441,35 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) builder.delete(); } + + public void setBlobProperties(BlobProperties properties) { + // TODO Auto-generated method stub + } + + public BlobSnapshot createBlobSnapshot(String container, String blob) { + return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); + } + + public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) { + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + // Metadata + for (Entry entry : options.getMetadata().entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + // TODO: Conditional headers (If Match, etc.) + + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + + BlobSnapshot blobSnapshot = new BlobSnapshot(); + blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); + blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); + blobSnapshot.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + + return blobSnapshot; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java new file mode 100644 index 0000000000000..78ee8f8286072 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java @@ -0,0 +1,33 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class BlobSnapshot { + private String snapshot; + private String etag; + private Date lastModified; + + public String getSnapshot() { + return snapshot; + } + + public void setSnapshot(String snapshot) { + this.snapshot = snapshot; + } + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java new file mode 100644 index 0000000000000..e0e753743507f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java @@ -0,0 +1,32 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class CreateBlobSnapshotOptions { + private HashMap metadata = new HashMap(); + private String leaseId; + //TODO: Add Ifxxx headers + + public HashMap getMetadata() { + return metadata; + } + + public CreateBlobSnapshotOptions setMetadata(HashMap metadata) { + this.metadata = metadata; + return this; + } + + public CreateBlobSnapshotOptions addMetadata(String key, String value) { + this.getMetadata().put(key, value); + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public CreateBlobSnapshotOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java index 4b712375ff76f..264918c529e3d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java @@ -18,6 +18,16 @@ public Date parse(String date) throws ParseException { return getFormat().parse(date); } + public Date parseNoThrow(String date) { + try { + return parse(date); + } + catch (ParseException e) { + //TODO: Is it better to return null or throw a runtime exception? + return null; + } + } + private DateFormat getFormat() { DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java index 9a70a0cdaa375..3dab5b8b1f34c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java @@ -1,19 +1,16 @@ package com.microsoft.azure.services.blob; -import java.util.Date; - public class DeleteBlobOptions { - //TODO: Date? - private Date snapshot; + private String snapshot; private String leaseId; - //TODO: Enum? + // TODO: Enum? private String deleteSnaphots; - public Date getSnapshot() { + public String getSnapshot() { return snapshot; } - public DeleteBlobOptions setSnapshot(Date snapshot) { + public DeleteBlobOptions setSnapshot(String snapshot) { this.snapshot = snapshot; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java index 63ae3405e71e2..4d755182e559d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java @@ -1,19 +1,18 @@ package com.microsoft.azure.services.blob; -import java.util.Date; public class GetBlobOptions { - private Date snapshot; + private String snapshot; private String leaseId; private boolean computeRangeMD5; private Long rangeStart; private Long rangeEnd; - public Date getSnapshot() { + public String getSnapshot() { return snapshot; } - public GetBlobOptions setSnapshot(Date snapshot) { + public GetBlobOptions setSnapshot(String snapshot) { this.snapshot = snapshot; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java index 1e3c78f759858..d4b7f560601b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -1,16 +1,15 @@ package com.microsoft.azure.services.blob; -import java.util.Date; public class GetBlobPropertiesOptions { - private Date snapshot; + private String snapshot; private String leaseId; - public Date getSnapshot() { + public String getSnapshot() { return snapshot; } - public GetBlobPropertiesOptions setSnapshot(Date snapshot) { + public GetBlobPropertiesOptions setSnapshot(String snapshot) { this.snapshot = snapshot; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 16e6890b67dc2..85e7670ab3cfa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -27,11 +27,11 @@ public class BlobServiceIntegrationTest extends IntegrationTestBase { public void createContainerWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.createContainer("foo"); - contract.deleteContainer("foo"); + service.createContainer("foo"); + service.deleteContainer("foo"); // Assert } @@ -40,19 +40,19 @@ public void createContainerWorks() throws Exception { public void createContainerWithMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.createContainer("foo2", new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); + service.createContainer("foo2", new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); - ContainerProperties prop = contract.getContainerMetadata("foo2"); - ContainerProperties prop2 = contract.getContainerProperties("foo2"); - ContainerACL acl = contract.getContainerACL("foo2"); + ContainerProperties prop = service.getContainerMetadata("foo2"); + ContainerProperties prop2 = service.getContainerProperties("foo2"); + ContainerACL acl = service.getContainerACL("foo2"); - ListContainersResults results2 = contract.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( + ListContainersResults results2 = service.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( EnumSet.of(ContainerListingDetails.METADATA))); - contract.deleteContainer("foo2"); + service.deleteContainer("foo2"); // Assert assertNotNull(prop); @@ -90,18 +90,18 @@ public void createContainerWithMetadataWorks() throws Exception { public void setContainerMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.createContainer("foo3"); + service.createContainer("foo3"); HashMap metadata = new HashMap(); metadata.put("test", "bar"); metadata.put("blah", "bleah"); - contract.setContainerMetadata("foo3", metadata); - ContainerProperties prop = contract.getContainerMetadata("foo3"); + service.setContainerMetadata("foo3", metadata); + ContainerProperties prop = service.getContainerMetadata("foo3"); - contract.deleteContainer("foo3"); + service.deleteContainer("foo3"); // Assert assertNotNull(prop); @@ -119,18 +119,18 @@ public void setContainerMetadataWorks() throws Exception { public void setContainerACLWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.createContainer("foo4"); + service.createContainer("foo4"); ContainerACL acl = new ContainerACL(); acl.setPublicAccess("blob"); acl.AddSignedIdentifier("test", "2010-01-01", "2020-01-01", "rwd"); - contract.setContainerACL("foo4", acl); + service.setContainerACL("foo4", acl); - ContainerACL acl2 = contract.getContainerACL("foo4"); - contract.deleteContainer("foo4"); + ContainerACL acl2 = service.getContainerACL("foo4"); + service.deleteContainer("foo4"); // Assert assertNotNull(acl2); @@ -149,10 +149,10 @@ public void setContainerACLWorks() throws Exception { public void listContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = contract.listContainers(); + ListContainersResults results = service.listContainers(); // Assert assertNotNull(results); @@ -169,10 +169,10 @@ public void listContainersWorks() throws Exception { public void listContainersWithPaginationWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = contract.listContainers(new ListContainersOptions().setMaxResults(3)); + ListContainersResults results = service.listContainers(new ListContainersOptions().setMaxResults(3)); // Assert assertNotNull(results); @@ -181,7 +181,7 @@ public void listContainersWithPaginationWorks() throws Exception { assertEquals(3, results.getMaxResults()); // Act - ListContainersResults results2 = contract.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); + ListContainersResults results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); // Assert assertNotNull(results2); @@ -194,10 +194,10 @@ public void listContainersWithPaginationWorks() throws Exception { public void listContainersWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = contract.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); + ListContainersResults results = service.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); // Assert assertNotNull(results); @@ -210,10 +210,10 @@ public void listContainersWithPrefixWorks() throws Exception { public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - ListBlobsResults results = contract.listBlobs("mycontainer11"); + ListBlobsResults results = service.listBlobs("mycontainer11"); // Assert assertNotNull(results); @@ -224,10 +224,10 @@ public void listBlobsWorks() throws Exception { public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - ListBlobsResults results = contract.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); + ListBlobsResults results = service.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); // Assert assertNotNull(results); @@ -238,10 +238,10 @@ public void listBlobsWithPrefixWorks() throws Exception { public void putPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.putPageBlob("mycontainer1", "test", 512); + service.putPageBlob("mycontainer1", "test", 512); // Assert } @@ -250,15 +250,15 @@ public void putPageBlobWorks() throws Exception { public void putPageBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.putPageBlob("mycontainer1", "test", 512, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.putPageBlob("mycontainer1", "test", 512, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") .setBlobContentLanguage("en-us") /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - BlobProperties props = contract.getBlobProperties("mycontainer1", "test"); + BlobProperties props = service.getBlobProperties("mycontainer1", "test"); // Assert assertNotNull(props); @@ -281,10 +281,10 @@ public void putPageBlobWithOptionsWorks() throws Exception { public void putBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); + service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); // Assert } @@ -293,16 +293,16 @@ public void putBlockBlobWorks() throws Exception { public void putBlockBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act String content = "some content"; - contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - BlobProperties props = contract.getBlobProperties("mycontainer1", "test2"); + BlobProperties props = service.getBlobProperties("mycontainer1", "test2"); // Assert assertNotNull(props); @@ -321,20 +321,64 @@ public void putBlockBlobWithOptionsWorks() throws Exception { assertEquals(0, props.getSequenceNumber()); } + @Test + public void createBlobSnapshotWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test3"; + service.putBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); + BlobSnapshot snapshot = service.createBlobSnapshot(container, blob); + + // Assert + assertNotNull(snapshot); + assertNotNull(snapshot.getEtag()); + assertNotNull(snapshot.getLastModified()); + assertNotNull(snapshot.getSnapshot()); + } + + @Test + public void createBlobSnapshotWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test3"; + service.putBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); + BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); + + BlobProperties props = 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")); + } + + @Test public void getBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act String content = "some content"; - contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - Blob blob = contract.getBlob("mycontainer1", "test2"); + Blob blob = service.getBlob("mycontainer1", "test2"); BlobProperties props = blob.getProperties(); // Assert @@ -359,15 +403,15 @@ public void getBlockBlobWorks() throws Exception { public void getPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act - contract.putPageBlob("mycontainer1", "test", 4096, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.putPageBlob("mycontainer1", "test", 4096, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") .setBlobContentLanguage("en-us") /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - Blob blob = contract.getBlob("mycontainer1", "test"); + Blob blob = service.getBlob("mycontainer1", "test"); BlobProperties props = blob.getProperties(); // Assert @@ -392,13 +436,13 @@ public void getPageBlobWorks() throws Exception { public void deleteBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService contract = config.create(BlobService.class); + BlobService service = config.create(BlobService.class); // Act String content = "some content"; - contract.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); - contract.deleteBlob("mycontainer1", "test2"); + service.deleteBlob("mycontainer1", "test2"); // Assert } From 014164d24616b4e21bff87729f2198bc7da95792 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 18:58:03 -0700 Subject: [PATCH 068/664] Rename "pubXxxBlob" to "createXxxBlob" --- .../azure/services/blob/BlobService.java | 14 +++++++--- .../azure/services/blob/BlobServiceImpl.java | 14 +++++----- ...lobOptions.java => CreateBlobOptions.java} | 28 +++++++++---------- .../blob/BlobServiceIntegrationTest.java | 26 ++++++++--------- 4 files changed, 44 insertions(+), 38 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{PutBlobOptions.java => CreateBlobOptions.java} (72%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index f1ad7129ecd17..5b05698b84ec1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -29,22 +29,28 @@ public interface BlobService { ListBlobsResults listBlobs(String container, ListBlobsOptions options); - void putPageBlob(String container, String blob, int length); - void putPageBlob(String container, String blob, int length, PutBlobOptions options); + void createPageBlob(String container, String blob, int length); - void putBlockBlob(String container, String blob, InputStream content); - void putBlockBlob(String container, String blob, InputStream content, PutBlobOptions options); + void createPageBlob(String container, String blob, int length, CreateBlobOptions options); + + void createBlockBlob(String container, String blob, InputStream content); + + void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options); BlobProperties getBlobProperties(String container, String blob); + BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); Blob getBlob(String container, String blob); + Blob getBlob(String container, String blob, GetBlobOptions options); void deleteBlob(String container, String blob); + void deleteBlob(String container, String blob, DeleteBlobOptions options); BlobSnapshot createBlobSnapshot(String container, String blob); + BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options); void setBlobProperties(BlobProperties properties); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 8222ca897b177..ec6e61b649800 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -266,11 +266,11 @@ public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResults.class); } - public void putPageBlob(String container, String blob, int length) { - putPageBlob(container, blob, length, new PutBlobOptions()); + public void createPageBlob(String container, String blob, int length) { + createPageBlob(container, blob, length, new CreateBlobOptions()); } - public void putPageBlob(String container, String blob, int length, PutBlobOptions options) { + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -291,11 +291,11 @@ public void putPageBlob(String container, String blob, int length, PutBlobOption builder.type("text/plain").put(""); } - public void putBlockBlob(String container, String blob, InputStream content) { - putBlockBlob(container, blob, content, new PutBlobOptions()); + public void createBlockBlob(String container, String blob, InputStream content) { + createBlockBlob(container, blob, content, new CreateBlobOptions()); } - public void putBlockBlob(String container, String blob, InputStream content, PutBlobOptions options) { + public void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -306,7 +306,7 @@ public void putBlockBlob(String container, String blob, InputStream content, Put builder.put(content); } - private Builder addPutBlobHeaders(PutBlobOptions options, Builder builder) { + private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); if (options.getContentType() == null) { // This is technically the default, but we explicitly add here to diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java similarity index 72% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java index a831ee7b60fa5..40d008feaa6f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/PutBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class PutBlobOptions { +public class CreateBlobOptions { private String contentType; private String contentEncoding; private String contentLanguage; @@ -21,7 +21,7 @@ public String getContentType() { return contentType; } - public PutBlobOptions setContentType(String contentType) { + public CreateBlobOptions setContentType(String contentType) { this.contentType = contentType; return this; } @@ -30,7 +30,7 @@ public String getContentEncoding() { return contentEncoding; } - public PutBlobOptions setContentEncoding(String contentEncoding) { + public CreateBlobOptions setContentEncoding(String contentEncoding) { this.contentEncoding = contentEncoding; return this; } @@ -39,7 +39,7 @@ public String getContentLanguage() { return contentLanguage; } - public PutBlobOptions setContentLanguage(String contentLanguage) { + public CreateBlobOptions setContentLanguage(String contentLanguage) { this.contentLanguage = contentLanguage; return this; } @@ -48,7 +48,7 @@ public String getContentMD5() { return contentMD5; } - public PutBlobOptions setContentMD5(String contentMD5) { + public CreateBlobOptions setContentMD5(String contentMD5) { this.contentMD5 = contentMD5; return this; } @@ -57,7 +57,7 @@ public String getCacheControl() { return cacheControl; } - public PutBlobOptions setCacheControl(String cacheControl) { + public CreateBlobOptions setCacheControl(String cacheControl) { this.cacheControl = cacheControl; return this; } @@ -66,7 +66,7 @@ public String getBlobContentType() { return blobContentType; } - public PutBlobOptions setBlobContentType(String blobContentType) { + public CreateBlobOptions setBlobContentType(String blobContentType) { this.blobContentType = blobContentType; return this; } @@ -75,7 +75,7 @@ public String getBlobContentEncoding() { return blobContentEncoding; } - public PutBlobOptions setBlobContentEncoding(String blobContentEncoding) { + public CreateBlobOptions setBlobContentEncoding(String blobContentEncoding) { this.blobContentEncoding = blobContentEncoding; return this; } @@ -84,7 +84,7 @@ public String getBlobContentLanguage() { return blobContentLanguage; } - public PutBlobOptions setBlobContentLanguage(String blobContentLanguage) { + public CreateBlobOptions setBlobContentLanguage(String blobContentLanguage) { this.blobContentLanguage = blobContentLanguage; return this; } @@ -93,7 +93,7 @@ public String getBlobContentMD5() { return blobContentMD5; } - public PutBlobOptions setBlobContentMD5(String blobContentMD5) { + public CreateBlobOptions setBlobContentMD5(String blobContentMD5) { this.blobContentMD5 = blobContentMD5; return this; } @@ -102,7 +102,7 @@ public String getBlobCacheControl() { return blobCacheControl; } - public PutBlobOptions setBlobCacheControl(String blobCacheControl) { + public CreateBlobOptions setBlobCacheControl(String blobCacheControl) { this.blobCacheControl = blobCacheControl; return this; } @@ -111,7 +111,7 @@ public HashMap getMetadata() { return metadata; } - public PutBlobOptions setMetadata(HashMap metadata) { + public CreateBlobOptions setMetadata(HashMap metadata) { this.metadata = metadata; return this; } @@ -120,7 +120,7 @@ public String getLeaseId() { return leaseId; } - public PutBlobOptions setLeaseId(String leaseId) { + public CreateBlobOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } @@ -129,7 +129,7 @@ public Long getSequenceNumber() { return sequenceNumber; } - public PutBlobOptions setSequenceNumber(Long sequenceNumber) { + public CreateBlobOptions setSequenceNumber(Long sequenceNumber) { this.sequenceNumber = sequenceNumber; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 85e7670ab3cfa..016c420361c48 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -235,25 +235,25 @@ public void listBlobsWithPrefixWorks() throws Exception { } @Test - public void putPageBlobWorks() throws Exception { + public void createPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); // Act - service.putPageBlob("mycontainer1", "test", 512); + service.createPageBlob("mycontainer1", "test", 512); // Assert } @Test - public void putPageBlobWithOptionsWorks() throws Exception { + public void createPageBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); // Act - service.putPageBlob("mycontainer1", "test", 512, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.createPageBlob("mycontainer1", "test", 512, 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")); @@ -278,26 +278,26 @@ public void putPageBlobWithOptionsWorks() throws Exception { } @Test - public void putBlockBlobWorks() throws Exception { + public void createBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); // Act - service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); + service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); // Assert } @Test - public void putBlockBlobWithOptionsWorks() throws Exception { + public void createBlockBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); // Act String content = "some content"; - service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + service.createBlockBlob("mycontainer1", "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")); @@ -330,7 +330,7 @@ public void createBlobSnapshotWorks() throws Exception { // Act String container = "mycontainer1"; String blob = "test3"; - service.putBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); + service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); BlobSnapshot snapshot = service.createBlobSnapshot(container, blob); // Assert @@ -349,7 +349,7 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { // Act String container = "mycontainer1"; String blob = "test3"; - service.putBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); + service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); BlobProperties props = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); @@ -373,7 +373,7 @@ public void getBlockBlobWorks() throws Exception { // Act String content = "some content"; - service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new PutBlobOptions().setBlobCacheControl("test") + service.createBlockBlob("mycontainer1", "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")); @@ -406,7 +406,7 @@ public void getPageBlobWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.putPageBlob("mycontainer1", "test", 4096, new PutBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.createPageBlob("mycontainer1", "test", 4096, 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")); @@ -440,7 +440,7 @@ public void deleteBlobWorks() throws Exception { // Act String content = "some content"; - service.putBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); service.deleteBlob("mycontainer1", "test2"); From 2eb7cfd63c68f907c35aaee5cb85a8b7b7bce038 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 20:29:07 -0700 Subject: [PATCH 069/664] Add support for "copyBlob" --- .../azure/services/blob/BlobService.java | 4 ++ .../azure/services/blob/BlobServiceImpl.java | 49 +++++++++++++++++++ .../azure/services/blob/CopyBlobOptions.java | 44 +++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 40 ++++++++++++--- 4 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 5b05698b84ec1..84b8db30197e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -53,5 +53,9 @@ public interface BlobService { BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options); + void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob); + + void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options); + void setBlobProperties(BlobProperties properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index ec6e61b649800..f619f42b34cba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -472,4 +472,53 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob return blobSnapshot; } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) { + copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); + } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { + WebResource webResource = getResource().path(destinationContainer + "/" + destinationBlob); + webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); + + // Specifies the name of the source blob, in one of the following + // formats: + // Blob in named container: /accountName/containerName/blobName + // + // Snapshot in named container: + // /accountName/containerName/blobName?snapshot= + // + // Blob in root container: /accountName/blobName + // + // Snapshot in root container: /accountName/blobName?snapshot= + String sourceName = "/" + this.accountName; + if (sourceContainer != null) { + sourceName += "/" + sourceContainer; + } + sourceName += "/" + sourceBlob; + if (options.getSourceSnapshot() != null) { + sourceName += "?snapshot=" + options.getSourceSnapshot(); + } + builder = addOptionalHeader(builder, "x-ms-copy-source", sourceName); + + // Metadata + for (Entry entry : options.getMetadata().entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + // TODO: Conditional headers (If Match, etc.) + + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + builder.type("text/plain").put(""); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java new file mode 100644 index 0000000000000..16b8058f0a815 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java @@ -0,0 +1,44 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class CopyBlobOptions { + private String leaseId; + private String sourceLeaseId; + private String sourceSnapshot; + private HashMap metadata = new HashMap(); + + // TODO: IfMatch options + + public String getSourceSnapshot() { + return sourceSnapshot; + } + + public void setSourceSnapshot(String sourceSnapshot) { + this.sourceSnapshot = sourceSnapshot; + } + + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } + + public String getLeaseId() { + return leaseId; + } + + public void setLeaseId(String leaseId) { + this.leaseId = leaseId; + } + + public String getSourceLeaseId() { + return sourceLeaseId; + } + + public void setSourceLeaseId(String sourceLeaseId) { + this.sourceLeaseId = sourceLeaseId; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 016c420361c48..5916e9df219d3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -297,8 +297,8 @@ public void createBlockBlobWithOptionsWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new CreateBlobOptions().setBlobCacheControl("test") - .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + service.createBlockBlob("mycontainer1", "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")); @@ -350,7 +350,8 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { String container = "mycontainer1"; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); + BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, + new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); BlobProperties props = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); @@ -364,7 +365,6 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { assertTrue(props.getMetadata().containsValue("bleah")); } - @Test public void getBlockBlobWorks() throws Exception { // Arrange @@ -373,8 +373,8 @@ public void getBlockBlobWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), new CreateBlobOptions().setBlobCacheControl("test") - .setBlobContentEncoding("UTF-8").setBlobContentLanguage("en-us") + service.createBlockBlob("mycontainer1", "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")); @@ -447,6 +447,34 @@ public void deleteBlobWorks() throws Exception { // Assert } + @Test + public void copyBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String content = "some content2"; + service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.copyBlob("mycontainer1", "test5", "mycontainer2", "test6"); + + Blob blob = service.getBlob("mycontainer1", "test5"); + BlobProperties props = blob.getProperties(); + + // Assert + 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()); + assertEquals(0, props.getSequenceNumber()); + assertEquals(content, inputStreamToString(blob.getContentStream(), "UTF-8")); + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From 332d3ea7d140396361bfb4d7c7f3a583e0b420fe Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 3 Nov 2011 20:52:21 -0700 Subject: [PATCH 070/664] Add support for lease actions --- .../azure/services/blob/BlobService.java | 8 +++ .../azure/services/blob/BlobServiceImpl.java | 43 ++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 51 +++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 84b8db30197e1..659367d0ca09c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -57,5 +57,13 @@ public interface BlobService { void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options); + String acquireLease(String container, String blob); + + String renewLease(String container, String blob, String leaseId); + + void releaseLease(String container, String blob, String leaseId); + + void breakLease(String container, String blob, String leaseId); + void setBlobProperties(BlobProperties properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index f619f42b34cba..c37ad7c232b3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -463,6 +463,13 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob // TODO: Conditional headers (If Match, etc.) + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); BlobSnapshot blobSnapshot = new BlobSnapshot(); @@ -521,4 +528,40 @@ public void copyBlob(String destinationContainer, String destinationBlob, String // producing the authorization hmac. builder.type("text/plain").put(""); } + + public String acquireLease(String container, String blob) { + return putLeaseImpl("acquire", container, blob, null); + } + + public String renewLease(String container, String blob, String leaseId) { + return putLeaseImpl("renew", container, blob, leaseId); + } + + public void releaseLease(String container, String blob, String leaseId) { + putLeaseImpl("release", container, blob, leaseId); + } + + public void breakLease(String container, String blob, String leaseId) { + putLeaseImpl("break", container, blob, leaseId); + } + + private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId){ + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "lease"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); + builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); + + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + + return response.getHeaders().getFirst("x-ms-lease-id"); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 5916e9df219d3..345025cee9de8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -475,6 +475,57 @@ public void copyBlobWorks() throws Exception { assertEquals(content, inputStreamToString(blob.getContentStream(), "UTF-8")); } + @Test + public void acquireLeaseWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String content = "some content2"; + service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + String leaseId = service.acquireLease("mycontainer2", "test6"); + service.releaseLease("mycontainer2", "test6", leaseId); + + // Assert + assertNotNull(leaseId); + } + + @Test + public void renewLeaseWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String content = "some content2"; + service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + String leaseId = service.acquireLease("mycontainer2", "test6"); + String leaseId2 = service.renewLease("mycontainer2", "test6", leaseId); + service.releaseLease("mycontainer2", "test6", leaseId); + + // Assert + assertNotNull(leaseId); + assertNotNull(leaseId2); + } + + @Test + public void breakLeaseWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String content = "some content2"; + service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + String leaseId = service.acquireLease("mycontainer2", "test6"); + service.breakLease("mycontainer2", "test6", leaseId); + service.releaseLease("mycontainer2", "test6", leaseId); + + // Assert + assertNotNull(leaseId); + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From 6601e406772c57992e81449a70fd7426af719231 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 4 Nov 2011 08:09:52 -0700 Subject: [PATCH 071/664] add support for "get/setServiceProperties" --- .../azure/services/blob/BlobService.java | 3 + .../azure/services/blob/BlobServiceImpl.java | 27 ++- .../azure/services/blob/MetadataAdapter.java | 19 ++- .../services/blob/MetadataHashMapType.java | 21 --- .../services/blob/ServiceProperties.java | 158 ++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 45 +++++ 6 files changed, 242 insertions(+), 31 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 659367d0ca09c..8571cdb2b65a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -5,6 +5,9 @@ //TODO: ServiceException annotation and handling in implementation public interface BlobService { + ServiceProperties getServiceProperties(); + void setServiceProperties(ServiceProperties serviceProperties); + ListContainersResults listContainers(); ListContainersResults listContainers(ListContainersOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index c37ad7c232b3b..2fa241f995d3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -19,7 +19,7 @@ public class BlobServiceImpl implements BlobService { private static final String X_MS_VERSION = "x-ms-version"; private static final String X_MS_BLOB_PUBLIC_ACCESS = "x-ms-blob-public-access"; private static final String X_MS_META_PREFIX = "x-ms-meta-"; - private static final String API_VERSION = "2009-09-19"; + private static final String API_VERSION = "2011-08-18"; private final Client channel; private final String accountName; private final String url; @@ -56,13 +56,6 @@ private Builder addOptionalHeader(Builder builder, String name, Object value) { return builder; } - private Builder addOptionalHeader(Builder builder, String name, int value, int defaultValue) { - if (value != defaultValue) { - builder = builder.header(name, Integer.toString(value)); - } - return builder; - } - private WebResource getResource() { WebResource res = channel.resource(url).path("/"); @@ -83,6 +76,22 @@ private WebResource setCanonicalizedResource(WebResource wr, String resourceName return wr; } + public ServiceProperties getServiceProperties() { + //TODO: timeout + WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, null, "properties"); + + return webResource.header(X_MS_VERSION, API_VERSION).get(ServiceProperties.class); + } + + public void setServiceProperties(ServiceProperties serviceProperties) { + //TODO: timeout + WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, null, "properties"); + + webResource.header(X_MS_VERSION, API_VERSION).type("application/xml").put(serviceProperties); + } + public void createContainer(String container) { createContainer(container, new CreateContainerOptions()); } @@ -545,7 +554,7 @@ public void breakLease(String container, String blob, String leaseId) { putLeaseImpl("break", container, blob, leaseId); } - private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId){ + private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId) { WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java index a23475f2f319c..40811d3f03d8c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java @@ -1,8 +1,11 @@ package com.microsoft.azure.services.blob; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import javax.naming.OperationNotSupportedException; +import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.adapters.XmlAdapter; import org.w3c.dom.Element; @@ -10,7 +13,7 @@ /* * JAXB adapter for element */ -public class MetadataAdapter extends XmlAdapter> { +public class MetadataAdapter extends XmlAdapter> { @Override public HashMap unmarshal(MetadataHashMapType arg0) throws Exception { @@ -26,4 +29,18 @@ public MetadataHashMapType marshal(HashMap arg0) throws Exceptio // We don't need marshaling for blob/container metadata throw new OperationNotSupportedException(); } + + + public static class MetadataHashMapType { + private List entries = new ArrayList(); + + @XmlAnyElement + public List getEntries() { + return entries; + } + + public void setEntries(List entries) { + this.entries = entries; + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java deleted file mode 100644 index 0f3e006e1260e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataHashMapType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.microsoft.azure.services.blob; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlAnyElement; - -import org.w3c.dom.Element; - -public class MetadataHashMapType { - private List entries = new ArrayList(); - - @XmlAnyElement - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java new file mode 100644 index 0000000000000..829d794270894 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java @@ -0,0 +1,158 @@ +package com.microsoft.azure.services.blob; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="StorageServiceProperties") +public class ServiceProperties { + 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; + + @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/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 345025cee9de8..e74d861889b5c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -23,6 +23,51 @@ public class BlobServiceIntegrationTest extends IntegrationTestBase { + @Test + public void getServiceProppertiesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + ServiceProperties 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(); + BlobService service = config.create(BlobService.class); + + // Act + ServiceProperties 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()); + } + + @Test public void createContainerWorks() throws Exception { // Arrange From 2acca42f9156bebf6699064d29ba90859e967ba7 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 09:55:34 -0700 Subject: [PATCH 072/664] Adding additional Message http headers Hardens the processing of BrokerProperties Takes the Date, ContentType, and Location http header into Message DTO --- .../implementation/ServiceBusServiceImpl.java | 25 ++++++++++++++++--- .../serviceBus/ServiceBusIntegrationTest.java | 5 ++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index a25eac4c266f6..79b0133d02fe4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -3,9 +3,11 @@ import java.io.InputStream; import java.rmi.UnexpectedException; import java.util.ArrayList; +import java.util.Date; import javax.inject.Inject; import javax.inject.Named; +import javax.ws.rs.core.MediaType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,12 +67,12 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("serviceBus", e); } - // REVIEW: contentType will be needed public void sendMessage(String path, Message message) throws ServiceException { try { getResource() .path(path) .path("messages") + .type(message.getContentType()) .header("BrokerProperties", mapper.toString(message.getProperties())) .post(message.getBody()); } @@ -121,9 +123,26 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { throw new RuntimeException("Unknown ReceiveMode"); } - // REVIEW: harden this - it's much too brittle. throws null exceptions very easily + String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); + String location = clientResult.getHeaders().getFirst("Location"); + MediaType contentType = clientResult.getType(); + Date date = clientResult.getResponseDate(); + + Message result = new Message(); - result.setProperties(mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties"))); + if (brokerProperties != null) + { + result.setProperties(mapper.fromString(brokerProperties)); + } + if (contentType != null) + { + result.setContentType(clientResult.toString()); + } + if (location != null) + { + result.getProperties().setLockLocation(location); + } + result.setDate(date); result.setBody(clientResult.getEntityInputStream()); return result; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index f2e8a833bb39f..425c131a52e0a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -153,4 +153,9 @@ public void peekLockedMessageCanBeAbandoned() throws Exception { assertNull(receivedMessage.getLockedUntilUtc()); } + + @Test + public void contentTypePassesThrough() throws Exception { + assertTrue(false); + } } From 8adb282218107c70a4243cd546a8014997ff0902 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 4 Nov 2011 10:11:18 -0700 Subject: [PATCH 073/664] add support for "setBlobProperties" --- .../azure/services/blob/BlobService.java | 4 +- .../azure/services/blob/BlobServiceImpl.java | 45 +++++++-- .../blob/SetBlobPropertiesOptions.java | 95 +++++++++++++++++++ .../blob/SetBlobPropertiesResult.java | 33 +++++++ .../blob/BlobServiceIntegrationTest.java | 39 +++++++- 5 files changed, 208 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 8571cdb2b65a9..79d7a07f4cace 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -6,6 +6,7 @@ //TODO: ServiceException annotation and handling in implementation public interface BlobService { ServiceProperties getServiceProperties(); + void setServiceProperties(ServiceProperties serviceProperties); ListContainersResults listContainers(); @@ -44,6 +45,8 @@ public interface BlobService { BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); + SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options); + Blob getBlob(String container, String blob); Blob getBlob(String container, String blob, GetBlobOptions options); @@ -68,5 +71,4 @@ public interface BlobService { void breakLease(String container, String blob, String leaseId); - void setBlobProperties(BlobProperties properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 2fa241f995d3e..3b4aa886cce7a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -72,12 +72,13 @@ private WebResource setCanonicalizedResource(WebResource wr, String resourceName value += "?comp=" + operation; } + // TODO: Is this the best way to pass a parameter to a filter? wr.setProperty("canonicalizedResource", value); return wr; } public ServiceProperties getServiceProperties() { - //TODO: timeout + // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); @@ -85,7 +86,7 @@ public ServiceProperties getServiceProperties() { } public void setServiceProperties(ServiceProperties serviceProperties) { - //TODO: timeout + // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); @@ -364,6 +365,42 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr return getBlobPropertiesFromResponse(response); } + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); + + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); + + WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); + builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + + SetBlobPropertiesResult result = new SetBlobPropertiesResult(); + + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + } + + return result; + } + public Blob getBlob(String container, String blob) { return getBlob(container, blob, new GetBlobOptions()); } @@ -451,10 +488,6 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) builder.delete(); } - public void setBlobProperties(BlobProperties properties) { - // TODO Auto-generated method stub - } - public BlobSnapshot createBlobSnapshot(String container, String blob) { return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java new file mode 100644 index 0000000000000..2f5965bb929b2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java @@ -0,0 +1,95 @@ +package com.microsoft.azure.services.blob; + + +public class SetBlobPropertiesOptions { + private String leaseId; + private String contentType; + private Long contentLength; + private String contentEncoding; + private String contentLanguage; + private String contentMD5; + private String cacheControl; + private String sequenceNumberAction; + private Long sequenceNumber; + + public String getContentType() { + return contentType; + } + + public SetBlobPropertiesOptions setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + public Long getContentLength() { + return contentLength; + } + + public SetBlobPropertiesOptions setContentLength(Long contentLength) { + this.contentLength = contentLength; + return this; + } + + public String getContentEncoding() { + return contentEncoding; + } + + public SetBlobPropertiesOptions setContentEncoding(String contentEncoding) { + this.contentEncoding = contentEncoding; + return this; + } + + public String getContentLanguage() { + return contentLanguage; + } + + public SetBlobPropertiesOptions setContentLanguage(String contentLanguage) { + this.contentLanguage = contentLanguage; + return this; + } + + public String getContentMD5() { + return contentMD5; + } + + public SetBlobPropertiesOptions setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + return this; + } + + public String getCacheControl() { + return cacheControl; + } + + public SetBlobPropertiesOptions setCacheControl(String cacheControl) { + this.cacheControl = cacheControl; + return this; + } + + public Long getSequenceNumber() { + return sequenceNumber; + } + + public SetBlobPropertiesOptions setSequenceNUmber(Long sequenceNUmber) { + this.sequenceNumber = sequenceNUmber; + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public SetBlobPropertiesOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public String getSequenceNumberAction() { + return sequenceNumberAction; + } + + public SetBlobPropertiesOptions setSequenceNumberAction(String sequenceNumberAction) { + this.sequenceNumberAction = sequenceNumberAction; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java new file mode 100644 index 0000000000000..6a99c9352f3ef --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java @@ -0,0 +1,33 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class SetBlobPropertiesResult { + private String etag; + private Date lastModified; + private Long sequenceNumber; + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + public Long getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(Long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index e74d861889b5c..98c04c3a5ae2c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -67,7 +67,6 @@ public void setServiceProppertiesWorks() throws Exception { assertNotNull(props.getMetrics().getVersion()); } - @Test public void createContainerWorks() throws Exception { // Arrange @@ -477,6 +476,44 @@ public void getPageBlobWorks() throws Exception { assertEquals(4096, inputStreamToByteArray(blob.getContentStream()).length); } + @Test + public void setBlobPropertiesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test10"; + service.createPageBlob(container, blob, 4096); + SetBlobPropertiesResult result = service.setBlobProperties(container, blob, 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); + + // Assert + assertNotNull(result); + assertNotNull(result.getEtag()); + assertNotNull(result.getLastModified()); + assertNotNull(result.getSequenceNumber()); + assertEquals(1, result.getSequenceNumber().longValue()); + + assertNotNull(props); + assertEquals("test", props.getCacheControl()); + assertEquals("UTF-8", props.getContentEncoding()); + assertEquals("en-us", props.getContentLanguage()); + 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()); + assertEquals(1, props.getSequenceNumber()); + } + @Test public void deleteBlobWorks() throws Exception { // Arrange From 9131c89fb00dc7a563b06840411375b75cc31c39 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 10:19:14 -0700 Subject: [PATCH 074/664] Taking into account messages made with null values --- .../implementation/ServiceBusServiceImpl.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 79b0133d02fe4..8a7af6f5f6443 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -69,12 +69,17 @@ private ServiceException processCatch(ServiceException e) { public void sendMessage(String path, Message message) throws ServiceException { try { - getResource() + WebResource resource = getResource() .path(path) - .path("messages") - .type(message.getContentType()) - .header("BrokerProperties", mapper.toString(message.getProperties())) - .post(message.getBody()); + .path("messages"); + + if (message.getContentType() != null) + resource.type(message.getContentType()); + + if (message.getProperties() != null) + resource.header("BrokerProperties", mapper.toString(message.getProperties())); + + resource.post(message.getBody()); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); From 472050b79d46a630757b23722408cf4dd00064c3 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 4 Nov 2011 10:24:41 -0700 Subject: [PATCH 075/664] Add support for "setBlobMetadata" --- .../azure/services/blob/BlobService.java | 4 +++ .../azure/services/blob/BlobServiceImpl.java | 32 +++++++++++++++++++ .../services/blob/SetBlobMetadataOptions.java | 14 ++++++++ .../services/blob/SetBlobMetadataResult.java | 24 ++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 31 ++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 79d7a07f4cace..cde3e5a7f0ff0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -47,6 +47,10 @@ public interface BlobService { SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options); + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata); + + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options); + Blob getBlob(String container, String blob); Blob getBlob(String container, String blob, GetBlobOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 3b4aa886cce7a..c2d72d1637783 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -401,6 +401,38 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, return result; } + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) { + return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); + } + + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + + WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + // Metadata + for (Entry entry : metadata.entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + // TODO: We need the following 2 to make sure that "Content-Length:0" + // header + // is sent to the server (IIS doesn't accept PUT without a content + // length). + // Since we are sending a "dummy" string, we also need to set the + // "Content-Type" header so that the hmac filter will see it when + // producing the authorization hmac. + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + + SetBlobMetadataResult result = new SetBlobMetadataResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + return result; + } + public Blob getBlob(String container, String blob) { return getBlob(container, blob, new GetBlobOptions()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java new file mode 100644 index 0000000000000..51f54038f33b6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.blob; + +public class SetBlobMetadataOptions { + private String leaseId; + + public String getLeaseId() { + return leaseId; + } + + public SetBlobMetadataOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java new file mode 100644 index 0000000000000..f8f18ec6d6d88 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java @@ -0,0 +1,24 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class SetBlobMetadataResult { + private String etag; + private Date lastModified; + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 98c04c3a5ae2c..e164fa310e7b0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -514,6 +514,37 @@ public void setBlobPropertiesWorks() throws Exception { assertEquals(1, props.getSequenceNumber()); } + @Test + public void setBlobMetadataWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test11"; + HashMap metadata = new HashMap(); + metadata.put("test", "bar"); + metadata.put("blah", "bleah"); + + service.createPageBlob(container, blob, 4096); + SetBlobMetadataResult result = service.setBlobMetadata(container, blob, metadata); + BlobProperties props = service.getBlobProperties(container, blob); + + // Assert + assertNotNull(result); + assertNotNull(result.getEtag()); + assertNotNull(result.getLastModified()); + + assertNotNull(props); + assertNotNull(props.getMetadata()); + assertEquals(2, props.getMetadata().size()); + assertTrue(props.getMetadata().containsKey("test")); + assertTrue(props.getMetadata().containsValue("bar")); + assertTrue(props.getMetadata().containsKey("blah")); + assertTrue(props.getMetadata().containsValue("bleah")); + } + @Test public void deleteBlobWorks() throws Exception { // Arrange From b1336ad5e8eecb5a09305463417926c47c3198fe Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 10:27:47 -0700 Subject: [PATCH 076/664] Fixing bug in how content type was moved from response to Message --- .../implementation/ServiceBusServiceImpl.java | 14 ++++++++------ .../serviceBus/ServiceBusIntegrationTest.java | 14 +++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 8a7af6f5f6443..5dd895000d102 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -28,6 +28,7 @@ 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 ServiceBusServiceImpl implements ServiceBusService { @@ -69,17 +70,18 @@ private ServiceException processCatch(ServiceException e) { public void sendMessage(String path, Message message) throws ServiceException { try { - WebResource resource = getResource() + Builder request = getResource() .path(path) - .path("messages"); + .path("messages") + .getRequestBuilder(); if (message.getContentType() != null) - resource.type(message.getContentType()); + request = request.type(message.getContentType()); if (message.getProperties() != null) - resource.header("BrokerProperties", mapper.toString(message.getProperties())); + request = request.header("BrokerProperties", mapper.toString(message.getProperties())); - resource.post(message.getBody()); + request.post(message.getBody()); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -141,7 +143,7 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { } if (contentType != null) { - result.setContentType(clientResult.toString()); + result.setContentType(contentType.toString()); } if (location != null) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 425c131a52e0a..48817ad64bd93 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -156,6 +156,18 @@ public void peekLockedMessageCanBeAbandoned() throws Exception { @Test public void contentTypePassesThrough() throws Exception { - assertTrue(false); + // Arrange + service.createQueue(new Queue().setName("TestContentTypePassesThrough")); + + // Act + service.sendMessage("TestContentTypePassesThrough", + new Message("Hello Again").setContentType("text/xml")); + + Message message = service.receiveMessage("TestContentTypePassesThrough", 1500, ReceiveMode.RECEIVE_AND_DELETE); + + + // Assert + assertNotNull(message); + assertEquals("text/xml", message.getContentType()); } } From 8549506878262310b5f1817f9865a5b265e4a882 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 10:53:36 -0700 Subject: [PATCH 077/664] Using updated semantics for unlock and delete of messages --- .../implementation/ServiceBusServiceImpl.java | 15 +++++-- .../serviceBus/ServiceBusIntegrationTest.java | 40 ++++++++++++++----- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 5dd895000d102..1c0197881c672 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -164,7 +164,7 @@ public void abandonMessage(Message message) throws ServiceException { try { getChannel() .resource(message.getLockLocation()) - .delete(); + .put(""); } catch(UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -175,8 +175,17 @@ public void abandonMessage(Message message) throws ServiceException { } public void completeMessage(Message message) throws ServiceException { - // TODO Auto-generated method stub - + try { + getChannel() + .resource(message.getLockLocation()) + .delete(); + } + catch(UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch(ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } public Queue createQueue(Queue entry) throws ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 48817ad64bd93..d8aa5f3d999b6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -86,7 +86,7 @@ public void receiveMessageWorks() throws Exception { service.sendMessage("TestReceiveMessageWorks", new Message("Hello World")); // Act - Message message = service.receiveMessage("TestReceiveMessageWorks", 500, ReceiveMode.RECEIVE_AND_DELETE); + Message message = service.receiveMessage("TestReceiveMessageWorks", 5, ReceiveMode.RECEIVE_AND_DELETE); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -102,7 +102,7 @@ public void peekLockMessageWorks() throws Exception { service.sendMessage("TestPeekLockMessageWorks", new Message("Hello Again")); // Act - Message message = service.receiveMessage("TestPeekLockMessageWorks", 500, ReceiveMode.PEEK_LOCK); + Message message = service.receiveMessage("TestPeekLockMessageWorks", 5, ReceiveMode.PEEK_LOCK); // Assert byte[] data = new byte[100]; @@ -116,7 +116,7 @@ public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeCompleted")); service.sendMessage("TestPeekLockedMessageCanBeCompleted", new Message("Hello Again")); - Message message = service.receiveMessage("TestPeekLockedMessageCanBeCompleted", 1500, ReceiveMode.PEEK_LOCK); + Message message = service.receiveMessage("TestPeekLockedMessageCanBeCompleted", 5, ReceiveMode.PEEK_LOCK); // Act String lockToken = message.getLockToken(); @@ -132,18 +132,18 @@ public void peekLockedMessageCanBeCompleted() throws Exception { } @Test - public void peekLockedMessageCanBeAbandoned() throws Exception { + public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeAbandoned")); + service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeUnlocked")); service.sendMessage("TestPeekLockedMessageCanBeAbandoned", new Message("Hello Again")); - Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeAbandoned", 1500, ReceiveMode.PEEK_LOCK); + Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeUnlocked", 5, ReceiveMode.PEEK_LOCK); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.abandonMessage(peekedMessage); - Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeAbandoned", 1500, ReceiveMode.RECEIVE_AND_DELETE); + Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeUnlocked", 5, ReceiveMode.RECEIVE_AND_DELETE); // Assert @@ -151,9 +151,30 @@ public void peekLockedMessageCanBeAbandoned() throws Exception { assertNotNull(lockedUntil); assertNull(receivedMessage.getLockToken()); assertNull(receivedMessage.getLockedUntilUtc()); + } + + + @Test + public void peekLockedMessageCanBeDeleted() throws Exception { + // Arrange + service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeDeleted")); + service.sendMessage("TestPeekLockedMessageCanBeDeleted", new Message("Hello Again")); + Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeDeleted", 5, ReceiveMode.PEEK_LOCK); + + // Act + String lockToken = peekedMessage.getLockToken(); + Date lockedUntil = peekedMessage.getLockedUntilUtc(); + + service.completeMessage(peekedMessage); + Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeDeleted", 5, ReceiveMode.RECEIVE_AND_DELETE); + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNull(receivedMessage.getLockToken()); + assertNull(receivedMessage.getLockedUntilUtc()); } - + @Test public void contentTypePassesThrough() throws Exception { // Arrange @@ -163,8 +184,7 @@ public void contentTypePassesThrough() throws Exception { service.sendMessage("TestContentTypePassesThrough", new Message("Hello Again").setContentType("text/xml")); - Message message = service.receiveMessage("TestContentTypePassesThrough", 1500, ReceiveMode.RECEIVE_AND_DELETE); - + Message message = service.receiveMessage("TestContentTypePassesThrough", 5, ReceiveMode.RECEIVE_AND_DELETE); // Assert assertNotNull(message); From 2b4aa27d50f202d57d76f194d037a5cfc854eb4c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 4 Nov 2011 12:25:53 -0700 Subject: [PATCH 078/664] Add support for "clear/updatePageBlobPages" --- .../azure/services/blob/BlobService.java | 9 +++ .../azure/services/blob/BlobServiceImpl.java | 59 ++++++++++++++++--- .../blob/UpdatePageBlobPagesOptions.java | 25 ++++++++ .../blob/UpdatePageBlobPagesResult.java | 42 +++++++++++++ .../blob/BlobServiceIntegrationTest.java | 50 +++++++++++++++- 5 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index cde3e5a7f0ff0..e72793fda35bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -37,6 +37,15 @@ public interface BlobService { void createPageBlob(String container, String blob, int length, CreateBlobOptions options); + UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd); + + UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd, UpdatePageBlobPagesOptions options); + + UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream); + + UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + UpdatePageBlobPagesOptions options); + void createBlockBlob(String container, String blob, InputStream content); void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index c2d72d1637783..b47758956e70f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -56,6 +56,17 @@ private Builder addOptionalHeader(Builder builder, String name, Object value) { return builder; } + 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; + } + private WebResource getResource() { WebResource res = channel.resource(url).path("/"); @@ -449,13 +460,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) { builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - if (options.getRangeStart() != null) { - String range = options.getRangeStart().toString() + "-"; - if (options.getRangeEnd() != null) { - range += options.getRangeEnd().toString(); - } - builder = addOptionalHeader(builder, "Range", range); - } + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); ClientResponse response = builder.get(ClientResponse.class); @@ -638,4 +643,44 @@ private String putLeaseImpl(String leaseAction, String container, String blob, S return response.getHeaders().getFirst("x-ms-lease-id"); } + + public UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd) { + return clearPageBlobPages(container, blob, rangeStart, rangeEnd, new UpdatePageBlobPagesOptions()); + } + + public UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd, UpdatePageBlobPagesOptions options) { + return updatePageBlobPagesImpl("clear", container, blob, rangeStart, rangeEnd, 0, null, options); + } + + public UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) { + return updatePageBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new UpdatePageBlobPagesOptions()); + } + + public UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + UpdatePageBlobPagesOptions options) { + return updatePageBlobPagesImpl("update", container, blob, rangeStart, rangeEnd, length, contentStream, options); + } + + private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, + InputStream contentStream, UpdatePageBlobPagesOptions options) { + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "page"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); + builder = addOptionalHeader(builder, "Content-Length", length); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-page-write", action); + + builder = builder.header("x-ms-blob-type", "BlockBlob"); + + Object content = (contentStream == null ? "" : contentStream); + ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); + UpdatePageBlobPagesResult result = new UpdatePageBlobPagesResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + return result; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java new file mode 100644 index 0000000000000..74e6f0ef2b098 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java @@ -0,0 +1,25 @@ +package com.microsoft.azure.services.blob; + +public class UpdatePageBlobPagesOptions { + private String leaseId; + private String contentMD5; + + // TODO: Add "if" from + // http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx + + public String getLeaseId() { + return leaseId; + } + + public void setLeaseId(String leaseId) { + this.leaseId = leaseId; + } + + public String getContentMD5() { + return contentMD5; + } + + public void setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java new file mode 100644 index 0000000000000..964471addca29 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java @@ -0,0 +1,42 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +public class UpdatePageBlobPagesResult { + private String etag; + private Date lastModified; + private String contentMD5; + private long sequenceNumber; + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + public String getContentMD5() { + return contentMD5; + } + + public void setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + } + + public long getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index e164fa310e7b0..18a341c992d87 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -321,6 +321,50 @@ public void createPageBlobWithOptionsWorks() throws Exception { assertEquals(0, props.getSequenceNumber()); } + @Test + public void clearPageBlobPagesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + service.createPageBlob(container, blob, 512); + + UpdatePageBlobPagesResult result = service.clearPageBlobPages(container, blob, 0, 511); + + // Assert + assertNotNull(result); + assertNull(result.getContentMD5()); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(0, result.getSequenceNumber()); + } + + @Test + public void updatePageBlobPagesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + String content = new String(new char[512]); + ByteArrayInputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); + service.createPageBlob(container, blob, 512); + + UpdatePageBlobPagesResult result = service.updatePageBlobPages(container, blob, 0, 511, content.length(), contentStream); + + // Assert + assertNotNull(result); + assertNotNull(result.getContentMD5()); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(0, result.getSequenceNumber()); + } + @Test public void createBlockBlobWorks() throws Exception { // Arrange @@ -486,9 +530,9 @@ public void setBlobPropertiesWorks() throws Exception { String container = "mycontainer1"; String blob = "test10"; service.createPageBlob(container, blob, 4096); - SetBlobPropertiesResult result = service.setBlobProperties(container, blob, new SetBlobPropertiesOptions().setCacheControl("test") - .setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L).setContentMD5(null).setContentType("text/plain") - .setSequenceNumberAction("increment")); + SetBlobPropertiesResult result = service.setBlobProperties(container, blob, + 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); From 2aa9a6b4de93f803a6e5a0c9b01cc49c1cc2cc99 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 13:31:41 -0700 Subject: [PATCH 079/664] Using options class in ServiceBusService.receiveMessage ReceiveMessageOptions has lock/peek switch and timeout receiveMessage becomes receiveQueueMessage and receiveSubscriptionMessage because two-string overloads are too problematic --- .../serviceBus/ReceiveMessageOptions.java | 46 ++++++++++++++++ .../serviceBus/ServiceBusService.java | 13 +++-- .../serviceBus/client/MessageReceiver.java | 7 +-- .../serviceBus/client/MessagingClient.java | 43 ++++----------- .../client/ReceiveMessageOptions.java | 17 ------ .../implementation/ServiceBusServiceImpl.java | 36 ++++++++---- .../serviceBus/IntegrationTestBase.java | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 55 +++++++++++-------- 8 files changed, 128 insertions(+), 91 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java new file mode 100644 index 0000000000000..4c65c64001f0f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java @@ -0,0 +1,46 @@ +package com.microsoft.azure.services.serviceBus; + + +public class ReceiveMessageOptions { + Integer timeout; + private ReceiveMode receiveMode = ReceiveMode.RECEIVE_AND_DELETE; + + public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); + + public Integer getTimeout() { + return timeout; + } + + public ReceiveMessageOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + + public ReceiveMode getReceiveMode() { + return receiveMode; + } + + public ReceiveMessageOptions setReceiveMode(ReceiveMode receiveMode) { + this.receiveMode = receiveMode; + return this; + } + + public boolean isReceiveAndDelete() { + return receiveMode == ReceiveMode.RECEIVE_AND_DELETE; + } + + public ReceiveMessageOptions setReceiveAndDelete() { + this.receiveMode = ReceiveMode.RECEIVE_AND_DELETE; + return this; + } + + public boolean isPeekLock() { + return receiveMode == ReceiveMode.PEEK_LOCK; + } + + public ReceiveMessageOptions setPeekLock() { + this.receiveMode = ReceiveMode.PEEK_LOCK; + return this; + } +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index d51361ca4bf6d..b62641ec92ea7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -8,10 +8,15 @@ public interface ServiceBusService { void sendMessage(String path, Message message) throws ServiceException; - Message receiveMessage(String queueName, Integer timeout, ReceiveMode receiveMode) throws ServiceException; - Message receiveMessage(String topicName, String subscriptionName, int timeout, ReceiveMode receiveMode) throws ServiceException; - void abandonMessage(Message message) throws ServiceException; - void completeMessage(Message message) throws ServiceException; + + Message receiveQueueMessage(String queueName) throws ServiceException; + Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + + Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; + Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; + + void unlockMessage(Message message) throws ServiceException; + void deleteMessage(Message message) throws ServiceException; Queue createQueue(Queue queue) throws ServiceException; void deleteQueue(String queuePath) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java index cb18c72c33155..01462469283db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java @@ -2,13 +2,12 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; public interface MessageReceiver { Message receiveMessage() throws ServiceException; Message receiveMessage(ReceiveMessageOptions options) throws ServiceException; - Message peekLockMessage() throws ServiceException; - Message peekLockMessage(ReceiveMessageOptions options) throws ServiceException; - void abandonMessage(Message message) throws ServiceException; - void completeMessage(Message message) throws ServiceException; + void unlockMessage(Message message) throws ServiceException; + void deleteMessage(Message message) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java index e3290259ba23d..a2d2f4bb557c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -5,6 +5,7 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; @@ -55,27 +56,16 @@ public Message receiveMessage() throws ServiceException { public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { - return service.receiveMessage(queue, options.getTimeout(), - ReceiveMode.RECEIVE_AND_DELETE); + return service.receiveQueueMessage(queue, options); } - public Message peekLockMessage() throws ServiceException { - return peekLockMessage(ReceiveMessageOptions.DEFAULT); + public void unlockMessage(Message message) throws ServiceException { + service.unlockMessage(message); } - public Message peekLockMessage(ReceiveMessageOptions options) + public void deleteMessage(Message message) throws ServiceException { - return service.receiveMessage(queue, options.getTimeout(), - ReceiveMode.PEEK_LOCK); - } - - public void abandonMessage(Message message) throws ServiceException { - service.abandonMessage(message); - } - - public void completeMessage(Message message) - throws ServiceException { - service.completeMessage(message); + service.deleteMessage(message); } }; } @@ -100,27 +90,16 @@ public Message receiveMessage() throws ServiceException { public Message receiveMessage(ReceiveMessageOptions options) throws ServiceException { - return service.receiveMessage(topic, subscription, options.getTimeout(), - ReceiveMode.RECEIVE_AND_DELETE); + return service.receiveSubscriptionMessage(topic, subscription, options); } - public Message peekLockMessage() throws ServiceException { - return peekLockMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message peekLockMessage(ReceiveMessageOptions options) - throws ServiceException { - return service.receiveMessage(topic, subscription, options.getTimeout(), - ReceiveMode.PEEK_LOCK); - } - - public void abandonMessage(Message message) throws ServiceException { - service.abandonMessage(message); + public void unlockMessage(Message message) throws ServiceException { + service.unlockMessage(message); } - public void completeMessage(Message message) + public void deleteMessage(Message message) throws ServiceException { - service.completeMessage(message); + service.deleteMessage(message); } }; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java deleted file mode 100644 index 380bcf2c3c02e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/ReceiveMessageOptions.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.microsoft.azure.services.serviceBus.client; - -public class ReceiveMessageOptions { - Integer timeout; - - public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); - - public Integer getTimeout() { - return timeout; - } - - public ReceiveMessageOptions setTimeout(Integer timeout) { - this.timeout = timeout; - return this; - } -} - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 1c0197881c672..1062b29613ae5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -15,6 +15,7 @@ import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.QueueList; +import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; import com.microsoft.azure.services.serviceBus.implementation.Entry; @@ -91,20 +92,25 @@ public void sendMessage(String path, Message message) throws ServiceException { } } - public Message receiveMessage(String queuePath, Integer timeout, - ReceiveMode receiveMode) throws ServiceException { + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); + } + + public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { WebResource resource = getResource() .path(queuePath) .path("messages") .path("head"); - if (timeout != null) { - resource = resource.queryParam("timeout", Integer.toString(timeout)); + if (options.getTimeout() != null) { + resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); } ClientResponse clientResult; - if (receiveMode == ReceiveMode.RECEIVE_AND_DELETE) { + if (options.isReceiveAndDelete()) { try { clientResult = resource.delete(ClientResponse.class); } @@ -115,7 +121,7 @@ public Message receiveMessage(String queuePath, Integer timeout, throw processCatch(new ServiceException(e)); } } - else if (receiveMode == ReceiveMode.PEEK_LOCK) { + else if (options.isPeekLock()) { try { clientResult = resource.post(ClientResponse.class, ""); } @@ -154,13 +160,21 @@ else if (receiveMode == ReceiveMode.PEEK_LOCK) { return result; } - public Message receiveMessage(String topicPath, String subscriptionName, - int timeout, ReceiveMode receiveMode) throws ServiceException { + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { // TODO Auto-generated method stub return null; } - public void abandonMessage(Message message) throws ServiceException { + + public void unlockMessage(Message message) throws ServiceException { try { getChannel() .resource(message.getLockLocation()) @@ -174,7 +188,7 @@ public void abandonMessage(Message message) throws ServiceException { } } - public void completeMessage(Message message) throws ServiceException { + public void deleteMessage(Message message) throws ServiceException { try { getChannel() .resource(message.getLockLocation()) @@ -337,4 +351,6 @@ public Feed getRules(String topicPath, String subscriptionName) { + + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 54f01d546e47b..ee39482e2b3e7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -46,7 +46,7 @@ public void initialize() throws Exception { testAlphaExists = true; long count = queue.getMessageCount(); for(long i = 0; i != count; ++i) { - service.receiveMessage(queueName, 2000, ReceiveMode.RECEIVE_AND_DELETE); + service.receiveQueueMessage(queueName, new ReceiveMessageOptions().setTimeout(20)); } } else { service.deleteQueue(queueName); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index d8aa5f3d999b6..a767a8765edc3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -19,6 +19,9 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { private Configuration config; private ServiceBusService service; + static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); + static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); + @Before public void createService() throws Exception { config = createConfiguration(); @@ -82,11 +85,12 @@ public void sendMessageWorks() throws Exception { @Test public void receiveMessageWorks() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestReceiveMessageWorks")); - service.sendMessage("TestReceiveMessageWorks", new Message("Hello World")); + String queueName = "TestReceiveMessageWorks"; + service.createQueue(new Queue().setName(queueName)); + service.sendMessage(queueName, new Message("Hello World")); // Act - Message message = service.receiveMessage("TestReceiveMessageWorks", 5, ReceiveMode.RECEIVE_AND_DELETE); + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -98,11 +102,12 @@ public void receiveMessageWorks() throws Exception { @Test public void peekLockMessageWorks() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestPeekLockMessageWorks")); - service.sendMessage("TestPeekLockMessageWorks", new Message("Hello Again")); + String queueName = "TestPeekLockMessageWorks"; + service.createQueue(new Queue().setName(queueName)); + service.sendMessage(queueName, new Message("Hello Again")); // Act - Message message = service.receiveMessage("TestPeekLockMessageWorks", 5, ReceiveMode.PEEK_LOCK); + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Assert byte[] data = new byte[100]; @@ -114,16 +119,17 @@ public void peekLockMessageWorks() throws Exception { @Test public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeCompleted")); - service.sendMessage("TestPeekLockedMessageCanBeCompleted", new Message("Hello Again")); - Message message = service.receiveMessage("TestPeekLockedMessageCanBeCompleted", 5, ReceiveMode.PEEK_LOCK); + String queueName = "TestPeekLockedMessageCanBeCompleted"; + service.createQueue(new Queue().setName(queueName)); + service.sendMessage(queueName, new Message("Hello Again")); + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act String lockToken = message.getLockToken(); Date lockedUntil = message.getLockedUntilUtc(); String lockLocation = message.getLockLocation(); - service.completeMessage(message); + service.deleteMessage(message); // Assert assertNotNull(lockToken); @@ -134,16 +140,17 @@ public void peekLockedMessageCanBeCompleted() throws Exception { @Test public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeUnlocked")); - service.sendMessage("TestPeekLockedMessageCanBeAbandoned", new Message("Hello Again")); - Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeUnlocked", 5, ReceiveMode.PEEK_LOCK); + String queueName = "TestPeekLockedMessageCanBeUnlocked"; + service.createQueue(new Queue().setName(queueName)); + service.sendMessage(queueName, new Message("Hello Again")); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); - service.abandonMessage(peekedMessage); - Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeUnlocked", 5, ReceiveMode.RECEIVE_AND_DELETE); + service.unlockMessage(peekedMessage); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); // Assert @@ -157,16 +164,17 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { @Test public void peekLockedMessageCanBeDeleted() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestPeekLockedMessageCanBeDeleted")); - service.sendMessage("TestPeekLockedMessageCanBeDeleted", new Message("Hello Again")); - Message peekedMessage = service.receiveMessage("TestPeekLockedMessageCanBeDeleted", 5, ReceiveMode.PEEK_LOCK); + String queueName = "TestPeekLockedMessageCanBeDeleted"; + service.createQueue(new Queue().setName(queueName)); + service.sendMessage(queueName, new Message("Hello Again")); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); - service.completeMessage(peekedMessage); - Message receivedMessage = service.receiveMessage("TestPeekLockedMessageCanBeDeleted", 5, ReceiveMode.RECEIVE_AND_DELETE); + service.deleteMessage(peekedMessage); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); // Assert assertNotNull(lockToken); @@ -178,13 +186,14 @@ public void peekLockedMessageCanBeDeleted() throws Exception { @Test public void contentTypePassesThrough() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestContentTypePassesThrough")); + String queueName = "TestContentTypePassesThrough"; + service.createQueue(new Queue().setName(queueName)); // Act - service.sendMessage("TestContentTypePassesThrough", + service.sendMessage(queueName, new Message("Hello Again").setContentType("text/xml")); - Message message = service.receiveMessage("TestContentTypePassesThrough", 5, ReceiveMode.RECEIVE_AND_DELETE); + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); // Assert assertNotNull(message); From 5f7dc51b40d58320f4007a3f6ea598cd112097a1 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 14:13:37 -0700 Subject: [PATCH 080/664] Changing naming for getQueueList Following conventions in blob to become: ListQueuesResult listQueues(); --- .../serviceBus/{QueueList.java => ListQueuesResult.java} | 5 +---- .../azure/services/serviceBus/ServiceBusService.java | 4 ++-- .../com/microsoft/azure/services/serviceBus/Util.java | 2 +- .../serviceBus/implementation/ServiceBusServiceImpl.java | 9 +++++---- .../services/serviceBus/ServiceBusIntegrationTest.java | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/{QueueList.java => ListQueuesResult.java} (87%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java index cb29a3a8aa639..4780ef72fb3be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/QueueList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java @@ -2,7 +2,7 @@ import java.util.List; -public class QueueList { +public class ListQueuesResult { private List queues; @@ -13,7 +13,4 @@ List getQueues() { public void setQueues(List queues) { this.queues = queues; } - - - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index b62641ec92ea7..a2cc77f4f9b95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -21,12 +21,12 @@ public interface ServiceBusService { Queue createQueue(Queue queue) throws ServiceException; void deleteQueue(String queuePath) throws ServiceException; Queue getQueue(String queuePath) throws ServiceException; - QueueList getQueueList() throws ServiceException; + ListQueuesResult listQueues() throws ServiceException; Entry createTopic(Entry topic) throws ServiceException; void deleteTopic(String topicPath) throws ServiceException; Entry getTopic(String topicPath) throws ServiceException; - Feed getTopics() throws ServiceException; + Feed getTopicList() throws ServiceException; void addSubscription(String topicPath, String subscriptionName, Entry subscription) throws ServiceException; void removeSubscription(String topicPath, String subscriptionName) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java index d2ed0fb88d2da..995e3ce657388 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java @@ -6,6 +6,6 @@ public class Util { public static Iterable iterateQueues(ServiceBusService service) throws ServiceException { //TODO: iterate over link rel=next pagination - return service.getQueueList().getQueues(); + return service.listQueues().getQueues(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 1062b29613ae5..1e489e4719f46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -14,7 +14,7 @@ import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.QueueList; +import com.microsoft.azure.services.serviceBus.ListQueuesResult; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; @@ -246,7 +246,7 @@ public Queue getQueue(String queuePath) throws ServiceException { } - public QueueList getQueueList() throws ServiceException { + public ListQueuesResult listQueues() throws ServiceException { try { Feed feed = getResource() .path("$Resources/Queues") @@ -255,7 +255,7 @@ public QueueList getQueueList() throws ServiceException { for(Entry entry : feed.getEntries()){ queues.add(new Queue(entry)); } - QueueList result = new QueueList(); + ListQueuesResult result = new ListQueuesResult(); result.setQueues(queues); return result; } @@ -300,7 +300,7 @@ public Entry getTopic(String topicPath) { return null; } - public Feed getTopics() { + public Feed getTopicList() throws ServiceException { // TODO Auto-generated method stub return null; } @@ -353,4 +353,5 @@ public Feed getRules(String topicPath, String subscriptionName) { + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index a767a8765edc3..cc613a2157761 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -34,7 +34,7 @@ public void fetchQueueAndListQueuesWorks() throws Exception { // Act Queue entry = service.getQueue("TestAlpha"); - QueueList feed = service.getQueueList(); + ListQueuesResult feed = service.listQueues(); // Assert assertNotNull(entry); From 1a0250fb410bdb624f3cc7b249afa7bd4978ec02 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 14:50:09 -0700 Subject: [PATCH 081/664] Adding topic support Also factoring exception handling out of method logic for clarity --- .../azure/services/serviceBus/Exports.java | 2 + .../services/serviceBus/ListQueuesResult.java | 8 +- .../services/serviceBus/ListTopicsResult.java | 16 + .../serviceBus/ServiceBusService.java | 6 +- .../azure/services/serviceBus/Topic.java | 31 + .../ServiceBusServiceForJersey.java | 278 ++++++++ .../implementation/ServiceBusServiceImpl.java | 660 ++++++++---------- .../serviceBus/ContractBuilderTest.java | 4 +- .../serviceBus/ServiceBusIntegrationTest.java | 22 + 9 files changed, 661 insertions(+), 366 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 8347887877822..ad705ee15a5e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -7,6 +7,7 @@ import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.azure.services.serviceBus.implementation.EntryModelProvider; import com.microsoft.azure.services.serviceBus.implementation.MarshallerProvider; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceForJersey; import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceImpl; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; @@ -16,6 +17,7 @@ public void register(Builder.Registry registry) { // provide contract implementation registry.add(ServiceBusService.class, ServiceBusServiceImpl.class); + registry.add(ServiceBusServiceForJersey.class); registry.add(MessagingClient.class); // alter jersey client config for serviceBus diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java index 4780ef72fb3be..f7d43abd506f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java @@ -4,13 +4,13 @@ public class ListQueuesResult { - private List queues; + private List items; List getQueues() { - return queues; + return items; } - public void setQueues(List queues) { - this.queues = queues; + public void setItems(List items) { + this.items = items; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java new file mode 100644 index 0000000000000..2e8cbaab37f4a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java @@ -0,0 +1,16 @@ +package com.microsoft.azure.services.serviceBus; + +import java.util.List; + +public class ListTopicsResult { + + private List items; + + List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index a2cc77f4f9b95..f7808957fe581 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -23,10 +23,10 @@ public interface ServiceBusService { Queue getQueue(String queuePath) throws ServiceException; ListQueuesResult listQueues() throws ServiceException; - Entry createTopic(Entry topic) throws ServiceException; + Topic createTopic(Topic topic) throws ServiceException; void deleteTopic(String topicPath) throws ServiceException; - Entry getTopic(String topicPath) throws ServiceException; - Feed getTopicList() throws ServiceException; + Topic getTopic(String topicPath) throws ServiceException; + ListTopicsResult listTopics() throws ServiceException; void addSubscription(String topicPath, String subscriptionName, Entry subscription) throws ServiceException; void removeSubscription(String topicPath, String subscriptionName) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java new file mode 100644 index 0000000000000..814388af750e8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java @@ -0,0 +1,31 @@ +package com.microsoft.azure.services.serviceBus; + +import javax.ws.rs.core.MediaType; + +import com.microsoft.azure.services.serviceBus.implementation.Content; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.EntryModel; +import com.microsoft.azure.services.serviceBus.implementation.TopicDescription; + +public class Topic extends EntryModel { + public Topic() { + super(new Entry(), new TopicDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setTopicDescription(getModel()); + } + + public Topic(Entry entry) { + super(entry, entry.getContent().getTopicDescription()); + } + + + public String getName() { + return getEntry().getTitle(); + } + + public Topic setName(String value) { + getEntry().setTitle(value); + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java new file mode 100644 index 0000000000000..257ca41146ff8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java @@ -0,0 +1,278 @@ +package com.microsoft.azure.services.serviceBus.implementation; + +import java.io.InputStream; +import java.rmi.UnexpectedException; +import java.util.ArrayList; +import java.util.Date; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.azure.services.serviceBus.ListTopicsResult; +import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.Queue; +import com.microsoft.azure.services.serviceBus.ListQueuesResult; +import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.azure.services.serviceBus.ReceiveMode; +import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.Topic; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Feed; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.auth.wrap.WrapFilter; +import com.microsoft.azure.utils.ServiceExceptionFactory; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientHandlerException; +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 ServiceBusServiceForJersey implements ServiceBusService { + + private Client channel; + private String uri; + private BrokerPropertiesMapper mapper; + static Log log = LogFactory.getLog(ServiceBusService.class); + + @Inject + public ServiceBusServiceForJersey( + Client channel, + @Named("serviceBus") WrapFilter authFilter, + @Named("serviceBus.uri") String uri, + BrokerPropertiesMapper mapper) { + + this.channel = channel; + this.uri = uri; + this.mapper = mapper; + channel.addFilter(authFilter); + } + + public Client getChannel() { + return channel; + } + + public void setChannel(Client channel) { + this.channel = channel; + } + + private WebResource getResource() { + return getChannel() + .resource(uri); + } + + + public void sendMessage(String path, Message message) throws ServiceException { + Builder request = getResource() + .path(path) + .path("messages") + .getRequestBuilder(); + + if (message.getContentType() != null) + request = request.type(message.getContentType()); + + if (message.getProperties() != null) + request = request.header("BrokerProperties", mapper.toString(message.getProperties())); + + request.post(message.getBody()); + } + + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); + } + + public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { + + WebResource resource = getResource() + .path(queuePath) + .path("messages") + .path("head"); + + if (options.getTimeout() != null) { + resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); + } + + ClientResponse clientResult; + if (options.isReceiveAndDelete()) { + clientResult = resource.delete(ClientResponse.class); + } + else if (options.isPeekLock()) { + clientResult = resource.post(ClientResponse.class, ""); + } + else { + throw new RuntimeException("Unknown ReceiveMode"); + } + + String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); + String location = clientResult.getHeaders().getFirst("Location"); + MediaType contentType = clientResult.getType(); + Date date = clientResult.getResponseDate(); + + + Message result = new Message(); + if (brokerProperties != null) + { + result.setProperties(mapper.fromString(brokerProperties)); + } + if (contentType != null) + { + result.setContentType(contentType.toString()); + } + if (location != null) + { + result.getProperties().setLockLocation(location); + } + result.setDate(date); + result.setBody(clientResult.getEntityInputStream()); + return result; + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + + public void unlockMessage(Message message) throws ServiceException { + getChannel() + .resource(message.getLockLocation()) + .put(""); + } + + public void deleteMessage(Message message) throws ServiceException { + getChannel() + .resource(message.getLockLocation()) + .delete(); + } + + public Queue createQueue(Queue entry) throws ServiceException { + return getResource() + .path(entry.getName()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Queue.class, entry); + } + + public void deleteQueue(String queuePath) throws ServiceException { + getResource() + .path(queuePath) + .delete(); + } + + public Queue getQueue(String queuePath) throws ServiceException { + return getResource() + .path(queuePath) + .get(Queue.class); + } + + + public ListQueuesResult listQueues() throws ServiceException { + Feed feed = getResource() + .path("$Resources/Queues") + .get(Feed.class); + ArrayList queues = new ArrayList(); + for(Entry entry : feed.getEntries()){ + queues.add(new Queue(entry)); + } + ListQueuesResult result = new ListQueuesResult(); + result.setItems(queues); + return result; + } + + public Topic createTopic(Topic entry) throws ServiceException { + return getResource() + .path(entry.getName()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Topic.class, entry); + } + + public void deleteTopic(String TopicPath) throws ServiceException { + getResource() + .path(TopicPath) + .delete(); + } + + public Topic getTopic(String TopicPath) throws ServiceException { + return getResource() + .path(TopicPath) + .get(Topic.class); + } + + + public ListTopicsResult listTopics() throws ServiceException { + Feed feed = getResource() + .path("$Resources/Topics") + .get(Feed.class); + ArrayList Topics = new ArrayList(); + for(Entry entry : feed.getEntries()){ + Topics.add(new Topic(entry)); + } + ListTopicsResult result = new ListTopicsResult(); + result.setItems(Topics); + return result; + } + + public void addSubscription(String topicPath, String subscriptionName, + Entry subscription) { + // TODO Auto-generated method stub + + } + + public void removeSubscription(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + + } + + public Entry getSubscription(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + return null; + } + + public Feed getSubscriptions(String topicPath) { + // TODO Auto-generated method stub + return null; + } + + public void addRule(String topicPath, String subscriptionName, + String ruleName, Entry rule) { + // TODO Auto-generated method stub + + } + + public void removeRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + + } + + public Entry getRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + return null; + } + + public Feed getRules(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + return null; + } + + + + + + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 1e489e4719f46..efb8bb05cfd7c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -1,357 +1,303 @@ -package com.microsoft.azure.services.serviceBus.implementation; - -import java.io.InputStream; -import java.rmi.UnexpectedException; -import java.util.ArrayList; -import java.util.Date; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.core.MediaType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ListQueuesResult; -import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.Feed; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.auth.wrap.WrapFilter; -import com.microsoft.azure.utils.ServiceExceptionFactory; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; -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 ServiceBusServiceImpl implements ServiceBusService { - - private Client channel; - private String uri; - private BrokerPropertiesMapper mapper; - static Log log = LogFactory.getLog(ServiceBusService.class); - - @Inject - public ServiceBusServiceImpl( - Client channel, - @Named("serviceBus") WrapFilter authFilter, - @Named("serviceBus.uri") String uri, - BrokerPropertiesMapper mapper) { - - this.channel = channel; - this.uri = uri; - this.mapper = mapper; - channel.addFilter(authFilter); - } - - public Client getChannel() { - return channel; - } - - public void setChannel(Client channel) { - this.channel = channel; - } - - private WebResource getResource() { - return getChannel() - .resource(uri); - } - - private ServiceException processCatch(ServiceException e) { - log.warn(e.getMessage(), e.getCause()); - return ServiceExceptionFactory.process("serviceBus", e); - } - - public void sendMessage(String path, Message message) throws ServiceException { - try { - Builder request = getResource() - .path(path) - .path("messages") - .getRequestBuilder(); - - if (message.getContentType() != null) - request = request.type(message.getContentType()); - - if (message.getProperties() != null) - request = request.header("BrokerProperties", mapper.toString(message.getProperties())); - - request.post(message.getBody()); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Message receiveQueueMessage(String queueName) - throws ServiceException { - return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); - } - - public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { - - WebResource resource = getResource() - .path(queuePath) - .path("messages") - .path("head"); - - if (options.getTimeout() != null) { - resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); - } - - ClientResponse clientResult; - if (options.isReceiveAndDelete()) { - try { - clientResult = resource.delete(ClientResponse.class); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - else if (options.isPeekLock()) { - try { - clientResult = resource.post(ClientResponse.class, ""); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - else { - throw new RuntimeException("Unknown ReceiveMode"); - } - - String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); - String location = clientResult.getHeaders().getFirst("Location"); - MediaType contentType = clientResult.getType(); - Date date = clientResult.getResponseDate(); - - - Message result = new Message(); - if (brokerProperties != null) - { - result.setProperties(mapper.fromString(brokerProperties)); - } - if (contentType != null) - { - result.setContentType(contentType.toString()); - } - if (location != null) - { - result.getProperties().setLockLocation(location); - } - result.setDate(date); - result.setBody(clientResult.getEntityInputStream()); - return result; - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - - public void unlockMessage(Message message) throws ServiceException { - try { - getChannel() - .resource(message.getLockLocation()) - .put(""); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public void deleteMessage(Message message) throws ServiceException { - try { - getChannel() - .resource(message.getLockLocation()) - .delete(); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public Queue createQueue(Queue entry) throws ServiceException { - try { - return getResource() - .path(entry.getName()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Queue.class, entry); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public void deleteQueue(String queuePath) throws ServiceException { - try { - getResource() - .path(queuePath) - .delete(); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public Queue getQueue(String queuePath) throws ServiceException { - try { - return getResource() - .path(queuePath) - .get(Queue.class); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public ListQueuesResult listQueues() throws ServiceException { - try { - Feed feed = getResource() - .path("$Resources/Queues") - .get(Feed.class); - ArrayList queues = new ArrayList(); - for(Entry entry : feed.getEntries()){ - queues.add(new Queue(entry)); - } - ListQueuesResult result = new ListQueuesResult(); - result.setQueues(queues); - return result; - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - public Entry createTopic(Entry entry) throws ServiceException { - try { - return getResource() - .path(entry.getTitle()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Entry.class, entry); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public void deleteTopic(String topicPath) throws ServiceException { - try { - getResource() - .path(topicPath) - .delete(); - } - catch(UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch(ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public Entry getTopic(String topicPath) { - // TODO Auto-generated method stub - return null; - } - - public Feed getTopicList() throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public void addSubscription(String topicPath, String subscriptionName, - Entry subscription) { - // TODO Auto-generated method stub - - } - - public void removeSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - - } - - public Entry getSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; - } - - public Feed getSubscriptions(String topicPath) { - // TODO Auto-generated method stub - return null; - } - - public void addRule(String topicPath, String subscriptionName, - String ruleName, Entry rule) { - // TODO Auto-generated method stub - - } - - public void removeRule(String topicPath, String subscriptionName, - String ruleName) { - // TODO Auto-generated method stub - - } - - public Entry getRule(String topicPath, String subscriptionName, - String ruleName) { - // TODO Auto-generated method stub - return null; - } - - public Feed getRules(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; - } - - - - - - -} +package com.microsoft.azure.services.serviceBus.implementation; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.serviceBus.ListQueuesResult; +import com.microsoft.azure.services.serviceBus.ListTopicsResult; +import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.azure.services.serviceBus.Queue; +import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.Topic; +import com.microsoft.azure.utils.ServiceExceptionFactory; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; + +public class ServiceBusServiceImpl implements ServiceBusService { + + private ServiceBusService service; + static Log log = LogFactory.getLog(ServiceBusService.class); + + public ServiceBusServiceImpl(ServiceBusServiceForJersey service) + { + this.service = service; + } + + + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("serviceBus", e); + } + + + public void sendMessage(String path, Message message) + throws ServiceException { + try { + service.sendMessage(path, message); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + try { + return service.receiveQueueMessage(queueName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Message receiveQueueMessage(String queueName, + ReceiveMessageOptions options) throws ServiceException { + try { + return service.receiveQueueMessage(queueName, options); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + try { + return service.receiveSubscriptionMessage(topicName, + subscriptionName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + try { + return service.receiveSubscriptionMessage(topicName, + subscriptionName, options); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void unlockMessage(Message message) throws ServiceException { + try { + service.unlockMessage(message); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void deleteMessage(Message message) throws ServiceException { + try { + service.deleteMessage(message); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Queue createQueue(Queue queue) throws ServiceException { + try { + return service.createQueue(queue); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void deleteQueue(String queuePath) throws ServiceException { + try { + service.deleteQueue(queuePath); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Queue getQueue(String queuePath) throws ServiceException { + try { + return service.getQueue(queuePath); + } 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 Topic createTopic(Topic topic) throws ServiceException { + try { + return service.createTopic(topic); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void deleteTopic(String topicPath) throws ServiceException { + try { + service.deleteTopic(topicPath); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Topic getTopic(String topicPath) throws ServiceException { + try { + return service.getTopic(topicPath); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public ListTopicsResult listTopics() throws ServiceException { + try { + return service.listTopics(); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void addSubscription(String topicPath, String subscriptionName, + Entry subscription) throws ServiceException { + try { + service.addSubscription(topicPath, subscriptionName, subscription); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void removeSubscription(String topicPath, String subscriptionName) + throws ServiceException { + try { + service.removeSubscription(topicPath, subscriptionName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Entry getSubscription(String topicPath, String subscriptionName) + throws ServiceException { + try { + return service.getSubscription(topicPath, subscriptionName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Feed getSubscriptions(String topicPath) throws ServiceException { + try { + return service.getSubscriptions(topicPath); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void addRule(String topicPath, String subscriptionName, + String ruleName, Entry rule) throws ServiceException { + try { + service.addRule(topicPath, subscriptionName, ruleName, rule); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public void removeRule(String topicPath, String subscriptionName, + String ruleName) throws ServiceException { + try { + service.removeRule(topicPath, subscriptionName, ruleName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Entry getRule(String topicPath, String subscriptionName, + String ruleName) throws ServiceException { + try { + return service.getRule(topicPath, subscriptionName, ruleName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + + public Feed getRules(String topicPath, String subscriptionName) + throws ServiceException { + try { + return service.getRules(topicPath, subscriptionName); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java index a2c97a920cb60..a518d5536874e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java @@ -6,7 +6,7 @@ import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceImpl; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceForJersey; public class ContractBuilderTest { @Test @@ -15,6 +15,6 @@ public void testDefaultBuilderCreatesServiceImpl() throws Exception { ServiceBusService service = config.create(ServiceBusService.class); assertNotNull(service); - assertEquals(ServiceBusServiceImpl.class, service.getClass()); + assertEquals(ServiceBusServiceForJersey.class, service.getClass()); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index cc613a2157761..57569afdd112b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -8,6 +8,7 @@ import org.junit.Before; import org.junit.Test; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMode; @@ -199,4 +200,25 @@ public void contentTypePassesThrough() throws Exception { assertNotNull(message); assertEquals("text/xml", message.getContentType()); } + + @Test + public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException{ + // Arrange + String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; + + // Act + Topic created = service.createTopic(new Topic().setName(topicName)); + ListTopicsResult listed = service.listTopics(); + Topic fetched = service.getTopic(topicName); + service.deleteTopic(topicName); + ListTopicsResult listed2 = service.listTopics(); + + // Assert + assertNotNull(created); + assertNotNull(listed); + assertNotNull(fetched); + assertNotNull(listed2); + + assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); + } } From a1173ecb15d0852853f84dc479790e6dc6282119 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 15:16:29 -0700 Subject: [PATCH 082/664] Adding Util.iterateTopics and fixing message body reader for Topic --- .../services/serviceBus/ListQueuesResult.java | 2 +- .../azure/services/serviceBus/Util.java | 10 ++++++++-- .../implementation/EntryModelProvider.java | 16 ++++++++++++++-- .../services/serviceBus/IntegrationTestBase.java | 6 ++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java index f7d43abd506f0..140b4cbffbcf3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java @@ -6,7 +6,7 @@ public class ListQueuesResult { private List items; - List getQueues() { + List getItems() { return items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java index 995e3ce657388..0a4c324d75d0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java @@ -5,7 +5,13 @@ public class Util { public static Iterable iterateQueues(ServiceBusService service) throws ServiceException { - //TODO: iterate over link rel=next pagination - return service.listQueues().getQueues(); + // TODO: iterate over link rel=next pagination + return service.listQueues().getItems(); + } + + public static Iterable iterateTopics(ServiceBusService service) + throws ServiceException { + // TODO: iterate over link rel=next pagination + return service.listTopics().getItems(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java index 5b271faeebfb4..07473beb8c48a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java @@ -4,6 +4,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; import javax.ws.rs.WebApplicationException; @@ -13,7 +14,6 @@ import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; -import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; @@ -43,7 +43,19 @@ public EntryModel readFrom(Class> type, Type genericType, Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, mediaType, httpHeaders, entityStream); - return new Queue(entry); + // these exceptions are masked as a RuntimeException because they cannot + // be thrown by this override + try { + return type.getConstructor(Entry.class).newInstance(entry); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } } public boolean isWriteable(Class type, Type genericType, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index ee39482e2b3e7..406acaf85ac7c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -53,6 +53,12 @@ public void initialize() throws Exception { } } } + for(Topic topic : iterateTopics(service)) { + String topicName = topic.getName(); + if (topicName.startsWith("Test") || topicName.startsWith("test")) { + service.deleteQueue(topicName); + } + } if (!testAlphaExists) { service.createQueue(new Queue().setName("TestAlpha")); } From c99f9e5dd74a546972a8ee1f9b0f4f21e4c60ead Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 4 Nov 2011 16:51:07 -0700 Subject: [PATCH 083/664] Add support for "listPageBlobRegions" --- .../azure/services/blob/BlobService.java | 12 ++-- .../azure/services/blob/BlobServiceImpl.java | 71 ++++++++++++------- ...BlobsResults.java => ListBlobsResult.java} | 2 +- ...Results.java => ListContainersResult.java} | 2 +- .../blob/ListPageBlobRegionsOptions.java | 44 ++++++++++++ .../blob/ListPageBlobRegionsResult.java | 71 +++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 53 +++++++++++--- 7 files changed, 213 insertions(+), 42 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ListBlobsResults.java => ListBlobsResult.java} (99%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ListContainersResults.java => ListContainersResult.java} (98%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index e72793fda35bd..74ea5d3395e7b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -9,9 +9,9 @@ public interface BlobService { void setServiceProperties(ServiceProperties serviceProperties); - ListContainersResults listContainers(); + ListContainersResult listContainers(); - ListContainersResults listContainers(ListContainersOptions options); + ListContainersResult listContainers(ListContainersOptions options); void createContainer(String container); @@ -29,9 +29,9 @@ public interface BlobService { void setContainerMetadata(String container, HashMap metadata); - ListBlobsResults listBlobs(String container); + ListBlobsResult listBlobs(String container); - ListBlobsResults listBlobs(String container, ListBlobsOptions options); + ListBlobsResult listBlobs(String container, ListBlobsOptions options); void createPageBlob(String container, String blob, int length); @@ -54,6 +54,10 @@ UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, lon BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); + ListPageBlobRegionsResult listPageBlobRegions(String container, String blob); + + ListPageBlobRegionsResult listPageBlobRegions(String container, String blob, ListPageBlobRegionsOptions options); + SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options); SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index b47758956e70f..72e990083a30a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -227,11 +227,11 @@ public void setContainerMetadata(String container, HashMap metad builder.header("Content-Type", "text/plain").put(""); } - public ListContainersResults listContainers() { + public ListContainersResult listContainers() { return listContainers(new ListContainersOptions()); } - public ListContainersResults listContainers(ListContainersOptions options) { + public ListContainersResult listContainers(ListContainersOptions options) { WebResource webResource = getResource().path("/").queryParam("comp", "list"); webResource = setCanonicalizedResource(webResource, null, "list"); @@ -242,32 +242,14 @@ public ListContainersResults listContainers(ListContainersOptions options) { webResource = webResource.queryParam("include", "metadata"); } - return webResource.header(X_MS_VERSION, API_VERSION).get(ListContainersResults.class); + return webResource.header(X_MS_VERSION, API_VERSION).get(ListContainersResult.class); } - public ListBlobsResults listBlobs(String container) { + public ListBlobsResult listBlobs(String container) { return listBlobs(container, new ListBlobsOptions()); } - 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(); - } - } - - public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { + public ListBlobsResult listBlobs(String container, ListBlobsOptions options) { WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); @@ -284,7 +266,7 @@ public ListBlobsResults listBlobs(String container, ListBlobsOptions options) { webResource = addOptionalQueryParam(webResource, "include", sb.toString()); } - return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResults.class); + return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResult.class); } public void createPageBlob(String container, String blob, int length) { @@ -672,8 +654,6 @@ private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-page-write", action); - builder = builder.header("x-ms-blob-type", "BlockBlob"); - Object content = (contentStream == null ? "" : contentStream); ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); UpdatePageBlobPagesResult result = new UpdatePageBlobPagesResult(); @@ -683,4 +663,41 @@ private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); return result; } -} + + public ListPageBlobRegionsResult listPageBlobRegions(String container, String blob) { + return listPageBlobRegions(container, blob, new ListPageBlobRegionsOptions()); + } + + public ListPageBlobRegionsResult listPageBlobRegions(String container, String blob, ListPageBlobRegionsOptions options) { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + ClientResponse response = builder.get(ClientResponse.class); + ListPageBlobRegionsResult result = response.getEntity(ListPageBlobRegionsResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + return result; + } + + 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(); + } + }} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index 584c871abd7ca..7f7bee756b88e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResults.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -11,7 +11,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @XmlRootElement(name = "EnumerationResults") -public class ListBlobsResults { +public class ListBlobsResult { private List blobs; private String containerName; private String prefix; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index 501406a1cb754..5b027dfa258e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResults.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -11,7 +11,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @XmlRootElement(name = "EnumerationResults") -public class ListContainersResults { +public class ListContainersResult { private List containers; private String accountName; private String prefix; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java new file mode 100644 index 0000000000000..5a2afd7d248a0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java @@ -0,0 +1,44 @@ +package com.microsoft.azure.services.blob; + +public class ListPageBlobRegionsOptions { + private String leaseId; + private String snapshot; + private Long rangeStart; + private Long rangeEnd; + + public String getLeaseId() { + return leaseId; + } + + public ListPageBlobRegionsOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public String getSnapshot() { + return snapshot; + } + + public ListPageBlobRegionsOptions setSnapshot(String snapshot) { + this.snapshot = snapshot; + return this; + } + + public Long getRangeStart() { + return rangeStart; + } + + public ListPageBlobRegionsOptions setRangeStart(Long rangeStart) { + this.rangeStart = rangeStart; + return this; + } + + public Long getRangeEnd() { + return rangeEnd; + } + + public ListPageBlobRegionsOptions setRangeEnd(Long rangeEnd) { + this.rangeEnd = rangeEnd; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java new file mode 100644 index 0000000000000..b3df499b85a0c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java @@ -0,0 +1,71 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="PageList") +public class ListPageBlobRegionsResult { + private Date lastModified; + private String etag; + private long contentLength; + private List pageRanges; + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public long getContentLength() { + return contentLength; + } + + public void setContentLength(long contentLength) { + this.contentLength = contentLength; + } + + @XmlElement(name="PageRange") + public List getPageRanges() { + return pageRanges; + } + + 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/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 18a341c992d87..5c3bf013a4514 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -93,7 +93,7 @@ public void createContainerWithMetadataWorks() throws Exception { ContainerProperties prop2 = service.getContainerProperties("foo2"); ContainerACL acl = service.getContainerACL("foo2"); - ListContainersResults results2 = service.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( EnumSet.of(ContainerListingDetails.METADATA))); service.deleteContainer("foo2"); @@ -196,7 +196,7 @@ public void listContainersWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = service.listContainers(); + ListContainersResult results = service.listContainers(); // Assert assertNotNull(results); @@ -216,7 +216,7 @@ public void listContainersWithPaginationWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = service.listContainers(new ListContainersOptions().setMaxResults(3)); + ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); // Assert assertNotNull(results); @@ -225,7 +225,7 @@ public void listContainersWithPaginationWorks() throws Exception { assertEquals(3, results.getMaxResults()); // Act - ListContainersResults results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); // Assert assertNotNull(results2); @@ -241,7 +241,7 @@ public void listContainersWithPrefixWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListContainersResults results = service.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); + ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); // Assert assertNotNull(results); @@ -257,7 +257,7 @@ public void listBlobsWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListBlobsResults results = service.listBlobs("mycontainer11"); + ListBlobsResult results = service.listBlobs("mycontainer11"); // Assert assertNotNull(results); @@ -271,7 +271,7 @@ public void listBlobsWithPrefixWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListBlobsResults results = service.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); + ListBlobsResult results = service.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); // Assert assertNotNull(results); @@ -352,10 +352,9 @@ public void updatePageBlobPagesWorks() throws Exception { String container = "mycontainer1"; String blob = "test"; String content = new String(new char[512]); - ByteArrayInputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); service.createPageBlob(container, blob, 512); - UpdatePageBlobPagesResult result = service.updatePageBlobPages(container, blob, 0, 511, content.length(), contentStream); + UpdatePageBlobPagesResult result = service.updatePageBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); // Assert assertNotNull(result); @@ -365,6 +364,42 @@ public void updatePageBlobPagesWorks() throws Exception { assertEquals(0, result.getSequenceNumber()); } + @Test + public void listPageBlobRegionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + String content = new String(new char[512]); + service.createPageBlob(container, blob, 16384 + 512); + + service.updatePageBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.updatePageBlobPages(container, blob, 1024, 1024 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.updatePageBlobPages(container, blob, 8192, 8192 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.updatePageBlobPages(container, blob, 16384, 16384 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + + ListPageBlobRegionsResult result = service.listPageBlobRegions(container, blob); + + // Assert + assertNotNull(result); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(16384 + 512, result.getContentLength()); + assertNotNull(result.getPageRanges()); + assertEquals(4, result.getPageRanges().size()); + assertEquals(0, result.getPageRanges().get(0).getStart()); + assertEquals(511, result.getPageRanges().get(0).getEnd()); + assertEquals(1024, result.getPageRanges().get(1).getStart()); + assertEquals(1024 + 511, result.getPageRanges().get(1).getEnd()); + assertEquals(8192, result.getPageRanges().get(2).getStart()); + assertEquals(8192 + 511, result.getPageRanges().get(2).getEnd()); + assertEquals(16384, result.getPageRanges().get(3).getStart()); + assertEquals(16384 + 511, result.getPageRanges().get(3).getEnd()); + } + @Test public void createBlockBlobWorks() throws Exception { // Arrange From b8612dbb6dec2a18e91705d72d81e77ae52a44fa Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 17:31:29 -0700 Subject: [PATCH 084/664] Changing argument to xxxName for consistency --- .../serviceBus/ServiceBusService.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index f7808957fe581..aa064b848889b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -7,7 +7,7 @@ public interface ServiceBusService { - void sendMessage(String path, Message message) throws ServiceException; + void sendMessage(String queueOrTopicName, Message message) throws ServiceException; Message receiveQueueMessage(String queueName) throws ServiceException; Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; @@ -19,23 +19,23 @@ public interface ServiceBusService { void deleteMessage(Message message) throws ServiceException; Queue createQueue(Queue queue) throws ServiceException; - void deleteQueue(String queuePath) throws ServiceException; - Queue getQueue(String queuePath) throws ServiceException; + void deleteQueue(String queueName) throws ServiceException; + Queue getQueue(String queueName) throws ServiceException; ListQueuesResult listQueues() throws ServiceException; Topic createTopic(Topic topic) throws ServiceException; - void deleteTopic(String topicPath) throws ServiceException; - Topic getTopic(String topicPath) throws ServiceException; + void deleteTopic(String topicName) throws ServiceException; + Topic getTopic(String topicName) throws ServiceException; ListTopicsResult listTopics() throws ServiceException; - void addSubscription(String topicPath, String subscriptionName, Entry subscription) throws ServiceException; - void removeSubscription(String topicPath, String subscriptionName) throws ServiceException; - Entry getSubscription(String topicPath, String subscriptionName) throws ServiceException; - Feed getSubscriptions(String topicPath) throws ServiceException; + void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; + void removeSubscription(String topicName, String subscriptionName) throws ServiceException; + Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; + Feed getSubscriptions(String topicName) throws ServiceException; - void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule) throws ServiceException; - void removeRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; - Entry getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; - Feed getRules(String topicPath, String subscriptionName) throws ServiceException; + void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; + void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + Feed getRules(String topicName, String subscriptionName) throws ServiceException; } From 26fc96e3f32c96d1ab6ab62df54a0910463998fd Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 4 Nov 2011 17:47:09 -0700 Subject: [PATCH 085/664] Splitting sendMessage into sendQueueMessage and sendTopicMessage sendMessage alone was impossible to have consistent parameter naming. it was also the only method that applied to more than one entity. --- .../services/serviceBus/ServiceBusService.java | 4 ++-- .../serviceBus/client/MessagingClient.java | 4 ++-- .../ServiceBusServiceForJersey.java | 11 +++++++++-- .../implementation/ServiceBusServiceImpl.java | 15 +++++++++++++-- .../serviceBus/ServiceBusIntegrationTest.java | 14 +++++++------- 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index aa064b848889b..c4fa4a176caf0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -7,11 +7,11 @@ public interface ServiceBusService { - void sendMessage(String queueOrTopicName, Message message) throws ServiceException; - + void sendQueueMessage(String queueName, Message message) throws ServiceException; Message receiveQueueMessage(String queueName) throws ServiceException; Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + void sendTopicMessage(String topicName, Message message) throws ServiceException; Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java index a2d2f4bb557c6..e98a73335e7de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -47,7 +47,7 @@ public MessageTransceiver openQueue(String queueName) { return new MessageTransceiver() { public void sendMessage(Message message) throws ServiceException { - service.sendMessage(queue, message); + service.sendQueueMessage(queue, message); } public Message receiveMessage() throws ServiceException { @@ -74,7 +74,7 @@ public MessageSender openTopic(String topicName) { final String topic = topicName; return new MessageSender() { public void sendMessage(Message message) throws ServiceException { - service.sendMessage(topic, message); + service.sendQueueMessage(topic, message); } }; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java index 257ca41146ff8..35eca1cf118d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java @@ -66,8 +66,7 @@ private WebResource getResource() { .resource(uri); } - - public void sendMessage(String path, Message message) throws ServiceException { + void sendMessage(String path, Message message) { Builder request = getResource() .path(path) .path("messages") @@ -82,6 +81,9 @@ public void sendMessage(String path, Message message) throws ServiceException { request.post(message.getBody()); } + public void sendQueueMessage(String path, Message message) throws ServiceException { + sendMessage(path, message); + } public Message receiveQueueMessage(String queueName) throws ServiceException { @@ -134,6 +136,11 @@ else if (options.isPeekLock()) { return result; } + public void sendTopicMessage(String topicName, Message message) throws ServiceException + { + sendMessage(topicName, message); + } + public Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { // TODO Auto-generated method stub diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index efb8bb05cfd7c..6160d5872c852 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -32,10 +32,10 @@ private ServiceException processCatch(ServiceException e) { } - public void sendMessage(String path, Message message) + public void sendQueueMessage(String path, Message message) throws ServiceException { try { - service.sendMessage(path, message); + service.sendQueueMessage(path, message); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -68,6 +68,17 @@ public Message receiveQueueMessage(String queueName, } + public void sendTopicMessage(String path, Message message) + throws ServiceException { + try { + service.sendTopicMessage(path, message); + } catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { try { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 57569afdd112b..9a80aeb15ca75 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -78,7 +78,7 @@ public void sendMessageWorks() throws Exception { Message message = new Message("sendMessageWorks"); // Act - service.sendMessage("TestAlpha", message); + service.sendQueueMessage("TestAlpha", message); // Assert } @@ -88,7 +88,7 @@ public void receiveMessageWorks() throws Exception { // Arrange String queueName = "TestReceiveMessageWorks"; service.createQueue(new Queue().setName(queueName)); - service.sendMessage(queueName, new Message("Hello World")); + service.sendQueueMessage(queueName, new Message("Hello World")); // Act Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); @@ -105,7 +105,7 @@ public void peekLockMessageWorks() throws Exception { // Arrange String queueName = "TestPeekLockMessageWorks"; service.createQueue(new Queue().setName(queueName)); - service.sendMessage(queueName, new Message("Hello Again")); + service.sendQueueMessage(queueName, new Message("Hello Again")); // Act Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); @@ -122,7 +122,7 @@ public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeCompleted"; service.createQueue(new Queue().setName(queueName)); - service.sendMessage(queueName, new Message("Hello Again")); + service.sendQueueMessage(queueName, new Message("Hello Again")); Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act @@ -143,7 +143,7 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeUnlocked"; service.createQueue(new Queue().setName(queueName)); - service.sendMessage(queueName, new Message("Hello Again")); + service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act @@ -167,7 +167,7 @@ public void peekLockedMessageCanBeDeleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeDeleted"; service.createQueue(new Queue().setName(queueName)); - service.sendMessage(queueName, new Message("Hello Again")); + service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); // Act @@ -191,7 +191,7 @@ public void contentTypePassesThrough() throws Exception { service.createQueue(new Queue().setName(queueName)); // Act - service.sendMessage(queueName, + service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); From d9b9b4052aa69137cafb3e164fedc3f534ea5247 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 5 Nov 2011 16:42:27 -0700 Subject: [PATCH 086/664] Add support for get/set/commit block list --- .../services/blob/Base64StringAdapter.java | 21 +++ .../azure/services/blob/BlobService.java | 30 ++-- .../azure/services/blob/BlobServiceImpl.java | 105 ++++++++++++-- .../azure/services/blob/BlockList.java | 75 ++++++++++ .../azure/services/blob/BlockListBackup.java | 117 +++++++++++++++ .../blob/CommitBlobBlocksOptions.java | 81 +++++++++++ .../azure/services/blob/CopyBlobOptions.java | 17 ++- ...tions.java => CreateBlobBlockOptions.java} | 5 +- .../services/blob/CreateBlobOptions.java | 5 + .../services/blob/CreateBlobPagesOptions.java | 27 ++++ ...Result.java => CreateBlobPagesResult.java} | 2 +- .../services/blob/ListBlobBlocksOptions.java | 34 +++++ .../services/blob/ListBlobBlocksResult.java | 96 ++++++++++++ ...tions.java => ListBlobRegionsOptions.java} | 10 +- ...Result.java => ListBlobRegionsResult.java} | 2 +- .../blob/BlobServiceIntegrationTest.java | 137 ++++++++++++++++-- 16 files changed, 714 insertions(+), 50 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{UpdatePageBlobPagesOptions.java => CreateBlobBlockOptions.java} (74%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{UpdatePageBlobPagesResult.java => CreateBlobPagesResult.java} (95%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ListPageBlobRegionsOptions.java => ListBlobRegionsOptions.java} (68%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ListPageBlobRegionsResult.java => ListBlobRegionsResult.java} (97%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java new file mode 100644 index 0000000000000..19af74595d1f0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java @@ -0,0 +1,21 @@ +package com.microsoft.azure.services.blob; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +import com.sun.jersey.core.util.Base64; + +/* + * JAXB adapter for element + */ +public class Base64StringAdapter extends XmlAdapter { + + @Override + public String marshal(String arg0) throws Exception { + return new String(Base64.encode(arg0)); + } + + @Override + public String unmarshal(String arg0) throws Exception { + return Base64.base64Decode(arg0); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 74ea5d3395e7b..0cd93c762245e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -37,26 +37,38 @@ public interface BlobService { void createPageBlob(String container, String blob, int length, CreateBlobOptions options); - UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd); + void createBlockBlob(String container, String blob, InputStream content); - UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd, UpdatePageBlobPagesOptions options); + void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options); - UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream); + CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd); - UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, - UpdatePageBlobPagesOptions options); + CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options); - void createBlockBlob(String container, String blob, InputStream content); + CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream); - void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options); + CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + CreateBlobPagesOptions options); + + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream); + + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options); + + void commitBlobBlocks(String container, String blob, BlockList blockList); + + void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options); + + ListBlobBlocksResult listBlobBlocks(String container, String blob); + + ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options); BlobProperties getBlobProperties(String container, String blob); BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); - ListPageBlobRegionsResult listPageBlobRegions(String container, String blob); + ListBlobRegionsResult listBlobRegions(String container, String blob); - ListPageBlobRegionsResult listPageBlobRegions(String container, String blob, ListPageBlobRegionsOptions options); + ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options); SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 72e990083a30a..e07cb41172c93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -13,6 +13,7 @@ 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 BlobServiceImpl implements BlobService { @@ -306,7 +307,8 @@ public void createBlockBlob(String container, String blob, InputStream content, builder = builder.header("x-ms-blob-type", "BlockBlob"); builder = addPutBlobHeaders(options, builder); - builder.put(content); + Object contentObject = (content == null ? new byte[0] : content); + builder.put(contentObject); } private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { @@ -626,25 +628,25 @@ private String putLeaseImpl(String leaseAction, String container, String blob, S return response.getHeaders().getFirst("x-ms-lease-id"); } - public UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd) { - return clearPageBlobPages(container, blob, rangeStart, rangeEnd, new UpdatePageBlobPagesOptions()); + public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) { + return clearBlobPages(container, blob, rangeStart, rangeEnd, new CreateBlobPagesOptions()); } - public UpdatePageBlobPagesResult clearPageBlobPages(String container, String blob, long rangeStart, long rangeEnd, UpdatePageBlobPagesOptions options) { + public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) { return updatePageBlobPagesImpl("clear", container, blob, rangeStart, rangeEnd, 0, null, options); } - public UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) { - return updatePageBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new UpdatePageBlobPagesOptions()); + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) { + return createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new CreateBlobPagesOptions()); } - public UpdatePageBlobPagesResult updatePageBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, - UpdatePageBlobPagesOptions options) { + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + CreateBlobPagesOptions options) { return updatePageBlobPagesImpl("update", container, blob, rangeStart, rangeEnd, length, contentStream, options); } - private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, - InputStream contentStream, UpdatePageBlobPagesOptions options) { + private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, + InputStream contentStream, CreateBlobPagesOptions options) { WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "page"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -656,7 +658,7 @@ private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String Object content = (contentStream == null ? "" : contentStream); ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); - UpdatePageBlobPagesResult result = new UpdatePageBlobPagesResult(); + CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); @@ -664,11 +666,11 @@ private UpdatePageBlobPagesResult updatePageBlobPagesImpl(String action, String return result; } - public ListPageBlobRegionsResult listPageBlobRegions(String container, String blob) { - return listPageBlobRegions(container, blob, new ListPageBlobRegionsOptions()); + public ListBlobRegionsResult listBlobRegions(String container, String blob) { + return listBlobRegions(container, blob, new ListBlobRegionsOptions()); } - public ListPageBlobRegionsResult listPageBlobRegions(String container, String blob, ListPageBlobRegionsOptions options) { + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); @@ -677,7 +679,7 @@ public ListPageBlobRegionsResult listPageBlobRegions(String container, String bl builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); - ListPageBlobRegionsResult result = response.getEntity(ListPageBlobRegionsResult.class); + ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); @@ -700,4 +702,75 @@ public void addValue(EnumSet enumSet, E value, String representation) { public String toString() { return sb.toString(); } - }} + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) { + createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) { + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "block"); + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = builder.type("application/octet-stream"); + + builder.put(contentStream); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList) { + commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) { + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "blocklist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getLeaseId()); + + // Metadata + for (Entry entry : options.getMetadata().entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + + builder.type("application/xml").put(blockList); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob) { + return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); + + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + ClientResponse response = builder.get(ClientResponse.class); + ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentType(response.getHeaders().getFirst("Content-Type")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); +// for (ListBlobBlocksResult.Entry entry : result.getCommittedBlocks()) { +// entry.setBlockId(Base64.base64Decode(entry.getBlockId())); +// } +// for (ListBlobBlocksResult.Entry entry : result.getUncommittedBlocks()) { +// entry.setBlockId(Base64.base64Decode(entry.getBlockId())); +// } + return result; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java new file mode 100644 index 0000000000000..ace0bc4a7f77e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java @@ -0,0 +1,75 @@ +package com.microsoft.azure.services.blob; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +@XmlRootElement(name = "BlockList") +public class BlockList { + private List entries = new ArrayList(); + + public BlockList addCommittedEntry(String blockId) { + CommittedEntry entry = new CommittedEntry(); + entry.setBlockId(blockId); + getEntries().add(entry); + return this; + } + + public BlockList addUncommittedEntry(String blockId) { + UncommittedEntry entry = new UncommittedEntry(); + entry.setBlockId(blockId); + getEntries().add(entry); + return this; + } + + public BlockList addLatestEntry(String blockId) { + LatestEntry entry = new LatestEntry(); + entry.setBlockId(blockId); + getEntries().add(entry); + return this; + } + + @XmlElementRefs({ @XmlElementRef(name = "Committed", type = CommittedEntry.class), @XmlElementRef(name = "Uncommitted", type = UncommittedEntry.class), + @XmlElementRef(name = "Latest", type = LatestEntry.class) }) + @XmlMixed + public List getEntries() { + return entries; + } + + public BlockList setEntries(List entries) { + this.entries = entries; + return this; + } + + public abstract static class Entry { + private String blockId; + + @XmlJavaTypeAdapter(Base64StringAdapter.class) + @XmlValue + public String getBlockId() { + return blockId; + } + + public void setBlockId(String blockId) { + this.blockId = blockId; + } + } + + @XmlRootElement(name = "Committed") + public static class CommittedEntry extends Entry { + } + + @XmlRootElement(name = "Uncommitted") + public static class UncommittedEntry extends Entry { + } + + @XmlRootElement(name = "Latest") + public static class LatestEntry extends Entry { + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java new file mode 100644 index 0000000000000..c85c64183ff33 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java @@ -0,0 +1,117 @@ +package com.microsoft.azure.services.blob; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +@XmlRootElement(name = "BlockList") +public class BlockListBackup { + private List committedEntries = new ArrayList(); + private List uncommittedEntries = new ArrayList(); + private List latestEntries = new ArrayList(); + + public BlockListBackup addCommittedEntry(String blockId) { + getCommittedEntries().add(blockId); + return this; + } + + public BlockListBackup addUncommittedEntry(String blockId) { + getUncommittedEntries().add(blockId); + return this; + } + + public BlockListBackup addLatestEntry(String blockId) { + getLatestEntries().add(blockId); + return this; + } + + @XmlElement(name = "Committed") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getCommittedEntries() { + return committedEntries; + } + + public BlockListBackup setCommittedEntries(List committedEntries) { + this.committedEntries = committedEntries; + return this; + } + + @XmlElement(name = "Uncommitted") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getUncommittedEntries() { + return uncommittedEntries; + } + + public BlockListBackup setUncommittedEntries(List uncommittedEntries) { + this.uncommittedEntries = uncommittedEntries; + return this; + } + + @XmlElement(name = "Latest") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getLatestEntries() { + return latestEntries; + } + + public BlockListBackup setLatestEntries(List latestEntries) { + this.latestEntries = latestEntries; + return this; + } +} +/* +public class BlockList { + private List committedEntries = new ArrayList(); + private List uncommittedEntries = new ArrayList(); + private List latestEntries = new ArrayList(); + + public BlockList addCommittedEntry(String blockId) { + getCommittedEntries().add(blockId); + return this; + } + + public BlockList addUncommittedEntry(String blockId) { + getUncommittedEntries().add(blockId); + return this; + } + + public BlockList addLatestEntry(String blockId) { + getLatestEntries().add(blockId); + return this; + } + + @XmlElement(name = "Committed") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getCommittedEntries() { + return committedEntries; + } + + public BlockList setCommittedEntries(List committedEntries) { + this.committedEntries = committedEntries; + return this; + } + + @XmlElement(name = "Uncommitted") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getUncommittedEntries() { + return uncommittedEntries; + } + + public BlockList setUncommittedEntries(List uncommittedEntries) { + this.uncommittedEntries = uncommittedEntries; + return this; + } + + @XmlElement(name = "Latest") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public List getLatestEntries() { + return latestEntries; + } + + public BlockList setLatestEntries(List latestEntries) { + this.latestEntries = latestEntries; + return this; + } + */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java new file mode 100644 index 0000000000000..7ed574f3f8951 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java @@ -0,0 +1,81 @@ +package com.microsoft.azure.services.blob; + +import java.util.HashMap; + +public class CommitBlobBlocksOptions { + private String blobContentType; + private String blobContentEncoding; + private String blobContentLanguage; + private String blobContentMD5; + private String blobCacheControl; + private HashMap metadata = new HashMap(); + private String leaseId; + + public String getBlobContentType() { + return blobContentType; + } + + public CommitBlobBlocksOptions setBlobContentType(String blobContentType) { + this.blobContentType = blobContentType; + return this; + } + + public String getBlobContentEncoding() { + return blobContentEncoding; + } + + public CommitBlobBlocksOptions setBlobContentEncoding(String blobContentEncoding) { + this.blobContentEncoding = blobContentEncoding; + return this; + } + + public String getBlobContentLanguage() { + return blobContentLanguage; + } + + public CommitBlobBlocksOptions setBlobContentLanguage(String blobContentLanguage) { + this.blobContentLanguage = blobContentLanguage; + return this; + } + + public String getBlobContentMD5() { + return blobContentMD5; + } + + public CommitBlobBlocksOptions setBlobContentMD5(String blobContentMD5) { + this.blobContentMD5 = blobContentMD5; + return this; + } + + public String getBlobCacheControl() { + return blobCacheControl; + } + + public CommitBlobBlocksOptions setBlobCacheControl(String blobCacheControl) { + this.blobCacheControl = blobCacheControl; + return this; + } + + public HashMap getMetadata() { + return metadata; + } + + public CommitBlobBlocksOptions setMetadata(HashMap metadata) { + this.metadata = metadata; + return this; + } + + public CommitBlobBlocksOptions addMetadata(String key, String value) { + this.getMetadata().put(key, value); + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public CommitBlobBlocksOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java index 16b8058f0a815..e31121baf1cb9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java @@ -14,31 +14,40 @@ public String getSourceSnapshot() { return sourceSnapshot; } - public void setSourceSnapshot(String sourceSnapshot) { + public CopyBlobOptions setSourceSnapshot(String sourceSnapshot) { this.sourceSnapshot = sourceSnapshot; + return this; } public HashMap getMetadata() { return metadata; } - public void setMetadata(HashMap metadata) { + public CopyBlobOptions setMetadata(HashMap metadata) { this.metadata = metadata; + return this; + } + + public CopyBlobOptions addMetadata(String key, String value) { + this.getMetadata().put(key, value); + return this; } public String getLeaseId() { return leaseId; } - public void setLeaseId(String leaseId) { + public CopyBlobOptions setLeaseId(String leaseId) { this.leaseId = leaseId; + return this; } public String getSourceLeaseId() { return sourceLeaseId; } - public void setSourceLeaseId(String sourceLeaseId) { + public CopyBlobOptions setSourceLeaseId(String sourceLeaseId) { this.sourceLeaseId = sourceLeaseId; + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java similarity index 74% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java index 74e6f0ef2b098..e1516a819f98c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java @@ -1,12 +1,9 @@ package com.microsoft.azure.services.blob; -public class UpdatePageBlobPagesOptions { +public class CreateBlobBlockOptions { private String leaseId; private String contentMD5; - // TODO: Add "if" from - // http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx - public String getLeaseId() { return leaseId; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java index 40d008feaa6f1..9033e493722b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java @@ -116,6 +116,11 @@ public CreateBlobOptions setMetadata(HashMap metadata) { return this; } + public CreateBlobOptions addMetadata(String key, String value) { + this.getMetadata().put(key, value); + return this; + } + public String getLeaseId() { return leaseId; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java new file mode 100644 index 0000000000000..90d42c9ac4dbc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java @@ -0,0 +1,27 @@ +package com.microsoft.azure.services.blob; + +public class CreateBlobPagesOptions { + private String leaseId; + private String contentMD5; + + // TODO: Add "if" from + // http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx + + public String getLeaseId() { + return leaseId; + } + + public CreateBlobPagesOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public String getContentMD5() { + return contentMD5; + } + + public CreateBlobPagesOptions setContentMD5(String contentMD5) { + this.contentMD5 = contentMD5; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java index 964471addca29..b41effe812734 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/UpdatePageBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java @@ -2,7 +2,7 @@ import java.util.Date; -public class UpdatePageBlobPagesResult { +public class CreateBlobPagesResult { private String etag; private Date lastModified; private String contentMD5; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java new file mode 100644 index 0000000000000..7577019948302 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java @@ -0,0 +1,34 @@ +package com.microsoft.azure.services.blob; + +public class ListBlobBlocksOptions { + private String leaseId; + private String snapshot; + private String listType; // "committed", "uncommitted", "all" + + public String getLeaseId() { + return leaseId; + } + + public ListBlobBlocksOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public String getSnapshot() { + return snapshot; + } + + public ListBlobBlocksOptions setSnapshot(String snapshot) { + this.snapshot = snapshot; + return this; + } + + public String getListType() { + return listType; + } + + public ListBlobBlocksOptions setListType(String listType) { + this.listType = listType; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java new file mode 100644 index 0000000000000..bfc97e3211d07 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java @@ -0,0 +1,96 @@ +package com.microsoft.azure.services.blob; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +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; + +@XmlRootElement(name = "BlockList") +public class ListBlobBlocksResult { + private Date lastModified; + private String etag; + private String contentType; + private long contentLength; + private List committedBlocks = new ArrayList(); + private List uncommittedBlocks = new ArrayList(); + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public long getContentLength() { + return contentLength; + } + + public void setContentLength(long contentLength) { + this.contentLength = contentLength; + } + + @XmlElementWrapper(name = "CommittedBlocks") + @XmlElement(name = "Block") + public List getCommittedBlocks() { + return committedBlocks; + } + + public void setCommittedBlocks(List committedBlocks) { + this.committedBlocks = committedBlocks; + } + + @XmlElementWrapper(name = "UncommittedBlocks") + @XmlElement(name = "Block") + public List getUncommittedBlocks() { + return uncommittedBlocks; + } + + public void setUncommittedBlocks(List uncommittedBlocks) { + this.uncommittedBlocks = uncommittedBlocks; + } + + public static class Entry { + private String blockId; + private long blockLength; + + @XmlElement(name = "Name") + @XmlJavaTypeAdapter(Base64StringAdapter.class) + public String getBlockId() { + return blockId; + } + + public void setBlockId(String blockId) { + this.blockId = blockId; + } + + @XmlElement(name = "Size") + public long getBlockLength() { + return blockLength; + } + + public void setBlockLength(long blockLength) { + this.blockLength = blockLength; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java similarity index 68% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java index 5a2afd7d248a0..995110267b28b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class ListPageBlobRegionsOptions { +public class ListBlobRegionsOptions { private String leaseId; private String snapshot; private Long rangeStart; @@ -10,7 +10,7 @@ public String getLeaseId() { return leaseId; } - public ListPageBlobRegionsOptions setLeaseId(String leaseId) { + public ListBlobRegionsOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } @@ -19,7 +19,7 @@ public String getSnapshot() { return snapshot; } - public ListPageBlobRegionsOptions setSnapshot(String snapshot) { + public ListBlobRegionsOptions setSnapshot(String snapshot) { this.snapshot = snapshot; return this; } @@ -28,7 +28,7 @@ public Long getRangeStart() { return rangeStart; } - public ListPageBlobRegionsOptions setRangeStart(Long rangeStart) { + public ListBlobRegionsOptions setRangeStart(Long rangeStart) { this.rangeStart = rangeStart; return this; } @@ -37,7 +37,7 @@ public Long getRangeEnd() { return rangeEnd; } - public ListPageBlobRegionsOptions setRangeEnd(Long rangeEnd) { + public ListBlobRegionsOptions setRangeEnd(Long rangeEnd) { this.rangeEnd = rangeEnd; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java index b3df499b85a0c..675ce97ec3737 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListPageBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java @@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="PageList") -public class ListPageBlobRegionsResult { +public class ListBlobRegionsResult { private Date lastModified; private String etag; private long contentLength; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 5c3bf013a4514..6a30b3eac6862 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -322,7 +322,7 @@ public void createPageBlobWithOptionsWorks() throws Exception { } @Test - public void clearPageBlobPagesWorks() throws Exception { + public void clearBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); @@ -332,7 +332,7 @@ public void clearPageBlobPagesWorks() throws Exception { String blob = "test"; service.createPageBlob(container, blob, 512); - UpdatePageBlobPagesResult result = service.clearPageBlobPages(container, blob, 0, 511); + CreateBlobPagesResult result = service.clearBlobPages(container, blob, 0, 511); // Assert assertNotNull(result); @@ -343,7 +343,7 @@ public void clearPageBlobPagesWorks() throws Exception { } @Test - public void updatePageBlobPagesWorks() throws Exception { + public void createBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); @@ -354,7 +354,7 @@ public void updatePageBlobPagesWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 512); - UpdatePageBlobPagesResult result = service.updatePageBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + CreateBlobPagesResult result = service.createBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); // Assert assertNotNull(result); @@ -365,7 +365,7 @@ public void updatePageBlobPagesWorks() throws Exception { } @Test - public void listPageBlobRegionsWorks() throws Exception { + public void listBlobRegionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); @@ -376,12 +376,12 @@ public void listPageBlobRegionsWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 16384 + 512); - service.updatePageBlobPages(container, blob, 0, 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.updatePageBlobPages(container, blob, 1024, 1024 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.updatePageBlobPages(container, blob, 8192, 8192 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.updatePageBlobPages(container, blob, 16384, 16384 + 511, content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); + 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"))); - ListPageBlobRegionsResult result = service.listPageBlobRegions(container, blob); + ListBlobRegionsResult result = service.listBlobRegions(container, blob); // Assert assertNotNull(result); @@ -400,6 +400,123 @@ public void listPageBlobRegionsWorks() throws Exception { assertEquals(16384 + 511, result.getPageRanges().get(3).getEnd()); } + @Test + public void listBlobBlocksOnEmptyBlobWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test13"; + String content = new String(new char[512]); + service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); + + ListBlobBlocksResult result = service.listBlobBlocks(container, blob); + + // Assert + assertNotNull(result); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(512, result.getContentLength()); + assertNotNull(result.getCommittedBlocks()); + assertEquals(0, result.getCommittedBlocks().size()); + //assertNotNull(result.getCommittedBlocks().get(0).getBlockId()); + //assertEquals(512, result.getCommittedBlocks().get(0).getBlockLength()); + assertNotNull(result.getUncommittedBlocks()); + assertEquals(0, result.getUncommittedBlocks().size()); + } + + @Test + public void listBlobBlocksWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test14"; + service.createBlockBlob(container, blob, null); + service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(new byte[256])); + service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); + service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); + + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setListType("all")); + + // Assert + assertNotNull(result); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(0, result.getContentLength()); + assertNotNull(result.getCommittedBlocks()); + assertEquals(0, result.getCommittedBlocks().size()); + assertNotNull(result.getUncommittedBlocks()); + assertEquals(3, result.getUncommittedBlocks().size()); + assertEquals("123", result.getUncommittedBlocks().get(0).getBlockId()); + assertEquals(256, result.getUncommittedBlocks().get(0).getBlockLength()); + assertEquals("124", result.getUncommittedBlocks().get(1).getBlockId()); + assertEquals(512, result.getUncommittedBlocks().get(1).getBlockLength()); + assertEquals("125", result.getUncommittedBlocks().get(2).getBlockId()); + assertEquals(195, result.getUncommittedBlocks().get(2).getBlockLength()); + } + + @Test + public void commitBlobBlocksWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test14"; + String blockId1 = "1fedcba"; + String blockId2 = "2abcdef"; + String blockId3 = "3zzzzzz"; + service.createBlockBlob(container, blob, null); + service.createBlobBlock(container, blob, blockId1, new ByteArrayInputStream(new byte[256])); + service.createBlobBlock(container, blob, blockId2, new ByteArrayInputStream(new byte[512])); + service.createBlobBlock(container, blob, blockId3, new ByteArrayInputStream(new byte[195])); + + BlockList blockList = new BlockList(); + blockList.addUncommittedEntry(blockId1).addLatestEntry(blockId3); + service.commitBlobBlocks(container, blob, blockList); + + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setListType("all")); + + // Assert + assertNotNull(result); + assertNotNull(result.getLastModified()); + assertNotNull(result.getEtag()); + assertEquals(256 + 195, result.getContentLength()); + + assertNotNull(result.getCommittedBlocks()); + assertEquals(2, result.getCommittedBlocks().size()); + assertEquals(blockId1, result.getCommittedBlocks().get(0).getBlockId()); + assertEquals(256, result.getCommittedBlocks().get(0).getBlockLength()); + assertEquals(blockId3, result.getCommittedBlocks().get(1).getBlockId()); + assertEquals(195, result.getCommittedBlocks().get(1).getBlockLength()); + + assertNotNull(result.getUncommittedBlocks()); + assertEquals(0, result.getUncommittedBlocks().size()); + } + + @Test + public void createBlobBlockWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test13"; + String content = new String(new char[512]); + service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(content.getBytes("UTF-8"))); + + // Assert + } + @Test public void createBlockBlobWorks() throws Exception { // Arrange From d86cb0844693abb55c3f4f5d3a8250f87000fdd7 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 5 Nov 2011 17:06:22 -0700 Subject: [PATCH 087/664] Remove unused file --- .../com/microsoft/azure/utils/Base64.java | 178 ------------------ .../microsoft/azure/utils/HmacSHA256Sign.java | 4 +- 2 files changed, 3 insertions(+), 179 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java deleted file mode 100644 index 901f8e0591d58..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.microsoft.azure.utils; - -/** - * TODO: Use a common library instead - * - * Provides Base64 encoding, decoding, and validation functionality. - * - * Copyright (c)2011 Microsoft. All rights reserved. - */ -final class Base64 { - private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - /** - * Decoded values, -1 is invalid character, -2 is = pad character. - */ - private static final byte decode64[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* - * 16- 31 - */ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* - * 32- 47 - */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, /* - * 48- 63 - */ - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 64-79 */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* - * 80- 95 - */ - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* - * 96- 111 - */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* - * 112- 127 - */ - }; - - /** - * Decodes a given Base64 string into its corresponding byte array. - * - * @param data - * the Base64 string, as a String object, to decode - * - * @return the corresponding decoded byte array - * @throws IllegalArgumentException - * If the string is not a valid base64 encoded string - */ - public static byte[] decode(String data) throws IllegalArgumentException { - int byteArrayLength = 3 * data.length() / 4; - - if (data.endsWith("==")) { - byteArrayLength -= 2; - } else if (data.endsWith("=")) { - byteArrayLength -= 1; - } - - byte[] retArray = new byte[byteArrayLength]; - int byteDex = 0; - int charDex = 0; - - for (; charDex < data.length(); charDex += 4) { - // get 4 chars, convert to 3 bytes - int char1 = decode64[(byte) data.charAt(charDex)]; - int char2 = decode64[(byte) data.charAt(charDex + 1)]; - int char3 = decode64[(byte) data.charAt(charDex + 2)]; - int char4 = decode64[(byte) data.charAt(charDex + 3)]; - - if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { - // invalid character(-1), or bad padding (-2) - throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); - } - - int tVal = char1 << 18; - tVal += char2 << 12; - tVal += (char3 & 0xff) << 6; - tVal += char4 & 0xff; - - if (char3 == -2) { - // two "==" pad chars, check bits 12-24 - tVal &= 0x00FFF000; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - } else if (char4 == -2) { - // one pad char "=" , check bits 6-24. - tVal &= 0x00FFFFC0; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - - } else { - // No pads take all 3 bytes, bits 0-24 - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - retArray[byteDex++] = (byte) (tVal & 0xFF); - } - } - return retArray; - } - - /** - * Encodes a byte array as a Base64 string. - * - * @param data - * the byte array to encode - * @return the Base64-encoded string, as a String object - */ - public static String encode(byte[] data) { - StringBuilder builder = new StringBuilder(); - int dataRemainder = data.length % 3; - - int j = 0; - int n = 0; - for (; j < data.length; j += 3) { - - if (j < data.length - dataRemainder) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); - } else { - if (dataRemainder == 1) { - n = (data[j] & 0xFF) << 16; - } else if (dataRemainder == 2) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); - } - } - - // Left here for readability - // byte char1 = (byte) ((n >>> 18) & 0x3F); - // byte char2 = (byte) ((n >>> 12) & 0x3F); - // byte char3 = (byte) ((n >>> 6) & 0x3F); - // byte char4 = (byte) (n & 0x3F); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); - } - - int bLength = builder.length(); - - // append '=' to pad - if (data.length % 3 == 1) { - builder.replace(bLength - 2, bLength, "=="); - } else if (data.length % 3 == 2) { - builder.replace(bLength - 1, bLength, "="); - } - - return builder.toString(); - } - - /** - * Determines whether the given string contains only Base64 characters. - * - * @param data - * the string, as a String object, to validate - * @return true if data is a valid Base64 string, otherwise false - */ - public static Boolean validateIsBase64String(String data) { - - if (data == null || data.length() % 4 != 0) { - return false; - } - - for (int m = 0; m < data.length(); m++) { - byte charByte = (byte) data.charAt(m); - - // pad char detected - if (decode64[charByte] == -2) { - if (m < data.length() - 2) { - return false; - } else if (m == data.length() - 2 && decode64[(byte) data.charAt(m + 1)] != -2) { - return false; - } - } - - if (charByte < 0 || decode64[charByte] == -1) { - return false; - } - } - - return true; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java index 61fc2d32b9191..ec52c7be9ec3f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java @@ -3,6 +3,8 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import com.sun.jersey.core.util.Base64; + public class HmacSHA256Sign { private final String accessKey; @@ -18,7 +20,7 @@ public String sign(String stringToSign) { Mac hmac = Mac.getInstance("hmacSHA256"); hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); - return Base64.encode(digest); + return new String(Base64.encode(digest)); } catch (Exception e) { throw new IllegalArgumentException("accessKey", e); From 50cbe727f8c7140b5cc3fb8d9210cd20d384ff85 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 5 Nov 2011 17:40:05 -0700 Subject: [PATCH 088/664] Code cleanup --- .../services/blob/Base64StringAdapter.java | 2 +- .../azure/services/blob/BlobService.java | 4 +- .../azure/services/blob/BlobServiceImpl.java | 337 +++++++----------- 3 files changed, 134 insertions(+), 209 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java index 19af74595d1f0..39d6dda4e39ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java @@ -5,7 +5,7 @@ import com.sun.jersey.core.util.Base64; /* - * JAXB adapter for element + * JAXB adapter for a Base64 encoded string element */ public class Base64StringAdapter extends XmlAdapter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 0cd93c762245e..1a32593ccf0ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -37,9 +37,9 @@ public interface BlobService { void createPageBlob(String container, String blob, int length, CreateBlobOptions options); - void createBlockBlob(String container, String blob, InputStream content); + void createBlockBlob(String container, String blob, InputStream contentStream); - void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options); + void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options); CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index e07cb41172c93..0be0cd7be9a1c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -4,6 +4,7 @@ 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; @@ -36,6 +37,24 @@ public BlobServiceImpl(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) St channel.addFilter(filter); } + 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 wr, String key, String value) { if (value != null) { wr = wr.queryParam(key, value); @@ -43,11 +62,11 @@ private WebResource addOptionalQueryParam(WebResource wr, String key, String val return wr; } - private WebResource addOptionalQueryParam(WebResource wr, String key, int value, int defaultValue) { + private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { if (value != defaultValue) { - wr = wr.queryParam(key, Integer.toString(value)); + webResource = webResource.queryParam(key, Integer.toString(value)); } - return wr; + return webResource; } private Builder addOptionalHeader(Builder builder, String name, Object value) { @@ -57,6 +76,13 @@ private Builder addOptionalHeader(Builder builder, String name, Object value) { return builder; } + private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { + for (Entry entry : metadata.entrySet()) { + builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + } + return builder; + } + private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { if (rangeStart != null) { String range = rangeStart.toString() + "-"; @@ -89,6 +115,29 @@ private WebResource setCanonicalizedResource(WebResource wr, String resourceName return wr; } + private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { + // Specifies the name of the source blob, in one of the following + // formats: + // Blob in named container: /accountName/containerName/blobName + // + // Snapshot in named container: + // /accountName/containerName/blobName?snapshot= + // + // Blob in root container: /accountName/blobName + // + // Snapshot in root container: /accountName/blobName?snapshot= + String sourceName = "/" + this.accountName; + if (sourceContainer != null) { + sourceName += "/" + sourceContainer; + } + sourceName += "/" + sourceBlob; + if (options.getSourceSnapshot() != null) { + sourceName += "?snapshot=" + options.getSourceSnapshot(); + } + return sourceName; + } + + public ServiceProperties getServiceProperties() { // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); @@ -111,35 +160,23 @@ public void createContainer(String container) { public void createContainer(String container, CreateContainerOptions options) { WebResource webResource = getResource().path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, null); WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, options.getPublicAccess()); - // Metadata - for (Entry entry : options.getMetadata().entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } - - // Public access - if (options.getPublicAccess() != null) { - builder = builder.header(X_MS_BLOB_PUBLIC_ACCESS, options.getPublicAccess()); - } - - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. - builder.header("Content-Type", "text/plain").put(""); + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); } public void deleteContainer(String container) { - WebResource webResource = getResource(); + WebResource webResource = getResource().path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); - webResource.path(container).queryParam("resType", "container").header(X_MS_VERSION, API_VERSION).delete(); + + WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + builder.delete(); } public ContainerProperties getContainerProperties(String container) { @@ -152,13 +189,12 @@ public ContainerProperties getContainerMetadata(String container) { private ContainerProperties getContainerPropertiesImpl(String container, String operation) { WebResource webResource = getResource().path(container).queryParam("resType", "container"); - if (operation != null) { - webResource = webResource.queryParam("comp", operation); - } - + webResource = addOptionalQueryParam(webResource, "comp", operation); webResource = setCanonicalizedResource(webResource, container, operation); - ClientResponse response = webResource.header(X_MS_VERSION, API_VERSION).get(ClientResponse.class); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); @@ -181,7 +217,9 @@ public ContainerACL getContainerACL(String container) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); webResource = setCanonicalizedResource(webResource, container, "acl"); - ClientResponse response = webResource.header(X_MS_VERSION, API_VERSION).get(ClientResponse.class); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); ContainerACL acl = new ContainerACL(); @@ -197,35 +235,23 @@ public void setContainerACL(String container, ContainerACL acl) { webResource = setCanonicalizedResource(webResource, container, "acl"); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); - // Note: Add content type here to enable proper HMAC signing - // builder = builder.header("Content-Type", "application/xml"); builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, acl.getPublicAccess()); ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); si.setSignedIdentifiers(acl.getSignedIdentifiers()); + // Note: Add content type here to enable proper HMAC signing builder.type("application/xml").put(si); } public void setContainerMetadata(String container, HashMap metadata) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container, "metadata"); WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalMetadataHeader(builder, metadata); - // Metadata - for (Entry entry : metadata.entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } - - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. - builder.header("Content-Type", "text/plain").put(""); + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); } public ListContainersResult listContainers() { @@ -234,7 +260,6 @@ public ListContainersResult listContainers() { public ListContainersResult listContainers(ListContainersOptions options) { WebResource webResource = getResource().path("/").queryParam("comp", "list"); - webResource = setCanonicalizedResource(webResource, null, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); @@ -243,7 +268,9 @@ public ListContainersResult listContainers(ListContainersOptions options) { webResource = webResource.queryParam("include", "metadata"); } - return webResource.header(X_MS_VERSION, API_VERSION).get(ListContainersResult.class); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + return builder.get(ListContainersResult.class); } public ListBlobsResult listBlobs(String container) { @@ -267,7 +294,9 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) { webResource = addOptionalQueryParam(webResource, "include", sb.toString()); } - return webResource.header(X_MS_VERSION, API_VERSION).get(ListBlobsResult.class); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + + return builder.get(ListBlobsResult.class); } public void createPageBlob(String container, String blob, int length) { @@ -277,46 +306,39 @@ public void createPageBlob(String container, String blob, int length) { public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); - builder = builder.header("x-ms-blob-type", "PageBlob"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); + builder = addOptionalHeader(builder, "Content-Length", 0); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); builder = addPutBlobHeaders(options, builder); - builder = builder.header("Content-Length", 0); - builder = builder.header("x-ms-blob-content-length", length); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing builder.type("text/plain").put(""); } - public void createBlockBlob(String container, String blob, InputStream content) { - createBlockBlob(container, blob, content, new CreateBlobOptions()); + public void createBlockBlob(String container, String blob, InputStream contentStream) { + createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); } - public void createBlockBlob(String container, String blob, InputStream content, CreateBlobOptions options) { + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = builder.header("x-ms-blob-type", "BlockBlob"); builder = addPutBlobHeaders(options, builder); - Object contentObject = (content == null ? new byte[0] : content); + Object contentObject = (contentStream == null ? new byte[0] : contentStream); builder.put(contentObject); } private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); if (options.getContentType() == null) { - // This is technically the default, but we explicitly add here to - // allow proper - // signing of the request headers. + // Note: Add content type here to enable proper HMAC signing builder = builder.type("application/octet-stream"); } builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); @@ -329,11 +351,7 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - - // Metadata - for (Entry entry : options.getMetadata().entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } + builder = addOptionalMetadataHeader(builder, options.getMetadata()); // TODO: Conditional headers (If Match, etc.) @@ -347,10 +365,7 @@ public BlobProperties getBlobProperties(String container, String blob) { public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) { WebResource webResource = getResource().path(container).path(blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - - if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - } + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -362,7 +377,6 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -376,13 +390,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); SetBlobPropertiesResult result = new SetBlobPropertiesResult(); @@ -402,24 +410,13 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, metadata); - // Metadata - for (Entry entry : metadata.entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } - - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); SetBlobMetadataResult result = new SetBlobMetadataResult(); @@ -435,15 +432,10 @@ public Blob getBlob(String container, String blob) { public Blob getBlob(String container, String blob, GetBlobOptions options) { WebResource webResource = getResource().path(container).path(blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - - if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - } + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); ClientResponse response = builder.get(ClientResponse.class); @@ -496,10 +488,7 @@ public void deleteBlob(String container, String blob) { public void deleteBlob(String container, String blob, DeleteBlobOptions options) { WebResource webResource = getResource().path(container + "/" + blob); - if (options.getSnapshot() != null) { - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - } - + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); @@ -516,23 +505,14 @@ public BlobSnapshot createBlobSnapshot(String container, String blob) { public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) { WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - // Metadata - for (Entry entry : options.getMetadata().entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } + builder = addOptionalMetadataHeader(builder, options.getMetadata()); // TODO: Conditional headers (If Match, etc.) - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); BlobSnapshot blobSnapshot = new BlobSnapshot(); @@ -548,47 +528,18 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { - WebResource webResource = getResource().path(destinationContainer + "/" + destinationBlob); + WebResource webResource = getResource().path(destinationContainer).path(destinationBlob); webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); - - // Specifies the name of the source blob, in one of the following - // formats: - // Blob in named container: /accountName/containerName/blobName - // - // Snapshot in named container: - // /accountName/containerName/blobName?snapshot= - // - // Blob in root container: /accountName/blobName - // - // Snapshot in root container: /accountName/blobName?snapshot= - String sourceName = "/" + this.accountName; - if (sourceContainer != null) { - sourceName += "/" + sourceContainer; - } - sourceName += "/" + sourceBlob; - if (options.getSourceSnapshot() != null) { - sourceName += "?snapshot=" + options.getSourceSnapshot(); - } - builder = addOptionalHeader(builder, "x-ms-copy-source", sourceName); - - // Metadata - for (Entry entry : options.getMetadata().entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } + builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); // TODO: Conditional headers (If Match, etc.) - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing builder.type("text/plain").put(""); } @@ -609,20 +560,14 @@ public void breakLease(String container, String blob, String leaseId) { } private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId) { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "lease"); + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); - // TODO: We need the following 2 to make sure that "Content-Length:0" - // header - // is sent to the server (IIS doesn't accept PUT without a content - // length). - // Since we are sending a "dummy" string, we also need to set the - // "Content-Type" header so that the hmac filter will see it when - // producing the authorization hmac. + // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); return response.getHeaders().getFirst("x-ms-lease-id"); @@ -647,8 +592,9 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, long private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, InputStream contentStream, CreateBlobPagesOptions options) { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "page"); + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "page"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); builder = addOptionalHeader(builder, "Content-Length", length); @@ -656,13 +602,16 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-page-write", action); - Object content = (contentStream == null ? "" : contentStream); + // Note: Add content type here to enable proper HMAC signing + Object content = (contentStream == null ? new byte[0] : contentStream); ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); + CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + return result; } @@ -679,29 +628,13 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); + ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - return result; - } - - 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(); - } + return result; } public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) { @@ -709,17 +642,16 @@ public void createBlobBlock(String container, String blob, String blockId, Input } public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "block"); + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "block"); webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - builder = builder.type("application/octet-stream"); - builder.put(contentStream); + // Note: Add content type here to enable proper HMAC signing + builder.type("application/octet-stream").put(contentStream); } public void commitBlobBlocks(String container, String blob, BlockList blockList) { @@ -727,21 +659,19 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) } public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "blocklist"); + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getLeaseId()); - - // Metadata - for (Entry entry : options.getMetadata().entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); - } + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + // Note: Add content type here to enable proper HMAC signing builder.type("application/xml").put(blockList); } @@ -751,26 +681,21 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) { public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); + ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentType(response.getHeaders().getFirst("Content-Type")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); -// for (ListBlobBlocksResult.Entry entry : result.getCommittedBlocks()) { -// entry.setBlockId(Base64.base64Decode(entry.getBlockId())); -// } -// for (ListBlobBlocksResult.Entry entry : result.getUncommittedBlocks()) { -// entry.setBlockId(Base64.base64Decode(entry.getBlockId())); -// } + return result; } } From af339781ebe62e9cd72ed154482dd3966c2b875c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 5 Nov 2011 17:47:24 -0700 Subject: [PATCH 089/664] Code cleanup --- .../azure/services/blob/BlobServiceImpl.java | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 0be0cd7be9a1c..c5bf76d08c1bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -18,9 +18,6 @@ public class BlobServiceImpl implements BlobService { - private static final String X_MS_VERSION = "x-ms-version"; - private static final String X_MS_BLOB_PUBLIC_ACCESS = "x-ms-blob-public-access"; - private static final String X_MS_META_PREFIX = "x-ms-meta-"; private static final String API_VERSION = "2011-08-18"; private final Client channel; private final String accountName; @@ -78,7 +75,7 @@ private Builder addOptionalHeader(Builder builder, String name, Object value) { private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { for (Entry entry : metadata.entrySet()) { - builder = builder.header(X_MS_META_PREFIX + entry.getKey(), entry.getValue()); + builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); } return builder; } @@ -143,7 +140,9 @@ public ServiceProperties getServiceProperties() { WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); - return webResource.header(X_MS_VERSION, API_VERSION).get(ServiceProperties.class); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ServiceProperties.class); } public void setServiceProperties(ServiceProperties serviceProperties) { @@ -151,7 +150,10 @@ public void setServiceProperties(ServiceProperties serviceProperties) { WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); - webResource.header(X_MS_VERSION, API_VERSION).type("application/xml").put(serviceProperties); + 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 createContainer(String container) { @@ -162,9 +164,9 @@ public void createContainer(String container, CreateContainerOptions options) { WebResource webResource = getResource().path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); - WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, options.getPublicAccess()); + builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); // Note: Add content type here to enable proper HMAC signing builder.type("text/plain").put(""); @@ -174,7 +176,7 @@ public void deleteContainer(String container) { WebResource webResource = getResource().path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); - WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder.delete(); } @@ -192,7 +194,7 @@ private ContainerProperties getContainerPropertiesImpl(String container, String webResource = addOptionalQueryParam(webResource, "comp", operation); webResource = setCanonicalizedResource(webResource, container, operation); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); ClientResponse response = builder.get(ClientResponse.class); @@ -203,8 +205,8 @@ private ContainerProperties getContainerPropertiesImpl(String container, String // Metadata HashMap metadata = new HashMap(); for (Entry> entry : response.getHeaders().entrySet()) { - if (entry.getKey().startsWith(X_MS_META_PREFIX)) { - String name = entry.getKey().substring(X_MS_META_PREFIX.length()); + 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); } @@ -217,14 +219,14 @@ public ContainerACL getContainerACL(String container) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); webResource = setCanonicalizedResource(webResource, container, "acl"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); ClientResponse response = builder.get(ClientResponse.class); ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); ContainerACL acl = new ContainerACL(); acl.setSignedIdentifiers(si.getSignedIdentifiers()); - acl.setPublicAccess(response.getHeaders().getFirst(X_MS_BLOB_PUBLIC_ACCESS)); + acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); acl.setEtag(response.getHeaders().getFirst("ETag")); acl.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return acl; @@ -234,8 +236,8 @@ public void setContainerACL(String container, ContainerACL acl) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); webResource = setCanonicalizedResource(webResource, container, "acl"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); - builder = addOptionalHeader(builder, X_MS_BLOB_PUBLIC_ACCESS, acl.getPublicAccess()); + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); si.setSignedIdentifiers(acl.getSignedIdentifiers()); @@ -247,7 +249,7 @@ public void setContainerMetadata(String container, HashMap metad WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container, "metadata"); - WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, metadata); // Note: Add content type here to enable proper HMAC signing @@ -268,7 +270,7 @@ public ListContainersResult listContainers(ListContainersOptions options) { webResource = webResource.queryParam("include", "metadata"); } - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); return builder.get(ListContainersResult.class); } @@ -294,7 +296,7 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) { webResource = addOptionalQueryParam(webResource, "include", sb.toString()); } - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); return builder.get(ListBlobsResult.class); } @@ -307,7 +309,7 @@ public void createPageBlob(String container, String blob, int length, CreateBlob WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); builder = addOptionalHeader(builder, "Content-Length", 0); builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); @@ -326,7 +328,7 @@ public void createBlockBlob(String container, String blob, InputStream contentSt WebResource webResource = getResource().path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = builder.header("x-ms-blob-type", "BlockBlob"); builder = addPutBlobHeaders(options, builder); @@ -367,7 +369,7 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.method("HEAD", ClientResponse.class); @@ -379,7 +381,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); - WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); @@ -412,7 +414,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); - WebResource.Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalMetadataHeader(builder, metadata); @@ -434,7 +436,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) { webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); @@ -456,8 +458,8 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { // Metadata HashMap metadata = new HashMap(); for (Entry> entry : response.getHeaders().entrySet()) { - if (entry.getKey().startsWith(X_MS_META_PREFIX)) { - String name = entry.getKey().substring(X_MS_META_PREFIX.length()); + 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); } @@ -491,7 +493,7 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphots()); @@ -506,7 +508,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalMetadataHeader(builder, options.getMetadata()); @@ -531,7 +533,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String WebResource webResource = getResource().path(destinationContainer).path(destinationBlob); webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); @@ -563,7 +565,7 @@ private String putLeaseImpl(String leaseAction, String container, String blob, S WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); @@ -595,7 +597,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "page"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); builder = addOptionalHeader(builder, "Content-Length", length); builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); @@ -623,7 +625,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -646,7 +648,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); @@ -662,7 +664,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList, WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); @@ -685,7 +687,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); - Builder builder = webResource.header(X_MS_VERSION, API_VERSION); + Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); From a92915821fddb8578001e325156a41c059ed48b0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sat, 5 Nov 2011 19:08:23 -0700 Subject: [PATCH 090/664] Throw exceptions systematically --- .../azure/services/blob/BlobServiceImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index c5bf76d08c1bb..f6db8a341fc52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -12,6 +12,7 @@ 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; @@ -34,6 +35,12 @@ public BlobServiceImpl(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) St channel.addFilter(filter); } + private void ThrowIfError(ClientResponse r) { + if (r.getStatus() >= 300) { + throw new UniformInterfaceException(r); + } + } + private class EnumCommaStringBuilder> { private final StringBuilder sb = new StringBuilder(); @@ -134,7 +141,6 @@ private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, return sourceName; } - public ServiceProperties getServiceProperties() { // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); @@ -197,6 +203,7 @@ private ContainerProperties getContainerPropertiesImpl(String container, String Builder builder = webResource.header("x-ms-version", API_VERSION); ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); @@ -222,6 +229,7 @@ public ContainerACL getContainerACL(String container) { Builder builder = webResource.header("x-ms-version", API_VERSION); ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); ContainerACL acl = new ContainerACL(); @@ -373,6 +381,7 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.method("HEAD", ClientResponse.class); + ThrowIfError(response); return getBlobPropertiesFromResponse(response); } @@ -394,6 +403,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); SetBlobPropertiesResult result = new SetBlobPropertiesResult(); @@ -420,6 +430,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); SetBlobMetadataResult result = new SetBlobMetadataResult(); result.setEtag(response.getHeaders().getFirst("ETag")); @@ -441,6 +452,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) { builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); BlobProperties properties = getBlobPropertiesFromResponse(response); Blob blobResult = new Blob(); @@ -516,6 +528,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); BlobSnapshot blobSnapshot = new BlobSnapshot(); blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); @@ -571,6 +584,7 @@ private String putLeaseImpl(String leaseAction, String container, String blob, S // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); return response.getHeaders().getFirst("x-ms-lease-id"); } @@ -607,6 +621,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont // Note: Add content type here to enable proper HMAC signing Object content = (contentStream == null ? new byte[0] : contentStream); ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); + ThrowIfError(response); CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); @@ -630,6 +645,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); @@ -691,6 +707,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); From 6d7da6fd87a40480b6ae05335fd70b143a483836 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 10:21:10 -0800 Subject: [PATCH 091/664] Add timeout configuration property Renamed "DateMapper" to "RFC1123DateMapper" --- .../services/blob/BlobConfiguration.java | 1 + .../azure/services/blob/BlobProperties.java | 2 +- .../azure/services/blob/BlobServiceImpl.java | 42 +++++++++++-------- .../blob/BlobSharedKeyLiteFilter.java | 2 +- .../azure/services/blob/ListBlobsResult.java | 2 +- .../services/blob/ListContainersResult.java | 2 +- ...teAdapter.java => RFC1123DateAdapter.java} | 6 +-- ...DateMapper.java => RFC1123DateMapper.java} | 2 +- .../services/blob/IntegrationTestBase.java | 1 + 9 files changed, 34 insertions(+), 26 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{DateAdapter.java => RFC1123DateAdapter.java} (65%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{DateMapper.java => RFC1123DateMapper.java} (96%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java index c0dab4926de04..d72b04056e136 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java @@ -4,4 +4,5 @@ public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; public final static String ACCOUNT_KEY = "blob.accountKey"; public final static String URL = "blob.url"; + public final static String TIMEOUT = "blob.timeout"; } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java index 236ca9b38ca42..f1da46b3fcd7d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java @@ -22,7 +22,7 @@ public class BlobProperties { private HashMap metadata = new HashMap(); @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(DateAdapter.class) + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getLastModified() { return lastModified; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index f6db8a341fc52..afb64c2ec9c24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -23,15 +23,20 @@ public class BlobServiceImpl implements BlobService { private final Client channel; private final String accountName; private final String url; + private final Integer timeout; + private final RFC1123DateMapper dateMapper; @Inject public BlobServiceImpl(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - // TODO: How to make this configurable though code? + @Named(BlobConfiguration.TIMEOUT) String timeout, + // TODO: How to make this configurable though code? BlobSharedKeyLiteFilter filter) { this.accountName = accountName; this.url = url; this.channel = channel; + this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); + this.dateMapper = new RFC1123DateMapper(); channel.addFilter(filter); } @@ -59,11 +64,11 @@ public String toString() { } } - private WebResource addOptionalQueryParam(WebResource wr, String key, String value) { + private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { if (value != null) { - wr = wr.queryParam(key, value); + webResource = webResource.queryParam(key, value.toString()); } - return wr; + return webResource; } private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { @@ -99,12 +104,13 @@ private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long ra } private WebResource getResource() { - WebResource res = channel.resource(url).path("/"); + WebResource webResource = channel.resource(url).path("/"); + webResource = addOptionalQueryParam(webResource, "timeout", timeout); - return res; + return webResource; } - private WebResource setCanonicalizedResource(WebResource wr, String resourceName, String operation) { + private WebResource setCanonicalizedResource(WebResource webResource, String resourceName, String operation) { String value = "/" + this.accountName + "/"; if (resourceName != null) { value += resourceName; @@ -115,8 +121,8 @@ private WebResource setCanonicalizedResource(WebResource wr, String resourceName } // TODO: Is this the best way to pass a parameter to a filter? - wr.setProperty("canonicalizedResource", value); - return wr; + webResource.setProperty("canonicalizedResource", value); + return webResource; } private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { @@ -207,7 +213,7 @@ private ContainerProperties getContainerPropertiesImpl(String container, String ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); // Metadata HashMap metadata = new HashMap(); @@ -236,7 +242,7 @@ public ContainerACL getContainerACL(String container) { acl.setSignedIdentifiers(si.getSignedIdentifiers()); acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + acl.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return acl; } @@ -408,7 +414,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesResult result = new SetBlobPropertiesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); } @@ -434,7 +440,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash SetBlobMetadataResult result = new SetBlobMetadataResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -465,7 +471,7 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { BlobProperties properties = new BlobProperties(); // Last-Modified - properties.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); // Metadata HashMap metadata = new HashMap(); @@ -533,7 +539,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob BlobSnapshot blobSnapshot = new BlobSnapshot(); blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); - blobSnapshot.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + blobSnapshot.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return blobSnapshot; } @@ -625,7 +631,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); @@ -650,7 +656,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -713,7 +719,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentType(response.getHeaders().getFirst("Content-Type")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(new DateMapper().parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); return result; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index 66a9fb5bc385d..f13c6c1d40dc9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -50,7 +50,7 @@ private void sign(ClientRequest cr) { String date = getHeader(cr, "Date"); if (date == "") { - date = new DateMapper().format(new Date()); + date = new RFC1123DateMapper().format(new Date()); cr.getHeaders().add("Date", date); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index 7f7bee756b88e..621862938a144 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -151,7 +151,7 @@ public static class BlobProperties { private String sequenceNUmber; @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(DateAdapter.class) + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getLastModified() { return lastModified; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index 5b027dfa258e5..9a2d978a2a928 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -122,7 +122,7 @@ public static class ContainerProperties { private String etag; @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(DateAdapter.class) + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) public Date getLastModified() { return lastModified; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java similarity index 65% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java index e5e493fd7752e..f5aab2e46ff58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java @@ -7,15 +7,15 @@ /* * JAXB adapter for element */ -public class DateAdapter extends XmlAdapter { +public class RFC1123DateAdapter extends XmlAdapter { @Override public Date unmarshal(String arg0) throws Exception { - return new DateMapper().parse(arg0); + return new RFC1123DateMapper().parse(arg0); } @Override public String marshal(Date arg0) throws Exception { - return new DateMapper().format(arg0); + return new RFC1123DateMapper().format(arg0); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java index 264918c529e3d..8a08eb691338b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DateMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java @@ -7,7 +7,7 @@ import java.util.Locale; import java.util.TimeZone; -public class DateMapper { +public class RFC1123DateMapper { private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; public String format(Date date) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index 4991e86f361d4..59f863b77fbcf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -11,6 +11,7 @@ protected Configuration createConfiguration() { config.setProperty(BlobConfiguration.ACCOUNT_NAME, "xxx"); config.setProperty(BlobConfiguration.ACCOUNT_KEY, "xxx"); config.setProperty(BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); + config.setProperty(BlobConfiguration.TIMEOUT, "20"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); From fdadd2ea4489b7cd2772d9c979cd974b21ee997e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 11:17:20 -0800 Subject: [PATCH 092/664] Add AccessCondition support for "getBlob" --- .../azure/services/blob/AccessCondition.java | 144 ++++++++++++++++++ .../blob/AccessConditionHeaderType.java | 57 +++++++ .../azure/services/blob/BlobServiceImpl.java | 8 + .../azure/services/blob/GetBlobOptions.java | 10 ++ 4 files changed, 219 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java new file mode 100644 index 0000000000000..3ffddd5bf19ed --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java @@ -0,0 +1,144 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; + +/** + * TODO: Unify this with client layer + * + * Represents a set of access conditions to be used for operations against the storage services. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class AccessCondition { + + /** + * Specifies that no access condition is set. + */ + public static final AccessCondition NONE = new AccessCondition(AccessConditionHeaderType.NONE, null); + + /** + * Returns an access condition such that an operation will be performed only if the resource's ETag value matches + * the specified ETag value. + *

+ * Setting this access condition modifies the request to include the HTTP If-Match conditional header. If + * this access condition is set, the operation is performed only if the ETag of the resource matches the specified + * ETag. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param etag + * A String that represents the ETag value to check. + * + * @return An AccessCondition object that represents the If-Match condition. + */ + public static AccessCondition ifMatch(String etag) { + return new AccessCondition(AccessConditionHeaderType.IF_MATCH, etag); + } + + /** + * Returns an access condition such that an operation will be performed only if the resource has been modified since + * the specified time. + *

+ * Setting this access condition modifies the request to include the HTTP If-Modified-Since conditional + * header. If this access condition is set, the operation is performed only if the resource has been modified since + * the specified time. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param lastMotified + * A java.util.Date object that represents the last-modified time to check for the resource. + * + * @return An AccessCondition object that represents the If-Modified-Since condition. + */ + public static AccessCondition ifModifiedSince(Date lastMotified) { + return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, new RFC1123DateMapper().format(lastMotified)); + } + + /** + * Returns an access condition such that an operation will be performed only if the resource's ETag value does not + * match the specified ETag value. + *

+ * Setting this access condition modifies the request to include the HTTP If-None-Match conditional header. + * If this access condition is set, the operation is performed only if the ETag of the resource does not match the + * specified ETag. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param etag + * A String that represents the ETag value to check. + * + * @return An AccessCondition object that represents the If-None-Match condition. + */ + public static AccessCondition ifNoneMatch(String etag) { + return new AccessCondition(AccessConditionHeaderType.IF_NONE_MATCH, etag); + } + + /** + * Returns an access condition such that an operation will be performed only if the resource has not been modified + * since the specified time. + *

+ * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional + * header. If this access condition is set, the operation is performed only if the resource has not been modified + * since the specified time. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param lastMotified + * A java.util.Date object that represents the last-modified time to check for the resource. + * + * @return An AccessCondition object that represents the If-Unmodified-Since condition. + */ + public static AccessCondition ifNotModifiedSince(Date lastMotified) { + return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, new RFC1123DateMapper().format(lastMotified)); + } + + /** + * Represents the header type. + */ + private AccessConditionHeaderType header = AccessConditionHeaderType.NONE; + + /** + * Represents the header value. + */ + private String value; + + /** + * Creates an instance of the AccessCondition class. + */ + protected AccessCondition() { + // Empty Default Ctor + } + + /** + * Creates an instance of the AccessCondition class using the specified header type and value. + * + * @param headerType + * An {@link AccessConditionHeaderType} value that represents the header type. + * @param value + * A String that represents the value of the header. + */ + protected AccessCondition(AccessConditionHeaderType headerType, String value) { + this.setHeader(headerType); + this.setValue(value); + } + + public AccessConditionHeaderType getHeader() { + return header; + } + + public void setHeader(AccessConditionHeaderType header) { + this.header = header; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java new file mode 100644 index 0000000000000..c0e8f8d8d6ab7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java @@ -0,0 +1,57 @@ +package com.microsoft.azure.services.blob; + + +/** + * TODO: Unify this with client layer + * + * Specifies the kinds of conditional headers that may be set for a request. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum AccessConditionHeaderType { + /** + * Specifies that no conditional headers are set. + */ + NONE, + + /** + * Specifies the If-Unmodified-Since conditional header is set. + */ + IF_UNMODIFIED_SINCE, + + /** + * Specifies the If-Match conditional header is set. + */ + IF_MATCH, + + /** + * Specifies the If-Modified-Since conditional header is set. + */ + IF_MODIFIED_SINCE, + + /** + * Specifies the If-None-Match conditional header is set. + */ + IF_NONE_MATCH; + + /** + * 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. + */ + @Override + public String toString() { + switch (this) { + case IF_MATCH: + return "If-Match"; + case IF_UNMODIFIED_SINCE: + return "If-Unmodified-Since"; + case IF_MODIFIED_SINCE: + return "If-Modified-Since"; + case IF_NONE_MATCH: + return "If-None-Match"; + default: + return ""; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index afb64c2ec9c24..270116063fbf1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -103,6 +103,13 @@ private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long ra return builder; } + private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { + if (accessCondition != null) { + builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); + } + return builder; + } + private WebResource getResource() { WebResource webResource = channel.resource(url).path("/"); webResource = addOptionalQueryParam(webResource, "timeout", timeout); @@ -456,6 +463,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) { Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); ClientResponse response = builder.get(ClientResponse.class); ThrowIfError(response); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java index 4d755182e559d..2b91521e8f797 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java @@ -7,6 +7,7 @@ public class GetBlobOptions { private boolean computeRangeMD5; private Long rangeStart; private Long rangeEnd; + private AccessCondition accessCondition; public String getSnapshot() { return snapshot; @@ -52,4 +53,13 @@ public GetBlobOptions setRangeEnd(Long rangeEnd) { this.rangeEnd = rangeEnd; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public GetBlobOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 91eda97662f4016af1e2ab90e309999f21f0442d Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 11:17:52 -0800 Subject: [PATCH 093/664] Move utility classes to "utils" package --- .../com/microsoft/azure/services/blob/AccessCondition.java | 2 ++ .../com/microsoft/azure/services/blob/BlobProperties.java | 2 ++ .../com/microsoft/azure/services/blob/BlobServiceImpl.java | 7 +++++-- .../azure/services/blob/BlobSharedKeyLiteFilter.java | 1 + .../java/com/microsoft/azure/services/blob/BlockList.java | 2 ++ .../com/microsoft/azure/services/blob/BlockListBackup.java | 2 ++ .../azure/services/blob/ListBlobBlocksResult.java | 2 ++ .../com/microsoft/azure/services/blob/ListBlobsResult.java | 2 ++ .../azure/services/blob/ListContainersResult.java | 2 ++ .../{services/blob => utils}/Base64StringAdapter.java | 2 +- .../azure/{services/blob => utils}/RFC1123DateAdapter.java | 3 ++- .../azure/{services/blob => utils}/RFC1123DateMapper.java | 2 +- 12 files changed, 24 insertions(+), 5 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{services/blob => utils}/Base64StringAdapter.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{services/blob => utils}/RFC1123DateAdapter.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{services/blob => utils}/RFC1123DateMapper.java (95%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java index 3ffddd5bf19ed..6696856d8159d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java @@ -2,6 +2,8 @@ import java.util.Date; +import com.microsoft.azure.utils.RFC1123DateMapper; + /** * TODO: Unify this with client layer * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java index f1da46b3fcd7d..4a06606e123f8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java @@ -6,6 +6,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.RFC1123DateAdapter; + //TODO: Unify this with ListBlobsResults.BlobProperties public class BlobProperties { private Date lastModified; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 270116063fbf1..51689b93a9474 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -10,6 +10,7 @@ import javax.inject.Inject; import javax.inject.Named; +import com.microsoft.azure.utils.RFC1123DateMapper; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; @@ -105,14 +106,16 @@ private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long ra private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { if (accessCondition != null) { - builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); + if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { + builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); + } } return builder; } private WebResource getResource() { WebResource webResource = channel.resource(url).path("/"); - webResource = addOptionalQueryParam(webResource, "timeout", timeout); + webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); return webResource; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index f13c6c1d40dc9..6b3f61b513fa6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -9,6 +9,7 @@ import javax.inject.Named; import com.microsoft.azure.utils.HmacSHA256Sign; +import com.microsoft.azure.utils.RFC1123DateMapper; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java index ace0bc4a7f77e..599a2bc699b38 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java @@ -10,6 +10,8 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.Base64StringAdapter; + @XmlRootElement(name = "BlockList") public class BlockList { private List entries = new ArrayList(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java index c85c64183ff33..fc014990eacd8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java @@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.Base64StringAdapter; + @XmlRootElement(name = "BlockList") public class BlockListBackup { private List committedEntries = new ArrayList(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java index bfc97e3211d07..86718a1609f58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java @@ -9,6 +9,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.Base64StringAdapter; + @XmlRootElement(name = "BlockList") public class ListBlobBlocksResult { private Date lastModified; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index 621862938a144..cae9ac838b6f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -10,6 +10,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.RFC1123DateAdapter; + @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { private List blobs; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index 9a2d978a2a928..7282dc0a23499 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -10,6 +10,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import com.microsoft.azure.utils.RFC1123DateAdapter; + @XmlRootElement(name = "EnumerationResults") public class ListContainersResult { private List containers; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java index 39d6dda4e39ff..e607ccfca983b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.utils; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java index f5aab2e46ff58..a5af1df1b36d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java @@ -1,9 +1,10 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.utils; import java.util.Date; import javax.xml.bind.annotation.adapters.XmlAdapter; + /* * JAXB adapter for element */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java index 8a08eb691338b..daf10c9bbd375 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/RFC1123DateMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.utils; import java.text.DateFormat; import java.text.ParseException; From 514523ffb1bd06354859981fe8ec9741b49abb39 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 12:15:35 -0800 Subject: [PATCH 094/664] Adding integration tests for AccessCondition --- .../blob/BlobServiceIntegrationTest.java | 98 ++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 6a30b3eac6862..946a638662b38 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -14,9 +14,12 @@ import java.io.Reader; import java.io.StringWriter; import java.io.Writer; +import java.util.Date; import java.util.EnumSet; import java.util.HashMap; +import junit.framework.Assert; + import org.junit.Test; import com.microsoft.azure.configuration.Configuration; @@ -421,8 +424,6 @@ public void listBlobBlocksOnEmptyBlobWorks() throws Exception { assertEquals(512, result.getContentLength()); assertNotNull(result.getCommittedBlocks()); assertEquals(0, result.getCommittedBlocks().size()); - //assertNotNull(result.getCommittedBlocks().get(0).getBlockId()); - //assertEquals(512, result.getCommittedBlocks().get(0).getBlockLength()); assertNotNull(result.getUncommittedBlocks()); assertEquals(0, result.getUncommittedBlocks().size()); } @@ -672,6 +673,99 @@ public void getPageBlobWorks() throws Exception { assertEquals(4096, inputStreamToByteArray(blob.getContentStream()).length); } + @Test + public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + service.createPageBlob("mycontainer1", "test", 4096); + try { + Blob blob = service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); + Assert.fail("getBlob should throw an exception"); + } + catch (Exception e) { + } + + // Assert + } + + @Test + public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + service.createPageBlob("mycontainer1", "test", 4096); + BlobProperties props = service.getBlobProperties("mycontainer1", "test"); + try { + Blob blob = service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); + Assert.fail("getBlob should throw an exception"); + } + catch (Exception e) { + } + + // Assert + } + + @Test + public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + service.createPageBlob("mycontainer1", "test", 4096); + BlobProperties props = service.getBlobProperties("mycontainer1", "test"); + try { + Blob blob = service.getBlob("mycontainer1", "test", + new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); + Assert.fail("getBlob should throw an exception"); + } + catch (Exception e) { + } + + // Assert + } + + @Test + public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + service.createPageBlob(container, blob, 4096); + BlobProperties 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 + Date lastModifiedBase = (Date) props.getLastModified().clone(); + + // +1 second + Date lastModifiedNext = new Date(lastModifiedBase.getTime() + 1 * 1000); + + while (true) { + HashMap metadata = new HashMap(); + metadata.put("test", "test1"); + SetBlobMetadataResult result = service.setBlobMetadata(container, blob, metadata); + if (result.getLastModified().compareTo(lastModifiedNext) >= 0) + break; + } + try { + Blob blobInstance = service.getBlob(container, blob, new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); + Assert.fail("getBlob should throw an exception"); + } + catch (Exception e) { + } + + // Assert + } + @Test public void setBlobPropertiesWorks() throws Exception { // Arrange From af58163ddd672fcd09ecb35cba93c148761faf5b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 12:41:09 -0800 Subject: [PATCH 095/664] Add AccessConditionSupport to "createXxxBlob" methods --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/CreateBlobOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 51689b93a9474..a5dd7acc2d840 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -378,6 +378,7 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // TODO: Conditional headers (If Match, etc.) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java index 9033e493722b8..2a086b85ed39b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java @@ -16,6 +16,7 @@ public class CreateBlobOptions { private HashMap metadata = new HashMap(); private String leaseId; private Long sequenceNumber; + private AccessCondition accessCondition; public String getContentType() { return contentType; @@ -138,4 +139,13 @@ public CreateBlobOptions setSequenceNumber(Long sequenceNumber) { this.sequenceNumber = sequenceNumber; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public CreateBlobOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From e21845d0a9aab4566ad6ac90835705bab9ccd01a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 13:34:50 -0800 Subject: [PATCH 096/664] Add AccessCondition to "getBlobProperties" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/GetBlobPropertiesOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index a5dd7acc2d840..b17b21cbc0132 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -396,6 +396,7 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); ClientResponse response = builder.method("HEAD", ClientResponse.class); ThrowIfError(response); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java index d4b7f560601b7..f9a59482d31b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -4,6 +4,7 @@ public class GetBlobPropertiesOptions { private String snapshot; private String leaseId; + private AccessCondition accessCondition; public String getSnapshot() { return snapshot; @@ -22,4 +23,13 @@ public GetBlobPropertiesOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public GetBlobPropertiesOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 47ad071d68e2f08cf42564351b4033ec33efae4d Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:15:17 -0800 Subject: [PATCH 097/664] Add AccessCondition to "setBlobProperties" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/SetBlobPropertiesOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index b17b21cbc0132..e8dc892e1330e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -418,6 +418,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java index 2f5965bb929b2..002c9f1fa1546 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java @@ -11,6 +11,7 @@ public class SetBlobPropertiesOptions { private String cacheControl; private String sequenceNumberAction; private Long sequenceNumber; + private AccessCondition accessCondition; public String getContentType() { return contentType; @@ -92,4 +93,13 @@ public SetBlobPropertiesOptions setSequenceNumberAction(String sequenceNumberAct this.sequenceNumberAction = sequenceNumberAction; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public SetBlobPropertiesOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 8e881c93f71f667bf36e3dc81867b328892a1c44 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:36:47 -0800 Subject: [PATCH 098/664] Add support for "getBlobMetadata" --- .../azure/services/blob/BlobService.java | 4 ++ .../azure/services/blob/BlobServiceImpl.java | 60 +++++++++++------ .../services/blob/GetBlobMetadataOptions.java | 35 ++++++++++ .../services/blob/GetBlobMetadataResult.java | 34 ++++++++++ .../blob/GetBlobPropertiesOptions.java | 1 - .../blob/BlobServiceIntegrationTest.java | 64 +++++++++++++++++-- 6 files changed, 172 insertions(+), 26 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 1a32593ccf0ee..43b51ae662191 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -66,6 +66,10 @@ CreateBlobPagesResult createBlobPages(String container, String blob, long rangeS BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); + GetBlobMetadataResult getBlobMetadata(String container, String blob); + + GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options); + ListBlobRegionsResult listBlobRegions(String container, String blob); ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index e8dc892e1330e..c2e28cebdfb72 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -113,6 +113,18 @@ private Builder addOptionalAccessContitionHeader(Builder builder, AccessConditio 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() { WebResource webResource = channel.resource(url).path("/"); webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); @@ -224,17 +236,8 @@ private ContainerProperties getContainerPropertiesImpl(String container, String ContainerProperties properties = new ContainerProperties(); properties.setEtag(response.getHeaders().getFirst("ETag")); properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); - // Metadata - 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); - } - } - properties.setMetadata(metadata); return properties; } @@ -341,7 +344,7 @@ public void createPageBlob(String container, String blob, int length, CreateBlob builder = addPutBlobHeaders(options, builder); // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + builder.type("application/octet-stream").put(new byte[0]); } public void createBlockBlob(String container, String blob, InputStream contentStream) { @@ -404,6 +407,31 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr return getBlobPropertiesFromResponse(response); } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob) { + return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); + } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + GetBlobMetadataResult properties = new GetBlobMetadataResult(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); + + return properties; + } + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); @@ -487,15 +515,7 @@ private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { // Last-Modified properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - // Metadata - 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); - } - } + HashMap metadata = getMetadataFromHeaders(response); properties.setMetadata(metadata); // diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java new file mode 100644 index 0000000000000..364ec7fbb1dae --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java @@ -0,0 +1,35 @@ +package com.microsoft.azure.services.blob; + + +public class GetBlobMetadataOptions { + private String snapshot; + private String leaseId; + private AccessCondition accessCondition; + + public String getSnapshot() { + return snapshot; + } + + public GetBlobMetadataOptions setSnapshot(String snapshot) { + this.snapshot = snapshot; + return this; + } + + public String getLeaseId() { + return leaseId; + } + + public GetBlobMetadataOptions setLeaseId(String leaseId) { + this.leaseId = leaseId; + return this; + } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public GetBlobMetadataOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java new file mode 100644 index 0000000000000..1d8b317b5cca2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java @@ -0,0 +1,34 @@ +package com.microsoft.azure.services.blob; + +import java.util.Date; +import java.util.HashMap; + +public class GetBlobMetadataResult { + private String etag; + private Date lastModified; + private HashMap metadata; + + public String getEtag() { + return etag; + } + + public void setEtag(String etag) { + this.etag = etag; + } + + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + 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/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java index f9a59482d31b6..5254ec481fb23 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -1,6 +1,5 @@ package com.microsoft.azure.services.blob; - public class GetBlobPropertiesOptions { private String snapshot; private String leaseId; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 946a638662b38..3681f06228cef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -682,7 +682,7 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { // Act service.createPageBlob("mycontainer1", "test", 4096); try { - Blob blob = service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); + service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); Assert.fail("getBlob should throw an exception"); } catch (Exception e) { @@ -701,7 +701,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { service.createPageBlob("mycontainer1", "test", 4096); BlobProperties props = service.getBlobProperties("mycontainer1", "test"); try { - Blob blob = service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); + service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); Assert.fail("getBlob should throw an exception"); } catch (Exception e) { @@ -720,8 +720,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { service.createPageBlob("mycontainer1", "test", 4096); BlobProperties props = service.getBlobProperties("mycontainer1", "test"); try { - Blob blob = service.getBlob("mycontainer1", "test", - new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); + service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); Assert.fail("getBlob should throw an exception"); } catch (Exception e) { @@ -757,7 +756,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception break; } try { - Blob blobInstance = service.getBlob(container, blob, new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); + service.getBlob(container, blob, new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); Assert.fail("getBlob should throw an exception"); } catch (Exception e) { @@ -766,6 +765,61 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception // Assert } + @Test + public void getBlobPropertiesWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + service.createPageBlob(container, blob, 4096); + BlobProperties props = service.getBlobProperties(container, blob); + + // Assert + // Assert + assertNotNull(props); + assertNull(props.getCacheControl()); + assertNull(props.getContentEncoding()); + assertNull(props.getContentLanguage()); + assertEquals("application/octet-stream", props.getContentType()); + 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()); + assertEquals(0, props.getSequenceNumber()); + } + + @Test + public void getBlobMetadataWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + String container = "mycontainer1"; + String blob = "test"; + 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()); + assertNotNull(props.getMetadata()); + assertEquals(2, props.getMetadata().size()); + assertTrue(props.getMetadata().containsKey("test")); + assertTrue(props.getMetadata().containsValue("bar")); + assertTrue(props.getMetadata().containsKey("blah")); + assertTrue(props.getMetadata().containsValue("bleah")); + assertNotNull(props.getLastModified()); + } + @Test public void setBlobPropertiesWorks() throws Exception { // Arrange From 8bd36d1aad07264650a6f31fc2814f4c85a98e37 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:39:18 -0800 Subject: [PATCH 099/664] Add AccessCondition to "setBlobMetadata" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 2 +- .../azure/services/blob/SetBlobMetadataOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index c2e28cebdfb72..c0e2b4aeba1eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -407,7 +407,6 @@ public BlobProperties getBlobProperties(String container, String blob, GetBlobPr return getBlobPropertiesFromResponse(response); } - public GetBlobMetadataResult getBlobMetadata(String container, String blob) { return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); } @@ -474,6 +473,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java index 51f54038f33b6..86ee7e5d144d9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java @@ -2,6 +2,7 @@ public class SetBlobMetadataOptions { private String leaseId; + private AccessCondition accessCondition; public String getLeaseId() { return leaseId; @@ -11,4 +12,13 @@ public SetBlobMetadataOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public SetBlobMetadataOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 94af60372f9a6cb7b77eb6726e16c1d4b129a5a8 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:41:41 -0800 Subject: [PATCH 100/664] Add AccessCondition to "commitBlockList" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/CommitBlobBlocksOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index c0e2b4aeba1eb..ef9eeadcb2c87 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -728,6 +728,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList, builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing builder.type("application/xml").put(blockList); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java index 7ed574f3f8951..030ffcbd59b18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java @@ -10,6 +10,7 @@ public class CommitBlobBlocksOptions { private String blobCacheControl; private HashMap metadata = new HashMap(); private String leaseId; + private AccessCondition accessCondition; public String getBlobContentType() { return blobContentType; @@ -78,4 +79,13 @@ public CommitBlobBlocksOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public CommitBlobBlocksOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 3cacfcfa7afd280fd66498b898fd7fe9e0da0185 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:43:45 -0800 Subject: [PATCH 101/664] Add AccessCondition to "deleteBlob" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/DeleteBlobOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index ef9eeadcb2c87..96158a81b3143 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -548,6 +548,7 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphots()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder.delete(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java index 3dab5b8b1f34c..fe323db329c42 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java @@ -5,6 +5,7 @@ public class DeleteBlobOptions { private String leaseId; // TODO: Enum? private String deleteSnaphots; + private AccessCondition accessCondition; public String getSnapshot() { return snapshot; @@ -32,4 +33,13 @@ public DeleteBlobOptions setDeleteSnaphots(String deleteSnaphots) { this.deleteSnaphots = deleteSnaphots; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public DeleteBlobOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 520f13188f68a072e6ffa98133bd76ef17395c98 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:52:29 -0800 Subject: [PATCH 102/664] Add AccessCondition to "copyBlob" --- .../azure/services/blob/BlobServiceImpl.java | 24 +++++++++++++++++++ .../azure/services/blob/CopyBlobOptions.java | 20 ++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 96158a81b3143..ffb4ee593124d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -113,6 +113,28 @@ private Builder addOptionalAccessContitionHeader(Builder builder, AccessConditio return builder; } + 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; + } + private HashMap getMetadataFromHeaders(ClientResponse response) { HashMap metadata = new HashMap(); for (Entry> entry : response.getHeaders().entrySet()) { @@ -592,6 +614,8 @@ public void copyBlob(String destinationContainer, String destinationBlob, String builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); // TODO: Conditional headers (If Match, etc.) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java index e31121baf1cb9..abe3e53d4c231 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java @@ -4,9 +4,11 @@ public class CopyBlobOptions { private String leaseId; + private AccessCondition accessCondition; private String sourceLeaseId; private String sourceSnapshot; private HashMap metadata = new HashMap(); + private AccessCondition sourceAccessCondition; // TODO: IfMatch options @@ -50,4 +52,22 @@ public CopyBlobOptions setSourceLeaseId(String sourceLeaseId) { this.sourceLeaseId = sourceLeaseId; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public CopyBlobOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } + + public AccessCondition getSourceAccessCondition() { + return sourceAccessCondition; + } + + public CopyBlobOptions setSourceAccessCondition(AccessCondition sourceAccessCondition) { + this.sourceAccessCondition = sourceAccessCondition; + return this; + } } From 33ff556fc78b215de775444361ce041e361e096a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:54:43 -0800 Subject: [PATCH 103/664] Add AccessCondition to "createBlobSnapshot" --- .../azure/services/blob/BlobServiceImpl.java | 3 +-- .../services/blob/CreateBlobSnapshotOptions.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index ffb4ee593124d..72b6dc5f8c829 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -586,8 +586,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlob Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalMetadataHeader(builder, options.getMetadata()); - - // TODO: Conditional headers (If Match, etc.) + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java index e0e753743507f..0dc3262003765 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java @@ -5,7 +5,7 @@ public class CreateBlobSnapshotOptions { private HashMap metadata = new HashMap(); private String leaseId; - //TODO: Add Ifxxx headers + private AccessCondition accessCondition; public HashMap getMetadata() { return metadata; @@ -29,4 +29,13 @@ public CreateBlobSnapshotOptions setLeaseId(String leaseId) { this.leaseId = leaseId; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public CreateBlobSnapshotOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 1fcce995431583b326c58a56ec8d3798697ec8df Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:57:48 -0800 Subject: [PATCH 104/664] Add AccessCondition to "clear/createBlobPages" --- .../azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/CreateBlobPagesOptions.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 72b6dc5f8c829..46e70ee850f67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -681,6 +681,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-page-write", action); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing Object content = (contentStream == null ? new byte[0] : contentStream); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java index 90d42c9ac4dbc..90d095be3243b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java @@ -3,9 +3,7 @@ public class CreateBlobPagesOptions { private String leaseId; private String contentMD5; - - // TODO: Add "if" from - // http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx + private AccessCondition accessCondition; public String getLeaseId() { return leaseId; @@ -24,4 +22,13 @@ public CreateBlobPagesOptions setContentMD5(String contentMD5) { this.contentMD5 = contentMD5; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public CreateBlobPagesOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From 37efd46c173db83ccd170cb14e608d9b80bec142 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 15:59:23 -0800 Subject: [PATCH 105/664] Add AccessCondition to "listBlobRegions" --- .../microsoft/azure/services/blob/BlobServiceImpl.java | 1 + .../azure/services/blob/ListBlobRegionsOptions.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 46e70ee850f67..d06c9672bd0e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -708,6 +708,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); ClientResponse response = builder.get(ClientResponse.class); ThrowIfError(response); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java index 995110267b28b..76b565bd5de98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java @@ -5,6 +5,7 @@ public class ListBlobRegionsOptions { private String snapshot; private Long rangeStart; private Long rangeEnd; + private AccessCondition accessCondition; public String getLeaseId() { return leaseId; @@ -41,4 +42,13 @@ public ListBlobRegionsOptions setRangeEnd(Long rangeEnd) { this.rangeEnd = rangeEnd; return this; } + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public ListBlobRegionsOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } } From bf294f1a57629a360e509813ebebc17a6d139cfc Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:03:55 -0800 Subject: [PATCH 106/664] Add AccessCondition to "acquireLease" --- .../azure/services/blob/AcquireLeaseOptions.java | 14 ++++++++++++++ .../azure/services/blob/BlobService.java | 2 ++ .../azure/services/blob/BlobServiceImpl.java | 15 ++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java new file mode 100644 index 0000000000000..a3c57ea692ff4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.blob; + +public class AcquireLeaseOptions { + private AccessCondition accessCondition; + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public AcquireLeaseOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 43b51ae662191..5efafbe22e953 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -98,6 +98,8 @@ CreateBlobPagesResult createBlobPages(String container, String blob, long rangeS String acquireLease(String container, String blob); + String acquireLease(String container, String blob, AcquireLeaseOptions options); + String renewLease(String container, String blob, String leaseId); void releaseLease(String container, String blob, String leaseId); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index d06c9672bd0e6..0986d41e12a46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -623,28 +623,33 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } public String acquireLease(String container, String blob) { - return putLeaseImpl("acquire", container, blob, null); + return acquireLease(container, blob, new AcquireLeaseOptions()); + } + + public String acquireLease(String container, String blob, AcquireLeaseOptions options) { + return putLeaseImpl("acquire", container, blob, null, options); } public String renewLease(String container, String blob, String leaseId) { - return putLeaseImpl("renew", container, blob, leaseId); + return putLeaseImpl("renew", container, blob, leaseId, null/*options*/); } public void releaseLease(String container, String blob, String leaseId) { - putLeaseImpl("release", container, blob, leaseId); + putLeaseImpl("release", container, blob, leaseId, null/*options*/); } public void breakLease(String container, String blob, String leaseId) { - putLeaseImpl("break", container, blob, leaseId); + putLeaseImpl("break", container, blob, leaseId, null/*options*/); } - private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId) { + private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, AcquireLeaseOptions options) { WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); From 548a1d0fd8d5846683cc81fff0e6a4cca87a468c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:04:58 -0800 Subject: [PATCH 107/664] Fix null reference bug --- .../com/microsoft/azure/services/blob/BlobServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 0986d41e12a46..9da26b0e1920f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -631,15 +631,15 @@ public String acquireLease(String container, String blob, AcquireLeaseOptions op } public String renewLease(String container, String blob, String leaseId) { - return putLeaseImpl("renew", container, blob, leaseId, null/*options*/); + return putLeaseImpl("renew", container, blob, leaseId, new AcquireLeaseOptions()); } public void releaseLease(String container, String blob, String leaseId) { - putLeaseImpl("release", container, blob, leaseId, null/*options*/); + putLeaseImpl("release", container, blob, leaseId, new AcquireLeaseOptions()); } public void breakLease(String container, String blob, String leaseId) { - putLeaseImpl("break", container, blob, leaseId, null/*options*/); + putLeaseImpl("break", container, blob, leaseId, new AcquireLeaseOptions()); } private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, AcquireLeaseOptions options) { From dbe439b46f915a72cde266f3b28acbac74c0cc0a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:07:36 -0800 Subject: [PATCH 108/664] Add AccessCondition to "setContainerMetadata" --- .../microsoft/azure/services/blob/BlobService.java | 2 ++ .../azure/services/blob/BlobServiceImpl.java | 5 +++++ .../services/blob/SetContainerMetadataOptions.java | 14 ++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 5efafbe22e953..4e8c19cca71d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -29,6 +29,8 @@ public interface BlobService { void setContainerMetadata(String container, HashMap metadata); + void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options); + ListBlobsResult listBlobs(String container); ListBlobsResult listBlobs(String container, ListBlobsOptions options); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 9da26b0e1920f..9f4a1119f5d0d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -295,11 +295,16 @@ public void setContainerACL(String container, ContainerACL acl) { } public void setContainerMetadata(String container, HashMap metadata) { + setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); + } + + public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) { WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); // Note: Add content type here to enable proper HMAC signing builder.type("text/plain").put(""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java new file mode 100644 index 0000000000000..b1a710eb4cf34 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.blob; + +public class SetContainerMetadataOptions { + private AccessCondition accessCondition; + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public SetContainerMetadataOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } +} From 6754d3dbb34ed40a33eb67ef5d2ff6efc0002c5c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:16:58 -0800 Subject: [PATCH 109/664] Add AccessCondition to "deleteContainer" --- .../microsoft/azure/services/blob/BlobService.java | 2 ++ .../azure/services/blob/BlobServiceImpl.java | 4 ++++ .../services/blob/DeleteContainerOptions.java | 14 ++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 4e8c19cca71d2..1688a95886ced 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -19,6 +19,8 @@ public interface BlobService { void deleteContainer(String container); + void deleteContainer(String container, DeleteContainerOptions options); + ContainerProperties getContainerProperties(String container); ContainerProperties getContainerMetadata(String container); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 9f4a1119f5d0d..d84a96869d077 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -229,10 +229,14 @@ public void createContainer(String container, CreateContainerOptions options) { } public void deleteContainer(String container) { + deleteContainer(container, new DeleteContainerOptions()); + } + public void deleteContainer(String container, DeleteContainerOptions options) { WebResource webResource = getResource().path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder.delete(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java new file mode 100644 index 0000000000000..567005baa7f35 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java @@ -0,0 +1,14 @@ +package com.microsoft.azure.services.blob; + +public class DeleteContainerOptions { + private AccessCondition accessCondition; + + public AccessCondition getAccessCondition() { + return accessCondition; + } + + public DeleteContainerOptions setAccessCondition(AccessCondition accessCondition) { + this.accessCondition = accessCondition; + return this; + } +} From 40c2eef1f89260c45c816736cae0baafdc4a9d6c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:24:02 -0800 Subject: [PATCH 110/664] Change "deleteSnapshots" property from String to bool --- .../azure/services/blob/BlobServiceImpl.java | 6 +----- .../azure/services/blob/DeleteBlobOptions.java | 11 +++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index d84a96869d077..9f07ec712df02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -414,8 +414,6 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // TODO: Conditional headers (If Match, etc.) - return builder; } @@ -578,7 +576,7 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphots()); + builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" : "include"); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder.delete(); @@ -625,8 +623,6 @@ public void copyBlob(String destinationContainer, String destinationBlob, String builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); - // TODO: Conditional headers (If Match, etc.) - // Note: Add content type here to enable proper HMAC signing builder.type("text/plain").put(""); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java index fe323db329c42..531a5676d3f39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java @@ -3,8 +3,7 @@ public class DeleteBlobOptions { private String snapshot; private String leaseId; - // TODO: Enum? - private String deleteSnaphots; + private boolean deleteSnaphotsOnly; private AccessCondition accessCondition; public String getSnapshot() { @@ -25,12 +24,12 @@ public DeleteBlobOptions setLeaseId(String leaseId) { return this; } - public String getDeleteSnaphots() { - return deleteSnaphots; + public boolean getDeleteSnaphotsOnly() { + return deleteSnaphotsOnly; } - public DeleteBlobOptions setDeleteSnaphots(String deleteSnaphots) { - this.deleteSnaphots = deleteSnaphots; + public DeleteBlobOptions setDeleteSnaphotsOnly(boolean deleteSnaphotsOnly) { + this.deleteSnaphotsOnly = deleteSnaphotsOnly; return this; } From 4d0bf055589437b3935690b18516da03767e9e84 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:26:05 -0800 Subject: [PATCH 111/664] Remove a few "TODO" comments --- .../java/com/microsoft/azure/services/blob/BlobServiceImpl.java | 2 -- .../java/com/microsoft/azure/services/blob/CopyBlobOptions.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 9f07ec712df02..505bc6734ef65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -192,7 +192,6 @@ private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, } public ServiceProperties getServiceProperties() { - // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); @@ -202,7 +201,6 @@ public ServiceProperties getServiceProperties() { } public void setServiceProperties(ServiceProperties serviceProperties) { - // TODO: timeout WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java index abe3e53d4c231..15ac928766d54 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java @@ -10,8 +10,6 @@ public class CopyBlobOptions { private HashMap metadata = new HashMap(); private AccessCondition sourceAccessCondition; - // TODO: IfMatch options - public String getSourceSnapshot() { return sourceSnapshot; } From c1c167b86fcd96210a1615330e46df06962d0831 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 16:30:10 -0800 Subject: [PATCH 112/664] Format files --- .../azure/services/blob/MetadataAdapter.java | 1 - .../services/blob/ServiceProperties.java | 31 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java index 40811d3f03d8c..953689d32df59 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java @@ -30,7 +30,6 @@ public MetadataHashMapType marshal(HashMap arg0) throws Exceptio throw new OperationNotSupportedException(); } - public static class MetadataHashMapType { private List entries = new ArrayList(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java index 829d794270894..44f0ef9c28354 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java @@ -3,13 +3,13 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name="StorageServiceProperties") +@XmlRootElement(name = "StorageServiceProperties") public class ServiceProperties { private Logging logging; private Metrics metrics; private String defaultServiceVersion; - @XmlElement(name="Logging") + @XmlElement(name = "Logging") public Logging getLogging() { return logging; } @@ -18,7 +18,7 @@ public void setLogging(Logging logging) { this.logging = logging; } - @XmlElement(name="Metrics") + @XmlElement(name = "Metrics") public Metrics getMetrics() { return metrics; } @@ -27,7 +27,7 @@ public void setMetrics(Metrics metrics) { this.metrics = metrics; } - @XmlElement(name="DefaultServiceVersion") + @XmlElement(name = "DefaultServiceVersion") public String getDefaultServiceVersion() { return defaultServiceVersion; } @@ -43,7 +43,7 @@ public static class Logging { private Boolean write; private RetentionPolicy retentionPolicy; - @XmlElement(name="RetentionPolicy") + @XmlElement(name = "RetentionPolicy") public RetentionPolicy getRetentionPolicy() { return retentionPolicy; } @@ -52,7 +52,7 @@ public void setRetentionPolicy(RetentionPolicy retentionPolicy) { this.retentionPolicy = retentionPolicy; } - @XmlElement(name="Write") + @XmlElement(name = "Write") public boolean isWrite() { return write; } @@ -61,7 +61,7 @@ public void setWrite(boolean write) { this.write = write; } - @XmlElement(name="Read") + @XmlElement(name = "Read") public boolean isRead() { return read; } @@ -70,7 +70,7 @@ public void setRead(boolean read) { this.read = read; } - @XmlElement(name="Delete") + @XmlElement(name = "Delete") public boolean isDelete() { return delete; } @@ -79,7 +79,7 @@ public void setDelete(boolean delete) { this.delete = delete; } - @XmlElement(name="Version") + @XmlElement(name = "Version") public String getVersion() { return version; } @@ -87,7 +87,6 @@ public String getVersion() { public void setVersion(String version) { this.version = version; } - } public static class Metrics { @@ -96,7 +95,7 @@ public static class Metrics { private Boolean includeAPIs; private RetentionPolicy retentionPolicy; - @XmlElement(name="RetentionPolicy") + @XmlElement(name = "RetentionPolicy") public RetentionPolicy getRetentionPolicy() { return retentionPolicy; } @@ -105,7 +104,7 @@ public void setRetentionPolicy(RetentionPolicy retentionPolicy) { this.retentionPolicy = retentionPolicy; } - @XmlElement(name="IncludeAPIs") + @XmlElement(name = "IncludeAPIs") public Boolean isIncludeAPIs() { return includeAPIs; } @@ -114,7 +113,7 @@ public void setIncludeAPIs(Boolean includeAPIs) { this.includeAPIs = includeAPIs; } - @XmlElement(name="Enabled") + @XmlElement(name = "Enabled") public boolean isEnabled() { return enabled; } @@ -123,7 +122,7 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - @XmlElement(name="Version") + @XmlElement(name = "Version") public String getVersion() { return version; } @@ -137,7 +136,7 @@ public static class RetentionPolicy { private boolean enabled; private Integer days; - @XmlElement(name="Days") + @XmlElement(name = "Days") public Integer getDays() { return days; } @@ -146,7 +145,7 @@ public void setDays(Integer days) { this.days = days; } - @XmlElement(name="Enabled") + @XmlElement(name = "Enabled") public boolean isEnabled() { return enabled; } From 95e870b1d96bf1c8755372f1f7060ffc4ca037ac Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 17:54:15 -0800 Subject: [PATCH 113/664] Wrap jersey exceptions into ServiceException exception --- .../azure/services/blob/BlobService.java | 110 +- .../services/blob/BlobServiceForJersey.java | 805 +++++++++++ .../azure/services/blob/BlobServiceImpl.java | 1177 ++++++++--------- .../azure/services/blob/Exports.java | 1 + .../blob/BlobServiceIntegrationTest.java | 9 +- 5 files changed, 1387 insertions(+), 715 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 1688a95886ced..0a06c77622dba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -3,111 +3,115 @@ import java.io.InputStream; import java.util.HashMap; -//TODO: ServiceException annotation and handling in implementation +import com.microsoft.azure.ServiceException; + public interface BlobService { - ServiceProperties getServiceProperties(); + ServiceProperties getServiceProperties() throws ServiceException; - void setServiceProperties(ServiceProperties serviceProperties); + void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; - ListContainersResult listContainers(); + ListContainersResult listContainers() throws ServiceException; - ListContainersResult listContainers(ListContainersOptions options); + ListContainersResult listContainers(ListContainersOptions options) throws ServiceException; - void createContainer(String container); + void createContainer(String container) throws ServiceException; - void createContainer(String container, CreateContainerOptions options); + void createContainer(String container, CreateContainerOptions options) throws ServiceException; - void deleteContainer(String container); + void deleteContainer(String container) throws ServiceException; - void deleteContainer(String container, DeleteContainerOptions options); + void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException; - ContainerProperties getContainerProperties(String container); + ContainerProperties getContainerProperties(String container) throws ServiceException; - ContainerProperties getContainerMetadata(String container); + ContainerProperties getContainerMetadata(String container) throws ServiceException; - ContainerACL getContainerACL(String container); + ContainerACL getContainerACL(String container) throws ServiceException; - void setContainerACL(String container, ContainerACL acl); + void setContainerACL(String container, ContainerACL acl) throws ServiceException; - void setContainerMetadata(String container, HashMap metadata); + void setContainerMetadata(String container, HashMap metadata) throws ServiceException; - void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options); + void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException; - ListBlobsResult listBlobs(String container); + ListBlobsResult listBlobs(String container) throws ServiceException; - ListBlobsResult listBlobs(String container, ListBlobsOptions options); + ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException; - void createPageBlob(String container, String blob, int length); + void createPageBlob(String container, String blob, int length) throws ServiceException; - void createPageBlob(String container, String blob, int length, CreateBlobOptions options); + void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException; - void createBlockBlob(String container, String blob, InputStream contentStream); + void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException; - void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options); + void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; - CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd); + CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException; - CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options); + CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) throws ServiceException; - CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream); + CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) + throws ServiceException; CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, - CreateBlobPagesOptions options); + CreateBlobPagesOptions options) throws ServiceException; - void createBlobBlock(String container, String blob, String blockId, InputStream contentStream); + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException; - void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options); + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException; - void commitBlobBlocks(String container, String blob, BlockList blockList); + void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException; - void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options); + void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; - ListBlobBlocksResult listBlobBlocks(String container, String blob); + ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException; - ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options); + ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException; - BlobProperties getBlobProperties(String container, String blob); + BlobProperties getBlobProperties(String container, String blob) throws ServiceException; - BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options); + BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException; - GetBlobMetadataResult getBlobMetadata(String container, String blob); + GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException; - GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options); + GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException; - ListBlobRegionsResult listBlobRegions(String container, String blob); + ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException; - ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options); + ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException; - SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options); + SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException; - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata); + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException; - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options); + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) + throws ServiceException; - Blob getBlob(String container, String blob); + Blob getBlob(String container, String blob) throws ServiceException; - Blob getBlob(String container, String blob, GetBlobOptions options); + Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException; - void deleteBlob(String container, String blob); + void deleteBlob(String container, String blob) throws ServiceException; - void deleteBlob(String container, String blob, DeleteBlobOptions options); + void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException; - BlobSnapshot createBlobSnapshot(String container, String blob); + BlobSnapshot createBlobSnapshot(String container, String blob) throws ServiceException; - BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options); + BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException; - void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob); + void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException; - void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options); + void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) + throws ServiceException; - String acquireLease(String container, String blob); + String acquireLease(String container, String blob) throws ServiceException; - String acquireLease(String container, String blob, AcquireLeaseOptions options); + String acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException; - String renewLease(String container, String blob, String leaseId); + String renewLease(String container, String blob, String leaseId) throws ServiceException; - void releaseLease(String container, String blob, String leaseId); + void releaseLease(String container, String blob, String leaseId) throws ServiceException; - void breakLease(String container, String blob, String leaseId); + void breakLease(String container, String blob, String leaseId) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java new file mode 100644 index 0000000000000..9f859d2ebe9f9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java @@ -0,0 +1,805 @@ +package com.microsoft.azure.services.blob; + +import java.io.InputStream; +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.azure.ServiceException; +import com.microsoft.azure.utils.RFC1123DateMapper; +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; + +public class BlobServiceForJersey implements BlobService { + private static Log log = LogFactory.getLog(BlobServiceForJersey.class); + + private static final String API_VERSION = "2011-08-18"; + private final Client channel; + private final String accountName; + private final String url; + private final Integer timeout; + private final RFC1123DateMapper dateMapper; + + @Inject + public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, + @Named(BlobConfiguration.TIMEOUT) String timeout, + // TODO: How to make this configurable though code? + BlobSharedKeyLiteFilter filter) { + + this.accountName = accountName; + this.url = url; + this.channel = channel; + this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); + this.dateMapper = new RFC1123DateMapper(); + channel.addFilter(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(); + } + } + + 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 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; + } + + 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; + } + + 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; + } + + private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { + builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); + if (options.getContentType() == null) { + // Note: Add content type here to enable proper HMAC signing + builder = builder.type("application/octet-stream"); + } + builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + return builder; + } + + private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { + BlobProperties properties = new BlobProperties(); + + // Last-Modified + 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")); + + properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); + properties.setContentType(response.getHeaders().getFirst("Content-Type")); + properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); + properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); + properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); + + 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"))); + } + 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() { + WebResource webResource = channel.resource(url).path("/"); + webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); + + return webResource; + } + + private WebResource setCanonicalizedResource(WebResource webResource, String resourceName, String operation) { + String value = "/" + this.accountName + "/"; + if (resourceName != null) { + value += resourceName; + } + + if (operation != null) { + value += "?comp=" + operation; + } + + // TODO: Is this the best way to pass a parameter to a filter? + webResource.setProperty("canonicalizedResource", value); + return webResource; + } + + private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { + // Specifies the name of the source blob, in one of the following + // formats: + // Blob in named container: /accountName/containerName/blobName + // + // Snapshot in named container: + // /accountName/containerName/blobName?snapshot= + // + // Blob in root container: /accountName/blobName + // + // Snapshot in root container: /accountName/blobName?snapshot= + String sourceName = "/" + this.accountName; + if (sourceContainer != null) { + sourceName += "/" + sourceContainer; + } + sourceName += "/" + sourceBlob; + if (options.getSourceSnapshot() != null) { + sourceName += "?snapshot=" + options.getSourceSnapshot(); + } + return sourceName; + } + + public ServiceProperties getServiceProperties() throws ServiceException { + WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, null, "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ServiceProperties.class); + } + + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { + WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, null, "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 createContainer(String container) throws ServiceException { + createContainer(container, new CreateContainerOptions()); + } + + public void createContainer(String container, CreateContainerOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container"); + webResource = setCanonicalizedResource(webResource, container, null); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); + } + + public void deleteContainer(String container) throws ServiceException { + deleteContainer(container, new DeleteContainerOptions()); + } + + public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container"); + webResource = setCanonicalizedResource(webResource, container, null); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + builder.delete(); + } + + public ContainerProperties getContainerProperties(String container) throws ServiceException { + return getContainerPropertiesImpl(container, null); + } + + public ContainerProperties getContainerMetadata(String container) throws ServiceException { + return getContainerPropertiesImpl(container, "metadata"); + } + + private ContainerProperties getContainerPropertiesImpl(String container, String operation) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container"); + webResource = addOptionalQueryParam(webResource, "comp", operation); + webResource = setCanonicalizedResource(webResource, container, operation); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ContainerProperties properties = new ContainerProperties(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); + + return properties; + } + + public ContainerACL getContainerACL(String container) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + webResource = setCanonicalizedResource(webResource, container, "acl"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); + ContainerACL acl = new ContainerACL(); + acl.setSignedIdentifiers(si.getSignedIdentifiers()); + acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); + acl.setEtag(response.getHeaders().getFirst("ETag")); + acl.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + return acl; + } + + public void setContainerACL(String container, ContainerACL acl) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + webResource = setCanonicalizedResource(webResource, container, "acl"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); + + ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); + si.setSignedIdentifiers(acl.getSignedIdentifiers()); + // Note: Add content type here to enable proper HMAC signing + builder.type("application/xml").put(si); + } + + public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { + setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); + } + + public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, container, "metadata"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); + } + + public ListContainersResult listContainers() throws ServiceException { + return listContainers(new ListContainersOptions()); + } + + public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { + WebResource webResource = getResource().path("/").queryParam("comp", "list"); + webResource = setCanonicalizedResource(webResource, null, "list"); + 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)) { + webResource = webResource.queryParam("include", "metadata"); + } + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ListContainersResult.class); + } + + public ListBlobsResult listBlobs(String container) throws ServiceException { + return listBlobs(container, new ListBlobsOptions()); + } + + public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); + webResource = setCanonicalizedResource(webResource, container, "list"); + 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()); + } + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ListBlobsResult.class); + } + + public void createPageBlob(String container, String blob, int length) throws ServiceException { + createPageBlob(container, blob, length, new CreateBlobOptions()); + } + + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + WebResource webResource = getResource().path(container + "/" + blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); + builder = addOptionalHeader(builder, "Content-Length", 0); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + builder = addPutBlobHeaders(options, builder); + + // Note: Add content type here to enable proper HMAC signing + builder.type("application/octet-stream").put(new byte[0]); + } + + public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { + createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); + } + + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + WebResource webResource = getResource().path(container + "/" + blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + builder = builder.header("x-ms-blob-type", "BlockBlob"); + builder = addPutBlobHeaders(options, builder); + + Object contentObject = (contentStream == null ? new byte[0] : contentStream); + builder.put(contentObject); + } + + public BlobProperties getBlobProperties(String container, String blob) throws ServiceException { + return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); + } + + public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.method("HEAD", ClientResponse.class); + ThrowIfError(response); + + return getBlobPropertiesFromResponse(response); + } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { + return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); + } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + GetBlobMetadataResult properties = new GetBlobMetadataResult(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); + + return properties; + } + + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); + builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); + + SetBlobPropertiesResult result = new SetBlobPropertiesResult(); + + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + } + + return result; + } + + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); + } + + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) + throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); + + SetBlobMetadataResult result = new SetBlobMetadataResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + return result; + } + + public Blob getBlob(String container, String blob) throws ServiceException { + return getBlob(container, blob, new GetBlobOptions()); + } + + public Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + BlobProperties properties = getBlobPropertiesFromResponse(response); + Blob blobResult = new Blob(); + blobResult.setProperties(properties); + blobResult.setContentStream(response.getEntityInputStream()); + return blobResult; + } + + public void deleteBlob(String container, String blob) throws ServiceException { + deleteBlob(container, blob, new DeleteBlobOptions()); + } + + public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { + WebResource webResource = getResource().path(container + "/" + blob); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" : "include"); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + builder.delete(); + } + + public BlobSnapshot createBlobSnapshot(String container, String blob) throws ServiceException { + return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); + } + + public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); + + BlobSnapshot blobSnapshot = new BlobSnapshot(); + blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); + blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); + blobSnapshot.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + + return blobSnapshot; + } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); + } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { + WebResource webResource = getResource().path(destinationContainer).path(destinationBlob); + webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); + builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("text/plain").put(""); + } + + public String acquireLease(String container, String blob) throws ServiceException { + return acquireLease(container, blob, new AcquireLeaseOptions()); + } + + public String acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + return putLeaseImpl("acquire", container, blob, null, options); + } + + public String renewLease(String container, String blob, String leaseId) throws ServiceException { + return putLeaseImpl("renew", container, blob, leaseId, new AcquireLeaseOptions()); + } + + public void releaseLease(String container, String blob, String leaseId) throws ServiceException { + putLeaseImpl("release", container, blob, leaseId, new AcquireLeaseOptions()); + } + + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + putLeaseImpl("break", container, blob, leaseId, new AcquireLeaseOptions()); + } + + private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, AcquireLeaseOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); + builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ThrowIfError(response); + + return response.getHeaders().getFirst("x-ms-lease-id"); + } + + 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, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) + throws ServiceException { + return updatePageBlobPagesImpl("clear", container, blob, rangeStart, rangeEnd, 0, null, options); + } + + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) + throws ServiceException { + return createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new CreateBlobPagesOptions()); + } + + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + CreateBlobPagesOptions options) throws ServiceException { + return updatePageBlobPagesImpl("update", container, blob, rangeStart, rangeEnd, length, contentStream, options); + } + + private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, + InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "page"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); + builder = addOptionalHeader(builder, "Content-Length", length); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-page-write", action); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + Object content = (contentStream == null ? new byte[0] : contentStream); + ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); + ThrowIfError(response); + + CreateBlobPagesResult result = new CreateBlobPagesResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + + return result; + } + + public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { + return listBlobRegions(container, blob, new ListBlobRegionsOptions()); + } + + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + + return result; + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) + throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "block"); + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("application/octet-stream").put(contentStream); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { + commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + + // Note: Add content type here to enable proper HMAC signing + builder.type("application/xml").put(blockList); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { + return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentType(response.getHeaders().getFirst("Content-Type")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + + return result; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java index 505bc6734ef65..c3f24d67201e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java @@ -1,795 +1,656 @@ package com.microsoft.azure.services.blob; import java.io.InputStream; -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.azure.utils.RFC1123DateMapper; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.utils.ServiceExceptionFactory; +import com.sun.jersey.api.client.ClientHandlerException; 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; public class BlobServiceImpl implements BlobService { + private static Log log = LogFactory.getLog(BlobServiceImpl.class); + private final BlobService service; - private static final String API_VERSION = "2011-08-18"; - private final Client channel; - private final String accountName; - private final String url; - private final Integer timeout; - private final RFC1123DateMapper dateMapper; - - @Inject - public BlobServiceImpl(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - @Named(BlobConfiguration.TIMEOUT) String timeout, - // TODO: How to make this configurable though code? - BlobSharedKeyLiteFilter filter) { - - this.accountName = accountName; - this.url = url; - this.channel = channel; - this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); - this.dateMapper = new RFC1123DateMapper(); - channel.addFilter(filter); + public BlobServiceImpl(BlobServiceForJersey service) { + this.service = service; } - private void ThrowIfError(ClientResponse r) { - if (r.getStatus() >= 300) { - throw new UniformInterfaceException(r); - } + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("blob", e); } - 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); - } + public ServiceProperties getServiceProperties() throws ServiceException { + try { + return service.getServiceProperties(); } - - @Override - public String toString() { - return sb.toString(); + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); } - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - if (value != null) { - webResource = webResource.queryParam(key, value.toString()); + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - return webResource; } - private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - if (value != defaultValue) { - webResource = webResource.queryParam(key, Integer.toString(value)); + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { + try { + service.setServiceProperties(serviceProperties); } - return webResource; - } - - private Builder addOptionalHeader(Builder builder, String name, Object value) { - if (value != null) { - builder = builder.header(name, value); + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); } - return builder; - } - - private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - for (Entry entry : metadata.entrySet()) { - builder = builder.header("x-ms-meta-" + entry.getKey(), entry.getValue()); + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - return builder; } - 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); + public ListContainersResult listContainers() throws ServiceException { + try { + return service.listContainers(); } - return builder; - } - - private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - if (accessCondition != null) { - if (accessCondition.getHeader() != AccessConditionHeaderType.NONE) { - builder = addOptionalHeader(builder, accessCondition.getHeader().toString(), accessCondition.getValue()); - } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); } - return builder; - } - - 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()); - } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - 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); - } + public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { + try { + return service.listContainers(options); } - return metadata; - } - - private WebResource getResource() { - WebResource webResource = channel.resource(url).path("/"); - webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); - - return webResource; - } - - private WebResource setCanonicalizedResource(WebResource webResource, String resourceName, String operation) { - String value = "/" + this.accountName + "/"; - if (resourceName != null) { - value += resourceName; + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); } - - if (operation != null) { - value += "?comp=" + operation; + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - - // TODO: Is this the best way to pass a parameter to a filter? - webResource.setProperty("canonicalizedResource", value); - return webResource; } - private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { - // Specifies the name of the source blob, in one of the following - // formats: - // Blob in named container: /accountName/containerName/blobName - // - // Snapshot in named container: - // /accountName/containerName/blobName?snapshot= - // - // Blob in root container: /accountName/blobName - // - // Snapshot in root container: /accountName/blobName?snapshot= - String sourceName = "/" + this.accountName; - if (sourceContainer != null) { - sourceName += "/" + sourceContainer; + public void createContainer(String container) throws ServiceException { + try { + service.createContainer(container); } - sourceName += "/" + sourceBlob; - if (options.getSourceSnapshot() != null) { - sourceName += "?snapshot=" + options.getSourceSnapshot(); + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - return sourceName; - } - - public ServiceProperties getServiceProperties() { - WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, null, "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - return builder.get(ServiceProperties.class); - } - - public void setServiceProperties(ServiceProperties serviceProperties) { - WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, null, "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 createContainer(String container) { - createContainer(container, new CreateContainerOptions()); - } - - public void createContainer(String container, CreateContainerOptions options) { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, null); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); - - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); - } - - public void deleteContainer(String container) { - deleteContainer(container, new DeleteContainerOptions()); - } - public void deleteContainer(String container, DeleteContainerOptions options) { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, null); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.delete(); - } - - public ContainerProperties getContainerProperties(String container) { - return getContainerPropertiesImpl(container, null); - } - - public ContainerProperties getContainerMetadata(String container) { - return getContainerPropertiesImpl(container, "metadata"); - } - - private ContainerProperties getContainerPropertiesImpl(String container, String operation) { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); - webResource = addOptionalQueryParam(webResource, "comp", operation); - webResource = setCanonicalizedResource(webResource, container, operation); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ContainerProperties properties = new ContainerProperties(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; - } - - public ContainerACL getContainerACL(String container) { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, container, "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); - ContainerACL acl = new ContainerACL(); - acl.setSignedIdentifiers(si.getSignedIdentifiers()); - acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); - acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - return acl; } - public void setContainerACL(String container, ContainerACL acl) { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, container, "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); - - ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); - si.setSignedIdentifiers(acl.getSignedIdentifiers()); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/xml").put(si); + public void createContainer(String container, CreateContainerOptions options) throws ServiceException { + try { + service.createContainer(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void setContainerMetadata(String container, HashMap metadata) { - setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); + public void deleteContainer(String container) throws ServiceException { + try { + service.deleteContainer(container); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container, "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { + try { + service.deleteContainer(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListContainersResult listContainers() { - return listContainers(new ListContainersOptions()); + public ContainerProperties getContainerProperties(String container) throws ServiceException { + try { + return service.getContainerProperties(container); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListContainersResult listContainers(ListContainersOptions options) { - WebResource webResource = getResource().path("/").queryParam("comp", "list"); - webResource = setCanonicalizedResource(webResource, null, "list"); - 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)) { - webResource = webResource.queryParam("include", "metadata"); + public ContainerProperties getContainerMetadata(String container) throws ServiceException { + try { + return service.getContainerMetadata(container); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - return builder.get(ListContainersResult.class); } - public ListBlobsResult listBlobs(String container) { - return listBlobs(container, new ListBlobsOptions()); + public ContainerACL getContainerACL(String container) throws ServiceException { + try { + return service.getContainerACL(container); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListBlobsResult listBlobs(String container, ListBlobsOptions options) { - WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, "list"); - 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()); + public void setContainerACL(String container, ContainerACL acl) throws ServiceException { + try { + service.setContainerACL(container, acl); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - return builder.get(ListBlobsResult.class); } - public void createPageBlob(String container, String blob, int length) { - createPageBlob(container, blob, length, new CreateBlobOptions()); + public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { + try { + service.setContainerMetadata(container, metadata); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) { - WebResource webResource = getResource().path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); - builder = addOptionalHeader(builder, "Content-Length", 0); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addPutBlobHeaders(options, builder); - - // Note: Add content type here to enable proper HMAC signing - builder.type("application/octet-stream").put(new byte[0]); + public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { + try { + service.setContainerMetadata(container, metadata, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void createBlockBlob(String container, String blob, InputStream contentStream) { - createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); + public ListBlobsResult listBlobs(String container) throws ServiceException { + try { + return service.listBlobs(container); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) { - WebResource webResource = getResource().path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder = builder.header("x-ms-blob-type", "BlockBlob"); - builder = addPutBlobHeaders(options, builder); - - Object contentObject = (contentStream == null ? new byte[0] : contentStream); - builder.put(contentObject); + public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { + try { + return service.listBlobs(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { - builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); - if (options.getContentType() == null) { - // Note: Add content type here to enable proper HMAC signing - builder = builder.type("application/octet-stream"); + public void createPageBlob(String container, String blob, int length) throws ServiceException { + try { + service.createPageBlob(container, blob, length); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - return builder; } - public BlobProperties getBlobProperties(String container, String blob) { - return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + try { + service.createPageBlob(container, blob, length, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) { - WebResource webResource = getResource().path(container).path(blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.method("HEAD", ClientResponse.class); - ThrowIfError(response); - - return getBlobPropertiesFromResponse(response); + public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { + try { + service.createBlockBlob(container, blob, contentStream); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public GetBlobMetadataResult getBlobMetadata(String container, String blob) { - return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + try { + service.createBlockBlob(container, blob, contentStream, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetBlobMetadataResult properties = new GetBlobMetadataResult(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; + public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) throws ServiceException { + try { + return service.clearBlobPages(container, blob, rangeStart, rangeEnd); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); - builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); - ThrowIfError(response); - - SetBlobPropertiesResult result = new SetBlobPropertiesResult(); - - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) + throws ServiceException { + try { + return service.clearBlobPages(container, blob, rangeStart, rangeEnd, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - - return result; } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) { - return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) + throws ServiceException { + try { + return service.createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); - ThrowIfError(response); - - SetBlobMetadataResult result = new SetBlobMetadataResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - return result; + public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, + CreateBlobPagesOptions options) throws ServiceException { + try { + return service.createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public Blob getBlob(String container, String blob) { - return getBlob(container, blob, new GetBlobOptions()); + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + try { + service.createBlobBlock(container, blob, blockId, contentStream); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public Blob getBlob(String container, String blob, GetBlobOptions options) { - WebResource webResource = getResource().path(container).path(blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - BlobProperties properties = getBlobPropertiesFromResponse(response); - Blob blobResult = new Blob(); - blobResult.setProperties(properties); - blobResult.setContentStream(response.getEntityInputStream()); - return blobResult; + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) + throws ServiceException { + try { + service.createBlobBlock(container, blob, blockId, contentStream, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - private BlobProperties getBlobPropertiesFromResponse(ClientResponse response) { - BlobProperties properties = new BlobProperties(); - - // Last-Modified - 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")); - - properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); - properties.setContentType(response.getHeaders().getFirst("Content-Type")); - properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); - properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); - properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); - - 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"))); + public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { + try { + service.commitBlobBlocks(container, blob, blockList); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); } - return properties; } - public void deleteBlob(String container, String blob) { - deleteBlob(container, blob, new DeleteBlobOptions()); + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + try { + service.commitBlobBlocks(container, blob, blockList, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void deleteBlob(String container, String blob, DeleteBlobOptions options) { - WebResource webResource = getResource().path(container + "/" + blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" : "include"); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.delete(); + public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { + try { + return service.listBlobBlocks(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public BlobSnapshot createBlobSnapshot(String container, String blob) { - return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + try { + return service.listBlobBlocks(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); - ThrowIfError(response); - - BlobSnapshot blobSnapshot = new BlobSnapshot(); - blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); - blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); - blobSnapshot.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - - return blobSnapshot; + public BlobProperties getBlobProperties(String container, String blob) throws ServiceException { + try { + return service.getBlobProperties(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) { - copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); + public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + try { + return service.getBlobProperties(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { - WebResource webResource = getResource().path(destinationContainer).path(destinationBlob); - webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); - builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { + try { + return service.getBlobMetadata(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public String acquireLease(String container, String blob) { - return acquireLease(container, blob, new AcquireLeaseOptions()); + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + try { + return service.getBlobMetadata(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public String acquireLease(String container, String blob, AcquireLeaseOptions options) { - return putLeaseImpl("acquire", container, blob, null, options); + public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { + try { + return service.listBlobRegions(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public String renewLease(String container, String blob, String leaseId) { - return putLeaseImpl("renew", container, blob, leaseId, new AcquireLeaseOptions()); + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + try { + return service.listBlobRegions(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void releaseLease(String container, String blob, String leaseId) { - putLeaseImpl("release", container, blob, leaseId, new AcquireLeaseOptions()); + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + try { + return service.setBlobProperties(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void breakLease(String container, String blob, String leaseId) { - putLeaseImpl("break", container, blob, leaseId, new AcquireLeaseOptions()); + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + try { + return service.setBlobMetadata(container, blob, metadata); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, AcquireLeaseOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); - builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); - ThrowIfError(response); - - return response.getHeaders().getFirst("x-ms-lease-id"); + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) + throws ServiceException { + try { + return service.setBlobMetadata(container, blob, metadata, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd) { - return clearBlobPages(container, blob, rangeStart, rangeEnd, new CreateBlobPagesOptions()); + public Blob getBlob(String container, String blob) throws ServiceException { + try { + return service.getBlob(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public CreateBlobPagesResult clearBlobPages(String container, String blob, long rangeStart, long rangeEnd, CreateBlobPagesOptions options) { - return updatePageBlobPagesImpl("clear", container, blob, rangeStart, rangeEnd, 0, null, options); + public Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + try { + return service.getBlob(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) { - return createBlobPages(container, blob, rangeStart, rangeEnd, length, contentStream, new CreateBlobPagesOptions()); + public void deleteBlob(String container, String blob) throws ServiceException { + try { + service.deleteBlob(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, - CreateBlobPagesOptions options) { - return updatePageBlobPagesImpl("update", container, blob, rangeStart, rangeEnd, length, contentStream, options); + public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { + try { + service.deleteBlob(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, - InputStream contentStream, CreateBlobPagesOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "page"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); - builder = addOptionalHeader(builder, "Content-Length", length); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-page-write", action); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - Object content = (contentStream == null ? new byte[0] : contentStream); - ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); - ThrowIfError(response); - - CreateBlobPagesResult result = new CreateBlobPagesResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); - - return result; + public BlobSnapshot createBlobSnapshot(String container, String blob) throws ServiceException { + try { + return service.createBlobSnapshot(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListBlobRegionsResult listBlobRegions(String container, String blob) { - return listBlobRegions(container, blob, new ListBlobRegionsOptions()); + public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + try { + return service.createBlobSnapshot(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - - return result; + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + try { + service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) { - createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) + throws ServiceException { + try { + service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - - // Note: Add content type here to enable proper HMAC signing - builder.type("application/octet-stream").put(contentStream); + public String acquireLease(String container, String blob) throws ServiceException { + try { + return service.acquireLease(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void commitBlobBlocks(String container, String blob, BlockList blockList) { - commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); + public String acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + try { + return service.acquireLease(container, blob, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - // Note: Add content type here to enable proper HMAC signing - builder.type("application/xml").put(blockList); + public String renewLease(String container, String blob, String leaseId) throws ServiceException { + try { + return service.renewLease(container, blob, leaseId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListBlobBlocksResult listBlobBlocks(String container, String blob) { - return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); + public void releaseLease(String container, String blob, String leaseId) throws ServiceException { + try { + service.releaseLease(container, blob, leaseId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentType(response.getHeaders().getFirst("Content-Type")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); - - return result; + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + try { + service.breakLease(container, blob, leaseId); + } + 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/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java index 814f206f0ab2a..a9e9cee80c239 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java @@ -5,6 +5,7 @@ public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { registry.add(BlobService.class, BlobServiceImpl.class); + registry.add(BlobServiceForJersey.class); registry.add(BlobSharedKeyLiteFilter.class); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 3681f06228cef..a4771b5806e39 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -22,6 +22,7 @@ import org.junit.Test; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; public class BlobServiceIntegrationTest extends IntegrationTestBase { @@ -685,7 +686,7 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); Assert.fail("getBlob should throw an exception"); } - catch (Exception e) { + catch (ServiceException e) { } // Assert @@ -704,7 +705,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); Assert.fail("getBlob should throw an exception"); } - catch (Exception e) { + catch (ServiceException e) { } // Assert @@ -723,7 +724,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); Assert.fail("getBlob should throw an exception"); } - catch (Exception e) { + catch (ServiceException e) { } // Assert @@ -759,7 +760,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception service.getBlob(container, blob, new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); Assert.fail("getBlob should throw an exception"); } - catch (Exception e) { + catch (ServiceException e) { } // Assert From 44049e7f460cf8b31c91280aa5d4c2999f288a83 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 18:31:07 -0800 Subject: [PATCH 114/664] Make container ACL start and expiry date java.util.Date instances --- .../azure/services/blob/AccessCondition.java | 6 ++-- .../services/blob/BlobServiceForJersey.java | 11 +++--- .../blob/BlobSharedKeyLiteFilter.java | 4 +-- .../azure/services/blob/ContainerACL.java | 22 +++++++----- .../azure/utils/ISO8601DateAdapter.java | 22 ++++++++++++ .../azure/utils/ISO8601DateConverter.java | 36 +++++++++++++++++++ .../azure/utils/RFC1123DateAdapter.java | 4 +-- ...eMapper.java => RFC1123DateConverter.java} | 2 +- .../blob/BlobServiceIntegrationTest.java | 19 ++++++---- 9 files changed, 95 insertions(+), 31 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/utils/{RFC1123DateMapper.java => RFC1123DateConverter.java} (96%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java index 6696856d8159d..f4a19054ef91e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java @@ -2,7 +2,7 @@ import java.util.Date; -import com.microsoft.azure.utils.RFC1123DateMapper; +import com.microsoft.azure.utils.RFC1123DateConverter; /** * TODO: Unify this with client layer @@ -55,7 +55,7 @@ public static AccessCondition ifMatch(String etag) { * @return An AccessCondition object that represents the If-Modified-Since condition. */ public static AccessCondition ifModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, new RFC1123DateMapper().format(lastMotified)); + return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); } /** @@ -95,7 +95,7 @@ public static AccessCondition ifNoneMatch(String etag) { * @return An AccessCondition object that represents the If-Unmodified-Since condition. */ public static AccessCondition ifNotModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, new RFC1123DateMapper().format(lastMotified)); + return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java index 9f859d2ebe9f9..298ee0e81828e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java @@ -10,11 +10,8 @@ import javax.inject.Inject; import javax.inject.Named; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.microsoft.azure.ServiceException; -import com.microsoft.azure.utils.RFC1123DateMapper; +import com.microsoft.azure.utils.RFC1123DateConverter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; @@ -23,14 +20,14 @@ import com.sun.jersey.core.util.Base64; public class BlobServiceForJersey implements BlobService { - private static Log log = LogFactory.getLog(BlobServiceForJersey.class); + //private static Log log = LogFactory.getLog(BlobServiceForJersey.class); private static final String API_VERSION = "2011-08-18"; private final Client channel; private final String accountName; private final String url; private final Integer timeout; - private final RFC1123DateMapper dateMapper; + private final RFC1123DateConverter dateMapper; @Inject public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, @@ -42,7 +39,7 @@ public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAM this.url = url; this.channel = channel; this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); - this.dateMapper = new RFC1123DateMapper(); + this.dateMapper = new RFC1123DateConverter(); channel.addFilter(filter); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index 6b3f61b513fa6..0daa704285f2d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -9,7 +9,7 @@ import javax.inject.Named; import com.microsoft.azure.utils.HmacSHA256Sign; -import com.microsoft.azure.utils.RFC1123DateMapper; +import com.microsoft.azure.utils.RFC1123DateConverter; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -51,7 +51,7 @@ private void sign(ClientRequest cr) { String date = getHeader(cr, "Date"); if (date == "") { - date = new RFC1123DateMapper().format(new Date()); + date = new RFC1123DateConverter().format(new Date()); cr.getHeaders().add("Date", date); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index c9eca4826c867..fbb1e1a385bb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -6,10 +6,14 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.azure.utils.ISO8601DateAdapter; public class ContainerACL { private String etag; private Date lastModified; + //TODO: Enum? private String publicAccess; private List signedIdentifiers = new ArrayList(); @@ -45,7 +49,7 @@ public void setSignedIdentifiers(List signedIdentifiers) { this.signedIdentifiers = signedIdentifiers; } - public void AddSignedIdentifier(String id, String start, String expiry, String permission) { + public void AddSignedIdentifier(String id, Date start, Date expiry, String permission) { AccessPolicy accessPolicy = new AccessPolicy(); accessPolicy.setStart(start); accessPolicy.setExpiry(expiry); @@ -96,27 +100,27 @@ public void setAccessPolicy(AccessPolicy accessPolicy) { } public static class AccessPolicy { - //TODO: Make it a date? - private String start; - //TODO: Make it a date? - private String expiry; + private Date start; + private Date expiry; private String permission; @XmlElement(name = "Start") - public String getStart() { + @XmlJavaTypeAdapter(ISO8601DateAdapter.class) + public Date getStart() { return start; } - public void setStart(String start) { + public void setStart(Date start) { this.start = start; } @XmlElement(name = "Expiry") - public String getExpiry() { + @XmlJavaTypeAdapter(ISO8601DateAdapter.class) + public Date getExpiry() { return expiry; } - public void setExpiry(String expiry) { + public void setExpiry(Date expiry) { this.expiry = expiry; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java new file mode 100644 index 0000000000000..a64849eb8631b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java @@ -0,0 +1,22 @@ +package com.microsoft.azure.utils; + +import java.util.Date; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +/* + * JAXB adapter for an ISO 8601 date time element + */ +public class ISO8601DateAdapter extends XmlAdapter { + + @Override + public Date unmarshal(String arg0) throws Exception { + return new ISO8601DateConverter().parse(arg0); + } + + @Override + public String marshal(Date arg0) throws Exception { + return new ISO8601DateConverter().format(arg0); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java new file mode 100644 index 0000000000000..797308a30f47f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java @@ -0,0 +1,36 @@ +package com.microsoft.azure.utils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +public class ISO8601DateConverter { + private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'.0000000Z'"; + + public String format(Date date) { + return getFormat().format(date); + } + + public Date parse(String date) throws ParseException { + return getFormat().parse(date); + } + + public Date parseNoThrow(String date) { + try { + return parse(date); + } + catch (ParseException e) { + //TODO: Is it better to return null or throw a runtime exception? + return null; + } + } + + private DateFormat getFormat() { + DateFormat iso8601Format = new SimpleDateFormat(ISO8601_PATTERN, Locale.US); + iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT")); + return iso8601Format; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java index a5af1df1b36d1..b11ae7d797dc0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java @@ -12,11 +12,11 @@ public class RFC1123DateAdapter extends XmlAdapter { @Override public Date unmarshal(String arg0) throws Exception { - return new RFC1123DateMapper().parse(arg0); + return new RFC1123DateConverter().parse(arg0); } @Override public String marshal(Date arg0) throws Exception { - return new RFC1123DateMapper().format(arg0); + return new RFC1123DateConverter().format(arg0); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java index daf10c9bbd375..678cf1de27230 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java @@ -7,7 +7,7 @@ import java.util.Locale; import java.util.TimeZone; -public class RFC1123DateMapper { +public class RFC1123DateConverter { private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; public String format(Date date) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index a4771b5806e39..9b846dd186d6c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -16,6 +16,7 @@ import java.io.Writer; import java.util.Date; import java.util.EnumSet; +import java.util.GregorianCalendar; import java.util.HashMap; import junit.framework.Assert; @@ -169,16 +170,20 @@ public void setContainerACLWorks() throws Exception { Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); + String container = "foo4"; + Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); + Date expiryEndDate = new GregorianCalendar(2020, 1, 1).getTime(); + // Act - service.createContainer("foo4"); + service.createContainer(container); ContainerACL acl = new ContainerACL(); acl.setPublicAccess("blob"); - acl.AddSignedIdentifier("test", "2010-01-01", "2020-01-01", "rwd"); - service.setContainerACL("foo4", acl); + acl.AddSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); + service.setContainerACL(container, acl); - ContainerACL acl2 = service.getContainerACL("foo4"); - service.deleteContainer("foo4"); + ContainerACL acl2 = service.getContainerACL(container); + service.deleteContainer(container); // Assert assertNotNull(acl2); @@ -188,8 +193,8 @@ public void setContainerACLWorks() throws Exception { assertEquals("blob", acl2.getPublicAccess()); assertEquals(1, acl2.getSignedIdentifiers().size()); assertEquals("test", acl2.getSignedIdentifiers().get(0).getId()); - assertEquals("2010-01-01T00:00:00.0000000Z", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getStart()); - assertEquals("2020-01-01T00:00:00.0000000Z", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getExpiry()); + assertEquals(expiryStartDate, acl2.getSignedIdentifiers().get(0).getAccessPolicy().getStart()); + assertEquals(expiryEndDate, acl2.getSignedIdentifiers().get(0).getAccessPolicy().getExpiry()); assertEquals("rwd", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getPermission()); } From 0a081c490c539070b86a3453e08d50488cbc15e2 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Sun, 6 Nov 2011 18:44:18 -0800 Subject: [PATCH 115/664] Move a few classes in ".implementation" package --- .../azure/services/blob/AccessCondition.java | 2 +- .../azure/services/blob/BlobProperties.java | 2 +- .../blob/BlobSharedKeyLiteFilter.java | 4 +- .../azure/services/blob/BlockList.java | 2 +- .../azure/services/blob/BlockListBackup.java | 2 +- .../azure/services/blob/ContainerACL.java | 6 +-- .../azure/services/blob/Exports.java | 2 + .../services/blob/ListBlobBlocksResult.java | 2 +- .../azure/services/blob/ListBlobsResult.java | 2 +- .../services/blob/ListContainersResult.java | 2 +- .../implementation}/Base64StringAdapter.java | 2 +- .../BlobServiceForJersey.java | 47 +++++++++++++++++-- .../{ => implementation}/BlobServiceImpl.java | 38 ++++++++++++++- .../ContainerACLDateAdapter.java} | 8 ++-- .../ContainerACLDateConverter.java} | 8 ++-- .../blob/implementation}/HmacSHA256Sign.java | 2 +- .../implementation}/RFC1123DateAdapter.java | 2 +- .../implementation}/RFC1123DateConverter.java | 2 +- 18 files changed, 107 insertions(+), 28 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils => services/blob/implementation}/Base64StringAdapter.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ => implementation}/BlobServiceForJersey.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ => implementation}/BlobServiceImpl.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils/ISO8601DateAdapter.java => services/blob/implementation/ContainerACLDateAdapter.java} (54%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils/ISO8601DateConverter.java => services/blob/implementation/ContainerACLDateConverter.java} (73%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils => services/blob/implementation}/HmacSHA256Sign.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils => services/blob/implementation}/RFC1123DateAdapter.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/{utils => services/blob/implementation}/RFC1123DateConverter.java (94%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java index f4a19054ef91e..5a3eec1904bf3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java @@ -2,7 +2,7 @@ import java.util.Date; -import com.microsoft.azure.utils.RFC1123DateConverter; +import com.microsoft.azure.services.blob.implementation.RFC1123DateConverter; /** * TODO: Unify this with client layer diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java index 4a06606e123f8..37e97a9255527 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.RFC1123DateAdapter; +import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; //TODO: Unify this with ListBlobsResults.BlobProperties public class BlobProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index 0daa704285f2d..a5d11b5e38d3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -8,8 +8,8 @@ import javax.inject.Named; -import com.microsoft.azure.utils.HmacSHA256Sign; -import com.microsoft.azure.utils.RFC1123DateConverter; +import com.microsoft.azure.services.blob.implementation.HmacSHA256Sign; +import com.microsoft.azure.services.blob.implementation.RFC1123DateConverter; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java index 599a2bc699b38..13f5a8362d674 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.Base64StringAdapter; +import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class BlockList { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java index fc014990eacd8..a4407ada6a8a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java @@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.Base64StringAdapter; +import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class BlockListBackup { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index fbb1e1a385bb0..4c71fa70d86e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.ISO8601DateAdapter; +import com.microsoft.azure.services.blob.implementation.ContainerACLDateAdapter; public class ContainerACL { private String etag; @@ -105,7 +105,7 @@ public static class AccessPolicy { private String permission; @XmlElement(name = "Start") - @XmlJavaTypeAdapter(ISO8601DateAdapter.class) + @XmlJavaTypeAdapter(ContainerACLDateAdapter.class) public Date getStart() { return start; } @@ -115,7 +115,7 @@ public void setStart(Date start) { } @XmlElement(name = "Expiry") - @XmlJavaTypeAdapter(ISO8601DateAdapter.class) + @XmlJavaTypeAdapter(ContainerACLDateAdapter.class) public Date getExpiry() { return expiry; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java index a9e9cee80c239..a69865b163f98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java @@ -1,6 +1,8 @@ package com.microsoft.azure.services.blob; import com.microsoft.azure.configuration.builder.Builder; +import com.microsoft.azure.services.blob.implementation.BlobServiceForJersey; +import com.microsoft.azure.services.blob.implementation.BlobServiceImpl; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java index 86718a1609f58..7c6430a5e9838 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.Base64StringAdapter; +import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class ListBlobBlocksResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index cae9ac838b6f5..c32ff4f132885 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.RFC1123DateAdapter; +import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index 7282dc0a23499..bc6eb86b030e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.utils.RFC1123DateAdapter; +import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") public class ListContainersResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java index e607ccfca983b..fd2ce47e9f7ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index 298ee0e81828e..d11a7d27f0c94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.services.blob.implementation; import java.io.InputStream; import java.util.EnumSet; @@ -11,7 +11,48 @@ import javax.inject.Named; import com.microsoft.azure.ServiceException; -import com.microsoft.azure.utils.RFC1123DateConverter; +import com.microsoft.azure.services.blob.AccessCondition; +import com.microsoft.azure.services.blob.AccessConditionHeaderType; +import com.microsoft.azure.services.blob.AcquireLeaseOptions; +import com.microsoft.azure.services.blob.Blob; +import com.microsoft.azure.services.blob.BlobConfiguration; +import com.microsoft.azure.services.blob.BlobListingDetails; +import com.microsoft.azure.services.blob.BlobProperties; +import com.microsoft.azure.services.blob.BlobService; +import com.microsoft.azure.services.blob.BlobSharedKeyLiteFilter; +import com.microsoft.azure.services.blob.BlobSnapshot; +import com.microsoft.azure.services.blob.BlockList; +import com.microsoft.azure.services.blob.CommitBlobBlocksOptions; +import com.microsoft.azure.services.blob.ContainerACL; +import com.microsoft.azure.services.blob.ContainerListingDetails; +import com.microsoft.azure.services.blob.ContainerProperties; +import com.microsoft.azure.services.blob.CopyBlobOptions; +import com.microsoft.azure.services.blob.CreateBlobBlockOptions; +import com.microsoft.azure.services.blob.CreateBlobOptions; +import com.microsoft.azure.services.blob.CreateBlobPagesOptions; +import com.microsoft.azure.services.blob.CreateBlobPagesResult; +import com.microsoft.azure.services.blob.CreateBlobSnapshotOptions; +import com.microsoft.azure.services.blob.CreateContainerOptions; +import com.microsoft.azure.services.blob.DeleteBlobOptions; +import com.microsoft.azure.services.blob.DeleteContainerOptions; +import com.microsoft.azure.services.blob.GetBlobMetadataOptions; +import com.microsoft.azure.services.blob.GetBlobMetadataResult; +import com.microsoft.azure.services.blob.GetBlobOptions; +import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.ListBlobBlocksOptions; +import com.microsoft.azure.services.blob.ListBlobBlocksResult; +import com.microsoft.azure.services.blob.ListBlobRegionsOptions; +import com.microsoft.azure.services.blob.ListBlobRegionsResult; +import com.microsoft.azure.services.blob.ListBlobsOptions; +import com.microsoft.azure.services.blob.ListBlobsResult; +import com.microsoft.azure.services.blob.ListContainersOptions; +import com.microsoft.azure.services.blob.ListContainersResult; +import com.microsoft.azure.services.blob.ServiceProperties; +import com.microsoft.azure.services.blob.SetBlobMetadataOptions; +import com.microsoft.azure.services.blob.SetBlobMetadataResult; +import com.microsoft.azure.services.blob.SetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.SetBlobPropertiesResult; +import com.microsoft.azure.services.blob.SetContainerMetadataOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; @@ -20,7 +61,7 @@ import com.sun.jersey.core.util.Base64; public class BlobServiceForJersey implements BlobService { - //private static Log log = LogFactory.getLog(BlobServiceForJersey.class); + // private static Log log = LogFactory.getLog(BlobServiceForJersey.class); private static final String API_VERSION = "2011-08-18"; private final Client channel; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java index c3f24d67201e5..fb753e17433c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.services.blob.implementation; import java.io.InputStream; import java.util.HashMap; @@ -7,6 +7,42 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.services.blob.AcquireLeaseOptions; +import com.microsoft.azure.services.blob.Blob; +import com.microsoft.azure.services.blob.BlobProperties; +import com.microsoft.azure.services.blob.BlobService; +import com.microsoft.azure.services.blob.BlobSnapshot; +import com.microsoft.azure.services.blob.BlockList; +import com.microsoft.azure.services.blob.CommitBlobBlocksOptions; +import com.microsoft.azure.services.blob.ContainerACL; +import com.microsoft.azure.services.blob.ContainerProperties; +import com.microsoft.azure.services.blob.CopyBlobOptions; +import com.microsoft.azure.services.blob.CreateBlobBlockOptions; +import com.microsoft.azure.services.blob.CreateBlobOptions; +import com.microsoft.azure.services.blob.CreateBlobPagesOptions; +import com.microsoft.azure.services.blob.CreateBlobPagesResult; +import com.microsoft.azure.services.blob.CreateBlobSnapshotOptions; +import com.microsoft.azure.services.blob.CreateContainerOptions; +import com.microsoft.azure.services.blob.DeleteBlobOptions; +import com.microsoft.azure.services.blob.DeleteContainerOptions; +import com.microsoft.azure.services.blob.GetBlobMetadataOptions; +import com.microsoft.azure.services.blob.GetBlobMetadataResult; +import com.microsoft.azure.services.blob.GetBlobOptions; +import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.ListBlobBlocksOptions; +import com.microsoft.azure.services.blob.ListBlobBlocksResult; +import com.microsoft.azure.services.blob.ListBlobRegionsOptions; +import com.microsoft.azure.services.blob.ListBlobRegionsResult; +import com.microsoft.azure.services.blob.ListBlobsOptions; +import com.microsoft.azure.services.blob.ListBlobsResult; +import com.microsoft.azure.services.blob.ListContainersOptions; +import com.microsoft.azure.services.blob.ListContainersResult; +import com.microsoft.azure.services.blob.ServiceProperties; +import com.microsoft.azure.services.blob.SetBlobMetadataOptions; +import com.microsoft.azure.services.blob.SetBlobMetadataResult; +import com.microsoft.azure.services.blob.SetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.SetBlobPropertiesResult; +import com.microsoft.azure.services.blob.SetContainerMetadataOptions; import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java similarity index 54% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java index a64849eb8631b..637ad3cec4b2a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import java.util.Date; @@ -8,15 +8,15 @@ /* * JAXB adapter for an ISO 8601 date time element */ -public class ISO8601DateAdapter extends XmlAdapter { +public class ContainerACLDateAdapter extends XmlAdapter { @Override public Date unmarshal(String arg0) throws Exception { - return new ISO8601DateConverter().parse(arg0); + return new ContainerACLDateConverter().parse(arg0); } @Override public String marshal(Date arg0) throws Exception { - return new ISO8601DateConverter().format(arg0); + return new ContainerACLDateConverter().format(arg0); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java similarity index 73% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java index 797308a30f47f..30393db741344 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ISO8601DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import java.text.DateFormat; import java.text.ParseException; @@ -7,8 +7,8 @@ import java.util.Locale; import java.util.TimeZone; -public class ISO8601DateConverter { - private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'.0000000Z'"; +public class ContainerACLDateConverter { + private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'.0000000Z'"; public String format(Date date) { return getFormat().format(date); @@ -29,7 +29,7 @@ public Date parseNoThrow(String date) { } private DateFormat getFormat() { - DateFormat iso8601Format = new SimpleDateFormat(ISO8601_PATTERN, Locale.US); + DateFormat iso8601Format = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT")); return iso8601Format; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java index ec52c7be9ec3f..2da14e9a6fd80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java index b11ae7d797dc0..fa6049d6af8b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java index 678cf1de27230..1e5f806565f78 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.azure.services.blob.implementation; import java.text.DateFormat; import java.text.ParseException; From d3bd26eafe553661eef4c5a023c6597bef12ce74 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 7 Nov 2011 09:44:54 -0800 Subject: [PATCH 116/664] Added "TODO" comments for things that need review --- .../blob/AccessConditionHeaderType.java | 2 + .../microsoft/azure/services/blob/Blob.java | 3 + .../services/blob/BlobConfiguration.java | 10 +- .../azure/services/blob/BlobSnapshot.java | 3 + .../azure/services/blob/BlockList.java | 3 + .../azure/services/blob/BlockListBackup.java | 119 --------- .../azure/services/blob/ContainerACL.java | 12 +- .../services/blob/ContainerProperties.java | 3 + .../services/blob/CreateBlobBlockOptions.java | 1 + .../services/blob/CreateBlobPagesResult.java | 1 + .../services/blob/ListBlobBlocksOptions.java | 1 + .../services/blob/ListBlobBlocksResult.java | 3 + .../services/blob/ListBlobRegionsResult.java | 3 + .../azure/services/blob/ListBlobsResult.java | 231 +++++++++--------- .../services/blob/ListContainersResult.java | 45 ++-- .../services/blob/ServiceProperties.java | 11 +- .../implementation/Base64StringAdapter.java | 2 + .../implementation/BlobServiceForJersey.java | 9 +- .../ContainerACLDateAdapter.java | 4 +- .../ContainerACLDateConverter.java | 6 + .../blob/implementation/HmacSHA256Sign.java | 3 + .../{ => implementation}/MetadataAdapter.java | 2 +- .../implementation/RFC1123DateAdapter.java | 4 +- .../implementation/RFC1123DateConverter.java | 7 +- 24 files changed, 228 insertions(+), 260 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{ => implementation}/MetadataAdapter.java (95%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java index c0e8f8d8d6ab7..6bbac7e753aee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java @@ -35,6 +35,8 @@ 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/azure/services/blob/Blob.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java index ae486e0b8dd59..b8f058d382f58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java @@ -2,6 +2,9 @@ import java.io.InputStream; +/* + * TODO: Should this be called "GetBlobResult"? + */ public class Blob { private InputStream contentStream; private BlobProperties properties; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java index d72b04056e136..e6990d4629fda 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java @@ -1,8 +1,16 @@ package com.microsoft.azure.services.blob; +/* + * TODO: Add convenience methods to create/augment a configuration with + * strongly typed settings + * + * TODO: Support for connection strings? + * + * TODO: Built-in support for dev fabric? + */ public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; public final static String ACCOUNT_KEY = "blob.accountKey"; public final static String URL = "blob.url"; public final static String TIMEOUT = "blob.timeout"; -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java index 78ee8f8286072..e1fd1fc9c23ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java @@ -2,6 +2,9 @@ import java.util.Date; +/* + * TODO: Rename to "CreateBlobSnapshotResult"? + */ public class BlobSnapshot { private String snapshot; private String etag; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java index 13f5a8362d674..d25aa3e42cd3d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java @@ -49,6 +49,9 @@ public BlockList setEntries(List entries) { return this; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public abstract static class Entry { private String blockId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java deleted file mode 100644 index a4407ada6a8a4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockListBackup.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.microsoft.azure.services.blob; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; - -@XmlRootElement(name = "BlockList") -public class BlockListBackup { - private List committedEntries = new ArrayList(); - private List uncommittedEntries = new ArrayList(); - private List latestEntries = new ArrayList(); - - public BlockListBackup addCommittedEntry(String blockId) { - getCommittedEntries().add(blockId); - return this; - } - - public BlockListBackup addUncommittedEntry(String blockId) { - getUncommittedEntries().add(blockId); - return this; - } - - public BlockListBackup addLatestEntry(String blockId) { - getLatestEntries().add(blockId); - return this; - } - - @XmlElement(name = "Committed") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getCommittedEntries() { - return committedEntries; - } - - public BlockListBackup setCommittedEntries(List committedEntries) { - this.committedEntries = committedEntries; - return this; - } - - @XmlElement(name = "Uncommitted") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getUncommittedEntries() { - return uncommittedEntries; - } - - public BlockListBackup setUncommittedEntries(List uncommittedEntries) { - this.uncommittedEntries = uncommittedEntries; - return this; - } - - @XmlElement(name = "Latest") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getLatestEntries() { - return latestEntries; - } - - public BlockListBackup setLatestEntries(List latestEntries) { - this.latestEntries = latestEntries; - return this; - } -} -/* -public class BlockList { - private List committedEntries = new ArrayList(); - private List uncommittedEntries = new ArrayList(); - private List latestEntries = new ArrayList(); - - public BlockList addCommittedEntry(String blockId) { - getCommittedEntries().add(blockId); - return this; - } - - public BlockList addUncommittedEntry(String blockId) { - getUncommittedEntries().add(blockId); - return this; - } - - public BlockList addLatestEntry(String blockId) { - getLatestEntries().add(blockId); - return this; - } - - @XmlElement(name = "Committed") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getCommittedEntries() { - return committedEntries; - } - - public BlockList setCommittedEntries(List committedEntries) { - this.committedEntries = committedEntries; - return this; - } - - @XmlElement(name = "Uncommitted") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getUncommittedEntries() { - return uncommittedEntries; - } - - public BlockList setUncommittedEntries(List uncommittedEntries) { - this.uncommittedEntries = uncommittedEntries; - return this; - } - - @XmlElement(name = "Latest") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public List getLatestEntries() { - return latestEntries; - } - - public BlockList setLatestEntries(List latestEntries) { - this.latestEntries = latestEntries; - return this; - } - */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index 4c71fa70d86e7..9964b8ec58d49 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -14,7 +14,7 @@ public class ContainerACL { private String etag; private Date lastModified; //TODO: Enum? - private String publicAccess; + private String publicAccess; // "blob", "container or null private List signedIdentifiers = new ArrayList(); public String getEtag() { @@ -62,6 +62,9 @@ public void AddSignedIdentifier(String id, Date start, Date expiry, String permi this.getSignedIdentifiers().add(signedIdentifier); } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ @XmlRootElement(name = "SignedIdentifiers") public static class SignedIdentifiers { private List signedIdentifiers = new ArrayList(); @@ -76,6 +79,10 @@ public void setSignedIdentifiers(List signedIdentifiers) { } } + + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class SignedIdentifier { private String id; private AccessPolicy accessPolicy; @@ -99,6 +106,9 @@ public void setAccessPolicy(AccessPolicy accessPolicy) { } } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class AccessPolicy { private Date start; private Date expiry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java index c3226a8b34b39..80453738f2db2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java @@ -3,6 +3,9 @@ import java.util.Date; import java.util.HashMap; +/* + * TODO: Rename to "GetContainerPropertiesResult"? + */ public class ContainerProperties { private String etag; private Date lastModified; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java index e1516a819f98c..1d5030a1f5b08 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java @@ -2,6 +2,7 @@ public class CreateBlobBlockOptions { 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/azure/services/blob/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java index b41effe812734..5c71081817690 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java @@ -3,6 +3,7 @@ import java.util.Date; public class CreateBlobPagesResult { + //TODO: For "Result" classes, should we include "Date", "x-ms-version" response headers? private String etag; private Date lastModified; private String contentMD5; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java index 7577019948302..8c38e15514775 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java @@ -3,6 +3,7 @@ public class ListBlobBlocksOptions { private String leaseId; private String snapshot; + //TODO: Enum? private String listType; // "committed", "uncommitted", "all" public String getLeaseId() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java index 7c6430a5e9838..a1c43864d2c4d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java @@ -72,6 +72,9 @@ public void setUncommittedBlocks(List uncommittedBlocks) { this.uncommittedBlocks = uncommittedBlocks; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class Entry { private String blockId; private long blockLength; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java index 675ce97ec3737..a696dcbb3fe05 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java @@ -46,6 +46,9 @@ public void setPageRanges(List pageRanges) { this.pageRanges = pageRanges; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class PageRange { private long start; private long end; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index c32ff4f132885..3a531ecdf7576 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -10,6 +10,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.azure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") @@ -86,6 +87,9 @@ public void setContainerName(String containerName) { this.containerName = containerName; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class Blob { private String name; private String url; @@ -138,119 +142,122 @@ public HashMap getMetadata() { public void setMetadata(HashMap metadata) { this.metadata = metadata; } + } + + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ + 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 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; - } + public void setSequenceNUmber(String sequenceNUmber) { + this.sequenceNUmber = sequenceNUmber; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index bc6eb86b030e7..649775ac9b224 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -10,6 +10,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.azure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") @@ -76,6 +77,9 @@ public void setMaxResults(int maxResults) { this.maxResults = maxResults; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class Container { private String name; private String url; @@ -118,29 +122,32 @@ public HashMap getMetadata() { public void setMetadata(HashMap metadata) { this.metadata = metadata; } + } - public static class ContainerProperties { - private Date lastModified; - private String etag; - - @XmlElement(name = "Last-Modified") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - public Date getLastModified() { - return lastModified; - } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ + public static class ContainerProperties { + private Date lastModified; + private String etag; + + @XmlElement(name = "Last-Modified") + @XmlJavaTypeAdapter(RFC1123DateAdapter.class) + public Date getLastModified() { + return lastModified; + } - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } - @XmlElement(name = "Etag") - public String getEtag() { - return etag; - } + @XmlElement(name = "Etag") + public String getEtag() { + return etag; + } - public void setEtag(String etag) { - this.etag = etag; - } + public void setEtag(String etag) { + this.etag = etag; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java index 44f0ef9c28354..f6615bdc2e916 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java @@ -36,6 +36,9 @@ public void setDefaultServiceVersion(String defaultServiceVersion) { this.defaultServiceVersion = defaultServiceVersion; } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class Logging { private String version; private Boolean delete; @@ -89,6 +92,9 @@ public void setVersion(String version) { } } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class Metrics { private String version; private boolean enabled; @@ -132,9 +138,12 @@ public void setVersion(String version) { } } + /* + * TODO: Are nested classes ok? (if not, we need to find a name for it) + */ public static class RetentionPolicy { private boolean enabled; - private Integer days; + private Integer days; // nullable, because optional if "enabled" is false @XmlElement(name = "Days") public Integer getDays() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java index fd2ce47e9f7ed..4ea9fd8875d70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java @@ -5,6 +5,8 @@ import com.sun.jersey.core.util.Base64; /* + * TODO: Move so some other common package? + * * JAXB adapter for a Base64 encoded string element */ public class Base64StringAdapter extends XmlAdapter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index d11a7d27f0c94..e460653a86702 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -63,6 +63,7 @@ public class BlobServiceForJersey implements BlobService { // private static Log log = LogFactory.getLog(BlobServiceForJersey.class); + // TODO: Should we make this a configuration options? private static final String API_VERSION = "2011-08-18"; private final Client channel; private final String accountName; @@ -70,11 +71,13 @@ public class BlobServiceForJersey implements BlobService { private final Integer timeout; private final RFC1123DateConverter dateMapper; + /* + * TODO: How can we make "timeout" optional? TODO: How to make "filter" + * configurable though code? + */ @Inject public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - @Named(BlobConfiguration.TIMEOUT) String timeout, - // TODO: How to make this configurable though code? - BlobSharedKeyLiteFilter filter) { + @Named(BlobConfiguration.TIMEOUT) String timeout, BlobSharedKeyLiteFilter filter) { this.accountName = accountName; this.url = url; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java index 637ad3cec4b2a..aa35d2c28232e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java @@ -6,7 +6,9 @@ /* - * JAXB adapter for an ISO 8601 date time element + * 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/azure/services/blob/implementation/ContainerACLDateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java index 30393db741344..6a1eb8a10298f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java @@ -7,7 +7,13 @@ import java.util.Locale; import java.util.TimeZone; +/* + * TODO: Move to some other common package? + * + * "not quite" ISO 8601 date time conversion routines + */ public class ContainerACLDateConverter { + // Note: because of the trailing "0000000", this is not quite ISO 8601 compatible private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'.0000000Z'"; public String format(Date date) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java index 2da14e9a6fd80..b9b2b1be3d0f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java @@ -5,6 +5,9 @@ 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/azure/services/blob/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java index 953689d32df59..8b5e1d2782d79 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.services.blob.implementation; import java.util.ArrayList; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java index fa6049d6af8b6..07204dafe2893 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java @@ -6,7 +6,9 @@ /* - * JAXB adapter for element + * 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/azure/services/blob/implementation/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java index 1e5f806565f78..5e7c45a51ad13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java @@ -7,6 +7,11 @@ import java.util.Locale; import java.util.TimeZone; +/* + * TODO: Move to some other common package? + * + * RFC 1123 date to string conversion + */ public class RFC1123DateConverter { private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; @@ -23,7 +28,7 @@ public Date parseNoThrow(String date) { return parse(date); } catch (ParseException e) { - //TODO: Is it better to return null or throw a runtime exception? + // TODO: Is it better to return null or throw a runtime exception? return null; } } From 886623c6e2d84aa5194fb6754c1b191fe1eb0276 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 8 Nov 2011 11:26:27 -0800 Subject: [PATCH 117/664] Adding a ServiceFilter behavior composability concept Convenient way to handle all pre- post- and retry- related requirements --- .../azure/http/ClientFilterAdapter.java | 52 +++++++++++++++++++ .../microsoft/azure/http/ServiceFilter.java | 16 ++++++ .../serviceBus/ServiceBusService.java | 3 ++ .../ServiceBusServiceForJersey.java | 31 ++++++++++- .../implementation/ServiceBusServiceImpl.java | 15 +++++- .../services/serviceBus/RetryFilter.java | 30 +++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 29 +++++++++++ 7 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java new file mode 100644 index 0000000000000..b9ece41229804 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java @@ -0,0 +1,52 @@ +package com.microsoft.azure.http; + +import com.microsoft.azure.http.ServiceFilter.Request; +import com.microsoft.azure.http.ServiceFilter.Response; +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; + +public class ClientFilterAdapter extends ClientFilter { + ServiceFilter filter; + + public ClientFilterAdapter(ServiceFilter filter) { + this.filter = filter; + } + + @Override + public ClientResponse handle(ClientRequest clientRequest) + throws ClientHandlerException { + + final ClientRequest cr = clientRequest; + Response resp = filter.handle( + new ServiceFilterRequest(clientRequest), + new ServiceFilter.Next() { + public Response handle( + Request request) { + return new ServiceFilterResponse( + getNext().handle(cr)); + } + }); + + return ((ServiceFilterResponse) resp).clientResponse; + } +} + +class ServiceFilterRequest implements ServiceFilter.Request { + ClientRequest clientRequest; + + public ServiceFilterRequest(ClientRequest clientRequest) { + this.clientRequest = clientRequest; + } + +} + +class ServiceFilterResponse implements ServiceFilter.Response { + ClientResponse clientResponse; + + public ServiceFilterResponse(ClientResponse clientResponse) { + this.clientResponse = clientResponse; + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java new file mode 100644 index 0000000000000..5c1d4cf5db0fd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java @@ -0,0 +1,16 @@ +package com.microsoft.azure.http; + + +public interface ServiceFilter { + Response handle(Request request, Next next); + + public interface Next { + Response handle(Request request); + } + + public interface Request { + } + + public interface Response { + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index c4fa4a176caf0..82ee96404c540 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -1,5 +1,6 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.Feed; @@ -7,6 +8,8 @@ public interface ServiceBusService { + ServiceBusService withFilter(ServiceFilter filter); + void sendQueueMessage(String queueName, Message message) throws ServiceException; Message receiveQueueMessage(String queueName) throws ServiceException; Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java index 35eca1cf118d2..efe91ac85e6d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java @@ -3,6 +3,7 @@ import java.io.InputStream; import java.rmi.UnexpectedException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import javax.inject.Inject; @@ -25,6 +26,8 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.WrapFilter; +import com.microsoft.azure.http.ClientFilterAdapter; +import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandlerException; @@ -40,6 +43,8 @@ public class ServiceBusServiceForJersey implements ServiceBusService { private BrokerPropertiesMapper mapper; static Log log = LogFactory.getLog(ServiceBusService.class); + ServiceFilter[] filters; + @Inject public ServiceBusServiceForJersey( Client channel, @@ -48,11 +53,30 @@ public ServiceBusServiceForJersey( BrokerPropertiesMapper mapper) { this.channel = channel; + this.filters = new ServiceFilter[0]; this.uri = uri; this.mapper = mapper; channel.addFilter(authFilter); } + public ServiceBusServiceForJersey( + Client channel, + ServiceFilter[] filters, + String uri, + BrokerPropertiesMapper mapper) { + this.channel = channel; + this.filters = filters; + this.uri = uri; + this.mapper = mapper; + } + + public ServiceBusService withFilter(ServiceFilter filter) { + ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); + newFilters[filters.length] = filter; + return new ServiceBusServiceForJersey(channel, newFilters, uri, mapper); + } + + public Client getChannel() { return channel; } @@ -62,8 +86,12 @@ public void setChannel(Client channel) { } private WebResource getResource() { - return getChannel() + WebResource resource = getChannel() .resource(uri); + for(ServiceFilter filter : filters) { + resource.addFilter(new ClientFilterAdapter(filter)); + } + return resource; } void sendMessage(String path, Message message) { @@ -282,4 +310,5 @@ public Feed getRules(String topicPath, String subscriptionName) { + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java index 6160d5872c852..2180e605775f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java @@ -1,9 +1,12 @@ package com.microsoft.azure.services.serviceBus.implementation; +import javax.inject.Inject; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.serviceBus.ListQueuesResult; import com.microsoft.azure.services.serviceBus.ListTopicsResult; import com.microsoft.azure.services.serviceBus.Message; @@ -20,12 +23,21 @@ public class ServiceBusServiceImpl implements ServiceBusService { private ServiceBusService service; static Log log = LogFactory.getLog(ServiceBusService.class); + @Inject public ServiceBusServiceImpl(ServiceBusServiceForJersey service) { this.service = service; } - + public ServiceBusServiceImpl(ServiceBusService service) { + this.service = service; + } + + public ServiceBusService withFilter(ServiceFilter filter) { + return new ServiceBusServiceImpl(service.withFilter(filter)); + } + + private ServiceException processCatch(ServiceException e) { log.warn(e.getMessage(), e.getCause()); return ServiceExceptionFactory.process("serviceBus", e); @@ -309,6 +321,7 @@ public Feed getRules(String topicPath, String subscriptionName) throw processCatch(new ServiceException(e)); } } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java new file mode 100644 index 0000000000000..477043bfaef59 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java @@ -0,0 +1,30 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.http.ServiceFilter; + +public class RetryFilter implements ServiceFilter { + + public Response handle(Request request, Next next) { + Response response = null; + Exception error = null; + + for (int retryCount = 0; retryCount != 3; ++retryCount) { + try { + response = next.handle(request); + } catch (Exception ex) { + error = ex; + } + + boolean shouldRetry = false; + // TODO policy + if (!shouldRetry) + break; + } + if (response == null && error != null) { + // TODO define correct way to rethrow + throw new RuntimeException(error); + } + return response; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 9a80aeb15ca75..2bc3cd2be60a5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,7 +1,9 @@ package com.microsoft.azure.services.serviceBus; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; +import java.util.List; import javax.sound.sampled.ReverbType; @@ -10,6 +12,9 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.azure.http.ServiceFilter.Request; +import com.microsoft.azure.http.ServiceFilter.Response; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusService; @@ -221,4 +226,28 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException{ assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); } + + @Test + public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { + // Arrange + final List requests = new ArrayList(); + final List responses = new ArrayList(); + + ServiceBusService filtered = service.withFilter(new ServiceFilter() { + public Response handle(Request request, Next next) { + requests.add(request); + Response response = next.handle(request); + responses.add(response); + return response; + } + }); + + // Act + Queue created = filtered.createQueue(new Queue().setName("TestFilterCanSeeAndChangeRequestOrResponse")); + + // Assert + assertNotNull(created); + assertEquals(1, requests.size()); + assertEquals(1, responses.size()); + } } From ae07c68a07b6a986806ea68fcdc4c4b70dd6395e Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 8 Nov 2011 12:01:11 -0800 Subject: [PATCH 118/664] Adding interface members for interop --- .../azure/http/ClientFilterAdapter.java | 74 +++++++++++++++++++ .../microsoft/azure/http/ServiceFilter.java | 30 ++++++++ 2 files changed, 104 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java index b9ece41229804..7575e036997e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java @@ -1,10 +1,19 @@ package com.microsoft.azure.http; +import java.io.InputStream; +import java.net.URI; +import java.util.Map; + +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response.StatusType; + import com.microsoft.azure.http.ServiceFilter.Request; import com.microsoft.azure.http.ServiceFilter.Response; +import com.sun.jersey.api.client.Client; 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.ClientResponse.Status; import com.sun.jersey.api.client.filter.ClientFilter; public class ClientFilterAdapter extends ClientFilter { @@ -40,6 +49,42 @@ public ServiceFilterRequest(ClientRequest clientRequest) { this.clientRequest = clientRequest; } + public Map getProperties() { + return clientRequest.getProperties(); + } + + public void setProperties(Map properties) { + clientRequest.setProperties(properties); + } + + public URI getURI() { + return clientRequest.getURI(); + } + + public void setURI(URI uri) { + clientRequest.setURI(uri); + } + + public String getMethod() { + return clientRequest.getMethod(); + } + + public void setMethod(String method) { + clientRequest.setMethod(method); + } + + public Object getEntity() { + return clientRequest.getEntity(); + } + + public void setEntity(Object entity) { + clientRequest.setEntity(entity); + } + + public MultivaluedMap getHeaders() { + return clientRequest.getHeaders(); + } + } class ServiceFilterResponse implements ServiceFilter.Response { @@ -49,4 +94,33 @@ public ServiceFilterResponse(ClientResponse clientResponse) { this.clientResponse = clientResponse; } + public Map getProperties() { + return clientResponse.getProperties(); + } + + public int getStatus() { + return clientResponse.getStatus(); + } + + public void setStatus(int status) { + clientResponse.setStatus(status); + } + + + public MultivaluedMap getHeaders() { + return clientResponse.getHeaders(); + } + + public boolean hasEntity() { + return clientResponse.hasEntity(); + } + + public InputStream getEntityInputStream() { + return clientResponse.getEntityInputStream(); + } + + public void setEntityInputStream(InputStream entity) { + clientResponse.setEntityInputStream(entity); + } + } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java index 5c1d4cf5db0fd..c793830dabdc0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java @@ -1,5 +1,11 @@ package com.microsoft.azure.http; +import java.io.InputStream; +import java.net.URI; +import java.util.Map; + +import javax.ws.rs.core.MultivaluedMap; + public interface ServiceFilter { Response handle(Request request, Next next); @@ -9,8 +15,32 @@ public interface Next { } public interface Request { + public String getMethod(); + public void setMethod(String method); + + public URI getURI(); + public void setURI(URI uri); + + public MultivaluedMap getHeaders(); + + public Object getEntity(); + public void setEntity(Object entity); + + public Map getProperties(); + public void setProperties(Map properties); } public interface Response { + int getStatus(); + void setStatus(int status); + + MultivaluedMap getHeaders(); + + boolean hasEntity(); + + InputStream getEntityInputStream(); + void setEntityInputStream(InputStream entity); + + Map getProperties(); } } From 38dfa17abda00f821a9bdf644a9718b1710cf6ea Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 8 Nov 2011 12:38:24 -0800 Subject: [PATCH 119/664] Fix ISO 8601 date format to confrom to Blob Storage REST API implementation --- .../services/blob/implementation/ContainerACLDateConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java index 6a1eb8a10298f..d5e44c8c45fe6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java @@ -14,7 +14,7 @@ */ public class ContainerACLDateConverter { // Note: because of the trailing "0000000", this is not quite ISO 8601 compatible - private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'.0000000Z'"; + private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; public String format(Date date) { return getFormat().format(date); From 2eec9ac35a7b30af9bffff8e330ba175b068de7e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 8 Nov 2011 12:38:35 -0800 Subject: [PATCH 120/664] Add TODO comment --- .../com/microsoft/azure/services/blob/ServiceProperties.java | 1 + 1 file changed, 1 insertion(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java index f6615bdc2e916..b1a30090cffa7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java @@ -5,6 +5,7 @@ @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; From d130d9bc7068c42f18b51482619b8acdc610dae9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 8 Nov 2011 15:01:10 -0800 Subject: [PATCH 121/664] Add "withFilter" implementation to BlobService --- .../azure/services/blob/BlobService.java | 3 +++ .../implementation/BlobServiceForJersey.java | 25 ++++++++++++++++++- .../blob/implementation/BlobServiceImpl.java | 12 +++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 0a06c77622dba..78e0a63b48fdd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -4,8 +4,11 @@ import java.util.HashMap; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ServiceFilter; public interface BlobService { + BlobService withFilter(ServiceFilter filter); + ServiceProperties getServiceProperties() throws ServiceException; void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index e460653a86702..6974883dbad0f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -1,6 +1,7 @@ package com.microsoft.azure.services.blob.implementation; import java.io.InputStream; +import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; import java.util.List; @@ -11,6 +12,7 @@ import javax.inject.Named; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.blob.AccessCondition; import com.microsoft.azure.services.blob.AccessConditionHeaderType; import com.microsoft.azure.services.blob.AcquireLeaseOptions; @@ -70,6 +72,8 @@ public class BlobServiceForJersey implements BlobService { private final String url; private final Integer timeout; private final RFC1123DateConverter dateMapper; + private final ServiceFilter[] filters; + private final BlobSharedKeyLiteFilter filter; /* * TODO: How can we make "timeout" optional? TODO: How to make "filter" @@ -79,14 +83,33 @@ public class BlobServiceForJersey implements BlobService { public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, @Named(BlobConfiguration.TIMEOUT) String timeout, BlobSharedKeyLiteFilter filter) { + this.channel = channel; this.accountName = accountName; this.url = url; - this.channel = channel; + this.filter = filter; this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); this.dateMapper = new RFC1123DateConverter(); + this.filters = new ServiceFilter[0]; channel.addFilter(filter); } + public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, + String url, Integer timeout, BlobSharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + this.channel = channel; + this.filters = filters; + this.accountName = accountName; + this.url = url; + this.filter = filter; + this.dateMapper = dateMapper; + this.timeout = timeout; + } + + public BlobService 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.timeout, this.filter, this.dateMapper); + } + private void ThrowIfError(ClientResponse r) { if (r.getStatus() >= 300) { throw new UniformInterfaceException(r); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java index fb753e17433c2..74fcc54ba628d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java @@ -3,10 +3,13 @@ import java.io.InputStream; import java.util.HashMap; +import javax.inject.Inject; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.blob.AcquireLeaseOptions; import com.microsoft.azure.services.blob.Blob; import com.microsoft.azure.services.blob.BlobProperties; @@ -51,10 +54,19 @@ public class BlobServiceImpl implements BlobService { private static Log log = LogFactory.getLog(BlobServiceImpl.class); private final BlobService service; + @Inject public BlobServiceImpl(BlobServiceForJersey service) { this.service = service; } + public BlobServiceImpl(BlobService service) { + this.service = service; + } + + public BlobService withFilter(ServiceFilter filter) { + return new BlobServiceImpl(service.withFilter(filter)); + } + private ServiceException processCatch(ServiceException e) { log.warn(e.getMessage(), e.getCause()); return ServiceExceptionFactory.process("blob", e); From 72918ae74a418aa089acce55c16ecce79615ffbd Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 8 Nov 2011 17:41:55 -0800 Subject: [PATCH 122/664] Add code review comments --- .../java/com/microsoft/azure/services/blob/BlobService.java | 3 +++ .../microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 78e0a63b48fdd..d316a8aefdf06 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -17,10 +17,12 @@ public interface BlobService { ListContainersResult listContainers(ListContainersOptions options) throws ServiceException; + //TODO: Should we use "create" or "put"? void createContainer(String container) throws ServiceException; void createContainer(String container, CreateContainerOptions options) throws ServiceException; + // TODO: Should this have a "DeleteContainerResult" class void deleteContainer(String container) throws ServiceException; void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException; @@ -41,6 +43,7 @@ public interface BlobService { ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException; + //TODO: Should we use "create" or "put"? void createPageBlob(String container, String blob, int length) throws ServiceException; void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java index a5d11b5e38d3b..33e9db418ab45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java @@ -15,6 +15,9 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.filter.ClientFilter; +/* + * TODO: Should the "full" shared key signing? + */ public class BlobSharedKeyLiteFilter extends ClientFilter { private final String accountName; private final HmacSHA256Sign signer; From edb459ef6bb8af9ae4fc94b2c4c5aa6d829a2ee8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 9 Nov 2011 11:47:06 -0800 Subject: [PATCH 123/664] Adding an implementation of the interface that can be instantiated Also re-introduces the idea of a default-singleton Configuration instance --- .../azure/configuration/Configuration.java | 12 ++ ...sServiceThatCanBeInstantiatedDirectly.java | 134 ++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index ec8918e90312e..a2297ba459897 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -38,6 +38,16 @@ private void init() { } } + public static Configuration getInstance() { + if (instance == null) + instance = Configuration.load(); + return instance; + } + + public static void setInstance(Configuration instance) { + Configuration.instance = instance; + } + public static Configuration load() { // TODO - load from somewhere return new Configuration(); @@ -62,4 +72,6 @@ public Object getProperty(String name) { public void setProperty(String name, Object value) { properties.put(name, value); } + + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java new file mode 100644 index 0000000000000..1913cf17731b2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java @@ -0,0 +1,134 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Feed; + +public class ServiceBusServiceThatCanBeInstantiatedDirectly implements ServiceBusService { + final ServiceBusService service; + + public ServiceBusServiceThatCanBeInstantiatedDirectly() throws Exception { + this(Configuration.getInstance()); + } + + public ServiceBusServiceThatCanBeInstantiatedDirectly(Configuration config) throws Exception { + service = config.create(ServiceBusService.class); + } + + public ServiceBusService withFilter(ServiceFilter filter) { + return service.withFilter(filter); + } + + public void sendQueueMessage(String queueName, Message message) + throws ServiceException { + service.sendQueueMessage(queueName, message); + } + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return service.receiveQueueMessage(queueName); + } + + public Message receiveQueueMessage(String queueName, + ReceiveMessageOptions options) throws ServiceException { + return service.receiveQueueMessage(queueName, options); + } + + public void sendTopicMessage(String topicName, Message message) + throws ServiceException { + service.sendTopicMessage(topicName, message); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + return service.receiveSubscriptionMessage(topicName, subscriptionName); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + return service.receiveSubscriptionMessage(topicName, subscriptionName, + options); + } + + public void unlockMessage(Message message) throws ServiceException { + service.unlockMessage(message); + } + + public void deleteMessage(Message message) throws ServiceException { + service.deleteMessage(message); + } + + public Queue createQueue(Queue queue) throws ServiceException { + return service.createQueue(queue); + } + + public void deleteQueue(String queueName) throws ServiceException { + service.deleteQueue(queueName); + } + + public Queue getQueue(String queueName) throws ServiceException { + return service.getQueue(queueName); + } + + public ListQueuesResult listQueues() throws ServiceException { + return service.listQueues(); + } + + public Topic createTopic(Topic topic) throws ServiceException { + return service.createTopic(topic); + } + + public void deleteTopic(String topicName) throws ServiceException { + service.deleteTopic(topicName); + } + + public Topic getTopic(String topicName) throws ServiceException { + return service.getTopic(topicName); + } + + public ListTopicsResult listTopics() throws ServiceException { + return service.listTopics(); + } + + public void addSubscription(String topicName, String subscriptionName, + Entry subscription) throws ServiceException { + service.addSubscription(topicName, subscriptionName, subscription); + } + + public void removeSubscription(String topicName, String subscriptionName) + throws ServiceException { + service.removeSubscription(topicName, subscriptionName); + } + + public Entry getSubscription(String topicName, String subscriptionName) + throws ServiceException { + return service.getSubscription(topicName, subscriptionName); + } + + public Feed getSubscriptions(String topicName) throws ServiceException { + return service.getSubscriptions(topicName); + } + + public void addRule(String topicName, String subscriptionName, + String ruleName, Entry rule) throws ServiceException { + service.addRule(topicName, subscriptionName, ruleName, rule); + } + + public void removeRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + service.removeRule(topicName, subscriptionName, ruleName); + } + + public Entry getRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + return service.getRule(topicName, subscriptionName, ruleName); + } + + public Feed getRules(String topicName, String subscriptionName) + throws ServiceException { + return service.getRules(topicName, subscriptionName); + } +} From 283fbf91341b0bfcfc5ecd4ce40210207b48b0bd Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 13:27:23 -0800 Subject: [PATCH 124/664] Format file --- .../azure/http/ClientFilterAdapter.java | 158 ++++++++---------- 1 file changed, 74 insertions(+), 84 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java index 7575e036997e0..68d6672c0b448 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java @@ -5,122 +5,112 @@ import java.util.Map; import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response.StatusType; import com.microsoft.azure.http.ServiceFilter.Request; import com.microsoft.azure.http.ServiceFilter.Response; -import com.sun.jersey.api.client.Client; 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.ClientResponse.Status; import com.sun.jersey.api.client.filter.ClientFilter; public class ClientFilterAdapter extends ClientFilter { - ServiceFilter filter; - - public ClientFilterAdapter(ServiceFilter filter) { - this.filter = filter; - } - - @Override - public ClientResponse handle(ClientRequest clientRequest) - throws ClientHandlerException { - - final ClientRequest cr = clientRequest; - Response resp = filter.handle( - new ServiceFilterRequest(clientRequest), - new ServiceFilter.Next() { - public Response handle( - Request request) { - return new ServiceFilterResponse( - getNext().handle(cr)); - } - }); - - return ((ServiceFilterResponse) resp).clientResponse; - } + ServiceFilter filter; + + public ClientFilterAdapter(ServiceFilter filter) { + this.filter = filter; + } + + @Override + public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { + + final ClientRequest cr = clientRequest; + Response resp = filter.handle(new ServiceFilterRequest(clientRequest), new ServiceFilter.Next() { + public Response handle(Request request) { + return new ServiceFilterResponse(getNext().handle(cr)); + } + }); + + return ((ServiceFilterResponse) resp).clientResponse; + } } class ServiceFilterRequest implements ServiceFilter.Request { - ClientRequest clientRequest; + ClientRequest clientRequest; - public ServiceFilterRequest(ClientRequest clientRequest) { - this.clientRequest = clientRequest; - } + public ServiceFilterRequest(ClientRequest clientRequest) { + this.clientRequest = clientRequest; + } - public Map getProperties() { - return clientRequest.getProperties(); - } + public Map getProperties() { + return clientRequest.getProperties(); + } - public void setProperties(Map properties) { - clientRequest.setProperties(properties); - } + public void setProperties(Map properties) { + clientRequest.setProperties(properties); + } - public URI getURI() { - return clientRequest.getURI(); - } + public URI getURI() { + return clientRequest.getURI(); + } - public void setURI(URI uri) { - clientRequest.setURI(uri); - } + public void setURI(URI uri) { + clientRequest.setURI(uri); + } - public String getMethod() { - return clientRequest.getMethod(); - } + public String getMethod() { + return clientRequest.getMethod(); + } - public void setMethod(String method) { - clientRequest.setMethod(method); - } + public void setMethod(String method) { + clientRequest.setMethod(method); + } - public Object getEntity() { - return clientRequest.getEntity(); - } + public Object getEntity() { + return clientRequest.getEntity(); + } - public void setEntity(Object entity) { - clientRequest.setEntity(entity); - } + public void setEntity(Object entity) { + clientRequest.setEntity(entity); + } - public MultivaluedMap getHeaders() { - return clientRequest.getHeaders(); - } + public MultivaluedMap getHeaders() { + return clientRequest.getHeaders(); + } } class ServiceFilterResponse implements ServiceFilter.Response { - ClientResponse clientResponse; - - public ServiceFilterResponse(ClientResponse clientResponse) { - this.clientResponse = clientResponse; - } - - public Map getProperties() { - return clientResponse.getProperties(); - } + ClientResponse clientResponse; - public int getStatus() { - return clientResponse.getStatus(); - } + public ServiceFilterResponse(ClientResponse clientResponse) { + this.clientResponse = clientResponse; + } - public void setStatus(int status) { - clientResponse.setStatus(status); - } + public Map getProperties() { + return clientResponse.getProperties(); + } + public int getStatus() { + return clientResponse.getStatus(); + } - public MultivaluedMap getHeaders() { - return clientResponse.getHeaders(); - } + public void setStatus(int status) { + clientResponse.setStatus(status); + } - public boolean hasEntity() { - return clientResponse.hasEntity(); - } + public MultivaluedMap getHeaders() { + return clientResponse.getHeaders(); + } - public InputStream getEntityInputStream() { - return clientResponse.getEntityInputStream(); - } + public boolean hasEntity() { + return clientResponse.hasEntity(); + } - public void setEntityInputStream(InputStream entity) { - clientResponse.setEntityInputStream(entity); - } + public InputStream getEntityInputStream() { + return clientResponse.getEntityInputStream(); + } + public void setEntityInputStream(InputStream entity) { + clientResponse.setEntityInputStream(entity); + } } \ No newline at end of file From 1716af1671738e96a643bab48e46aecaafcc1d42 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 13:27:39 -0800 Subject: [PATCH 125/664] Add code review comments --- .../java/com/microsoft/azure/services/blob/BlobService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index d316a8aefdf06..05bc5ac6b3f02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -52,20 +52,24 @@ public interface BlobService { 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; CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException; + //TODO: createBlockBlobBlock? void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException; void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException; + //TODO: commitBlockBlobBlocks? void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException; void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; From 99a201274366a5ff17431d4132918a587ccc3b01 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 13:28:04 -0800 Subject: [PATCH 126/664] Rename class --- .../microsoft/azure/services/blob/Exports.java | 3 ++- .../implementation/BlobServiceForJersey.java | 11 +++++++---- .../SharedKeyLiteFilter.java} | 17 +++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{BlobSharedKeyLiteFilter.java => implementation/SharedKeyLiteFilter.java} (86%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java index a69865b163f98..bd35ecad674bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java @@ -3,11 +3,12 @@ import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.services.blob.implementation.BlobServiceForJersey; import com.microsoft.azure.services.blob.implementation.BlobServiceImpl; +import com.microsoft.azure.services.blob.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { registry.add(BlobService.class, BlobServiceImpl.class); registry.add(BlobServiceForJersey.class); - registry.add(BlobSharedKeyLiteFilter.class); + registry.add(SharedKeyLiteFilter.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index 6974883dbad0f..f131a2d860ac6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -12,6 +12,7 @@ import javax.inject.Named; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.http.ClientFilterAdapter; import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.blob.AccessCondition; import com.microsoft.azure.services.blob.AccessConditionHeaderType; @@ -21,7 +22,6 @@ import com.microsoft.azure.services.blob.BlobListingDetails; import com.microsoft.azure.services.blob.BlobProperties; import com.microsoft.azure.services.blob.BlobService; -import com.microsoft.azure.services.blob.BlobSharedKeyLiteFilter; import com.microsoft.azure.services.blob.BlobSnapshot; import com.microsoft.azure.services.blob.BlockList; import com.microsoft.azure.services.blob.CommitBlobBlocksOptions; @@ -73,7 +73,7 @@ public class BlobServiceForJersey implements BlobService { private final Integer timeout; private final RFC1123DateConverter dateMapper; private final ServiceFilter[] filters; - private final BlobSharedKeyLiteFilter filter; + private final SharedKeyLiteFilter filter; /* * TODO: How can we make "timeout" optional? TODO: How to make "filter" @@ -81,7 +81,7 @@ public class BlobServiceForJersey implements BlobService { */ @Inject public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - @Named(BlobConfiguration.TIMEOUT) String timeout, BlobSharedKeyLiteFilter filter) { + @Named(BlobConfiguration.TIMEOUT) String timeout, SharedKeyLiteFilter filter) { this.channel = channel; this.accountName = accountName; @@ -94,7 +94,7 @@ public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAM } public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, - String url, Integer timeout, BlobSharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + String url, Integer timeout, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; this.accountName = accountName; @@ -268,6 +268,9 @@ private HashMap getMetadataFromHeaders(ClientResponse response) private WebResource getResource() { WebResource webResource = channel.resource(url).path("/"); webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); + for(ServiceFilter filter : filters) { + webResource.addFilter(new ClientFilterAdapter(filter)); + } return webResource; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java index 33e9db418ab45..4a29b1c591aab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.azure.services.blob.implementation; import java.util.ArrayList; import java.util.Collections; @@ -8,8 +8,7 @@ import javax.inject.Named; -import com.microsoft.azure.services.blob.implementation.HmacSHA256Sign; -import com.microsoft.azure.services.blob.implementation.RFC1123DateConverter; +import com.microsoft.azure.services.blob.BlobConfiguration; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -18,11 +17,11 @@ /* * TODO: Should the "full" shared key signing? */ -public class BlobSharedKeyLiteFilter extends ClientFilter { +public class SharedKeyLiteFilter extends ClientFilter { private final String accountName; private final HmacSHA256Sign signer; - public BlobSharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { + public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { this.accountName = accountName; // TODO: How to make this configurable? @@ -32,12 +31,14 @@ public BlobSharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String acc @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - sign(cr); + // Only sign if no other filter has done it yet + if (cr.getHeaders().getFirst("Authorization") == null) { + sign(cr); + } return this.getNext().handle(cr); } - private String nullEmpty(String value) { return value != null ? value : ""; } @@ -66,7 +67,7 @@ private void sign(ClientRequest cr) { System.out.println(stringToSign); String signature = this.signer.sign(stringToSign); - cr.getHeaders().add("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); + cr.getHeaders().putSingle("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); } /* From 7cf381c38c0f714e17201301152901a8339bc12f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 13:31:42 -0800 Subject: [PATCH 127/664] Implement experimantal ExponentialRetryPolicy filter --- .../common/ExponentialRetryPolicyFilter.java | 94 +++++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 36 +++++++ 2 files changed, 130 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java new file mode 100644 index 0000000000000..14a2e71e357b9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java @@ -0,0 +1,94 @@ +package com.microsoft.azure.common; + +import java.util.Arrays; +import java.util.Random; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.azure.http.ServiceFilter; + +public class ExponentialRetryPolicyFilter implements ServiceFilter { + private static final Log log = LogFactory.getLog(ExponentialRetryPolicyFilter.class); + + public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; + public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; + public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; + public static final int DEFAULT_MIN_BACKOFF = 1000 * 3; + + private final int deltaBackoffIntervalInMs; + private final int maximumAttempts; + private final Random randRef = new Random(); + private final int resolvedMaxBackoff = DEFAULT_MAX_BACKOFF; + private final int resolvedMinBackoff = DEFAULT_MIN_BACKOFF; + private final int[] retryableStatusCodes; + + public ExponentialRetryPolicyFilter(int[] retryableStatusCodes) { + this(DEFAULT_CLIENT_BACKOFF, DEFAULT_CLIENT_RETRY_COUNT, retryableStatusCodes); + } + + public ExponentialRetryPolicyFilter(int deltaBackoff, int maximumAttempts, int[] retryableStatusCodes) { + this.deltaBackoffIntervalInMs = deltaBackoff; + this.maximumAttempts = maximumAttempts; + this.retryableStatusCodes = Arrays.copyOf(retryableStatusCodes, retryableStatusCodes.length); + Arrays.sort(this.retryableStatusCodes); + } + + public Response handle(Request request, Next next) { + // Only the last added retry policy should be active + if (request.getProperties().containsKey("RetryPolicy")) + return next.handle(request); + request.getProperties().put("RetryPolicy", this); + + // Retry the operation up to "getMaximumAttempts" + for (int retryCount = 0;; ++retryCount) { + Response response = next.handle(request); + + boolean shouldRetry = shouldRetry(retryCount, response); + if (!shouldRetry) + return response; + + int backoffTime = calculateBackoff(retryCount); + log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", backoffTime, retryCount)); + backoff(backoffTime); + } + } + + private void backoff(int milliseconds) { + try { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) { + // Restore the interrupted status + Thread.currentThread().interrupt(); + } + } + + private int calculateBackoff(int currentRetryCount) { + // Calculate backoff Interval between 80% and 120% of the desired + // backoff, multiply by 2^n -1 for + // exponential + int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); + int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) + + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - (int) (this.deltaBackoffIntervalInMs * 0.8)); + incrementDelta *= boundedRandDelta; + + // Enforce max / min backoffs + return Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff); + } + + private boolean shouldRetry(int retryCount, Response response) { + if (retryCount >= getMaximumAttempts()) + return false; + + // Don't retry if not retryable status code + if (Arrays.binarySearch(this.retryableStatusCodes, response.getStatus()) < 0) + return false; + + return true; + } + + private int getMaximumAttempts() { + return this.maximumAttempts; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 9b846dd186d6c..b3d7b07417e8e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -24,7 +24,9 @@ import org.junit.Test; import com.microsoft.azure.ServiceException; +import com.microsoft.azure.common.ExponentialRetryPolicyFilter; import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.http.ServiceFilter; public class BlobServiceIntegrationTest extends IntegrationTestBase { @@ -989,6 +991,40 @@ public void breakLeaseWorks() throws Exception { assertNotNull(leaseId); } + class RetryPolicyObserver implements ServiceFilter { + public int requestCount; + + public Response handle(Request request, Next next) { + requestCount++; + return next.handle(request); + } + } + + @Test + public void retryPolicyWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + + // Act + RetryPolicyObserver observer = new RetryPolicyObserver(); + service = service.withFilter(observer); + service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 3, new int[] { 400, 500, 503 })); + + ServiceException Error = null; + try { + service.createPageBlob("mycontainer1", "test", 12); + } + catch (ServiceException e) { + Error = e; + } + + // Assert + assertNotNull(Error); + assertEquals(400, Error.getHttpStatusCode()); + assertEquals(4, observer.requestCount); + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From a85898671e7e3480e1231b04dc03ce08c45a3ffe Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 13:34:49 -0800 Subject: [PATCH 128/664] Adding an integration test on retry policy composition --- .../blob/BlobServiceIntegrationTest.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index b3d7b07417e8e..e25b839e46c84 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -1005,11 +1005,37 @@ public void retryPolicyWorks() throws Exception { // Arrange Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); + RetryPolicyObserver observer = new RetryPolicyObserver(); + service = service.withFilter(observer); // Act + service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 3, new int[] { 400, 500, 503 })); + + ServiceException Error = null; + try { + service.createPageBlob("mycontainer1", "test", 12); + } + catch (ServiceException e) { + Error = e; + } + + // Assert + assertNotNull(Error); + assertEquals(400, Error.getHttpStatusCode()); + assertEquals(4, observer.requestCount); + } + + @Test + public void retryPolicyCompositionWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); + + // Act service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 3, new int[] { 400, 500, 503 })); + service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 2, new int[] { 400, 500, 503 })); ServiceException Error = null; try { @@ -1022,7 +1048,7 @@ public void retryPolicyWorks() throws Exception { // Assert assertNotNull(Error); assertEquals(400, Error.getHttpStatusCode()); - assertEquals(4, observer.requestCount); + assertEquals(3, observer.requestCount); } private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { From 75dbb923a2840c94e4a6faaf46371750331bb21c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 9 Nov 2011 14:22:03 -0800 Subject: [PATCH 129/664] Add "BlobOptions" base classe for timeout --- .../azure/services/blob/AcquireLeaseOptions.java | 2 +- .../azure/services/blob/BlobListingDetails.java | 6 +++--- .../azure/services/blob/BlobOptions.java | 15 +++++++++++++++ .../services/blob/CommitBlobBlocksOptions.java | 2 +- .../azure/services/blob/CopyBlobOptions.java | 2 +- .../services/blob/CreateBlobBlockOptions.java | 4 ++-- .../azure/services/blob/CreateBlobOptions.java | 2 +- .../services/blob/CreateBlobPagesOptions.java | 2 +- .../services/blob/CreateBlobSnapshotOptions.java | 2 +- .../services/blob/CreateContainerOptions.java | 2 +- .../azure/services/blob/DeleteBlobOptions.java | 2 +- .../services/blob/DeleteContainerOptions.java | 2 +- .../services/blob/GetBlobMetadataOptions.java | 3 +-- .../azure/services/blob/GetBlobOptions.java | 3 +-- .../services/blob/GetBlobPropertiesOptions.java | 2 +- .../services/blob/ListBlobBlocksOptions.java | 4 ++-- .../services/blob/ListBlobRegionsOptions.java | 2 +- .../azure/services/blob/ListBlobsOptions.java | 2 +- .../services/blob/ListContainersOptions.java | 2 +- .../services/blob/SetBlobMetadataOptions.java | 2 +- .../services/blob/SetBlobPropertiesOptions.java | 3 +-- .../blob/SetContainerMetadataOptions.java | 2 +- .../blob/implementation/BlobServiceForJersey.java | 13 ++++++++----- 23 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java index a3c57ea692ff4..aea31118f08a5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class AcquireLeaseOptions { +public class AcquireLeaseOptions extends BlobOptions { private AccessCondition accessCondition; public AccessCondition getAccessCondition() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java index 57595fc6d1c76..4c603362ed8eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java @@ -2,12 +2,12 @@ /** * TODO: Naming and unification with client package - * + * * 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 { @@ -38,7 +38,7 @@ public enum BlobListingDetails { /** * Sets the value of this enum. - * + * * @param val * The value being assigned. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java new file mode 100644 index 0000000000000..1c649ea881628 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java @@ -0,0 +1,15 @@ +package com.microsoft.azure.services.blob; + +public class BlobOptions { + // Nullable because it is optional + private Integer timeout; + + public Integer getTimeout() { + return timeout; + } + + public BlobOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java index 030ffcbd59b18..ace8125f80655 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CommitBlobBlocksOptions { +public class CommitBlobBlocksOptions extends BlobOptions { private String blobContentType; private String blobContentEncoding; private String blobContentLanguage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java index 15ac928766d54..c1fbe882fd69e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CopyBlobOptions { +public class CopyBlobOptions extends BlobOptions { private String leaseId; private AccessCondition accessCondition; private String sourceLeaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java index 1d5030a1f5b08..8d58f73415a16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java @@ -1,8 +1,8 @@ package com.microsoft.azure.services.blob; -public class CreateBlobBlockOptions { +public class CreateBlobBlockOptions extends BlobOptions { private String leaseId; - //TODO: Should the service layer support computing MD5 for the caller? + // 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/azure/services/blob/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java index 2a086b85ed39b..a01bee91e7286 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CreateBlobOptions { +public class CreateBlobOptions extends BlobOptions { private String contentType; private String contentEncoding; private String contentLanguage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java index 90d095be3243b..ad662e262ace5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class CreateBlobPagesOptions { +public class CreateBlobPagesOptions extends BlobOptions { private String leaseId; private String contentMD5; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java index 0dc3262003765..fda2f92c4a88d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CreateBlobSnapshotOptions { +public class CreateBlobSnapshotOptions extends BlobOptions { private HashMap metadata = new HashMap(); private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java index 7cf500be46e6f..61ca68f781258 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class CreateContainerOptions { +public class CreateContainerOptions extends BlobOptions { private String publicAccess; private HashMap metadata = new HashMap(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java index 531a5676d3f39..42a8b69b7c0fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class DeleteBlobOptions { +public class DeleteBlobOptions extends BlobOptions { private String snapshot; private String leaseId; private boolean deleteSnaphotsOnly; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java index 567005baa7f35..08823c610c058 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class DeleteContainerOptions { +public class DeleteContainerOptions extends BlobOptions { private AccessCondition accessCondition; public AccessCondition getAccessCondition() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java index 364ec7fbb1dae..2e31a628f1358 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.blob; - -public class GetBlobMetadataOptions { +public class GetBlobMetadataOptions extends BlobOptions { private String snapshot; private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java index 2b91521e8f797..d8ea83aa6eb74 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.blob; - -public class GetBlobOptions { +public class GetBlobOptions extends BlobOptions { private String snapshot; private String leaseId; private boolean computeRangeMD5; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java index 5254ec481fb23..d276343c59398 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class GetBlobPropertiesOptions { +public class GetBlobPropertiesOptions extends BlobOptions { private String snapshot; private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java index 8c38e15514775..911df5304f196 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java @@ -1,9 +1,9 @@ package com.microsoft.azure.services.blob; -public class ListBlobBlocksOptions { +public class ListBlobBlocksOptions extends BlobOptions { private String leaseId; private String snapshot; - //TODO: Enum? + // TODO: Enum? private String listType; // "committed", "uncommitted", "all" public String getLeaseId() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java index 76b565bd5de98..54af7e0c78d34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class ListBlobRegionsOptions { +public class ListBlobRegionsOptions extends BlobOptions { private String leaseId; private String snapshot; private Long rangeStart; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java index 085a55cbb12f1..a75507f2afe24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java @@ -2,7 +2,7 @@ import java.util.EnumSet; -public class ListBlobsOptions { +public class ListBlobsOptions extends BlobOptions { private String prefix; private String marker; private int maxResults; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java index cae1af10aff43..f9e547a5fe57f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java @@ -2,7 +2,7 @@ import java.util.EnumSet; -public class ListContainersOptions { +public class ListContainersOptions extends BlobOptions { private String prefix; private String marker; private int maxResults; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java index 86ee7e5d144d9..a8d5e0729f79a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class SetBlobMetadataOptions { +public class SetBlobMetadataOptions extends BlobOptions { private String leaseId; private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java index 002c9f1fa1546..eaa0e49258b39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java @@ -1,7 +1,6 @@ package com.microsoft.azure.services.blob; - -public class SetBlobPropertiesOptions { +public class SetBlobPropertiesOptions extends BlobOptions { private String leaseId; private String contentType; private Long contentLength; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java index b1a710eb4cf34..dec78bd216970 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.blob; -public class SetContainerMetadataOptions { +public class SetContainerMetadataOptions extends BlobOptions { private AccessCondition accessCondition; public AccessCondition getAccessCondition() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index f131a2d860ac6..63dc9d46e8bd0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -80,8 +80,12 @@ public class BlobServiceForJersey implements BlobService { * configurable though code? */ @Inject - public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - @Named(BlobConfiguration.TIMEOUT) String timeout, SharedKeyLiteFilter filter) { + public BlobServiceForJersey( + Client channel, + @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, + @Named(BlobConfiguration.URL) String url, + @Named(BlobConfiguration.TIMEOUT) String timeout, + SharedKeyLiteFilter filter) { this.channel = channel; this.accountName = accountName; @@ -93,8 +97,7 @@ public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAM channel.addFilter(filter); } - public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, - String url, Integer timeout, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, Integer timeout, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; this.accountName = accountName; @@ -268,7 +271,7 @@ private HashMap getMetadataFromHeaders(ClientResponse response) private WebResource getResource() { WebResource webResource = channel.resource(url).path("/"); webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); - for(ServiceFilter filter : filters) { + for (ServiceFilter filter : filters) { webResource.addFilter(new ClientFilterAdapter(filter)); } From 19ec1fd48658d3eb9280b4ec14181df9b85888a9 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Wed, 9 Nov 2011 16:51:01 -0800 Subject: [PATCH 130/664] Added preliminary Javadoc content. --- .../azure/services/serviceBus/Message.java | 267 +++++++++++++++++- 1 file changed, 262 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 43d95f107b03f..44f402c39f0fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -6,173 +6,430 @@ import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; +/** + * Represents a service bus message. + */ public class Message { BrokerProperties properties; InputStream body; String contentType; Date date; + /** + * Creates an instance of the Message class. + */ public Message() { this.properties = new BrokerProperties(); } - + + /** + * Creates an instance of the Message class using the specified + * InputStream. + * + * @param body + * An InputStream object that represents the body of + * the message. + */ public Message(InputStream body) { this.properties = new BrokerProperties(); this.body = body; - } + } + /** + * Creates an instance of the Message class using the specified + * byte array. + * + * @param body + * A byte array that represents the body of the message. + */ public Message(byte[] body) { this.properties = new BrokerProperties(); this.body = (body == null) ? null : new ByteArrayInputStream(body); } + /** + * Creates an instance of the Message class using the specified + * string. + * + * @param body + * A String object that represents the body of the + * message. + */ public Message(String body) { this.properties = new BrokerProperties(); - this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); + this.body = (body == null) ? null : new ByteArrayInputStream( + body.getBytes()); } Message(BrokerProperties properties, InputStream body) { this.properties = properties; this.body = body; } - + + /** + * Returns the properties of the message. + * + * @return A {@link BrokerProperties} object that represents the properties + * of the message. + */ public BrokerProperties getProperties() { return properties; } - + + /** + * Sets the properties of the message. + * + * @param properties + * A {@link BrokerProperties} object that represents the + * properties of the message. + */ public Message setProperties(BrokerProperties properties) { this.properties = properties; return this; } + /** + * Returns the body of the message. + * + * @return An InputStream object that represents the body of + * the message. + */ public InputStream getBody() { return body; } + /** + * Specifies the body of the message. + * + * @param body + * An InputStream object that represents the body of + * the message. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setBody(InputStream body) { this.body = body; return this; } + /** + * Returns the content type of the message. + * + * @return A String object that represents the content type. + */ public String getContentType() { return contentType; } + /** + * Sets the content type of the message. + * + * @param contentType + * A String object that represents the content type. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setContentType(String contentType) { this.contentType = contentType; return this; } + /** + * Returns the date/time of the message. + * + * @return A Date object that represents the date/time of the + * object. + */ public Date getDate() { return date; } + /** + * Sets the date/time of the message. + * + * @param date + * A Date object that represents the date/time of the + * object. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setDate(Date date) { this.date = date; return this; } + /** + * Returns the delivery count of the message. + * + * @return The delivery count. + */ public Integer getDeliveryCount() { return properties.getDeliveryCount(); } + /** + * Returns the message ID. + * + * @return A String object that represents the message ID. + */ public String getMessageId() { return properties.getMessageId(); } + /** + * Sets the message ID. + * + * @param messageId + * A String object that represents the message ID. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setMessageId(String messageId) { properties.setMessageId(messageId); return this; } + /** + * Returns the message sequence number. + * + * @return The message sequence number. + * + */ public Long getSequenceNumber() { return properties.getSequenceNumber(); } + /** + * Returns the time-to-live for the message. + * + * @return The time, in seconds, for the message to live. + */ public Double getTimeToLive() { return properties.getTimeToLive(); } + /** + * Sets the time-to-live for the message. + * + * @param timeToLive + * The time, in seconds, for the message to live. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setTimeToLive(Double timeToLive) { properties.setTimeToLive(timeToLive); return this; } + /** + * Returns the lock token for the message. + * + * @return A String object that represents the lock token. + */ public String getLockToken() { return properties.getLockToken(); } + /** + * Returns the locked-until date/time. + * + * @return A Date object that represents the locked-until + * date/time, in UTC format. + */ public Date getLockedUntilUtc() { return properties.getLockedUntilUtc(); } + /** + * Returns the correlation ID. + * + * @return A String object that represents the correlation ID. + * + */ public String getCorrelationId() { return properties.getCorrelationId(); } + /** + * Sets the correlation ID. + * + * @param correlationId + * A String object that represents the correlation + * ID. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setCorrelationId(String correlationId) { properties.setCorrelationId(correlationId); return this; } + /** + * Returns the session ID for the message. + * + * @return A String object that represents the session ID. + * + */ public String getSessionId() { return properties.getSessionId(); } + /** + * Sets the session ID for the message. + * + * @param sessionId + * A String object that represents the session ID. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setSessionId(String sessionId) { properties.setSessionId(sessionId); return this; } + /** + * Returns the label of the message. + * + * @return A String object that represents the label. + */ public String getLabel() { return properties.getLabel(); } + /** + * Sets the label of the message. + * + * @param label + * A String object that represents the label. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setLabel(String label) { properties.setLabel(label); return this; } + /** + * Returns the Reply-To recipient of the message. + * + * @return A String object that represents the Reply-To + * recipient. + */ public String getReplyTo() { return properties.getReplyTo(); } + /** + * Sets the Reply-To recipient for the message. + * + * @param replyTo + * A String object that represents the Reply-To + * recipient. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setReplyTo(String replyTo) { properties.setReplyTo(replyTo); return this; } + /** + * Returns the To recipient of the message. + * + * @return A String object that represents the To recipient. + */ public String getTo() { return properties.getTo(); } + /** + * Sets the To recipient of the message. + * + * @param A + * String object that represents the To recipient. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setTo(String to) { properties.setTo(to); return this; } + /** + * Returns the scheduled enqueue date/time. + * + * @return A Date object that represents the date/time of the + * message in UTC format. + */ public Date getScheduledEnqueueTimeUtc() { return properties.getScheduledEnqueueTimeUtc(); } + /** + * Sets the scheduled enqueue time. + * + * @param scheduledEnqueueTimeUtc + * A Date object that represents the date/time of + * the message in UTC format. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); return this; } + /** + * Returns the session ID of the Reply To recipient. + * + * @return A String object that represents the session ID of + * the Reply To recipient. + */ public String getReplyToSessionId() { return properties.getReplyToSessionId(); } + /** + * Sets the session ID of the Reply To recipient. + * + * @param replyToSessionId + * A String object that represents the session ID of + * the Reply To recipient. + * + * @return A Message object that reperesents the updated + * message. + */ public Message setReplyToSessionId(String replyToSessionId) { properties.setReplyToSessionId(replyToSessionId); return this; } + /** + * Returns the message location. + * + * @return A String object that represents the message + * location. + */ public String getMessageLocation() { return properties.getMessageLocation(); } + /** + * Returns the lock location. + * + * @return A String object that represents the lock location. + */ public String getLockLocation() { return properties.getLockLocation(); } From cbb079fe752447ef0c001de253e6248eabcce947 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 9 Nov 2011 16:53:53 -0800 Subject: [PATCH 131/664] Switching over to contract/service naming convention --- .../azure/services/serviceBus/Exports.java | 10 +- .../serviceBus/ServiceBusConfiguration.java | 7 + .../serviceBus/ServiceBusContract.java | 44 +++++ .../serviceBus/ServiceBusService.java | 174 ++++++++++++++---- ...sServiceThatCanBeInstantiatedDirectly.java | 134 -------------- .../services/serviceBus/Subscription.java | 15 ++ .../azure/services/serviceBus/Util.java | 4 +- .../serviceBus/client/MessagingClient.java | 18 +- ...java => ServiceBusExceptionProcessor.java} | 72 ++++---- ...orJersey.java => ServiceBusRestProxy.java} | 20 +- .../serviceBus/ContractBuilderTest.java | 20 -- .../serviceBus/IntegrationTestBase.java | 4 +- .../serviceBus/ServiceBusCreationTest.java | 54 ++++++ .../serviceBus/ServiceBusIntegrationTest.java | 8 +- 14 files changed, 326 insertions(+), 258 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/{ServiceBusServiceImpl.java => ServiceBusExceptionProcessor.java} (82%) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/{ServiceBusServiceForJersey.java => ServiceBusRestProxy.java} (88%) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index ad705ee15a5e0..d7336a6577560 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -7,8 +7,8 @@ import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.azure.services.serviceBus.implementation.EntryModelProvider; import com.microsoft.azure.services.serviceBus.implementation.MarshallerProvider; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceForJersey; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceImpl; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; @@ -16,8 +16,10 @@ public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { // provide contract implementation - registry.add(ServiceBusService.class, ServiceBusServiceImpl.class); - registry.add(ServiceBusServiceForJersey.class); + registry.add(ServiceBusContract.class, ServiceBusExceptionProcessor.class); + registry.add(ServiceBusService.class); + registry.add(ServiceBusExceptionProcessor.class); + registry.add(ServiceBusRestProxy.class); registry.add(MessagingClient.class); // alter jersey client config for serviceBus diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java index 25a58ad1c6feb..c08312370a431 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java @@ -9,6 +9,13 @@ public class ServiceBusConfiguration { public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; + public static Configuration configure( + String namespace, String authenticationName, + String authenticationPassword) { + return configure(null, Configuration.getInstance(), namespace, authenticationName, + authenticationPassword); + } + public static Configuration configure(Configuration configuration, String namespace, String authenticationName, String authenticationPassword) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java new file mode 100644 index 0000000000000..ed50f91c73e8f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java @@ -0,0 +1,44 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.Feed; + +import com.microsoft.azure.ServiceException; + + +public interface ServiceBusContract { + ServiceBusContract withFilter(ServiceFilter filter); + + void sendQueueMessage(String queueName, Message message) throws ServiceException; + Message receiveQueueMessage(String queueName) throws ServiceException; + Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + + void sendTopicMessage(String topicName, Message message) throws ServiceException; + Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; + Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; + + void unlockMessage(Message message) throws ServiceException; + void deleteMessage(Message message) throws ServiceException; + + Queue createQueue(Queue queue) throws ServiceException; + void deleteQueue(String queueName) throws ServiceException; + Queue getQueue(String queueName) throws ServiceException; + ListQueuesResult listQueues() throws ServiceException; + + Topic createTopic(Topic topic) throws ServiceException; + void deleteTopic(String topicName) throws ServiceException; + Topic getTopic(String topicName) throws ServiceException; + ListTopicsResult listTopics() throws ServiceException; + + void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; + void removeSubscription(String topicName, String subscriptionName) throws ServiceException; + Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; + Feed getSubscriptions(String topicName) throws ServiceException; + + void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; + void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + Feed getRules(String topicName, String subscriptionName) throws ServiceException; +} + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index 82ee96404c540..145aeeb3003d6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -1,44 +1,150 @@ package com.microsoft.azure.services.serviceBus; +import javax.inject.Inject; + +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.Feed; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; -import com.microsoft.azure.ServiceException; +public class ServiceBusService implements ServiceBusContract { + final ServiceBusContract next; + + public ServiceBusService() throws Exception { + this(null, Configuration.getInstance()); + } + public ServiceBusService(Configuration config) throws Exception { + this(null, config); + } -public interface ServiceBusService { - ServiceBusService withFilter(ServiceFilter filter); + public ServiceBusService(String profile) throws Exception { + this(profile, Configuration.getInstance()); + } + + public ServiceBusService(String profile, Configuration config) throws Exception { + next = config.create(profile, ServiceBusService.class); + } + + @Inject + public ServiceBusService(ServiceBusContract next) throws Exception { + this.next = next; + } - void sendQueueMessage(String queueName, Message message) throws ServiceException; - Message receiveQueueMessage(String queueName) throws ServiceException; - Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; - - void sendTopicMessage(String topicName, Message message) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; - - void unlockMessage(Message message) throws ServiceException; - void deleteMessage(Message message) throws ServiceException; - - Queue createQueue(Queue queue) throws ServiceException; - void deleteQueue(String queueName) throws ServiceException; - Queue getQueue(String queueName) throws ServiceException; - ListQueuesResult listQueues() throws ServiceException; - - Topic createTopic(Topic topic) throws ServiceException; - void deleteTopic(String topicName) throws ServiceException; - Topic getTopic(String topicName) throws ServiceException; - ListTopicsResult listTopics() throws ServiceException; - - void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; - void removeSubscription(String topicName, String subscriptionName) throws ServiceException; - Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; - Feed getSubscriptions(String topicName) throws ServiceException; - - void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; - void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Feed getRules(String topicName, String subscriptionName) throws ServiceException; -} + public ServiceBusContract withFilter(ServiceFilter filter) { + return next.withFilter(filter); + } + + public void sendQueueMessage(String queueName, Message message) + throws ServiceException { + next.sendQueueMessage(queueName, message); + } + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return next.receiveQueueMessage(queueName); + } + + public Message receiveQueueMessage(String queueName, + ReceiveMessageOptions options) throws ServiceException { + return next.receiveQueueMessage(queueName, options); + } + + public void sendTopicMessage(String topicName, Message message) + throws ServiceException { + next.sendTopicMessage(topicName, message); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + return next.receiveSubscriptionMessage(topicName, subscriptionName); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + return next.receiveSubscriptionMessage(topicName, subscriptionName, + options); + } + + public void unlockMessage(Message message) throws ServiceException { + next.unlockMessage(message); + } + + public void deleteMessage(Message message) throws ServiceException { + next.deleteMessage(message); + } + + public Queue createQueue(Queue queue) throws ServiceException { + return next.createQueue(queue); + } + public void deleteQueue(String queueName) throws ServiceException { + next.deleteQueue(queueName); + } + + public Queue getQueue(String queueName) throws ServiceException { + return next.getQueue(queueName); + } + + public ListQueuesResult listQueues() throws ServiceException { + return next.listQueues(); + } + + public Topic createTopic(Topic topic) throws ServiceException { + return next.createTopic(topic); + } + + public void deleteTopic(String topicName) throws ServiceException { + next.deleteTopic(topicName); + } + + public Topic getTopic(String topicName) throws ServiceException { + return next.getTopic(topicName); + } + + public ListTopicsResult listTopics() throws ServiceException { + return next.listTopics(); + } + + public void addSubscription(String topicName, String subscriptionName, + Entry subscription) throws ServiceException { + next.addSubscription(topicName, subscriptionName, subscription); + } + + public void removeSubscription(String topicName, String subscriptionName) + throws ServiceException { + next.removeSubscription(topicName, subscriptionName); + } + + public Entry getSubscription(String topicName, String subscriptionName) + throws ServiceException { + return next.getSubscription(topicName, subscriptionName); + } + + public Feed getSubscriptions(String topicName) throws ServiceException { + return next.getSubscriptions(topicName); + } + + public void addRule(String topicName, String subscriptionName, + String ruleName, Entry rule) throws ServiceException { + next.addRule(topicName, subscriptionName, ruleName, rule); + } + + public void removeRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + next.removeRule(topicName, subscriptionName, ruleName); + } + + public Entry getRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + return next.getRule(topicName, subscriptionName, ruleName); + } + + public Feed getRules(String topicName, String subscriptionName) + throws ServiceException { + return next.getRules(topicName, subscriptionName); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java deleted file mode 100644 index 1913cf17731b2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusServiceThatCanBeInstantiatedDirectly.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.Feed; - -public class ServiceBusServiceThatCanBeInstantiatedDirectly implements ServiceBusService { - final ServiceBusService service; - - public ServiceBusServiceThatCanBeInstantiatedDirectly() throws Exception { - this(Configuration.getInstance()); - } - - public ServiceBusServiceThatCanBeInstantiatedDirectly(Configuration config) throws Exception { - service = config.create(ServiceBusService.class); - } - - public ServiceBusService withFilter(ServiceFilter filter) { - return service.withFilter(filter); - } - - public void sendQueueMessage(String queueName, Message message) - throws ServiceException { - service.sendQueueMessage(queueName, message); - } - - public Message receiveQueueMessage(String queueName) - throws ServiceException { - return service.receiveQueueMessage(queueName); - } - - public Message receiveQueueMessage(String queueName, - ReceiveMessageOptions options) throws ServiceException { - return service.receiveQueueMessage(queueName, options); - } - - public void sendTopicMessage(String topicName, Message message) - throws ServiceException { - service.sendTopicMessage(topicName, message); - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { - return service.receiveSubscriptionMessage(topicName, subscriptionName); - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - return service.receiveSubscriptionMessage(topicName, subscriptionName, - options); - } - - public void unlockMessage(Message message) throws ServiceException { - service.unlockMessage(message); - } - - public void deleteMessage(Message message) throws ServiceException { - service.deleteMessage(message); - } - - public Queue createQueue(Queue queue) throws ServiceException { - return service.createQueue(queue); - } - - public void deleteQueue(String queueName) throws ServiceException { - service.deleteQueue(queueName); - } - - public Queue getQueue(String queueName) throws ServiceException { - return service.getQueue(queueName); - } - - public ListQueuesResult listQueues() throws ServiceException { - return service.listQueues(); - } - - public Topic createTopic(Topic topic) throws ServiceException { - return service.createTopic(topic); - } - - public void deleteTopic(String topicName) throws ServiceException { - service.deleteTopic(topicName); - } - - public Topic getTopic(String topicName) throws ServiceException { - return service.getTopic(topicName); - } - - public ListTopicsResult listTopics() throws ServiceException { - return service.listTopics(); - } - - public void addSubscription(String topicName, String subscriptionName, - Entry subscription) throws ServiceException { - service.addSubscription(topicName, subscriptionName, subscription); - } - - public void removeSubscription(String topicName, String subscriptionName) - throws ServiceException { - service.removeSubscription(topicName, subscriptionName); - } - - public Entry getSubscription(String topicName, String subscriptionName) - throws ServiceException { - return service.getSubscription(topicName, subscriptionName); - } - - public Feed getSubscriptions(String topicName) throws ServiceException { - return service.getSubscriptions(topicName); - } - - public void addRule(String topicName, String subscriptionName, - String ruleName, Entry rule) throws ServiceException { - service.addRule(topicName, subscriptionName, ruleName, rule); - } - - public void removeRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { - service.removeRule(topicName, subscriptionName, ruleName); - } - - public Entry getRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { - return service.getRule(topicName, subscriptionName, ruleName); - } - - public Feed getRules(String topicName, String subscriptionName) - throws ServiceException { - return service.getRules(topicName, subscriptionName); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java new file mode 100644 index 0000000000000..faafbbf5ee33e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java @@ -0,0 +1,15 @@ +package com.microsoft.azure.services.serviceBus; + +import com.microsoft.azure.services.serviceBus.implementation.Entry; +import com.microsoft.azure.services.serviceBus.implementation.EntryModel; +import com.microsoft.azure.services.serviceBus.implementation.QueueDescription; +import com.microsoft.azure.services.serviceBus.implementation.SubscriptionDescription; + +public class Subscription extends EntryModel { + + public Subscription(Entry entry, SubscriptionDescription model) { + super(entry, model); + // TODO Auto-generated constructor stub + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java index 0a4c324d75d0e..06383c34d9216 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java @@ -3,13 +3,13 @@ import com.microsoft.azure.ServiceException; public class Util { - public static Iterable iterateQueues(ServiceBusService service) + public static Iterable iterateQueues(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listQueues().getItems(); } - public static Iterable iterateTopics(ServiceBusService service) + public static Iterable iterateTopics(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listTopics().getItems(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java index e98a73335e7de..dee490dff226b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -7,38 +7,38 @@ import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; public class MessagingClient { - private ServiceBusService service; + private ServiceBusContract service; public MessagingClient() throws Exception { - this.setService(Configuration.load().create(ServiceBusService.class)); + this.setService(Configuration.load().create(ServiceBusContract.class)); } public MessagingClient(String profile) throws Exception { - this.setService(Configuration.load().create(profile, ServiceBusService.class)); + this.setService(Configuration.load().create(profile, ServiceBusContract.class)); } public MessagingClient(Configuration configuration) throws Exception { - this.setService(configuration.create(ServiceBusService.class)); + this.setService(configuration.create(ServiceBusContract.class)); } public MessagingClient(String profile, Configuration configuration) throws Exception { - this.setService(configuration.create(profile, ServiceBusService.class)); + this.setService(configuration.create(profile, ServiceBusContract.class)); } @Inject - public MessagingClient(ServiceBusService service) { + public MessagingClient(ServiceBusContract service) { this.setService(service); } - public void setService(ServiceBusService service) { + public void setService(ServiceBusContract service) { this.service = service; } - public ServiceBusService getService() { + public ServiceBusContract getService() { return service; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java similarity index 82% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 2180e605775f5..0821cab80d977 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -12,29 +12,29 @@ import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; import com.microsoft.azure.services.serviceBus.Topic; import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; -public class ServiceBusServiceImpl implements ServiceBusService { +public class ServiceBusExceptionProcessor implements ServiceBusContract { - private ServiceBusService service; - static Log log = LogFactory.getLog(ServiceBusService.class); + private ServiceBusContract next; + static Log log = LogFactory.getLog(ServiceBusContract.class); - @Inject - public ServiceBusServiceImpl(ServiceBusServiceForJersey service) - { - this.service = service; + public ServiceBusExceptionProcessor(ServiceBusContract next) { + this.next = next; } - public ServiceBusServiceImpl(ServiceBusService service) { - this.service = service; + @Inject + public ServiceBusExceptionProcessor(ServiceBusRestProxy next) + { + this.next = next; } - public ServiceBusService withFilter(ServiceFilter filter) { - return new ServiceBusServiceImpl(service.withFilter(filter)); + public ServiceBusContract withFilter(ServiceFilter filter) { + return new ServiceBusExceptionProcessor(next.withFilter(filter)); } @@ -47,7 +47,7 @@ private ServiceException processCatch(ServiceException e) { public void sendQueueMessage(String path, Message message) throws ServiceException { try { - service.sendQueueMessage(path, message); + next.sendQueueMessage(path, message); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -59,7 +59,7 @@ public void sendQueueMessage(String path, Message message) public Message receiveQueueMessage(String queueName) throws ServiceException { try { - return service.receiveQueueMessage(queueName); + return next.receiveQueueMessage(queueName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -71,7 +71,7 @@ public Message receiveQueueMessage(String queueName) public Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException { try { - return service.receiveQueueMessage(queueName, options); + return next.receiveQueueMessage(queueName, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -83,7 +83,7 @@ public Message receiveQueueMessage(String queueName, public void sendTopicMessage(String path, Message message) throws ServiceException { try { - service.sendTopicMessage(path, message); + next.sendTopicMessage(path, message); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -94,7 +94,7 @@ public void sendTopicMessage(String path, Message message) public Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { try { - return service.receiveSubscriptionMessage(topicName, + return next.receiveSubscriptionMessage(topicName, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -108,7 +108,7 @@ public Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { try { - return service.receiveSubscriptionMessage(topicName, + return next.receiveSubscriptionMessage(topicName, subscriptionName, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -120,7 +120,7 @@ public Message receiveSubscriptionMessage(String topicName, public void unlockMessage(Message message) throws ServiceException { try { - service.unlockMessage(message); + next.unlockMessage(message); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -131,7 +131,7 @@ public void unlockMessage(Message message) throws ServiceException { public void deleteMessage(Message message) throws ServiceException { try { - service.deleteMessage(message); + next.deleteMessage(message); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -142,7 +142,7 @@ public void deleteMessage(Message message) throws ServiceException { public Queue createQueue(Queue queue) throws ServiceException { try { - return service.createQueue(queue); + return next.createQueue(queue); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -153,7 +153,7 @@ public Queue createQueue(Queue queue) throws ServiceException { public void deleteQueue(String queuePath) throws ServiceException { try { - service.deleteQueue(queuePath); + next.deleteQueue(queuePath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -164,7 +164,7 @@ public void deleteQueue(String queuePath) throws ServiceException { public Queue getQueue(String queuePath) throws ServiceException { try { - return service.getQueue(queuePath); + return next.getQueue(queuePath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -175,7 +175,7 @@ public Queue getQueue(String queuePath) throws ServiceException { public ListQueuesResult listQueues() throws ServiceException { try { - return service.listQueues(); + return next.listQueues(); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -186,7 +186,7 @@ public ListQueuesResult listQueues() throws ServiceException { public Topic createTopic(Topic topic) throws ServiceException { try { - return service.createTopic(topic); + return next.createTopic(topic); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -197,7 +197,7 @@ public Topic createTopic(Topic topic) throws ServiceException { public void deleteTopic(String topicPath) throws ServiceException { try { - service.deleteTopic(topicPath); + next.deleteTopic(topicPath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -208,7 +208,7 @@ public void deleteTopic(String topicPath) throws ServiceException { public Topic getTopic(String topicPath) throws ServiceException { try { - return service.getTopic(topicPath); + return next.getTopic(topicPath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -219,7 +219,7 @@ public Topic getTopic(String topicPath) throws ServiceException { public ListTopicsResult listTopics() throws ServiceException { try { - return service.listTopics(); + return next.listTopics(); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -231,7 +231,7 @@ public ListTopicsResult listTopics() throws ServiceException { public void addSubscription(String topicPath, String subscriptionName, Entry subscription) throws ServiceException { try { - service.addSubscription(topicPath, subscriptionName, subscription); + next.addSubscription(topicPath, subscriptionName, subscription); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -243,7 +243,7 @@ public void addSubscription(String topicPath, String subscriptionName, public void removeSubscription(String topicPath, String subscriptionName) throws ServiceException { try { - service.removeSubscription(topicPath, subscriptionName); + next.removeSubscription(topicPath, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -255,7 +255,7 @@ public void removeSubscription(String topicPath, String subscriptionName) public Entry getSubscription(String topicPath, String subscriptionName) throws ServiceException { try { - return service.getSubscription(topicPath, subscriptionName); + return next.getSubscription(topicPath, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -266,7 +266,7 @@ public Entry getSubscription(String topicPath, String subscriptionName) public Feed getSubscriptions(String topicPath) throws ServiceException { try { - return service.getSubscriptions(topicPath); + return next.getSubscriptions(topicPath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -278,7 +278,7 @@ public Feed getSubscriptions(String topicPath) throws ServiceException { public void addRule(String topicPath, String subscriptionName, String ruleName, Entry rule) throws ServiceException { try { - service.addRule(topicPath, subscriptionName, ruleName, rule); + next.addRule(topicPath, subscriptionName, ruleName, rule); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -290,7 +290,7 @@ public void addRule(String topicPath, String subscriptionName, public void removeRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { - service.removeRule(topicPath, subscriptionName, ruleName); + next.removeRule(topicPath, subscriptionName, ruleName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -302,7 +302,7 @@ public void removeRule(String topicPath, String subscriptionName, public Entry getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { - return service.getRule(topicPath, subscriptionName, ruleName); + return next.getRule(topicPath, subscriptionName, ruleName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { @@ -314,7 +314,7 @@ public Entry getRule(String topicPath, String subscriptionName, public Feed getRules(String topicPath, String subscriptionName) throws ServiceException { try { - return service.getRules(topicPath, subscriptionName); + return next.getRules(topicPath, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } catch (ClientHandlerException e) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java index efe91ac85e6d7..0cdc2f8f4d3f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,7 +1,5 @@ package com.microsoft.azure.services.serviceBus.implementation; -import java.io.InputStream; -import java.rmi.UnexpectedException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -18,8 +16,7 @@ import com.microsoft.azure.services.serviceBus.Queue; import com.microsoft.azure.services.serviceBus.ListQueuesResult; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; import com.microsoft.azure.services.serviceBus.Topic; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.Feed; @@ -28,25 +25,22 @@ import com.microsoft.azure.auth.wrap.WrapFilter; import com.microsoft.azure.http.ClientFilterAdapter; import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; 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 ServiceBusServiceForJersey implements ServiceBusService { +public class ServiceBusRestProxy implements ServiceBusContract { private Client channel; private String uri; private BrokerPropertiesMapper mapper; - static Log log = LogFactory.getLog(ServiceBusService.class); + static Log log = LogFactory.getLog(ServiceBusContract.class); ServiceFilter[] filters; @Inject - public ServiceBusServiceForJersey( + public ServiceBusRestProxy( Client channel, @Named("serviceBus") WrapFilter authFilter, @Named("serviceBus.uri") String uri, @@ -59,7 +53,7 @@ public ServiceBusServiceForJersey( channel.addFilter(authFilter); } - public ServiceBusServiceForJersey( + public ServiceBusRestProxy( Client channel, ServiceFilter[] filters, String uri, @@ -70,10 +64,10 @@ public ServiceBusServiceForJersey( this.mapper = mapper; } - public ServiceBusService withFilter(ServiceFilter filter) { + public ServiceBusContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new ServiceBusServiceForJersey(channel, newFilters, uri, mapper); + return new ServiceBusRestProxy(channel, newFilters, uri, mapper); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java deleted file mode 100644 index a518d5536874e..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ContractBuilderTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - - -import static org.junit.Assert.*; -import org.junit.Test; - -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusService; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusServiceForJersey; - -public class ContractBuilderTest { - @Test - public void testDefaultBuilderCreatesServiceImpl() throws Exception { - Configuration config = new Configuration(); - ServiceBusService service = config.create(ServiceBusService.class); - - assertNotNull(service); - assertEquals(ServiceBusServiceForJersey.class, service.getClass()); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 406acaf85ac7c..6ad146f8a64c5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -6,7 +6,7 @@ import org.junit.BeforeClass; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; import com.microsoft.azure.services.serviceBus.Queue; import static com.microsoft.azure.services.serviceBus.Util.*; @@ -38,7 +38,7 @@ public void initialize() throws Exception { System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; - ServiceBusService service = createConfiguration().create(ServiceBusService.class); + ServiceBusContract service = createConfiguration().create(ServiceBusContract.class); for(Queue queue : iterateQueues(service)) { String queueName = queue.getName(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java new file mode 100644 index 0000000000000..a48c9e1c998d2 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java @@ -0,0 +1,54 @@ +package com.microsoft.azure.services.serviceBus; + + +import static org.junit.Assert.*; +import org.junit.Test; + +import com.microsoft.azure.configuration.Configuration; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; + +public class ServiceBusCreationTest { + @Test + public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { + ServiceBusConfiguration.configure("my-namespace", "my-identity", "my-shared-secret"); + ServiceBusService service = new ServiceBusService(); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + public Configuration newConfiguration() { + Configuration config = new Configuration(); + ServiceBusConfiguration.configure(config, "my-namespace", "my-identity", "my-shared-secret"); + return config; + } + + @Test + public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = new ServiceBusService(config); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + @Test + public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = config.create(ServiceBusService.class); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + @Test + public void testDefaultBuilderCreatesServiceImpl() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = config.create(ServiceBusContract.class); + + assertNotNull(service); + } + + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 2bc3cd2be60a5..350256bff6839 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -17,13 +17,13 @@ import com.microsoft.azure.http.ServiceFilter.Response; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.ServiceBusService; +import com.microsoft.azure.services.serviceBus.ServiceBusContract; import static org.junit.Assert.*; public class ServiceBusIntegrationTest extends IntegrationTestBase { private Configuration config; - private ServiceBusService service; + private ServiceBusContract service; static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); @@ -31,7 +31,7 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { @Before public void createService() throws Exception { config = createConfiguration(); - service = config.create(ServiceBusService.class); + service = config.create(ServiceBusContract.class); } @Test @@ -233,7 +233,7 @@ public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { final List requests = new ArrayList(); final List responses = new ArrayList(); - ServiceBusService filtered = service.withFilter(new ServiceFilter() { + ServiceBusContract filtered = service.withFilter(new ServiceFilter() { public Response handle(Request request, Next next) { requests.add(request); Response response = next.handle(request); From 6c10b861b0b713828939b75be4028650a8513c3e Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 10 Nov 2011 11:58:43 -0800 Subject: [PATCH 132/664] Configuring findbugs --- microsoft-azure-api/pom.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b5ee7f0df3563..c63d4a1fa1d38 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -78,6 +78,18 @@ + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + true + true + true + + + From ce96780df25e400dacfe72d6724a47046748cfed Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 10 Nov 2011 12:15:59 -0800 Subject: [PATCH 133/664] Fix typo --- .../java/com/microsoft/azure/services/blob/ContainerACL.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index 9964b8ec58d49..10b19926b4743 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -49,7 +49,7 @@ public void setSignedIdentifiers(List signedIdentifiers) { this.signedIdentifiers = signedIdentifiers; } - public void AddSignedIdentifier(String id, Date start, Date expiry, String permission) { + public void addSignedIdentifier(String id, Date start, Date expiry, String permission) { AccessPolicy accessPolicy = new AccessPolicy(); accessPolicy.setStart(start); accessPolicy.setExpiry(expiry); From 714181a3ff66281790de3a489af2aa6a6bb65275 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 10 Nov 2011 12:16:54 -0800 Subject: [PATCH 134/664] Applying changes from code review --- .../services/blob/BlobConfiguration.java | 1 - .../azure/services/blob/BlobService.java | 32 ++-- .../blob/{Blob.java => GetBlobResult.java} | 5 +- .../implementation/BlobServiceForJersey.java | 153 +++++++++++------- .../blob/implementation/BlobServiceImpl.java | 127 ++++++++++++++- .../blob/BlobServiceIntegrationTest.java | 8 +- .../services/blob/IntegrationTestBase.java | 1 - 7 files changed, 248 insertions(+), 79 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/{Blob.java => GetBlobResult.java} (87%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java index e6990d4629fda..dbb3c41a130c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java @@ -12,5 +12,4 @@ public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; public final static String ACCOUNT_KEY = "blob.accountKey"; public final static String URL = "blob.url"; - public final static String TIMEOUT = "blob.timeout"; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java index 05bc5ac6b3f02..e44e80b550156 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java @@ -11,30 +11,40 @@ public interface BlobService { ServiceProperties getServiceProperties() throws ServiceException; + ServiceProperties getServiceProperties(BlobOptions options) throws ServiceException; + void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; + void setServiceProperties(ServiceProperties serviceProperties, BlobOptions options) throws ServiceException; + ListContainersResult listContainers() throws ServiceException; ListContainersResult listContainers(ListContainersOptions options) throws ServiceException; - //TODO: Should we use "create" or "put"? void createContainer(String container) throws ServiceException; void createContainer(String container, CreateContainerOptions options) throws ServiceException; - // TODO: Should this have a "DeleteContainerResult" class void deleteContainer(String container) throws ServiceException; void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException; ContainerProperties getContainerProperties(String container) throws ServiceException; + ContainerProperties getContainerProperties(String container, BlobOptions options) throws ServiceException; + ContainerProperties getContainerMetadata(String container) throws ServiceException; + ContainerProperties getContainerMetadata(String container, BlobOptions options) throws ServiceException; + ContainerACL getContainerACL(String container) throws ServiceException; + ContainerACL getContainerACL(String container, BlobOptions options) throws ServiceException; + void setContainerACL(String container, ContainerACL acl) throws ServiceException; + void setContainerACL(String container, ContainerACL acl, BlobOptions options) throws ServiceException; + void setContainerMetadata(String container, HashMap metadata) throws ServiceException; void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException; @@ -43,7 +53,6 @@ public interface BlobService { ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException; - //TODO: Should we use "create" or "put"? void createPageBlob(String container, String blob, int length) throws ServiceException; void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException; @@ -52,24 +61,22 @@ public interface BlobService { void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; - //TODO: Should we use "createPageBlobPages"? + // 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"? + // TODO: Should we use "updatePageBlobPages"? CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream) throws ServiceException; CreateBlobPagesResult createBlobPages(String container, String blob, long rangeStart, long rangeEnd, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException; - //TODO: createBlockBlobBlock? void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException; void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException; - //TODO: commitBlockBlobBlocks? void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException; void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; @@ -90,6 +97,8 @@ CreateBlobPagesResult createBlobPages(String container, String blob, long rangeS ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException; + SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException; + SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException; SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException; @@ -97,9 +106,9 @@ CreateBlobPagesResult createBlobPages(String container, String blob, long rangeS SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) throws ServiceException; - Blob getBlob(String container, String blob) throws ServiceException; + GetBlobResult getBlob(String container, String blob) throws ServiceException; - Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException; + GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException; void deleteBlob(String container, String blob) throws ServiceException; @@ -120,8 +129,13 @@ void copyBlob(String destinationContainer, String destinationBlob, String source String renewLease(String container, String blob, String leaseId) throws ServiceException; + String renewLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException; + void releaseLease(String container, String blob, String leaseId) throws ServiceException; + void releaseLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException; + void breakLease(String container, String blob, String leaseId) throws ServiceException; + void breakLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java rename to microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java index b8f058d382f58..a7fecabaf48d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Blob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java @@ -2,10 +2,7 @@ import java.io.InputStream; -/* - * TODO: Should this be called "GetBlobResult"? - */ -public class Blob { +public class GetBlobResult { private InputStream contentStream; private BlobProperties properties; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index 63dc9d46e8bd0..263513a96ecda 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -17,9 +17,10 @@ import com.microsoft.azure.services.blob.AccessCondition; import com.microsoft.azure.services.blob.AccessConditionHeaderType; import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.Blob; +import com.microsoft.azure.services.blob.GetBlobResult; import com.microsoft.azure.services.blob.BlobConfiguration; import com.microsoft.azure.services.blob.BlobListingDetails; +import com.microsoft.azure.services.blob.BlobOptions; import com.microsoft.azure.services.blob.BlobProperties; import com.microsoft.azure.services.blob.BlobService; import com.microsoft.azure.services.blob.BlobSnapshot; @@ -70,7 +71,6 @@ public class BlobServiceForJersey implements BlobService { private final Client channel; private final String accountName; private final String url; - private final Integer timeout; private final RFC1123DateConverter dateMapper; private final ServiceFilter[] filters; private final SharedKeyLiteFilter filter; @@ -84,33 +84,31 @@ public BlobServiceForJersey( Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - @Named(BlobConfiguration.TIMEOUT) String timeout, SharedKeyLiteFilter filter) { this.channel = channel; this.accountName = accountName; this.url = url; this.filter = filter; - this.timeout = (timeout == null ? null : Integer.parseInt(timeout)); this.dateMapper = new RFC1123DateConverter(); this.filters = new ServiceFilter[0]; channel.addFilter(filter); } - public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, Integer timeout, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + public BlobServiceForJersey(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; - this.timeout = timeout; } public BlobService 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.timeout, this.filter, this.dateMapper); + return new BlobServiceForJersey(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); } private void ThrowIfError(ClientResponse r) { @@ -190,16 +188,16 @@ private Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCo 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 = ""; + 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()); } @@ -268,9 +266,9 @@ private HashMap getMetadataFromHeaders(ClientResponse response) return metadata; } - private WebResource getResource() { + private WebResource getResource(BlobOptions options) { WebResource webResource = channel.resource(url).path("/"); - webResource = addOptionalQueryParam(webResource, "timeout", this.timeout); + webResource = addOptionalQueryParam(webResource, "timeout", options.getTimeout()); for (ServiceFilter filter : filters) { webResource.addFilter(new ClientFilterAdapter(filter)); } @@ -316,7 +314,11 @@ private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, } public ServiceProperties getServiceProperties() throws ServiceException { - WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + return getServiceProperties(new BlobOptions()); + } + + public ServiceProperties getServiceProperties(BlobOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -325,7 +327,11 @@ public ServiceProperties getServiceProperties() throws ServiceException { } public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - WebResource webResource = getResource().path("/").queryParam("resType", "service").queryParam("comp", "properties"); + setServiceProperties(serviceProperties, new BlobOptions()); + } + + public void setServiceProperties(ServiceProperties serviceProperties, BlobOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, null, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -339,7 +345,7 @@ public void createContainer(String container) throws ServiceException { } public void createContainer(String container, CreateContainerOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); + WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -355,7 +361,7 @@ public void deleteContainer(String container) throws ServiceException { } public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); + WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -365,15 +371,23 @@ public void deleteContainer(String container, DeleteContainerOptions options) th } public ContainerProperties getContainerProperties(String container) throws ServiceException { - return getContainerPropertiesImpl(container, null); + return getContainerProperties(container, new BlobOptions()); + } + + public ContainerProperties getContainerProperties(String container, BlobOptions options) throws ServiceException { + return getContainerPropertiesImpl(container, options, null); } public ContainerProperties getContainerMetadata(String container) throws ServiceException { - return getContainerPropertiesImpl(container, "metadata"); + return getContainerMetadata(container, new BlobOptions()); } - private ContainerProperties getContainerPropertiesImpl(String container, String operation) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container"); + public ContainerProperties getContainerMetadata(String container, BlobOptions options) throws ServiceException { + return getContainerPropertiesImpl(container, options, "metadata"); + } + + private ContainerProperties getContainerPropertiesImpl(String container, BlobOptions options, String operation) throws ServiceException { + WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); webResource = addOptionalQueryParam(webResource, "comp", operation); webResource = setCanonicalizedResource(webResource, container, operation); @@ -391,7 +405,11 @@ private ContainerProperties getContainerPropertiesImpl(String container, String } public ContainerACL getContainerACL(String container) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + return getContainerACL(container, new BlobOptions()); + } + + public ContainerACL getContainerACL(String container, BlobOptions options) throws ServiceException { + WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); webResource = setCanonicalizedResource(webResource, container, "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -409,7 +427,11 @@ public ContainerACL getContainerACL(String container) throws ServiceException { } public void setContainerACL(String container, ContainerACL acl) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "acl"); + setContainerACL(container, acl, new BlobOptions()); + } + + public void setContainerACL(String container, ContainerACL acl, BlobOptions options) throws ServiceException { + WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); webResource = setCanonicalizedResource(webResource, container, "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -426,7 +448,7 @@ public void setContainerMetadata(String container, HashMap metad } public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("resType", "container").queryParam("comp", "metadata"); + WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -442,7 +464,7 @@ public ListContainersResult listContainers() throws ServiceException { } public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { - WebResource webResource = getResource().path("/").queryParam("comp", "list"); + WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); webResource = setCanonicalizedResource(webResource, null, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); @@ -461,7 +483,7 @@ public ListBlobsResult listBlobs(String container) throws ServiceException { } public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).queryParam("comp", "list").queryParam("resType", "container"); + WebResource webResource = getResource(options).path(container).queryParam("comp", "list").queryParam("resType", "container"); webResource = setCanonicalizedResource(webResource, container, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); @@ -487,7 +509,7 @@ public void createPageBlob(String container, String blob, int length) throws Ser } public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { - WebResource webResource = getResource().path(container + "/" + blob); + WebResource webResource = getResource(options).path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -506,7 +528,7 @@ public void createBlockBlob(String container, String blob, InputStream contentSt } public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { - WebResource webResource = getResource().path(container + "/" + blob); + WebResource webResource = getResource(options).path(container + "/" + blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -523,7 +545,7 @@ public BlobProperties getBlobProperties(String container, String blob) throws Se } public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob); + WebResource webResource = getResource(options).path(container).path(blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); @@ -542,7 +564,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro } public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); @@ -561,8 +583,12 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetB return properties; } + public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { + return setBlobProperties(container, blob, new SetBlobPropertiesOptions()); + } + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "properties"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "properties"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -598,7 +624,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "metadata"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -616,12 +642,12 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash return result; } - public Blob getBlob(String container, String blob) throws ServiceException { + public GetBlobResult getBlob(String container, String blob) throws ServiceException { return getBlob(container, blob, new GetBlobOptions()); } - public Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob); + public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + WebResource webResource = getResource(options).path(container).path(blob); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); @@ -634,7 +660,7 @@ public Blob getBlob(String container, String blob, GetBlobOptions options) throw ThrowIfError(response); BlobProperties properties = getBlobPropertiesFromResponse(response); - Blob blobResult = new Blob(); + GetBlobResult blobResult = new GetBlobResult(); blobResult.setProperties(properties); blobResult.setContentStream(response.getEntityInputStream()); return blobResult; @@ -645,7 +671,7 @@ public void deleteBlob(String container, String blob) throws ServiceException { } public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { - WebResource webResource = getResource().path(container + "/" + blob); + WebResource webResource = getResource(options).path(container + "/" + blob); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); @@ -662,7 +688,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob) throws Ser } public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { - WebResource webResource = getResource().path(container + "/" + blob).queryParam("comp", "snapshot"); + WebResource webResource = getResource(options).path(container + "/" + blob).queryParam("comp", "snapshot"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -687,7 +713,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { - WebResource webResource = getResource().path(destinationContainer).path(destinationBlob); + WebResource webResource = getResource(options).path(destinationContainer).path(destinationBlob); webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -707,29 +733,42 @@ public String acquireLease(String container, String blob) throws ServiceExceptio } public String acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { - return putLeaseImpl("acquire", container, blob, null, options); + return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); } public String renewLease(String container, String blob, String leaseId) throws ServiceException { - return putLeaseImpl("renew", container, blob, leaseId, new AcquireLeaseOptions()); + return renewLease(container, blob, leaseId, new BlobOptions()); + } + + public String renewLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); } public void releaseLease(String container, String blob, String leaseId) throws ServiceException { - putLeaseImpl("release", container, blob, leaseId, new AcquireLeaseOptions()); + releaseLease(container, blob, leaseId, new BlobOptions()); + } + + public void releaseLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); } public void breakLease(String container, String blob, String leaseId) throws ServiceException { - putLeaseImpl("break", container, blob, leaseId, new AcquireLeaseOptions()); + breakLease(container, blob, leaseId, new BlobOptions()); + } + + public void breakLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); } - private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, AcquireLeaseOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "lease"); + private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, BlobOptions options, AccessCondition accessCondition) + throws ServiceException { + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "lease"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); + builder = addOptionalAccessContitionHeader(builder, accessCondition); // Note: Add content type here to enable proper HMAC signing ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); @@ -759,7 +798,7 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, long private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "page"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "page"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -789,7 +828,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro } public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "pagelist"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "pagelist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -814,7 +853,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "block"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "block"); webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); @@ -831,7 +870,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) } public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -853,7 +892,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws } public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { - WebResource webResource = getResource().path(container).path(blob).queryParam("comp", "blocklist"); + WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java index 74fcc54ba628d..a0dd788913748 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java @@ -11,7 +11,8 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.Blob; +import com.microsoft.azure.services.blob.GetBlobResult; +import com.microsoft.azure.services.blob.BlobOptions; import com.microsoft.azure.services.blob.BlobProperties; import com.microsoft.azure.services.blob.BlobService; import com.microsoft.azure.services.blob.BlobSnapshot; @@ -84,6 +85,30 @@ public ServiceProperties getServiceProperties() throws ServiceException { } } + public ServiceProperties getServiceProperties(BlobOptions 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(ServiceProperties serviceProperties, BlobOptions 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 setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { try { service.setServiceProperties(serviceProperties); @@ -180,6 +205,18 @@ public ContainerProperties getContainerProperties(String container) throws Servi } } + public ContainerProperties getContainerProperties(String container, BlobOptions options) throws ServiceException { + try { + return service.getContainerProperties(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public ContainerProperties getContainerMetadata(String container) throws ServiceException { try { return service.getContainerMetadata(container); @@ -192,6 +229,18 @@ public ContainerProperties getContainerMetadata(String container) throws Service } } + public ContainerProperties getContainerMetadata(String container, BlobOptions options) throws ServiceException { + try { + return service.getContainerMetadata(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public ContainerACL getContainerACL(String container) throws ServiceException { try { return service.getContainerACL(container); @@ -204,6 +253,18 @@ public ContainerACL getContainerACL(String container) throws ServiceException { } } + public ContainerACL getContainerACL(String container, BlobOptions options) throws ServiceException { + try { + return service.getContainerACL(container, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public void setContainerACL(String container, ContainerACL acl) throws ServiceException { try { service.setContainerACL(container, acl); @@ -216,6 +277,18 @@ public void setContainerACL(String container, ContainerACL acl) throws ServiceEx } } + public void setContainerACL(String container, ContainerACL acl, BlobOptions options) throws ServiceException { + try { + service.setContainerACL(container, acl, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { try { service.setContainerMetadata(container, metadata); @@ -520,6 +593,18 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, } } + public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { + try { + return service.setBlobProperties(container, blob); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { try { return service.setBlobMetadata(container, blob, metadata); @@ -545,7 +630,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash } } - public Blob getBlob(String container, String blob) throws ServiceException { + public GetBlobResult getBlob(String container, String blob) throws ServiceException { try { return service.getBlob(container, blob); } @@ -557,7 +642,7 @@ public Blob getBlob(String container, String blob) throws ServiceException { } } - public Blob getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { try { return service.getBlob(container, blob, options); } @@ -678,6 +763,18 @@ public String renewLease(String container, String blob, String leaseId) throws S } } + public String renewLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + try { + return service.renewLease(container, blob, leaseId, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public void releaseLease(String container, String blob, String leaseId) throws ServiceException { try { service.releaseLease(container, blob, leaseId); @@ -690,6 +787,18 @@ public void releaseLease(String container, String blob, String leaseId) throws S } } + public void releaseLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + try { + service.releaseLease(container, blob, leaseId, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + public void breakLease(String container, String blob, String leaseId) throws ServiceException { try { service.breakLease(container, blob, leaseId); @@ -701,4 +810,16 @@ public void breakLease(String container, String blob, String leaseId) throws Ser throw processCatch(new ServiceException(e)); } } + + public void breakLease(String container, String blob, String leaseId, BlobOptions options) throws ServiceException { + try { + service.breakLease(container, blob, leaseId, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index e25b839e46c84..6a28ce65f2be9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -181,7 +181,7 @@ public void setContainerACLWorks() throws Exception { ContainerACL acl = new ContainerACL(); acl.setPublicAccess("blob"); - acl.AddSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); + acl.addSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); service.setContainerACL(container, acl); ContainerACL acl2 = service.getContainerACL(container); @@ -627,7 +627,7 @@ public void getBlockBlobWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - Blob blob = service.getBlob("mycontainer1", "test2"); + GetBlobResult blob = service.getBlob("mycontainer1", "test2"); BlobProperties props = blob.getProperties(); // Assert @@ -660,7 +660,7 @@ public void getPageBlobWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - Blob blob = service.getBlob("mycontainer1", "test"); + GetBlobResult blob = service.getBlob("mycontainer1", "test"); BlobProperties props = blob.getProperties(); // Assert @@ -923,7 +923,7 @@ public void copyBlobWorks() throws Exception { service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); service.copyBlob("mycontainer1", "test5", "mycontainer2", "test6"); - Blob blob = service.getBlob("mycontainer1", "test5"); + GetBlobResult blob = service.getBlob("mycontainer1", "test5"); BlobProperties props = blob.getProperties(); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index 59f863b77fbcf..4991e86f361d4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -11,7 +11,6 @@ protected Configuration createConfiguration() { config.setProperty(BlobConfiguration.ACCOUNT_NAME, "xxx"); config.setProperty(BlobConfiguration.ACCOUNT_KEY, "xxx"); config.setProperty(BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); - config.setProperty(BlobConfiguration.TIMEOUT, "20"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); From f2e3ae3e82b622500a6c85ba7aa284babb7ba22a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 10 Nov 2011 13:37:15 -0800 Subject: [PATCH 135/664] Support configuring integration tests with env. variables --- .../services/blob/IntegrationTestBase.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index 4991e86f361d4..6423228b382d7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -1,5 +1,7 @@ package com.microsoft.azure.services.blob; +import java.util.Map; + import org.junit.Before; import org.junit.BeforeClass; @@ -8,9 +10,10 @@ public abstract class IntegrationTestBase { protected Configuration createConfiguration() { Configuration config = new Configuration(); - config.setProperty(BlobConfiguration.ACCOUNT_NAME, "xxx"); - config.setProperty(BlobConfiguration.ACCOUNT_KEY, "xxx"); - config.setProperty(BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); + Map env = System.getenv(); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); + setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); @@ -20,6 +23,14 @@ protected Configuration createConfiguration() { return config; } + private 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"); From 72797f29c2425b9da18f671da8e4152e24028f01 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 10 Nov 2011 15:07:06 -0800 Subject: [PATCH 136/664] Add Eclipse settings for code style and formatting --- .gitignore | 1 - .../.settings/org.eclipse.jdt.core.prefs | 288 ++++++++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 114 +++++++ .../.settings/org.eclipse.m2e.core.prefs | 5 + 4 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs create mode 100644 microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs create mode 100644 microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs diff --git a/.gitignore b/.gitignore index 8c1a51c48c71a..11a721777fdd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .classpath .project -.settings target node_modules diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000..162f1b9000c93 --- /dev/null +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,288 @@ +#Wed Nov 09 14:11:15 PST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +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.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 +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=160 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000000..46133d527bb33 --- /dev/null +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,114 @@ +#Thu Nov 10 13:35:31 PST 2011 +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=false +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=false +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=false +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=false +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile +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=12 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.overrideannotation=true +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=false +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs b/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000..55679f3b05ac3 --- /dev/null +++ b/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Tue Oct 18 09:29:27 PDT 2011 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 From b58404a1ff3b2bbc43d0d8785e82913d51a9ebc9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 10 Nov 2011 15:08:01 -0800 Subject: [PATCH 137/664] Updating integration test to work on any blob account --- .../blob/BlobServiceIntegrationTest.java | 240 ++++++++++++------ .../services/blob/IntegrationTestBase.java | 4 +- 2 files changed, 162 insertions(+), 82 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 6a28ce65f2be9..12be28fbd8e42 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -21,6 +21,8 @@ import junit.framework.Assert; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.azure.ServiceException; @@ -29,6 +31,81 @@ import com.microsoft.azure.http.ServiceFilter; public class BlobServiceIntegrationTest extends IntegrationTestBase { + private static final String testContainersPrefix = "sdktest-"; + private static final String createableContainersPrefix = "csdktest-"; + private static String CREATEABLE_CONTAINER_1; + private static String CREATEABLE_CONTAINER_2; + private static String CREATEABLE_CONTAINER_3; + private static String CREATEABLE_CONTAINER_4; + private static String TEST_CONTAINER_FOR_BLOBS; + private static String TEST_CONTAINER_FOR_BLOBS_2; + private static String TEST_CONTAINER_FOR_LISTING; + private static String[] creatableContainers; + private static String[] testContainers; + + @BeforeClass + public static void setup() throws Exception { + // Setup container names array (list of container names used by + // integration tests) + testContainers = new String[10]; + for (int i = 0; i < testContainers.length; i++) { + testContainers[i] = String.format("%s%d", testContainersPrefix, i + 1); + } + + creatableContainers = new String[10]; + for (int i = 0; i < creatableContainers.length; i++) { + creatableContainers[i] = String.format("%s%d", createableContainersPrefix, i + 1); + } + + CREATEABLE_CONTAINER_1 = creatableContainers[0]; + CREATEABLE_CONTAINER_2 = creatableContainers[1]; + CREATEABLE_CONTAINER_3 = creatableContainers[2]; + CREATEABLE_CONTAINER_4 = creatableContainers[3]; + + TEST_CONTAINER_FOR_BLOBS = testContainers[0]; + TEST_CONTAINER_FOR_BLOBS_2 = testContainers[1]; + TEST_CONTAINER_FOR_LISTING = testContainers[2]; + + // Create all test containers and their content + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + for (int i = 0; i < testContainers.length; i++) { + try { + service.createContainer(testContainers[i]); + } + catch (ServiceException e) { + // 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 + public static void cleanup() throws Exception { + Configuration config = createConfiguration(); + BlobService service = config.create(BlobService.class); + for (int i = 0; i < testContainers.length; i++) { + try { + service.deleteContainer(testContainers[i]); + } + catch (ServiceException e) { + // Ignore exception as the containers might not exists + } + } + + for (int i = 0; i < creatableContainers.length; i++) { + try { + service.deleteContainer(creatableContainers[i]); + } + catch (ServiceException e) { + // Ignore exception as the containers might not exists + } + } + } @Test public void getServiceProppertiesWorks() throws Exception { @@ -81,8 +158,7 @@ public void createContainerWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createContainer("foo"); - service.deleteContainer("foo"); + service.createContainer(CREATEABLE_CONTAINER_1); // Assert } @@ -94,16 +170,17 @@ public void createContainerWithMetadataWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createContainer("foo2", new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); + service.createContainer(CREATEABLE_CONTAINER_2, + new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); - ContainerProperties prop = service.getContainerMetadata("foo2"); - ContainerProperties prop2 = service.getContainerProperties("foo2"); - ContainerACL acl = service.getContainerACL("foo2"); + ContainerProperties prop = service.getContainerMetadata(CREATEABLE_CONTAINER_2); + ContainerProperties prop2 = service.getContainerProperties(CREATEABLE_CONTAINER_2); + ContainerACL acl = service.getContainerACL(CREATEABLE_CONTAINER_2); - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix("foo2").setListingDetails( + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix(CREATEABLE_CONTAINER_2).setListingDetails( EnumSet.of(ContainerListingDetails.METADATA))); - service.deleteContainer("foo2"); + service.deleteContainer(CREATEABLE_CONTAINER_2); // Assert assertNotNull(prop); @@ -144,15 +221,13 @@ public void setContainerMetadataWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createContainer("foo3"); + service.createContainer(CREATEABLE_CONTAINER_3); HashMap metadata = new HashMap(); metadata.put("test", "bar"); metadata.put("blah", "bleah"); - service.setContainerMetadata("foo3", metadata); - ContainerProperties prop = service.getContainerMetadata("foo3"); - - service.deleteContainer("foo3"); + service.setContainerMetadata(CREATEABLE_CONTAINER_3, metadata); + ContainerProperties prop = service.getContainerMetadata(CREATEABLE_CONTAINER_3); // Assert assertNotNull(prop); @@ -172,7 +247,7 @@ public void setContainerACLWorks() throws Exception { Configuration config = createConfiguration(); BlobService service = config.create(BlobService.class); - String container = "foo4"; + String container = CREATEABLE_CONTAINER_4; Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); Date expiryEndDate = new GregorianCalendar(2020, 1, 1).getTime(); @@ -211,7 +286,7 @@ public void listContainersWorks() throws Exception { // Assert assertNotNull(results); - assertEquals(8, results.getContainers().size()); + assertTrue(testContainers.length <= results.getContainers().size()); assertNotNull(results.getContainers().get(0).getName()); assertNotNull(results.getContainers().get(0).getMetadata()); assertNotNull(results.getContainers().get(0).getProperties()); @@ -228,6 +303,7 @@ public void listContainersWithPaginationWorks() throws Exception { // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); // Assert assertNotNull(results); @@ -235,12 +311,8 @@ public void listContainersWithPaginationWorks() throws Exception { assertNotNull(results.getNextMarker()); assertEquals(3, results.getMaxResults()); - // Act - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); - - // Assert assertNotNull(results2); - assertEquals(5, results2.getContainers().size()); + assertTrue(testContainers.length - 3 <= results2.getContainers().size()); assertEquals("", results2.getNextMarker()); assertEquals(0, results2.getMaxResults()); } @@ -252,13 +324,21 @@ public void listContainersWithPrefixWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix("mycontainer1")); - + ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix(testContainersPrefix).setMaxResults(3)); // Assert assertNotNull(results); assertEquals(3, results.getContainers().size()); assertNotNull(results.getNextMarker()); - assertEquals(0, results.getMaxResults()); + assertEquals(3, results.getMaxResults()); + + // Act + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); + + // Assert + assertNotNull(results2); + assertEquals(testContainers.length - 3, results2.getContainers().size()); + assertNotNull(results2.getNextMarker()); + assertEquals(0, results2.getMaxResults()); } @Test @@ -268,11 +348,11 @@ public void listBlobsWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListBlobsResult results = service.listBlobs("mycontainer11"); + ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING); // Assert assertNotNull(results); - assertEquals(3, results.getBlobs().size()); + assertEquals(4, results.getBlobs().size()); } @Test @@ -282,7 +362,7 @@ public void listBlobsWithPrefixWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - ListBlobsResult results = service.listBlobs("mycontainer11", new ListBlobsOptions().setPrefix("Create")); + ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setPrefix("myblob")); // Assert assertNotNull(results); @@ -296,7 +376,7 @@ public void createPageBlobWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 512); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512); // Assert } @@ -308,12 +388,12 @@ public void createPageBlobWithOptionsWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 512, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, 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")); - BlobProperties props = service.getBlobProperties("mycontainer1", "test"); + BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); // Assert assertNotNull(props); @@ -339,7 +419,7 @@ public void clearBlobPagesWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 512); @@ -360,7 +440,7 @@ public void createBlobPagesWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; String content = new String(new char[512]); service.createPageBlob(container, blob, 512); @@ -382,7 +462,7 @@ public void listBlobRegionsWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; String content = new String(new char[512]); service.createPageBlob(container, blob, 16384 + 512); @@ -418,7 +498,7 @@ public void listBlobBlocksOnEmptyBlobWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test13"; String content = new String(new char[512]); service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); @@ -443,7 +523,7 @@ public void listBlobBlocksWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test14"; service.createBlockBlob(container, blob, null); service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(new byte[256])); @@ -476,7 +556,7 @@ public void commitBlobBlocksWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test14"; String blockId1 = "1fedcba"; String blockId2 = "2abcdef"; @@ -516,7 +596,7 @@ public void createBlobBlockWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test13"; String content = new String(new char[512]); service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); @@ -533,7 +613,7 @@ public void createBlockBlobWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream("some content".getBytes())); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream("some content".getBytes())); // Assert } @@ -546,12 +626,12 @@ public void createBlockBlobWithOptionsWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), + 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")); + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); - BlobProperties props = service.getBlobProperties("mycontainer1", "test2"); + BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); // Assert assertNotNull(props); @@ -577,7 +657,7 @@ public void createBlobSnapshotWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); BlobSnapshot snapshot = service.createBlobSnapshot(container, blob); @@ -596,7 +676,7 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); BlobSnapshot snapshot = service.createBlobSnapshot(container, blob, @@ -622,12 +702,12 @@ public void getBlockBlobWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8")), + 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")); + /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") + /* .setContentMD5("1234") */.setContentType("text/plain")); - GetBlobResult blob = service.getBlob("mycontainer1", "test2"); + GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); BlobProperties props = blob.getProperties(); // Assert @@ -655,12 +735,12 @@ public void getPageBlobWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 4096, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, 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("mycontainer1", "test"); + GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); BlobProperties props = blob.getProperties(); // Assert @@ -688,9 +768,9 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 4096); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); try { - service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -706,10 +786,10 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 4096); - BlobProperties props = service.getBlobProperties("mycontainer1", "test"); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); + BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { - service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifNoneMatch(props.getEtag()))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -725,10 +805,10 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - service.createPageBlob("mycontainer1", "test", 4096); - BlobProperties props = service.getBlobProperties("mycontainer1", "test"); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); + BlobProperties props = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); try { - service.getBlob("mycontainer1", "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifModifiedSince(props.getLastModified()))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -744,7 +824,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096); BlobProperties props = service.getBlobProperties(container, blob); @@ -780,7 +860,7 @@ public void getBlobPropertiesWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096); BlobProperties props = service.getBlobProperties(container, blob); @@ -810,7 +890,7 @@ public void getBlobMetadataWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; service.createPageBlob(container, blob, 4096, new CreateBlobOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); GetBlobMetadataResult props = service.getBlobMetadata(container, blob); @@ -835,7 +915,7 @@ public void setBlobPropertiesWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test10"; service.createPageBlob(container, blob, 4096); SetBlobPropertiesResult result = service.setBlobProperties(container, blob, @@ -873,7 +953,7 @@ public void setBlobMetadataWorks() throws Exception { BlobService service = config.create(BlobService.class); // Act - String container = "mycontainer1"; + String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test11"; HashMap metadata = new HashMap(); metadata.put("test", "bar"); @@ -905,9 +985,9 @@ public void deleteBlobWorks() throws Exception { // Act String content = "some content"; - service.createBlockBlob("mycontainer1", "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.deleteBlob("mycontainer1", "test2"); + service.deleteBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); // Assert } @@ -920,10 +1000,10 @@ public void copyBlobWorks() throws Exception { // Act String content = "some content2"; - service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.copyBlob("mycontainer1", "test5", "mycontainer2", "test6"); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + service.copyBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5", TEST_CONTAINER_FOR_BLOBS, "test6"); - GetBlobResult blob = service.getBlob("mycontainer1", "test5"); + GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); BlobProperties props = blob.getProperties(); // Assert @@ -948,9 +1028,9 @@ public void acquireLeaseWorks() throws Exception { // Act String content = "some content2"; - service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease("mycontainer2", "test6"); - service.releaseLease("mycontainer2", "test6", leaseId); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6"); + service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert assertNotNull(leaseId); @@ -964,10 +1044,10 @@ public void renewLeaseWorks() throws Exception { // Act String content = "some content2"; - service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease("mycontainer2", "test6"); - String leaseId2 = service.renewLease("mycontainer2", "test6", leaseId); - service.releaseLease("mycontainer2", "test6", leaseId); + 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); + service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert assertNotNull(leaseId); @@ -982,10 +1062,10 @@ public void breakLeaseWorks() throws Exception { // Act String content = "some content2"; - service.createBlockBlob("mycontainer2", "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - String leaseId = service.acquireLease("mycontainer2", "test6"); - service.breakLease("mycontainer2", "test6", leaseId); - service.releaseLease("mycontainer2", "test6", leaseId); + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); + String leaseId = service.acquireLease(TEST_CONTAINER_FOR_BLOBS, "test6"); + service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); + service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); // Assert assertNotNull(leaseId); @@ -1013,7 +1093,7 @@ public void retryPolicyWorks() throws Exception { ServiceException Error = null; try { - service.createPageBlob("mycontainer1", "test", 12); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 12); } catch (ServiceException e) { Error = e; @@ -1039,7 +1119,7 @@ public void retryPolicyCompositionWorks() throws Exception { ServiceException Error = null; try { - service.createPageBlob("mycontainer1", "test", 12); + service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 12); } catch (ServiceException e) { Error = e; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index 6423228b382d7..3db78c24a532d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -8,7 +8,7 @@ import com.microsoft.azure.configuration.Configuration; public abstract class IntegrationTestBase { - protected Configuration createConfiguration() { + protected static Configuration createConfiguration() { Configuration config = new Configuration(); Map env = System.getenv(); setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); @@ -23,7 +23,7 @@ protected Configuration createConfiguration() { return config; } - private void setConfigValue(Configuration config, Map props, String key, String defaultValue) { + private static void setConfigValue(Configuration config, Map props, String key, String defaultValue) { String value = props.get(key); if (value == null) value = defaultValue; From 3b02bd456de311b0faed95a5678e30114b1f7122 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 10 Nov 2011 15:21:36 -0800 Subject: [PATCH 138/664] Adding constructor to Queue which accepts the queueName Streamlines createQueue call --- .../azure/services/serviceBus/Queue.java | 5 +++++ .../serviceBus/IntegrationTestBase.java | 2 +- .../serviceBus/ServiceBusCreationTest.java | 2 -- .../serviceBus/ServiceBusIntegrationTest.java | 22 ++++++++----------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index e1a57beda00fe..f380e6d5406d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -22,6 +22,11 @@ public Queue() { public Queue(Entry entry) { super(entry, entry.getContent().getQueueDescription()); } + + public Queue(String name) { + this(); + setName(name); + } public String getName() { return getEntry().getTitle(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 6ad146f8a64c5..52b256b35b891 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -60,7 +60,7 @@ public void initialize() throws Exception { } } if (!testAlphaExists) { - service.createQueue(new Queue().setName("TestAlpha")); + service.createQueue(new Queue("TestAlpha")); } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java index a48c9e1c998d2..bfc7dd0a81517 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java @@ -49,6 +49,4 @@ public void testDefaultBuilderCreatesServiceImpl() throws Exception { assertNotNull(service); } - - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 350256bff6839..a8dbd968c49a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -53,11 +53,7 @@ public void createQueueWorks() throws Exception { // Arrange // Act - Queue queue = new Queue(); - - queue.setName("TestCreateQueueWorks"); - queue.setMaxSizeInMegabytes(1024L); - + Queue queue = new Queue("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); Queue saved = service.createQueue(queue); // Assert @@ -69,7 +65,7 @@ public void createQueueWorks() throws Exception { @Test public void deleteQueueWorks() throws Exception { // Arrange - service.createQueue(new Queue().setName("TestDeleteQueueWorks")); + service.createQueue(new Queue("TestDeleteQueueWorks")); // Act service.deleteQueue("TestDeleteQueueWorks"); @@ -92,7 +88,7 @@ public void sendMessageWorks() throws Exception { public void receiveMessageWorks() throws Exception { // Arrange String queueName = "TestReceiveMessageWorks"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello World")); // Act @@ -109,7 +105,7 @@ public void receiveMessageWorks() throws Exception { public void peekLockMessageWorks() throws Exception { // Arrange String queueName = "TestPeekLockMessageWorks"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); // Act @@ -126,7 +122,7 @@ public void peekLockMessageWorks() throws Exception { public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeCompleted"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); @@ -147,7 +143,7 @@ public void peekLockedMessageCanBeCompleted() throws Exception { public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeUnlocked"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); @@ -171,7 +167,7 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { public void peekLockedMessageCanBeDeleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeDeleted"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); @@ -193,7 +189,7 @@ public void peekLockedMessageCanBeDeleted() throws Exception { public void contentTypePassesThrough() throws Exception { // Arrange String queueName = "TestContentTypePassesThrough"; - service.createQueue(new Queue().setName(queueName)); + service.createQueue(new Queue(queueName)); // Act service.sendQueueMessage(queueName, @@ -243,7 +239,7 @@ public Response handle(Request request, Next next) { }); // Act - Queue created = filtered.createQueue(new Queue().setName("TestFilterCanSeeAndChangeRequestOrResponse")); + Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")); // Assert assertNotNull(created); From 91136b0153936afb2536d99d6c7dd976bc1eeac2 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:16:37 -0800 Subject: [PATCH 139/664] Adding fields needed to create maven bundle --- microsoft-azure-api/pom.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index c63d4a1fa1d38..b725a1eea6ee1 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -3,8 +3,28 @@ com.microsoft.azure microsoft-azure-api 0.0.1-SNAPSHOT + jar + Microsoft Azure Client API API for Microsoft Azure Clients + https://github.com/WindowsAzure/azure-sdk-for-java + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + scm:git:https://github.com/WindowsAzure/azure-sdk-for-java + scm:git:git://github.com/WindowsAzure/azure-sdk-for-java.git + + + + UTF-8 + From 499eb289dbff695d0477087fb1ede4b27b8ce715 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:25:29 -0800 Subject: [PATCH 140/664] Removing always-on logging filter. Closes #6 --- .../azure/configuration/jersey/Exports.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java index caa8ac407e170..6d4e177399d18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java @@ -8,28 +8,26 @@ import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.client.filter.LoggingFilter; public class Exports implements Builder.Exports { - public void register(Registry registry) { - registry.add(new Builder.Factory() { - public ClientConfig create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = new DefaultClientConfig(); - for(Entry entry : properties.entrySet()) { - clientConfig.getProperties().put(entry.getKey(), entry.getValue()); - } - return clientConfig; - } - }); - - registry.add(new Builder.Factory() { - public Client create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - Client client = Client.create(clientConfig); - client.addFilter(new LoggingFilter()); - return client; - } - }); - } + public void register(Registry registry) { + registry.add(new Builder.Factory() { + public ClientConfig create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = new DefaultClientConfig(); + for (Entry entry : properties.entrySet()) { + clientConfig.getProperties().put(entry.getKey(), entry.getValue()); + } + return clientConfig; + } + }); + + registry.add(new Builder.Factory() { + public Client create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + Client client = Client.create(clientConfig); + return client; + } + }); + } } From ed534671945d10f50c9dea771af584b573e49315 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 13:26:07 -0800 Subject: [PATCH 141/664] Update Eclipse settings for formatting comments --- .../.settings/org.eclipse.jdt.core.prefs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs index 162f1b9000c93..d71cd7f7e5458 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 @@ -#Wed Nov 09 14:11:15 PST 2011 +#Fri Nov 11 09:34:55 PST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -61,17 +61,17 @@ org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=false +org.eclipse.jdt.core.formatter.comment.format_header=true org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=false org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.line_length=120 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false From 3094bd0ab56395b4a06f98270859c3bbd8c948ba Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 13:27:04 -0800 Subject: [PATCH 142/664] Removing "TODO" comments (made them issues in issue tracker) --- .../common/ExponentialRetryPolicyFilter.java | 2 +- .../azure/services/blob/AccessCondition.java | 22 +++++++++---------- .../blob/AccessConditionHeaderType.java | 9 +++----- .../services/blob/BlobConfiguration.java | 8 ------- .../services/blob/BlobListingDetails.java | 6 ++--- .../azure/services/blob/BlockList.java | 3 --- .../azure/services/blob/ContainerACL.java | 13 +---------- .../blob/ContainerListingDetails.java | 6 ++--- .../services/blob/CreateBlobPagesResult.java | 1 - .../services/blob/ListBlobBlocksOptions.java | 1 - .../services/blob/ListBlobBlocksResult.java | 3 --- .../services/blob/ListBlobRegionsResult.java | 11 ++++------ .../azure/services/blob/ListBlobsResult.java | 6 ----- .../services/blob/ListContainersResult.java | 6 ----- .../services/blob/ServiceProperties.java | 9 -------- .../ContainerACLDateConverter.java | 2 +- .../implementation/SharedKeyLiteFilter.java | 10 ++++++++- 17 files changed, 33 insertions(+), 85 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java index 14a2e71e357b9..35901b47afdab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java @@ -14,7 +14,7 @@ public class ExponentialRetryPolicyFilter implements ServiceFilter { public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; - public static final int DEFAULT_MIN_BACKOFF = 1000 * 3; + public static final int DEFAULT_MIN_BACKOFF = 100 * 3; private final int deltaBackoffIntervalInMs; private final int maximumAttempts; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java index 5a3eec1904bf3..078040b0d5464 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java @@ -5,10 +5,8 @@ import com.microsoft.azure.services.blob.implementation.RFC1123DateConverter; /** - * TODO: Unify this with client layer - * * Represents a set of access conditions to be used for operations against the storage services. - * + * * Copyright (c)2011 Microsoft. All rights reserved. */ public final class AccessCondition { @@ -28,10 +26,10 @@ public final class AccessCondition { *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. - * + * * @param etag * A String that represents the ETag value to check. - * + * * @return An AccessCondition object that represents the If-Match condition. */ public static AccessCondition ifMatch(String etag) { @@ -48,10 +46,10 @@ public static AccessCondition ifMatch(String etag) { *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. - * + * * @param lastMotified * A java.util.Date object that represents the last-modified time to check for the resource. - * + * * @return An AccessCondition object that represents the If-Modified-Since condition. */ public static AccessCondition ifModifiedSince(Date lastMotified) { @@ -68,10 +66,10 @@ public static AccessCondition ifModifiedSince(Date lastMotified) { *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. - * + * * @param etag * A String that represents the ETag value to check. - * + * * @return An AccessCondition object that represents the If-None-Match condition. */ public static AccessCondition ifNoneMatch(String etag) { @@ -88,10 +86,10 @@ public static AccessCondition ifNoneMatch(String etag) { *

* For more information, see Specifying * Conditional Headers for Blob Service Operations. - * + * * @param lastMotified * A java.util.Date object that represents the last-modified time to check for the resource. - * + * * @return An AccessCondition object that represents the If-Unmodified-Since condition. */ public static AccessCondition ifNotModifiedSince(Date lastMotified) { @@ -117,7 +115,7 @@ protected AccessCondition() { /** * Creates an instance of the AccessCondition class using the specified header type and value. - * + * * @param headerType * An {@link AccessConditionHeaderType} value that represents the header type. * @param value diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java index 6bbac7e753aee..652aa98ccec49 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java @@ -1,11 +1,8 @@ package com.microsoft.azure.services.blob; - /** - * TODO: Unify this with client layer - * * Specifies the kinds of conditional headers that may be set for a request. - * + * * Copyright (c)2011 Microsoft. All rights reserved. */ public enum AccessConditionHeaderType { @@ -36,9 +33,9 @@ public enum AccessConditionHeaderType { /** * 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. */ @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java index dbb3c41a130c6..b0367a277a12f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java @@ -1,13 +1,5 @@ package com.microsoft.azure.services.blob; -/* - * TODO: Add convenience methods to create/augment a configuration with - * strongly typed settings - * - * TODO: Support for connection strings? - * - * TODO: Built-in support for dev fabric? - */ public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; public final static String ACCOUNT_KEY = "blob.accountKey"; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java index 4c603362ed8eb..40eab6896dd4a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java @@ -1,12 +1,10 @@ package com.microsoft.azure.services.blob; /** - * TODO: Naming and unification with client package - * * 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. + * 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. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java index d25aa3e42cd3d..13f5a8362d674 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java @@ -49,9 +49,6 @@ public BlockList setEntries(List entries) { return this; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public abstract static class Entry { private String blockId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java index 10b19926b4743..a2a670fd998ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java @@ -13,8 +13,7 @@ public class ContainerACL { private String etag; private Date lastModified; - //TODO: Enum? - private String publicAccess; // "blob", "container or null + private String publicAccess; // "blob", "container" or null private List signedIdentifiers = new ArrayList(); public String getEtag() { @@ -62,9 +61,6 @@ public void addSignedIdentifier(String id, Date start, Date expiry, String permi this.getSignedIdentifiers().add(signedIdentifier); } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ @XmlRootElement(name = "SignedIdentifiers") public static class SignedIdentifiers { private List signedIdentifiers = new ArrayList(); @@ -79,10 +75,6 @@ public void setSignedIdentifiers(List signedIdentifiers) { } } - - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class SignedIdentifier { private String id; private AccessPolicy accessPolicy; @@ -106,9 +98,6 @@ public void setAccessPolicy(AccessPolicy accessPolicy) { } } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class AccessPolicy { private Date start; private Date expiry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java index 577e1ac543a5f..e8d67b09d566b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java @@ -1,11 +1,9 @@ package com.microsoft.azure.services.blob; /** - * TODO: Naming and unification with client package - * * Specifies which details to include when listing the containers in this * storage account. - * + * * Copyright (c)2011 Microsoft. All rights reserved. */ public enum ContainerListingDetails { @@ -26,7 +24,7 @@ public enum ContainerListingDetails { /** * Sets the value of this enum. - * + * * @param val * The value being assigned. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java index 5c71081817690..b41effe812734 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java @@ -3,7 +3,6 @@ import java.util.Date; public class CreateBlobPagesResult { - //TODO: For "Result" classes, should we include "Date", "x-ms-version" response headers? private String etag; private Date lastModified; private String contentMD5; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java index 911df5304f196..018e413aea44c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java @@ -3,7 +3,6 @@ public class ListBlobBlocksOptions extends BlobOptions { private String leaseId; private String snapshot; - // TODO: Enum? private String listType; // "committed", "uncommitted", "all" public String getLeaseId() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java index a1c43864d2c4d..7c6430a5e9838 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java @@ -72,9 +72,6 @@ public void setUncommittedBlocks(List uncommittedBlocks) { this.uncommittedBlocks = uncommittedBlocks; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class Entry { private String blockId; private long blockLength; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java index a696dcbb3fe05..45542cfe03843 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name="PageList") +@XmlRootElement(name = "PageList") public class ListBlobRegionsResult { private Date lastModified; private String etag; @@ -37,7 +37,7 @@ public void setContentLength(long contentLength) { this.contentLength = contentLength; } - @XmlElement(name="PageRange") + @XmlElement(name = "PageRange") public List getPageRanges() { return pageRanges; } @@ -46,14 +46,11 @@ public void setPageRanges(List pageRanges) { this.pageRanges = pageRanges; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class PageRange { private long start; private long end; - @XmlElement(name="Start") + @XmlElement(name = "Start") public long getStart() { return start; } @@ -62,7 +59,7 @@ public void setStart(long start) { this.start = start; } - @XmlElement(name="End") + @XmlElement(name = "End") public long getEnd() { return end; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java index 3a531ecdf7576..cddbcb78ba2fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java @@ -87,9 +87,6 @@ public void setContainerName(String containerName) { this.containerName = containerName; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class Blob { private String name; private String url; @@ -144,9 +141,6 @@ public void setMetadata(HashMap metadata) { } } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class BlobProperties { private Date lastModified; private String etag; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java index 649775ac9b224..532480c8e75a3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java @@ -77,9 +77,6 @@ public void setMaxResults(int maxResults) { this.maxResults = maxResults; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class Container { private String name; private String url; @@ -124,9 +121,6 @@ public void setMetadata(HashMap metadata) { } } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class ContainerProperties { private Date lastModified; private String etag; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java index b1a30090cffa7..65619b7cf7f52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java @@ -37,9 +37,6 @@ public void setDefaultServiceVersion(String defaultServiceVersion) { this.defaultServiceVersion = defaultServiceVersion; } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class Logging { private String version; private Boolean delete; @@ -93,9 +90,6 @@ public void setVersion(String version) { } } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class Metrics { private String version; private boolean enabled; @@ -139,9 +133,6 @@ public void setVersion(String version) { } } - /* - * TODO: Are nested classes ok? (if not, we need to find a name for it) - */ public static class RetentionPolicy { private boolean enabled; private Integer days; // nullable, because optional if "enabled" is false diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java index d5e44c8c45fe6..c890c4cbdc3ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java @@ -9,7 +9,7 @@ /* * TODO: Move to some other common package? - * + * * "not quite" ISO 8601 date time conversion routines */ public class ContainerACLDateConverter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java index 4a29b1c591aab..6e8247277fe16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java @@ -8,6 +8,9 @@ import javax.inject.Named; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.microsoft.azure.services.blob.BlobConfiguration; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; @@ -18,6 +21,8 @@ * TODO: Should the "full" shared key signing? */ public class SharedKeyLiteFilter extends ClientFilter { + private static Log log = LogFactory.getLog(SharedKeyLiteFilter.class); + private final String accountName; private final HmacSHA256Sign signer; @@ -65,7 +70,10 @@ private void sign(ClientRequest cr) { stringToSign += addCanonicalizedHeaders(cr); stringToSign += addCanonicalizedResource(cr); - System.out.println(stringToSign); + if (log.isDebugEnabled()) { + log.debug(String.format("String to sign: \"%s\"", stringToSign)); + } + String signature = this.signer.sign(stringToSign); cr.getHeaders().putSingle("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); } From 6e9ff56c1263c63c69f6fadde20e39f53b4d9f5f Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 13:29:24 -0800 Subject: [PATCH 143/664] Make canonical resource code compatible with storage emulator --- .../implementation/BlobServiceForJersey.java | 73 +++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java index 263513a96ecda..095f18c320f03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java @@ -17,7 +17,6 @@ import com.microsoft.azure.services.blob.AccessCondition; import com.microsoft.azure.services.blob.AccessConditionHeaderType; import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.GetBlobResult; import com.microsoft.azure.services.blob.BlobConfiguration; import com.microsoft.azure.services.blob.BlobListingDetails; import com.microsoft.azure.services.blob.BlobOptions; @@ -42,6 +41,7 @@ import com.microsoft.azure.services.blob.GetBlobMetadataResult; import com.microsoft.azure.services.blob.GetBlobOptions; import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.GetBlobResult; import com.microsoft.azure.services.blob.ListBlobBlocksOptions; import com.microsoft.azure.services.blob.ListBlobBlocksResult; import com.microsoft.azure.services.blob.ListBlobRegionsOptions; @@ -66,7 +66,6 @@ public class BlobServiceForJersey implements BlobService { // private static Log log = LogFactory.getLog(BlobServiceForJersey.class); - // TODO: Should we make this a configuration options? private static final String API_VERSION = "2011-08-18"; private final Client channel; private final String accountName; @@ -80,10 +79,7 @@ public class BlobServiceForJersey implements BlobService { * configurable though code? */ @Inject - public BlobServiceForJersey( - Client channel, - @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, - @Named(BlobConfiguration.URL) String url, + public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, SharedKeyLiteFilter filter) { this.channel = channel; @@ -97,6 +93,7 @@ public BlobServiceForJersey( public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + this.channel = channel; this.filters = filters; this.accountName = accountName; @@ -276,18 +273,18 @@ private WebResource getResource(BlobOptions options) { return webResource; } - private WebResource setCanonicalizedResource(WebResource webResource, String resourceName, String operation) { - String value = "/" + this.accountName + "/"; - if (resourceName != null) { - value += resourceName; - } + 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; } - // TODO: Is this the best way to pass a parameter to a filter? webResource.setProperty("canonicalizedResource", value); + return webResource; } @@ -319,7 +316,7 @@ public ServiceProperties getServiceProperties() throws ServiceException { public ServiceProperties getServiceProperties(BlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, null, "properties"); + webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -332,7 +329,7 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser public void setServiceProperties(ServiceProperties serviceProperties, BlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, null, "properties"); + webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -346,7 +343,7 @@ public void createContainer(String container) throws ServiceException { public void createContainer(String container, CreateContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, null); + webResource = setCanonicalizedResource(webResource, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, options.getMetadata()); @@ -362,7 +359,7 @@ public void deleteContainer(String container) throws ServiceException { public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, null); + webResource = setCanonicalizedResource(webResource, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); @@ -389,7 +386,7 @@ public ContainerProperties getContainerMetadata(String container, BlobOptions op private ContainerProperties getContainerPropertiesImpl(String container, BlobOptions options, String operation) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); webResource = addOptionalQueryParam(webResource, "comp", operation); - webResource = setCanonicalizedResource(webResource, container, operation); + webResource = setCanonicalizedResource(webResource, operation); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -410,7 +407,7 @@ public ContainerACL getContainerACL(String container) throws ServiceException { public ContainerACL getContainerACL(String container, BlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, container, "acl"); + webResource = setCanonicalizedResource(webResource, "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -432,7 +429,7 @@ public void setContainerACL(String container, ContainerACL acl) throws ServiceEx public void setContainerACL(String container, ContainerACL acl, BlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, container, "acl"); + webResource = setCanonicalizedResource(webResource, "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); @@ -449,7 +446,7 @@ public void setContainerMetadata(String container, HashMap metad public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container, "metadata"); + webResource = setCanonicalizedResource(webResource, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, metadata); @@ -465,7 +462,7 @@ public ListContainersResult listContainers() throws ServiceException { public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); - webResource = setCanonicalizedResource(webResource, null, "list"); + webResource = setCanonicalizedResource(webResource, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); @@ -484,7 +481,7 @@ public ListBlobsResult listBlobs(String container) throws ServiceException { public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("comp", "list").queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, container, "list"); + webResource = setCanonicalizedResource(webResource, "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); @@ -510,7 +507,7 @@ public void createPageBlob(String container, String blob, int length) throws Ser public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); @@ -529,7 +526,7 @@ public void createBlockBlob(String container, String blob, InputStream contentSt public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -546,7 +543,7 @@ public BlobProperties getBlobProperties(String container, String blob) throws Se public BlobProperties getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -565,7 +562,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + webResource = setCanonicalizedResource(webResource, "metadata"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -589,7 +586,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob) public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "properties"); + webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); @@ -625,7 +622,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "metadata"); + webResource = setCanonicalizedResource(webResource, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -648,7 +645,7 @@ public GetBlobResult getBlob(String container, String blob) throws ServiceExcept public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -673,7 +670,7 @@ public void deleteBlob(String container, String blob) throws ServiceException { public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, null); + webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -689,7 +686,7 @@ public BlobSnapshot createBlobSnapshot(String container, String blob) throws Ser public BlobSnapshot createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob).queryParam("comp", "snapshot"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "snapshot"); + webResource = setCanonicalizedResource(webResource, "snapshot"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -714,7 +711,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { WebResource webResource = getResource(options).path(destinationContainer).path(destinationBlob); - webResource = setCanonicalizedResource(webResource, destinationContainer + "/" + destinationBlob, null); + webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -763,7 +760,7 @@ public void breakLease(String container, String blob, String leaseId, BlobOption private String putLeaseImpl(String leaseAction, String container, String blob, String leaseId, BlobOptions options, AccessCondition accessCondition) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "lease"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "lease"); + webResource = setCanonicalizedResource(webResource, "lease"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); @@ -799,7 +796,7 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, long private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, Long rangeStart, Long rangeEnd, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "page"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "page"); + webResource = setCanonicalizedResource(webResource, "page"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, rangeStart, rangeEnd); @@ -829,7 +826,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "pagelist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "pagelist"); + webResource = setCanonicalizedResource(webResource, "pagelist"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); @@ -855,7 +852,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "block"); webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "block"); + webResource = setCanonicalizedResource(webResource, "block"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -871,7 +868,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + webResource = setCanonicalizedResource(webResource, "blocklist"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -893,7 +890,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, container + "/" + blob, "blocklist"); + webResource = setCanonicalizedResource(webResource, "blocklist"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); From 068bf45009d5decc1938fef3057b3084072b63cb Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 13:30:54 -0800 Subject: [PATCH 144/664] Add support for storage emulator in integration tests --- .../microsoft/azure/services/blob/IntegrationTestBase.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java index 3db78c24a532d..792c09d75e864 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java @@ -11,6 +11,13 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { Configuration config = new Configuration(); Map env = System.getenv(); + + // Storage emulator support + //setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "devstoreaccount1"); + //setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); + //setConfigValue(config, env, BlobConfiguration.URL, "http://127.0.0.1:10000/devstoreaccount1"); + + // Storage account support setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); From 92623162919d7d503e746d14fc0e5f949e18ab31 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:35:57 -0800 Subject: [PATCH 145/664] Applied formatting rules provided to Eclipse --- .../com/microsoft/azure/ServiceException.java | 168 ++-- .../microsoft/azure/auth/wrap/Exports.java | 12 +- .../microsoft/azure/auth/wrap/WrapClient.java | 181 ++-- .../microsoft/azure/auth/wrap/WrapFilter.java | 37 +- .../auth/wrap/contract/WrapContract.java | 2 +- .../auth/wrap/contract/WrapContractImpl.java | 72 +- .../auth/wrap/contract/WrapResponse.java | 59 +- .../azure/configuration/Configuration.java | 107 ++- .../azure/configuration/builder/Builder.java | 45 +- .../configuration/builder/DefaultBuilder.java | 296 +++--- .../microsoft/azure/http/ServiceFilter.java | 77 +- .../azure/services/blob/BlobProperties.java | 2 +- .../implementation/Base64StringAdapter.java | 2 +- .../ContainerACLDateAdapter.java | 5 +- .../implementation/RFC1123DateAdapter.java | 5 +- .../implementation/RFC1123DateConverter.java | 4 +- .../azure/services/serviceBus/Exports.java | 64 +- .../services/serviceBus/ListQueuesResult.java | 16 +- .../services/serviceBus/ListTopicsResult.java | 14 +- .../azure/services/serviceBus/Message.java | 845 +++++++++--------- .../azure/services/serviceBus/Queue.java | 228 +++-- .../serviceBus/ReceiveMessageOptions.java | 82 +- .../services/serviceBus/ReceiveMode.java | 4 +- .../serviceBus/ServiceBusConfiguration.java | 87 +- .../serviceBus/ServiceBusContract.java | 83 +- .../serviceBus/ServiceBusService.java | 274 +++--- .../services/serviceBus/Subscription.java | 8 +- .../azure/services/serviceBus/Topic.java | 33 +- .../azure/services/serviceBus/Util.java | 20 +- .../serviceBus/client/MessageReceiver.java | 12 +- .../serviceBus/client/MessageSender.java | 3 +- .../serviceBus/client/MessageTransceiver.java | 1 - .../serviceBus/client/MessagingClient.java | 185 ++-- .../implementation/BrokerProperties.java | 366 ++++---- .../BrokerPropertiesMapper.java | 87 +- .../serviceBus/implementation/EntryModel.java | 36 +- .../implementation/EntryModelProvider.java | 118 +-- .../implementation/MarshallerProvider.java | 76 +- .../NamespacePrefixMapperImpl.java | 20 +- .../ServiceBusExceptionProcessor.java | 627 ++++++------- .../implementation/ServiceBusRestProxy.java | 529 ++++++----- .../microsoft/azure/utils/DateFactory.java | 2 +- .../azure/utils/DefaultDateFactory.java | 6 +- .../com/microsoft/azure/utils/Exports.java | 6 +- .../azure/utils/ServiceExceptionFactory.java | 101 ++- .../auth/wrap/WrapClientIntegrationTest.java | 36 +- .../azure/auth/wrap/WrapClientTest.java | 190 ++-- .../contract/WrapContractIntegrationTest.java | 22 +- .../builder/AlterClassWithProperties.java | 12 +- .../ClassWithMultipleCtorMultipleInject.java | 11 +- .../ClassWithMultipleCtorNoInject.java | 9 +- .../builder/ClassWithNamedParameter.java | 25 +- .../builder/ClassWithProperties.java | 67 +- .../builder/ClassWithSingleCtorNoInject.java | 6 +- .../builder/DefaultBuilderTest.java | 296 +++--- .../BrokerPropertiesMapperTest.java | 199 ++--- .../serviceBus/IntegrationTestBase.java | 101 +-- .../services/serviceBus/RetryFilter.java | 41 +- .../ServiceBusConfigurationTest.java | 82 +- .../serviceBus/ServiceBusCreationTest.java | 83 +- .../serviceBus/ServiceBusIntegrationTest.java | 445 +++++---- .../MessagingClientIntegrationTest.java | 118 ++- .../utils/ServiceExceptionFactoryTest.java | 92 +- 63 files changed, 3440 insertions(+), 3402 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java index a7c96a5df82e7..fb180d3738f65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java @@ -1,85 +1,97 @@ package com.microsoft.azure; + import java.util.HashMap; import java.util.Map; - public class ServiceException extends Exception { - - private static final long serialVersionUID = -4942076377009150131L; - - int httpStatusCode; - String httpReasonPhrase; - String serviceName; - - String errorCode; - String errorMessage; - Map errorValues; - - public ServiceException() { - init(); - } - - public ServiceException(String message) { - super(message); - init(); - } - - public ServiceException(String message, Throwable cause) { - super(message, cause); - init(); - } - - public ServiceException(Throwable cause) { - super(cause); - init(); - } - - private void init() { - errorValues = new HashMap(); - } - - - public int getHttpStatusCode() { - return httpStatusCode; - } - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - public String getHttpReasonPhrase() { - return httpReasonPhrase; - } - public void setHttpReasonPhrase(String httpReasonPhrase) { - this.httpReasonPhrase = httpReasonPhrase; - } - public String getErrorCode() { - return errorCode; - } - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - public String getErrorMessage() { - return errorMessage; - } - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - public Map getErrorValues() { - return errorValues; - } - public void setErrorValues(Map errorValues) { - this.errorValues = errorValues; - } - public String getErrorValue(String name) { - return errorValues.get(name); - } - public void setErrorValue(String name, String value) { - this.errorValues.put(name, value); - } - public String getServiceName() { - return serviceName; - } - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } + + private static final long serialVersionUID = -4942076377009150131L; + + int httpStatusCode; + String httpReasonPhrase; + String serviceName; + + String errorCode; + String errorMessage; + Map errorValues; + + public ServiceException() { + init(); + } + + public ServiceException(String message) { + super(message); + init(); + } + + public ServiceException(String message, Throwable cause) { + super(message, cause); + init(); + } + + public ServiceException(Throwable cause) { + super(cause); + init(); + } + + private void init() { + errorValues = new HashMap(); + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpReasonPhrase() { + return httpReasonPhrase; + } + + public void setHttpReasonPhrase(String httpReasonPhrase) { + this.httpReasonPhrase = httpReasonPhrase; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public Map getErrorValues() { + return errorValues; + } + + public void setErrorValues(Map errorValues) { + this.errorValues = errorValues; + } + + public String getErrorValue(String name) { + return errorValues.get(name); + } + + public void setErrorValue(String name, String value) { + this.errorValues.put(name, value); + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java index e5c1ba053b5f0..a317c746b5eaf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java @@ -5,12 +5,12 @@ import com.microsoft.azure.configuration.builder.Builder.Registry; public class Exports implements - com.microsoft.azure.configuration.builder.Builder.Exports { + com.microsoft.azure.configuration.builder.Builder.Exports { - public void register(Registry registry) { - registry.add(WrapContract.class, WrapContractImpl.class); - registry.add(WrapClient.class); - registry.add(WrapFilter.class); - } + public void register(Registry registry) { + registry.add(WrapContract.class, WrapContractImpl.class); + registry.add(WrapClient.class); + registry.add(WrapFilter.class); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java index 01b780cb90cf5..c4063e790e3cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java @@ -13,93 +13,98 @@ public class WrapClient { - WrapContract contract; - private DateFactory dateFactory; - private String uri; - private String name; - private String password; - private String scope; - - private ActiveToken activeToken; - - - @Inject - public WrapClient( - WrapContract contract, - DateFactory dateFactory, - @Named("wrap.uri") String uri, - @Named("wrap.scope") String scope, - @Named("wrap.name") String name, - @Named("wrap.password") String password) { - this.contract = contract; - this.dateFactory = dateFactory; - this.uri = uri; - this.scope = scope; - this.name = name; - this.password = password; - } - - - /** - * @return the contract - */ - public WrapContract getContract() { - return contract; - } - - /** - * @param contract the contract to set - */ - public void setContract(WrapContract contract) { - this.contract = contract; - } - - public String getAccessToken() throws ServiceException { - Date now = dateFactory.getDate(); - ActiveToken active = this.activeToken; - - if (active != null && now.before(active.getExpiresUtc()) ) { - return active.getWrapResponse().getAccessToken(); - } - - WrapResponse wrapResponse = getContract().post(uri, name, password, scope); - Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); - - ActiveToken acquired = new ActiveToken(); - acquired.setWrapResponse(wrapResponse); - acquired.setExpiresUtc(expiresUtc); - this.activeToken = acquired; - - return wrapResponse.getAccessToken(); - } - - class ActiveToken { - Date expiresUtc; - WrapResponse wrapResponse; - /** - * @return the expiresUtc - */ - public Date getExpiresUtc() { - return expiresUtc; - } - /** - * @param expiresUtc the expiresUtc to set - */ - public void setExpiresUtc(Date expiresUtc) { - this.expiresUtc = expiresUtc; - } - /** - * @return the wrapResponse - */ - public WrapResponse getWrapResponse() { - return wrapResponse; - } - /** - * @param wrapResponse the wrapResponse to set - */ - public void setWrapResponse(WrapResponse wrapResponse) { - this.wrapResponse = wrapResponse; - } - } + WrapContract contract; + private DateFactory dateFactory; + private String uri; + private String name; + private String password; + private String scope; + + private ActiveToken activeToken; + + @Inject + public WrapClient( + WrapContract contract, + DateFactory dateFactory, + @Named("wrap.uri") String uri, + @Named("wrap.scope") String scope, + @Named("wrap.name") String name, + @Named("wrap.password") String password) { + this.contract = contract; + this.dateFactory = dateFactory; + this.uri = uri; + this.scope = scope; + this.name = name; + this.password = password; + } + + /** + * @return the contract + */ + public WrapContract getContract() { + return contract; + } + + /** + * @param contract + * the contract to set + */ + public void setContract(WrapContract contract) { + this.contract = contract; + } + + public String getAccessToken() throws ServiceException { + Date now = dateFactory.getDate(); + ActiveToken active = this.activeToken; + + if (active != null && now.before(active.getExpiresUtc())) { + return active.getWrapResponse().getAccessToken(); + } + + WrapResponse wrapResponse = getContract().post(uri, name, password, scope); + Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); + + ActiveToken acquired = new ActiveToken(); + acquired.setWrapResponse(wrapResponse); + acquired.setExpiresUtc(expiresUtc); + this.activeToken = acquired; + + return wrapResponse.getAccessToken(); + } + + class ActiveToken { + Date expiresUtc; + WrapResponse wrapResponse; + + /** + * @return the expiresUtc + */ + public Date getExpiresUtc() { + return expiresUtc; + } + + /** + * @param expiresUtc + * the expiresUtc to set + */ + public void setExpiresUtc(Date expiresUtc) { + this.expiresUtc = expiresUtc; + } + + /** + * @return the wrapResponse + */ + public WrapResponse getWrapResponse() { + return wrapResponse; + } + + /** + * @param wrapResponse + * the wrapResponse to set + */ + public void setWrapResponse(WrapResponse wrapResponse) { + this.wrapResponse = wrapResponse; + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java index dd77896c9d622..0490c0a537617 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java @@ -7,27 +7,28 @@ import com.sun.jersey.api.client.filter.ClientFilter; public class WrapFilter extends ClientFilter { - private WrapClient client; + private WrapClient client; - public WrapFilter(WrapClient client) { - this.client = client; - } + public WrapFilter(WrapClient client) { + this.client = client; + } - @Override - public ClientResponse handle(ClientRequest cr) - throws ClientHandlerException { + @Override + public ClientResponse handle(ClientRequest cr) + throws ClientHandlerException { - String accessToken; - try { - accessToken = client.getAccessToken(); - } catch (ServiceException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } + String accessToken; + try { + accessToken = client.getAccessToken(); + } + catch (ServiceException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } - cr.getHeaders().add("Authorization", - "WRAP access_token=\"" + accessToken + "\""); + cr.getHeaders().add("Authorization", + "WRAP access_token=\"" + accessToken + "\""); - return this.getNext().handle(cr); - } + return this.getNext().handle(cr); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java index 261c3c7f3cd44..a3d5effb686da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java @@ -3,5 +3,5 @@ import com.microsoft.azure.ServiceException; public interface WrapContract { - WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; + WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java index 46fe925aa0527..b6d376c837b62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java @@ -13,40 +13,40 @@ import com.sun.jersey.api.representation.Form; public class WrapContractImpl implements WrapContract { - Client channel; - - static Log log = LogFactory.getLog(WrapContract.class); - - @Inject - public WrapContractImpl(Client channel) { - this.channel = channel; - } - - public WrapResponse post(String uri, String name, String password, String scope) throws ServiceException { - Form requestForm = new Form(); - requestForm.add("wrap_name", name); - requestForm.add("wrap_password", password); - requestForm.add("wrap_scope", scope); - - Form responseForm; - try { - responseForm = channel.resource(uri) - .accept(MediaType.APPLICATION_FORM_URLENCODED) - .type(MediaType.APPLICATION_FORM_URLENCODED) - .post(Form.class, requestForm); - } - catch (UniformInterfaceException e) { - log.warn("WRAP server returned error acquiring access_token", e); - throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); - } - - WrapResponse response = new WrapResponse(); - - response.setAccessToken(responseForm.getFirst("wrap_access_token")); - - String expiresIn = responseForm.getFirst("wrap_access_token_expires_in"); - response.setExpiresIn(Long.parseLong(expiresIn)); - - return response; - } + Client channel; + + static Log log = LogFactory.getLog(WrapContract.class); + + @Inject + public WrapContractImpl(Client channel) { + this.channel = channel; + } + + public WrapResponse post(String uri, String name, String password, String scope) throws ServiceException { + Form requestForm = new Form(); + requestForm.add("wrap_name", name); + requestForm.add("wrap_password", password); + requestForm.add("wrap_scope", scope); + + Form responseForm; + try { + responseForm = channel.resource(uri) + .accept(MediaType.APPLICATION_FORM_URLENCODED) + .type(MediaType.APPLICATION_FORM_URLENCODED) + .post(Form.class, requestForm); + } + catch (UniformInterfaceException e) { + log.warn("WRAP server returned error acquiring access_token", e); + throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); + } + + WrapResponse response = new WrapResponse(); + + response.setAccessToken(responseForm.getFirst("wrap_access_token")); + + String expiresIn = responseForm.getFirst("wrap_access_token_expires_in"); + response.setExpiresIn(Long.parseLong(expiresIn)); + + return response; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java index 5032e699947c1..cdea222b9ce3f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java @@ -1,31 +1,36 @@ package com.microsoft.azure.auth.wrap.contract; public class WrapResponse { - String accessToken; - long expiresIn; - - /** - * @return the accessToken - */ - public String getAccessToken() { - return accessToken; - } - /** - * @param accessToken the accessToken to set - */ - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - /** - * @return the expiresIn - */ - public long getExpiresIn() { - return expiresIn; - } - /** - * @param expiresIn the expiresIn to set - */ - public void setExpiresIn(long expiresIn) { - this.expiresIn = expiresIn; - } + String accessToken; + long expiresIn; + + /** + * @return the accessToken + */ + public String getAccessToken() { + return accessToken; + } + + /** + * @param accessToken + * the accessToken to set + */ + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + /** + * @return the expiresIn + */ + public long getExpiresIn() { + return expiresIn; + } + + /** + * @param expiresIn + * the expiresIn to set + */ + public void setExpiresIn(long expiresIn) { + this.expiresIn = expiresIn; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index a2297ba459897..7374bccc760d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -8,70 +8,69 @@ import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.json.JSONConfiguration; +public class Configuration { -public class Configuration { + private static Configuration instance; + Map properties; + Builder builder; - private static Configuration instance; - Map properties; - Builder builder; + public Configuration() { + this.properties = new HashMap(); + this.builder = DefaultBuilder.create(); + init(); + } - public Configuration() { - this.properties = new HashMap(); - this.builder = DefaultBuilder.create(); - init(); - } + public Configuration(Builder builder) { + this.properties = new HashMap(); + this.builder = builder; + init(); + } - public Configuration(Builder builder) { - this.properties = new HashMap(); - this.builder = builder; - init(); - } + private void init() { + // DefaultClientConfig clientConfig = new DefaultClientConfig(); + // clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + try { + setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); + } + catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } - private void init() { -// DefaultClientConfig clientConfig = new DefaultClientConfig(); -// clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - try { - setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - public static Configuration getInstance() { - if (instance == null) - instance = Configuration.load(); - return instance; - } + public static Configuration getInstance() { + if (instance == null) + instance = Configuration.load(); + return instance; + } - public static void setInstance(Configuration instance) { - Configuration.instance = instance; - } + public static void setInstance(Configuration instance) { + Configuration.instance = instance; + } - public static Configuration load() { - // TODO - load from somewhere - return new Configuration(); - } - - public T create(Class service) throws Exception { - return builder.build("", service, properties); - } + public static Configuration load() { + // TODO - load from somewhere + return new Configuration(); + } - public T create(String profile, Class service) throws Exception { - return builder.build(profile, service, properties); - } + public T create(Class service) throws Exception { + return builder.build("", service, properties); + } - public Builder getBuilder() { - return builder; - } + public T create(String profile, Class service) throws Exception { + return builder.build(profile, service, properties); + } - public Object getProperty(String name) { - return properties.get(name); - } + public Builder getBuilder() { + return builder; + } - public void setProperty(String name, Object value) { - properties.put(name, value); - } - + public Object getProperty(String name) { + return properties.get(name); + } + + public void setProperty(String name, Object value) { + properties.put(name, value); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java index 60b9aa3578afe..5d72561ed18fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java @@ -2,28 +2,29 @@ import java.util.Map; - public interface Builder { - public abstract T build(String profile, Class service, Map properties) throws Exception; - - public interface Factory { - T create(String profile, Builder builder, Map properties) throws Exception; - } - - public interface Alteration { - T alter(T instance, Builder builder, Map properties) throws Exception; - } - - public interface Registry { - Registry add(Class service); - Registry add(Class service, Class implementation); - Registry add(Factory factory); - - void alter(Class service, Alteration alteration); - } - - public interface Exports { - void register(Registry registry); - } + public abstract T build(String profile, Class service, Map properties) throws Exception; + + public interface Factory { + T create(String profile, Builder builder, Map properties) throws Exception; + } + + public interface Alteration { + T alter(T instance, Builder builder, Map properties) throws Exception; + } + + public interface Registry { + Registry add(Class service); + + Registry add(Class service, Class implementation); + + Registry add(Factory factory); + + void alter(Class service, Alteration alteration); + } + + public interface Exports { + void register(Registry registry); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java index f0dc5b1b0ec19..f80d5f65f9951 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java @@ -13,161 +13,155 @@ import javax.inject.Inject; import javax.inject.Named; +public class DefaultBuilder implements Builder, Builder.Registry { + Map, Factory> factories; + Map, List>> alterations; + public DefaultBuilder() { + factories = new HashMap, Factory>(); + alterations = new HashMap, List>>(); + } -public class DefaultBuilder implements Builder, Builder.Registry { - Map, Factory> factories; - Map, List>> alterations; - - public DefaultBuilder() { - factories = new HashMap, Factory>(); - alterations = new HashMap, List>>(); - } - - public static DefaultBuilder create() { - DefaultBuilder builder = new DefaultBuilder(); - - for(Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { - exports.register(builder); - } - - return builder; - } - - void addFactory(Class service, Factory factory) { - factories.put(service, factory); - } - - public Builder.Registry add(Class service) { - return add(service, service); - } - - Constructor findInjectConstructor(Class implementation) { - - Constructor withInject = null; - Constructor withoutInject = null; - int count = 0; - - for (Constructor ctor : implementation.getConstructors()) { - if (ctor.getAnnotation(Inject.class) != null) { - if (withInject != null){ - throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); - } - withInject = ctor; - } - else { - ++count; - withoutInject = ctor; - } - } - if (withInject != null) { - return withInject; - } - if (count != 1) { - throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); - } - return withoutInject; - } - - public Builder.Registry add(Class service, final Class implementation) { - final Constructor ctor = findInjectConstructor(implementation); - final Class[] parameterTypes = ctor.getParameterTypes(); - final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); - - addFactory(service, new Builder.Factory() { - @SuppressWarnings("unchecked") - public T create(String profile, Builder builder, Map properties) throws Exception { - Object[] initargs = new Object[parameterTypes.length]; - for(int i = 0; i != parameterTypes.length; ++i) { - - boolean located = false; - - String named = findNamedAnnotation(parameterAnnotations[i]); - String fullName = dotCombine(profile, named); - - boolean probeProperties = fullName != null && fullName != ""; - int startingIndex = 0; - while(!located && probeProperties) { - String probeName = fullName.substring(startingIndex); - if (!located && named != null && properties.containsKey(probeName)){ - located = true; - initargs[i] = properties.get(probeName); - } - else { - startingIndex = fullName.indexOf('.', startingIndex) + 1; - if (startingIndex == 0) { - probeProperties = false; - } - } - } - - if (!located) { - located = true; - initargs[i] = builder.build(fullName, parameterTypes[i], properties); - } - } - - return (T) ctor.newInstance(initargs); - } - }); - return this; - } - - - protected String dotCombine(String profile, String named) { - boolean noProfile = profile == null || profile == ""; - boolean noName = named == null || named == ""; - if (noName) - return profile; - if (noProfile) - return named; - return profile + "." + named; - } - - protected String findNamedAnnotation(Annotation[] annotations) { - for(Annotation annotation : annotations){ - if (Named.class.isAssignableFrom(annotation.getClass())){ - return ((Named)annotation).value(); - } - } - return null; - } - - public Registry add(Factory factory) { - for(Type genericInterface : factory.getClass().getGenericInterfaces()) - { - ParameterizedType parameterizedType = (ParameterizedType) genericInterface; - if (parameterizedType.getRawType().equals(Builder.Factory.class)) { - Type typeArgument = parameterizedType.getActualTypeArguments()[0]; - addFactory((Class)typeArgument, factory); - } - } - return this; - } - - - @SuppressWarnings("unchecked") - public T build(String profile, Class service, Map properties) throws Exception { - Factory factory = (Factory) factories.get(service); - if (factory == null) { - throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); - } - T instance = factory.create(profile, this, properties); - List> alterationList = alterations.get(service); - if (alterationList != null){ - for(Alteration alteration : alterationList){ - instance = ((Alteration)alteration).alter(instance, this, properties); - } - } - return instance; + public static DefaultBuilder create() { + DefaultBuilder builder = new DefaultBuilder(); + + for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { + exports.register(builder); + } + + return builder; } - public void alter(Class service, Alteration alteration) { - if (!this.alterations.containsKey(service)) { - this.alterations.put(service, new ArrayList>()); - } - this.alterations.get(service).add(alteration); - } + void addFactory(Class service, Factory factory) { + factories.put(service, factory); + } + public Builder.Registry add(Class service) { + return add(service, service); + } + + Constructor findInjectConstructor(Class implementation) { + + Constructor withInject = null; + Constructor withoutInject = null; + int count = 0; + + for (Constructor ctor : implementation.getConstructors()) { + if (ctor.getAnnotation(Inject.class) != null) { + if (withInject != null) { + throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); + } + withInject = ctor; + } + else { + ++count; + withoutInject = ctor; + } + } + if (withInject != null) { + return withInject; + } + if (count != 1) { + throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); + } + return withoutInject; + } + + public Builder.Registry add(Class service, final Class implementation) { + final Constructor ctor = findInjectConstructor(implementation); + final Class[] parameterTypes = ctor.getParameterTypes(); + final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); + + addFactory(service, new Builder.Factory() { + @SuppressWarnings("unchecked") + public T create(String profile, Builder builder, Map properties) throws Exception { + Object[] initargs = new Object[parameterTypes.length]; + for (int i = 0; i != parameterTypes.length; ++i) { + + boolean located = false; + + String named = findNamedAnnotation(parameterAnnotations[i]); + String fullName = dotCombine(profile, named); + + boolean probeProperties = fullName != null && fullName != ""; + int startingIndex = 0; + while (!located && probeProperties) { + String probeName = fullName.substring(startingIndex); + if (!located && named != null && properties.containsKey(probeName)) { + located = true; + initargs[i] = properties.get(probeName); + } + else { + startingIndex = fullName.indexOf('.', startingIndex) + 1; + if (startingIndex == 0) { + probeProperties = false; + } + } + } + + if (!located) { + located = true; + initargs[i] = builder.build(fullName, parameterTypes[i], properties); + } + } + + return (T) ctor.newInstance(initargs); + } + }); + return this; + } + + protected String dotCombine(String profile, String named) { + boolean noProfile = profile == null || profile == ""; + boolean noName = named == null || named == ""; + if (noName) + return profile; + if (noProfile) + return named; + return profile + "." + named; + } + + protected String findNamedAnnotation(Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (Named.class.isAssignableFrom(annotation.getClass())) { + return ((Named) annotation).value(); + } + } + return null; + } + + public Registry add(Factory factory) { + for (Type genericInterface : factory.getClass().getGenericInterfaces()) { + ParameterizedType parameterizedType = (ParameterizedType) genericInterface; + if (parameterizedType.getRawType().equals(Builder.Factory.class)) { + Type typeArgument = parameterizedType.getActualTypeArguments()[0]; + addFactory((Class) typeArgument, factory); + } + } + return this; + } + + @SuppressWarnings("unchecked") + public T build(String profile, Class service, Map properties) throws Exception { + Factory factory = (Factory) factories.get(service); + if (factory == null) { + throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); + } + T instance = factory.create(profile, this, properties); + List> alterationList = alterations.get(service); + if (alterationList != null) { + for (Alteration alteration : alterationList) { + instance = ((Alteration) alteration).alter(instance, this, properties); + } + } + return instance; + } + + public void alter(Class service, Alteration alteration) { + if (!this.alterations.containsKey(service)) { + this.alterations.put(service, new ArrayList>()); + } + this.alterations.get(service).add(alteration); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java index c793830dabdc0..3ebd4fe9890dc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java @@ -6,41 +6,46 @@ import javax.ws.rs.core.MultivaluedMap; - public interface ServiceFilter { - Response handle(Request request, Next next); - - public interface Next { - Response handle(Request request); - } - - public interface Request { - public String getMethod(); - public void setMethod(String method); - - public URI getURI(); - public void setURI(URI uri); - - public MultivaluedMap getHeaders(); - - public Object getEntity(); - public void setEntity(Object entity); - - public Map getProperties(); - public void setProperties(Map properties); - } - - public interface Response { - int getStatus(); - void setStatus(int status); - - MultivaluedMap getHeaders(); - - boolean hasEntity(); - - InputStream getEntityInputStream(); - void setEntityInputStream(InputStream entity); - - Map getProperties(); - } + Response handle(Request request, Next next); + + public interface Next { + Response handle(Request request); + } + + public interface Request { + public String getMethod(); + + public void setMethod(String method); + + public URI getURI(); + + public void setURI(URI uri); + + public MultivaluedMap getHeaders(); + + public Object getEntity(); + + public void setEntity(Object entity); + + public Map getProperties(); + + public void setProperties(Map properties); + } + + public interface Response { + int getStatus(); + + void setStatus(int status); + + MultivaluedMap getHeaders(); + + boolean hasEntity(); + + InputStream getEntityInputStream(); + + void setEntityInputStream(InputStream entity); + + Map getProperties(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java index 37e97a9255527..4e75ea3e335e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java @@ -8,7 +8,7 @@ import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; -//TODO: Unify this with ListBlobsResults.BlobProperties +// TODO: Unify this with ListBlobsResults.BlobProperties public class BlobProperties { private Date lastModified; private String etag; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java index 4ea9fd8875d70..22cde9443562f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java @@ -6,7 +6,7 @@ /* * TODO: Move so some other common package? - * + * * JAXB adapter for a Base64 encoded string element */ public class Base64StringAdapter extends XmlAdapter { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java index aa35d2c28232e..58c9f01a8392a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java @@ -4,13 +4,12 @@ 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 { +public class ContainerACLDateAdapter extends XmlAdapter { @Override public Date unmarshal(String arg0) throws Exception { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java index 07204dafe2893..570246adec097 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java @@ -4,13 +4,12 @@ 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 { +public class RFC1123DateAdapter extends XmlAdapter { @Override public Date unmarshal(String arg0) throws Exception { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java index 5e7c45a51ad13..e6ed6f6e7c60c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java @@ -9,8 +9,8 @@ /* * TODO: Move to some other common package? - * - * RFC 1123 date to string conversion + * + * RFC 1123 date to string conversion */ public class RFC1123DateConverter { private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index d7336a6577560..46e0723c20e62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -13,36 +13,36 @@ import com.sun.jersey.api.json.JSONConfiguration; public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - - // provide contract implementation - registry.add(ServiceBusContract.class, ServiceBusExceptionProcessor.class); - registry.add(ServiceBusService.class); - registry.add(ServiceBusExceptionProcessor.class); - registry.add(ServiceBusRestProxy.class); - registry.add(MessagingClient.class); - - // alter jersey client config for serviceBus - registry.alter(ClientConfig.class, new Builder.Alteration() { - - public ClientConfig alter(ClientConfig instance, Builder builder, - Map properties) throws Exception { - - // enable this feature for unattributed json object serialization - instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - - // need to avoid certain element prefixes, which the service does not ignore - instance.getSingletons().add(new MarshallerProvider()); - - // add body reader/writer for EntryModel descendant classes - instance.getClasses().add(EntryModelProvider.class); - - return instance; - } - }); - - // convenience provider to transform BrokerProperty headers to json - registry.add(BrokerPropertiesMapper.class); - - } + public void register(Builder.Registry registry) { + + // provide contract implementation + registry.add(ServiceBusContract.class, ServiceBusExceptionProcessor.class); + registry.add(ServiceBusService.class); + registry.add(ServiceBusExceptionProcessor.class); + registry.add(ServiceBusRestProxy.class); + registry.add(MessagingClient.class); + + // alter jersey client config for serviceBus + registry.alter(ClientConfig.class, new Builder.Alteration() { + + public ClientConfig alter(ClientConfig instance, Builder builder, + Map properties) throws Exception { + + // enable this feature for unattributed json object serialization + instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + + // need to avoid certain element prefixes, which the service does not ignore + instance.getSingletons().add(new MarshallerProvider()); + + // add body reader/writer for EntryModel descendant classes + instance.getClasses().add(EntryModelProvider.class); + + return instance; + } + }); + + // convenience provider to transform BrokerProperty headers to json + registry.add(BrokerPropertiesMapper.class); + + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java index 140b4cbffbcf3..ebfb9fc0076fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java @@ -3,14 +3,14 @@ import java.util.List; public class ListQueuesResult { - - private List items; - List getItems() { - return items; - } + private List items; - public void setItems(List items) { - this.items = items; - } + List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java index 2e8cbaab37f4a..25cb84cccbaf0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java @@ -4,13 +4,13 @@ public class ListTopicsResult { - private List items; + private List items; - List getItems() { - return items; - } + List getItems() { + return items; + } - public void setItems(List items) { - this.items = items; - } + public void setItems(List items) { + this.items = items; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java index 44f402c39f0fc..eac6a63438465 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java @@ -10,427 +10,426 @@ * Represents a service bus message. */ public class Message { - BrokerProperties properties; - InputStream body; - String contentType; - Date date; - - /** - * Creates an instance of the Message class. - */ - public Message() { - this.properties = new BrokerProperties(); - } - - /** - * Creates an instance of the Message class using the specified - * InputStream. - * - * @param body - * An InputStream object that represents the body of - * the message. - */ - public Message(InputStream body) { - this.properties = new BrokerProperties(); - this.body = body; - } - - /** - * Creates an instance of the Message class using the specified - * byte array. - * - * @param body - * A byte array that represents the body of the message. - */ - public Message(byte[] body) { - this.properties = new BrokerProperties(); - this.body = (body == null) ? null : new ByteArrayInputStream(body); - } - - /** - * Creates an instance of the Message class using the specified - * string. - * - * @param body - * A String object that represents the body of the - * message. - */ - public Message(String body) { - this.properties = new BrokerProperties(); - this.body = (body == null) ? null : new ByteArrayInputStream( - body.getBytes()); - } - - Message(BrokerProperties properties, InputStream body) { - this.properties = properties; - this.body = body; - } - - /** - * Returns the properties of the message. - * - * @return A {@link BrokerProperties} object that represents the properties - * of the message. - */ - public BrokerProperties getProperties() { - return properties; - } - - /** - * Sets the properties of the message. - * - * @param properties - * A {@link BrokerProperties} object that represents the - * properties of the message. - */ - public Message setProperties(BrokerProperties properties) { - this.properties = properties; - return this; - } - - /** - * Returns the body of the message. - * - * @return An InputStream object that represents the body of - * the message. - */ - public InputStream getBody() { - return body; - } - - /** - * Specifies the body of the message. - * - * @param body - * An InputStream object that represents the body of - * the message. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setBody(InputStream body) { - this.body = body; - return this; - } - - /** - * Returns the content type of the message. - * - * @return A String object that represents the content type. - */ - public String getContentType() { - return contentType; - } - - /** - * Sets the content type of the message. - * - * @param contentType - * A String object that represents the content type. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Returns the date/time of the message. - * - * @return A Date object that represents the date/time of the - * object. - */ - public Date getDate() { - return date; - } - - /** - * Sets the date/time of the message. - * - * @param date - * A Date object that represents the date/time of the - * object. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setDate(Date date) { - this.date = date; - return this; - } - - /** - * Returns the delivery count of the message. - * - * @return The delivery count. - */ - public Integer getDeliveryCount() { - return properties.getDeliveryCount(); - } - - /** - * Returns the message ID. - * - * @return A String object that represents the message ID. - */ - public String getMessageId() { - return properties.getMessageId(); - } - - /** - * Sets the message ID. - * - * @param messageId - * A String object that represents the message ID. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setMessageId(String messageId) { - properties.setMessageId(messageId); - return this; - } - - /** - * Returns the message sequence number. - * - * @return The message sequence number. - * - */ - public Long getSequenceNumber() { - return properties.getSequenceNumber(); - } - - /** - * Returns the time-to-live for the message. - * - * @return The time, in seconds, for the message to live. - */ - public Double getTimeToLive() { - return properties.getTimeToLive(); - } - - /** - * Sets the time-to-live for the message. - * - * @param timeToLive - * The time, in seconds, for the message to live. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setTimeToLive(Double timeToLive) { - properties.setTimeToLive(timeToLive); - return this; - } - - /** - * Returns the lock token for the message. - * - * @return A String object that represents the lock token. - */ - public String getLockToken() { - return properties.getLockToken(); - } - - /** - * Returns the locked-until date/time. - * - * @return A Date object that represents the locked-until - * date/time, in UTC format. - */ - public Date getLockedUntilUtc() { - return properties.getLockedUntilUtc(); - } - - /** - * Returns the correlation ID. - * - * @return A String object that represents the correlation ID. - * - */ - public String getCorrelationId() { - return properties.getCorrelationId(); - } - - /** - * Sets the correlation ID. - * - * @param correlationId - * A String object that represents the correlation - * ID. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setCorrelationId(String correlationId) { - properties.setCorrelationId(correlationId); - return this; - } - - /** - * Returns the session ID for the message. - * - * @return A String object that represents the session ID. - * - */ - public String getSessionId() { - return properties.getSessionId(); - } - - /** - * Sets the session ID for the message. - * - * @param sessionId - * A String object that represents the session ID. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setSessionId(String sessionId) { - properties.setSessionId(sessionId); - return this; - } - - /** - * Returns the label of the message. - * - * @return A String object that represents the label. - */ - public String getLabel() { - return properties.getLabel(); - } - - /** - * Sets the label of the message. - * - * @param label - * A String object that represents the label. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setLabel(String label) { - properties.setLabel(label); - return this; - } - - /** - * Returns the Reply-To recipient of the message. - * - * @return A String object that represents the Reply-To - * recipient. - */ - public String getReplyTo() { - return properties.getReplyTo(); - } - - /** - * Sets the Reply-To recipient for the message. - * - * @param replyTo - * A String object that represents the Reply-To - * recipient. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setReplyTo(String replyTo) { - properties.setReplyTo(replyTo); - return this; - } - - /** - * Returns the To recipient of the message. - * - * @return A String object that represents the To recipient. - */ - public String getTo() { - return properties.getTo(); - } - - /** - * Sets the To recipient of the message. - * - * @param A - * String object that represents the To recipient. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setTo(String to) { - properties.setTo(to); - return this; - } - - /** - * Returns the scheduled enqueue date/time. - * - * @return A Date object that represents the date/time of the - * message in UTC format. - */ - public Date getScheduledEnqueueTimeUtc() { - return properties.getScheduledEnqueueTimeUtc(); - } - - /** - * Sets the scheduled enqueue time. - * - * @param scheduledEnqueueTimeUtc - * A Date object that represents the date/time of - * the message in UTC format. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { - properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); - return this; - } - - /** - * Returns the session ID of the Reply To recipient. - * - * @return A String object that represents the session ID of - * the Reply To recipient. - */ - public String getReplyToSessionId() { - return properties.getReplyToSessionId(); - } - - /** - * Sets the session ID of the Reply To recipient. - * - * @param replyToSessionId - * A String object that represents the session ID of - * the Reply To recipient. - * - * @return A Message object that reperesents the updated - * message. - */ - public Message setReplyToSessionId(String replyToSessionId) { - properties.setReplyToSessionId(replyToSessionId); - return this; - } - - /** - * Returns the message location. - * - * @return A String object that represents the message - * location. - */ - public String getMessageLocation() { - return properties.getMessageLocation(); - } - - /** - * Returns the lock location. - * - * @return A String object that represents the lock location. - */ - public String getLockLocation() { - return properties.getLockLocation(); - } + BrokerProperties properties; + InputStream body; + String contentType; + Date date; + + /** + * Creates an instance of the Message class. + */ + public Message() { + this.properties = new BrokerProperties(); + } + + /** + * Creates an instance of the Message class using the specified InputStream. + * + * @param body + * An InputStream object that represents the body of + * the message. + */ + public Message(InputStream body) { + this.properties = new BrokerProperties(); + this.body = body; + } + + /** + * Creates an instance of the Message class using the specified + * byte array. + * + * @param body + * A byte array that represents the body of the message. + */ + public Message(byte[] body) { + this.properties = new BrokerProperties(); + this.body = (body == null) ? null : new ByteArrayInputStream(body); + } + + /** + * Creates an instance of the Message class using the specified + * string. + * + * @param body + * A String object that represents the body of the + * message. + */ + public Message(String body) { + this.properties = new BrokerProperties(); + this.body = (body == null) ? null : new ByteArrayInputStream( + body.getBytes()); + } + + Message(BrokerProperties properties, InputStream body) { + this.properties = properties; + this.body = body; + } + + /** + * Returns the properties of the message. + * + * @return A {@link BrokerProperties} object that represents the properties + * of the message. + */ + public BrokerProperties getProperties() { + return properties; + } + + /** + * Sets the properties of the message. + * + * @param properties + * A {@link BrokerProperties} object that represents the + * properties of the message. + */ + public Message setProperties(BrokerProperties properties) { + this.properties = properties; + return this; + } + + /** + * Returns the body of the message. + * + * @return An InputStream object that represents the body of + * the message. + */ + public InputStream getBody() { + return body; + } + + /** + * Specifies the body of the message. + * + * @param body + * An InputStream object that represents the body of + * the message. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setBody(InputStream body) { + this.body = body; + return this; + } + + /** + * Returns the content type of the message. + * + * @return A String object that represents the content type. + */ + public String getContentType() { + return contentType; + } + + /** + * Sets the content type of the message. + * + * @param contentType + * A String object that represents the content type. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Returns the date/time of the message. + * + * @return A Date object that represents the date/time of the + * object. + */ + public Date getDate() { + return date; + } + + /** + * Sets the date/time of the message. + * + * @param date + * A Date object that represents the date/time of the + * object. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setDate(Date date) { + this.date = date; + return this; + } + + /** + * Returns the delivery count of the message. + * + * @return The delivery count. + */ + public Integer getDeliveryCount() { + return properties.getDeliveryCount(); + } + + /** + * Returns the message ID. + * + * @return A String object that represents the message ID. + */ + public String getMessageId() { + return properties.getMessageId(); + } + + /** + * Sets the message ID. + * + * @param messageId + * A String object that represents the message ID. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setMessageId(String messageId) { + properties.setMessageId(messageId); + return this; + } + + /** + * Returns the message sequence number. + * + * @return The message sequence number. + * + */ + public Long getSequenceNumber() { + return properties.getSequenceNumber(); + } + + /** + * Returns the time-to-live for the message. + * + * @return The time, in seconds, for the message to live. + */ + public Double getTimeToLive() { + return properties.getTimeToLive(); + } + + /** + * Sets the time-to-live for the message. + * + * @param timeToLive + * The time, in seconds, for the message to live. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setTimeToLive(Double timeToLive) { + properties.setTimeToLive(timeToLive); + return this; + } + + /** + * Returns the lock token for the message. + * + * @return A String object that represents the lock token. + */ + public String getLockToken() { + return properties.getLockToken(); + } + + /** + * Returns the locked-until date/time. + * + * @return A Date object that represents the locked-until + * date/time, in UTC format. + */ + public Date getLockedUntilUtc() { + return properties.getLockedUntilUtc(); + } + + /** + * Returns the correlation ID. + * + * @return A String object that represents the correlation ID. + * + */ + public String getCorrelationId() { + return properties.getCorrelationId(); + } + + /** + * Sets the correlation ID. + * + * @param correlationId + * A String object that represents the correlation + * ID. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setCorrelationId(String correlationId) { + properties.setCorrelationId(correlationId); + return this; + } + + /** + * Returns the session ID for the message. + * + * @return A String object that represents the session ID. + * + */ + public String getSessionId() { + return properties.getSessionId(); + } + + /** + * Sets the session ID for the message. + * + * @param sessionId + * A String object that represents the session ID. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setSessionId(String sessionId) { + properties.setSessionId(sessionId); + return this; + } + + /** + * Returns the label of the message. + * + * @return A String object that represents the label. + */ + public String getLabel() { + return properties.getLabel(); + } + + /** + * Sets the label of the message. + * + * @param label + * A String object that represents the label. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setLabel(String label) { + properties.setLabel(label); + return this; + } + + /** + * Returns the Reply-To recipient of the message. + * + * @return A String object that represents the Reply-To + * recipient. + */ + public String getReplyTo() { + return properties.getReplyTo(); + } + + /** + * Sets the Reply-To recipient for the message. + * + * @param replyTo + * A String object that represents the Reply-To + * recipient. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setReplyTo(String replyTo) { + properties.setReplyTo(replyTo); + return this; + } + + /** + * Returns the To recipient of the message. + * + * @return A String object that represents the To recipient. + */ + public String getTo() { + return properties.getTo(); + } + + /** + * Sets the To recipient of the message. + * + * @param A + * String object that represents the To recipient. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setTo(String to) { + properties.setTo(to); + return this; + } + + /** + * Returns the scheduled enqueue date/time. + * + * @return A Date object that represents the date/time of the + * message in UTC format. + */ + public Date getScheduledEnqueueTimeUtc() { + return properties.getScheduledEnqueueTimeUtc(); + } + + /** + * Sets the scheduled enqueue time. + * + * @param scheduledEnqueueTimeUtc + * A Date object that represents the date/time of + * the message in UTC format. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { + properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); + return this; + } + + /** + * Returns the session ID of the Reply To recipient. + * + * @return A String object that represents the session ID of + * the Reply To recipient. + */ + public String getReplyToSessionId() { + return properties.getReplyToSessionId(); + } + + /** + * Sets the session ID of the Reply To recipient. + * + * @param replyToSessionId + * A String object that represents the session ID of + * the Reply To recipient. + * + * @return A Message object that reperesents the updated + * message. + */ + public Message setReplyToSessionId(String replyToSessionId) { + properties.setReplyToSessionId(replyToSessionId); + return this; + } + + /** + * Returns the message location. + * + * @return A String object that represents the message + * location. + */ + public String getMessageLocation() { + return properties.getMessageLocation(); + } + + /** + * Returns the lock location. + * + * @return A String object that represents the lock location. + */ + public String getLockLocation() { + return properties.getLockLocation(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java index f380e6d5406d4..dd9143e685418 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java @@ -1,6 +1,5 @@ package com.microsoft.azure.services.serviceBus; - import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; @@ -9,121 +8,120 @@ import com.microsoft.azure.services.serviceBus.implementation.EntryModel; import com.microsoft.azure.services.serviceBus.implementation.QueueDescription; - public class Queue extends EntryModel { - public Queue() { - super(new Entry(), new QueueDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setQueueDescription(getModel()); - } - - public Queue(Entry entry) { - super(entry, entry.getContent().getQueueDescription()); - } - - public Queue(String name) { - this(); - setName(name); - } - - public String getName() { - return getEntry().getTitle(); - } - - public Queue setName(String value) { - getEntry().setTitle(value); - return this; - } - - public Duration getLockDuration() { - return getModel().getLockDuration(); - } - - public Queue setLockDuration(Duration value) { - getModel().setLockDuration(value); - return this; - } - - public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); - } - - public Queue setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); - return this; - } - - public Boolean isRequiresDuplicateDetection() { - return getModel().isRequiresDuplicateDetection(); - } - - public Queue setRequiresDuplicateDetection(Boolean value) { - getModel().setRequiresDuplicateDetection(value); - return this; - } - - public Boolean isRequiresSession() { - return getModel().isRequiresSession(); - } - - public Queue setRequiresSession(Boolean value) { - getModel().setRequiresSession(value); - return this; - } - - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } - - public Queue setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } - - public Boolean isDeadLetteringOnMessageExpiration() { - return getModel().isDeadLetteringOnMessageExpiration(); - } - - public Queue setDeadLetteringOnMessageExpiration(Boolean value) { - getModel().setDeadLetteringOnMessageExpiration(value); - return this; - } - - public Duration getDuplicateDetectionHistoryTimeWindow() { - return getModel().getDuplicateDetectionHistoryTimeWindow(); - } - - public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { - getModel().setDuplicateDetectionHistoryTimeWindow(value); - return this; - } - - public Integer getMaxDeliveryCount() { - return getModel().getMaxDeliveryCount(); - } - - public Queue setMaxDeliveryCount(Integer value) { - getModel().setMaxDeliveryCount(value); - return this; - } - - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } - - public Queue setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } - - public Long getSizeInBytes() { - return getModel().getSizeInBytes(); - } - - public Long getMessageCount() { - return getModel().getMessageCount(); - } + public Queue() { + super(new Entry(), new QueueDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setQueueDescription(getModel()); + } + + public Queue(Entry entry) { + super(entry, entry.getContent().getQueueDescription()); + } + + public Queue(String name) { + this(); + setName(name); + } + + public String getName() { + return getEntry().getTitle(); + } + + public Queue setName(String value) { + getEntry().setTitle(value); + return this; + } + + public Duration getLockDuration() { + return getModel().getLockDuration(); + } + + public Queue setLockDuration(Duration value) { + getModel().setLockDuration(value); + return this; + } + + public Long getMaxSizeInMegabytes() { + return getModel().getMaxSizeInMegabytes(); + } + + public Queue setMaxSizeInMegabytes(Long value) { + getModel().setMaxSizeInMegabytes(value); + return this; + } + + public Boolean isRequiresDuplicateDetection() { + return getModel().isRequiresDuplicateDetection(); + } + + public Queue setRequiresDuplicateDetection(Boolean value) { + getModel().setRequiresDuplicateDetection(value); + return this; + } + + public Boolean isRequiresSession() { + return getModel().isRequiresSession(); + } + + public Queue setRequiresSession(Boolean value) { + getModel().setRequiresSession(value); + return this; + } + + public Duration getDefaultMessageTimeToLive() { + return getModel().getDefaultMessageTimeToLive(); + } + + public Queue setDefaultMessageTimeToLive(Duration value) { + getModel().setDefaultMessageTimeToLive(value); + return this; + } + + public Boolean isDeadLetteringOnMessageExpiration() { + return getModel().isDeadLetteringOnMessageExpiration(); + } + + public Queue setDeadLetteringOnMessageExpiration(Boolean value) { + getModel().setDeadLetteringOnMessageExpiration(value); + return this; + } + + public Duration getDuplicateDetectionHistoryTimeWindow() { + return getModel().getDuplicateDetectionHistoryTimeWindow(); + } + + public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { + getModel().setDuplicateDetectionHistoryTimeWindow(value); + return this; + } + + public Integer getMaxDeliveryCount() { + return getModel().getMaxDeliveryCount(); + } + + public Queue setMaxDeliveryCount(Integer value) { + getModel().setMaxDeliveryCount(value); + return this; + } + + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } + + public Queue setEnableBatchedOperations(Boolean value) { + getModel().setEnableBatchedOperations(value); + return this; + } + + public Long getSizeInBytes() { + return getModel().getSizeInBytes(); + } + + public Long getMessageCount() { + return getModel().getMessageCount(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java index 4c65c64001f0f..e5ff93f511e6f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java @@ -1,46 +1,44 @@ package com.microsoft.azure.services.serviceBus; - public class ReceiveMessageOptions { - Integer timeout; - private ReceiveMode receiveMode = ReceiveMode.RECEIVE_AND_DELETE; - - public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); - - public Integer getTimeout() { - return timeout; - } - - public ReceiveMessageOptions setTimeout(Integer timeout) { - this.timeout = timeout; - return this; - } - - public ReceiveMode getReceiveMode() { - return receiveMode; - } - - public ReceiveMessageOptions setReceiveMode(ReceiveMode receiveMode) { - this.receiveMode = receiveMode; - return this; - } - - public boolean isReceiveAndDelete() { - return receiveMode == ReceiveMode.RECEIVE_AND_DELETE; - } - - public ReceiveMessageOptions setReceiveAndDelete() { - this.receiveMode = ReceiveMode.RECEIVE_AND_DELETE; - return this; - } - - public boolean isPeekLock() { - return receiveMode == ReceiveMode.PEEK_LOCK; - } - - public ReceiveMessageOptions setPeekLock() { - this.receiveMode = ReceiveMode.PEEK_LOCK; - return this; - } + Integer timeout; + private ReceiveMode receiveMode = ReceiveMode.RECEIVE_AND_DELETE; + + public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); + + public Integer getTimeout() { + return timeout; + } + + public ReceiveMessageOptions setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } + + public ReceiveMode getReceiveMode() { + return receiveMode; + } + + public ReceiveMessageOptions setReceiveMode(ReceiveMode receiveMode) { + this.receiveMode = receiveMode; + return this; + } + + public boolean isReceiveAndDelete() { + return receiveMode == ReceiveMode.RECEIVE_AND_DELETE; + } + + public ReceiveMessageOptions setReceiveAndDelete() { + this.receiveMode = ReceiveMode.RECEIVE_AND_DELETE; + return this; + } + + public boolean isPeekLock() { + return receiveMode == ReceiveMode.PEEK_LOCK; + } + + public ReceiveMessageOptions setPeekLock() { + this.receiveMode = ReceiveMode.PEEK_LOCK; + return this; + } } - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java index b96aa03a3835a..fb23bc9e8d536 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java @@ -1,6 +1,6 @@ package com.microsoft.azure.services.serviceBus; public enum ReceiveMode { - PEEK_LOCK, - RECEIVE_AND_DELETE, + PEEK_LOCK, + RECEIVE_AND_DELETE, } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java index c08312370a431..04be04a545130 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java @@ -3,47 +3,48 @@ import com.microsoft.azure.configuration.Configuration; public class ServiceBusConfiguration { - public final static String URI = "serviceBus.uri"; - public final static String WRAP_URI = "serviceBus.wrap.uri"; - public final static String WRAP_NAME = "serviceBus.wrap.name"; - public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; - public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; - - public static Configuration configure( - String namespace, String authenticationName, - String authenticationPassword) { - return configure(null, Configuration.getInstance(), namespace, authenticationName, - authenticationPassword); - } - - public static Configuration configure(Configuration configuration, - String namespace, String authenticationName, - String authenticationPassword) { - return configure(null, configuration, namespace, authenticationName, - authenticationPassword); - } - - public static Configuration configure(String profile, Configuration configuration, - String namespace, String authenticationName, - String authenticationPassword) { - - if (profile == null) { - profile = ""; - } else if (profile.length() != 0 && !profile.endsWith(".")) { - profile = profile + "."; - } - - configuration.setProperty(profile + URI, "https://" + namespace - + ".servicebus.windows.net/"); - - configuration.setProperty(profile + WRAP_URI, "https://" + namespace - + "-sb.accesscontrol.windows.net/WRAPv0.9"); - - configuration.setProperty(profile + WRAP_NAME, authenticationName); - configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); - configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace - + ".servicebus.windows.net/"); - - return configuration; - } + public final static String URI = "serviceBus.uri"; + public final static String WRAP_URI = "serviceBus.wrap.uri"; + public final static String WRAP_NAME = "serviceBus.wrap.name"; + public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; + public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; + + public static Configuration configure( + String namespace, String authenticationName, + String authenticationPassword) { + return configure(null, Configuration.getInstance(), namespace, authenticationName, + authenticationPassword); + } + + public static Configuration configure(Configuration configuration, + String namespace, String authenticationName, + String authenticationPassword) { + return configure(null, configuration, namespace, authenticationName, + authenticationPassword); + } + + public static Configuration configure(String profile, Configuration configuration, + String namespace, String authenticationName, + String authenticationPassword) { + + if (profile == null) { + profile = ""; + } + else if (profile.length() != 0 && !profile.endsWith(".")) { + profile = profile + "."; + } + + configuration.setProperty(profile + URI, "https://" + namespace + + ".servicebus.windows.net/"); + + configuration.setProperty(profile + WRAP_URI, "https://" + namespace + + "-sb.accesscontrol.windows.net/WRAPv0.9"); + + configuration.setProperty(profile + WRAP_NAME, authenticationName); + configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); + configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace + + ".servicebus.windows.net/"); + + return configuration; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java index ed50f91c73e8f..4992a15bd2f46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java @@ -6,39 +6,54 @@ import com.microsoft.azure.ServiceException; - public interface ServiceBusContract { - ServiceBusContract withFilter(ServiceFilter filter); - - void sendQueueMessage(String queueName, Message message) throws ServiceException; - Message receiveQueueMessage(String queueName) throws ServiceException; - Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; - - void sendTopicMessage(String topicName, Message message) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; - - void unlockMessage(Message message) throws ServiceException; - void deleteMessage(Message message) throws ServiceException; - - Queue createQueue(Queue queue) throws ServiceException; - void deleteQueue(String queueName) throws ServiceException; - Queue getQueue(String queueName) throws ServiceException; - ListQueuesResult listQueues() throws ServiceException; - - Topic createTopic(Topic topic) throws ServiceException; - void deleteTopic(String topicName) throws ServiceException; - Topic getTopic(String topicName) throws ServiceException; - ListTopicsResult listTopics() throws ServiceException; - - void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; - void removeSubscription(String topicName, String subscriptionName) throws ServiceException; - Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; - Feed getSubscriptions(String topicName) throws ServiceException; - - void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; - void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Feed getRules(String topicName, String subscriptionName) throws ServiceException; -} + ServiceBusContract withFilter(ServiceFilter filter); + + void sendQueueMessage(String queueName, Message message) throws ServiceException; + + Message receiveQueueMessage(String queueName) throws ServiceException; + + Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + + void sendTopicMessage(String topicName, Message message) throws ServiceException; + + Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; + + Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; + + void unlockMessage(Message message) throws ServiceException; + + void deleteMessage(Message message) throws ServiceException; + + Queue createQueue(Queue queue) throws ServiceException; + + void deleteQueue(String queueName) throws ServiceException; + + Queue getQueue(String queueName) throws ServiceException; + ListQueuesResult listQueues() throws ServiceException; + + Topic createTopic(Topic topic) throws ServiceException; + + void deleteTopic(String topicName) throws ServiceException; + + Topic getTopic(String topicName) throws ServiceException; + + ListTopicsResult listTopics() throws ServiceException; + + void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; + + void removeSubscription(String topicName, String subscriptionName) throws ServiceException; + + Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; + + Feed getSubscriptions(String topicName) throws ServiceException; + + void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; + + void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + + Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + + Feed getRules(String topicName, String subscriptionName) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index 145aeeb3003d6..b65686c6ade3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -10,141 +10,141 @@ import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; public class ServiceBusService implements ServiceBusContract { - final ServiceBusContract next; - - public ServiceBusService() throws Exception { - this(null, Configuration.getInstance()); - } - - public ServiceBusService(Configuration config) throws Exception { - this(null, config); - } - - public ServiceBusService(String profile) throws Exception { - this(profile, Configuration.getInstance()); - } - - public ServiceBusService(String profile, Configuration config) throws Exception { - next = config.create(profile, ServiceBusService.class); - } - - @Inject - public ServiceBusService(ServiceBusContract next) throws Exception { - this.next = next; - } - - public ServiceBusContract withFilter(ServiceFilter filter) { - return next.withFilter(filter); - } - - public void sendQueueMessage(String queueName, Message message) - throws ServiceException { - next.sendQueueMessage(queueName, message); - } - - public Message receiveQueueMessage(String queueName) - throws ServiceException { - return next.receiveQueueMessage(queueName); - } - - public Message receiveQueueMessage(String queueName, - ReceiveMessageOptions options) throws ServiceException { - return next.receiveQueueMessage(queueName, options); - } - - public void sendTopicMessage(String topicName, Message message) - throws ServiceException { - next.sendTopicMessage(topicName, message); - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { - return next.receiveSubscriptionMessage(topicName, subscriptionName); - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - return next.receiveSubscriptionMessage(topicName, subscriptionName, - options); - } - - public void unlockMessage(Message message) throws ServiceException { - next.unlockMessage(message); - } - - public void deleteMessage(Message message) throws ServiceException { - next.deleteMessage(message); - } - - public Queue createQueue(Queue queue) throws ServiceException { - return next.createQueue(queue); - } - - public void deleteQueue(String queueName) throws ServiceException { - next.deleteQueue(queueName); - } - - public Queue getQueue(String queueName) throws ServiceException { - return next.getQueue(queueName); - } - - public ListQueuesResult listQueues() throws ServiceException { - return next.listQueues(); - } - - public Topic createTopic(Topic topic) throws ServiceException { - return next.createTopic(topic); - } - - public void deleteTopic(String topicName) throws ServiceException { - next.deleteTopic(topicName); - } - - public Topic getTopic(String topicName) throws ServiceException { - return next.getTopic(topicName); - } - - public ListTopicsResult listTopics() throws ServiceException { - return next.listTopics(); - } - - public void addSubscription(String topicName, String subscriptionName, - Entry subscription) throws ServiceException { - next.addSubscription(topicName, subscriptionName, subscription); - } - - public void removeSubscription(String topicName, String subscriptionName) - throws ServiceException { - next.removeSubscription(topicName, subscriptionName); - } - - public Entry getSubscription(String topicName, String subscriptionName) - throws ServiceException { - return next.getSubscription(topicName, subscriptionName); - } - - public Feed getSubscriptions(String topicName) throws ServiceException { - return next.getSubscriptions(topicName); - } - - public void addRule(String topicName, String subscriptionName, - String ruleName, Entry rule) throws ServiceException { - next.addRule(topicName, subscriptionName, ruleName, rule); - } - - public void removeRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { - next.removeRule(topicName, subscriptionName, ruleName); - } - - public Entry getRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { - return next.getRule(topicName, subscriptionName, ruleName); - } - - public Feed getRules(String topicName, String subscriptionName) - throws ServiceException { - return next.getRules(topicName, subscriptionName); - } + final ServiceBusContract next; + + public ServiceBusService() throws Exception { + this(null, Configuration.getInstance()); + } + + public ServiceBusService(Configuration config) throws Exception { + this(null, config); + } + + public ServiceBusService(String profile) throws Exception { + this(profile, Configuration.getInstance()); + } + + public ServiceBusService(String profile, Configuration config) throws Exception { + next = config.create(profile, ServiceBusService.class); + } + + @Inject + public ServiceBusService(ServiceBusContract next) throws Exception { + this.next = next; + } + + public ServiceBusContract withFilter(ServiceFilter filter) { + return next.withFilter(filter); + } + + public void sendQueueMessage(String queueName, Message message) + throws ServiceException { + next.sendQueueMessage(queueName, message); + } + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return next.receiveQueueMessage(queueName); + } + + public Message receiveQueueMessage(String queueName, + ReceiveMessageOptions options) throws ServiceException { + return next.receiveQueueMessage(queueName, options); + } + + public void sendTopicMessage(String topicName, Message message) + throws ServiceException { + next.sendTopicMessage(topicName, message); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + return next.receiveSubscriptionMessage(topicName, subscriptionName); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + return next.receiveSubscriptionMessage(topicName, subscriptionName, + options); + } + + public void unlockMessage(Message message) throws ServiceException { + next.unlockMessage(message); + } + + public void deleteMessage(Message message) throws ServiceException { + next.deleteMessage(message); + } + + public Queue createQueue(Queue queue) throws ServiceException { + return next.createQueue(queue); + } + + public void deleteQueue(String queueName) throws ServiceException { + next.deleteQueue(queueName); + } + + public Queue getQueue(String queueName) throws ServiceException { + return next.getQueue(queueName); + } + + public ListQueuesResult listQueues() throws ServiceException { + return next.listQueues(); + } + + public Topic createTopic(Topic topic) throws ServiceException { + return next.createTopic(topic); + } + + public void deleteTopic(String topicName) throws ServiceException { + next.deleteTopic(topicName); + } + + public Topic getTopic(String topicName) throws ServiceException { + return next.getTopic(topicName); + } + + public ListTopicsResult listTopics() throws ServiceException { + return next.listTopics(); + } + + public void addSubscription(String topicName, String subscriptionName, + Entry subscription) throws ServiceException { + next.addSubscription(topicName, subscriptionName, subscription); + } + + public void removeSubscription(String topicName, String subscriptionName) + throws ServiceException { + next.removeSubscription(topicName, subscriptionName); + } + + public Entry getSubscription(String topicName, String subscriptionName) + throws ServiceException { + return next.getSubscription(topicName, subscriptionName); + } + + public Feed getSubscriptions(String topicName) throws ServiceException { + return next.getSubscriptions(topicName); + } + + public void addRule(String topicName, String subscriptionName, + String ruleName, Entry rule) throws ServiceException { + next.addRule(topicName, subscriptionName, ruleName, rule); + } + + public void removeRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + next.removeRule(topicName, subscriptionName, ruleName); + } + + public Entry getRule(String topicName, String subscriptionName, + String ruleName) throws ServiceException { + return next.getRule(topicName, subscriptionName, ruleName); + } + + public Feed getRules(String topicName, String subscriptionName) + throws ServiceException { + return next.getRules(topicName, subscriptionName); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java index faafbbf5ee33e..892d3d98c28de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java @@ -7,9 +7,9 @@ public class Subscription extends EntryModel { - public Subscription(Entry entry, SubscriptionDescription model) { - super(entry, model); - // TODO Auto-generated constructor stub - } + public Subscription(Entry entry, SubscriptionDescription model) { + super(entry, model); + // TODO Auto-generated constructor stub + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java index 814388af750e8..79dcd8bb07247 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java @@ -8,24 +8,23 @@ import com.microsoft.azure.services.serviceBus.implementation.TopicDescription; public class Topic extends EntryModel { - public Topic() { - super(new Entry(), new TopicDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setTopicDescription(getModel()); - } + public Topic() { + super(new Entry(), new TopicDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setTopicDescription(getModel()); + } - public Topic(Entry entry) { - super(entry, entry.getContent().getTopicDescription()); - } + public Topic(Entry entry) { + super(entry, entry.getContent().getTopicDescription()); + } + public String getName() { + return getEntry().getTitle(); + } - public String getName() { - return getEntry().getTitle(); - } - - public Topic setName(String value) { - getEntry().setTitle(value); - return this; - } + public Topic setName(String value) { + getEntry().setTitle(value); + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java index 06383c34d9216..4bd2bcaa0c810 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java @@ -3,15 +3,15 @@ import com.microsoft.azure.ServiceException; public class Util { - public static Iterable iterateQueues(ServiceBusContract service) - throws ServiceException { - // TODO: iterate over link rel=next pagination - return service.listQueues().getItems(); - } + public static Iterable iterateQueues(ServiceBusContract service) + throws ServiceException { + // TODO: iterate over link rel=next pagination + return service.listQueues().getItems(); + } - public static Iterable iterateTopics(ServiceBusContract service) - throws ServiceException { - // TODO: iterate over link rel=next pagination - return service.listTopics().getItems(); - } + public static Iterable iterateTopics(ServiceBusContract service) + throws ServiceException { + // TODO: iterate over link rel=next pagination + return service.listTopics().getItems(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java index 01462469283db..9ada6e000f9a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java @@ -4,10 +4,12 @@ import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; - public interface MessageReceiver { - Message receiveMessage() throws ServiceException; - Message receiveMessage(ReceiveMessageOptions options) throws ServiceException; - void unlockMessage(Message message) throws ServiceException; - void deleteMessage(Message message) throws ServiceException; + Message receiveMessage() throws ServiceException; + + Message receiveMessage(ReceiveMessageOptions options) throws ServiceException; + + void unlockMessage(Message message) throws ServiceException; + + void deleteMessage(Message message) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java index f710502261215..d388625d33a7d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java @@ -3,7 +3,6 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.Message; - public interface MessageSender { - void sendMessage(Message message) throws ServiceException; + void sendMessage(Message message) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java index 253fc046a8949..6bded3cb6b0a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java @@ -1,4 +1,3 @@ - package com.microsoft.azure.services.serviceBus.client; public interface MessageTransceiver extends MessageSender, MessageReceiver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java index dee490dff226b..e19f3c1c234f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -10,97 +10,96 @@ import com.microsoft.azure.services.serviceBus.ServiceBusContract; public class MessagingClient { - private ServiceBusContract service; - - - public MessagingClient() throws Exception { - this.setService(Configuration.load().create(ServiceBusContract.class)); - } - - public MessagingClient(String profile) throws Exception { - this.setService(Configuration.load().create(profile, ServiceBusContract.class)); - } - - public MessagingClient(Configuration configuration) throws Exception { - this.setService(configuration.create(ServiceBusContract.class)); - } - - public MessagingClient(String profile, Configuration configuration) throws Exception { - this.setService(configuration.create(profile, ServiceBusContract.class)); - } - - @Inject - public MessagingClient(ServiceBusContract service) { - this.setService(service); - } - - public void setService(ServiceBusContract service) { - this.service = service; - } - - public ServiceBusContract getService() { - return service; - } - - public MessageTransceiver openQueue(String queueName) { - final String queue = queueName; - return new MessageTransceiver() { - - public void sendMessage(Message message) throws ServiceException { - service.sendQueueMessage(queue, message); - } - - public Message receiveMessage() throws ServiceException { - return receiveMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message receiveMessage(ReceiveMessageOptions options) - throws ServiceException { - return service.receiveQueueMessage(queue, options); - } - - public void unlockMessage(Message message) throws ServiceException { - service.unlockMessage(message); - } - - public void deleteMessage(Message message) - throws ServiceException { - service.deleteMessage(message); - } - }; - } - - public MessageSender openTopic(String topicName) { - final String topic = topicName; - return new MessageSender() { - public void sendMessage(Message message) throws ServiceException { - service.sendQueueMessage(topic, message); - } - }; - } - - public MessageReceiver openSubscription(String topicName, String subscriptionName) { - final String topic = topicName; - final String subscription = subscriptionName; - return new MessageReceiver() { - - public Message receiveMessage() throws ServiceException { - return receiveMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message receiveMessage(ReceiveMessageOptions options) - throws ServiceException { - return service.receiveSubscriptionMessage(topic, subscription, options); - } - - public void unlockMessage(Message message) throws ServiceException { - service.unlockMessage(message); - } - - public void deleteMessage(Message message) - throws ServiceException { - service.deleteMessage(message); - } - }; - } + private ServiceBusContract service; + + public MessagingClient() throws Exception { + this.setService(Configuration.load().create(ServiceBusContract.class)); + } + + public MessagingClient(String profile) throws Exception { + this.setService(Configuration.load().create(profile, ServiceBusContract.class)); + } + + public MessagingClient(Configuration configuration) throws Exception { + this.setService(configuration.create(ServiceBusContract.class)); + } + + public MessagingClient(String profile, Configuration configuration) throws Exception { + this.setService(configuration.create(profile, ServiceBusContract.class)); + } + + @Inject + public MessagingClient(ServiceBusContract service) { + this.setService(service); + } + + public void setService(ServiceBusContract service) { + this.service = service; + } + + public ServiceBusContract getService() { + return service; + } + + public MessageTransceiver openQueue(String queueName) { + final String queue = queueName; + return new MessageTransceiver() { + + public void sendMessage(Message message) throws ServiceException { + service.sendQueueMessage(queue, message); + } + + public Message receiveMessage() throws ServiceException { + return receiveMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message receiveMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveQueueMessage(queue, options); + } + + public void unlockMessage(Message message) throws ServiceException { + service.unlockMessage(message); + } + + public void deleteMessage(Message message) + throws ServiceException { + service.deleteMessage(message); + } + }; + } + + public MessageSender openTopic(String topicName) { + final String topic = topicName; + return new MessageSender() { + public void sendMessage(Message message) throws ServiceException { + service.sendQueueMessage(topic, message); + } + }; + } + + public MessageReceiver openSubscription(String topicName, String subscriptionName) { + final String topic = topicName; + final String subscription = subscriptionName; + return new MessageReceiver() { + + public Message receiveMessage() throws ServiceException { + return receiveMessage(ReceiveMessageOptions.DEFAULT); + } + + public Message receiveMessage(ReceiveMessageOptions options) + throws ServiceException { + return service.receiveSubscriptionMessage(topic, subscription, options); + } + + public void unlockMessage(Message message) throws ServiceException { + service.unlockMessage(message); + } + + public void deleteMessage(Message message) + throws ServiceException { + service.deleteMessage(message); + } + }; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java index 860e788ffc981..83fffa7ad2987 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java @@ -8,197 +8,193 @@ import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonWriteNullProperties; - // // members of this class defined per specification at // http://msdn.microsoft.com/en-us/library/windowsazure/hh367521.aspx#BKMK_REST3prod // -@JsonIgnoreProperties(ignoreUnknown=true) +@JsonIgnoreProperties(ignoreUnknown = true) @JsonWriteNullProperties(false) public class BrokerProperties { - @JsonProperty("CorrelationId") - String correlationId; - - @JsonProperty("SessionId") - String sessionId; - - @JsonProperty("DeliveryCount") - Integer deliveryCount; - - @JsonProperty("LockedUntilUtc") - Date lockedUntilUtc; - - @JsonProperty("LockToken") - String lockToken; - - @JsonProperty("MessageId") - String messageId; - - @JsonProperty("Label") - String label; - - @JsonProperty("ReplyTo") - String replyTo; - - @JsonProperty("SequenceNumber") - Long sequenceNumber; - - @JsonProperty("TimeToLive") - Double timeToLive; - - @JsonProperty("To") - String to; - - @JsonProperty("ScheduledEnqueueTimeUtc") - Date scheduledEnqueueTimeUtc; - - @JsonProperty("ReplyToSessionId") - String replyToSessionId; - - @JsonProperty("MessageLocation") - String messageLocation; - - @JsonProperty("LockLocation") - String lockLocation; - - - - @JsonIgnore - public Integer getDeliveryCount() { - return deliveryCount; - } - - public void setDeliveryCount(Integer deliveryCount) { - this.deliveryCount = deliveryCount; - } - - @JsonIgnore - public String getMessageId() { - return messageId; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @JsonIgnore - public Long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - @JsonIgnore - public Double getTimeToLive() { - return timeToLive; - } - - public void setTimeToLive(Double timeToLive) { - this.timeToLive = timeToLive; - } - - @JsonIgnore - public String getLockToken() { - return lockToken; - } - - public void setLockToken(String lockToken) { - this.lockToken = lockToken; - } - - @JsonIgnore - public Date getLockedUntilUtc() { - return lockedUntilUtc; - } - - public void setLockedUntilUtc(Date lockedUntilUtc) { - this.lockedUntilUtc = lockedUntilUtc; - } - - @JsonIgnore - public String getCorrelationId() { - return correlationId; - } - - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - @JsonIgnore - public String getSessionId() { - return sessionId; - } - - public void setSessionId(String sessionId) { - this.sessionId = sessionId; - } - - @JsonIgnore - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - @JsonIgnore - public String getReplyTo() { - return replyTo; - } - - public void setReplyTo(String replyTo) { - this.replyTo = replyTo; - } - - @JsonIgnore - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - @JsonIgnore - public Date getScheduledEnqueueTimeUtc() { - return scheduledEnqueueTimeUtc; - } - - public void setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { - this.scheduledEnqueueTimeUtc = scheduledEnqueueTimeUtc; - } - - @JsonIgnore - public String getReplyToSessionId() { - return replyToSessionId; - } - - public void setReplyToSessionId(String replyToSessionId) { - this.replyToSessionId = replyToSessionId; - } - - @JsonIgnore - public String getMessageLocation() { - return messageLocation; - } - - public void setMessageLocation(String messageLocation) { - this.messageLocation = messageLocation; - } - - @JsonIgnore - public String getLockLocation() { - return lockLocation; - } - - public void setLockLocation(String lockLocation) { - this.lockLocation = lockLocation; - } - - + @JsonProperty("CorrelationId") + String correlationId; + + @JsonProperty("SessionId") + String sessionId; + + @JsonProperty("DeliveryCount") + Integer deliveryCount; + + @JsonProperty("LockedUntilUtc") + Date lockedUntilUtc; + + @JsonProperty("LockToken") + String lockToken; + + @JsonProperty("MessageId") + String messageId; + + @JsonProperty("Label") + String label; + + @JsonProperty("ReplyTo") + String replyTo; + + @JsonProperty("SequenceNumber") + Long sequenceNumber; + + @JsonProperty("TimeToLive") + Double timeToLive; + + @JsonProperty("To") + String to; + + @JsonProperty("ScheduledEnqueueTimeUtc") + Date scheduledEnqueueTimeUtc; + + @JsonProperty("ReplyToSessionId") + String replyToSessionId; + + @JsonProperty("MessageLocation") + String messageLocation; + + @JsonProperty("LockLocation") + String lockLocation; + + @JsonIgnore + public Integer getDeliveryCount() { + return deliveryCount; + } + + public void setDeliveryCount(Integer deliveryCount) { + this.deliveryCount = deliveryCount; + } + + @JsonIgnore + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + @JsonIgnore + public Long getSequenceNumber() { + return sequenceNumber; + } + + public void setSequenceNumber(Long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + @JsonIgnore + public Double getTimeToLive() { + return timeToLive; + } + + public void setTimeToLive(Double timeToLive) { + this.timeToLive = timeToLive; + } + + @JsonIgnore + public String getLockToken() { + return lockToken; + } + + public void setLockToken(String lockToken) { + this.lockToken = lockToken; + } + + @JsonIgnore + public Date getLockedUntilUtc() { + return lockedUntilUtc; + } + + public void setLockedUntilUtc(Date lockedUntilUtc) { + this.lockedUntilUtc = lockedUntilUtc; + } + + @JsonIgnore + public String getCorrelationId() { + return correlationId; + } + + public void setCorrelationId(String correlationId) { + this.correlationId = correlationId; + } + + @JsonIgnore + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + @JsonIgnore + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @JsonIgnore + public String getReplyTo() { + return replyTo; + } + + public void setReplyTo(String replyTo) { + this.replyTo = replyTo; + } + + @JsonIgnore + public String getTo() { + return to; + } + + public void setTo(String to) { + this.to = to; + } + + @JsonIgnore + public Date getScheduledEnqueueTimeUtc() { + return scheduledEnqueueTimeUtc; + } + + public void setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { + this.scheduledEnqueueTimeUtc = scheduledEnqueueTimeUtc; + } + + @JsonIgnore + public String getReplyToSessionId() { + return replyToSessionId; + } + + public void setReplyToSessionId(String replyToSessionId) { + this.replyToSessionId = replyToSessionId; + } + + @JsonIgnore + public String getMessageLocation() { + return messageLocation; + } + + public void setMessageLocation(String messageLocation) { + this.messageLocation = messageLocation; + } + + @JsonIgnore + public String getLockLocation() { + return lockLocation; + } + + public void setLockLocation(String lockLocation) { + this.lockLocation = lockLocation; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java index 69e6a13a09480..e1a59b142336d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -9,48 +9,53 @@ import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; +public class BrokerPropertiesMapper { -public class BrokerPropertiesMapper { + public BrokerProperties fromString(String value) + throws IllegalArgumentException { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.readValue(value.getBytes(), BrokerProperties.class); + } + catch (JsonParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + } - public BrokerProperties fromString(String value) - throws IllegalArgumentException { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.readValue(value.getBytes(), BrokerProperties.class); - } catch (JsonParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } - } - - public String toString(BrokerProperties value) { - ObjectMapper mapper = new ObjectMapper(); - Writer writer = new StringWriter(); - try { - mapper.writeValue(writer, value); - } catch (JsonGenerationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } - return writer.toString(); - } + public String toString(BrokerProperties value) { + ObjectMapper mapper = new ObjectMapper(); + Writer writer = new StringWriter(); + try { + mapper.writeValue(writer, value); + } + catch (JsonGenerationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (JsonMappingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + return writer.toString(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java index 57abc5cc9cb49..c59d75de0b59b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java @@ -3,27 +3,27 @@ import com.microsoft.azure.services.serviceBus.implementation.Entry; public class EntryModel { - Entry entry; - T model; + Entry entry; + T model; - public EntryModel(Entry entry, T model) { - this.entry = entry; - this.model = model; - } + public EntryModel(Entry entry, T model) { + this.entry = entry; + this.model = model; + } - public Entry getEntry() { - return entry; - } + public Entry getEntry() { + return entry; + } - public void setEntry(Entry entry) { - this.entry = entry; - } + public void setEntry(Entry entry) { + this.entry = entry; + } - public T getModel() { - return model; - } + public T getModel() { + return model; + } - public void setModel(T model) { - this.model = model; - } + public void setModel(T model) { + this.model = model; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java index 07473beb8c48a..c7ccce52c0230 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java @@ -19,62 +19,66 @@ import com.sun.jersey.spi.MessageBodyWorkers; public class EntryModelProvider extends - AbstractMessageReaderWriterProvider> { - - MessageBodyWorkers workers; - - public EntryModelProvider(@Context MessageBodyWorkers workers) { - this.workers = workers; - } - - public boolean isReadable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { - return EntryModel.class.isAssignableFrom(type); - } - - public EntryModel readFrom(Class> type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { - - MessageBodyReader reader = workers.getMessageBodyReader( - Entry.class, Entry.class, annotations, mediaType); - - Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, - mediaType, httpHeaders, entityStream); - - // these exceptions are masked as a RuntimeException because they cannot - // be thrown by this override - try { - return type.getConstructor(Entry.class).newInstance(entry); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } - } - - public boolean isWriteable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { - return EntryModel.class.isAssignableFrom(type); - } - - public void writeTo(EntryModel t, Class type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, - OutputStream entityStream) throws IOException, - WebApplicationException { - - Entry entry = t.getEntry(); - - MessageBodyWriter writer = workers.getMessageBodyWriter( - Entry.class, Entry.class, annotations, mediaType); - - writer.writeTo(entry, Entry.class, genericType, annotations, mediaType, httpHeaders, entityStream); - } + AbstractMessageReaderWriterProvider> { + + MessageBodyWorkers workers; + + public EntryModelProvider(@Context MessageBodyWorkers workers) { + this.workers = workers; + } + + public boolean isReadable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return EntryModel.class.isAssignableFrom(type); + } + + public EntryModel readFrom(Class> type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + MessageBodyReader reader = workers.getMessageBodyReader( + Entry.class, Entry.class, annotations, mediaType); + + Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, + mediaType, httpHeaders, entityStream); + + // these exceptions are masked as a RuntimeException because they cannot + // be thrown by this override + try { + return type.getConstructor(Entry.class).newInstance(entry); + } + catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + catch (InstantiationException e) { + throw new RuntimeException(e); + } + } + + public boolean isWriteable(Class type, Type genericType, + Annotation[] annotations, MediaType mediaType) { + return EntryModel.class.isAssignableFrom(type); + } + + public void writeTo(EntryModel t, Class type, Type genericType, + Annotation[] annotations, MediaType mediaType, + MultivaluedMap httpHeaders, + OutputStream entityStream) throws IOException, + WebApplicationException { + + Entry entry = t.getEntry(); + + MessageBodyWriter writer = workers.getMessageBodyWriter( + Entry.class, Entry.class, annotations, mediaType); + + writer.writeTo(entry, Entry.class, genericType, annotations, mediaType, httpHeaders, entityStream); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java index 783ba5ab9dcd0..4bc43498df63e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java @@ -9,47 +9,49 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.PropertyException; - @Provider @Produces("application/atom+xml") public class MarshallerProvider implements ContextResolver { - @Context - private ContextResolver jaxbContextResolver; - - public Marshaller getContext(Class type) { - Marshaller marshaller; - try { - marshaller = getJAXBContext(type).createMarshaller(); - } catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); - try { - marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); - } catch (PropertyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - return marshaller; - } + @Context + private ContextResolver jaxbContextResolver; + + public Marshaller getContext(Class type) { + Marshaller marshaller; + try { + marshaller = getJAXBContext(type).createMarshaller(); + } + catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); + try { + marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); + } + catch (PropertyException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + return marshaller; + } - private JAXBContext getJAXBContext(Class type) throws Exception { - JAXBContext context = null; - if (jaxbContextResolver != null){ - context = jaxbContextResolver.getContext(type); - } - if (context == null){ - context = JAXBContext.newInstance(type); - } - return context; - } + private JAXBContext getJAXBContext(Class type) throws Exception { + JAXBContext context = null; + if (jaxbContextResolver != null) { + context = jaxbContextResolver.getContext(type); + } + if (context == null) { + context = JAXBContext.newInstance(type); + } + return context; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java index c2f9762642103..751c8d89c6e7e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java @@ -4,15 +4,15 @@ public class NamespacePrefixMapperImpl extends NamespacePrefixMapper { - @Override - public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { - if (namespaceUri == "http://www.w3.org/2005/Atom") { - return "atom"; - } - else if (namespaceUri == "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect") { - return ""; - } - return suggestion; - } + @Override + public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { + if (namespaceUri == "http://www.w3.org/2005/Atom") { + return "atom"; + } + else if (namespaceUri == "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect") { + return ""; + } + return suggestion; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 0821cab80d977..5887fd70ddb58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -20,308 +20,329 @@ public class ServiceBusExceptionProcessor implements ServiceBusContract { - private ServiceBusContract next; - static Log log = LogFactory.getLog(ServiceBusContract.class); - - public ServiceBusExceptionProcessor(ServiceBusContract next) { - this.next = next; - } - - @Inject - public ServiceBusExceptionProcessor(ServiceBusRestProxy next) - { - this.next = next; - } - - public ServiceBusContract withFilter(ServiceFilter filter) { - return new ServiceBusExceptionProcessor(next.withFilter(filter)); - } - - - private ServiceException processCatch(ServiceException e) { - log.warn(e.getMessage(), e.getCause()); - return ServiceExceptionFactory.process("serviceBus", e); - } - - - public void sendQueueMessage(String path, Message message) - throws ServiceException { - try { - next.sendQueueMessage(path, message); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Message receiveQueueMessage(String queueName) - throws ServiceException { - try { - return next.receiveQueueMessage(queueName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Message receiveQueueMessage(String queueName, - ReceiveMessageOptions options) throws ServiceException { - try { - return next.receiveQueueMessage(queueName, options); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void sendTopicMessage(String path, Message message) - throws ServiceException { - try { - next.sendTopicMessage(path, message); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { - try { - return next.receiveSubscriptionMessage(topicName, - subscriptionName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - try { - return next.receiveSubscriptionMessage(topicName, - subscriptionName, options); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void unlockMessage(Message message) throws ServiceException { - try { - next.unlockMessage(message); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void deleteMessage(Message message) throws ServiceException { - try { - next.deleteMessage(message); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Queue createQueue(Queue queue) throws ServiceException { - try { - return next.createQueue(queue); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void deleteQueue(String queuePath) throws ServiceException { - try { - next.deleteQueue(queuePath); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Queue getQueue(String queuePath) throws ServiceException { - try { - return next.getQueue(queuePath); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public ListQueuesResult listQueues() throws ServiceException { - try { - return next.listQueues(); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Topic createTopic(Topic topic) throws ServiceException { - try { - return next.createTopic(topic); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void deleteTopic(String topicPath) throws ServiceException { - try { - next.deleteTopic(topicPath); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Topic getTopic(String topicPath) throws ServiceException { - try { - return next.getTopic(topicPath); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public ListTopicsResult listTopics() throws ServiceException { - try { - return next.listTopics(); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void addSubscription(String topicPath, String subscriptionName, - Entry subscription) throws ServiceException { - try { - next.addSubscription(topicPath, subscriptionName, subscription); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void removeSubscription(String topicPath, String subscriptionName) - throws ServiceException { - try { - next.removeSubscription(topicPath, subscriptionName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Entry getSubscription(String topicPath, String subscriptionName) - throws ServiceException { - try { - return next.getSubscription(topicPath, subscriptionName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Feed getSubscriptions(String topicPath) throws ServiceException { - try { - return next.getSubscriptions(topicPath); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void addRule(String topicPath, String subscriptionName, - String ruleName, Entry rule) throws ServiceException { - try { - next.addRule(topicPath, subscriptionName, ruleName, rule); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public void removeRule(String topicPath, String subscriptionName, - String ruleName) throws ServiceException { - try { - next.removeRule(topicPath, subscriptionName, ruleName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Entry getRule(String topicPath, String subscriptionName, - String ruleName) throws ServiceException { - try { - return next.getRule(topicPath, subscriptionName, ruleName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - - public Feed getRules(String topicPath, String subscriptionName) - throws ServiceException { - try { - return next.getRules(topicPath, subscriptionName); - } catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - + private ServiceBusContract next; + static Log log = LogFactory.getLog(ServiceBusContract.class); + + public ServiceBusExceptionProcessor(ServiceBusContract next) { + this.next = next; + } + + @Inject + public ServiceBusExceptionProcessor(ServiceBusRestProxy next) { + this.next = next; + } + + public ServiceBusContract withFilter(ServiceFilter filter) { + return new ServiceBusExceptionProcessor(next.withFilter(filter)); + } + + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("serviceBus", e); + } + + public void sendQueueMessage(String path, Message message) + throws ServiceException { + try { + next.sendQueueMessage(path, message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + try { + return next.receiveQueueMessage(queueName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Message receiveQueueMessage(String queueName, + ReceiveMessageOptions options) throws ServiceException { + try { + return next.receiveQueueMessage(queueName, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void sendTopicMessage(String path, Message message) + throws ServiceException { + try { + next.sendTopicMessage(path, message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + try { + return next.receiveSubscriptionMessage(topicName, + subscriptionName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + try { + return next.receiveSubscriptionMessage(topicName, + subscriptionName, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void unlockMessage(Message message) throws ServiceException { + try { + next.unlockMessage(message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteMessage(Message message) throws ServiceException { + try { + next.deleteMessage(message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Queue createQueue(Queue queue) throws ServiceException { + try { + return next.createQueue(queue); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteQueue(String queuePath) throws ServiceException { + try { + next.deleteQueue(queuePath); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Queue getQueue(String queuePath) throws ServiceException { + try { + return next.getQueue(queuePath); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListQueuesResult listQueues() throws ServiceException { + try { + return next.listQueues(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Topic createTopic(Topic topic) throws ServiceException { + try { + return next.createTopic(topic); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void deleteTopic(String topicPath) throws ServiceException { + try { + next.deleteTopic(topicPath); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Topic getTopic(String topicPath) throws ServiceException { + try { + return next.getTopic(topicPath); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListTopicsResult listTopics() throws ServiceException { + try { + return next.listTopics(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void addSubscription(String topicPath, String subscriptionName, + Entry subscription) throws ServiceException { + try { + next.addSubscription(topicPath, subscriptionName, subscription); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void removeSubscription(String topicPath, String subscriptionName) + throws ServiceException { + try { + next.removeSubscription(topicPath, subscriptionName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Entry getSubscription(String topicPath, String subscriptionName) + throws ServiceException { + try { + return next.getSubscription(topicPath, subscriptionName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Feed getSubscriptions(String topicPath) throws ServiceException { + try { + return next.getSubscriptions(topicPath); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void addRule(String topicPath, String subscriptionName, + String ruleName, Entry rule) throws ServiceException { + try { + next.addRule(topicPath, subscriptionName, ruleName, rule); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public void removeRule(String topicPath, String subscriptionName, + String ruleName) throws ServiceException { + try { + next.removeRule(topicPath, subscriptionName, ruleName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Entry getRule(String topicPath, String subscriptionName, + String ruleName) throws ServiceException { + try { + return next.getRule(topicPath, subscriptionName, ruleName); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public Feed getRules(String topicPath, String subscriptionName) + throws ServiceException { + try { + return next.getRules(topicPath, subscriptionName); + } + 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/azure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java index 0cdc2f8f4d3f3..555a329582c3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -32,277 +32,262 @@ public class ServiceBusRestProxy implements ServiceBusContract { - private Client channel; - private String uri; - private BrokerPropertiesMapper mapper; - static Log log = LogFactory.getLog(ServiceBusContract.class); - - ServiceFilter[] filters; - - @Inject - public ServiceBusRestProxy( - Client channel, - @Named("serviceBus") WrapFilter authFilter, - @Named("serviceBus.uri") String uri, - BrokerPropertiesMapper mapper) { - - this.channel = channel; - this.filters = new ServiceFilter[0]; - this.uri = uri; - this.mapper = mapper; - channel.addFilter(authFilter); - } - - public ServiceBusRestProxy( - Client channel, - ServiceFilter[] filters, - String uri, - BrokerPropertiesMapper mapper) { - this.channel = channel; - this.filters = filters; - this.uri = uri; - this.mapper = mapper; - } - - public ServiceBusContract withFilter(ServiceFilter filter) { - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new ServiceBusRestProxy(channel, newFilters, uri, mapper); - } - - - public Client getChannel() { - return channel; - } - - public void setChannel(Client channel) { - this.channel = channel; - } - - private WebResource getResource() { - WebResource resource = getChannel() - .resource(uri); - for(ServiceFilter filter : filters) { - resource.addFilter(new ClientFilterAdapter(filter)); - } - return resource; - } - - void sendMessage(String path, Message message) { - Builder request = getResource() - .path(path) - .path("messages") - .getRequestBuilder(); - - if (message.getContentType() != null) - request = request.type(message.getContentType()); - - if (message.getProperties() != null) - request = request.header("BrokerProperties", mapper.toString(message.getProperties())); - - request.post(message.getBody()); - } - - public void sendQueueMessage(String path, Message message) throws ServiceException { - sendMessage(path, message); - } - - public Message receiveQueueMessage(String queueName) - throws ServiceException { - return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); - } - - public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { - - WebResource resource = getResource() - .path(queuePath) - .path("messages") - .path("head"); - - if (options.getTimeout() != null) { - resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); - } - - ClientResponse clientResult; - if (options.isReceiveAndDelete()) { - clientResult = resource.delete(ClientResponse.class); - } - else if (options.isPeekLock()) { - clientResult = resource.post(ClientResponse.class, ""); - } - else { - throw new RuntimeException("Unknown ReceiveMode"); - } - - String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); - String location = clientResult.getHeaders().getFirst("Location"); - MediaType contentType = clientResult.getType(); - Date date = clientResult.getResponseDate(); - - - Message result = new Message(); - if (brokerProperties != null) - { - result.setProperties(mapper.fromString(brokerProperties)); - } - if (contentType != null) - { - result.setContentType(contentType.toString()); - } - if (location != null) - { - result.getProperties().setLockLocation(location); - } - result.setDate(date); - result.setBody(clientResult.getEntityInputStream()); - return result; - } - - public void sendTopicMessage(String topicName, Message message) throws ServiceException - { - sendMessage(topicName, message); - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - public Message receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - - public void unlockMessage(Message message) throws ServiceException { - getChannel() - .resource(message.getLockLocation()) - .put(""); - } - - public void deleteMessage(Message message) throws ServiceException { - getChannel() - .resource(message.getLockLocation()) - .delete(); - } - - public Queue createQueue(Queue entry) throws ServiceException { - return getResource() - .path(entry.getName()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Queue.class, entry); - } - - public void deleteQueue(String queuePath) throws ServiceException { - getResource() - .path(queuePath) - .delete(); - } - - public Queue getQueue(String queuePath) throws ServiceException { - return getResource() - .path(queuePath) - .get(Queue.class); - } - - - public ListQueuesResult listQueues() throws ServiceException { - Feed feed = getResource() - .path("$Resources/Queues") - .get(Feed.class); - ArrayList queues = new ArrayList(); - for(Entry entry : feed.getEntries()){ - queues.add(new Queue(entry)); - } - ListQueuesResult result = new ListQueuesResult(); - result.setItems(queues); - return result; - } - - public Topic createTopic(Topic entry) throws ServiceException { - return getResource() - .path(entry.getName()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Topic.class, entry); - } - - public void deleteTopic(String TopicPath) throws ServiceException { - getResource() - .path(TopicPath) - .delete(); - } - - public Topic getTopic(String TopicPath) throws ServiceException { - return getResource() - .path(TopicPath) - .get(Topic.class); - } - - - public ListTopicsResult listTopics() throws ServiceException { - Feed feed = getResource() - .path("$Resources/Topics") - .get(Feed.class); - ArrayList Topics = new ArrayList(); - for(Entry entry : feed.getEntries()){ - Topics.add(new Topic(entry)); - } - ListTopicsResult result = new ListTopicsResult(); - result.setItems(Topics); - return result; - } - - public void addSubscription(String topicPath, String subscriptionName, - Entry subscription) { - // TODO Auto-generated method stub - - } - - public void removeSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - - } - - public Entry getSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; - } - - public Feed getSubscriptions(String topicPath) { - // TODO Auto-generated method stub - return null; - } - - public void addRule(String topicPath, String subscriptionName, - String ruleName, Entry rule) { - // TODO Auto-generated method stub - - } - - public void removeRule(String topicPath, String subscriptionName, - String ruleName) { - // TODO Auto-generated method stub - - } - - public Entry getRule(String topicPath, String subscriptionName, - String ruleName) { - // TODO Auto-generated method stub - return null; - } - - public Feed getRules(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; - } - - - - - - + private Client channel; + private String uri; + private BrokerPropertiesMapper mapper; + static Log log = LogFactory.getLog(ServiceBusContract.class); + + ServiceFilter[] filters; + + @Inject + public ServiceBusRestProxy( + Client channel, + @Named("serviceBus") WrapFilter authFilter, + @Named("serviceBus.uri") String uri, + BrokerPropertiesMapper mapper) { + + this.channel = channel; + this.filters = new ServiceFilter[0]; + this.uri = uri; + this.mapper = mapper; + channel.addFilter(authFilter); + } + + public ServiceBusRestProxy( + Client channel, + ServiceFilter[] filters, + String uri, + BrokerPropertiesMapper mapper) { + this.channel = channel; + this.filters = filters; + this.uri = uri; + this.mapper = mapper; + } + + public ServiceBusContract withFilter(ServiceFilter filter) { + ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); + newFilters[filters.length] = filter; + return new ServiceBusRestProxy(channel, newFilters, uri, mapper); + } + + public Client getChannel() { + return channel; + } + + public void setChannel(Client channel) { + this.channel = channel; + } + + private WebResource getResource() { + WebResource resource = getChannel() + .resource(uri); + for (ServiceFilter filter : filters) { + resource.addFilter(new ClientFilterAdapter(filter)); + } + return resource; + } + + void sendMessage(String path, Message message) { + Builder request = getResource() + .path(path) + .path("messages") + .getRequestBuilder(); + + if (message.getContentType() != null) + request = request.type(message.getContentType()); + + if (message.getProperties() != null) + request = request.header("BrokerProperties", mapper.toString(message.getProperties())); + + request.post(message.getBody()); + } + + public void sendQueueMessage(String path, Message message) throws ServiceException { + sendMessage(path, message); + } + + public Message receiveQueueMessage(String queueName) + throws ServiceException { + return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); + } + + public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { + + WebResource resource = getResource() + .path(queuePath) + .path("messages") + .path("head"); + + if (options.getTimeout() != null) { + resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); + } + + ClientResponse clientResult; + if (options.isReceiveAndDelete()) { + clientResult = resource.delete(ClientResponse.class); + } + else if (options.isPeekLock()) { + clientResult = resource.post(ClientResponse.class, ""); + } + else { + throw new RuntimeException("Unknown ReceiveMode"); + } + + String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); + String location = clientResult.getHeaders().getFirst("Location"); + MediaType contentType = clientResult.getType(); + Date date = clientResult.getResponseDate(); + + Message result = new Message(); + if (brokerProperties != null) { + result.setProperties(mapper.fromString(brokerProperties)); + } + if (contentType != null) { + result.setContentType(contentType.toString()); + } + if (location != null) { + result.getProperties().setLockLocation(location); + } + result.setDate(date); + result.setBody(clientResult.getEntityInputStream()); + return result; + } + + public void sendTopicMessage(String topicName, Message message) throws ServiceException { + sendMessage(topicName, message); + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public Message receiveSubscriptionMessage(String topicName, + String subscriptionName, ReceiveMessageOptions options) + throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + public void unlockMessage(Message message) throws ServiceException { + getChannel() + .resource(message.getLockLocation()) + .put(""); + } + + public void deleteMessage(Message message) throws ServiceException { + getChannel() + .resource(message.getLockLocation()) + .delete(); + } + + public Queue createQueue(Queue entry) throws ServiceException { + return getResource() + .path(entry.getName()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Queue.class, entry); + } + + public void deleteQueue(String queuePath) throws ServiceException { + getResource() + .path(queuePath) + .delete(); + } + + public Queue getQueue(String queuePath) throws ServiceException { + return getResource() + .path(queuePath) + .get(Queue.class); + } + + public ListQueuesResult listQueues() throws ServiceException { + Feed feed = getResource() + .path("$Resources/Queues") + .get(Feed.class); + ArrayList queues = new ArrayList(); + for (Entry entry : feed.getEntries()) { + queues.add(new Queue(entry)); + } + ListQueuesResult result = new ListQueuesResult(); + result.setItems(queues); + return result; + } + + public Topic createTopic(Topic entry) throws ServiceException { + return getResource() + .path(entry.getName()) + .type("application/atom+xml")//;type=entry;charset=utf-8") + .put(Topic.class, entry); + } + + public void deleteTopic(String TopicPath) throws ServiceException { + getResource() + .path(TopicPath) + .delete(); + } + + public Topic getTopic(String TopicPath) throws ServiceException { + return getResource() + .path(TopicPath) + .get(Topic.class); + } + + public ListTopicsResult listTopics() throws ServiceException { + Feed feed = getResource() + .path("$Resources/Topics") + .get(Feed.class); + ArrayList Topics = new ArrayList(); + for (Entry entry : feed.getEntries()) { + Topics.add(new Topic(entry)); + } + ListTopicsResult result = new ListTopicsResult(); + result.setItems(Topics); + return result; + } + + public void addSubscription(String topicPath, String subscriptionName, + Entry subscription) { + // TODO Auto-generated method stub + + } + + public void removeSubscription(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + + } + + public Entry getSubscription(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + return null; + } + + public Feed getSubscriptions(String topicPath) { + // TODO Auto-generated method stub + return null; + } + + public void addRule(String topicPath, String subscriptionName, + String ruleName, Entry rule) { + // TODO Auto-generated method stub + + } + + public void removeRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + + } + + public Entry getRule(String topicPath, String subscriptionName, + String ruleName) { + // TODO Auto-generated method stub + return null; + } + + public Feed getRules(String topicPath, String subscriptionName) { + // TODO Auto-generated method stub + return null; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java index 5ed6361a48beb..3763c530eb648 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java @@ -3,5 +3,5 @@ import java.util.Date; public interface DateFactory { - Date getDate(); + Date getDate(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java index 25e28411cb3b2..5d6107605c21c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java @@ -3,7 +3,7 @@ import java.util.Date; public class DefaultDateFactory implements DateFactory { - public Date getDate() { - return new Date(); - } + public Date getDate() { + return new Date(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java index c7c0a63df09c2..b223246d67075 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java @@ -3,7 +3,7 @@ import com.microsoft.azure.configuration.builder.Builder; public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - registry.add(DateFactory.class, DefaultDateFactory.class); - } + public void register(Builder.Registry registry) { + registry.add(DateFactory.class, DefaultDateFactory.class); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java index e01fe3fd12067..2d41da101995a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java @@ -8,56 +8,55 @@ public class ServiceExceptionFactory { - public static ServiceException process(String serviceName, ServiceException exception) { - Throwable cause = exception.getCause(); - - for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - if (ServiceException.class.isAssignableFrom(scan.getClass())) { - return populate(exception, serviceName, (ServiceException)scan); - } - else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { - return populate(exception, serviceName, (UniformInterfaceException)scan); - } - } - - exception.setServiceName(serviceName); - - return exception; - } - - - static ServiceException populate(ServiceException exception, String serviceName, - UniformInterfaceException cause) { - exception.setServiceName(serviceName); - - if (cause != null) { - ClientResponse response = cause.getResponse(); - if (response != null) { - Status status = response.getClientResponseStatus(); - if (status == null) { - status = Status.fromStatusCode(response.getStatus()); - } - if (status == null) { - exception.setHttpStatusCode(response.getStatus()); - } - else { - exception.setHttpStatusCode(status.getStatusCode()); - exception.setHttpReasonPhrase(status.getReasonPhrase()); - } - } - } - return exception; - } - - static ServiceException populate(ServiceException exception, String serviceName, - ServiceException cause) { - exception.setServiceName(cause.getServiceName()); - exception.setHttpStatusCode(cause.getHttpStatusCode()); - exception.setHttpReasonPhrase(cause.getHttpReasonPhrase()); - exception.setErrorCode(cause.getErrorCode()); - exception.setErrorMessage(cause.getErrorMessage()); - exception.setErrorValues(cause.getErrorValues()); - return exception; - } + public static ServiceException process(String serviceName, ServiceException exception) { + Throwable cause = exception.getCause(); + + for (Throwable scan = cause; scan != null; scan = scan.getCause()) { + if (ServiceException.class.isAssignableFrom(scan.getClass())) { + return populate(exception, serviceName, (ServiceException) scan); + } + else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { + return populate(exception, serviceName, (UniformInterfaceException) scan); + } + } + + exception.setServiceName(serviceName); + + return exception; + } + + static ServiceException populate(ServiceException exception, String serviceName, + UniformInterfaceException cause) { + exception.setServiceName(serviceName); + + if (cause != null) { + ClientResponse response = cause.getResponse(); + if (response != null) { + Status status = response.getClientResponseStatus(); + if (status == null) { + status = Status.fromStatusCode(response.getStatus()); + } + if (status == null) { + exception.setHttpStatusCode(response.getStatus()); + } + else { + exception.setHttpStatusCode(status.getStatusCode()); + exception.setHttpReasonPhrase(status.getReasonPhrase()); + } + } + } + return exception; + } + + static ServiceException populate(ServiceException exception, String serviceName, + ServiceException cause) { + exception.setServiceName(cause.getServiceName()); + exception.setHttpStatusCode(cause.getHttpStatusCode()); + exception.setHttpReasonPhrase(cause.getHttpReasonPhrase()); + exception.setErrorCode(cause.getErrorCode()); + exception.setErrorMessage(cause.getErrorMessage()); + exception.setErrorValues(cause.getErrorValues()); + return exception; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java index 67976043920fe..4392a61ffc57b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java @@ -7,25 +7,25 @@ import com.microsoft.azure.configuration.Configuration; public class WrapClientIntegrationTest { - private Configuration createConfiguration() { - Configuration config = new Configuration(); - config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); - config.setProperty("wrapClient.name", "owner"); - config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - return config; - } + private Configuration createConfiguration() { + Configuration config = new Configuration(); + config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); + config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); + config.setProperty("wrapClient.name", "owner"); + config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + return config; + } - @Test - public void wrapClientWillAcquireAccessToken() throws Exception { - // Arrange - Configuration config = createConfiguration(); - WrapClient client = config.create(WrapClient.class); + @Test + public void wrapClientWillAcquireAccessToken() throws Exception { + // Arrange + Configuration config = createConfiguration(); + WrapClient client = config.create(WrapClient.class); - // Act - String accessToken = client.getAccessToken(); + // Act + String accessToken = client.getAccessToken(); - // Assert - Assert.assertNotNull(accessToken); - } + // Assert + Assert.assertNotNull(accessToken); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java index c99b079aa8494..27c336ba2bd08 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java @@ -18,100 +18,100 @@ import com.microsoft.azure.utils.DateFactory; public class WrapClientTest { - private WrapContract contract; - private WrapClient client; - private DateFactory dateFactory; - private Calendar calendar; - - @Before - public void init() { - calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - dateFactory = mock(DateFactory.class); - contract = mock(WrapContract.class); - client = new WrapClient( - contract, - dateFactory, - "testurl", - "testscope", - "testname", - "testpassword"); - - when(dateFactory.getDate()).thenAnswer(new Answer() { - public Date answer(InvocationOnMock invocation) throws Throwable { - return calendar.getTime(); - } - }); - - } - - @Test - public void clientUsesContractToGetToken() throws ServiceException{ - // Arrange - WrapResponse wrapResponse = new WrapResponse(); - wrapResponse.setAccessToken("testaccesstoken"); - wrapResponse.setExpiresIn(83); - - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); - - // Act - String accessToken = client.getAccessToken(); - - // Assert - assertNotNull(accessToken); - assertEquals("testaccesstoken", accessToken); - } - - - @Test - public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException{ - // Arrange - WrapResponse wrapResponse = new WrapResponse(); - wrapResponse.setAccessToken("testaccesstoken"); - wrapResponse.setExpiresIn(83); - - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); - - // Act - String accessToken1 = client.getAccessToken(); - String accessToken2 = client.getAccessToken(); - calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken(); - - // Assert - assertEquals("testaccesstoken", accessToken1); - assertEquals("testaccesstoken", accessToken2); - assertEquals("testaccesstoken", accessToken3); - - verify(contract, times(1)).post("testurl", "testname", "testpassword", "testscope"); - } - - @Test - public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException{ - // Arrange - doAnswer(new Answer() { - int count = 0; - public WrapResponse answer(InvocationOnMock invocation) throws Throwable { - ++count; - WrapResponse wrapResponse = new WrapResponse(); - wrapResponse.setAccessToken("testaccesstoken" + count); - wrapResponse.setExpiresIn(83); - return wrapResponse; - } - }).when(contract).post("testurl", "testname", "testpassword", "testscope"); - - // Act - String accessToken1 = client.getAccessToken(); - String accessToken2 = client.getAccessToken(); - calendar.add(Calendar.SECOND, 45); - String accessToken3 = client.getAccessToken(); - - // Assert - assertEquals("testaccesstoken1", accessToken1); - assertEquals("testaccesstoken1", accessToken2); - assertEquals("testaccesstoken2", accessToken3); - - verify(contract, times(2)).post("testurl", "testname", "testpassword", "testscope"); - } + private WrapContract contract; + private WrapClient client; + private DateFactory dateFactory; + private Calendar calendar; + + @Before + public void init() { + calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + dateFactory = mock(DateFactory.class); + contract = mock(WrapContract.class); + client = new WrapClient( + contract, + dateFactory, + "testurl", + "testscope", + "testname", + "testpassword"); + + when(dateFactory.getDate()).thenAnswer(new Answer() { + public Date answer(InvocationOnMock invocation) throws Throwable { + return calendar.getTime(); + } + }); + + } + + @Test + public void clientUsesContractToGetToken() throws ServiceException { + // Arrange + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken"); + wrapResponse.setExpiresIn(83); + + when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + + // Act + String accessToken = client.getAccessToken(); + + // Assert + assertNotNull(accessToken); + assertEquals("testaccesstoken", accessToken); + } + + @Test + public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException { + // Arrange + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken"); + wrapResponse.setExpiresIn(83); + + when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + + // Act + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); + calendar.add(Calendar.SECOND, 40); + String accessToken3 = client.getAccessToken(); + + // Assert + assertEquals("testaccesstoken", accessToken1); + assertEquals("testaccesstoken", accessToken2); + assertEquals("testaccesstoken", accessToken3); + + verify(contract, times(1)).post("testurl", "testname", "testpassword", "testscope"); + } + + @Test + public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException { + // Arrange + doAnswer(new Answer() { + int count = 0; + + public WrapResponse answer(InvocationOnMock invocation) throws Throwable { + ++count; + WrapResponse wrapResponse = new WrapResponse(); + wrapResponse.setAccessToken("testaccesstoken" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).post("testurl", "testname", "testpassword", "testscope"); + + // Act + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); + calendar.add(Calendar.SECOND, 45); + String accessToken3 = client.getAccessToken(); + + // Assert + assertEquals("testaccesstoken1", accessToken1); + assertEquals("testaccesstoken1", accessToken2); + assertEquals("testaccesstoken2", accessToken3); + + verify(contract, times(2)).post("testurl", "testname", "testpassword", "testscope"); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java index fab7e7faf0ee3..66e5d515eadbb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java @@ -6,16 +6,16 @@ import com.sun.jersey.api.client.Client; public class WrapContractIntegrationTest { - @Test - public void yaaaaargh() throws Exception { - Configuration config = new Configuration(); - - WrapContract contract = new WrapContractImpl(config.create(Client.class)); + @Test + public void yaaaaargh() throws Exception { + Configuration config = new Configuration(); - contract.post( - "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", - "owner", - "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", - "http://lodejard.servicebus.windows.net"); - } + WrapContract contract = new WrapContractImpl(config.create(Client.class)); + + contract.post( + "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", + "owner", + "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", + "http://lodejard.servicebus.windows.net"); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java index ef81367eb0a72..7cbf7288e7dc8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java @@ -2,12 +2,12 @@ import java.util.Map; -public class AlterClassWithProperties implements Builder.Alteration{ +public class AlterClassWithProperties implements Builder.Alteration { - public ClassWithProperties alter(ClassWithProperties instance, - Builder builder, Map properties) throws Exception { - instance.setFoo(instance.getFoo() + " - changed"); - return instance; - } + public ClassWithProperties alter(ClassWithProperties instance, + Builder builder, Map properties) throws Exception { + instance.setFoo(instance.getFoo() + " - changed"); + return instance; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java index 341753eade6d7..610a9560a3d67 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java @@ -3,8 +3,11 @@ import javax.inject.Inject; public class ClassWithMultipleCtorMultipleInject { - @Inject - public ClassWithMultipleCtorMultipleInject(){} - @Inject - public ClassWithMultipleCtorMultipleInject(String x){} + @Inject + public ClassWithMultipleCtorMultipleInject() { + } + + @Inject + public ClassWithMultipleCtorMultipleInject(String x) { + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java index 90149fe4dc73f..75faecdfc63a5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java @@ -1,8 +1,9 @@ package com.microsoft.azure.configuration.builder; public class ClassWithMultipleCtorNoInject { - public ClassWithMultipleCtorNoInject() { - } - public ClassWithMultipleCtorNoInject(String x) { - } + public ClassWithMultipleCtorNoInject() { + } + + public ClassWithMultipleCtorNoInject(String x) { + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java index 62c930bada839..15cb555e01882 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java @@ -4,19 +4,18 @@ import javax.inject.Named; public class ClassWithNamedParameter { - private String hello; + private String hello; - @Inject - public ClassWithNamedParameter(@Named("Foo") String hello) { - this.hello = hello; - } + @Inject + public ClassWithNamedParameter(@Named("Foo") String hello) { + this.hello = hello; + } - public String getHello() { - return hello; - } - - public void setHello(String hello) { - this.hello = hello; - } -} + public String getHello() { + return hello; + } + public void setHello(String hello) { + this.hello = hello; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java index 22c365db6e722..26f13b2004de2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java @@ -1,36 +1,41 @@ package com.microsoft.azure.configuration.builder; public class ClassWithProperties { - String foo; - String bar; - - public ClassWithProperties(){ - foo = "one"; - bar = "two"; - } + String foo; + String bar; - /** - * @return the foo - */ - public String getFoo() { - return foo; - } - /** - * @param foo the foo to set - */ - public void setFoo(String foo) { - this.foo = foo; - } - /** - * @return the bar - */ - public String getBar() { - return bar; - } - /** - * @param bar the bar to set - */ - public void setBar(String bar) { - this.bar = bar; - } + public ClassWithProperties() { + foo = "one"; + bar = "two"; + } + + /** + * @return the foo + */ + public String getFoo() { + return foo; + } + + /** + * @param foo + * the foo to set + */ + public void setFoo(String foo) { + this.foo = foo; + } + + /** + * @return the bar + */ + public String getBar() { + return bar; + } + + /** + * @param bar + * the bar to set + */ + public void setBar(String bar) { + this.bar = bar; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java index 1a34374e55923..5924cddb64294 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java @@ -1,7 +1,7 @@ package com.microsoft.azure.configuration.builder; public class ClassWithSingleCtorNoInject { - public ClassWithSingleCtorNoInject() { - - } + public ClassWithSingleCtorNoInject() { + + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java index df7761cb40b2b..d186be8db6438 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java @@ -12,152 +12,152 @@ public class DefaultBuilderTest { - Map properties; - DefaultBuilder builder; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void init() { - properties = new HashMap(); - builder = new DefaultBuilder(); - } - - @Test - public void namedAnnotationsComeFromBuildProperties() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - - // Act - Map properties = new HashMap(); - properties.put("Foo", "world"); - ClassWithNamedParameter cwnp = builder.build("", - ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("world", cwnp.getHello()); - } - - @Test - public void namedAnnotationReportsMissingProperty() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithNamedParameter.class); - - // Act - ClassWithNamedParameter cwnp = builder.build("", - ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("world", cwnp.getHello()); - } - - @Test - public void singleCtorWithNoInjectShouldBeUsed() throws Exception { - // Arrange - builder.add(ClassWithSingleCtorNoInject.class); - - // Act - ClassWithSingleCtorNoInject result = builder.build("", - ClassWithSingleCtorNoInject.class, properties); - - // Assert - Assert.assertNotNull(result); - } - - @Test - public void multipleCtorWithNoInjectShouldFail() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithMultipleCtorNoInject.class); - - // Act - ClassWithMultipleCtorNoInject result = builder.build("", - ClassWithMultipleCtorNoInject.class, properties); - - // Assert - Assert.assertTrue("Exception must occur", false); - } - - @Test - public void multipleCtorWithMultipleInjectShouldFail() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithMultipleCtorMultipleInject.class); - - // Act - ClassWithMultipleCtorMultipleInject result = builder.build("", - ClassWithMultipleCtorMultipleInject.class, properties); - - // Assert - Assert.assertTrue("Exception must occur", false); - } - - @Test - public void alterationExecutesWhenInstanceCreated() throws Exception { - // Arrange - builder.add(ClassWithProperties.class); - builder.alter(ClassWithProperties.class, new AlterClassWithProperties()); - - // Act - ClassWithProperties result = builder.build("",ClassWithProperties.class, properties); - - // Assert - Assert.assertEquals("one - changed", result.getFoo()); - } - - @Test - public void namedParametersUseProfileBasedKeysFirst() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("testing.Foo", "Profile foo value"); - - // Act - ClassWithNamedParameter result = builder.build("testing", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("Profile foo value", result.getHello()); - } - - @Test - public void namedParametersFallBackToNonProfileBasedKeys() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("testing.Foo", "Profile foo value"); - - // Act - ClassWithNamedParameter result1 = builder.build("", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result2 = builder.build("production", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("fallback", result1.getHello()); - Assert.assertEquals("fallback", result2.getHello()); - Assert.assertEquals("fallback", result2.getHello()); - } - - @Test - public void namedParamatersFallBackFromLeftToRight() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("custom.Foo", "custom.Foo value"); - properties.put("testing.custom.Foo", "testing.custom.Foo value"); - - // Act - ClassWithNamedParameter result1 = builder.build("custom", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result2 = builder.build("production.custom", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("custom.Foo value", result1.getHello()); - Assert.assertEquals("custom.Foo value", result2.getHello()); - Assert.assertEquals("testing.custom.Foo value", result3.getHello()); - } + Map properties; + DefaultBuilder builder; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Before + public void init() { + properties = new HashMap(); + builder = new DefaultBuilder(); + } + + @Test + public void namedAnnotationsComeFromBuildProperties() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + + // Act + Map properties = new HashMap(); + properties.put("Foo", "world"); + ClassWithNamedParameter cwnp = builder.build("", + ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("world", cwnp.getHello()); + } + + @Test + public void namedAnnotationReportsMissingProperty() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + builder.add(ClassWithNamedParameter.class); + + // Act + ClassWithNamedParameter cwnp = builder.build("", + ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("world", cwnp.getHello()); + } + + @Test + public void singleCtorWithNoInjectShouldBeUsed() throws Exception { + // Arrange + builder.add(ClassWithSingleCtorNoInject.class); + + // Act + ClassWithSingleCtorNoInject result = builder.build("", + ClassWithSingleCtorNoInject.class, properties); + + // Assert + Assert.assertNotNull(result); + } + + @Test + public void multipleCtorWithNoInjectShouldFail() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + builder.add(ClassWithMultipleCtorNoInject.class); + + // Act + ClassWithMultipleCtorNoInject result = builder.build("", + ClassWithMultipleCtorNoInject.class, properties); + + // Assert + Assert.assertTrue("Exception must occur", false); + } + + @Test + public void multipleCtorWithMultipleInjectShouldFail() throws Exception { + // Arrange + thrown.expect(RuntimeException.class); + + builder.add(ClassWithMultipleCtorMultipleInject.class); + + // Act + ClassWithMultipleCtorMultipleInject result = builder.build("", + ClassWithMultipleCtorMultipleInject.class, properties); + + // Assert + Assert.assertTrue("Exception must occur", false); + } + + @Test + public void alterationExecutesWhenInstanceCreated() throws Exception { + // Arrange + builder.add(ClassWithProperties.class); + builder.alter(ClassWithProperties.class, new AlterClassWithProperties()); + + // Act + ClassWithProperties result = builder.build("", ClassWithProperties.class, properties); + + // Assert + Assert.assertEquals("one - changed", result.getFoo()); + } + + @Test + public void namedParametersUseProfileBasedKeysFirst() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("testing.Foo", "Profile foo value"); + + // Act + ClassWithNamedParameter result = builder.build("testing", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("Profile foo value", result.getHello()); + } + + @Test + public void namedParametersFallBackToNonProfileBasedKeys() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("testing.Foo", "Profile foo value"); + + // Act + ClassWithNamedParameter result1 = builder.build("", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result2 = builder.build("production", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("fallback", result1.getHello()); + Assert.assertEquals("fallback", result2.getHello()); + Assert.assertEquals("fallback", result2.getHello()); + } + + @Test + public void namedParamatersFallBackFromLeftToRight() throws Exception { + // Arrange + builder.add(ClassWithNamedParameter.class); + properties.put("Foo", "fallback"); + properties.put("custom.Foo", "custom.Foo value"); + properties.put("testing.custom.Foo", "testing.custom.Foo value"); + + // Act + ClassWithNamedParameter result1 = builder.build("custom", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result2 = builder.build("production.custom", ClassWithNamedParameter.class, properties); + ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); + + // Assert + Assert.assertEquals("custom.Foo value", result1.getHello()); + Assert.assertEquals("custom.Foo value", result2.getHello()); + Assert.assertEquals("testing.custom.Foo value", result3.getHello()); + } } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index 12c6820eba34d..f376db1b5435e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -13,105 +13,102 @@ import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; public class BrokerPropertiesMapperTest { - @Test - public void jsonStringMapsToBrokerPropertiesObject(){ - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = mapper.fromString("{\"DeliveryCount\":5,\"MessageId\":\"something\"}"); - - // Assert - assertNotNull(properties); - assertEquals(new Integer(5), properties.getDeliveryCount()); - assertEquals("something", properties.getMessageId()); - } - - @Test - public void nonDefaultPropertiesMapToJsonString(){ - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = new BrokerProperties(); - properties.setMessageId("foo"); - properties.setDeliveryCount(7); - String json = mapper.toString(properties); - - // Assert - assertNotNull(json); - assertEquals("{\"DeliveryCount\":7,\"MessageId\":\"foo\"}", json); - } - - @Test - public void deserializingAllPossibleValues() { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar.set(1994, 10, 6, 8, 49, 37); - Date schedTimeUtc = calendar.getTime(); - - Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar2.set(2011, 9, 14, 12, 34, 56); - Date lockedUntilUtc = calendar2.getTime(); - - // Act - BrokerProperties properties = mapper.fromString( - "{"+ - "\"CorrelationId\": \"corid\","+ - "\"SessionId\": \"sesid\","+ - "\"DeliveryCount\": 5,"+ - "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\","+ - "\"LockToken\": \"loctok\","+ - "\"MessageId\": \"mesid\","+ - "\"Label\": \"lab\","+ - "\"ReplyTo\": \"repto\","+ - "\"SequenceNumber\": 7,"+ - "\"TimeToLive\": 8.123,"+ - "\"To\": \"to\","+ - "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\","+ - "\"ReplyToSessionId\": \"reptosesid\","+ - "\"MessageLocation\": \"mesloc\","+ - "\"LockLocation\": \"locloc\""+ - "}"); - - - - // Assert - assertNotNull(properties); - - long lockedUntilDelta = properties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); - long schedTimeDelta = properties.getScheduledEnqueueTimeUtc().getTime() - schedTimeUtc.getTime(); - - assertEquals("corid", properties.getCorrelationId()); - assertEquals("sesid", properties.getSessionId()); - assertEquals(5, (int)properties.getDeliveryCount()); - assertTrue(Math.abs(lockedUntilDelta) < 500); - assertEquals("loctok", properties.getLockToken()); - assertEquals("mesid", properties.getMessageId()); - assertEquals("lab", properties.getLabel()); - assertEquals("repto", properties.getReplyTo()); - assertEquals(7, (long)properties.getSequenceNumber()); - assertEquals(8.123, properties.getTimeToLive(), .001); - assertEquals("to", properties.getTo()); - assertTrue(Math.abs(schedTimeDelta) < 500); - assertEquals("reptosesid", properties.getReplyToSessionId()); - assertEquals("mesloc", properties.getMessageLocation()); - assertEquals("locloc", properties.getLockLocation()); - } - - @Test - public void missingDatesDeserializeAsNull() - { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = mapper.fromString("{}"); - - // Assert - assertNull(properties.getLockedUntilUtc()); - assertNull(properties.getScheduledEnqueueTimeUtc()); - } + @Test + public void jsonStringMapsToBrokerPropertiesObject() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + // Act + BrokerProperties properties = mapper.fromString("{\"DeliveryCount\":5,\"MessageId\":\"something\"}"); + + // Assert + assertNotNull(properties); + assertEquals(new Integer(5), properties.getDeliveryCount()); + assertEquals("something", properties.getMessageId()); + } + + @Test + public void nonDefaultPropertiesMapToJsonString() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + // Act + BrokerProperties properties = new BrokerProperties(); + properties.setMessageId("foo"); + properties.setDeliveryCount(7); + String json = mapper.toString(properties); + + // Assert + assertNotNull(json); + assertEquals("{\"DeliveryCount\":7,\"MessageId\":\"foo\"}", json); + } + + @Test + public void deserializingAllPossibleValues() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar.set(1994, 10, 6, 8, 49, 37); + Date schedTimeUtc = calendar.getTime(); + + Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + calendar2.set(2011, 9, 14, 12, 34, 56); + Date lockedUntilUtc = calendar2.getTime(); + + // Act + BrokerProperties properties = mapper.fromString( + "{" + + "\"CorrelationId\": \"corid\"," + + "\"SessionId\": \"sesid\"," + + "\"DeliveryCount\": 5," + + "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + + "\"LockToken\": \"loctok\"," + + "\"MessageId\": \"mesid\"," + + "\"Label\": \"lab\"," + + "\"ReplyTo\": \"repto\"," + + "\"SequenceNumber\": 7," + + "\"TimeToLive\": 8.123," + + "\"To\": \"to\"," + + "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + + "\"ReplyToSessionId\": \"reptosesid\"," + + "\"MessageLocation\": \"mesloc\"," + + "\"LockLocation\": \"locloc\"" + + "}"); + + // Assert + assertNotNull(properties); + + long lockedUntilDelta = properties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); + long schedTimeDelta = properties.getScheduledEnqueueTimeUtc().getTime() - schedTimeUtc.getTime(); + + assertEquals("corid", properties.getCorrelationId()); + assertEquals("sesid", properties.getSessionId()); + assertEquals(5, (int) properties.getDeliveryCount()); + assertTrue(Math.abs(lockedUntilDelta) < 500); + assertEquals("loctok", properties.getLockToken()); + assertEquals("mesid", properties.getMessageId()); + assertEquals("lab", properties.getLabel()); + assertEquals("repto", properties.getReplyTo()); + assertEquals(7, (long) properties.getSequenceNumber()); + assertEquals(8.123, properties.getTimeToLive(), .001); + assertEquals("to", properties.getTo()); + assertTrue(Math.abs(schedTimeDelta) < 500); + assertEquals("reptosesid", properties.getReplyToSessionId()); + assertEquals("mesloc", properties.getMessageLocation()); + assertEquals("locloc", properties.getLockLocation()); + } + + @Test + public void missingDatesDeserializeAsNull() { + // Arrange + BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); + + // Act + BrokerProperties properties = mapper.fromString("{}"); + + // Assert + assertNull(properties.getLockedUntilUtc()); + assertNull(properties.getScheduledEnqueueTimeUtc()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index 52b256b35b891..c8236b4474711 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -11,56 +11,57 @@ import static com.microsoft.azure.services.serviceBus.Util.*; public abstract class IntegrationTestBase { - protected Configuration createConfiguration() { - Configuration config = new Configuration(); - ServiceBusConfiguration.configure(config, "lodejard", "owner", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); + protected Configuration createConfiguration() { + Configuration config = new Configuration(); + ServiceBusConfiguration.configure(config, "lodejard", "owner", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - // when mock running - //config.setProperty("serviceBus.uri", "http://localhost:8086"); - //config.setProperty("wrapClient.uri", "http://localhost:8081/WRAPv0.9"); - - return config; - } - - @BeforeClass - public static void initializeSystem() { - System.out.println("initialize"); - System.setProperty("http.proxyHost", "itgproxy"); - System.setProperty("http.proxyPort", "80"); - System.setProperty("http.keepAlive", "false"); - } + // when mock running + //config.setProperty("serviceBus.uri", "http://localhost:8086"); + //config.setProperty("wrapClient.uri", "http://localhost:8081/WRAPv0.9"); - @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"); - - boolean testAlphaExists = false; - ServiceBusContract service = createConfiguration().create(ServiceBusContract.class); - for(Queue queue : iterateQueues(service)) { - String queueName = queue.getName(); - if (queueName.startsWith("Test") || queueName.startsWith("test")) { - if (queueName.equalsIgnoreCase("TestAlpha")) { - testAlphaExists = true; - long count = queue.getMessageCount(); - for(long i = 0; i != count; ++i) { - service.receiveQueueMessage(queueName, new ReceiveMessageOptions().setTimeout(20)); - } - } else { - service.deleteQueue(queueName); - } - } - } - for(Topic topic : iterateTopics(service)) { - String topicName = topic.getName(); - if (topicName.startsWith("Test") || topicName.startsWith("test")) { - service.deleteQueue(topicName); - } - } - if (!testAlphaExists) { - service.createQueue(new Queue("TestAlpha")); - } - } + return config; + } + + @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"); + + boolean testAlphaExists = false; + ServiceBusContract service = createConfiguration().create(ServiceBusContract.class); + for (Queue queue : iterateQueues(service)) { + String queueName = queue.getName(); + if (queueName.startsWith("Test") || queueName.startsWith("test")) { + if (queueName.equalsIgnoreCase("TestAlpha")) { + testAlphaExists = true; + long count = queue.getMessageCount(); + for (long i = 0; i != count; ++i) { + service.receiveQueueMessage(queueName, new ReceiveMessageOptions().setTimeout(20)); + } + } + else { + service.deleteQueue(queueName); + } + } + } + for (Topic topic : iterateTopics(service)) { + String topicName = topic.getName(); + if (topicName.startsWith("Test") || topicName.startsWith("test")) { + service.deleteQueue(topicName); + } + } + if (!testAlphaExists) { + service.createQueue(new Queue("TestAlpha")); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java index 477043bfaef59..10bda5d1b3196 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java @@ -4,27 +4,28 @@ public class RetryFilter implements ServiceFilter { - public Response handle(Request request, Next next) { - Response response = null; - Exception error = null; + public Response handle(Request request, Next next) { + Response response = null; + Exception error = null; - for (int retryCount = 0; retryCount != 3; ++retryCount) { - try { - response = next.handle(request); - } catch (Exception ex) { - error = ex; - } + for (int retryCount = 0; retryCount != 3; ++retryCount) { + try { + response = next.handle(request); + } + catch (Exception ex) { + error = ex; + } - boolean shouldRetry = false; - // TODO policy - if (!shouldRetry) - break; - } - if (response == null && error != null) { - // TODO define correct way to rethrow - throw new RuntimeException(error); - } - return response; - } + boolean shouldRetry = false; + // TODO policy + if (!shouldRetry) + break; + } + if (response == null && error != null) { + // TODO define correct way to rethrow + throw new RuntimeException(error); + } + return response; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java index f1340164e699b..2431ed4cd04cc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java @@ -7,45 +7,45 @@ import com.microsoft.azure.configuration.Configuration; public class ServiceBusConfigurationTest { - @Test - public void ConfigureSetsExpectedProperties() { - // Arrange - Configuration config = new Configuration(); - - // Act - ServiceBusConfiguration.configure(config, "alpha", "beta", "gamma"); - - // Assert - assertEquals("https://alpha.servicebus.windows.net/", - config.getProperty("serviceBus.uri")); - assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", - config.getProperty("serviceBus.wrap.uri")); - assertEquals("beta", - config.getProperty("serviceBus.wrap.name")); - assertEquals("gamma", - config.getProperty("serviceBus.wrap.password")); - assertEquals("http://alpha.servicebus.windows.net/", - config.getProperty("serviceBus.wrap.scope")); - } - - @Test - public void UsingProfileAddsPrefix() { - // Arrange - Configuration config = new Configuration(); - - // Act - ServiceBusConfiguration.configure("backup", config, "alpha", "beta", "gamma"); - - // Assert - assertEquals("https://alpha.servicebus.windows.net/", - config.getProperty("backup.serviceBus.uri")); - assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", - config.getProperty("backup.serviceBus.wrap.uri")); - assertEquals("beta", - config.getProperty("backup.serviceBus.wrap.name")); - assertEquals("gamma", - config.getProperty("backup.serviceBus.wrap.password")); - assertEquals("http://alpha.servicebus.windows.net/", - config.getProperty("backup.serviceBus.wrap.scope")); - } + @Test + public void ConfigureSetsExpectedProperties() { + // Arrange + Configuration config = new Configuration(); + + // Act + ServiceBusConfiguration.configure(config, "alpha", "beta", "gamma"); + + // Assert + assertEquals("https://alpha.servicebus.windows.net/", + config.getProperty("serviceBus.uri")); + assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", + config.getProperty("serviceBus.wrap.uri")); + assertEquals("beta", + config.getProperty("serviceBus.wrap.name")); + assertEquals("gamma", + config.getProperty("serviceBus.wrap.password")); + assertEquals("http://alpha.servicebus.windows.net/", + config.getProperty("serviceBus.wrap.scope")); + } + + @Test + public void UsingProfileAddsPrefix() { + // Arrange + Configuration config = new Configuration(); + + // Act + ServiceBusConfiguration.configure("backup", config, "alpha", "beta", "gamma"); + + // Assert + assertEquals("https://alpha.servicebus.windows.net/", + config.getProperty("backup.serviceBus.uri")); + assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", + config.getProperty("backup.serviceBus.wrap.uri")); + assertEquals("beta", + config.getProperty("backup.serviceBus.wrap.name")); + assertEquals("gamma", + config.getProperty("backup.serviceBus.wrap.password")); + assertEquals("http://alpha.servicebus.windows.net/", + config.getProperty("backup.serviceBus.wrap.scope")); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java index bfc7dd0a81517..3f08b85983a6b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java @@ -1,6 +1,5 @@ package com.microsoft.azure.services.serviceBus; - import static org.junit.Assert.*; import org.junit.Test; @@ -8,45 +7,45 @@ import com.microsoft.azure.services.serviceBus.ServiceBusContract; import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; -public class ServiceBusCreationTest { - @Test - public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { - ServiceBusConfiguration.configure("my-namespace", "my-identity", "my-shared-secret"); - ServiceBusService service = new ServiceBusService(); - - assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); - } - - public Configuration newConfiguration() { - Configuration config = new Configuration(); - ServiceBusConfiguration.configure(config, "my-namespace", "my-identity", "my-shared-secret"); - return config; - } - - @Test - public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = new ServiceBusService(config); - - assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); - } - - @Test - public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = config.create(ServiceBusService.class); - - assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); - } - - @Test - public void testDefaultBuilderCreatesServiceImpl() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = config.create(ServiceBusContract.class); - - assertNotNull(service); - } +public class ServiceBusCreationTest { + @Test + public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { + ServiceBusConfiguration.configure("my-namespace", "my-identity", "my-shared-secret"); + ServiceBusService service = new ServiceBusService(); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + public Configuration newConfiguration() { + Configuration config = new Configuration(); + ServiceBusConfiguration.configure(config, "my-namespace", "my-identity", "my-shared-secret"); + return config; + } + + @Test + public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = new ServiceBusService(config); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + @Test + public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = config.create(ServiceBusService.class); + + assertNotNull(service); + assertEquals(ServiceBusService.class, service.getClass()); + } + + @Test + public void testDefaultBuilderCreatesServiceImpl() throws Exception { + Configuration config = newConfiguration(); + ServiceBusContract service = config.create(ServiceBusContract.class); + + assertNotNull(service); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index a8dbd968c49a4..6362ff1ee0f5b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -22,228 +22,225 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { - private Configuration config; - private ServiceBusContract service; - - static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); - static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); - - @Before - public void createService() throws Exception { - config = createConfiguration(); - service = config.create(ServiceBusContract.class); - } - - @Test - public void fetchQueueAndListQueuesWorks() throws Exception { - // Arrange - - // Act - Queue entry = service.getQueue("TestAlpha"); - ListQueuesResult feed = service.listQueues(); - - // Assert - assertNotNull(entry); - assertNotNull(feed); - } - - - @Test - public void createQueueWorks() throws Exception { - // Arrange - - // Act - Queue queue = new Queue("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); - Queue saved = service.createQueue(queue); - - // Assert - assertNotNull(saved); - assertNotSame(queue, saved); - assertEquals("TestCreateQueueWorks", saved.getName()); - } - - @Test - public void deleteQueueWorks() throws Exception { - // Arrange - service.createQueue(new Queue("TestDeleteQueueWorks")); - - // Act - service.deleteQueue("TestDeleteQueueWorks"); - - // Assert - } - - @Test - public void sendMessageWorks() throws Exception { - // Arrange - Message message = new Message("sendMessageWorks"); - - // Act - service.sendQueueMessage("TestAlpha", message); - - // Assert - } - - @Test - public void receiveMessageWorks() throws Exception { - // Arrange - String queueName = "TestReceiveMessageWorks"; - service.createQueue(new Queue(queueName)); - service.sendQueueMessage(queueName, new Message("Hello World")); - - // Act - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); - byte[] data = new byte[100]; - int size = message.getBody().read(data); - - // Assert - assertEquals(11, size); - assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size)); - } - - @Test - public void peekLockMessageWorks() throws Exception { - // Arrange - String queueName = "TestPeekLockMessageWorks"; - service.createQueue(new Queue(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - - // Act - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); - - // Assert - byte[] data = new byte[100]; - int size = message.getBody().read(data); - assertEquals(11, size); - assertEquals("Hello Again", new String(data, 0, size)); - } - - @Test - public void peekLockedMessageCanBeCompleted() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeCompleted"; - service.createQueue(new Queue(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); - - // Act - String lockToken = message.getLockToken(); - Date lockedUntil = message.getLockedUntilUtc(); - String lockLocation = message.getLockLocation(); - - service.deleteMessage(message); - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNotNull(lockLocation); - } - - @Test - public void peekLockedMessageCanBeUnlocked() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeUnlocked"; - service.createQueue(new Queue(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); - - // Act - String lockToken = peekedMessage.getLockToken(); - Date lockedUntil = peekedMessage.getLockedUntilUtc(); - - service.unlockMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); - - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNull(receivedMessage.getLockToken()); - assertNull(receivedMessage.getLockedUntilUtc()); - } - - - @Test - public void peekLockedMessageCanBeDeleted() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeDeleted"; - service.createQueue(new Queue(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); - - // Act - String lockToken = peekedMessage.getLockToken(); - Date lockedUntil = peekedMessage.getLockedUntilUtc(); - - service.deleteMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNull(receivedMessage.getLockToken()); - assertNull(receivedMessage.getLockedUntilUtc()); - } - - @Test - public void contentTypePassesThrough() throws Exception { - // Arrange - String queueName = "TestContentTypePassesThrough"; - service.createQueue(new Queue(queueName)); - - // Act - service.sendQueueMessage(queueName, - new Message("Hello Again").setContentType("text/xml")); - - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); - - // Assert - assertNotNull(message); - assertEquals("text/xml", message.getContentType()); - } - - @Test - public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException{ - // Arrange - String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; - - // Act - Topic created = service.createTopic(new Topic().setName(topicName)); - ListTopicsResult listed = service.listTopics(); - Topic fetched = service.getTopic(topicName); - service.deleteTopic(topicName); - ListTopicsResult listed2 = service.listTopics(); - - // Assert - assertNotNull(created); - assertNotNull(listed); - assertNotNull(fetched); - assertNotNull(listed2); - - assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); - } - - @Test - public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { - // Arrange - final List requests = new ArrayList(); - final List responses = new ArrayList(); - - ServiceBusContract filtered = service.withFilter(new ServiceFilter() { - public Response handle(Request request, Next next) { - requests.add(request); - Response response = next.handle(request); - responses.add(response); - return response; - } - }); - - // Act - Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")); - - // Assert - assertNotNull(created); - assertEquals(1, requests.size()); - assertEquals(1, responses.size()); - } + private Configuration config; + private ServiceBusContract service; + + static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); + static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); + + @Before + public void createService() throws Exception { + config = createConfiguration(); + service = config.create(ServiceBusContract.class); + } + + @Test + public void fetchQueueAndListQueuesWorks() throws Exception { + // Arrange + + // Act + Queue entry = service.getQueue("TestAlpha"); + ListQueuesResult feed = service.listQueues(); + + // Assert + assertNotNull(entry); + assertNotNull(feed); + } + + @Test + public void createQueueWorks() throws Exception { + // Arrange + + // Act + Queue queue = new Queue("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); + Queue saved = service.createQueue(queue); + + // Assert + assertNotNull(saved); + assertNotSame(queue, saved); + assertEquals("TestCreateQueueWorks", saved.getName()); + } + + @Test + public void deleteQueueWorks() throws Exception { + // Arrange + service.createQueue(new Queue("TestDeleteQueueWorks")); + + // Act + service.deleteQueue("TestDeleteQueueWorks"); + + // Assert + } + + @Test + public void sendMessageWorks() throws Exception { + // Arrange + Message message = new Message("sendMessageWorks"); + + // Act + service.sendQueueMessage("TestAlpha", message); + + // Assert + } + + @Test + public void receiveMessageWorks() throws Exception { + // Arrange + String queueName = "TestReceiveMessageWorks"; + service.createQueue(new Queue(queueName)); + service.sendQueueMessage(queueName, new Message("Hello World")); + + // Act + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + byte[] data = new byte[100]; + int size = message.getBody().read(data); + + // Assert + assertEquals(11, size); + assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size)); + } + + @Test + public void peekLockMessageWorks() throws Exception { + // Arrange + String queueName = "TestPeekLockMessageWorks"; + service.createQueue(new Queue(queueName)); + service.sendQueueMessage(queueName, new Message("Hello Again")); + + // Act + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + + // Assert + byte[] data = new byte[100]; + int size = message.getBody().read(data); + assertEquals(11, size); + assertEquals("Hello Again", new String(data, 0, size)); + } + + @Test + public void peekLockedMessageCanBeCompleted() throws Exception { + // Arrange + String queueName = "TestPeekLockedMessageCanBeCompleted"; + service.createQueue(new Queue(queueName)); + service.sendQueueMessage(queueName, new Message("Hello Again")); + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + + // Act + String lockToken = message.getLockToken(); + Date lockedUntil = message.getLockedUntilUtc(); + String lockLocation = message.getLockLocation(); + + service.deleteMessage(message); + + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNotNull(lockLocation); + } + + @Test + public void peekLockedMessageCanBeUnlocked() throws Exception { + // Arrange + String queueName = "TestPeekLockedMessageCanBeUnlocked"; + service.createQueue(new Queue(queueName)); + service.sendQueueMessage(queueName, new Message("Hello Again")); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + + // Act + String lockToken = peekedMessage.getLockToken(); + Date lockedUntil = peekedMessage.getLockedUntilUtc(); + + service.unlockMessage(peekedMessage); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNull(receivedMessage.getLockToken()); + assertNull(receivedMessage.getLockedUntilUtc()); + } + + @Test + public void peekLockedMessageCanBeDeleted() throws Exception { + // Arrange + String queueName = "TestPeekLockedMessageCanBeDeleted"; + service.createQueue(new Queue(queueName)); + service.sendQueueMessage(queueName, new Message("Hello Again")); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + + // Act + String lockToken = peekedMessage.getLockToken(); + Date lockedUntil = peekedMessage.getLockedUntilUtc(); + + service.deleteMessage(peekedMessage); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(lockToken); + assertNotNull(lockedUntil); + assertNull(receivedMessage.getLockToken()); + assertNull(receivedMessage.getLockedUntilUtc()); + } + + @Test + public void contentTypePassesThrough() throws Exception { + // Arrange + String queueName = "TestContentTypePassesThrough"; + service.createQueue(new Queue(queueName)); + + // Act + service.sendQueueMessage(queueName, + new Message("Hello Again").setContentType("text/xml")); + + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + + // Assert + assertNotNull(message); + assertEquals("text/xml", message.getContentType()); + } + + @Test + public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { + // Arrange + String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; + + // Act + Topic created = service.createTopic(new Topic().setName(topicName)); + ListTopicsResult listed = service.listTopics(); + Topic fetched = service.getTopic(topicName); + service.deleteTopic(topicName); + ListTopicsResult listed2 = service.listTopics(); + + // Assert + assertNotNull(created); + assertNotNull(listed); + assertNotNull(fetched); + assertNotNull(listed2); + + assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); + } + + @Test + public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { + // Arrange + final List requests = new ArrayList(); + final List responses = new ArrayList(); + + ServiceBusContract filtered = service.withFilter(new ServiceFilter() { + public Response handle(Request request, Next next) { + requests.add(request); + Response response = next.handle(request); + responses.add(response); + return response; + } + }); + + // Act + Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")); + + // Assert + assertNotNull(created); + assertEquals(1, requests.size()); + assertEquals(1, responses.size()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java index 0c63405f21ee4..d9298bace7b4d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java @@ -13,67 +13,61 @@ public class MessagingClientIntegrationTest extends IntegrationTestBase { - private MessagingClient messaging; - - @Before - public void createClient() throws Exception - { - messaging = createConfiguration().create(MessagingClient.class); - } - - @Test - public void queueWillSendAndReceiveMessages() throws Exception - { - // Arrange - MessageTransceiver port = messaging.openQueue("TestAlpha"); - Message messageOut = new Message("queueWillSendAndReceiveMessages"); - - // Act - port.sendMessage(messageOut); - Message messageIn = port.receiveMessage(); - - // Assert - assertNotSame(messageOut, messageIn); - - byte[] data = new byte[100]; - int size = messageIn.getBody().read(data); - assertEquals(31, size); - assertEquals("queueWillSendAndReceiveMessages", new String(data, 0, size)); - } - - - @Test - public void queueIsSenderAndReceiver() throws Exception - { - // Arrange - MessageSender sender = messaging.openQueue("TestAlpha"); - MessageReceiver receiver = messaging.openQueue("TestAlpha"); - Message messageOut = new Message("queueIsSenderAndReceiver"); - - // Act - sender.sendMessage(messageOut); - Message messageIn = receiver.receiveMessage(); - - // Assert - assertNotSame(messageOut, messageIn); - - byte[] data = new byte[100]; - int size = messageIn.getBody().read(data); - assertEquals(24, size); - assertEquals("queueIsSenderAndReceiver", new String(data, 0, size)); - } - - - @Test - public void clientMayBeCreatedDirectly() throws Exception - { - // Arrange - - // Act - MessagingClient mc = new MessagingClient(createConfiguration()); - mc.openQueue("TestAlpha").sendMessage(new Message("clientMayBeCreatedDirectly")); - - // Assert - } + private MessagingClient messaging; + + @Before + public void createClient() throws Exception { + messaging = createConfiguration().create(MessagingClient.class); + } + + @Test + public void queueWillSendAndReceiveMessages() throws Exception { + // Arrange + MessageTransceiver port = messaging.openQueue("TestAlpha"); + Message messageOut = new Message("queueWillSendAndReceiveMessages"); + + // Act + port.sendMessage(messageOut); + Message messageIn = port.receiveMessage(); + + // Assert + assertNotSame(messageOut, messageIn); + + byte[] data = new byte[100]; + int size = messageIn.getBody().read(data); + assertEquals(31, size); + assertEquals("queueWillSendAndReceiveMessages", new String(data, 0, size)); + } + + @Test + public void queueIsSenderAndReceiver() throws Exception { + // Arrange + MessageSender sender = messaging.openQueue("TestAlpha"); + MessageReceiver receiver = messaging.openQueue("TestAlpha"); + Message messageOut = new Message("queueIsSenderAndReceiver"); + + // Act + sender.sendMessage(messageOut); + Message messageIn = receiver.receiveMessage(); + + // Assert + assertNotSame(messageOut, messageIn); + + byte[] data = new byte[100]; + int size = messageIn.getBody().read(data); + assertEquals(24, size); + assertEquals("queueIsSenderAndReceiver", new String(data, 0, size)); + } + + @Test + public void clientMayBeCreatedDirectly() throws Exception { + // Arrange + + // Act + MessagingClient mc = new MessagingClient(createConfiguration()); + mc.openQueue("TestAlpha").sendMessage(new Message("clientMayBeCreatedDirectly")); + + // Assert + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java index 672125cb5dc2f..d4229e1f18cb1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java @@ -12,53 +12,53 @@ import com.sun.jersey.api.client.UniformInterfaceException; public class ServiceExceptionFactoryTest { - @Test - public void serviceNameAndMessageAndCauseAppearInException() { - // Arrange - ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); - - // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); - - // Assert - assertNotNull(exception); - assertEquals("testing", exception.getServiceName()); - assertEquals("this is a test", exception.getMessage()); - assertEquals(cause, exception.getCause()); - } + @Test + public void serviceNameAndMessageAndCauseAppearInException() { + // Arrange + ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException cause = new UniformInterfaceException( + response); - @Test - public void httpStatusCodeAndReasonPhraseAppearInException() { - // Arrange - ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); - - // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); - - // Assert - assertNotNull(exception); - assertEquals(404, exception.getHttpStatusCode()); - assertEquals("Not Found", exception.getHttpReasonPhrase()); - } - - @Test - public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExceptions() { - // Arrange - ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException rootCause = new UniformInterfaceException(response); - ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException(rootCause)); - ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); + // Act + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); - // Act - ServiceException exception = ServiceExceptionFactory.process("actual", new ServiceException(wrappingException)); - - // Assert - assertEquals(503, exception.getHttpStatusCode()); - assertEquals("underlying", exception.getServiceName()); - } + // Assert + assertNotNull(exception); + assertEquals("testing", exception.getServiceName()); + assertEquals("this is a test", exception.getMessage()); + assertEquals(cause, exception.getCause()); + } + + @Test + public void httpStatusCodeAndReasonPhraseAppearInException() { + // Arrange + ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException cause = new UniformInterfaceException( + response); + + // Act + ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); + + // Assert + assertNotNull(exception); + assertEquals(404, exception.getHttpStatusCode()); + assertEquals("Not Found", exception.getHttpReasonPhrase()); + } + + @Test + public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExceptions() { + // Arrange + ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); + UniformInterfaceException rootCause = new UniformInterfaceException(response); + ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException(rootCause)); + ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); + + // Act + ServiceException exception = ServiceExceptionFactory.process("actual", new ServiceException(wrappingException)); + + // Assert + assertEquals(503, exception.getHttpStatusCode()); + assertEquals("underlying", exception.getServiceName()); + } } From 05a968a07ef0c84bb88ec030ead978942b4f3207 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:41:51 -0800 Subject: [PATCH 146/664] Continued implementation of Subscription Adds SubscriptionDescription knowledge to xsd Adds fluent delegate methods to Subscription data model --- .../services/serviceBus/Subscription.java | 112 +++++++++++++++++- .../src/main/resources/servicebus-atom.xsd | 1 + 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java index 892d3d98c28de..be365ebe7d425 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java @@ -1,15 +1,119 @@ package com.microsoft.azure.services.serviceBus; +import javax.ws.rs.core.MediaType; +import javax.xml.datatype.Duration; + +import com.microsoft.azure.services.serviceBus.implementation.Content; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.EntryModel; -import com.microsoft.azure.services.serviceBus.implementation.QueueDescription; +import com.microsoft.azure.services.serviceBus.implementation.RuleDescription; import com.microsoft.azure.services.serviceBus.implementation.SubscriptionDescription; public class Subscription extends EntryModel { - public Subscription(Entry entry, SubscriptionDescription model) { - super(entry, model); - // TODO Auto-generated constructor stub + public Subscription() { + super(new Entry(), new SubscriptionDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setSubscriptionDescription(getModel()); + } + + public Subscription(Entry entry) { + super(entry, entry.getContent().getSubscriptionDescription()); + } + + public Subscription(String name) { + this(); + setName(name); + } + + public String getName() { + return getEntry().getTitle(); + } + + public Subscription setName(String value) { + getEntry().setTitle(value); + return this; + } + + public Duration getLockDuration() { + return getModel().getLockDuration(); + } + + public Subscription setLockDuration(Duration value) { + getModel().setLockDuration(value); + return this; + } + + public Boolean isRequiresSession() { + return getModel().isRequiresSession(); + } + + public Subscription setRequiresSession(Boolean value) { + getModel().setRequiresSession(value); + return this; + } + + public Duration getDefaultMessageTimeToLive() { + return getModel().getDefaultMessageTimeToLive(); + } + + public Subscription setDefaultMessageTimeToLive(Duration value) { + getModel().setDefaultMessageTimeToLive(value); + return this; + } + + public Boolean isDeadLetteringOnMessageExpiration() { + return getModel().isDeadLetteringOnMessageExpiration(); + } + + public Subscription setDeadLetteringOnMessageExpiration(Boolean value) { + getModel().setDeadLetteringOnMessageExpiration(value); + return this; + } + + public Boolean isDeadLetteringOnFilterEvaluationExceptions() { + return getModel().isDeadLetteringOnFilterEvaluationExceptions(); + } + + public Subscription setDeadLetteringOnFilterEvaluationExceptions(Boolean value) { + getModel().setDeadLetteringOnFilterEvaluationExceptions(value); + return this; + } + + public RuleDescription getDefaultRuleDescription() { + return getModel().getDefaultRuleDescription(); + } + + public Subscription setDefaultRuleDescription(RuleDescription value) { + getModel().setDefaultRuleDescription(value); + return this; } + public Long getMessageCount() { + return getModel().getMessageCount(); + } + + public Subscription setMessageCount(Long value) { + getModel().setMessageCount(value); + return this; + } + + public Integer getMaxDeliveryCount() { + return getModel().getMaxDeliveryCount(); + } + + public Subscription setMaxDeliveryCount(Integer value) { + getModel().setMaxDeliveryCount(value); + return this; + } + + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } + + public Subscription setEnableBatchedOperations(Boolean value) { + getModel().setEnableBatchedOperations(value); + return this; + } } diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index c7649f01686bf..6b319fbb89fb2 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -29,6 +29,7 @@ + From 0daf0938b653594f6c7c4f6be6e3d243cddcb5a9 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:47:22 -0800 Subject: [PATCH 147/664] Running organize imports from Eclipse --- .../.settings/org.eclipse.jdt.core.prefs | 3 ++- .../.settings/org.eclipse.jdt.ui.prefs | 8 ++++++-- .../azure/configuration/Configuration.java | 3 +-- .../blob/implementation/BlobServiceImpl.java | 2 +- .../azure/services/serviceBus/Exports.java | 2 +- .../services/serviceBus/ServiceBusContract.java | 3 +-- .../services/serviceBus/ServiceBusService.java | 1 - .../services/serviceBus/client/MessagingClient.java | 1 - .../serviceBus/implementation/BrokerProperties.java | 1 - .../serviceBus/implementation/EntryModel.java | 1 - .../implementation/EntryModelProvider.java | 1 - .../implementation/ServiceBusRestProxy.java | 13 +++++-------- .../azure/utils/ServiceExceptionFactory.java | 1 - .../microsoft/azure/auth/wrap/WrapClientTest.java | 6 +++--- .../services/blob/BlobServiceIntegrationTest.java | 5 +---- .../serviceBus/BrokerPropertiesMapperTest.java | 1 - .../services/serviceBus/IntegrationTestBase.java | 5 +---- .../services/serviceBus/ServiceBusCreationTest.java | 3 +-- .../serviceBus/ServiceBusIntegrationTest.java | 8 ++------ .../client/MessagingClientIntegrationTest.java | 3 --- 20 files changed, 25 insertions(+), 46 deletions(-) diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs index d71cd7f7e5458..7f276808d59fd 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 09:34:55 PST 2011 +#Fri Nov 11 13:45:12 PST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -95,6 +95,7 @@ org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs index 46133d527bb33..92fc0239bfd40 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 @@ -#Thu Nov 10 13:35:31 PST 2011 +#Fri Nov 11 13:45:12 PST 2011 cleanup.add_default_serial_version_id=true cleanup.add_generated_serial_version_id=false cleanup.add_missing_annotations=true @@ -55,11 +55,15 @@ 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=12 +formatter_settings_version=11 org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=1 sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java index 7374bccc760d8..07790ebe93318 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java @@ -2,11 +2,10 @@ import java.util.HashMap; import java.util.Map; + import com.microsoft.azure.configuration.builder.Builder; import com.microsoft.azure.configuration.builder.DefaultBuilder; import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.json.JSONConfiguration; public class Configuration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java index a0dd788913748..38dc877fc9902 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java @@ -11,7 +11,6 @@ import com.microsoft.azure.ServiceException; import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.GetBlobResult; import com.microsoft.azure.services.blob.BlobOptions; import com.microsoft.azure.services.blob.BlobProperties; import com.microsoft.azure.services.blob.BlobService; @@ -33,6 +32,7 @@ import com.microsoft.azure.services.blob.GetBlobMetadataResult; import com.microsoft.azure.services.blob.GetBlobOptions; import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; +import com.microsoft.azure.services.blob.GetBlobResult; import com.microsoft.azure.services.blob.ListBlobBlocksOptions; import com.microsoft.azure.services.blob.ListBlobBlocksResult; import com.microsoft.azure.services.blob.ListBlobRegionsOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java index 46e0723c20e62..6dc5b6341e236 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java @@ -7,8 +7,8 @@ import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.azure.services.serviceBus.implementation.EntryModelProvider; import com.microsoft.azure.services.serviceBus.implementation.MarshallerProvider; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; +import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java index 4992a15bd2f46..962ead82d959c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java @@ -1,11 +1,10 @@ package com.microsoft.azure.services.serviceBus; +import com.microsoft.azure.ServiceException; import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.Feed; -import com.microsoft.azure.ServiceException; - public interface ServiceBusContract { ServiceBusContract withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java index b65686c6ade3a..a20579c57afbb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java @@ -7,7 +7,6 @@ import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.microsoft.azure.services.serviceBus.implementation.Feed; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java index e19f3c1c234f7..bfc6e60637e91 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java @@ -6,7 +6,6 @@ import com.microsoft.azure.configuration.Configuration; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ReceiveMode; import com.microsoft.azure.services.serviceBus.ServiceBusContract; public class MessagingClient { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java index 83fffa7ad2987..f1d774b1d4e52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java @@ -2,7 +2,6 @@ import java.util.Date; -import org.codehaus.jackson.annotate.JsonGetter; import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java index c59d75de0b59b..07bc648a4905b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java @@ -1,6 +1,5 @@ package com.microsoft.azure.services.serviceBus.implementation; -import com.microsoft.azure.services.serviceBus.implementation.Entry; public class EntryModel { Entry entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java index c7ccce52c0230..5b1d932601615 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java @@ -14,7 +14,6 @@ import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; -import com.microsoft.azure.services.serviceBus.implementation.Entry; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java index 555a329582c3b..3e23c8e94cc94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -11,20 +11,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import com.microsoft.azure.ServiceException; +import com.microsoft.azure.auth.wrap.WrapFilter; +import com.microsoft.azure.http.ClientFilterAdapter; +import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.azure.services.serviceBus.ListQueuesResult; import com.microsoft.azure.services.serviceBus.ListTopicsResult; import com.microsoft.azure.services.serviceBus.Message; import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ListQueuesResult; import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.azure.services.serviceBus.ServiceBusContract; import com.microsoft.azure.services.serviceBus.Topic; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.Feed; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.auth.wrap.WrapFilter; -import com.microsoft.azure.http.ClientFilterAdapter; -import com.microsoft.azure.http.ServiceFilter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java index 2d41da101995a..93130feffe2fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java @@ -1,7 +1,6 @@ package com.microsoft.azure.utils; import com.microsoft.azure.ServiceException; -import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java index 27c336ba2bd08..0f9b5befb240f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java @@ -1,5 +1,8 @@ package com.microsoft.azure.auth.wrap; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -9,9 +12,6 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - import com.microsoft.azure.ServiceException; import com.microsoft.azure.auth.wrap.contract.WrapContract; import com.microsoft.azure.auth.wrap.contract.WrapResponse; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java index 12be28fbd8e42..df00c8a262654 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java @@ -1,9 +1,6 @@ package com.microsoft.azure.services.blob; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java index f376db1b5435e..a2d3cc169e21b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -6,7 +6,6 @@ import java.util.Date; import java.util.TimeZone; -import org.codehaus.jackson.annotate.JsonProperty; import org.junit.Test; import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java index c8236b4474711..b305c22d77520 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java @@ -1,14 +1,11 @@ package com.microsoft.azure.services.serviceBus; -import java.io.Console; +import static com.microsoft.azure.services.serviceBus.Util.*; import org.junit.Before; import org.junit.BeforeClass; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; -import com.microsoft.azure.services.serviceBus.Queue; -import static com.microsoft.azure.services.serviceBus.Util.*; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java index 3f08b85983a6b..b5364e74826ab 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java @@ -1,11 +1,10 @@ package com.microsoft.azure.services.serviceBus; import static org.junit.Assert.*; + import org.junit.Test; import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; public class ServiceBusCreationTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java index 6362ff1ee0f5b..edf83ff3ae492 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,12 +1,12 @@ package com.microsoft.azure.services.serviceBus; +import static org.junit.Assert.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; -import javax.sound.sampled.ReverbType; - import org.junit.Before; import org.junit.Test; @@ -15,10 +15,6 @@ import com.microsoft.azure.http.ServiceFilter; import com.microsoft.azure.http.ServiceFilter.Request; import com.microsoft.azure.http.ServiceFilter.Response; -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.ReceiveMode; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; -import static org.junit.Assert.*; public class ServiceBusIntegrationTest extends IntegrationTestBase { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java index d9298bace7b4d..8a3b1bd4224e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java @@ -2,12 +2,9 @@ import static org.junit.Assert.*; -import java.io.IOException; - import org.junit.Before; import org.junit.Test; -import com.microsoft.azure.ServiceException; import com.microsoft.azure.services.serviceBus.IntegrationTestBase; import com.microsoft.azure.services.serviceBus.Message; From 9b129f48a7e1b5519ce631e17abf736e17f93172 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 16:13:37 -0800 Subject: [PATCH 148/664] Changing package namespace --- .../microsoft/azure/auth/wrap/Exports.java | 16 ---- .../azure/services/blob/Exports.java | 14 --- .../serviceBus/client/MessageSender.java | 8 -- .../ServiceException.java | 2 +- .../windowsazure/auth/wrap/Exports.java | 16 ++++ .../auth/wrap/WrapClient.java | 10 +- .../auth/wrap/WrapFilter.java | 4 +- .../auth/wrap/contract/WrapContract.java | 4 +- .../auth/wrap/contract/WrapContractImpl.java | 6 +- .../auth/wrap/contract/WrapResponse.java | 2 +- .../common/ExponentialRetryPolicyFilter.java | 4 +- .../configuration/Configuration.java | 6 +- .../configuration/builder/Builder.java | 2 +- .../configuration/builder/DefaultBuilder.java | 2 +- .../configuration/jersey/Exports.java | 6 +- .../http/ClientFilterAdapter.java | 6 +- .../http/ServiceFilter.java | 2 +- .../services/blob/AccessCondition.java | 4 +- .../blob/AccessConditionHeaderType.java | 2 +- .../services/blob/AcquireLeaseOptions.java | 2 +- .../services/blob/BlobConfiguration.java | 2 +- .../services/blob/BlobListingDetails.java | 2 +- .../services/blob/BlobOptions.java | 2 +- .../services/blob/BlobProperties.java | 4 +- .../services/blob/BlobService.java | 6 +- .../services/blob/BlobSnapshot.java | 2 +- .../services/blob/BlockList.java | 4 +- .../blob/CommitBlobBlocksOptions.java | 2 +- .../services/blob/ContainerACL.java | 4 +- .../blob/ContainerListingDetails.java | 2 +- .../services/blob/ContainerProperties.java | 2 +- .../services/blob/CopyBlobOptions.java | 2 +- .../services/blob/CreateBlobBlockOptions.java | 2 +- .../services/blob/CreateBlobOptions.java | 2 +- .../services/blob/CreateBlobPagesOptions.java | 2 +- .../services/blob/CreateBlobPagesResult.java | 2 +- .../blob/CreateBlobSnapshotOptions.java | 2 +- .../services/blob/CreateContainerOptions.java | 2 +- .../services/blob/DeleteBlobOptions.java | 2 +- .../services/blob/DeleteContainerOptions.java | 2 +- .../windowsazure/services/blob/Exports.java | 14 +++ .../services/blob/GetBlobMetadataOptions.java | 2 +- .../services/blob/GetBlobMetadataResult.java | 2 +- .../services/blob/GetBlobOptions.java | 2 +- .../blob/GetBlobPropertiesOptions.java | 2 +- .../services/blob/GetBlobResult.java | 2 +- .../services/blob/ListBlobBlocksOptions.java | 2 +- .../services/blob/ListBlobBlocksResult.java | 4 +- .../services/blob/ListBlobRegionsOptions.java | 2 +- .../services/blob/ListBlobRegionsResult.java | 2 +- .../services/blob/ListBlobsOptions.java | 2 +- .../services/blob/ListBlobsResult.java | 6 +- .../services/blob/ListContainersOptions.java | 2 +- .../services/blob/ListContainersResult.java | 6 +- .../services/blob/ServiceProperties.java | 2 +- .../services/blob/SetBlobMetadataOptions.java | 2 +- .../services/blob/SetBlobMetadataResult.java | 2 +- .../blob/SetBlobPropertiesOptions.java | 2 +- .../blob/SetBlobPropertiesResult.java | 2 +- .../blob/SetContainerMetadataOptions.java | 2 +- .../implementation/Base64StringAdapter.java | 2 +- .../implementation/BlobServiceForJersey.java | 92 +++++++++---------- .../blob/implementation/BlobServiceImpl.java | 82 ++++++++--------- .../ContainerACLDateAdapter.java | 2 +- .../ContainerACLDateConverter.java | 2 +- .../blob/implementation/HmacSHA256Sign.java | 2 +- .../blob/implementation/MetadataAdapter.java | 2 +- .../implementation/RFC1123DateAdapter.java | 2 +- .../implementation/RFC1123DateConverter.java | 2 +- .../implementation/SharedKeyLiteFilter.java | 4 +- .../services/serviceBus/Exports.java | 16 ++-- .../services/serviceBus/ListQueuesResult.java | 2 +- .../services/serviceBus/ListTopicsResult.java | 2 +- .../services/serviceBus/Message.java | 4 +- .../services/serviceBus/Queue.java | 10 +- .../serviceBus/ReceiveMessageOptions.java | 2 +- .../services/serviceBus/ReceiveMode.java | 2 +- .../serviceBus/ServiceBusConfiguration.java | 4 +- .../serviceBus/ServiceBusContract.java | 10 +- .../serviceBus/ServiceBusService.java | 12 +-- .../services/serviceBus/Subscription.java | 12 +-- .../services/serviceBus/Topic.java | 10 +- .../services/serviceBus/Util.java | 4 +- .../serviceBus/client/MessageReceiver.java | 8 +- .../serviceBus/client/MessageSender.java | 8 ++ .../serviceBus/client/MessageTransceiver.java | 2 +- .../serviceBus/client/MessagingClient.java | 12 +-- .../implementation/BrokerProperties.java | 2 +- .../BrokerPropertiesMapper.java | 2 +- .../serviceBus/implementation/EntryModel.java | 3 +- .../implementation/EntryModelProvider.java | 2 +- .../implementation/MarshallerProvider.java | 2 +- .../NamespacePrefixMapperImpl.java | 2 +- .../ServiceBusExceptionProcessor.java | 24 ++--- .../implementation/ServiceBusRestProxy.java | 28 +++--- .../utils/DateFactory.java | 2 +- .../utils/DefaultDateFactory.java | 2 +- .../utils/Exports.java | 4 +- .../utils/ServiceExceptionFactory.java | 4 +- ...zure.configuration.builder.Builder$Exports | 5 - ...zure.configuration.builder.Builder$Exports | 5 + .../src/main/resources/package-names.xjb | 4 +- .../services/serviceBus/RetryFilter.java | 31 ------- .../auth/wrap/WrapClientIntegrationTest.java | 5 +- .../auth/wrap/WrapClientTest.java | 11 ++- .../contract/WrapContractIntegrationTest.java | 6 +- .../builder/AlterClassWithProperties.java | 4 +- .../ClassWithMultipleCtorMultipleInject.java | 2 +- .../ClassWithMultipleCtorNoInject.java | 2 +- .../builder/ClassWithNamedParameter.java | 2 +- .../builder/ClassWithProperties.java | 2 +- .../builder/ClassWithSingleCtorNoInject.java | 2 +- .../builder/DefaultBuilderTest.java | 4 +- .../blob/BlobServiceIntegrationTest.java | 37 +++++++- .../services/blob/IntegrationTestBase.java | 5 +- .../BrokerPropertiesMapperTest.java | 6 +- .../serviceBus/IntegrationTestBase.java | 11 ++- .../ServiceBusConfigurationTest.java | 5 +- .../serviceBus/ServiceBusCreationTest.java | 7 +- .../serviceBus/ServiceBusIntegrationTest.java | 19 ++-- .../MessagingClientIntegrationTest.java | 10 +- .../utils/ServiceExceptionFactoryTest.java | 5 +- 122 files changed, 417 insertions(+), 392 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/ServiceException.java (93%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/auth/wrap/WrapClient.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/auth/wrap/WrapFilter.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/auth/wrap/contract/WrapContract.java (56%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/auth/wrap/contract/WrapContractImpl.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/auth/wrap/contract/WrapResponse.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/common/ExponentialRetryPolicyFilter.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/configuration/Configuration.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/configuration/builder/Builder.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/configuration/builder/DefaultBuilder.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/configuration/jersey/Exports.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/http/ClientFilterAdapter.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/http/ServiceFilter.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/AccessCondition.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/AccessConditionHeaderType.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/AcquireLeaseOptions.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobConfiguration.java (81%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobListingDetails.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobOptions.java (84%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobProperties.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobService.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlobSnapshot.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/BlockList.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CommitBlobBlocksOptions.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ContainerACL.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ContainerListingDetails.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ContainerProperties.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CopyBlobOptions.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateBlobBlockOptions.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateBlobOptions.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateBlobPagesOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateBlobPagesResult.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateBlobSnapshotOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/CreateContainerOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/DeleteBlobOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/DeleteContainerOptions.java (87%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/GetBlobMetadataOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/GetBlobMetadataResult.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/GetBlobOptions.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/GetBlobPropertiesOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/GetBlobResult.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobBlocksOptions.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobBlocksResult.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobRegionsOptions.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobRegionsResult.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobsOptions.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListBlobsResult.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListContainersOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ListContainersResult.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/ServiceProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/SetBlobMetadataOptions.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/SetBlobMetadataResult.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/SetBlobPropertiesOptions.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/SetBlobPropertiesResult.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/SetContainerMetadataOptions.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/Base64StringAdapter.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/BlobServiceForJersey.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/BlobServiceImpl.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/ContainerACLDateAdapter.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/ContainerACLDateConverter.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/HmacSHA256Sign.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/MetadataAdapter.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/RFC1123DateAdapter.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/RFC1123DateConverter.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/blob/implementation/SharedKeyLiteFilter.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Exports.java (68%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ListQueuesResult.java (80%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ListTopicsResult.java (80%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Message.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Queue.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ReceiveMessageOptions.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ReceiveMode.java (54%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusConfiguration.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusContract.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusService.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Subscription.java (86%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Topic.java (62%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/Util.java (81%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/client/MessageReceiver.java (53%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/client/MessageTransceiver.java (54%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/client/MessagingClient.java (89%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/BrokerProperties.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/BrokerPropertiesMapper.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/EntryModel.java (85%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/EntryModelProvider.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/MarshallerProvider.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/NamespacePrefixMapperImpl.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/ServiceBusExceptionProcessor.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/services/serviceBus/implementation/ServiceBusRestProxy.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/utils/DateFactory.java (65%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/utils/DefaultDateFactory.java (77%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/utils/Exports.java (62%) rename microsoft-azure-api/src/main/java/com/microsoft/{azure => windowsazure}/utils/ServiceExceptionFactory.java (96%) delete mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports create mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/auth/wrap/WrapClientIntegrationTest.java (85%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/auth/wrap/WrapClientTest.java (91%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/auth/wrap/contract/WrapContractIntegrationTest.java (68%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/AlterClassWithProperties.java (74%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/ClassWithMultipleCtorMultipleInject.java (79%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/ClassWithMultipleCtorNoInject.java (73%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/ClassWithNamedParameter.java (86%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/ClassWithProperties.java (91%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/ClassWithSingleCtorNoInject.java (62%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/configuration/builder/DefaultBuilderTest.java (97%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/blob/BlobServiceIntegrationTest.java (95%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/blob/IntegrationTestBase.java (91%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/BrokerPropertiesMapperTest.java (94%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/IntegrationTestBase.java (80%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusConfigurationTest.java (89%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusCreationTest.java (79%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/ServiceBusIntegrationTest.java (90%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/services/serviceBus/client/MessagingClientIntegrationTest.java (79%) rename microsoft-azure-api/src/test/java/com/microsoft/{azure => windowsazure}/utils/ServiceExceptionFactoryTest.java (93%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java deleted file mode 100644 index a317c746b5eaf..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/Exports.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.microsoft.azure.auth.wrap; - -import com.microsoft.azure.auth.wrap.contract.WrapContract; -import com.microsoft.azure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.azure.configuration.builder.Builder.Registry; - -public class Exports implements - com.microsoft.azure.configuration.builder.Builder.Exports { - - public void register(Registry registry) { - registry.add(WrapContract.class, WrapContractImpl.class); - registry.add(WrapClient.class); - registry.add(WrapFilter.class); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java deleted file mode 100644 index bd35ecad674bd..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/Exports.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.microsoft.azure.services.blob; - -import com.microsoft.azure.configuration.builder.Builder; -import com.microsoft.azure.services.blob.implementation.BlobServiceForJersey; -import com.microsoft.azure.services.blob.implementation.BlobServiceImpl; -import com.microsoft.azure.services.blob.implementation.SharedKeyLiteFilter; - -public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - registry.add(BlobService.class, BlobServiceImpl.class); - registry.add(BlobServiceForJersey.class); - registry.add(SharedKeyLiteFilter.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java deleted file mode 100644 index d388625d33a7d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageSender.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.microsoft.azure.services.serviceBus.client; - -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.services.serviceBus.Message; - -public interface MessageSender { - void sendMessage(Message message) throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java index fb180d3738f65..4519f1bf1034a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java @@ -1,4 +1,4 @@ -package com.microsoft.azure; +package com.microsoft.windowsazure; import java.util.HashMap; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java new file mode 100644 index 0000000000000..5acaa03325cae --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java @@ -0,0 +1,16 @@ +package com.microsoft.windowsazure.auth.wrap; + +import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; +import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; +import com.microsoft.windowsazure.configuration.builder.Builder.Registry; + +public class Exports implements + com.microsoft.windowsazure.configuration.builder.Builder.Exports { + + public void register(Registry registry) { + registry.add(WrapContract.class, WrapContractImpl.class); + registry.add(WrapClient.class); + registry.add(WrapFilter.class); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java index c4063e790e3cd..36bf0683b870d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.auth.wrap; +package com.microsoft.windowsazure.auth.wrap; import java.util.Date; @@ -6,10 +6,10 @@ import javax.inject.Named; import javax.management.timer.Timer; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.auth.wrap.contract.WrapContract; -import com.microsoft.azure.auth.wrap.contract.WrapResponse; -import com.microsoft.azure.utils.DateFactory; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; +import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; +import com.microsoft.windowsazure.utils.DateFactory; public class WrapClient { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java index 0490c0a537617..dd322619984e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.auth.wrap; +package com.microsoft.windowsazure.auth.wrap; -import com.microsoft.azure.ServiceException; +import com.microsoft.windowsazure.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java similarity index 56% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java index a3d5effb686da..7b583d7ef63ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.auth.wrap.contract; +package com.microsoft.windowsazure.auth.wrap.contract; -import com.microsoft.azure.ServiceException; +import com.microsoft.windowsazure.ServiceException; public interface WrapContract { WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java index b6d376c837b62..313d490a9be2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.auth.wrap.contract; +package com.microsoft.windowsazure.auth.wrap.contract; import javax.inject.Inject; import javax.ws.rs.core.MediaType; @@ -6,8 +6,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java index cdea222b9ce3f..ab06407f92f1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/auth/wrap/contract/WrapResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.auth.wrap.contract; +package com.microsoft.windowsazure.auth.wrap.contract; public class WrapResponse { String accessToken; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java index 35901b47afdab..c85f1b2c3fd69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/common/ExponentialRetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.common; +package com.microsoft.windowsazure.common; import java.util.Arrays; import java.util.Random; @@ -6,7 +6,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.windowsazure.http.ServiceFilter; public class ExponentialRetryPolicyFilter implements ServiceFilter { private static final Log log = LogFactory.getLog(ExponentialRetryPolicyFilter.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java index 07790ebe93318..fd794ece45585 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java @@ -1,10 +1,10 @@ -package com.microsoft.azure.configuration; +package com.microsoft.windowsazure.configuration; import java.util.HashMap; import java.util.Map; -import com.microsoft.azure.configuration.builder.Builder; -import com.microsoft.azure.configuration.builder.DefaultBuilder; +import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.configuration.builder.DefaultBuilder; import com.sun.jersey.api.client.config.ClientConfig; public class Configuration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java index 5d72561ed18fb..0a3e11ff25d6d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java index f80d5f65f9951..e6510fdbb8ea1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java index 6d4e177399d18..a6337e8b40f56 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java @@ -1,10 +1,10 @@ -package com.microsoft.azure.configuration.jersey; +package com.microsoft.windowsazure.configuration.jersey; import java.util.Map; import java.util.Map.Entry; -import com.microsoft.azure.configuration.builder.Builder; -import com.microsoft.azure.configuration.builder.Builder.Registry; +import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.configuration.builder.Builder.Registry; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java index 68d6672c0b448..caba87fb4f4d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.http; +package com.microsoft.windowsazure.http; import java.io.InputStream; import java.net.URI; @@ -6,8 +6,8 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.azure.http.ServiceFilter.Request; -import com.microsoft.azure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.http.ServiceFilter.Request; +import com.microsoft.windowsazure.http.ServiceFilter.Response; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java index 3ebd4fe9890dc..4ed73c5318cc5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/http/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.http; +package com.microsoft.windowsazure.http; import java.io.InputStream; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java index 078040b0d5464..14584b02b235e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessCondition.java @@ -1,8 +1,8 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; -import com.microsoft.azure.services.blob.implementation.RFC1123DateConverter; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; /** * Represents a set of access conditions to be used for operations against the storage services. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java index 652aa98ccec49..d7853e9af2008 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AccessConditionHeaderType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AccessConditionHeaderType.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; /** * Specifies the kinds of conditional headers that may be set for a request. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java index aea31118f08a5..1c8c12e0c7ce7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/AcquireLeaseOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class AcquireLeaseOptions extends BlobOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java similarity index 81% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java index b0367a277a12f..6e95bcc286b03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java index 40eab6896dd4a..89a47338fa333 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; /** * Specifies which items to include when listing a set of blobs. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java similarity index 84% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java index 1c649ea881628..33bdb70c4447d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class BlobOptions { // Nullable because it is optional diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java index 4e75ea3e335e0..5b2e4a7a3c91b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.HashMap; @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; // TODO: Unify this with ListBlobsResults.BlobProperties public class BlobProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java index e44e80b550156..2ed07255c9509 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java @@ -1,10 +1,10 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.io.InputStream; 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 BlobService { BlobService withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java index e1fd1fc9c23ec..b899fc651eef5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlobSnapshot.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobSnapshot.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java index 13f5a8362d674..6538b4e147f3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlockList.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.ArrayList; import java.util.List; @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; +import com.microsoft.windowsazure.services.blob.implementation.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class BlockList { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java index ace8125f80655..f2361c346b712 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CommitBlobBlocksOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java index a2a670fd998ec..fd0e57145bfd2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerACL.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.ArrayList; import java.util.Date; @@ -8,7 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.ContainerACLDateAdapter; +import com.microsoft.windowsazure.services.blob.implementation.ContainerACLDateAdapter; public class ContainerACL { private String etag; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java index e8d67b09d566b..e701554e2e637 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerListingDetails.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; /** * Specifies which details to include when listing the containers in this diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java index 80453738f2db2..ed609dbcc1c0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ContainerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java index c1fbe882fd69e..a9fc887f5d35a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CopyBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java index 8d58f73415a16..db6735b76c3ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobBlockOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobBlockOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class CreateBlobBlockOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java index a01bee91e7286..2832661fc240d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java index ad662e262ace5..6237569fa5a72 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class CreateBlobPagesOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java index b41effe812734..23c9ab30ee740 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobPagesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java index fda2f92c4a88d..a55d69c079679 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateBlobSnapshotOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java index 61ca68f781258..dde34928563d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/CreateContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/CreateContainerOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java index 42a8b69b7c0fc..64af6ad591b41 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class DeleteBlobOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java index 08823c610c058..6f02b58a560e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/DeleteContainerOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/DeleteContainerOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class DeleteContainerOptions extends BlobOptions { private AccessCondition accessCondition; 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 new file mode 100644 index 0000000000000..7ddaa2dc3a72b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.services.blob; + +import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.services.blob.implementation.BlobServiceForJersey; +import com.microsoft.windowsazure.services.blob.implementation.BlobServiceImpl; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; + +public class Exports implements Builder.Exports { + public void register(Builder.Registry registry) { + registry.add(BlobService.class, BlobServiceImpl.class); + registry.add(BlobServiceForJersey.class); + registry.add(SharedKeyLiteFilter.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java index 2e31a628f1358..1b688fd5e2bb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class GetBlobMetadataOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java index 1d8b317b5cca2..c6182e85b70cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java index d8ea83aa6eb74..3664c4fb9711c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class GetBlobOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java index d276343c59398..01bac1ef65565 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobPropertiesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class GetBlobPropertiesOptions extends BlobOptions { private String snapshot; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java index a7fecabaf48d4..3771d9e8ea259 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/GetBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/GetBlobResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java index 018e413aea44c..52f56a25ed531 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class ListBlobBlocksOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java index 7c6430a5e9838..18247d2469bf2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobBlocksResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.ArrayList; import java.util.Date; @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.Base64StringAdapter; +import com.microsoft.windowsazure.services.blob.implementation.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class ListBlobBlocksResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java index 54af7e0c78d34..6720f89692b55 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class ListBlobRegionsOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java index 45542cfe03843..54b311c0c3c9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobRegionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobRegionsResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java index a75507f2afe24..87cfacec5ad9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java index cddbcb78ba2fa..c78d44053cdcb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListBlobsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListBlobsResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.HashMap; @@ -10,8 +10,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.MetadataAdapter; -import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; +import com.microsoft.windowsazure.services.blob.implementation.MetadataAdapter; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") public class ListBlobsResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java index f9e547a5fe57f..57e05cdc3ed80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java index 532480c8e75a3..5d391c711b21c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ListContainersResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; import java.util.HashMap; @@ -10,8 +10,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.azure.services.blob.implementation.MetadataAdapter; -import com.microsoft.azure.services.blob.implementation.RFC1123DateAdapter; +import com.microsoft.windowsazure.services.blob.implementation.MetadataAdapter; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; @XmlRootElement(name = "EnumerationResults") public class ListContainersResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java index 65619b7cf7f52..2ed57fbf7599c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/ServiceProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; 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/blob/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java index a8d5e0729f79a..890104b535136 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class SetBlobMetadataOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java index f8f18ec6d6d88..3484a65d7ec26 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobMetadataResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java index eaa0e49258b39..caf14d1a30be0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class SetBlobPropertiesOptions extends BlobOptions { private String leaseId; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java index 6a99c9352f3ef..74a001310fbc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetBlobPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetBlobPropertiesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java index dec78bd216970..3ad16c234e6fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/SetContainerMetadataOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/SetContainerMetadataOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; public class SetContainerMetadataOptions extends BlobOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java index 22cde9443562f..26d19c8cd3117 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java index 095f18c320f03..cc53d3a47bcfd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceForJersey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; import java.util.Arrays; @@ -11,51 +11,51 @@ import javax.inject.Inject; import javax.inject.Named; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.http.ClientFilterAdapter; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.blob.AccessCondition; -import com.microsoft.azure.services.blob.AccessConditionHeaderType; -import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.BlobConfiguration; -import com.microsoft.azure.services.blob.BlobListingDetails; -import com.microsoft.azure.services.blob.BlobOptions; -import com.microsoft.azure.services.blob.BlobProperties; -import com.microsoft.azure.services.blob.BlobService; -import com.microsoft.azure.services.blob.BlobSnapshot; -import com.microsoft.azure.services.blob.BlockList; -import com.microsoft.azure.services.blob.CommitBlobBlocksOptions; -import com.microsoft.azure.services.blob.ContainerACL; -import com.microsoft.azure.services.blob.ContainerListingDetails; -import com.microsoft.azure.services.blob.ContainerProperties; -import com.microsoft.azure.services.blob.CopyBlobOptions; -import com.microsoft.azure.services.blob.CreateBlobBlockOptions; -import com.microsoft.azure.services.blob.CreateBlobOptions; -import com.microsoft.azure.services.blob.CreateBlobPagesOptions; -import com.microsoft.azure.services.blob.CreateBlobPagesResult; -import com.microsoft.azure.services.blob.CreateBlobSnapshotOptions; -import com.microsoft.azure.services.blob.CreateContainerOptions; -import com.microsoft.azure.services.blob.DeleteBlobOptions; -import com.microsoft.azure.services.blob.DeleteContainerOptions; -import com.microsoft.azure.services.blob.GetBlobMetadataOptions; -import com.microsoft.azure.services.blob.GetBlobMetadataResult; -import com.microsoft.azure.services.blob.GetBlobOptions; -import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; -import com.microsoft.azure.services.blob.GetBlobResult; -import com.microsoft.azure.services.blob.ListBlobBlocksOptions; -import com.microsoft.azure.services.blob.ListBlobBlocksResult; -import com.microsoft.azure.services.blob.ListBlobRegionsOptions; -import com.microsoft.azure.services.blob.ListBlobRegionsResult; -import com.microsoft.azure.services.blob.ListBlobsOptions; -import com.microsoft.azure.services.blob.ListBlobsResult; -import com.microsoft.azure.services.blob.ListContainersOptions; -import com.microsoft.azure.services.blob.ListContainersResult; -import com.microsoft.azure.services.blob.ServiceProperties; -import com.microsoft.azure.services.blob.SetBlobMetadataOptions; -import com.microsoft.azure.services.blob.SetBlobMetadataResult; -import com.microsoft.azure.services.blob.SetBlobPropertiesOptions; -import com.microsoft.azure.services.blob.SetBlobPropertiesResult; -import com.microsoft.azure.services.blob.SetContainerMetadataOptions; +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.AccessConditionHeaderType; +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.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java index 38dc877fc9902..ae119143d7ac6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/BlobServiceImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; import java.util.HashMap; @@ -8,46 +8,46 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.blob.AcquireLeaseOptions; -import com.microsoft.azure.services.blob.BlobOptions; -import com.microsoft.azure.services.blob.BlobProperties; -import com.microsoft.azure.services.blob.BlobService; -import com.microsoft.azure.services.blob.BlobSnapshot; -import com.microsoft.azure.services.blob.BlockList; -import com.microsoft.azure.services.blob.CommitBlobBlocksOptions; -import com.microsoft.azure.services.blob.ContainerACL; -import com.microsoft.azure.services.blob.ContainerProperties; -import com.microsoft.azure.services.blob.CopyBlobOptions; -import com.microsoft.azure.services.blob.CreateBlobBlockOptions; -import com.microsoft.azure.services.blob.CreateBlobOptions; -import com.microsoft.azure.services.blob.CreateBlobPagesOptions; -import com.microsoft.azure.services.blob.CreateBlobPagesResult; -import com.microsoft.azure.services.blob.CreateBlobSnapshotOptions; -import com.microsoft.azure.services.blob.CreateContainerOptions; -import com.microsoft.azure.services.blob.DeleteBlobOptions; -import com.microsoft.azure.services.blob.DeleteContainerOptions; -import com.microsoft.azure.services.blob.GetBlobMetadataOptions; -import com.microsoft.azure.services.blob.GetBlobMetadataResult; -import com.microsoft.azure.services.blob.GetBlobOptions; -import com.microsoft.azure.services.blob.GetBlobPropertiesOptions; -import com.microsoft.azure.services.blob.GetBlobResult; -import com.microsoft.azure.services.blob.ListBlobBlocksOptions; -import com.microsoft.azure.services.blob.ListBlobBlocksResult; -import com.microsoft.azure.services.blob.ListBlobRegionsOptions; -import com.microsoft.azure.services.blob.ListBlobRegionsResult; -import com.microsoft.azure.services.blob.ListBlobsOptions; -import com.microsoft.azure.services.blob.ListBlobsResult; -import com.microsoft.azure.services.blob.ListContainersOptions; -import com.microsoft.azure.services.blob.ListContainersResult; -import com.microsoft.azure.services.blob.ServiceProperties; -import com.microsoft.azure.services.blob.SetBlobMetadataOptions; -import com.microsoft.azure.services.blob.SetBlobMetadataResult; -import com.microsoft.azure.services.blob.SetBlobPropertiesOptions; -import com.microsoft.azure.services.blob.SetBlobPropertiesResult; -import com.microsoft.azure.services.blob.SetContainerMetadataOptions; -import com.microsoft.azure.utils.ServiceExceptionFactory; +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.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java index 58c9f01a8392a..fc5f4a291f0ad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java index c890c4cbdc3ec..24154ffcc2ebe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/ContainerACLDateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.text.DateFormat; import java.text.ParseException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java index b9b2b1be3d0f1..5bb7810ccca81 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java index 8b5e1d2782d79..5f9f3a3775d05 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.util.ArrayList; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java index 570246adec097..829eea95ad088 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java index e6ed6f6e7c60c..d379144bf4adf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/RFC1123DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.text.DateFormat; import java.text.ParseException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java index 6e8247277fe16..9566181381336 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/blob/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob.implementation; +package com.microsoft.windowsazure.services.blob.implementation; import java.util.ArrayList; import java.util.Collections; @@ -11,7 +11,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.services.blob.BlobConfiguration; +import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java similarity index 68% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index 6dc5b6341e236..fdce616e6d084 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -1,14 +1,14 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import java.util.Map; -import com.microsoft.azure.configuration.builder.Builder; -import com.microsoft.azure.services.serviceBus.client.MessagingClient; -import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; -import com.microsoft.azure.services.serviceBus.implementation.EntryModelProvider; -import com.microsoft.azure.services.serviceBus.implementation.MarshallerProvider; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusExceptionProcessor; -import com.microsoft.azure.services.serviceBus.implementation.ServiceBusRestProxy; +import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.services.serviceBus.client.MessagingClient; +import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; +import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModelProvider; +import com.microsoft.windowsazure.services.serviceBus.implementation.MarshallerProvider; +import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor; +import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.json.JSONConfiguration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java similarity index 80% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java index ebfb9fc0076fb..a6af5fd05c4ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java similarity index 80% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java index 25cb84cccbaf0..25476ebc85b1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java index eac6a63438465..59a4455191c8d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java @@ -1,10 +1,10 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; -import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; +import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; /** * Represents a service bus message. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java index dd9143e685418..39dc2d42bae13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java @@ -1,12 +1,12 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; -import com.microsoft.azure.services.serviceBus.implementation.Content; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.EntryModel; -import com.microsoft.azure.services.serviceBus.implementation.QueueDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.Content; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; public class Queue extends EntryModel { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java index e5ff93f511e6f..f78b77f11083c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; public class ReceiveMessageOptions { Integer timeout; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java similarity index 54% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java index fb23bc9e8d536..10ae6c5130440 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; public enum ReceiveMode { PEEK_LOCK, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index 04be04a545130..32dea6b47cc06 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.configuration.Configuration; public class ServiceBusConfiguration { public final static String URI = "serviceBus.uri"; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 962ead82d959c..47eb5fd88e797 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,9 +1,9 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.Feed; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; public interface ServiceBusContract { ServiceBusContract withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index a20579c57afbb..eb7abe5d47473 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -1,12 +1,12 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import javax.inject.Inject; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.Feed; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.http.ServiceFilter; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java similarity index 86% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java index be365ebe7d425..70df4b1eee7da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java @@ -1,13 +1,13 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; -import com.microsoft.azure.services.serviceBus.implementation.Content; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.EntryModel; -import com.microsoft.azure.services.serviceBus.implementation.RuleDescription; -import com.microsoft.azure.services.serviceBus.implementation.SubscriptionDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.Content; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; public class Subscription extends EntryModel { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java similarity index 62% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java index 79dcd8bb07247..af9b38bf36caa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java @@ -1,11 +1,11 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import javax.ws.rs.core.MediaType; -import com.microsoft.azure.services.serviceBus.implementation.Content; -import com.microsoft.azure.services.serviceBus.implementation.Entry; -import com.microsoft.azure.services.serviceBus.implementation.EntryModel; -import com.microsoft.azure.services.serviceBus.implementation.TopicDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.Content; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; public class Topic extends EntryModel { public Topic() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java similarity index 81% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 4bd2bcaa0c810..4c7e9c147493c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.azure.ServiceException; +import com.microsoft.windowsazure.ServiceException; public class Util { public static Iterable iterateQueues(ServiceBusContract service) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java similarity index 53% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java index 9ada6e000f9a9..96268b4d29721 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java @@ -1,8 +1,8 @@ -package com.microsoft.azure.services.serviceBus.client; +package com.microsoft.windowsazure.services.serviceBus.client; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; public interface MessageReceiver { Message receiveMessage() throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java new file mode 100644 index 0000000000000..13de652bc2368 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java @@ -0,0 +1,8 @@ +package com.microsoft.windowsazure.services.serviceBus.client; + +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.services.serviceBus.Message; + +public interface MessageSender { + void sendMessage(Message message) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java similarity index 54% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java index 6bded3cb6b0a0..dcc2c17029dad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessageTransceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.client; +package com.microsoft.windowsazure.services.serviceBus.client; public interface MessageTransceiver extends MessageSender, MessageReceiver { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java index bfc6e60637e91..c52c650e206e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java @@ -1,12 +1,12 @@ -package com.microsoft.azure.services.serviceBus.client; +package com.microsoft.windowsazure.services.serviceBus.client; import javax.inject.Inject; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; public class MessagingClient { private ServiceBusContract service; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index f1d774b1d4e52..549efae90c5d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index e1a59b142336d..d443289f1a164 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.IOException; import java.io.StringWriter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java index 07bc648a4905b..71d618e533851 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java @@ -1,5 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; - +package com.microsoft.windowsazure.services.serviceBus.implementation; public class EntryModel { Entry entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java index 5b1d932601615..17569830549b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.IOException; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index 4bc43498df63e..719ba346946bf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java index 751c8d89c6e7e..11b954e7acdb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 5887fd70ddb58..215c8a43455b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -1,26 +1,26 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.inject.Inject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.serviceBus.ListQueuesResult; -import com.microsoft.azure.services.serviceBus.ListTopicsResult; -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; -import com.microsoft.azure.services.serviceBus.Topic; -import com.microsoft.azure.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.Queue; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; public class ServiceBusExceptionProcessor implements ServiceBusContract { - private ServiceBusContract next; + private final ServiceBusContract next; static Log log = LogFactory.getLog(ServiceBusContract.class); public ServiceBusExceptionProcessor(ServiceBusContract next) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 3e23c8e94cc94..8f307f999ae15 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus.implementation; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.ArrayList; import java.util.Arrays; @@ -11,17 +11,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.auth.wrap.WrapFilter; -import com.microsoft.azure.http.ClientFilterAdapter; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.services.serviceBus.ListQueuesResult; -import com.microsoft.azure.services.serviceBus.ListTopicsResult; -import com.microsoft.azure.services.serviceBus.Message; -import com.microsoft.azure.services.serviceBus.Queue; -import com.microsoft.azure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.azure.services.serviceBus.ServiceBusContract; -import com.microsoft.azure.services.serviceBus.Topic; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.auth.wrap.WrapFilter; +import com.microsoft.windowsazure.http.ClientFilterAdapter; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.Queue; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Topic; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; @@ -30,8 +30,8 @@ public class ServiceBusRestProxy implements ServiceBusContract { private Client channel; - private String uri; - private BrokerPropertiesMapper mapper; + private final String uri; + private final BrokerPropertiesMapper mapper; static Log log = LogFactory.getLog(ServiceBusContract.class); ServiceFilter[] filters; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java similarity index 65% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java index 3763c530eb648..9998578fc5809 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.windowsazure.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java similarity index 77% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java index 5d6107605c21c..4677c6291f366 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/DefaultDateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.windowsazure.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java similarity index 62% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java index b223246d67075..b75caf547d68e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.utils; +package com.microsoft.windowsazure.utils; -import com.microsoft.azure.configuration.builder.Builder; +import com.microsoft.windowsazure.configuration.builder.Builder; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java index 93130feffe2fd..39a89358e77b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/azure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java @@ -1,6 +1,6 @@ -package com.microsoft.azure.utils; +package com.microsoft.windowsazure.utils; -import com.microsoft.azure.ServiceException; +import com.microsoft.windowsazure.ServiceException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports deleted file mode 100644 index d10d0c6df32bd..0000000000000 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.azure.configuration.builder.Builder$Exports +++ /dev/null @@ -1,5 +0,0 @@ -com.microsoft.azure.auth.wrap.Exports -com.microsoft.azure.configuration.jersey.Exports -com.microsoft.azure.services.blob.Exports -com.microsoft.azure.services.serviceBus.Exports -com.microsoft.azure.utils.Exports 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 new file mode 100644 index 0000000000000..0b1087c7d616d --- /dev/null +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports @@ -0,0 +1,5 @@ +com.microsoft.windowsazure.auth.wrap.Exports +com.microsoft.windowsazure.configuration.jersey.Exports +com.microsoft.windowsazure.services.blob.Exports +com.microsoft.windowsazure.services.serviceBus.Exports +com.microsoft.windowsazure.utils.Exports diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb index 94ff16dbb2614..70e0e3714dd7b 100644 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ b/microsoft-azure-api/src/main/resources/package-names.xjb @@ -6,12 +6,12 @@ jaxb:extensionBindingPrefixes="xjc"> - + - + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java b/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java deleted file mode 100644 index 10bda5d1b3196..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/RetryFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.microsoft.azure.services.serviceBus; - -import com.microsoft.azure.http.ServiceFilter; - -public class RetryFilter implements ServiceFilter { - - public Response handle(Request request, Next next) { - Response response = null; - Exception error = null; - - for (int retryCount = 0; retryCount != 3; ++retryCount) { - try { - response = next.handle(request); - } - catch (Exception ex) { - error = ex; - } - - boolean shouldRetry = false; - // TODO policy - if (!shouldRetry) - break; - } - if (response == null && error != null) { - // TODO define correct way to rethrow - throw new RuntimeException(error); - } - return response; - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java similarity index 85% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java index 4392a61ffc57b..665d3152297fa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java @@ -1,10 +1,11 @@ -package com.microsoft.azure.auth.wrap; +package com.microsoft.windowsazure.auth.wrap; import junit.framework.Assert; import org.junit.Test; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.auth.wrap.WrapClient; +import com.microsoft.windowsazure.configuration.Configuration; public class WrapClientIntegrationTest { private Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java similarity index 91% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java index 0f9b5befb240f..6dc11fd627667 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.auth.wrap; +package com.microsoft.windowsazure.auth.wrap; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -12,10 +12,11 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.auth.wrap.contract.WrapContract; -import com.microsoft.azure.auth.wrap.contract.WrapResponse; -import com.microsoft.azure.utils.DateFactory; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.auth.wrap.WrapClient; +import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; +import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; +import com.microsoft.windowsazure.utils.DateFactory; public class WrapClientTest { private WrapContract contract; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java similarity index 68% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java index 66e5d515eadbb..46650236ed02a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/auth/wrap/contract/WrapContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java @@ -1,8 +1,10 @@ -package com.microsoft.azure.auth.wrap.contract; +package com.microsoft.windowsazure.auth.wrap.contract; import org.junit.Test; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; +import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; +import com.microsoft.windowsazure.configuration.Configuration; import com.sun.jersey.api.client.Client; public class WrapContractIntegrationTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java similarity index 74% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index 7cbf7288e7dc8..fe3add91c205c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -1,7 +1,9 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import java.util.Map; +import com.microsoft.windowsazure.configuration.builder.Builder; + public class AlterClassWithProperties implements Builder.Alteration { public ClassWithProperties alter(ClassWithProperties instance, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java similarity index 79% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java index 610a9560a3d67..1eb511b7b5a0e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorMultipleInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import javax.inject.Inject; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java similarity index 73% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java index 75faecdfc63a5..bfb5e28955d6b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithMultipleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; public class ClassWithMultipleCtorNoInject { public ClassWithMultipleCtorNoInject() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java similarity index 86% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java index 15cb555e01882..e9f08cad2e950 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithNamedParameter.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import javax.inject.Inject; import javax.inject.Named; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java similarity index 91% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java index 26f13b2004de2..f0b1e1b49ef62 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; public class ClassWithProperties { String foo; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java similarity index 62% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java index 5924cddb64294..13a763a60f799 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/ClassWithSingleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; public class ClassWithSingleCtorNoInject { public ClassWithSingleCtorNoInject() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java similarity index 97% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java index d186be8db6438..1406c10764189 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.configuration.builder; +package com.microsoft.windowsazure.configuration.builder; import java.util.HashMap; import java.util.Map; @@ -10,6 +10,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; +import com.microsoft.windowsazure.configuration.builder.DefaultBuilder; + public class DefaultBuilderTest { Map properties; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java similarity index 95% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java index df00c8a262654..6685c3caa4b74 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/BlobServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import static org.junit.Assert.*; @@ -22,10 +22,37 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.common.ExponentialRetryPolicyFilter; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.http.ServiceFilter; +import com.microsoft.windowsazure.ServiceException; +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; public class BlobServiceIntegrationTest extends IntegrationTestBase { private static final String testContainersPrefix = "sdktest-"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java similarity index 91% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 792c09d75e864..09fa79cf340c6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -1,11 +1,12 @@ -package com.microsoft.azure.services.blob; +package com.microsoft.windowsazure.services.blob; import java.util.Map; import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.blob.BlobConfiguration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java similarity index 94% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java index a2d3cc169e21b..2f2f8d52be6c8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; @@ -8,8 +8,8 @@ import org.junit.Test; -import com.microsoft.azure.services.serviceBus.implementation.BrokerProperties; -import com.microsoft.azure.services.serviceBus.implementation.BrokerPropertiesMapper; +import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; +import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; public class BrokerPropertiesMapperTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java similarity index 80% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index b305c22d77520..1ad04051f637c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -1,11 +1,16 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; -import static com.microsoft.azure.services.serviceBus.Util.*; +import static com.microsoft.windowsazure.services.serviceBus.Util.*; import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.Queue; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Topic; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java similarity index 89% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 2431ed4cd04cc..333460f7266b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -1,10 +1,11 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; import org.junit.Test; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class ServiceBusConfigurationTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java similarity index 79% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index b5364e74826ab..dbb811756a5be 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -1,10 +1,13 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; import org.junit.Test; -import com.microsoft.azure.configuration.Configuration; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusService; public class ServiceBusCreationTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java similarity index 90% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index edf83ff3ae492..8903f7b66cfaf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; @@ -10,11 +10,18 @@ import org.junit.Before; import org.junit.Test; -import com.microsoft.azure.ServiceException; -import com.microsoft.azure.configuration.Configuration; -import com.microsoft.azure.http.ServiceFilter; -import com.microsoft.azure.http.ServiceFilter.Request; -import com.microsoft.azure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.http.ServiceFilter.Request; +import com.microsoft.windowsazure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.Queue; +import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Topic; public class ServiceBusIntegrationTest extends IntegrationTestBase { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java similarity index 79% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java index 8a3b1bd4224e1..02b2ad454002d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/services/serviceBus/client/MessagingClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java @@ -1,12 +1,16 @@ -package com.microsoft.azure.services.serviceBus.client; +package com.microsoft.windowsazure.services.serviceBus.client; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; -import com.microsoft.azure.services.serviceBus.IntegrationTestBase; -import com.microsoft.azure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.IntegrationTestBase; +import com.microsoft.windowsazure.services.serviceBus.Message; +import com.microsoft.windowsazure.services.serviceBus.client.MessageReceiver; +import com.microsoft.windowsazure.services.serviceBus.client.MessageSender; +import com.microsoft.windowsazure.services.serviceBus.client.MessageTransceiver; +import com.microsoft.windowsazure.services.serviceBus.client.MessagingClient; public class MessagingClientIntegrationTest extends IntegrationTestBase { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java similarity index 93% rename from microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index d4229e1f18cb1..af4a944ea8f6f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/azure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.utils; +package com.microsoft.windowsazure.utils; import static org.junit.Assert.*; @@ -6,7 +6,8 @@ import org.junit.Test; -import com.microsoft.azure.ServiceException; +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; From 3a65eab679db17ffe8d3c43cded12c09bc1ef870 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 11 Nov 2011 17:12:02 -0800 Subject: [PATCH 149/664] 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 150/664] 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 151/664] 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 152/664] 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 153/664] 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 154/664] 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 155/664] 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 156/664] 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 157/664] 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 158/664] 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 159/664] 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 160/664] 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 161/664] 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 162/664] 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 163/664] 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 164/664] 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 165/664] 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 166/664] 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 167/664] 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 168/664] 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 169/664] 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 170/664] 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 171/664] 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 172/664] 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 173/664] 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 174/664] 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 175/664] 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 ab43525988def0fec74aa9b09a3737552bc24d22 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 11 Nov 2011 13:59:39 -0800 Subject: [PATCH 176/664] Adding delegate methods to Topic --- .../services/serviceBus/Topic.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java index af9b38bf36caa..38ca9a1100cae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java @@ -1,6 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus; import javax.ws.rs.core.MediaType; +import javax.xml.datatype.Duration; import com.microsoft.windowsazure.services.serviceBus.implementation.Content; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; @@ -19,6 +20,11 @@ public Topic(Entry entry) { super(entry, entry.getContent().getTopicDescription()); } + public Topic(String name) { + this(); + setName(name); + } + public String getName() { return getEntry().getTitle(); } @@ -27,4 +33,54 @@ public Topic setName(String value) { getEntry().setTitle(value); return this; } + + public Duration getDefaultMessageTimeToLive() { + return getModel().getDefaultMessageTimeToLive(); + } + + public Topic setDefaultMessageTimeToLive(Duration value) { + getModel().setDefaultMessageTimeToLive(value); + return this; + } + + public Long getMaxSizeInMegabytes() { + return getModel().getMaxSizeInMegabytes(); + } + + public Topic setMaxSizeInMegabytes(Long value) { + getModel().setMaxSizeInMegabytes(value); + return this; + } + + public Boolean isRequiresDuplicateDetection() { + return getModel().isRequiresDuplicateDetection(); + } + + public Topic setRequiresDuplicateDetection(Boolean value) { + getModel().setRequiresDuplicateDetection(value); + return this; + } + + public Duration getDuplicateDetectionHistoryTimeWindow() { + return getModel().getDuplicateDetectionHistoryTimeWindow(); + } + + public Topic setDuplicateDetectionHistoryTimeWindow(Duration value) { + getModel().setDuplicateDetectionHistoryTimeWindow(value); + return this; + } + + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } + + public Topic setEnableBatchedOperations(Boolean value) { + getModel().setEnableBatchedOperations(value); + return this; + } + + public Long getSizeInBytes() { + return getModel().getSizeInBytes(); + } + } From 455dded713c5120c112e613c48aa6e25eb74e40f Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 12:24:52 -0800 Subject: [PATCH 177/664] Building out REST operations over Subscription entry --- .../serviceBus/ListSubscriptionsResult.java | 16 +++++ .../serviceBus/ServiceBusContract.java | 8 +-- .../serviceBus/ServiceBusService.java | 19 +++-- .../ServiceBusExceptionProcessor.java | 17 ++--- .../implementation/ServiceBusRestProxy.java | 48 +++++++++---- .../serviceBus/ServiceBusIntegrationTest.java | 71 +++++++++++++++++-- 6 files changed, 136 insertions(+), 43 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java new file mode 100644 index 0000000000000..263321fbe4a01 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java @@ -0,0 +1,16 @@ +package com.microsoft.windowsazure.services.serviceBus; + +import java.util.List; + +public class ListSubscriptionsResult { + + private List items; + + List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 47eb5fd88e797..529fa605161d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -40,13 +40,13 @@ public interface ServiceBusContract { ListTopicsResult listTopics() throws ServiceException; - void addSubscription(String topicName, String subscriptionName, Entry subscription) throws ServiceException; + Subscription createSubscription(String topicName, Subscription subscription) throws ServiceException; - void removeSubscription(String topicName, String subscriptionName) throws ServiceException; + void deleteSubscription(String topicName, String subscriptionName) throws ServiceException; - Entry getSubscription(String topicName, String subscriptionName) throws ServiceException; + Subscription getSubscription(String topicName, String subscriptionName) throws ServiceException; - Feed getSubscriptions(String topicName) throws ServiceException; + ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index eb7abe5d47473..0bc16bfd2e59c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -2,11 +2,11 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; @@ -108,23 +108,22 @@ public ListTopicsResult listTopics() throws ServiceException { return next.listTopics(); } - public void addSubscription(String topicName, String subscriptionName, - Entry subscription) throws ServiceException { - next.addSubscription(topicName, subscriptionName, subscription); + public Subscription createSubscription(String topicName, Subscription subscription) throws ServiceException { + return next.createSubscription(topicName, subscription); } - public void removeSubscription(String topicName, String subscriptionName) + public void deleteSubscription(String topicName, String subscriptionName) throws ServiceException { - next.removeSubscription(topicName, subscriptionName); + next.deleteSubscription(topicName, subscriptionName); } - public Entry getSubscription(String topicName, String subscriptionName) + public Subscription getSubscription(String topicName, String subscriptionName) throws ServiceException { return next.getSubscription(topicName, subscriptionName); } - public Feed getSubscriptions(String topicName) throws ServiceException { - return next.getSubscriptions(topicName); + public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { + return next.listSubscriptions(topicName); } public void addRule(String topicName, String subscriptionName, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 215c8a43455b2..c22e6c42067b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -8,11 +8,13 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Subscription; import com.microsoft.windowsazure.services.serviceBus.Topic; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; @@ -242,10 +244,9 @@ public ListTopicsResult listTopics() throws ServiceException { } } - public void addSubscription(String topicPath, String subscriptionName, - Entry subscription) throws ServiceException { + public Subscription createSubscription(String topicPath, Subscription subscription) throws ServiceException { try { - next.addSubscription(topicPath, subscriptionName, subscription); + return next.createSubscription(topicPath, subscription); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -255,10 +256,10 @@ public void addSubscription(String topicPath, String subscriptionName, } } - public void removeSubscription(String topicPath, String subscriptionName) + public void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException { try { - next.removeSubscription(topicPath, subscriptionName); + next.deleteSubscription(topicPath, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -268,7 +269,7 @@ public void removeSubscription(String topicPath, String subscriptionName) } } - public Entry getSubscription(String topicPath, String subscriptionName) + public Subscription getSubscription(String topicPath, String subscriptionName) throws ServiceException { try { return next.getSubscription(topicPath, subscriptionName); @@ -281,9 +282,9 @@ public Entry getSubscription(String topicPath, String subscriptionName) } } - public Feed getSubscriptions(String topicPath) throws ServiceException { + public ListSubscriptionsResult listSubscriptions(String topicPath) throws ServiceException { try { - return next.getSubscriptions(topicPath); + return next.listSubscriptions(topicPath); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 8f307f999ae15..0c1e11848d833 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -16,11 +16,13 @@ import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.Subscription; import com.microsoft.windowsazure.services.serviceBus.Topic; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -214,7 +216,7 @@ public ListQueuesResult listQueues() throws ServiceException { public Topic createTopic(Topic entry) throws ServiceException { return getResource() .path(entry.getName()) - .type("application/atom+xml")//;type=entry;charset=utf-8") + .type("application/atom+xml;type=entry;charset=utf-8") .put(Topic.class, entry); } @@ -243,25 +245,43 @@ public ListTopicsResult listTopics() throws ServiceException { return result; } - public void addSubscription(String topicPath, String subscriptionName, - Entry subscription) { - // TODO Auto-generated method stub - + public Subscription createSubscription(String topicPath, Subscription subscription) { + return getResource() + .path(topicPath) + .path("subscriptions") + .path(subscription.getName()) + .type("application/atom+xml;type=entry;charset=utf-8") + .put(Subscription.class, subscription); } - public void removeSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - + public void deleteSubscription(String topicPath, String subscriptionName) { + getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .delete(); } - public Entry getSubscription(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; + public Subscription getSubscription(String topicPath, String subscriptionName) { + return getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .get(Subscription.class); } - public Feed getSubscriptions(String topicPath) { - // TODO Auto-generated method stub - return null; + public ListSubscriptionsResult listSubscriptions(String topicPath) { + Feed feed = getResource() + .path(topicPath) + .path("subscriptions") + .get(Feed.class); + ArrayList list = new ArrayList(); + for (Entry entry : feed.getEntries()) { + list.add(new Subscription(entry)); + } + ListSubscriptionsResult result = new ListSubscriptionsResult(); + result.setItems(list); + return result; } public void addRule(String topicPath, String subscriptionName, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8903f7b66cfaf..65739474223f7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -15,13 +15,6 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.http.ServiceFilter.Request; import com.microsoft.windowsazure.http.ServiceFilter.Response; -import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.Queue; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.Topic; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -246,4 +239,68 @@ public Response handle(Request request, Next next) { assertEquals(1, requests.size()); assertEquals(1, responses.size()); } + + @Test + public void subscriptionsCanBeCreatedOnTopics() throws Exception { + // Arrange + String topicName = "TestSubscriptionsCanBeCreatedOnTopics"; + service.createTopic(new Topic(topicName)); + + // Act + Subscription created = service.createSubscription(topicName, new Subscription("MySubscription")); + + // Assert + assertNotNull(created); + assertEquals("MySubscription", created.getName()); + } + + @Test + public void subscriptionsCanBeListed() throws Exception { + // Arrange + String topicName = "TestSubscriptionsCanBeListed"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("MySubscription2")); + + // Act + ListSubscriptionsResult result = service.listSubscriptions(topicName); + + // Assert + assertNotNull(result); + assertEquals(1, result.getItems().size()); + assertEquals("MySubscription2", result.getItems().get(0).getName()); + } + + @Test + public void subscriptionsDetailsMayBeFetched() throws Exception { + // Arrange + String topicName = "TestSubscriptionsDetailsMayBeFetched"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("MySubscription3")); + + // Act + Subscription result = service.getSubscription(topicName, "MySubscription3"); + + // Assert + assertNotNull(result); + assertEquals("MySubscription3", result.getName()); + } + + @Test + public void subscriptionsMayBeDeleted() throws Exception { + // Arrange + String topicName = "TestSubscriptionsMayBeDeleted"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("MySubscription4")); + service.createSubscription(topicName, new Subscription("MySubscription5")); + + // Act + service.deleteSubscription(topicName, "MySubscription4"); + + // Assert + ListSubscriptionsResult result = service.listSubscriptions(topicName); + assertNotNull(result); + assertEquals(1, result.getItems().size()); + assertEquals("MySubscription5", result.getItems().get(0).getName()); + + } } From 6b2c865560f524ec1c0ddbc7f7d4143c55db27ba Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 12:28:17 -0800 Subject: [PATCH 178/664] Removing stateful messaging client This code is better as a sample --- .../services/serviceBus/Exports.java | 2 - .../serviceBus/client/MessageReceiver.java | 15 --- .../serviceBus/client/MessageSender.java | 8 -- .../serviceBus/client/MessageTransceiver.java | 5 - .../serviceBus/client/MessagingClient.java | 104 ------------------ .../MessagingClientIntegrationTest.java | 74 ------------- 6 files changed, 208 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index fdce616e6d084..8c881ec5c4a64 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -3,7 +3,6 @@ import java.util.Map; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.serviceBus.client.MessagingClient; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModelProvider; import com.microsoft.windowsazure.services.serviceBus.implementation.MarshallerProvider; @@ -20,7 +19,6 @@ public void register(Builder.Registry registry) { registry.add(ServiceBusService.class); registry.add(ServiceBusExceptionProcessor.class); registry.add(ServiceBusRestProxy.class); - registry.add(MessagingClient.class); // alter jersey client config for serviceBus registry.alter(ClientConfig.class, new Builder.Alteration() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java deleted file mode 100644 index 96268b4d29721..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.microsoft.windowsazure.services.serviceBus.client; - -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; - -public interface MessageReceiver { - Message receiveMessage() throws ServiceException; - - Message receiveMessage(ReceiveMessageOptions options) throws ServiceException; - - void unlockMessage(Message message) throws ServiceException; - - void deleteMessage(Message message) throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java deleted file mode 100644 index 13de652bc2368..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.microsoft.windowsazure.services.serviceBus.client; - -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.services.serviceBus.Message; - -public interface MessageSender { - void sendMessage(Message message) throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java deleted file mode 100644 index dcc2c17029dad..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageTransceiver.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.microsoft.windowsazure.services.serviceBus.client; - -public interface MessageTransceiver extends MessageSender, MessageReceiver { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java deleted file mode 100644 index c52c650e206e1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.microsoft.windowsazure.services.serviceBus.client; - -import javax.inject.Inject; - -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; - -public class MessagingClient { - private ServiceBusContract service; - - public MessagingClient() throws Exception { - this.setService(Configuration.load().create(ServiceBusContract.class)); - } - - public MessagingClient(String profile) throws Exception { - this.setService(Configuration.load().create(profile, ServiceBusContract.class)); - } - - public MessagingClient(Configuration configuration) throws Exception { - this.setService(configuration.create(ServiceBusContract.class)); - } - - public MessagingClient(String profile, Configuration configuration) throws Exception { - this.setService(configuration.create(profile, ServiceBusContract.class)); - } - - @Inject - public MessagingClient(ServiceBusContract service) { - this.setService(service); - } - - public void setService(ServiceBusContract service) { - this.service = service; - } - - public ServiceBusContract getService() { - return service; - } - - public MessageTransceiver openQueue(String queueName) { - final String queue = queueName; - return new MessageTransceiver() { - - public void sendMessage(Message message) throws ServiceException { - service.sendQueueMessage(queue, message); - } - - public Message receiveMessage() throws ServiceException { - return receiveMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message receiveMessage(ReceiveMessageOptions options) - throws ServiceException { - return service.receiveQueueMessage(queue, options); - } - - public void unlockMessage(Message message) throws ServiceException { - service.unlockMessage(message); - } - - public void deleteMessage(Message message) - throws ServiceException { - service.deleteMessage(message); - } - }; - } - - public MessageSender openTopic(String topicName) { - final String topic = topicName; - return new MessageSender() { - public void sendMessage(Message message) throws ServiceException { - service.sendQueueMessage(topic, message); - } - }; - } - - public MessageReceiver openSubscription(String topicName, String subscriptionName) { - final String topic = topicName; - final String subscription = subscriptionName; - return new MessageReceiver() { - - public Message receiveMessage() throws ServiceException { - return receiveMessage(ReceiveMessageOptions.DEFAULT); - } - - public Message receiveMessage(ReceiveMessageOptions options) - throws ServiceException { - return service.receiveSubscriptionMessage(topic, subscription, options); - } - - public void unlockMessage(Message message) throws ServiceException { - service.unlockMessage(message); - } - - public void deleteMessage(Message message) - throws ServiceException { - service.deleteMessage(message); - } - }; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java deleted file mode 100644 index 02b2ad454002d..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClientIntegrationTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.microsoft.windowsazure.services.serviceBus.client; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -import com.microsoft.windowsazure.services.serviceBus.IntegrationTestBase; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.client.MessageReceiver; -import com.microsoft.windowsazure.services.serviceBus.client.MessageSender; -import com.microsoft.windowsazure.services.serviceBus.client.MessageTransceiver; -import com.microsoft.windowsazure.services.serviceBus.client.MessagingClient; - -public class MessagingClientIntegrationTest extends IntegrationTestBase { - - private MessagingClient messaging; - - @Before - public void createClient() throws Exception { - messaging = createConfiguration().create(MessagingClient.class); - } - - @Test - public void queueWillSendAndReceiveMessages() throws Exception { - // Arrange - MessageTransceiver port = messaging.openQueue("TestAlpha"); - Message messageOut = new Message("queueWillSendAndReceiveMessages"); - - // Act - port.sendMessage(messageOut); - Message messageIn = port.receiveMessage(); - - // Assert - assertNotSame(messageOut, messageIn); - - byte[] data = new byte[100]; - int size = messageIn.getBody().read(data); - assertEquals(31, size); - assertEquals("queueWillSendAndReceiveMessages", new String(data, 0, size)); - } - - @Test - public void queueIsSenderAndReceiver() throws Exception { - // Arrange - MessageSender sender = messaging.openQueue("TestAlpha"); - MessageReceiver receiver = messaging.openQueue("TestAlpha"); - Message messageOut = new Message("queueIsSenderAndReceiver"); - - // Act - sender.sendMessage(messageOut); - Message messageIn = receiver.receiveMessage(); - - // Assert - assertNotSame(messageOut, messageIn); - - byte[] data = new byte[100]; - int size = messageIn.getBody().read(data); - assertEquals(24, size); - assertEquals("queueIsSenderAndReceiver", new String(data, 0, size)); - } - - @Test - public void clientMayBeCreatedDirectly() throws Exception { - // Arrange - - // Act - MessagingClient mc = new MessagingClient(createConfiguration()); - mc.openQueue("TestAlpha").sendMessage(new Message("clientMayBeCreatedDirectly")); - - // Assert - } - -} From 8a31ce4857138a5511f3068b990e793db5853c8a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 12:48:49 -0800 Subject: [PATCH 179/664] 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 180/664] 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()); From b61ffc436c7051d62d2230540e1dcbc48eff3041 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 14:15:10 -0800 Subject: [PATCH 181/664] Refactoring ServiceBusContract methods for review notes Standardizes result DTO class conventions Introduces serviceBus.models package for results and options --- .../serviceBus/ServiceBusContract.java | 33 +++++--- .../serviceBus/ServiceBusService.java | 32 +++++--- .../ServiceBusExceptionProcessor.java | 36 +++++---- .../implementation/ServiceBusRestProxy.java | 76 ++++++++++--------- .../serviceBus/models/CreateQueueResult.java | 21 +++++ .../models/CreateSubscriptionResult.java | 21 +++++ .../serviceBus/models/CreateTopicResult.java | 21 +++++ .../serviceBus/models/GetQueueResult.java | 21 +++++ .../models/GetSubscriptionResult.java | 21 +++++ .../serviceBus/models/GetTopicResult.java | 21 +++++ .../{ => models}/ListQueuesResult.java | 6 +- .../{ => models}/ListSubscriptionsResult.java | 6 +- .../{ => models}/ListTopicsResult.java | 6 +- .../{ => models}/ReceiveMessageOptions.java | 3 +- .../serviceBus/{ => models}/ReceiveMode.java | 2 +- .../models/ReceiveQueueMessageResult.java | 21 +++++ .../ReceiveSubscriptionMessageResult.java | 5 ++ .../serviceBus/IntegrationTestBase.java | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 35 +++++---- 19 files changed, 296 insertions(+), 93 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/ListQueuesResult.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/ListSubscriptionsResult.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/ListTopicsResult.java (55%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/ReceiveMessageOptions.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/ReceiveMode.java (51%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 529fa605161d1..7c530fac5b4f8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -4,47 +4,60 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; +import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; public interface ServiceBusContract { ServiceBusContract withFilter(ServiceFilter filter); void sendQueueMessage(String queueName, Message message) throws ServiceException; - Message receiveQueueMessage(String queueName) throws ServiceException; + ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException; - Message receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; void sendTopicMessage(String topicName, Message message) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; + ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; - Message receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; + ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) + throws ServiceException; void unlockMessage(Message message) throws ServiceException; void deleteMessage(Message message) throws ServiceException; - Queue createQueue(Queue queue) throws ServiceException; + CreateQueueResult createQueue(Queue queue) throws ServiceException; void deleteQueue(String queueName) throws ServiceException; - Queue getQueue(String queueName) throws ServiceException; + GetQueueResult getQueue(String queueName) throws ServiceException; ListQueuesResult listQueues() throws ServiceException; - Topic createTopic(Topic topic) throws ServiceException; + CreateTopicResult createTopic(Topic topic) throws ServiceException; void deleteTopic(String topicName) throws ServiceException; - Topic getTopic(String topicName) throws ServiceException; + GetTopicResult getTopic(String topicName) throws ServiceException; ListTopicsResult listTopics() throws ServiceException; - Subscription createSubscription(String topicName, Subscription subscription) throws ServiceException; + CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException; void deleteSubscription(String topicName, String subscriptionName) throws ServiceException; - Subscription getSubscription(String topicName, String subscriptionName) throws ServiceException; + GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException; ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 0bc16bfd2e59c..fb7863908b173 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -7,6 +7,18 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; +import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; @@ -41,12 +53,12 @@ public void sendQueueMessage(String queueName, Message message) next.sendQueueMessage(queueName, message); } - public Message receiveQueueMessage(String queueName) + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { return next.receiveQueueMessage(queueName); } - public Message receiveQueueMessage(String queueName, + public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException { return next.receiveQueueMessage(queueName, options); } @@ -56,12 +68,12 @@ public void sendTopicMessage(String topicName, Message message) next.sendTopicMessage(topicName, message); } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { return next.receiveSubscriptionMessage(topicName, subscriptionName); } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { return next.receiveSubscriptionMessage(topicName, subscriptionName, @@ -76,7 +88,7 @@ public void deleteMessage(Message message) throws ServiceException { next.deleteMessage(message); } - public Queue createQueue(Queue queue) throws ServiceException { + public CreateQueueResult createQueue(Queue queue) throws ServiceException { return next.createQueue(queue); } @@ -84,7 +96,7 @@ public void deleteQueue(String queueName) throws ServiceException { next.deleteQueue(queueName); } - public Queue getQueue(String queueName) throws ServiceException { + public GetQueueResult getQueue(String queueName) throws ServiceException { return next.getQueue(queueName); } @@ -92,7 +104,7 @@ public ListQueuesResult listQueues() throws ServiceException { return next.listQueues(); } - public Topic createTopic(Topic topic) throws ServiceException { + public CreateTopicResult createTopic(Topic topic) throws ServiceException { return next.createTopic(topic); } @@ -100,7 +112,7 @@ public void deleteTopic(String topicName) throws ServiceException { next.deleteTopic(topicName); } - public Topic getTopic(String topicName) throws ServiceException { + public GetTopicResult getTopic(String topicName) throws ServiceException { return next.getTopic(topicName); } @@ -108,7 +120,7 @@ public ListTopicsResult listTopics() throws ServiceException { return next.listTopics(); } - public Subscription createSubscription(String topicName, Subscription subscription) throws ServiceException { + public CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException { return next.createSubscription(topicName, subscription); } @@ -117,7 +129,7 @@ public void deleteSubscription(String topicName, String subscriptionName) next.deleteSubscription(topicName, subscriptionName); } - public Subscription getSubscription(String topicName, String subscriptionName) + public GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException { return next.getSubscription(topicName, subscriptionName); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index c22e6c42067b1..e6b0272e02ce7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -7,15 +7,23 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.Queue; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.Subscription; import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; @@ -56,7 +64,7 @@ public void sendQueueMessage(String path, Message message) } } - public Message receiveQueueMessage(String queueName) + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { try { return next.receiveQueueMessage(queueName); @@ -69,7 +77,7 @@ public Message receiveQueueMessage(String queueName) } } - public Message receiveQueueMessage(String queueName, + public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException { try { return next.receiveQueueMessage(queueName, options); @@ -95,7 +103,7 @@ public void sendTopicMessage(String path, Message message) } } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { try { return next.receiveSubscriptionMessage(topicName, @@ -109,7 +117,7 @@ public Message receiveSubscriptionMessage(String topicName, } } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { try { @@ -148,7 +156,7 @@ public void deleteMessage(Message message) throws ServiceException { } } - public Queue createQueue(Queue queue) throws ServiceException { + public CreateQueueResult createQueue(Queue queue) throws ServiceException { try { return next.createQueue(queue); } @@ -172,7 +180,7 @@ public void deleteQueue(String queuePath) throws ServiceException { } } - public Queue getQueue(String queuePath) throws ServiceException { + public GetQueueResult getQueue(String queuePath) throws ServiceException { try { return next.getQueue(queuePath); } @@ -196,7 +204,7 @@ public ListQueuesResult listQueues() throws ServiceException { } } - public Topic createTopic(Topic topic) throws ServiceException { + public CreateTopicResult createTopic(Topic topic) throws ServiceException { try { return next.createTopic(topic); } @@ -220,7 +228,7 @@ public void deleteTopic(String topicPath) throws ServiceException { } } - public Topic getTopic(String topicPath) throws ServiceException { + public GetTopicResult getTopic(String topicPath) throws ServiceException { try { return next.getTopic(topicPath); } @@ -244,7 +252,7 @@ public ListTopicsResult listTopics() throws ServiceException { } } - public Subscription createSubscription(String topicPath, Subscription subscription) throws ServiceException { + public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) throws ServiceException { try { return next.createSubscription(topicPath, subscription); } @@ -269,7 +277,7 @@ public void deleteSubscription(String topicPath, String subscriptionName) } } - public Subscription getSubscription(String topicPath, String subscriptionName) + public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException { try { return next.getSubscription(topicPath, subscriptionName); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 0c1e11848d833..f7f6d13181b4d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -15,15 +15,23 @@ import com.microsoft.windowsazure.auth.wrap.WrapFilter; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.Queue; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.Subscription; import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; @@ -105,12 +113,12 @@ public void sendQueueMessage(String path, Message message) throws ServiceExcepti sendMessage(path, message); } - public Message receiveQueueMessage(String queueName) + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); } - public Message receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { + public ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { WebResource resource = getResource() .path(queuePath) @@ -137,32 +145,32 @@ else if (options.isPeekLock()) { MediaType contentType = clientResult.getType(); Date date = clientResult.getResponseDate(); - Message result = new Message(); + Message message = new Message(); if (brokerProperties != null) { - result.setProperties(mapper.fromString(brokerProperties)); + message.setProperties(mapper.fromString(brokerProperties)); } if (contentType != null) { - result.setContentType(contentType.toString()); + message.setContentType(contentType.toString()); } if (location != null) { - result.getProperties().setLockLocation(location); + message.getProperties().setLockLocation(location); } - result.setDate(date); - result.setBody(clientResult.getEntityInputStream()); - return result; + message.setDate(date); + message.setBody(clientResult.getEntityInputStream()); + return new ReceiveQueueMessageResult(message); } public void sendTopicMessage(String topicName, Message message) throws ServiceException { sendMessage(topicName, message); } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { // TODO Auto-generated method stub return null; } - public Message receiveSubscriptionMessage(String topicName, + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { // TODO Auto-generated method stub @@ -181,11 +189,11 @@ public void deleteMessage(Message message) throws ServiceException { .delete(); } - public Queue createQueue(Queue entry) throws ServiceException { - return getResource() + public CreateQueueResult createQueue(Queue entry) throws ServiceException { + return new CreateQueueResult(getResource() .path(entry.getName()) - .type("application/atom+xml")//;type=entry;charset=utf-8") - .put(Queue.class, entry); + .type("application/atom+xml;type=entry;charset=utf-8") + .put(Queue.class, entry)); } public void deleteQueue(String queuePath) throws ServiceException { @@ -194,10 +202,10 @@ public void deleteQueue(String queuePath) throws ServiceException { .delete(); } - public Queue getQueue(String queuePath) throws ServiceException { - return getResource() + public GetQueueResult getQueue(String queuePath) throws ServiceException { + return new GetQueueResult(getResource() .path(queuePath) - .get(Queue.class); + .get(Queue.class)); } public ListQueuesResult listQueues() throws ServiceException { @@ -213,11 +221,11 @@ public ListQueuesResult listQueues() throws ServiceException { return result; } - public Topic createTopic(Topic entry) throws ServiceException { - return getResource() + public CreateTopicResult createTopic(Topic entry) throws ServiceException { + return new CreateTopicResult(getResource() .path(entry.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Topic.class, entry); + .put(Topic.class, entry)); } public void deleteTopic(String TopicPath) throws ServiceException { @@ -226,10 +234,10 @@ public void deleteTopic(String TopicPath) throws ServiceException { .delete(); } - public Topic getTopic(String TopicPath) throws ServiceException { - return getResource() + public GetTopicResult getTopic(String TopicPath) throws ServiceException { + return new GetTopicResult(getResource() .path(TopicPath) - .get(Topic.class); + .get(Topic.class)); } public ListTopicsResult listTopics() throws ServiceException { @@ -245,13 +253,13 @@ public ListTopicsResult listTopics() throws ServiceException { return result; } - public Subscription createSubscription(String topicPath, Subscription subscription) { - return getResource() + public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) { + return new CreateSubscriptionResult(getResource() .path(topicPath) .path("subscriptions") .path(subscription.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Subscription.class, subscription); + .put(Subscription.class, subscription)); } public void deleteSubscription(String topicPath, String subscriptionName) { @@ -262,12 +270,12 @@ public void deleteSubscription(String topicPath, String subscriptionName) { .delete(); } - public Subscription getSubscription(String topicPath, String subscriptionName) { - return getResource() + public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) { + return new GetSubscriptionResult(getResource() .path(topicPath) .path("subscriptions") .path(subscriptionName) - .get(Subscription.class); + .get(Subscription.class)); } public ListSubscriptionsResult listSubscriptions(String topicPath) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java new file mode 100644 index 0000000000000..f8eaa0349f6f3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Queue; + +public class CreateQueueResult { + + private Queue value; + + public CreateQueueResult(Queue value) { + this.setValue(value); + } + + public void setValue(Queue value) { + this.value = value; + } + + public Queue getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java new file mode 100644 index 0000000000000..1e600e6e02214 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Subscription; + +public class CreateSubscriptionResult { + + private Subscription value; + + public CreateSubscriptionResult(Subscription value) { + this.setValue(value); + } + + public void setValue(Subscription value) { + this.value = value; + } + + public Subscription getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java new file mode 100644 index 0000000000000..0e5cf9a04505f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Topic; + +public class CreateTopicResult { + + private Topic value; + + public CreateTopicResult(Topic value) { + this.setValue(value); + } + + public void setValue(Topic value) { + this.value = value; + } + + public Topic getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java new file mode 100644 index 0000000000000..fd6032caf3334 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Queue; + +public class GetQueueResult { + + private Queue value; + + public GetQueueResult(Queue value) { + this.setValue(value); + } + + public void setValue(Queue value) { + this.value = value; + } + + public Queue getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java new file mode 100644 index 0000000000000..fd3f4ad17260e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Subscription; + +public class GetSubscriptionResult { + + private Subscription value; + + public GetSubscriptionResult(Subscription value) { + this.setValue(value); + } + + public void setValue(Subscription value) { + this.value = value; + } + + public Subscription getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java new file mode 100644 index 0000000000000..eea050fc6c222 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Topic; + +public class GetTopicResult { + + private Topic value; + + public GetTopicResult(Topic value) { + this.setValue(value); + } + + public void setValue(Topic value) { + this.value = value; + } + + public Topic getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index a6af5fd05c4ed..6b2c4812ebcc7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -1,12 +1,14 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; +import com.microsoft.windowsazure.services.serviceBus.Queue; + public class ListQueuesResult { private List items; - List getItems() { + public List getItems() { return items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 263321fbe4a01..4fa900852cc9f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -1,12 +1,14 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; +import com.microsoft.windowsazure.services.serviceBus.Subscription; + public class ListSubscriptionsResult { private List items; - List getItems() { + public List getItems() { return items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java similarity index 55% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index 25476ebc85b1b..64d3b468e8ea4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -1,12 +1,14 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; +import com.microsoft.windowsazure.services.serviceBus.Topic; + public class ListTopicsResult { private List items; - List getItems() { + public List getItems() { return items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java index f78b77f11083c..f9bda855f4ea9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; + public class ReceiveMessageOptions { Integer timeout; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java similarity index 51% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java index 10ae6c5130440..195c2fa8ad7c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; public enum ReceiveMode { PEEK_LOCK, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java new file mode 100644 index 0000000000000..d7a6fb03c6ff1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import com.microsoft.windowsazure.services.serviceBus.Message; + +public class ReceiveQueueMessageResult { + + private Message value; + + public ReceiveQueueMessageResult(Message value) { + this.setValue(value); + } + + public void setValue(Message value) { + this.value = value; + } + + public Message getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java new file mode 100644 index 0000000000000..f886781c427ab --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class ReceiveSubscriptionMessageResult { + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 1ad04051f637c..d5a1a1bd2d579 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -7,10 +7,10 @@ import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.services.serviceBus.Queue; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 65739474223f7..d40a38dfbff14 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -15,6 +15,10 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.http.ServiceFilter.Request; import com.microsoft.windowsazure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -35,7 +39,7 @@ public void fetchQueueAndListQueuesWorks() throws Exception { // Arrange // Act - Queue entry = service.getQueue("TestAlpha"); + Queue entry = service.getQueue("TestAlpha").getValue(); ListQueuesResult feed = service.listQueues(); // Assert @@ -49,7 +53,7 @@ public void createQueueWorks() throws Exception { // Act Queue queue = new Queue("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); - Queue saved = service.createQueue(queue); + Queue saved = service.createQueue(queue).getValue(); // Assert assertNotNull(saved); @@ -87,7 +91,7 @@ public void receiveMessageWorks() throws Exception { service.sendQueueMessage(queueName, new Message("Hello World")); // Act - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -104,7 +108,7 @@ public void peekLockMessageWorks() throws Exception { service.sendQueueMessage(queueName, new Message("Hello Again")); // Act - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Assert byte[] data = new byte[100]; @@ -119,7 +123,7 @@ public void peekLockedMessageCanBeCompleted() throws Exception { String queueName = "TestPeekLockedMessageCanBeCompleted"; service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = message.getLockToken(); @@ -140,14 +144,14 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { String queueName = "TestPeekLockedMessageCanBeUnlocked"; service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.unlockMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(lockToken); @@ -162,14 +166,14 @@ public void peekLockedMessageCanBeDeleted() throws Exception { String queueName = "TestPeekLockedMessageCanBeDeleted"; service.createQueue(new Queue(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS); + Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.deleteMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(lockToken); @@ -188,7 +192,7 @@ public void contentTypePassesThrough() throws Exception { service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); + Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(message); @@ -201,9 +205,9 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; // Act - Topic created = service.createTopic(new Topic().setName(topicName)); + Topic created = service.createTopic(new Topic().setName(topicName)).getValue(); ListTopicsResult listed = service.listTopics(); - Topic fetched = service.getTopic(topicName); + Topic fetched = service.getTopic(topicName).getValue(); service.deleteTopic(topicName); ListTopicsResult listed2 = service.listTopics(); @@ -232,7 +236,7 @@ public Response handle(Request request, Next next) { }); // Act - Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")); + Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")).getValue(); // Assert assertNotNull(created); @@ -247,7 +251,7 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { service.createTopic(new Topic(topicName)); // Act - Subscription created = service.createSubscription(topicName, new Subscription("MySubscription")); + Subscription created = service.createSubscription(topicName, new Subscription("MySubscription")).getValue(); // Assert assertNotNull(created); @@ -278,7 +282,7 @@ public void subscriptionsDetailsMayBeFetched() throws Exception { service.createSubscription(topicName, new Subscription("MySubscription3")); // Act - Subscription result = service.getSubscription(topicName, "MySubscription3"); + Subscription result = service.getSubscription(topicName, "MySubscription3").getValue(); // Assert assertNotNull(result); @@ -301,6 +305,5 @@ public void subscriptionsMayBeDeleted() throws Exception { assertNotNull(result); assertEquals(1, result.getItems().size()); assertEquals("MySubscription5", result.getItems().get(0).getName()); - } } From 656fe6c364d71ba5d6fa094bfa0b37021fcdc1b4 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 14:54:43 -0800 Subject: [PATCH 182/664] Moving domain objects into models package --- .../services/serviceBus/ServiceBusContract.java | 4 ++++ .../services/serviceBus/ServiceBusService.java | 4 ++++ .../microsoft/windowsazure/services/serviceBus/Util.java | 2 ++ .../implementation/ServiceBusExceptionProcessor.java | 8 ++++---- .../serviceBus/implementation/ServiceBusRestProxy.java | 8 ++++---- .../services/serviceBus/models/CreateQueueResult.java | 1 - .../serviceBus/models/CreateSubscriptionResult.java | 1 - .../services/serviceBus/models/CreateTopicResult.java | 1 - .../services/serviceBus/models/GetQueueResult.java | 1 - .../services/serviceBus/models/GetSubscriptionResult.java | 1 - .../services/serviceBus/models/GetTopicResult.java | 1 - .../services/serviceBus/models/ListQueuesResult.java | 1 - .../serviceBus/models/ListSubscriptionsResult.java | 1 - .../services/serviceBus/models/ListTopicsResult.java | 1 - .../services/serviceBus/{ => models}/Message.java | 2 +- .../services/serviceBus/{ => models}/Queue.java | 2 +- .../serviceBus/models/ReceiveQueueMessageResult.java | 1 - .../services/serviceBus/{ => models}/Subscription.java | 2 +- .../services/serviceBus/{ => models}/Topic.java | 2 +- .../services/serviceBus/IntegrationTestBase.java | 4 ++-- .../services/serviceBus/ServiceBusIntegrationTest.java | 4 ++++ 21 files changed, 28 insertions(+), 24 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/Message.java (99%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/Queue.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/Subscription.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/{ => models}/Topic.java (97%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 7c530fac5b4f8..dc7f0deeade1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -13,9 +13,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; public interface ServiceBusContract { ServiceBusContract withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index fb7863908b173..45ee452ffeaec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -16,9 +16,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 4c7e9c147493c..295909d50d110 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,6 +1,8 @@ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; public class Util { public static Iterable iterateQueues(ServiceBusContract service) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index e6b0272e02ce7..4a9fb4b6a4f93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -7,11 +7,7 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.Subscription; -import com.microsoft.windowsazure.services.serviceBus.Topic; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; @@ -21,9 +17,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index f7f6d13181b4d..8bd0946c9f997 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -15,11 +15,7 @@ import com.microsoft.windowsazure.auth.wrap.WrapFilter; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.Subscription; -import com.microsoft.windowsazure.services.serviceBus.Topic; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; @@ -29,9 +25,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index f8eaa0349f6f3..85107629fb02f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Queue; public class CreateQueueResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 1e600e6e02214..3b74257241380 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Subscription; public class CreateSubscriptionResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 0e5cf9a04505f..10192e3e454a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Topic; public class CreateTopicResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index fd6032caf3334..005b5a5a8c1f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Queue; public class GetQueueResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index fd3f4ad17260e..4e28a6137f1ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Subscription; public class GetSubscriptionResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index eea050fc6c222..5c6a0af54619c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Topic; public class GetTopicResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index 6b2c4812ebcc7..cfe755389d9ad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -2,7 +2,6 @@ import java.util.List; -import com.microsoft.windowsazure.services.serviceBus.Queue; public class ListQueuesResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 4fa900852cc9f..4624ba154806e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -2,7 +2,6 @@ import java.util.List; -import com.microsoft.windowsazure.services.serviceBus.Subscription; public class ListSubscriptionsResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index 64d3b468e8ea4..5d3047674426e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -2,7 +2,6 @@ import java.util.List; -import com.microsoft.windowsazure.services.serviceBus.Topic; public class ListTopicsResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java index 59a4455191c8d..d0a82299965de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java index 39dc2d42bae13..2bfb8506fe2b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java index d7a6fb03c6ff1..5e6e31989fbc7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.serviceBus.models; -import com.microsoft.windowsazure.services.serviceBus.Message; public class ReceiveQueueMessageResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java index 70df4b1eee7da..5076f7f350b88 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java index 38ca9a1100cae..c8b08f1d585ad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; import javax.xml.datatype.Duration; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index d5a1a1bd2d579..0dbc7fbb6fceb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -6,11 +6,11 @@ import org.junit.BeforeClass; import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; public abstract class IntegrationTestBase { protected Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index d40a38dfbff14..2c3066e692746 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -18,7 +18,11 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; +import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.Topic; public class ServiceBusIntegrationTest extends IntegrationTestBase { From 25f0aedbcb65e3df105827d8de1b7399aead4c85 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 15:16:03 -0800 Subject: [PATCH 183/664] Implementing receiveMessage operation for subscription --- .../implementation/ServiceBusRestProxy.java | 21 ++++++++++++++----- .../ReceiveSubscriptionMessageResult.java | 14 +++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 20 ++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 8bd0946c9f997..78ebd91a7194c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -125,6 +125,11 @@ public ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMe .path("messages") .path("head"); + Message message = receiveMessage(options, resource); + return new ReceiveQueueMessageResult(message); + } + + private Message receiveMessage(ReceiveMessageOptions options, WebResource resource) { if (options.getTimeout() != null) { resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); } @@ -157,7 +162,7 @@ else if (options.isPeekLock()) { } message.setDate(date); message.setBody(clientResult.getEntityInputStream()); - return new ReceiveQueueMessageResult(message); + return message; } public void sendTopicMessage(String topicName, Message message) throws ServiceException { @@ -166,15 +171,21 @@ public void sendTopicMessage(String topicName, Message message) throws ServiceEx public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { - // TODO Auto-generated method stub - return null; + return receiveSubscriptionMessage(topicName, subscriptionName, ReceiveMessageOptions.DEFAULT); } public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource resource = getResource() + .path(topicName) + .path("subscriptions") + .path(subscriptionName) + .path("messages") + .path("head"); + + Message message = receiveMessage(options, resource); + return new ReceiveSubscriptionMessageResult(message); } public void unlockMessage(Message message) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java index f886781c427ab..3666750e431eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -2,4 +2,18 @@ public class ReceiveSubscriptionMessageResult { + private Message value; + + public ReceiveSubscriptionMessageResult(Message value) { + this.setValue(value); + } + + public void setValue(Message value) { + this.value = value; + } + + public Message getValue() { + return value; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 2c3066e692746..fd8f891c91b48 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -310,4 +310,24 @@ public void subscriptionsMayBeDeleted() throws Exception { assertEquals(1, result.getItems().size()); assertEquals("MySubscription5", result.getItems().get(0).getName()); } + + @Test + public void subscriptionWillReceiveMessage() throws Exception { + // Arrange + String topicName = "TestSubscriptionWillReceiveMessage"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("sub")); + service.sendTopicMessage(topicName, new Message("

Testing subscription

").setContentType("text/html")); + + // Act + Message message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS).getValue(); + + // Assert + assertNotNull(message); + + byte[] data = new byte[100]; + int size = message.getBody().read(data); + assertEquals("

Testing subscription

", new String(data, 0, size)); + assertEquals("text/html", message.getContentType()); + } } From 3a2574d01a42b2b6b8be34d4ba73a6320ffd7a20 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 15:24:20 -0800 Subject: [PATCH 184/664] Renames according to naming conventions --- ...ServiceContract.java => BlobContract.java} | 2 +- .../services/blob/BlobService.java | 332 ++++++++++++++++++ .../windowsazure/services/blob/Exports.java | 8 +- ...eImpl.java => BlobExceptionProcessor.java} | 16 +- ...rviceForJersey.java => BlobRestProxy.java} | 24 +- .../services/blob/models/GetBlobResult.java | 17 +- .../windowsazure/services/queue/Exports.java | 8 +- ...erviceContract.java => QueueContract.java} | 2 +- .../services/queue/QueueService.java | 157 +++++++++ ...Impl.java => QueueExceptionProcessor.java} | 16 +- ...viceForJersey.java => QueueRestProxy.java} | 15 +- .../blob/BlobServiceIntegrationTest.java | 107 +++--- .../queue/QueueServiceIntegrationTest.java | 34 +- 13 files changed, 616 insertions(+), 122 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/{BlobServiceContract.java => BlobContract.java} (99%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/{BlobServiceImpl.java => BlobExceptionProcessor.java} (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/{BlobServiceForJersey.java => BlobRestProxy.java} (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/{QueueServiceContract.java => QueueContract.java} (97%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/{QueueServiceImpl.java => QueueExceptionProcessor.java} (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/{QueueServiceForJersey.java => QueueRestProxy.java} (95%) 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/BlobContract.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobServiceContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index fe1ce485a51d7..6a0c7096de9ca 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/BlobContract.java @@ -46,7 +46,7 @@ import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; -public interface BlobServiceContract extends FilterableService { +public interface BlobContract 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/BlobService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java new file mode 100644 index 0000000000000..27e07821df9ca --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java @@ -0,0 +1,332 @@ +package com.microsoft.windowsazure.services.blob; + +import java.io.InputStream; +import java.util.HashMap; + +import javax.inject.Inject; + +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; +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.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.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; +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.GetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +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; +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.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; +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 class BlobService implements BlobContract { + final BlobContract next; + + public BlobService() throws Exception { + this(null, Configuration.getInstance()); + } + + public BlobService(Configuration config) throws Exception { + this(null, config); + } + + public BlobService(String profile) throws Exception { + this(profile, Configuration.getInstance()); + } + + public BlobService(String profile, Configuration config) throws Exception { + next = config.create(profile, BlobContract.class); + } + + @Inject + public BlobService(BlobContract next) throws Exception { + this.next = next; + } + + public BlobContract withFilter(ServiceFilter filter) { + return next.withFilter(filter); + } + + public GetServicePropertiesResult getServiceProperties() throws ServiceException { + return next.getServiceProperties(); + } + + public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { + return next.getServiceProperties(options); + } + + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { + next.setServiceProperties(serviceProperties); + } + + public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException { + next.setServiceProperties(serviceProperties, options); + } + + public ListContainersResult listContainers() throws ServiceException { + return next.listContainers(); + } + + public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { + return next.listContainers(options); + } + + public void createContainer(String container) throws ServiceException { + next.createContainer(container); + } + + public void createContainer(String container, CreateContainerOptions options) throws ServiceException { + next.createContainer(container, options); + } + + public void deleteContainer(String container) throws ServiceException { + next.deleteContainer(container); + } + + public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { + next.deleteContainer(container, options); + } + + public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { + return next.getContainerProperties(container); + } + + public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException { + return next.getContainerProperties(container, options); + } + + public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { + return next.getContainerMetadata(container); + } + + public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException { + return next.getContainerMetadata(container, options); + } + + public GetContainerACLResult getContainerACL(String container) throws ServiceException { + return next.getContainerACL(container); + } + + public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { + return next.getContainerACL(container, options); + } + + public void setContainerACL(String container, ContainerACL acl) throws ServiceException { + next.setContainerACL(container, acl); + } + + public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { + next.setContainerACL(container, acl, options); + } + + public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { + next.setContainerMetadata(container, metadata); + } + + public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { + next.setContainerMetadata(container, metadata, options); + } + + public ListBlobsResult listBlobs(String container) throws ServiceException { + return next.listBlobs(container); + } + + public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { + return next.listBlobs(container, options); + } + + public void createPageBlob(String container, String blob, int length) throws ServiceException { + next.createPageBlob(container, blob, length); + } + + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + next.createPageBlob(container, blob, length, options); + } + + public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { + next.createBlockBlob(container, blob, contentStream); + } + + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + next.createBlockBlob(container, blob, contentStream, options); + } + + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { + return next.clearBlobPages(container, blob, range); + } + + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { + return next.clearBlobPages(container, blob, range, options); + } + + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) + throws ServiceException { + return next.createBlobPages(container, blob, range, length, contentStream); + } + + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, + CreateBlobPagesOptions options) throws ServiceException { + return next.createBlobPages(container, blob, range, length, contentStream, options); + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + next.createBlobBlock(container, blob, blockId, contentStream); + } + + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) + throws ServiceException { + next.createBlobBlock(container, blob, blockId, contentStream, options); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { + next.commitBlobBlocks(container, blob, blockList); + } + + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + next.commitBlobBlocks(container, blob, blockList, options); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { + return next.listBlobBlocks(container, blob); + } + + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + return next.listBlobBlocks(container, blob, options); + } + + public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { + return next.getBlobProperties(container, blob); + } + + public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + return next.getBlobProperties(container, blob, options); + } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { + return next.getBlobMetadata(container, blob); + } + + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + return next.getBlobMetadata(container, blob, options); + } + + public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { + return next.listBlobRegions(container, blob); + } + + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + return next.listBlobRegions(container, blob, options); + } + + public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { + return next.setBlobProperties(container, blob); + } + + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + return next.setBlobProperties(container, blob, options); + } + + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + return next.setBlobMetadata(container, blob, metadata); + } + + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) + throws ServiceException { + return next.setBlobMetadata(container, blob, metadata, options); + } + + public GetBlobResult getBlob(String container, String blob) throws ServiceException { + return next.getBlob(container, blob); + } + + public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + return next.getBlob(container, blob, options); + } + + public void deleteBlob(String container, String blob) throws ServiceException { + next.deleteBlob(container, blob); + } + + public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { + next.deleteBlob(container, blob, options); + } + + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { + return next.createBlobSnapshot(container, blob); + } + + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + return next.createBlobSnapshot(container, blob, options); + } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); + } + + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) + throws ServiceException { + next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); + } + + public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { + return next.acquireLease(container, blob); + } + + public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + return next.acquireLease(container, blob, options); + } + + public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { + return next.renewLease(container, blob, leaseId); + } + + public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + return next.renewLease(container, blob, leaseId, options); + } + + public void releaseLease(String container, String blob, String leaseId) throws ServiceException { + next.releaseLease(container, blob, leaseId); + } + + public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + next.releaseLease(container, blob, leaseId, options); + } + + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + next.breakLease(container, blob, leaseId); + } + + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + next.breakLease(container, blob, leaseId, options); + } +} 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 f921e376dee2f..1b6ca2d36d6e8 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 @@ -1,14 +1,14 @@ package com.microsoft.windowsazure.services.blob; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.blob.implementation.BlobServiceForJersey; -import com.microsoft.windowsazure.services.blob.implementation.BlobServiceImpl; +import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; +import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(BlobServiceContract.class, BlobServiceImpl.class); - registry.add(BlobServiceForJersey.class); + registry.add(BlobContract.class, BlobExceptionProcessor.class); + registry.add(BlobRestProxy.class); registry.add(SharedKeyLiteFilter.class); } } 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/BlobExceptionProcessor.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index e4ad60d8c8f14..7e4fc8b7e5876 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/BlobExceptionProcessor.java @@ -10,7 +10,7 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.blob.BlobServiceContract; +import com.microsoft.windowsazure.services.blob.BlobContract; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; @@ -55,21 +55,21 @@ import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; -public class BlobServiceImpl implements BlobServiceContract { - private static Log log = LogFactory.getLog(BlobServiceImpl.class); - private final BlobServiceContract service; +public class BlobExceptionProcessor implements BlobContract { + private static Log log = LogFactory.getLog(BlobExceptionProcessor.class); + private final BlobContract service; @Inject - public BlobServiceImpl(BlobServiceForJersey service) { + public BlobExceptionProcessor(BlobRestProxy service) { this.service = service; } - public BlobServiceImpl(BlobServiceContract service) { + public BlobExceptionProcessor(BlobContract service) { this.service = service; } - public BlobServiceContract withFilter(ServiceFilter filter) { - return new BlobServiceImpl(service.withFilter(filter)); + public BlobContract withFilter(ServiceFilter filter) { + return new BlobExceptionProcessor(service.withFilter(filter)); } private ServiceException processCatch(ServiceException e) { 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/BlobRestProxy.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobServiceForJersey.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 9251166e19ae1..c2245a10460b0 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/BlobRestProxy.java @@ -12,7 +12,7 @@ import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobConfiguration; -import com.microsoft.windowsazure.services.blob.BlobServiceContract; +import com.microsoft.windowsazure.services.blob.BlobContract; 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; @@ -62,8 +62,8 @@ import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.core.util.Base64; -public class BlobServiceForJersey implements BlobServiceContract { - // private static Log log = LogFactory.getLog(BlobServiceForJersey.class); +public class BlobRestProxy implements BlobContract { + // private static Log log = LogFactory.getLog(BlobRestProxy.class); private static final String API_VERSION = "2011-08-18"; private final Client channel; @@ -74,7 +74,7 @@ public class BlobServiceForJersey implements BlobServiceContract { private final SharedKeyLiteFilter filter; @Inject - public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, + public BlobRestProxy(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, SharedKeyLiteFilter filter) { this.channel = channel; @@ -86,8 +86,7 @@ public BlobServiceForJersey(Client channel, @Named(BlobConfiguration.ACCOUNT_NAM channel.addFilter(filter); } - public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, - RFC1123DateConverter dateMapper) { + public BlobRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; @@ -97,10 +96,10 @@ public BlobServiceForJersey(Client channel, ServiceFilter[] filters, String acco this.dateMapper = dateMapper; } - public BlobServiceContract withFilter(ServiceFilter filter) { + public BlobContract 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); + return new BlobRestProxy(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); } private void ThrowIfError(ClientResponse r) { @@ -177,7 +176,7 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { return builder; } - private GetBlobPropertiesResult getBlobPropertiesFromResponse(ClientResponse response) { + private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { // Properties BlobProperties properties = new BlobProperties(); properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); @@ -480,7 +479,7 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob, ClientResponse response = builder.method("HEAD", ClientResponse.class); ThrowIfError(response); - return getBlobPropertiesFromResponse(response); + return getBlobPropertiesResultFromResponse(response); } public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { @@ -583,9 +582,10 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio ClientResponse response = builder.get(ClientResponse.class); ThrowIfError(response); - GetBlobPropertiesResult properties = getBlobPropertiesFromResponse(response); + GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response); GetBlobResult blobResult = new GetBlobResult(); - blobResult.setProperties(properties); + blobResult.setProperties(properties.getProperties()); + blobResult.setMetadata(properties.getMetadata()); blobResult.setContentStream(response.getEntityInputStream()); return blobResult; } 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 f26772819be5e..3c65e0cfd8e71 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 @@ -1,11 +1,12 @@ package com.microsoft.windowsazure.services.blob.models; import java.io.InputStream; - +import java.util.HashMap; public class GetBlobResult { private InputStream contentStream; - private GetBlobPropertiesResult properties; + private BlobProperties properties; + private HashMap metadata; public InputStream getContentStream() { return contentStream; @@ -15,11 +16,19 @@ public void setContentStream(InputStream contentStream) { this.contentStream = contentStream; } - public GetBlobPropertiesResult getProperties() { + public BlobProperties getProperties() { return properties; } - public void setProperties(GetBlobPropertiesResult properties) { + public void setProperties(BlobProperties properties) { this.properties = properties; } + + public HashMap getMetadata() { + return metadata; + } + + public void setMetadata(HashMap metadata) { + this.metadata = metadata; + } } 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 8998a2fca38a7..372527a5daab7 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,14 +1,14 @@ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.queue.implementation.QueueServiceForJersey; -import com.microsoft.windowsazure.services.queue.implementation.QueueServiceImpl; +import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; +import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { - registry.add(QueueServiceContract.class, QueueServiceImpl.class); - registry.add(QueueServiceForJersey.class); + registry.add(QueueContract.class, QueueExceptionProcessor.class); + registry.add(QueueRestProxy.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/QueueContract.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueServiceContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index f6cd3798b585a..c19014ad0aa38 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/QueueContract.java @@ -18,7 +18,7 @@ import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; -public interface QueueServiceContract extends FilterableService { +public interface QueueContract extends FilterableService { GetServicePropertiesResult getServiceProperties() throws ServiceException; GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException; 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/QueueService.java new file mode 100644 index 0000000000000..83655347e721e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java @@ -0,0 +1,157 @@ +package com.microsoft.windowsazure.services.queue; + +import java.util.HashMap; + +import javax.inject.Inject; + +import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.http.ServiceFilter; +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; +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 class QueueService implements QueueContract { + final QueueContract next; + + public QueueService() throws Exception { + this(null, Configuration.getInstance()); + } + + public QueueService(Configuration config) throws Exception { + this(null, config); + } + + public QueueService(String profile) throws Exception { + this(profile, Configuration.getInstance()); + } + + public QueueService(String profile, Configuration config) throws Exception { + next = config.create(profile, QueueContract.class); + } + + @Inject + public QueueService(QueueContract next) throws Exception { + this.next = next; + } + + public QueueContract withFilter(ServiceFilter filter) { + return next.withFilter(filter); + } + + public GetServicePropertiesResult getServiceProperties() throws ServiceException { + return next.getServiceProperties(); + } + + public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { + return next.getServiceProperties(options); + } + + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { + next.setServiceProperties(serviceProperties); + } + + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + next.setServiceProperties(serviceProperties, options); + } + + public void createQueue(String queue) throws ServiceException { + next.createQueue(queue); + } + + public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { + next.createQueue(queue, options); + } + + public void deleteQueue(String queue) throws ServiceException { + next.deleteQueue(queue); + } + + public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { + next.deleteQueue(queue, options); + } + + public ListQueuesResult listQueues() throws ServiceException { + return next.listQueues(); + } + + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + return next.listQueues(options); + } + + public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { + return next.getQueueMetadata(queue); + } + + public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { + return next.getQueueMetadata(queue, options); + } + + public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { + next.setQueueMetadata(queue, metadata); + } + + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + next.setQueueMetadata(queue, metadata, options); + } + + public void createMessage(String queue, String messageText) throws ServiceException { + next.createMessage(queue, messageText); + } + + public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { + next.createMessage(queue, messageText, options); + } + + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) + throws ServiceException { + return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); + } + + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, + QueueServiceOptions options) throws ServiceException { + return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); + } + + public void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException { + next.deleteMessage(queue, messageId, popReceipt); + } + + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { + next.deleteMessage(queue, messageId, popReceipt, options); + } + + public ListMessagesResult listMessages(String queue) throws ServiceException { + return next.listMessages(queue); + } + + public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { + return next.listMessages(queue, options); + } + + public PeekMessagesResult peekMessages(String queue) throws ServiceException { + return next.peekMessages(queue); + } + + public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { + return next.peekMessages(queue, options); + } + + public void clearMessages(String queue) throws ServiceException { + next.clearMessages(queue); + } + + public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { + next.clearMessages(queue, options); + } +} \ No newline at end of file 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/QueueExceptionProcessor.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index b2710351c0c7d..a61c96dfe3657 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/QueueExceptionProcessor.java @@ -9,7 +9,7 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.queue.QueueServiceContract; +import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; @@ -27,21 +27,21 @@ 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; +public class QueueExceptionProcessor implements QueueContract { + private static Log log = LogFactory.getLog(QueueExceptionProcessor.class); + private final QueueContract service; @Inject - public QueueServiceImpl(QueueServiceForJersey service) { + public QueueExceptionProcessor(QueueRestProxy service) { this.service = service; } - public QueueServiceImpl(QueueServiceContract service) { + public QueueExceptionProcessor(QueueContract service) { this.service = service; } - public QueueServiceContract withFilter(ServiceFilter filter) { - return new QueueServiceImpl(service.withFilter(filter)); + public QueueContract withFilter(ServiceFilter filter) { + return new QueueExceptionProcessor(service.withFilter(filter)); } private ServiceException processCatch(ServiceException e) { 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/QueueRestProxy.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueServiceForJersey.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 67392df8b4f06..b4444af8e7882 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/QueueRestProxy.java @@ -13,7 +13,7 @@ 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; +import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; @@ -32,8 +32,8 @@ 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); +public class QueueRestProxy implements QueueContract { + //private static Log log = LogFactory.getLog(QueueRestProxy.class); private static final String API_VERSION = "2011-08-18"; private final Client channel; @@ -44,7 +44,7 @@ public class QueueServiceForJersey implements QueueServiceContract { private final SharedKeyLiteFilter filter; @Inject - public QueueServiceForJersey(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, + public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, SharedKeyLiteFilter filter) { this.channel = channel; @@ -56,8 +56,7 @@ public QueueServiceForJersey(Client channel, @Named(QueueConfiguration.ACCOUNT_N channel.addFilter(filter); } - public QueueServiceForJersey(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, - RFC1123DateConverter dateMapper) { + public QueueRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; @@ -67,10 +66,10 @@ public QueueServiceForJersey(Client channel, ServiceFilter[] filters, String acc this.dateMapper = dateMapper; } - public QueueServiceContract withFilter(ServiceFilter filter) { + public QueueContract 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); + return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); } private void ThrowIfError(ClientResponse r) { 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 7727c89aa5162..53535f43c3842 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 @@ -92,7 +92,7 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); for (int i = 0; i < testContainers.length; i++) { try { service.createContainer(testContainers[i]); @@ -106,7 +106,7 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); for (int i = 0; i < testContainers.length; i++) { try { service.deleteContainer(testContainers[i]); @@ -130,7 +130,7 @@ public static void cleanup() throws Exception { public void getServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -148,7 +148,7 @@ public void getServiceProppertiesWorks() throws Exception { public void setServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -174,7 +174,7 @@ public void setServiceProppertiesWorks() throws Exception { public void createContainerWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_1); @@ -186,7 +186,7 @@ public void createContainerWorks() throws Exception { public void createContainerWithMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_2, @@ -236,7 +236,7 @@ public void createContainerWithMetadataWorks() throws Exception { public void setContainerMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createContainer(CREATEABLE_CONTAINER_3); @@ -263,7 +263,7 @@ public void setContainerMetadataWorks() throws Exception { public void setContainerACLWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); String container = CREATEABLE_CONTAINER_4; Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); @@ -297,7 +297,7 @@ public void setContainerACLWorks() throws Exception { public void listContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act ListContainersResult results = service.listContainers(); @@ -317,7 +317,7 @@ public void listContainersWorks() throws Exception { public void listContainersWithPaginationWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); @@ -339,7 +339,7 @@ public void listContainersWithPaginationWorks() throws Exception { public void listContainersWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix(testContainersPrefix).setMaxResults(3)); @@ -363,7 +363,7 @@ public void listContainersWithPrefixWorks() throws Exception { public void workingWithRootContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // // Ensure root container exists @@ -430,7 +430,7 @@ public void workingWithRootContainersWorks() throws Exception { public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); String[] blobNames = { "myblob1", "myblob2", "other-blob1", "other-blob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -452,7 +452,7 @@ public void listBlobsWorks() throws Exception { public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -482,7 +482,7 @@ public void listBlobsWithPrefixWorks() throws Exception { public void listBlobsWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -504,7 +504,7 @@ public void listBlobsWithOptionsWorks() throws Exception { public void listBlobsWithDelimiterWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.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); @@ -547,7 +547,7 @@ public void listBlobsWithDelimiterWorks() throws Exception { public void createPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512); @@ -559,7 +559,7 @@ public void createPageBlobWorks() throws Exception { public void createPageBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") @@ -594,7 +594,7 @@ public void createPageBlobWithOptionsWorks() throws Exception { public void clearBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -615,7 +615,7 @@ public void clearBlobPagesWorks() throws Exception { public void createBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -638,7 +638,7 @@ public void createBlobPagesWorks() throws Exception { public void listBlobRegionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -674,7 +674,7 @@ public void listBlobRegionsWorks() throws Exception { public void listBlobBlocksOnEmptyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -699,7 +699,7 @@ public void listBlobBlocksOnEmptyBlobWorks() throws Exception { public void listBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -732,7 +732,7 @@ public void listBlobBlocksWorks() throws Exception { public void commitBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -772,7 +772,7 @@ public void commitBlobBlocksWorks() throws Exception { public void createBlobBlockWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -789,7 +789,7 @@ public void createBlobBlockWorks() throws Exception { public void createBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream("some content".getBytes())); @@ -801,7 +801,7 @@ public void createBlockBlobWorks() throws Exception { public void createBlockBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content"; @@ -837,7 +837,7 @@ public void createBlockBlobWithOptionsWorks() throws Exception { public void createBlobSnapshotWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -856,7 +856,7 @@ public void createBlobSnapshotWorks() throws Exception { public void createBlobSnapshotWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -881,7 +881,7 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { public void getBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content"; @@ -890,8 +890,7 @@ public void getBlockBlobWorks() throws Exception { /* .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 result = blob.getProperties(); + GetBlobResult result = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); // Assert assertNotNull(result); @@ -912,14 +911,14 @@ public void getBlockBlobWorks() throws Exception { assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); assertEquals(0, props.getSequenceNumber()); - assertEquals(content, inputStreamToString(blob.getContentStream(), "UTF-8")); + assertEquals(content, inputStreamToString(result.getContentStream(), "UTF-8")); } @Test public void getPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, new CreateBlobOptions().setBlobCacheControl("test").setBlobContentEncoding("UTF-8") @@ -927,8 +926,7 @@ public void getPageBlobWorks() throws Exception { /* .setBlobContentMD5("1234") */.setBlobContentType("text/plain").setCacheControl("test").setContentEncoding("UTF-8") /* .setContentMD5("1234") */.setContentType("text/plain")); - GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); - GetBlobPropertiesResult result = blob.getProperties(); + GetBlobResult result = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); // Assert assertNotNull(result); @@ -948,14 +946,14 @@ public void getPageBlobWorks() throws Exception { assertEquals("PageBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); assertEquals(0, props.getSequenceNumber()); - assertEquals(4096, inputStreamToByteArray(blob.getContentStream()).length); + assertEquals(4096, inputStreamToByteArray(result.getContentStream()).length); } @Test public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -973,7 +971,7 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -993,7 +991,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -1013,7 +1011,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1049,7 +1047,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception public void getBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1082,7 +1080,7 @@ public void getBlobPropertiesWorks() throws Exception { public void getBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1106,7 +1104,7 @@ public void getBlobMetadataWorks() throws Exception { public void setBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1148,7 +1146,7 @@ public void setBlobPropertiesWorks() throws Exception { public void setBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1179,7 +1177,7 @@ public void setBlobMetadataWorks() throws Exception { public void deleteBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content"; @@ -1194,15 +1192,14 @@ public void deleteBlobWorks() throws Exception { public void copyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content2"; service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); service.copyBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5", TEST_CONTAINER_FOR_BLOBS, "test6"); - GetBlobResult blob = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); - GetBlobPropertiesResult result = blob.getProperties(); + GetBlobResult result = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); // Assert assertNotNull(result); @@ -1219,14 +1216,14 @@ public void copyBlobWorks() throws Exception { assertEquals("BlockBlob", props.getBlobType()); assertEquals("unlocked", props.getLeaseStatus()); assertEquals(0, props.getSequenceNumber()); - assertEquals(content, inputStreamToString(blob.getContentStream(), "UTF-8")); + assertEquals(content, inputStreamToString(result.getContentStream(), "UTF-8")); } @Test public void acquireLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content2"; @@ -1242,7 +1239,7 @@ public void acquireLeaseWorks() throws Exception { public void renewLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content2"; @@ -1260,7 +1257,7 @@ public void renewLeaseWorks() throws Exception { public void breakLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); // Act String content = "some content2"; @@ -1286,7 +1283,7 @@ public Response handle(Request request, Next next) { public void retryPolicyWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); @@ -1311,7 +1308,7 @@ public void retryPolicyWorks() throws Exception { public void retryPolicyCompositionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobServiceContract service = config.create(BlobServiceContract.class); + BlobContract service = config.create(BlobContract.class); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); 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 c6dcd331fda81..13fa91b7ed279 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 @@ -71,7 +71,7 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); for (int i = 0; i < testQueues.length; i++) { try { service.createQueue(testQueues[i]); @@ -85,7 +85,7 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); for (int i = 0; i < testQueues.length; i++) { try { @@ -110,7 +110,7 @@ public static void cleanup() throws Exception { public void getServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -128,7 +128,7 @@ public void getServicePropertiesWorks() throws Exception { public void setServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -152,7 +152,7 @@ public void setServicePropertiesWorks() throws Exception { public void createQueueWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createQueue(CREATABLE_QUEUE_1); @@ -170,7 +170,7 @@ public void createQueueWorks() throws Exception { public void createQueueWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createQueue(CREATABLE_QUEUE_2, new CreateQueueOptions().addMetadata("foo", "bar").addMetadata("test", "blah")); @@ -190,7 +190,7 @@ public void createQueueWithOptionsWorks() throws Exception { public void listQueuesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act ListQueuesResult result = service.listQueues(); @@ -208,7 +208,7 @@ public void listQueuesWorks() throws Exception { public void listQueuesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act ListQueuesResult result = service.listQueues(new ListQueuesOptions().setMaxResults(3).setPrefix(testQueuesPrefix)); @@ -243,7 +243,7 @@ public void listQueuesWithOptionsWorks() throws Exception { public void setQueueMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createQueue(CREATABLE_QUEUE_3); @@ -270,7 +270,7 @@ public void setQueueMetadataWorks() throws Exception { public void createMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message1"); @@ -285,7 +285,7 @@ public void createMessageWorks() throws Exception { public void listMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -323,7 +323,7 @@ public void listMessagesWorks() throws Exception { public void listMessagesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -363,7 +363,7 @@ public void listMessagesWithOptionsWorks() throws Exception { public void peekMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -397,7 +397,7 @@ public void peekMessagesWorks() throws Exception { public void peekMessagesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -432,7 +432,7 @@ public void peekMessagesWithOptionsWorks() throws Exception { public void clearMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message1"); @@ -452,7 +452,7 @@ public void clearMessagesWorks() throws Exception { public void deleteMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message1"); @@ -473,7 +473,7 @@ public void deleteMessageWorks() throws Exception { public void updateMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueServiceContract service = config.create(QueueServiceContract.class); + QueueContract service = config.create(QueueContract.class); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); From 98bc0b04ba419d6d576542039c956751ea383d64 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 15:38:39 -0800 Subject: [PATCH 185/664] Update class registration --- .../com/microsoft/windowsazure/services/blob/Exports.java | 4 +++- .../com/microsoft/windowsazure/services/queue/Exports.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 1b6ca2d36d6e8..3bb6b29f7bd1f 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 @@ -1,13 +1,15 @@ package com.microsoft.windowsazure.services.blob; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; +import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { registry.add(BlobContract.class, BlobExceptionProcessor.class); + registry.add(BlobService.class); + registry.add(BlobExceptionProcessor.class); registry.add(BlobRestProxy.class); registry.add(SharedKeyLiteFilter.class); } 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 372527a5daab7..526442f4eacce 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,13 +1,15 @@ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; +import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { registry.add(QueueContract.class, QueueExceptionProcessor.class); + registry.add(QueueService.class); + registry.add(QueueExceptionProcessor.class); registry.add(QueueRestProxy.class); registry.add(SharedKeyLiteFilter.class); } From cc052a21e3e12d11cf97d58db42001ab922e0528 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 15:43:41 -0800 Subject: [PATCH 186/664] Testing default constructor for services --- .../windowsazure/services/blob/BlobServiceIntegrationTest.java | 2 +- .../services/queue/QueueServiceIntegrationTest.java | 2 +- 2 files changed, 2 insertions(+), 2 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 53535f43c3842..6da158877a5ee 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 @@ -130,7 +130,7 @@ public static void cleanup() throws Exception { public void getServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobService service = new BlobService(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); 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 13fa91b7ed279..91df9a21bf128 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 @@ -110,7 +110,7 @@ public static void cleanup() throws Exception { public void getServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueService service = new QueueService(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); From 8793eb1d3fdf1e8cc4b66badb00a9e6044a3ddb8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 15:54:41 -0800 Subject: [PATCH 187/664] Implementing rule entity methods --- .../serviceBus/ServiceBusContract.java | 14 ++-- .../serviceBus/ServiceBusService.java | 22 +++--- .../ServiceBusExceptionProcessor.java | 20 +++-- .../implementation/ServiceBusRestProxy.java | 57 ++++++++++--- .../serviceBus/models/CreateRuleResult.java | 19 +++++ .../serviceBus/models/GetRuleResult.java | 19 +++++ .../serviceBus/models/ListRulesResult.java | 17 ++++ .../services/serviceBus/models/Rule.java | 36 +++++++++ .../src/main/resources/servicebus-atom.xsd | 1 + .../serviceBus/ServiceBusIntegrationTest.java | 79 +++++++++++++++++++ 10 files changed, 247 insertions(+), 37 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index dc7f0deeade1b..e1ddae8f9b8a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -2,15 +2,16 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; @@ -18,6 +19,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; @@ -65,11 +67,11 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; - void addRule(String topicName, String subscriptionName, String ruleName, Entry rule) throws ServiceException; + CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException; - void removeRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Entry getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; - Feed getRules(String topicName, String subscriptionName) throws ServiceException; + ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 45ee452ffeaec..b28c40c1cbc00 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -5,15 +5,16 @@ import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; @@ -21,6 +22,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; @@ -142,23 +144,23 @@ public ListSubscriptionsResult listSubscriptions(String topicName) throws Servic return next.listSubscriptions(topicName); } - public void addRule(String topicName, String subscriptionName, - String ruleName, Entry rule) throws ServiceException { - next.addRule(topicName, subscriptionName, ruleName, rule); + public CreateRuleResult createRule(String topicName, String subscriptionName, + Rule rule) throws ServiceException { + return next.createRule(topicName, subscriptionName, rule); } - public void removeRule(String topicName, String subscriptionName, + public void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { - next.removeRule(topicName, subscriptionName, ruleName); + next.deleteRule(topicName, subscriptionName, ruleName); } - public Entry getRule(String topicName, String subscriptionName, + public GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { return next.getRule(topicName, subscriptionName, ruleName); } - public Feed getRules(String topicName, String subscriptionName) + public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { - return next.getRules(topicName, subscriptionName); + return next.listRules(topicName, subscriptionName); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 4a9fb4b6a4f93..9694977e2a062 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -9,12 +9,15 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; @@ -22,6 +25,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; @@ -302,10 +306,10 @@ public ListSubscriptionsResult listSubscriptions(String topicPath) throws Servic } } - public void addRule(String topicPath, String subscriptionName, - String ruleName, Entry rule) throws ServiceException { + public CreateRuleResult createRule(String topicPath, String subscriptionName, + Rule rule) throws ServiceException { try { - next.addRule(topicPath, subscriptionName, ruleName, rule); + return next.createRule(topicPath, subscriptionName, rule); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -315,10 +319,10 @@ public void addRule(String topicPath, String subscriptionName, } } - public void removeRule(String topicPath, String subscriptionName, + public void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { - next.removeRule(topicPath, subscriptionName, ruleName); + next.deleteRule(topicPath, subscriptionName, ruleName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -328,7 +332,7 @@ public void removeRule(String topicPath, String subscriptionName, } } - public Entry getRule(String topicPath, String subscriptionName, + public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { return next.getRule(topicPath, subscriptionName, ruleName); @@ -341,10 +345,10 @@ public Entry getRule(String topicPath, String subscriptionName, } } - public Feed getRules(String topicPath, String subscriptionName) + public ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException { try { - return next.getRules(topicPath, subscriptionName); + return next.listRules(topicPath, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 78ebd91a7194c..f4c11d9f2b53a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -17,12 +17,15 @@ import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; +import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; @@ -30,6 +33,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; +import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; import com.sun.jersey.api.client.Client; @@ -303,27 +307,54 @@ public ListSubscriptionsResult listSubscriptions(String topicPath) { return result; } - public void addRule(String topicPath, String subscriptionName, - String ruleName, Entry rule) { - // TODO Auto-generated method stub - + public CreateRuleResult createRule(String topicPath, String subscriptionName, + Rule rule) { + return new CreateRuleResult(getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .path("rules") + .path(rule.getName()) + .type("application/atom+xml;type=entry;charset=utf-8") + .put(Rule.class, rule)); } - public void removeRule(String topicPath, String subscriptionName, + public void deleteRule(String topicPath, String subscriptionName, String ruleName) { - // TODO Auto-generated method stub - + getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .path("rules") + .path(ruleName) + .delete(); } - public Entry getRule(String topicPath, String subscriptionName, + public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) { - // TODO Auto-generated method stub - return null; + return new GetRuleResult(getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .path("rules") + .path(ruleName) + .get(Rule.class)); } - public Feed getRules(String topicPath, String subscriptionName) { - // TODO Auto-generated method stub - return null; + public ListRulesResult listRules(String topicPath, String subscriptionName) { + Feed feed = getResource() + .path(topicPath) + .path("subscriptions") + .path(subscriptionName) + .path("rules") + .get(Feed.class); + ArrayList list = new ArrayList(); + for (Entry entry : feed.getEntries()) { + list.add(new Rule(entry)); + } + ListRulesResult result = new ListRulesResult(); + result.setItems(list); + return result; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java new file mode 100644 index 0000000000000..114e189b22a3b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -0,0 +1,19 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class CreateRuleResult { + + private Rule value; + + public CreateRuleResult(Rule value) { + this.setValue(value); + } + + public void setValue(Rule value) { + this.value = value; + } + + public Rule getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java new file mode 100644 index 0000000000000..d4d49839298a0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -0,0 +1,19 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class GetRuleResult { + + private Rule value; + + public GetRuleResult(Rule value) { + this.setValue(value); + } + + public void setValue(Rule value) { + this.value = value; + } + + public Rule getValue() { + return value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java new file mode 100644 index 0000000000000..8917fc0b04111 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -0,0 +1,17 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import java.util.List; + +public class ListRulesResult { + + private List items; + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java new file mode 100644 index 0000000000000..a78a721f601c1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java @@ -0,0 +1,36 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +import javax.ws.rs.core.MediaType; + +import com.microsoft.windowsazure.services.serviceBus.implementation.Content; +import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; +import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; + +public class Rule extends EntryModel { + + public Rule() { + super(new Entry(), new RuleDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setRuleDescription(getModel()); + } + + public Rule(Entry entry) { + super(entry, entry.getContent().getRuleDescription()); + } + + public Rule(String name) { + this(); + setName(name); + } + + public String getName() { + return getEntry().getTitle(); + } + + public Rule setName(String value) { + getEntry().setTitle(value); + return this; + } +} diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd index 6b319fbb89fb2..b8387023a54be 100644 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd @@ -30,6 +30,7 @@ + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index fd8f891c91b48..0f47e6e3b9ee4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -16,11 +16,13 @@ import com.microsoft.windowsazure.http.ServiceFilter.Request; import com.microsoft.windowsazure.http.ServiceFilter.Response; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; @@ -330,4 +332,81 @@ public void subscriptionWillReceiveMessage() throws Exception { assertEquals("

Testing subscription

", new String(data, 0, size)); assertEquals("text/html", message.getContentType()); } + + @Test + public void rulesCanBeCreatedOnSubscriptions() throws Exception { + // Arrange + String topicName = "TestrulesCanBeCreatedOnSubscriptions"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("sub")); + + // Act + Rule created = service.createRule(topicName, "sub", new Rule("MyRule1")).getValue(); + + // Assert + assertNotNull(created); + assertEquals("MyRule1", created.getName()); + } + + @Test + public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { + // Arrange + String topicName = "TestrulesCanBeListedAndDefaultRuleIsPrecreated"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("sub")); + service.createRule(topicName, "sub", new Rule("MyRule2")); + + // Act + ListRulesResult result = service.listRules(topicName, "sub"); + + // Assert + assertNotNull(result); + assertEquals(2, result.getItems().size()); + Rule rule0 = result.getItems().get(0); + Rule rule1 = result.getItems().get(1); + if (rule0.getName() == "MyRule2") { + Rule swap = rule1; + rule1 = rule0; + rule0 = swap; + } + + assertEquals("$Default", rule0.getName()); + assertEquals("MyRule2", rule1.getName()); + assertNotNull(result.getItems().get(0).getModel()); + } + + @Test + public void ruleDetailsMayBeFetched() throws Exception { + // Arrange + String topicName = "TestruleDetailsMayBeFetched"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("sub")); + + // Act + Rule result = service.getRule(topicName, "sub", "$Default").getValue(); + + // Assert + assertNotNull(result); + assertEquals("$Default", result.getName()); + } + + @Test + public void rulesMayBeDeleted() throws Exception { + // Arrange + String topicName = "TestRulesMayBeDeleted"; + service.createTopic(new Topic(topicName)); + service.createSubscription(topicName, new Subscription("sub")); + service.createRule(topicName, "sub", new Rule("MyRule4")); + service.createRule(topicName, "sub", new Rule("MyRule5")); + + // Act + service.deleteRule(topicName, "sub", "MyRule5"); + service.deleteRule(topicName, "sub", "$Default"); + + // Assert + ListRulesResult result = service.listRules(topicName, "sub"); + assertNotNull(result); + assertEquals(1, result.getItems().size()); + assertEquals("MyRule4", result.getItems().get(0).getName()); + } } From ac1f12bf43f4fea663d5294a6f07ba7442b1dc2a Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 15:56:38 -0800 Subject: [PATCH 188/664] Move various classes to "common" and "utils" packages --- .../windowsazure/auth/wrap/Exports.java | 4 +- .../windowsazure/auth/wrap/WrapClient.java | 2 +- .../windowsazure/auth/wrap/WrapFilter.java | 2 +- .../auth/wrap/contract/WrapContract.java | 2 +- .../auth/wrap/contract/WrapContractImpl.java | 2 +- .../builder => common}/Builder.java | 60 ++-- .../Configuration.java | 4 +- .../builder => common}/DefaultBuilder.java | 335 +++++++++--------- .../common/ExponentialRetryPolicyFilter.java | 1 - .../{http => common}/FilterableService.java | 3 +- .../{ => common}/ServiceException.java | 194 +++++----- .../{http => common}/ServiceFilter.java | 2 +- .../services/blob/BlobContract.java | 4 +- .../services/blob/BlobService.java | 6 +- .../windowsazure/services/blob/Exports.java | 2 +- .../BlobExceptionProcessor.java | 4 +- .../blob/implementation/BlobRestProxy.java | 6 +- .../windowsazure/services/queue/Exports.java | 2 +- .../services/queue/QueueContract.java | 4 +- .../services/queue/QueueService.java | 6 +- .../QueueExceptionProcessor.java | 4 +- .../queue/implementation/QueueRestProxy.java | 6 +- .../services/serviceBus/Exports.java | 2 +- .../serviceBus/ServiceBusConfiguration.java | 2 +- .../serviceBus/ServiceBusContract.java | 4 +- .../serviceBus/ServiceBusService.java | 6 +- .../services/serviceBus/Util.java | 2 +- .../serviceBus/client/MessageReceiver.java | 2 +- .../serviceBus/client/MessageSender.java | 2 +- .../serviceBus/client/MessagingClient.java | 4 +- .../ServiceBusExceptionProcessor.java | 4 +- .../implementation/ServiceBusRestProxy.java | 6 +- .../microsoft/windowsazure/utils/Exports.java | 2 +- .../utils/ServiceExceptionFactory.java | 2 +- .../jersey}/ClientFilterAdapter.java | 7 +- .../jersey/Exports.java | 66 ++-- ...zure.configuration.builder.Builder$Exports | 2 +- .../auth/wrap/WrapClientIntegrationTest.java | 2 +- .../auth/wrap/WrapClientTest.java | 2 +- .../contract/WrapContractIntegrationTest.java | 2 +- .../builder/AlterClassWithProperties.java | 2 +- .../builder/DefaultBuilderTest.java | 2 +- .../blob/BlobServiceIntegrationTest.java | 6 +- .../services/blob/IntegrationTestBase.java | 3 +- .../services/queue/IntegrationTestBase.java | 2 +- .../queue/QueueServiceIntegrationTest.java | 4 +- .../serviceBus/IntegrationTestBase.java | 2 +- .../ServiceBusConfigurationTest.java | 2 +- .../serviceBus/ServiceBusCreationTest.java | 2 +- .../serviceBus/ServiceBusIntegrationTest.java | 10 +- .../utils/ServiceExceptionFactoryTest.java | 2 +- 51 files changed, 405 insertions(+), 406 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{configuration/builder => common}/Builder.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{configuration => common}/Configuration.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{configuration/builder => common}/DefaultBuilder.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{http => common}/FilterableService.java (65%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{ => common}/ServiceException.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{http => common}/ServiceFilter.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{http => utils/jersey}/ClientFilterAdapter.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{configuration => utils}/jersey/Exports.java (83%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java index 5acaa03325cae..e48999f72dfee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java @@ -2,10 +2,10 @@ import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.builder.Builder.Registry; +import com.microsoft.windowsazure.common.Builder.Registry; public class Exports implements - com.microsoft.windowsazure.configuration.builder.Builder.Exports { + com.microsoft.windowsazure.common.Builder.Exports { public void register(Registry registry) { registry.add(WrapContract.class, WrapContractImpl.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java index 36bf0683b870d..e35dda7a4b14d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java @@ -6,9 +6,9 @@ import javax.inject.Named; import javax.management.timer.Timer; -import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.utils.DateFactory; public class WrapClient { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java index dd322619984e1..78b1749e60479 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.auth.wrap; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java index 7b583d7ef63ae..8267af0bc055e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.auth.wrap.contract; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; public interface WrapContract { WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java index 313d490a9be2c..e35b8b2b309be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java @@ -6,7 +6,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java index 0a3e11ff25d6d..6047f230e230a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java @@ -1,30 +1,30 @@ -package com.microsoft.windowsazure.configuration.builder; - -import java.util.Map; - -public interface Builder { - - public abstract T build(String profile, Class service, Map properties) throws Exception; - - public interface Factory { - T create(String profile, Builder builder, Map properties) throws Exception; - } - - public interface Alteration { - T alter(T instance, Builder builder, Map properties) throws Exception; - } - - public interface Registry { - Registry add(Class service); - - Registry add(Class service, Class implementation); - - Registry add(Factory factory); - - void alter(Class service, Alteration alteration); - } - - public interface Exports { - void register(Registry registry); - } -} +package com.microsoft.windowsazure.common; + +import java.util.Map; + +public interface Builder { + + public abstract T build(String profile, Class service, Map properties) throws Exception; + + public interface Factory { + T create(String profile, Builder builder, Map properties) throws Exception; + } + + public interface Alteration { + T alter(T instance, Builder builder, Map properties) throws Exception; + } + + public interface Registry { + Registry add(Class service); + + Registry add(Class service, Class implementation); + + Registry add(Factory factory); + + void alter(Class service, Alteration alteration); + } + + public interface Exports { + void register(Registry registry); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java index fd794ece45585..055596f9482c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java @@ -1,10 +1,8 @@ -package com.microsoft.windowsazure.configuration; +package com.microsoft.windowsazure.common; import java.util.HashMap; import java.util.Map; -import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.configuration.builder.DefaultBuilder; import com.sun.jersey.api.client.config.ClientConfig; public class Configuration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java index e6510fdbb8ea1..74eef8182403f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java @@ -1,167 +1,168 @@ -package com.microsoft.windowsazure.configuration.builder; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ServiceLoader; - -import javax.inject.Inject; -import javax.inject.Named; - -public class DefaultBuilder implements Builder, Builder.Registry { - Map, Factory> factories; - Map, List>> alterations; - - public DefaultBuilder() { - factories = new HashMap, Factory>(); - alterations = new HashMap, List>>(); - } - - public static DefaultBuilder create() { - DefaultBuilder builder = new DefaultBuilder(); - - for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { - exports.register(builder); - } - - return builder; - } - - void addFactory(Class service, Factory factory) { - factories.put(service, factory); - } - - public Builder.Registry add(Class service) { - return add(service, service); - } - - Constructor findInjectConstructor(Class implementation) { - - Constructor withInject = null; - Constructor withoutInject = null; - int count = 0; - - for (Constructor ctor : implementation.getConstructors()) { - if (ctor.getAnnotation(Inject.class) != null) { - if (withInject != null) { - throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); - } - withInject = ctor; - } - else { - ++count; - withoutInject = ctor; - } - } - if (withInject != null) { - return withInject; - } - if (count != 1) { - throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); - } - return withoutInject; - } - - public Builder.Registry add(Class service, final Class implementation) { - final Constructor ctor = findInjectConstructor(implementation); - final Class[] parameterTypes = ctor.getParameterTypes(); - final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); - - addFactory(service, new Builder.Factory() { - @SuppressWarnings("unchecked") - public T create(String profile, Builder builder, Map properties) throws Exception { - Object[] initargs = new Object[parameterTypes.length]; - for (int i = 0; i != parameterTypes.length; ++i) { - - boolean located = false; - - String named = findNamedAnnotation(parameterAnnotations[i]); - String fullName = dotCombine(profile, named); - - boolean probeProperties = fullName != null && fullName != ""; - int startingIndex = 0; - while (!located && probeProperties) { - String probeName = fullName.substring(startingIndex); - if (!located && named != null && properties.containsKey(probeName)) { - located = true; - initargs[i] = properties.get(probeName); - } - else { - startingIndex = fullName.indexOf('.', startingIndex) + 1; - if (startingIndex == 0) { - probeProperties = false; - } - } - } - - if (!located) { - located = true; - initargs[i] = builder.build(fullName, parameterTypes[i], properties); - } - } - - return (T) ctor.newInstance(initargs); - } - }); - return this; - } - - protected String dotCombine(String profile, String named) { - boolean noProfile = profile == null || profile == ""; - boolean noName = named == null || named == ""; - if (noName) - return profile; - if (noProfile) - return named; - return profile + "." + named; - } - - protected String findNamedAnnotation(Annotation[] annotations) { - for (Annotation annotation : annotations) { - if (Named.class.isAssignableFrom(annotation.getClass())) { - return ((Named) annotation).value(); - } - } - return null; - } - - public Registry add(Factory factory) { - for (Type genericInterface : factory.getClass().getGenericInterfaces()) { - ParameterizedType parameterizedType = (ParameterizedType) genericInterface; - if (parameterizedType.getRawType().equals(Builder.Factory.class)) { - Type typeArgument = parameterizedType.getActualTypeArguments()[0]; - addFactory((Class) typeArgument, factory); - } - } - return this; - } - - @SuppressWarnings("unchecked") - public T build(String profile, Class service, Map properties) throws Exception { - Factory factory = (Factory) factories.get(service); - if (factory == null) { - throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); - } - T instance = factory.create(profile, this, properties); - List> alterationList = alterations.get(service); - if (alterationList != null) { - for (Alteration alteration : alterationList) { - instance = ((Alteration) alteration).alter(instance, this, properties); - } - } - return instance; - } - - public void alter(Class service, Alteration alteration) { - if (!this.alterations.containsKey(service)) { - this.alterations.put(service, new ArrayList>()); - } - this.alterations.get(service).add(alteration); - } - -} +package com.microsoft.windowsazure.common; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; + +import javax.inject.Inject; +import javax.inject.Named; + + +public class DefaultBuilder implements Builder, Builder.Registry { + Map, Factory> factories; + Map, List>> alterations; + + public DefaultBuilder() { + factories = new HashMap, Factory>(); + alterations = new HashMap, List>>(); + } + + public static DefaultBuilder create() { + DefaultBuilder builder = new DefaultBuilder(); + + for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { + exports.register(builder); + } + + return builder; + } + + void addFactory(Class service, Factory factory) { + factories.put(service, factory); + } + + public Builder.Registry add(Class service) { + return add(service, service); + } + + Constructor findInjectConstructor(Class implementation) { + + Constructor withInject = null; + Constructor withoutInject = null; + int count = 0; + + for (Constructor ctor : implementation.getConstructors()) { + if (ctor.getAnnotation(Inject.class) != null) { + if (withInject != null) { + throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); + } + withInject = ctor; + } + else { + ++count; + withoutInject = ctor; + } + } + if (withInject != null) { + return withInject; + } + if (count != 1) { + throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); + } + return withoutInject; + } + + public Builder.Registry add(Class service, final Class implementation) { + final Constructor ctor = findInjectConstructor(implementation); + final Class[] parameterTypes = ctor.getParameterTypes(); + final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); + + addFactory(service, new Builder.Factory() { + @SuppressWarnings("unchecked") + public T create(String profile, Builder builder, Map properties) throws Exception { + Object[] initargs = new Object[parameterTypes.length]; + for (int i = 0; i != parameterTypes.length; ++i) { + + boolean located = false; + + String named = findNamedAnnotation(parameterAnnotations[i]); + String fullName = dotCombine(profile, named); + + boolean probeProperties = fullName != null && fullName != ""; + int startingIndex = 0; + while (!located && probeProperties) { + String probeName = fullName.substring(startingIndex); + if (!located && named != null && properties.containsKey(probeName)) { + located = true; + initargs[i] = properties.get(probeName); + } + else { + startingIndex = fullName.indexOf('.', startingIndex) + 1; + if (startingIndex == 0) { + probeProperties = false; + } + } + } + + if (!located) { + located = true; + initargs[i] = builder.build(fullName, parameterTypes[i], properties); + } + } + + return (T) ctor.newInstance(initargs); + } + }); + return this; + } + + protected String dotCombine(String profile, String named) { + boolean noProfile = profile == null || profile == ""; + boolean noName = named == null || named == ""; + if (noName) + return profile; + if (noProfile) + return named; + return profile + "." + named; + } + + protected String findNamedAnnotation(Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (Named.class.isAssignableFrom(annotation.getClass())) { + return ((Named) annotation).value(); + } + } + return null; + } + + public Registry add(Factory factory) { + for (Type genericInterface : factory.getClass().getGenericInterfaces()) { + ParameterizedType parameterizedType = (ParameterizedType) genericInterface; + if (parameterizedType.getRawType().equals(Builder.Factory.class)) { + Type typeArgument = parameterizedType.getActualTypeArguments()[0]; + addFactory((Class) typeArgument, factory); + } + } + return this; + } + + @SuppressWarnings("unchecked") + public T build(String profile, Class service, Map properties) throws Exception { + Factory factory = (Factory) factories.get(service); + if (factory == null) { + throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); + } + T instance = factory.create(profile, this, properties); + List> alterationList = alterations.get(service); + if (alterationList != null) { + for (Alteration alteration : alterationList) { + instance = ((Alteration) alteration).alter(instance, this, properties); + } + } + return instance; + } + + public void alter(Class service, Alteration alteration) { + if (!this.alterations.containsKey(service)) { + this.alterations.put(service, new ArrayList>()); + } + this.alterations.get(service).add(alteration); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java index c85f1b2c3fd69..6ec6c2b3fd1c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java @@ -6,7 +6,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.http.ServiceFilter; public class ExponentialRetryPolicyFilter implements ServiceFilter { private static final Log log = LogFactory.getLog(ExponentialRetryPolicyFilter.class); 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/common/FilterableService.java similarity index 65% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/FilterableService.java index d9c1c628dfe0a..d60ce20225bf0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/FilterableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/FilterableService.java @@ -1,4 +1,5 @@ -package com.microsoft.windowsazure.http; +package com.microsoft.windowsazure.common; + public interface FilterableService { T withFilter(ServiceFilter filter); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java index 4519f1bf1034a..37a6e0be9304f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java @@ -1,97 +1,97 @@ -package com.microsoft.windowsazure; - -import java.util.HashMap; -import java.util.Map; - -public class ServiceException extends Exception { - - private static final long serialVersionUID = -4942076377009150131L; - - int httpStatusCode; - String httpReasonPhrase; - String serviceName; - - String errorCode; - String errorMessage; - Map errorValues; - - public ServiceException() { - init(); - } - - public ServiceException(String message) { - super(message); - init(); - } - - public ServiceException(String message, Throwable cause) { - super(message, cause); - init(); - } - - public ServiceException(Throwable cause) { - super(cause); - init(); - } - - private void init() { - errorValues = new HashMap(); - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpReasonPhrase() { - return httpReasonPhrase; - } - - public void setHttpReasonPhrase(String httpReasonPhrase) { - this.httpReasonPhrase = httpReasonPhrase; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public Map getErrorValues() { - return errorValues; - } - - public void setErrorValues(Map errorValues) { - this.errorValues = errorValues; - } - - public String getErrorValue(String name) { - return errorValues.get(name); - } - - public void setErrorValue(String name, String value) { - this.errorValues.put(name, value); - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - -} +package com.microsoft.windowsazure.common; + +import java.util.HashMap; +import java.util.Map; + +public class ServiceException extends Exception { + + private static final long serialVersionUID = -4942076377009150131L; + + int httpStatusCode; + String httpReasonPhrase; + String serviceName; + + String errorCode; + String errorMessage; + Map errorValues; + + public ServiceException() { + init(); + } + + public ServiceException(String message) { + super(message); + init(); + } + + public ServiceException(String message, Throwable cause) { + super(message, cause); + init(); + } + + public ServiceException(Throwable cause) { + super(cause); + init(); + } + + private void init() { + errorValues = new HashMap(); + } + + public int getHttpStatusCode() { + return httpStatusCode; + } + + public void setHttpStatusCode(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + public String getHttpReasonPhrase() { + return httpReasonPhrase; + } + + public void setHttpReasonPhrase(String httpReasonPhrase) { + this.httpReasonPhrase = httpReasonPhrase; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public Map getErrorValues() { + return errorValues; + } + + public void setErrorValues(Map errorValues) { + this.errorValues = errorValues; + } + + public String getErrorValue(String name) { + return errorValues.get(name); + } + + public void setErrorValue(String name, String value) { + this.errorValues.put(name, value); + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java index 4ed73c5318cc5..504f899633584 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.http; +package com.microsoft.windowsazure.common; import java.io.InputStream; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index 6a0c7096de9ca..e34ad58ce00ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -3,8 +3,8 @@ import java.io.InputStream; import java.util.HashMap; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.FilterableService; +import com.microsoft.windowsazure.common.FilterableService; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; 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/BlobService.java index 27e07821df9ca..b5b68aa4f2715 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/BlobService.java @@ -5,9 +5,9 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; 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 3bb6b29f7bd1f..10a7c9948cf3d 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 @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.blob; -import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 7e4fc8b7e5876..b0f630844a79e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -8,8 +8,8 @@ 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.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobContract; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index c2245a10460b0..d69a806095d40 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -8,9 +8,8 @@ import javax.inject.Inject; import javax.inject.Named; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ClientFilterAdapter; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.BlobContract; import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers.EnumCommaStringBuilder; @@ -56,6 +55,7 @@ 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.jersey.ClientFilterAdapter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; 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 526442f4eacce..d86505cbc46ce 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,6 +1,6 @@ package com.microsoft.windowsazure.services.queue; -import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index c19014ad0aa38..6ac72ebc2ff9b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java @@ -2,8 +2,8 @@ import java.util.HashMap; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.FilterableService; +import com.microsoft.windowsazure.common.FilterableService; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; 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/QueueService.java index 83655347e721e..8767bd9c03716 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/QueueService.java @@ -4,9 +4,9 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index a61c96dfe3657..a81a34e76296e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -7,8 +7,8 @@ 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.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index b4444af8e7882..d61daea82911c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -7,9 +7,8 @@ import javax.inject.Inject; import javax.inject.Named; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ClientFilterAdapter; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers; import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; import com.microsoft.windowsazure.services.queue.QueueConfiguration; @@ -27,6 +26,7 @@ import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; +import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index fdce616e6d084..d1b12a5865495 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -2,7 +2,7 @@ import java.util.Map; -import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.serviceBus.client.MessagingClient; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModelProvider; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index 32dea6b47cc06..486ceca26b0c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; public class ServiceBusConfiguration { public final static String URI = "serviceBus.uri"; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 47eb5fd88e797..43af02eddc82b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index eb7abe5d47473..5dd8472338324 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -4,9 +4,9 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.Feed; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 4c7e9c147493c..6c36a33521cc7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; public class Util { public static Iterable iterateQueues(ServiceBusContract service) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java index 96268b4d29721..075a7249b9f51 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageReceiver.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.client; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java index 13de652bc2368..897a7c11f03e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessageSender.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.client; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.serviceBus.Message; public interface MessageSender { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java index c52c650e206e1..83c5367449c56 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/client/MessagingClient.java @@ -2,8 +2,8 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.serviceBus.Message; import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 215c8a43455b2..a2dc4c3fea06b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -5,8 +5,8 @@ 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.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 8f307f999ae15..ec634c5a15eec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -11,10 +11,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.auth.wrap.WrapFilter; -import com.microsoft.windowsazure.http.ClientFilterAdapter; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; @@ -22,6 +21,7 @@ import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.Topic; +import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java index b75caf547d68e..a18deb52bd4ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.utils; -import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.common.Builder; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java index 39a89358e77b7..c912956194a5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.utils; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java index caba87fb4f4d8..6b8df9741c46d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/http/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.http; +package com.microsoft.windowsazure.utils.jersey; import java.io.InputStream; import java.net.URI; @@ -6,8 +6,9 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.http.ServiceFilter.Request; -import com.microsoft.windowsazure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceFilter.Request; +import com.microsoft.windowsazure.common.ServiceFilter.Response; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java index a6337e8b40f56..aa6cc310da149 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java @@ -1,33 +1,33 @@ -package com.microsoft.windowsazure.configuration.jersey; - -import java.util.Map; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.configuration.builder.Builder; -import com.microsoft.windowsazure.configuration.builder.Builder.Registry; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class Exports implements Builder.Exports { - - public void register(Registry registry) { - registry.add(new Builder.Factory() { - public ClientConfig create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = new DefaultClientConfig(); - for (Entry entry : properties.entrySet()) { - clientConfig.getProperties().put(entry.getKey(), entry.getValue()); - } - return clientConfig; - } - }); - - registry.add(new Builder.Factory() { - public Client create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - Client client = Client.create(clientConfig); - return client; - } - }); - } -} +package com.microsoft.windowsazure.utils.jersey; + +import java.util.Map; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.common.Builder.Registry; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; + +public class Exports implements Builder.Exports { + + public void register(Registry registry) { + registry.add(new Builder.Factory() { + public ClientConfig create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = new DefaultClientConfig(); + for (Entry entry : properties.entrySet()) { + clientConfig.getProperties().put(entry.getKey(), entry.getValue()); + } + return clientConfig; + } + }); + + registry.add(new Builder.Factory() { + public Client create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + Client client = Client.create(clientConfig); + return client; + } + }); + } +} 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 ce9f1f862db41..a38b6dbc69c03 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,5 @@ com.microsoft.windowsazure.auth.wrap.Exports -com.microsoft.windowsazure.configuration.jersey.Exports +com.microsoft.windowsazure.utils.jersey.Exports com.microsoft.windowsazure.services.blob.Exports com.microsoft.windowsazure.services.queue.Exports com.microsoft.windowsazure.services.serviceBus.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java index 665d3152297fa..01f26e42cca1d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import com.microsoft.windowsazure.auth.wrap.WrapClient; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; public class WrapClientIntegrationTest { private Configuration createConfiguration() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java index 6dc11fd627667..240ef4c6dd1f8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java @@ -12,10 +12,10 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import com.microsoft.windowsazure.ServiceException; import com.microsoft.windowsazure.auth.wrap.WrapClient; import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.utils.DateFactory; public class WrapClientTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java index 46650236ed02a..95d94e3269f65 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java @@ -4,7 +4,7 @@ import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; import com.sun.jersey.api.client.Client; public class WrapContractIntegrationTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index fe3add91c205c..8c847bfbc5c31 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -2,7 +2,7 @@ import java.util.Map; -import com.microsoft.windowsazure.configuration.builder.Builder; +import com.microsoft.windowsazure.common.Builder; public class AlterClassWithProperties implements Builder.Alteration { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java index 1406c10764189..ec629888f0713 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import com.microsoft.windowsazure.configuration.builder.DefaultBuilder; +import com.microsoft.windowsazure.common.DefaultBuilder; public class DefaultBuilderTest { 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 6da158877a5ee..1dc922e13c5f6 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 @@ -21,10 +21,10 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.Configuration; import com.microsoft.windowsazure.common.ExponentialRetryPolicyFilter; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.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; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 09fa79cf340c6..744e7a6f823fe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -5,8 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.blob.BlobConfiguration; +import com.microsoft.windowsazure.common.Configuration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { 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..5c96a872956e0 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 @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { 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 91df9a21bf128..2933ea52de1a4 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 @@ -11,8 +11,8 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 1ad04051f637c..9e02dd2a2b488 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; import com.microsoft.windowsazure.services.serviceBus.Queue; import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 333460f7266b7..32546aeb201ad 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class ServiceBusConfigurationTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index dbb811756a5be..9f826c11d6f09 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.common.Configuration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.ServiceBusService; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 8903f7b66cfaf..47baab63bf9bb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -10,11 +10,11 @@ import org.junit.Before; import org.junit.Test; -import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.http.ServiceFilter; -import com.microsoft.windowsazure.http.ServiceFilter.Request; -import com.microsoft.windowsazure.http.ServiceFilter.Response; +import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceFilter.Request; +import com.microsoft.windowsazure.common.ServiceFilter.Response; import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.Message; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index af4a944ea8f6f..f561b553362fb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -6,7 +6,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.ServiceException; +import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; From af4f094d5bc1de9ea72be1fb61fd7ec8ee12a275 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 15:57:48 -0800 Subject: [PATCH 189/664] Adding delegate methods from Rule to RuleDescription --- .../services/serviceBus/models/Rule.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java index a78a721f601c1..20f696d7730e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java @@ -5,6 +5,8 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.Content; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.Filter; +import com.microsoft.windowsazure.services.serviceBus.implementation.RuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; public class Rule extends EntryModel { @@ -33,4 +35,23 @@ public Rule setName(String value) { getEntry().setTitle(value); return this; } + + public Filter getFilter() { + return getModel().getFilter(); + } + + public Rule setFilter(Filter value) { + getModel().setFilter(value); + return this; + } + + public RuleAction getAction() { + return getModel().getAction(); + } + + public Rule setAction(RuleAction value) { + getModel().setAction(value); + return this; + } + } From 1f44e9916938ffac2a2015752736c9eff599c4d3 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 14 Nov 2011 16:14:03 -0800 Subject: [PATCH 190/664] Rename resource file to match java filename --- ...om.microsoft.windowsazure.common.Builder$Exports} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename microsoft-azure-api/src/main/resources/META-INF/services/{com.microsoft.windowsazure.configuration.builder.Builder$Exports => com.microsoft.windowsazure.common.Builder$Exports} (97%) 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.common.Builder$Exports similarity index 97% rename from microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.configuration.builder.Builder$Exports rename to microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports index a38b6dbc69c03..5f3449a0ff8fb 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.common.Builder$Exports @@ -1,6 +1,6 @@ -com.microsoft.windowsazure.auth.wrap.Exports -com.microsoft.windowsazure.utils.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 +com.microsoft.windowsazure.auth.wrap.Exports +com.microsoft.windowsazure.services.blob.Exports +com.microsoft.windowsazure.services.queue.Exports +com.microsoft.windowsazure.services.serviceBus.Exports +com.microsoft.windowsazure.utils.Exports +com.microsoft.windowsazure.utils.jersey.Exports From bb45c224dcfd095b5719b0cfd001a8b3d29373f6 Mon Sep 17 00:00:00 2001 From: Walter Blaurock Date: Mon, 14 Nov 2011 16:49:16 -0800 Subject: [PATCH 191/664] Adding ServiceRuntime --- microsoft-azure-api/pom.xml | 6 + .../serviceruntime/AcquireCurrentState.java | 33 + .../serviceruntime/AcquireLeaseInfo.java | 157 +++++ .../windowsazure/serviceruntime/Adapter1.java | 30 + .../ChunkedGoalStateDeserializer.java | 53 ++ .../ConfigurationSettingInfo.java | 92 +++ .../ConfigurationSettingsInfo.java | 76 +++ .../CurrentRoleInstanceInfo.java | 216 ++++++ .../serviceruntime/CurrentState.java | 19 + .../serviceruntime/CurrentStateInfo.java | 69 ++ .../CurrentStateSerializer.java | 13 + .../serviceruntime/CurrentStatus.java | 5 + .../serviceruntime/CurrentStatusEnum.java | 64 ++ .../serviceruntime/DeploymentInfo.java | 84 +++ .../serviceruntime/EndpointInfo.java | 138 ++++ .../serviceruntime/EndpointsInfo.java | 76 +++ .../serviceruntime/ExpectedState.java | 11 + .../serviceruntime/ExpectedStateEnum.java | 58 ++ .../serviceruntime/FileInputChannel.java | 24 + .../serviceruntime/FileOutputChannel.java | 24 + .../serviceruntime/GoalState.java | 48 ++ .../GoalStateChangedListener.java | 11 + .../serviceruntime/GoalStateDeserializer.java | 15 + .../serviceruntime/GoalStateInfo.java | 184 +++++ .../serviceruntime/InputChannel.java | 13 + .../serviceruntime/LocalResource.java | 84 +++ .../serviceruntime/LocalResourceInfo.java | 111 +++ .../serviceruntime/LocalResourcesInfo.java | 76 +++ .../serviceruntime/ObjectFactory.java | 250 +++++++ .../serviceruntime/OutputChannel.java | 13 + .../Protocol1RuntimeClient.java | 48 ++ .../Protocol1RuntimeCurrentStateClient.java | 42 ++ .../Protocol1RuntimeGoalStateClient.java | 155 +++++ .../serviceruntime/ProtocolEnum.java | 88 +++ .../serviceruntime/ReleaseCurrentState.java | 7 + .../windowsazure/serviceruntime/Role.java | 54 ++ .../serviceruntime/RoleEnvironment.java | 631 ++++++++++++++++++ .../serviceruntime/RoleEnvironmentChange.java | 13 + .../RoleEnvironmentChangedEvent.java | 41 ++ .../RoleEnvironmentChangedListener.java | 28 + .../RoleEnvironmentChangingEvent.java | 69 ++ .../RoleEnvironmentChangingListener.java | 42 ++ ...EnvironmentConfigurationSettingChange.java | 31 + .../serviceruntime/RoleEnvironmentData.java | 55 ++ .../RoleEnvironmentDataDeserializer.java | 13 + .../serviceruntime/RoleEnvironmentInfo.java | 123 ++++ .../RoleEnvironmentNotAvailableException.java | 31 + .../RoleEnvironmentStoppingListener.java | 22 + .../RoleEnvironmentTopologyChange.java | 31 + .../windowsazure/serviceruntime/RoleInfo.java | 97 +++ .../serviceruntime/RoleInstance.java | 94 +++ .../serviceruntime/RoleInstanceEndpoint.java | 76 +++ .../serviceruntime/RoleInstanceInfo.java | 135 ++++ .../serviceruntime/RoleInstanceStatus.java | 23 + .../serviceruntime/RoleInstancesInfo.java | 76 +++ .../serviceruntime/RolesInfo.java | 76 +++ .../serviceruntime/RuntimeClient.java | 12 + .../serviceruntime/RuntimeClientFactory.java | 13 + .../RuntimeCurrentStateClient.java | 11 + .../RuntimeGoalStateClient.java | 18 + .../serviceruntime/RuntimeKernel.java | 82 +++ .../RuntimeServerDiscoveryInfo.java | 69 ++ .../RuntimeServerEndpointInfo.java | 92 +++ .../RuntimeServerEndpointsInfo.java | 76 +++ .../serviceruntime/RuntimeVersionManager.java | 51 ++ .../RuntimeVersionProtocolClient.java | 48 ++ .../serviceruntime/StatusLeaseInfo.java | 156 +++++ .../XmlCurrentStateSerializer.java | 65 ++ .../XmlGoalStateDeserializer.java | 44 ++ .../XmlRoleEnvironmentDataDeserializer.java | 172 +++++ .../windowsazure/serviceruntime/overview.html | 6 + .../windowsazure/serviceruntime/package.html | 16 + .../serviceruntime/FileInputChannelTests.java | 40 ++ .../serviceruntime/MockInputChannel.java | 69 ++ ...otocol1RuntimeCurrentStateClientTests.java | 102 +++ .../Protocol1RuntimeGoalStateClientTests.java | 269 ++++++++ .../serviceruntime/RoleEnvironmentTests.java | 61 ++ .../RuntimeVersionManagerTests.java | 114 ++++ .../XmlGoalStateDeserializerTests.java | 16 + 79 files changed, 5756 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b725a1eea6ee1..94dfea2a308a2 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -44,6 +44,12 @@ 4.8 test + + org.hamcrest + hamcrest-all + 1.1 + test + org.mockito mockito-all diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java new file mode 100644 index 0000000000000..70ec3914a6875 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java @@ -0,0 +1,33 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.math.BigInteger; +import java.util.Calendar; + +/** + * + */ +class AcquireCurrentState extends CurrentState { + private final BigInteger incarnation; + private final CurrentStatus status; + private final Calendar expiration; + + public AcquireCurrentState(String clientId, BigInteger incarnation, + CurrentStatus status, Calendar expiration) { + super(clientId); + this.incarnation = incarnation; + this.status = status; + this.expiration = expiration; + } + + public BigInteger getIncarnation() { + return incarnation; + } + + public CurrentStatus getStatus() { + return status; + } + + public Calendar getExpiration() { + return expiration; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java new file mode 100644 index 0000000000000..fdf1c8a0eab34 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java @@ -0,0 +1,157 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.math.BigInteger; +import java.util.Calendar; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + *

Java class for AcquireLeaseInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="AcquireLeaseInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="Incarnation" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
+ *         <element name="Status" type="{}CurrentStatusEnum"/>
+ *         <element name="StatusDetail" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Expiration" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
+ *       </all>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AcquireLeaseInfo", propOrder = { + +}) +class AcquireLeaseInfo { + + @XmlElement(name = "Incarnation", required = true) + @XmlSchemaType(name = "unsignedLong") + protected BigInteger incarnation; + @XmlElement(name = "Status", required = true) + protected CurrentStatusEnum status; + @XmlElement(name = "StatusDetail", required = true) + protected String statusDetail; + @XmlElement(name = "Expiration", required = true, type = String.class) + @XmlJavaTypeAdapter(Adapter1 .class) + @XmlSchemaType(name = "dateTime") + protected Calendar expiration; + + /** + * Gets the value of the incarnation property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getIncarnation() { + return incarnation; + } + + /** + * Sets the value of the incarnation property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setIncarnation(BigInteger value) { + this.incarnation = value; + } + + /** + * Gets the value of the status property. + * + * @return + * possible object is + * {@link CurrentStatusEnum } + * + */ + public CurrentStatusEnum getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + * @param value + * allowed object is + * {@link CurrentStatusEnum } + * + */ + public void setStatus(CurrentStatusEnum value) { + this.status = value; + } + + /** + * Gets the value of the statusDetail property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStatusDetail() { + return statusDetail; + } + + /** + * Sets the value of the statusDetail property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStatusDetail(String value) { + this.statusDetail = value; + } + + /** + * Gets the value of the expiration property. + * + * @return + * possible object is + * {@link String } + * + */ + public Calendar getExpiration() { + return expiration; + } + + /** + * Sets the value of the expiration property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setExpiration(Calendar value) { + this.expiration = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java new file mode 100644 index 0000000000000..7277282500f23 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java @@ -0,0 +1,30 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Calendar; +import javax.xml.bind.annotation.adapters.XmlAdapter; + +class Adapter1 + extends XmlAdapter +{ + + + public Calendar unmarshal(String value) { + return (javax.xml.bind.DatatypeConverter.parseDateTime(value)); + } + + public String marshal(Calendar value) { + if (value == null) { + return null; + } + return (javax.xml.bind.DatatypeConverter.printDateTime(value)); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java new file mode 100644 index 0000000000000..10abb5956fb44 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -0,0 +1,53 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; + +class ChunkedGoalStateDeserializer implements GoalStateDeserializer { + private final XmlGoalStateDeserializer deserializer; + private BufferedReader reader; + + public ChunkedGoalStateDeserializer() { + this.deserializer = new XmlGoalStateDeserializer(); + } + + @Override + public void initialize(InputStream inputStream) { + try { + reader = new BufferedReader(new InputStreamReader(inputStream, + "UTF-8")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + @Override + public GoalState deserialize() { + try { + String lengthString = reader.readLine(); + + if (lengthString == null) { + return null; + } + + int length = Integer.parseInt(lengthString.toString(), 16); + char chunkData[] = new char[length]; + + reader.read(chunkData, 0, length); + + GoalState goalState = deserializer + .deserialize(new String(chunkData)); + + reader.readLine(); + + return goalState; + } catch (IOException e) { + e.printStackTrace(); + + return null; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java new file mode 100644 index 0000000000000..9ea4fc74eaa7d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java @@ -0,0 +1,92 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ConfigurationSettingInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ConfigurationSettingInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ConfigurationSettingInfo") +class ConfigurationSettingInfo { + + @XmlAttribute(required = true) + protected String name; + @XmlAttribute(required = true) + protected String value; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java new file mode 100644 index 0000000000000..b5ac3b805f9b3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ConfigurationSettingsInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ConfigurationSettingsInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="ConfigurationSetting" type="{}ConfigurationSettingInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ConfigurationSettingsInfo", propOrder = { + "configurationSetting" +}) +class ConfigurationSettingsInfo { + + @XmlElement(name = "ConfigurationSetting") + protected List configurationSetting; + + /** + * Gets the value of the configurationSetting property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the configurationSetting property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getConfigurationSetting().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ConfigurationSettingInfo } + * + * + */ + public List getConfigurationSetting() { + if (configurationSetting == null) { + configurationSetting = new ArrayList(); + } + return this.configurationSetting; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java new file mode 100644 index 0000000000000..aa502627d4b84 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java @@ -0,0 +1,216 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CurrentRoleInstanceInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CurrentRoleInstanceInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="ConfigurationSettings" type="{}ConfigurationSettingsInfo" minOccurs="0"/>
+ *         <element name="LocalResources" type="{}LocalResourcesInfo" minOccurs="0"/>
+ *         <element name="Endpoints" type="{}EndpointsInfo" minOccurs="0"/>
+ *       </all>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="roleName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="faultDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="updateDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CurrentRoleInstanceInfo", propOrder = { + +}) +class CurrentRoleInstanceInfo { + + @XmlElement(name = "ConfigurationSettings") + protected ConfigurationSettingsInfo configurationSettings; + @XmlElement(name = "LocalResources") + protected LocalResourcesInfo localResources; + @XmlElement(name = "Endpoints") + protected EndpointsInfo endpoints; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected String roleName; + @XmlAttribute(required = true) + protected int faultDomain; + @XmlAttribute(required = true) + protected int updateDomain; + + /** + * Gets the value of the configurationSettings property. + * + * @return + * possible object is + * {@link ConfigurationSettingsInfo } + * + */ + public ConfigurationSettingsInfo getConfigurationSettings() { + return configurationSettings; + } + + /** + * Sets the value of the configurationSettings property. + * + * @param value + * allowed object is + * {@link ConfigurationSettingsInfo } + * + */ + public void setConfigurationSettings(ConfigurationSettingsInfo value) { + this.configurationSettings = value; + } + + /** + * Gets the value of the localResources property. + * + * @return + * possible object is + * {@link LocalResourcesInfo } + * + */ + public LocalResourcesInfo getLocalResources() { + return localResources; + } + + /** + * Sets the value of the localResources property. + * + * @param value + * allowed object is + * {@link LocalResourcesInfo } + * + */ + public void setLocalResources(LocalResourcesInfo value) { + this.localResources = value; + } + + /** + * Gets the value of the endpoints property. + * + * @return + * possible object is + * {@link EndpointsInfo } + * + */ + public EndpointsInfo getEndpoints() { + return endpoints; + } + + /** + * Sets the value of the endpoints property. + * + * @param value + * allowed object is + * {@link EndpointsInfo } + * + */ + public void setEndpoints(EndpointsInfo value) { + this.endpoints = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the roleName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRoleName() { + return roleName; + } + + /** + * Sets the value of the roleName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRoleName(String value) { + this.roleName = value; + } + + /** + * Gets the value of the faultDomain property. + * + */ + public int getFaultDomain() { + return faultDomain; + } + + /** + * Sets the value of the faultDomain property. + * + */ + public void setFaultDomain(int value) { + this.faultDomain = value; + } + + /** + * Gets the value of the updateDomain property. + * + */ + public int getUpdateDomain() { + return updateDomain; + } + + /** + * Sets the value of the updateDomain property. + * + */ + public void setUpdateDomain(int value) { + this.updateDomain = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java new file mode 100644 index 0000000000000..6b2408f889e75 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java @@ -0,0 +1,19 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +class CurrentState { + private final String clientId; + + public CurrentState(String clientId) { + this.clientId = clientId; + } + + public String getClientId() { + return clientId; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java new file mode 100644 index 0000000000000..dbcd006fd451b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java @@ -0,0 +1,69 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CurrentStateInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="CurrentStateInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice>
+ *         <element name="StatusLease" type="{}StatusLeaseInfo"/>
+ *       </choice>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CurrentStateInfo", propOrder = { + "statusLease" +}) +class CurrentStateInfo { + + @XmlElement(name = "StatusLease") + protected StatusLeaseInfo statusLease; + + /** + * Gets the value of the statusLease property. + * + * @return + * possible object is + * {@link StatusLeaseInfo } + * + */ + public StatusLeaseInfo getStatusLease() { + return statusLease; + } + + /** + * Sets the value of the statusLease property. + * + * @param value + * allowed object is + * {@link StatusLeaseInfo } + * + */ + public void setStatusLease(StatusLeaseInfo value) { + this.statusLease = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java new file mode 100644 index 0000000000000..dff84856d6012 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java @@ -0,0 +1,13 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.OutputStream; + +/** + * + */ +interface CurrentStateSerializer { + public void serialize(CurrentState state, OutputStream stream); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java new file mode 100644 index 0000000000000..0b5b76960c7a1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.serviceruntime; + +enum CurrentStatus { + STARTED, BUSY, RECYCLE, STOPPED, +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java new file mode 100644 index 0000000000000..0e7c4657d3356 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java @@ -0,0 +1,64 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for CurrentStatusEnum. + * + *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <simpleType name="CurrentStatusEnum">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="Started"/>
+ *     <enumeration value="Busy"/>
+ *     <enumeration value="Recycle"/>
+ *     <enumeration value="Stopped"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "CurrentStatusEnum") +@XmlEnum +enum CurrentStatusEnum { + + @XmlEnumValue("Started") + STARTED("Started"), + @XmlEnumValue("Busy") + BUSY("Busy"), + @XmlEnumValue("Recycle") + RECYCLE("Recycle"), + @XmlEnumValue("Stopped") + STOPPED("Stopped"); + private final String value; + + CurrentStatusEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + public static CurrentStatusEnum fromValue(String v) { + for (CurrentStatusEnum c: CurrentStatusEnum.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java new file mode 100644 index 0000000000000..92bbd0f1f9b77 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java @@ -0,0 +1,84 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for DeploymentInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="DeploymentInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="emulated" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DeploymentInfo") +class DeploymentInfo { + + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected boolean emulated; + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the emulated property. + * + */ + public boolean isEmulated() { + return emulated; + } + + /** + * Sets the value of the emulated property. + * + */ + public void setEmulated(boolean value) { + this.emulated = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java new file mode 100644 index 0000000000000..50401a623c15b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java @@ -0,0 +1,138 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for EndpointInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="EndpointInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="address" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="port" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="protocol" use="required" type="{}ProtocolEnum" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "EndpointInfo") +class EndpointInfo { + + @XmlAttribute(required = true) + protected String name; + @XmlAttribute(required = true) + protected String address; + @XmlAttribute(required = true) + protected int port; + @XmlAttribute(required = true) + protected ProtocolEnum protocol; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the address property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAddress() { + return address; + } + + /** + * Sets the value of the address property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAddress(String value) { + this.address = value; + } + + /** + * Gets the value of the port property. + * + */ + public int getPort() { + return port; + } + + /** + * Sets the value of the port property. + * + */ + public void setPort(int value) { + this.port = value; + } + + /** + * Gets the value of the protocol property. + * + * @return + * possible object is + * {@link ProtocolEnum } + * + */ + public ProtocolEnum getProtocol() { + return protocol; + } + + /** + * Sets the value of the protocol property. + * + * @param value + * allowed object is + * {@link ProtocolEnum } + * + */ + public void setProtocol(ProtocolEnum value) { + this.protocol = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java new file mode 100644 index 0000000000000..daed15178a87d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for EndpointsInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="EndpointsInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Endpoint" type="{}EndpointInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "EndpointsInfo", propOrder = { + "endpoint" +}) +class EndpointsInfo { + + @XmlElement(name = "Endpoint") + protected List endpoint; + + /** + * Gets the value of the endpoint property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the endpoint property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getEndpoint().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link EndpointInfo } + * + * + */ + public List getEndpoint() { + if (endpoint == null) { + endpoint = new ArrayList(); + } + return this.endpoint; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java new file mode 100644 index 0000000000000..230f498af838b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java @@ -0,0 +1,11 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +enum ExpectedState { + STARTED, STOPPED, +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java new file mode 100644 index 0000000000000..18125994e9a8e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java @@ -0,0 +1,58 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ExpectedStateEnum. + * + *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <simpleType name="ExpectedStateEnum">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="Started"/>
+ *     <enumeration value="Stopped"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "ExpectedStateEnum") +@XmlEnum +enum ExpectedStateEnum { + + @XmlEnumValue("Started") + STARTED("Started"), + @XmlEnumValue("Stopped") + STOPPED("Stopped"); + private final String value; + + ExpectedStateEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + public static ExpectedStateEnum fromValue(String v) { + for (ExpectedStateEnum c: ExpectedStateEnum.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java new file mode 100644 index 0000000000000..6681d688cf6fc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java @@ -0,0 +1,24 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** + * + */ +class FileInputChannel implements InputChannel { + public FileInputChannel() { + } + + public InputStream getInputStream(String name) { + try { + return new FileInputStream(name); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java new file mode 100644 index 0000000000000..499197828681a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java @@ -0,0 +1,24 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; + +/** + * + */ +class FileOutputChannel implements OutputChannel { + public FileOutputChannel() { + } + + public OutputStream getOutputStream(String name) { + try { + return new FileOutputStream(name); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java new file mode 100644 index 0000000000000..ca18e97d2c53b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java @@ -0,0 +1,48 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.math.BigInteger; +import java.util.Calendar; + +/** + * + */ +class GoalState { + private final BigInteger incarnation; + private final ExpectedState expectedState; + private final String environmentPath; + private final Calendar deadline; + private final String currentStateEndpoint; + + public GoalState(BigInteger incarnation, ExpectedState expectedState, + String environmentPath, Calendar deadline, + String currentStateEndpoint) { + this.incarnation = incarnation; + this.expectedState = expectedState; + this.environmentPath = environmentPath; + this.deadline = deadline; + this.currentStateEndpoint = currentStateEndpoint; + } + + public BigInteger getIncarnation() { + return incarnation; + } + + public ExpectedState getExpectedState() { + return expectedState; + } + + public String getEnvironmentPath() { + return environmentPath; + } + + public Calendar getDeadline() { + return deadline; + } + + public String getCurrentStateEndpoint() { + return currentStateEndpoint; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java new file mode 100644 index 0000000000000..440ff116fac8d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java @@ -0,0 +1,11 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +interface GoalStateChangedListener { + public void goalStateChanged(GoalState newGoalState); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java new file mode 100644 index 0000000000000..8e51706589ca9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java @@ -0,0 +1,15 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; + +/** + * + */ +interface GoalStateDeserializer { + public void initialize(InputStream inputStream); + + public GoalState deserialize(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java new file mode 100644 index 0000000000000..0293f16adaaf8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java @@ -0,0 +1,184 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.math.BigInteger; +import java.util.Calendar; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + *

Java class for GoalStateInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="GoalStateInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="Incarnation" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
+ *         <element name="ExpectedState" type="{}ExpectedStateEnum"/>
+ *         <element name="RoleEnvironmentPath" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="CurrentStateEndpoint" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Deadline" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
+ *       </all>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "GoalStateInfo", propOrder = { + +}) +class GoalStateInfo { + + @XmlElement(name = "Incarnation", required = true) + @XmlSchemaType(name = "unsignedLong") + protected BigInteger incarnation; + @XmlElement(name = "ExpectedState", required = true) + protected ExpectedStateEnum expectedState; + @XmlElement(name = "RoleEnvironmentPath", required = true) + protected String roleEnvironmentPath; + @XmlElement(name = "CurrentStateEndpoint", required = true) + protected String currentStateEndpoint; + @XmlElement(name = "Deadline", required = true, type = String.class) + @XmlJavaTypeAdapter(Adapter1 .class) + @XmlSchemaType(name = "dateTime") + protected Calendar deadline; + + /** + * Gets the value of the incarnation property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getIncarnation() { + return incarnation; + } + + /** + * Sets the value of the incarnation property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setIncarnation(BigInteger value) { + this.incarnation = value; + } + + /** + * Gets the value of the expectedState property. + * + * @return + * possible object is + * {@link ExpectedStateEnum } + * + */ + public ExpectedStateEnum getExpectedState() { + return expectedState; + } + + /** + * Sets the value of the expectedState property. + * + * @param value + * allowed object is + * {@link ExpectedStateEnum } + * + */ + public void setExpectedState(ExpectedStateEnum value) { + this.expectedState = value; + } + + /** + * Gets the value of the roleEnvironmentPath property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRoleEnvironmentPath() { + return roleEnvironmentPath; + } + + /** + * Sets the value of the roleEnvironmentPath property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRoleEnvironmentPath(String value) { + this.roleEnvironmentPath = value; + } + + /** + * Gets the value of the currentStateEndpoint property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCurrentStateEndpoint() { + return currentStateEndpoint; + } + + /** + * Sets the value of the currentStateEndpoint property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCurrentStateEndpoint(String value) { + this.currentStateEndpoint = value; + } + + /** + * Gets the value of the deadline property. + * + * @return + * possible object is + * {@link String } + * + */ + public Calendar getDeadline() { + return deadline; + } + + /** + * Sets the value of the deadline property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDeadline(Calendar value) { + this.deadline = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java new file mode 100644 index 0000000000000..a45bee2e0751a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java @@ -0,0 +1,13 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; + +/** + * + */ +interface InputChannel { + public abstract InputStream getInputStream(String name); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java new file mode 100644 index 0000000000000..71a2a5147043d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java @@ -0,0 +1,84 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents a local storage resource reserved for a service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + */ +public final class LocalResource { + + /** + * maximum size in megabytes allocated for the local storage resource, as + * defined in the service + */ + private int maximumSizeInMegabytes; + + /** + * name of the local store as declared in the service definition file. + */ + private String name; + + /** + * full directory path to the local storage resource. + */ + private String rootPath; + + /** + * Package accessible constructor + * + * @param maximumSizeInMegabytes + * @param name + * @param rootPath + */ + LocalResource(int maximumSizeInMegabytes, String name, String rootPath) { + this.maximumSizeInMegabytes = maximumSizeInMegabytes; + this.name = name; + this.rootPath = rootPath; + } + + /** + * Returns the maximum size, in megabytes, allocated for the local storage + * resource, as defined in the service. + * + * @return The maximum size, in megabytes, allocated for the local storage + * resource. + */ + public int getMaximumSizeInMegabytes() { + return maximumSizeInMegabytes; + } + + /** + * Returns the name of the local store as declared in the service definition + * file. + * + * @return A String object that represents the name of the + * local store. + */ + public String getName() { + return name; + } + + /** + * Returns the full directory path to the local storage resource. + * + * @return A String object that represents the path to the + * local storage resource. + */ + public String getRootPath() { + return rootPath; + } + + /** + * Returns the name, maximum size, and full directory path of the local + * resource. + * + * @return A String object that contains the local resource + * name, maximum size, and directory path. + */ + @Override + public String toString() { + return name + " max:" + maximumSizeInMegabytes + "MB path:" + rootPath; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java new file mode 100644 index 0000000000000..643c5ca6e75eb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java @@ -0,0 +1,111 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for LocalResourceInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="LocalResourceInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="path" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="sizeInMB" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "LocalResourceInfo") +class LocalResourceInfo { + + @XmlAttribute(required = true) + protected String name; + @XmlAttribute(required = true) + protected String path; + @XmlAttribute(required = true) + protected int sizeInMB; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the path property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPath() { + return path; + } + + /** + * Sets the value of the path property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPath(String value) { + this.path = value; + } + + /** + * Gets the value of the sizeInMB property. + * + */ + public int getSizeInMB() { + return sizeInMB; + } + + /** + * Sets the value of the sizeInMB property. + * + */ + public void setSizeInMB(int value) { + this.sizeInMB = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java new file mode 100644 index 0000000000000..3a8ba4a4bb21f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for LocalResourcesInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="LocalResourcesInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="LocalResource" type="{}LocalResourceInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "LocalResourcesInfo", propOrder = { + "localResource" +}) +class LocalResourcesInfo { + + @XmlElement(name = "LocalResource") + protected List localResource; + + /** + * Gets the value of the localResource property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the localResource property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getLocalResource().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link LocalResourceInfo } + * + * + */ + public List getLocalResource() { + if (localResource == null) { + localResource = new ArrayList(); + } + return this.localResource; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java new file mode 100644 index 0000000000000..bf4d4e423f770 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java @@ -0,0 +1,250 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.microsoft.windowsazure.serviceruntime package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +class ObjectFactory { + + private final static QName _GoalState_QNAME = new QName("", "GoalState"); + private final static QName _RoleEnvironment_QNAME = new QName("", "RoleEnvironment"); + private final static QName _CurrentState_QNAME = new QName("", "CurrentState"); + private final static QName _RuntimeServerDiscovery_QNAME = new QName("", "RuntimeServerDiscovery"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.windowsazure.serviceruntime + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link StatusLeaseInfo.Release } + * + */ + public StatusLeaseInfo.Release createStatusLeaseInfoRelease() { + return new StatusLeaseInfo.Release(); + } + + /** + * Create an instance of {@link RuntimeServerEndpointsInfo } + * + */ + public RuntimeServerEndpointsInfo createRuntimeServerEndpointsInfo() { + return new RuntimeServerEndpointsInfo(); + } + + /** + * Create an instance of {@link RuntimeServerEndpointInfo } + * + */ + public RuntimeServerEndpointInfo createRuntimeServerEndpointInfo() { + return new RuntimeServerEndpointInfo(); + } + + /** + * Create an instance of {@link RuntimeServerDiscoveryInfo } + * + */ + public RuntimeServerDiscoveryInfo createRuntimeServerDiscoveryInfo() { + return new RuntimeServerDiscoveryInfo(); + } + + /** + * Create an instance of {@link GoalStateInfo } + * + */ + public GoalStateInfo createGoalStateInfo() { + return new GoalStateInfo(); + } + + /** + * Create an instance of {@link LocalResourcesInfo } + * + */ + public LocalResourcesInfo createLocalResourcesInfo() { + return new LocalResourcesInfo(); + } + + /** + * Create an instance of {@link ConfigurationSettingInfo } + * + */ + public ConfigurationSettingInfo createConfigurationSettingInfo() { + return new ConfigurationSettingInfo(); + } + + /** + * Create an instance of {@link CurrentStateInfo } + * + */ + public CurrentStateInfo createCurrentStateInfo() { + return new CurrentStateInfo(); + } + + /** + * Create an instance of {@link CurrentRoleInstanceInfo } + * + */ + public CurrentRoleInstanceInfo createCurrentRoleInstanceInfo() { + return new CurrentRoleInstanceInfo(); + } + + /** + * Create an instance of {@link LocalResourceInfo } + * + */ + public LocalResourceInfo createLocalResourceInfo() { + return new LocalResourceInfo(); + } + + /** + * Create an instance of {@link RolesInfo } + * + */ + public RolesInfo createRolesInfo() { + return new RolesInfo(); + } + + /** + * Create an instance of {@link StatusLeaseInfo } + * + */ + public StatusLeaseInfo createStatusLeaseInfo() { + return new StatusLeaseInfo(); + } + + /** + * Create an instance of {@link DeploymentInfo } + * + */ + public DeploymentInfo createDeploymentInfo() { + return new DeploymentInfo(); + } + + /** + * Create an instance of {@link RoleInstancesInfo } + * + */ + public RoleInstancesInfo createRoleInstancesInfo() { + return new RoleInstancesInfo(); + } + + /** + * Create an instance of {@link RoleInfo } + * + */ + public RoleInfo createRoleInfo() { + return new RoleInfo(); + } + + /** + * Create an instance of {@link ConfigurationSettingsInfo } + * + */ + public ConfigurationSettingsInfo createConfigurationSettingsInfo() { + return new ConfigurationSettingsInfo(); + } + + /** + * Create an instance of {@link EndpointsInfo } + * + */ + public EndpointsInfo createEndpointsInfo() { + return new EndpointsInfo(); + } + + /** + * Create an instance of {@link AcquireLeaseInfo } + * + */ + public AcquireLeaseInfo createAcquireLeaseInfo() { + return new AcquireLeaseInfo(); + } + + /** + * Create an instance of {@link EndpointInfo } + * + */ + public EndpointInfo createEndpointInfo() { + return new EndpointInfo(); + } + + /** + * Create an instance of {@link RoleEnvironmentInfo } + * + */ + public RoleEnvironmentInfo createRoleEnvironmentInfo() { + return new RoleEnvironmentInfo(); + } + + /** + * Create an instance of {@link RoleInstanceInfo } + * + */ + public RoleInstanceInfo createRoleInstanceInfo() { + return new RoleInstanceInfo(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GoalStateInfo }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "GoalState") + public JAXBElement createGoalState(GoalStateInfo value) { + return new JAXBElement(_GoalState_QNAME, GoalStateInfo.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link RoleEnvironmentInfo }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "RoleEnvironment") + public JAXBElement createRoleEnvironment(RoleEnvironmentInfo value) { + return new JAXBElement(_RoleEnvironment_QNAME, RoleEnvironmentInfo.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CurrentStateInfo }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "CurrentState") + public JAXBElement createCurrentState(CurrentStateInfo value) { + return new JAXBElement(_CurrentState_QNAME, CurrentStateInfo.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link RuntimeServerDiscoveryInfo }{@code >}} + * + */ + @XmlElementDecl(namespace = "", name = "RuntimeServerDiscovery") + public JAXBElement createRuntimeServerDiscovery(RuntimeServerDiscoveryInfo value) { + return new JAXBElement(_RuntimeServerDiscovery_QNAME, RuntimeServerDiscoveryInfo.class, null, value); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java new file mode 100644 index 0000000000000..2e9ed8f2fa162 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java @@ -0,0 +1,13 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.OutputStream; + +/** + * + */ +interface OutputChannel { + public abstract OutputStream getOutputStream(String name); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java new file mode 100644 index 0000000000000..de419213f8d50 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java @@ -0,0 +1,48 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +class Protocol1RuntimeClient implements RuntimeClient { + private final Protocol1RuntimeGoalStateClient goalStateClient; + private final Protocol1RuntimeCurrentStateClient currentStateClient; + + public Protocol1RuntimeClient( + Protocol1RuntimeGoalStateClient goalStateClient, + Protocol1RuntimeCurrentStateClient currentStateClient, + String endpoint) { + this.goalStateClient = goalStateClient; + this.currentStateClient = currentStateClient; + + this.goalStateClient.setEndpoint(endpoint); + } + + @Override + public GoalState getCurrentGoalState() throws InterruptedException { + return goalStateClient.getCurrentGoalState(); + } + + @Override + public RoleEnvironmentData getRoleEnvironmentData() + throws InterruptedException { + return goalStateClient.getRoleEnvironmentData(); + } + + @Override + public void addGoalStateChangedListener(GoalStateChangedListener listener) { + goalStateClient.addGoalStateChangedListener(listener); + } + + @Override + public void removeGoalStateChangedListener(GoalStateChangedListener listener) { + goalStateClient.removeGoalStateChangedListener(listener); + } + + @Override + public void setCurrentState(CurrentState state) { + currentStateClient.setCurrentState(state); + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java new file mode 100644 index 0000000000000..48e33a719258f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java @@ -0,0 +1,42 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.concurrent.atomic.AtomicReference; + +/** + * + */ +class Protocol1RuntimeCurrentStateClient implements RuntimeCurrentStateClient { + private final CurrentStateSerializer serializer; + private final OutputChannel outputChannel; + private final AtomicReference endpoint; + + public Protocol1RuntimeCurrentStateClient( + CurrentStateSerializer serializer, OutputChannel outputChannel) { + this.serializer = serializer; + this.outputChannel = outputChannel; + this.endpoint = new AtomicReference(); + } + + public void setEndpoint(String endpoint) { + this.endpoint.set(endpoint); + } + + @Override + public void setCurrentState(CurrentState state) { + OutputStream outputStream = outputChannel.getOutputStream(endpoint + .get()); + + serializer.serialize(state, outputStream); + + try { + outputStream.close(); + } catch (IOException e) { + throw new RoleEnvironmentNotAvailableException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java new file mode 100644 index 0000000000000..a1457962c88bb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java @@ -0,0 +1,155 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +/** + * + */ +class Protocol1RuntimeGoalStateClient implements RuntimeGoalStateClient { + private final Protocol1RuntimeCurrentStateClient currentStateClient; + private Thread ioThread; + private final GoalStateDeserializer goalStateDeserializer; + private final RoleEnvironmentDataDeserializer roleEnvironmentDeserializer; + private final InputChannel inputChannel; + private final CountDownLatch goalStateLatch; + private final List listeners; + private String endpoint; + + private AtomicReference currentGoalState; + private AtomicReference currentEnvironmentData; + + public Protocol1RuntimeGoalStateClient( + Protocol1RuntimeCurrentStateClient currentStateClient, + GoalStateDeserializer goalStateDeserializer, + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer, + InputChannel inputChannel) { + this.currentStateClient = currentStateClient; + this.goalStateDeserializer = goalStateDeserializer; + this.roleEnvironmentDeserializer = roleEnvironmentDeserializer; + this.inputChannel = inputChannel; + + this.listeners = new LinkedList(); + this.goalStateLatch = new CountDownLatch(1); + + this.currentGoalState = new AtomicReference(); + this.currentEnvironmentData = new AtomicReference(); + } + + public GoalState getCurrentGoalState() throws InterruptedException { + ensureGoalStateRetrieved(); + + return currentGoalState.get(); + } + + public synchronized RoleEnvironmentData getRoleEnvironmentData() + throws InterruptedException { + ensureGoalStateRetrieved(); + + if (currentEnvironmentData.get() == null) { + GoalState current = currentGoalState.get(); + + if (current.getEnvironmentPath() == null) { + throw new InterruptedException( + "No role environment data for the current goal state."); + } + + InputStream environmentStream = inputChannel.getInputStream(current + .getEnvironmentPath()); + + currentEnvironmentData.set(roleEnvironmentDeserializer + .deserialize(environmentStream)); + } + + return currentEnvironmentData.get(); + } + + public void addGoalStateChangedListener(GoalStateChangedListener listener) { + listeners.add(listener); + } + + public void removeGoalStateChangedListener(GoalStateChangedListener listener) { + listeners.remove(listener); + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + private void ensureGoalStateRetrieved() throws InterruptedException { + ensureThread(); + + if (currentGoalState.get() == null) { + while (!goalStateLatch.await(100, TimeUnit.MILLISECONDS)) { + ensureThread(); + } + } + } + + private void ensureThread() { + if (ioThread == null || !ioThread.isAlive()) { + startGoalStateTask(); + } + } + + private void startGoalStateTask() { + Runnable goalStateListener = new Runnable() { + public void run() { + InputStream inputStream = inputChannel.getInputStream(endpoint); + + goalStateDeserializer.initialize(inputStream); + + GoalState goalState = goalStateDeserializer.deserialize(); + + if (goalState == null) { + return; + } + + currentGoalState.set(goalState); + + if (goalState.getEnvironmentPath() != null) { + currentEnvironmentData.set(null); + } + + currentStateClient.setEndpoint(currentGoalState.get() + .getCurrentStateEndpoint()); + + goalStateLatch.countDown(); + + while (true) { + goalState = goalStateDeserializer.deserialize(); + + if (goalState == null) { + return; + } + + currentGoalState.set(goalState); + + if (goalState.getEnvironmentPath() != null) { + currentEnvironmentData.set(null); + } + + currentStateClient.setEndpoint(currentGoalState.get() + .getCurrentStateEndpoint()); + + for (GoalStateChangedListener listener : listeners) { + listener.goalStateChanged(currentGoalState.get()); + } + } + } + }; + + ioThread = new Thread(goalStateListener); + + ioThread.setDaemon(true); + + ioThread.start(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java new file mode 100644 index 0000000000000..2b3e92aab6215 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java @@ -0,0 +1,88 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for ProtocolEnum. + * + *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <simpleType name="ProtocolEnum">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="ip"/>
+ *     <enumeration value="tcp"/>
+ *     <enumeration value="tls"/>
+ *     <enumeration value="http"/>
+ *     <enumeration value="https"/>
+ *     <enumeration value="wcf:tcp"/>
+ *     <enumeration value="wcf:tls"/>
+ *     <enumeration value="wcf:http"/>
+ *     <enumeration value="wcf:https"/>
+ *     <enumeration value="wcf:https:certificate"/>
+ *     <enumeration value="udp"/>
+ *     <enumeration value="raw"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "ProtocolEnum") +@XmlEnum +enum ProtocolEnum { + + @XmlEnumValue("ip") + IP("ip"), + @XmlEnumValue("tcp") + TCP("tcp"), + @XmlEnumValue("tls") + TLS("tls"), + @XmlEnumValue("http") + HTTP("http"), + @XmlEnumValue("https") + HTTPS("https"), + @XmlEnumValue("wcf:tcp") + WCF_TCP("wcf:tcp"), + @XmlEnumValue("wcf:tls") + WCF_TLS("wcf:tls"), + @XmlEnumValue("wcf:http") + WCF_HTTP("wcf:http"), + @XmlEnumValue("wcf:https") + WCF_HTTPS("wcf:https"), + @XmlEnumValue("wcf:https:certificate") + WCF_HTTPS_CERTIFICATE("wcf:https:certificate"), + @XmlEnumValue("udp") + UDP("udp"), + @XmlEnumValue("raw") + RAW("raw"); + private final String value; + + ProtocolEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + public static ProtocolEnum fromValue(String v) { + for (ProtocolEnum c: ProtocolEnum.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java new file mode 100644 index 0000000000000..8aa2fb7d992c2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java @@ -0,0 +1,7 @@ +package com.microsoft.windowsazure.serviceruntime; + +class ReleaseCurrentState extends CurrentState { + public ReleaseCurrentState(String clientId) { + super(clientId); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java new file mode 100644 index 0000000000000..62aa134e39e87 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java @@ -0,0 +1,54 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Map; + +/** + * Represents a role that is defined as part of a hosted service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + */ +public final class Role { + private final String name; + private final Map instances; + + /** + * Constructor + * + * @param name + * @param instances + */ + Role(String name, Map instances) { + this.name = name; + this.instances = instances; + } + + /** + * Returns the collection of instances for the role. + *

+ * The number of instances of a role to be deployed to Windows Azure is + * specified in the service's configuration file. + *

+ * A role must define at least one internal endpoint in order for its set of + * instances to be known at runtime. + * + * @return A read-only java.util.Map object that contains the + * instances for the role, or null if the instances + * could not be retrieved. + */ + public Map getInstances() { + return instances; + } + + /** + * Returns the name of the role as it is declared in the service definition + * file. + * + * @return A String object that represents the name of the role + * as it is declared in the service definition file. + */ + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java new file mode 100644 index 0000000000000..d8015c1be4cc7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -0,0 +1,631 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Calendar; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; + +/** + * Represents the Windows Azure environment in which an instance of a role is + * running. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + */ +public final class RoleEnvironment { + private static final String VersionEndpointEnvironmentName = "WaRuntimeEndpoint"; + private static final String VersionEndpointFixedPath = "\\\\.\\pipe\\WindowsAzureRuntime"; + private static final String clientId; + + private static RuntimeClient runtimeClient; + private static AtomicReference currentGoalState; + private static AtomicReference currentEnvironmentData; + private static List changingListeners; + private static List changedListeners; + private static List stoppingListeners; + private static AtomicReference lastState; + private static final Calendar maxDateTime; + + static { + try { + JAXBContext.newInstance(RoleEnvironment.class.getPackage() + .getName()); + } catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + clientId = UUID.randomUUID().toString(); + maxDateTime = javax.xml.bind.DatatypeConverter + .parseDateTime("9999-12-31T23:59:59.9999999"); + } + + private RoleEnvironment() { + }; + + private static synchronized void initialize() { + if (runtimeClient == null) { + String endpoint = System.getenv(VersionEndpointEnvironmentName); + + if (endpoint == null) { + endpoint = VersionEndpointFixedPath; + } + + RuntimeKernel kernel = RuntimeKernel.getKernel(); + + try { + runtimeClient = kernel.getRuntimeVersionManager() + .getRuntimeClient(endpoint); + } catch (Throwable t) { + throw new RoleEnvironmentNotAvailableException(t); + } + + changingListeners = new LinkedList(); + changedListeners = new LinkedList(); + stoppingListeners = new LinkedList(); + + try { + currentGoalState = new AtomicReference( + runtimeClient.getCurrentGoalState()); + currentEnvironmentData = new AtomicReference( + runtimeClient.getRoleEnvironmentData()); + } catch (InterruptedException e) { + throw new RoleEnvironmentNotAvailableException(e); + } + + lastState = new AtomicReference(); + + runtimeClient + .addGoalStateChangedListener(new GoalStateChangedListener() { + public void goalStateChanged(GoalState newGoalState) { + switch (newGoalState.getExpectedState()) { + case STARTED: + if (newGoalState.getIncarnation() + .compareTo( + currentGoalState.get() + .getIncarnation()) > 0) { + processGoalStateChange(newGoalState); + } + break; + case STOPPED: + raiseStoppingEvent(); + + CurrentState stoppedState = new AcquireCurrentState( + clientId, + newGoalState.getIncarnation(), + CurrentStatus.STOPPED, maxDateTime); + + runtimeClient.setCurrentState(stoppedState); + break; + } + } + }); + } else { + try { + currentGoalState.set(runtimeClient.getCurrentGoalState()); + currentEnvironmentData.set(runtimeClient + .getRoleEnvironmentData()); + } catch (InterruptedException e) { + throw new RoleEnvironmentNotAvailableException(e); + } + } + } + + private static void processGoalStateChange(GoalState newGoalState) { + List changes = new LinkedList(); + RoleEnvironmentChangingEvent changingEvent = new RoleEnvironmentChangingEvent( + changes); + CurrentState last = lastState.get(); + + calculateChanges(changes); + + if (changes.isEmpty()) { + acceptLatestIncarnation(newGoalState, last); + } else { + for (RoleEnvironmentChangingListener listener : changingListeners) { + try { + listener.roleEnvironmentChanging(changingEvent); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + if (changingEvent.isCancelled()) { + CurrentState recycleState = new AcquireCurrentState(clientId, + newGoalState.getIncarnation(), CurrentStatus.RECYCLE, + maxDateTime); + + runtimeClient.setCurrentState(recycleState); + + return; + } + + acceptLatestIncarnation(newGoalState, last); + + try { + currentEnvironmentData.set(runtimeClient + .getRoleEnvironmentData()); + } catch (InterruptedException e) { + throw new RoleEnvironmentNotAvailableException(e); + } + + for (RoleEnvironmentChangedListener listener : changedListeners) { + try { + listener.roleEnvironmentChanged(new RoleEnvironmentChangedEvent( + changes)); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + } + + private static void acceptLatestIncarnation(GoalState newGoalState, + CurrentState last) { + if (last != null && last instanceof AcquireCurrentState) { + AcquireCurrentState acquireState = (AcquireCurrentState) last; + + CurrentState acceptState = new AcquireCurrentState(clientId, + newGoalState.getIncarnation(), acquireState.getStatus(), + acquireState.getExpiration()); + + runtimeClient.setCurrentState(acceptState); + } + + currentGoalState.set(newGoalState); + } + + private static void calculateChanges(List changes) { + RoleEnvironmentData current = currentEnvironmentData.get(); + RoleEnvironmentData newData; + + try { + newData = runtimeClient.getRoleEnvironmentData(); + } catch (InterruptedException e) { + throw new RoleEnvironmentNotAvailableException(e); + } + + Map currentConfig = current.getConfigurationSettings(); + Map newConfig = newData.getConfigurationSettings(); + Map currentRoles = current.getRoles(); + Map newRoles = newData.getRoles(); + + for (String setting : currentConfig.keySet()) { + if (newConfig.containsKey(setting)) { + if (!newConfig.get(setting).equals(currentConfig.get(setting))) { + changes.add(new RoleEnvironmentConfigurationSettingChange( + setting)); + } + } else { + changes.add(new RoleEnvironmentConfigurationSettingChange( + setting)); + } + } + + for (String setting : newConfig.keySet()) { + if (!currentConfig.containsKey(setting)) { + changes.add(new RoleEnvironmentConfigurationSettingChange( + setting)); + } + } + + Set changedRoleSet = new HashSet(); + + for (String role : currentRoles.keySet()) { + if (newRoles.containsKey(role)) { + Role currentRole = currentRoles.get(role); + Role newRole = newRoles.get(role); + + for (String instance : currentRole.getInstances().keySet()) { + if (newRole.getInstances().containsKey(instance)) { + RoleInstance currentInstance = currentRole + .getInstances().get(instance); + RoleInstance newInstance = newRole.getInstances().get( + instance); + + if (currentInstance.getUpdateDomain() == newInstance + .getUpdateDomain() + && currentInstance.getFaultDomain() == newInstance + .getFaultDomain()) { + for (String endpoint : currentInstance + .getInstanceEndpoints().keySet()) { + if (newInstance.getInstanceEndpoints() + .containsKey(endpoint)) { + RoleInstanceEndpoint currentEndpoint = currentInstance + .getInstanceEndpoints().get( + endpoint); + RoleInstanceEndpoint newEndpoint = newInstance + .getInstanceEndpoints().get( + endpoint); + + if (!currentEndpoint.getProtocol().equals( + newEndpoint.getProtocol()) + || !currentEndpoint.getIpEndPoint() + .equals(newEndpoint + .getIpEndPoint())) { + changedRoleSet.add(role); + } + } else { + changedRoleSet.add(role); + } + } + } else { + changedRoleSet.add(role); + } + } else { + changedRoleSet.add(role); + } + } + } else { + changedRoleSet.add(role); + } + } + + for (String role : newRoles.keySet()) { + if (currentRoles.containsKey(role)) { + Role currentRole = currentRoles.get(role); + Role newRole = newRoles.get(role); + + for (String instance : newRole.getInstances().keySet()) { + if (currentRole.getInstances().containsKey(instance)) { + RoleInstance currentInstance = currentRole + .getInstances().get(instance); + RoleInstance newInstance = newRole.getInstances().get( + instance); + + if (currentInstance.getUpdateDomain() == newInstance + .getUpdateDomain() + && currentInstance.getFaultDomain() == newInstance + .getFaultDomain()) { + for (String endpoint : newInstance + .getInstanceEndpoints().keySet()) { + if (currentInstance.getInstanceEndpoints() + .containsKey(endpoint)) { + RoleInstanceEndpoint currentEndpoint = currentInstance + .getInstanceEndpoints().get( + endpoint); + RoleInstanceEndpoint newEndpoint = newInstance + .getInstanceEndpoints().get( + endpoint); + + if (!currentEndpoint.getProtocol().equals( + newEndpoint.getProtocol()) + || !currentEndpoint.getIpEndPoint() + .equals(newEndpoint + .getIpEndPoint())) { + changedRoleSet.add(role); + } + } else { + changedRoleSet.add(role); + } + } + } else { + changedRoleSet.add(role); + } + } else { + changedRoleSet.add(role); + } + } + } else { + changedRoleSet.add(role); + } + } + + for (String role : changedRoleSet) { + changes.add(new RoleEnvironmentTopologyChange(role)); + } + } + + private static synchronized void raiseStoppingEvent() { + for (RoleEnvironmentStoppingListener listener : stoppingListeners) { + try { + listener.roleEnvironmentStopping(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + } + + /** + * Returns a {@link RoleInstance} object that represents the role instance + * in which this code is currently executing. + * + * @return A RoleInstance object that represents the role + * instance in which this code is currently executing. + */ + public static RoleInstance getCurrentRoleInstance() { + initialize(); + + return currentEnvironmentData.get().getCurrentInstance(); + } + + /** + * Returns the deployment ID that uniquely identifies the deployment in + * which this role instance is running. + * + * @return A String object that represents the deployment ID. + */ + public static String getDeploymentId() { + initialize(); + + return currentEnvironmentData.get().getDeploymentId(); + } + + /** + * Indicates whether the role instance is running in the Windows Azure + * environment. + * + * @return true if this instance is running in the development + * fabric or in the Windows Azure environment in the cloud; + * otherwise, false. + */ + public static boolean isAvailable() { + try { + initialize(); + } catch (RoleEnvironmentNotAvailableException ex) { + } + + return runtimeClient != null; + } + + /** + * Indicates whether the role instance is running in the development fabric. + * + * @return true if this instance is running in the development + * fabric; otherwise, false. + */ + public static boolean isEmulated() { + initialize(); + + return currentEnvironmentData.get().isEmulated(); + } + + /** + * Returns the set of {@link Role} objects defined for your service. + *

+ * Roles are defined in the service definition file. + * + * @return A java.util.Map object containing the set of + * {@link Role} objects that represent the roles defined for your + * service. + */ + public static Map getRoles() { + initialize(); + + return currentEnvironmentData.get().getRoles(); + } + + /** + * Retrieves the settings in the service configuration file. + *

+ * A role's configuration settings are defined in the service definition + * file. Values for configuration settings are set in the service + * configuration file. + * + * @return A java.util.Map object containing the + * String objects that represent the configuration + * settings. + */ + public static Map getConfigurationSettings() { + initialize(); + + return currentEnvironmentData.get().getConfigurationSettings(); + } + + /** + * Retrieves the set of named local storage resources. + * + * @return A java.util.Map object containing the + * String objects that represent the local storage + * resources. + */ + public static Map getLocalResources() { + initialize(); + + return currentEnvironmentData.get().getLocalResources(); + } + + /** + * Requests that the current role instance be stopped and restarted. + *

+ * Before the role instance is recycled, the Windows Azure load balancer + * takes the role instance out of rotation. This ensures that no new + * requests are routed to the instance while it is restarting. + * + * A call to RequestRecycle initiates the normal shutdown + * cycle. Windows Azure raises the Stopping event and calls the + * OnStop method so that you can run the necessary code to + * prepare the instance to be recycled. + */ + public static void requestRecycle() { + initialize(); + + CurrentState recycleState = new AcquireCurrentState(clientId, + currentGoalState.get().getIncarnation(), CurrentStatus.RECYCLE, + maxDateTime); + + runtimeClient.setCurrentState(recycleState); + } + + /** + * Sets the status of the role instance. + *

+ * An instance may indicate that it is in one of two states: Ready or Busy. + * If an instance's state is Ready, it is prepared to receive requests from + * the load balancer. If the instance's state is Busy, it will not receive + * requests from the load balancer. + * + * @param status + * A {@link RoleInstanceStatus} value that indicates whether the + * instance is ready or busy. + * @param expiration + * A java.util.Calendar value that specifies the + * expiration date and time of the status. + * + */ + public static void setStatus(RoleInstanceStatus status, Calendar expiration) { + initialize(); + + CurrentStatus currentStatus = CurrentStatus.STARTED; + + switch (status) { + case Busy: + currentStatus = CurrentStatus.BUSY; + break; + case Ready: + currentStatus = CurrentStatus.STARTED; + } + + CurrentState newState = new AcquireCurrentState(clientId, + currentGoalState.get().getIncarnation(), currentStatus, + expiration); + + lastState.set(newState); + + runtimeClient.setCurrentState(newState); + } + + /** + * Clears the status of the role instance. + *

+ * An instance may indicate that it has completed communicating status by + * calling this method. + * + */ + public static void clearStatus() { + initialize(); + + CurrentState newState = new ReleaseCurrentState(clientId); + + lastState.set(newState); + + runtimeClient.setCurrentState(newState); + } + + /** + * Adds an event listener for the Changed event, which occurs + * after a configuration change has been applied to a role instance. + *

+ * A Changed event is encapsulated in a + * {@link RoleEnvironmentChangedEvent} object. + * + * @param listener + * A {@link RoleEnvironmentChangedListener} object that + * represents the event listener to add. + * + * @see #removeRoleEnvironmentChangedListener + */ + public static synchronized void addRoleEnvironmentChangedListener( + RoleEnvironmentChangedListener listener) { + initialize(); + + changedListeners.add(listener); + } + + /** + * Removes an event listener for the Changed event. + * + * @param listener + * A {@link RoleEnvironmentChangedListener} object that + * represents the event listener to remove. + * + * @see #addRoleEnvironmentChangedListener + */ + public static synchronized void removeRoleEnvironmentChangedListener( + RoleEnvironmentChangedListener listener) { + initialize(); + + changedListeners.remove(listener); + } + + /** + * Adds an event listener for the Changing event, which occurs + * before a change to the service configuration is applied to the running + * instances of the role. + *

+ * Service configuration changes are applied on-the-fly to running role + * instances. Configuration changes include changes to the service + * configuration changes and changes to the number of instances in the + * service. + *

+ * This event occurs after the new configuration file has been submitted to + * Windows Azure but before the changes have been applied to each running + * role instance. This event can be cancelled for a given instance to + * prevent the configuration change. + *

+ * Note that cancelling this event causes the instance to be automatically + * recycled. When the instance is recycled, the configuration change is + * applied when it restarts. + *

+ * A Changing event is encapsulated in a + * {@link RoleEnvironmentChangingEvent} object. + * + * @param listener + * A {@link RoleEnvironmentChangingListener} object that + * represents the event listener to add. + * + * @see #removeRoleEnvironmentChangingListener + */ + public static synchronized void addRoleEnvironmentChangingListener( + RoleEnvironmentChangingListener listener) { + initialize(); + + changingListeners.add(listener); + } + + /** + * Removes an event listener for the Changing event. + * + * @param listener + * A {@link RoleEnvironmentChangingListener} object that + * represents the event listener to remove. + * + * @see #addRoleEnvironmentChangingListener + */ + public static void removeRoleEnvironmentChangingListener( + RoleEnvironmentChangingListener listener) { + initialize(); + + changingListeners.remove(listener); + } + + /** + * Adds an event listener for the Stopping event, which occurs + * wheen the role is stopping. + * + * @param listener + * A {@link RoleEnvironmentStoppingListener} object that + * represents the event listener to add. + * + * @see #removeRoleEnvironmentStoppingListener + */ + public static synchronized void addRoleEnvironmentStoppingListener( + RoleEnvironmentStoppingListener listener) { + initialize(); + + stoppingListeners.add(listener); + } + + /** + * Removes an event listener for the Stopping event. + * + * @param listener + * A {@link RoleEnvironmentStoppingListener} object that + * represents the event listener to remove. + * + * @see #addRoleEnvironmentStoppingListener + */ + public static synchronized void removeRoleEnvironmentStoppingListener( + RoleEnvironmentStoppingListener listener) { + initialize(); + + stoppingListeners.remove(listener); + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java new file mode 100644 index 0000000000000..471be6da8a914 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Abstract class that represents a change to the service's configuration. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public abstract class RoleEnvironmentChange { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java new file mode 100644 index 0000000000000..34869c8e614ff --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java @@ -0,0 +1,41 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Collection; + +/** + * Occurs after a change to the service configuration has been applied to the + * running instances of the role. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public class RoleEnvironmentChangedEvent { + + private Collection changes; + + /** + * Constructor. Can only be called by the deserialization logic + * + * @param changes + */ + RoleEnvironmentChangedEvent(Collection changes) { + this.changes = changes; + } + + /** + * Returns a collection of the configuration changes that were applied to + * the role instance. + * + * @return A java.util.Collection object containing the + * {@link RoleEnvironmentChange} objects that represent the + * configuration changes that were applied to the role instance. + * + * @see RoleEnvironmentChange + */ + public Collection getChanges() { + return changes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java new file mode 100644 index 0000000000000..01d1ad226971a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java @@ -0,0 +1,28 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents the listener for the environment changed event. + *

+ * The environment changed event is encapsulated in a + * {@link RoleEnvironmentChangedEvent} object. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public interface RoleEnvironmentChangedListener { + + /** + * Occurs after a change to the service configuration has been applied to + * the running instances of the role. + * + * @param event + * A {@link RoleEnvironmentChangedEvent} object that represents + * the environment changed event. + * + * @see RoleEnvironmentChangingListener#roleEnvironmentChanging + */ + public void roleEnvironmentChanged(RoleEnvironmentChangedEvent event); + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java new file mode 100644 index 0000000000000..4a733eb28b5a0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java @@ -0,0 +1,69 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Collection; + +/** + * + * Occurs before a change to the service configuration is applied to the running + * instances of the role. + *

+ * Service configuration changes are applied on-the-fly to running role + * instances. Configuration changes include changes to the service configuration + * changes and changes to the number of instances in the service. + *

+ * This event occurs after the new configuration file has been submitted to + * Windows Azure but before the changes have been applied to each running role + * instance. This event can be cancelled for a given instance to prevent the + * configuration change. + *

+ * Note that cancelling this event causes the instance to be automatically + * recycled. When the instance is recycled, the configuration change is applied + * when it restarts. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + * @see RoleEnvironmentChangingListener + * @see RoleEnvironmentChangedEvent + */ +public class RoleEnvironmentChangingEvent { + private final Collection changes; + private boolean cancelled; + + RoleEnvironmentChangingEvent(Collection changes) { + this.changes = changes; + + cancelled = false; + } + + /** + * Cancel the configuration change. + *

+ * Cancellation causes the role instance to be immediately recycled. The + * configuration changes are applied when the instance restarts. + * + */ + public void cancel() { + cancelled = true; + } + + boolean isCancelled() { + return cancelled; + } + + /** + * Returns a collection of the configuration changes that are about to be + * applied to the role instance. + * + * @return A java.util.Collection object containing + * {@link RoleEnvironmentChange} objects that represent the + * configuration changes that are about to be applied to the role + * instance. + * + * @see RoleEnvironmentChange + */ + public Collection getChanges() { + return changes; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java new file mode 100644 index 0000000000000..9d541fdbc54d0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java @@ -0,0 +1,42 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents the listener for the environment changing event. + *

+ * The environment changing event is encapsulated in an + * {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangingEvent} object. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public interface RoleEnvironmentChangingListener { + + /** + * Occurs before a change to the service configuration is applied to the + * running instances of the role. + *

+ * Service configuration changes are applied on-the-fly to running role + * instances. Configuration changes include changes to the service + * configuration changes and changes to the number of instances in the + * service. + *

+ * This event occurs after the new configuration file has been submitted to + * Windows Azure but before the changes have been applied to each running + * role instance. This event can be cancelled for a given instance to + * prevent the configuration change. + *

+ * Note that cancelling this event causes the instance to be automatically + * recycled. When the instance is recycled, the configuration change is + * applied when it restarts. + * + * @param event + * A {@link RoleEnvironmentChangingEvent} object that represents + * the environment changing event. + * + * @see RoleEnvironmentChangedListener#roleEnvironmentChanged + */ + public void roleEnvironmentChanging(RoleEnvironmentChangingEvent event); + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java new file mode 100644 index 0000000000000..04a9db5084bd0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java @@ -0,0 +1,31 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents a change to a configuration setting. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + * @see RoleEnvironmentTopologyChange + */ +public class RoleEnvironmentConfigurationSettingChange extends + RoleEnvironmentChange { + + private String settingName; + + RoleEnvironmentConfigurationSettingChange(String settingName) { + this.settingName = settingName; + } + + /** + * Returns the name of the configuration setting that has been changed. + * + * @return A String object that represents the name of the + * configuration setting that has been changed. + */ + public String getConfigurationSettingName() { + return settingName; + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java new file mode 100644 index 0000000000000..3254c634f311b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java @@ -0,0 +1,55 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Map; + +/** + * + */ +class RoleEnvironmentData { + private final String deploymentId; + private final Map configurationSettings; + private final Map localResources; + private final RoleInstance currentInstance; + private final Map roles; + private final boolean isEmulated; + + public RoleEnvironmentData(String deploymentId, + Map configurationSettings, + Map localResources, + RoleInstance currentInstance, Map roles, + boolean isEmulated) { + this.deploymentId = deploymentId; + this.configurationSettings = configurationSettings; + this.localResources = localResources; + this.currentInstance = currentInstance; + this.roles = roles; + this.isEmulated = isEmulated; + } + + public Map getConfigurationSettings() { + return configurationSettings; + } + + public Map getLocalResources() { + return localResources; + } + + public RoleInstance getCurrentInstance() { + return currentInstance; + } + + public Map getRoles() { + return roles; + } + + public String getDeploymentId() { + return deploymentId; + } + + public boolean isEmulated() { + return isEmulated; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java new file mode 100644 index 0000000000000..8a16a9e7b8e60 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java @@ -0,0 +1,13 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; + +/** + * + */ +interface RoleEnvironmentDataDeserializer { + public RoleEnvironmentData deserialize(InputStream stream); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java new file mode 100644 index 0000000000000..0cbd9fe328b89 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java @@ -0,0 +1,123 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RoleEnvironmentInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RoleEnvironmentInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="Deployment" type="{}DeploymentInfo"/>
+ *         <element name="CurrentInstance" type="{}CurrentRoleInstanceInfo"/>
+ *         <element name="Roles" type="{}RolesInfo" minOccurs="0"/>
+ *       </all>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RoleEnvironmentInfo", propOrder = { + +}) +class RoleEnvironmentInfo { + + @XmlElement(name = "Deployment", required = true) + protected DeploymentInfo deployment; + @XmlElement(name = "CurrentInstance", required = true) + protected CurrentRoleInstanceInfo currentInstance; + @XmlElement(name = "Roles") + protected RolesInfo roles; + + /** + * Gets the value of the deployment property. + * + * @return + * possible object is + * {@link DeploymentInfo } + * + */ + public DeploymentInfo getDeployment() { + return deployment; + } + + /** + * Sets the value of the deployment property. + * + * @param value + * allowed object is + * {@link DeploymentInfo } + * + */ + public void setDeployment(DeploymentInfo value) { + this.deployment = value; + } + + /** + * Gets the value of the currentInstance property. + * + * @return + * possible object is + * {@link CurrentRoleInstanceInfo } + * + */ + public CurrentRoleInstanceInfo getCurrentInstance() { + return currentInstance; + } + + /** + * Sets the value of the currentInstance property. + * + * @param value + * allowed object is + * {@link CurrentRoleInstanceInfo } + * + */ + public void setCurrentInstance(CurrentRoleInstanceInfo value) { + this.currentInstance = value; + } + + /** + * Gets the value of the roles property. + * + * @return + * possible object is + * {@link RolesInfo } + * + */ + public RolesInfo getRoles() { + return roles; + } + + /** + * Sets the value of the roles property. + * + * @param value + * allowed object is + * {@link RolesInfo } + * + */ + public void setRoles(RolesInfo value) { + this.roles = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java new file mode 100644 index 0000000000000..be5b7b73c6fa0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java @@ -0,0 +1,31 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents an exception indicating the role environment is not available. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * + * + */ +public class RoleEnvironmentNotAvailableException extends RuntimeException { + + private static final long serialVersionUID = -6218741025124056882L; + + /** + * Creates an instance of the + * RoleEnvironmentNotAvailableException class. + * + * @param t + * A java.lang.Throwable object that represents the + * cause for the exception. + * + */ + + public RoleEnvironmentNotAvailableException(Throwable t) { + initCause(t); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java new file mode 100644 index 0000000000000..7257e736c94c0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java @@ -0,0 +1,22 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents the listener for the stopping event. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + */ +public interface RoleEnvironmentStoppingListener { + /** + * Occurs when the role instance is about to be stopped. + *

+ * This event is raised after the instance has been taken out of the load + * balancer's rotation before the OnStop method is called. You + * can use this event to run code that is required for the role instance + * to shut down in an orderly fashion. + */ + + public void roleEnvironmentStopping(); + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java new file mode 100644 index 0000000000000..00d9ff569bbd0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java @@ -0,0 +1,31 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Represents a change to the topology of the service. + *

+ * The service's topology refers to the number of instances deployed for each + * role that the service defines. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + */ +public class RoleEnvironmentTopologyChange extends RoleEnvironmentChange { + + private String roleName; + + RoleEnvironmentTopologyChange(String roleName) { + this.roleName = roleName; + } + + /** + * Returns the name of the affected role. + * + * @return A String object that represents the name of the + * affected role. + */ + public String getRoleName() { + return roleName; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java new file mode 100644 index 0000000000000..5b77b6b7d7473 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java @@ -0,0 +1,97 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RoleInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RoleInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="Instances" type="{}RoleInstancesInfo"/>
+ *       </all>
+ *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RoleInfo", propOrder = { + +}) +class RoleInfo { + + @XmlElement(name = "Instances", required = true) + protected RoleInstancesInfo instances; + @XmlAttribute(required = true) + protected String name; + + /** + * Gets the value of the instances property. + * + * @return + * possible object is + * {@link RoleInstancesInfo } + * + */ + public RoleInstancesInfo getInstances() { + return instances; + } + + /** + * Sets the value of the instances property. + * + * @param value + * allowed object is + * {@link RoleInstancesInfo } + * + */ + public void setInstances(RoleInstancesInfo value) { + this.instances = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java new file mode 100644 index 0000000000000..ac18e2fcce421 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java @@ -0,0 +1,94 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.Map; + +/** + * Represents an instance of a role. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public final class RoleInstance { + private final String id; + private final int faultDomain; + private final int updateDomain; + private final Map endpoints; + private Role role; + + /** + * Constructor + * + * @param id + * @param faultDomain + * @param updateDomain + * @param endpoints + */ + RoleInstance(String id, int faultDomain, int updateDomain, + Map endpoints) { + this.id = id; + this.faultDomain = faultDomain; + this.updateDomain = updateDomain; + this.endpoints = endpoints; + } + + void setRole(Role role) { + this.role = role; + } + + /** + * Returns an integer value that indicates the fault domain in which this + * instance resides. + * + * @return The fault domain in which this instance resides. + */ + public int getFaultDomain() { + return faultDomain; + } + + /** + * Returns the ID of this instance. + *

+ * The returned ID is unique to the application domain of the role�s + * instance. If an instance is terminated and has been configured to restart + * automatically, the restarted instance will have the same ID as the + * terminated instance. + * + * @return A String object that represents the ID of this + * instance. + */ + public String getId() { + return id; + } + + /** + * Returns an integer value that indicates the update domain in which this + * instance resides. + * + * @return The update domain in which this instance resides. + */ + public int getUpdateDomain() { + return updateDomain; + } + + /** + * Returns the {@link Role} object associated with this instance. + * + * @return The Role object associated with this instance + */ + public Role getRole() { + return role; + } + + /** + * Returns the set of endpoints associated with this role instance. + * + * @return A Map object of {@link RoleInstanceEndpoint} objects + * that represent the set of endpoints associated with this + * role instance. + */ + public Map getInstanceEndpoints() { + return endpoints; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java new file mode 100644 index 0000000000000..42641d70f75ec --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java @@ -0,0 +1,76 @@ +package com.microsoft.windowsazure.serviceruntime; + +import java.net.InetSocketAddress; + +/** + * Represents an endpoint associated with a role instance. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public final class RoleInstanceEndpoint { + + /** + * Gets the RoleInstance object associated with this endpoint. + */ + private RoleInstance roleInstance; + + /** + * Gets the protocol associated with the endpoint + */ + private final String protocol; + + /** + * Represents a network endpoint as an IP address and a port number. + */ + private final InetSocketAddress ipEndPoint; + + /** + * Package accessible constructor + * + * @param protocol + * @param ipEndPoint + */ + RoleInstanceEndpoint(String protocol, InetSocketAddress ipEndPoint) { + this.protocol = protocol; + this.ipEndPoint = ipEndPoint; + } + + void setRoleInstance(RoleInstance roleInstance) { + this.roleInstance = roleInstance; + } + + /** + * Returns the {@link RoleInstance} object associated with this endpoint. + * + * @return A RoleInstance object that represents the role + * instance associated with this endpoint. + */ + public RoleInstance getRoleInstance() { + return roleInstance; + } + + /** + * Returns the protocol associated with the endpoint. + * + * @return A String object that represents the protocol + * associated with the endpoint. + */ + public String getProtocol() { + return protocol; + } + + /** + * Returns an InetSocketAddress object for this role instance + * endpoint. The InetSocketAddress object provides the IP + * address and port number for the endpoint. + * + * @return A java.net.InetSocketAddress object that contains + * the IP address and port number for the endpoint. + */ + public InetSocketAddress getIpEndPoint() { + return ipEndPoint; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java new file mode 100644 index 0000000000000..d259a68e4b34b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java @@ -0,0 +1,135 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RoleInstanceInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RoleInstanceInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="Endpoints" type="{}EndpointsInfo"/>
+ *       </all>
+ *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="faultDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="updateDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RoleInstanceInfo", propOrder = { + +}) +class RoleInstanceInfo { + + @XmlElement(name = "Endpoints", required = true) + protected EndpointsInfo endpoints; + @XmlAttribute(required = true) + protected String id; + @XmlAttribute(required = true) + protected int faultDomain; + @XmlAttribute(required = true) + protected int updateDomain; + + /** + * Gets the value of the endpoints property. + * + * @return + * possible object is + * {@link EndpointsInfo } + * + */ + public EndpointsInfo getEndpoints() { + return endpoints; + } + + /** + * Sets the value of the endpoints property. + * + * @param value + * allowed object is + * {@link EndpointsInfo } + * + */ + public void setEndpoints(EndpointsInfo value) { + this.endpoints = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the faultDomain property. + * + */ + public int getFaultDomain() { + return faultDomain; + } + + /** + * Sets the value of the faultDomain property. + * + */ + public void setFaultDomain(int value) { + this.faultDomain = value; + } + + /** + * Gets the value of the updateDomain property. + * + */ + public int getUpdateDomain() { + return updateDomain; + } + + /** + * Sets the value of the updateDomain property. + * + */ + public void setUpdateDomain(int value) { + this.updateDomain = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java new file mode 100644 index 0000000000000..b7b7be7492a1f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java @@ -0,0 +1,23 @@ +package com.microsoft.windowsazure.serviceruntime; + +/** + * Defines role instance status values, such as Busy and Ready. + *

+ * The {@link RoleEnvironment#setStatus} method + * uses a value from this enumeration. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + * @author mariok + * + */ +public enum RoleInstanceStatus { + /** + * The role instance is unavailable for requests. + */ + Busy, + /** + * The role instance is ready to accept requests. + */ + Ready +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java new file mode 100644 index 0000000000000..316ac5938d03b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RoleInstancesInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RoleInstancesInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Instance" type="{}RoleInstanceInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RoleInstancesInfo", propOrder = { + "instance" +}) +class RoleInstancesInfo { + + @XmlElement(name = "Instance") + protected List instance; + + /** + * Gets the value of the instance property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the instance property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getInstance().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link RoleInstanceInfo } + * + * + */ + public List getInstance() { + if (instance == null) { + instance = new ArrayList(); + } + return this.instance; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java new file mode 100644 index 0000000000000..20adb3c45bcfe --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RolesInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RolesInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Role" type="{}RoleInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RolesInfo", propOrder = { + "role" +}) +class RolesInfo { + + @XmlElement(name = "Role") + protected List role; + + /** + * Gets the value of the role property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the role property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getRole().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link RoleInfo } + * + * + */ + public List getRole() { + if (role == null) { + role = new ArrayList(); + } + return this.role; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java new file mode 100644 index 0000000000000..4822fca33f7c6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java @@ -0,0 +1,12 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +interface RuntimeClient extends RuntimeGoalStateClient, + RuntimeCurrentStateClient { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java new file mode 100644 index 0000000000000..fec652da83fde --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java @@ -0,0 +1,13 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +interface RuntimeClientFactory { + public String getVersion(); + + public RuntimeClient createRuntimeClient(String path); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java new file mode 100644 index 0000000000000..a79e145fce053 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java @@ -0,0 +1,11 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +interface RuntimeCurrentStateClient { + public void setCurrentState(CurrentState state); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java new file mode 100644 index 0000000000000..22ec8ab676e18 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java @@ -0,0 +1,18 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +interface RuntimeGoalStateClient { + public GoalState getCurrentGoalState() throws InterruptedException; + + public RoleEnvironmentData getRoleEnvironmentData() + throws InterruptedException; + + public void addGoalStateChangedListener(GoalStateChangedListener listener); + + public void removeGoalStateChangedListener(GoalStateChangedListener listener); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java new file mode 100644 index 0000000000000..bb54a99ba5301 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java @@ -0,0 +1,82 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +/** + * + */ +class RuntimeKernel { + private static RuntimeKernel theKernel; + + private final CurrentStateSerializer currentStateSerializer; + private final GoalStateDeserializer goalStateDeserializer; + private final InputChannel inputChannel; + private final OutputChannel outputChannel; + private final Protocol1RuntimeCurrentStateClient protocol1RuntimeCurrentStateClient; + private final RoleEnvironmentDataDeserializer roleEnvironmentDataDeserializer; + private final Protocol1RuntimeGoalStateClient protocol1RuntimeGoalStateClient; + private final RuntimeVersionProtocolClient runtimeVersionProtocolClient; + private final RuntimeVersionManager runtimeVersionManager; + + private RuntimeKernel() { + this.currentStateSerializer = new XmlCurrentStateSerializer(); + this.goalStateDeserializer = new ChunkedGoalStateDeserializer(); + this.inputChannel = new FileInputChannel(); + this.outputChannel = new FileOutputChannel(); + this.protocol1RuntimeCurrentStateClient = new Protocol1RuntimeCurrentStateClient( + currentStateSerializer, outputChannel); + this.roleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); + this.protocol1RuntimeGoalStateClient = new Protocol1RuntimeGoalStateClient( + protocol1RuntimeCurrentStateClient, goalStateDeserializer, + roleEnvironmentDataDeserializer, inputChannel); + this.runtimeVersionProtocolClient = new RuntimeVersionProtocolClient( + inputChannel); + this.runtimeVersionManager = new RuntimeVersionManager( + runtimeVersionProtocolClient); + } + + public static RuntimeKernel getKernel() { + if (theKernel == null) { + theKernel = new RuntimeKernel(); + } + + return theKernel; + } + + public CurrentStateSerializer getCurrentStateSerializer() { + return currentStateSerializer; + } + + public GoalStateDeserializer getGoalStateDeserializer() { + return goalStateDeserializer; + } + + public InputChannel getInputChannel() { + return inputChannel; + } + + public OutputChannel getOutputChannel() { + return outputChannel; + } + + public Protocol1RuntimeCurrentStateClient getProtocol1RuntimeCurrentStateClient() { + return protocol1RuntimeCurrentStateClient; + } + + public RoleEnvironmentDataDeserializer getRoleEnvironmentDataDeserializer() { + return roleEnvironmentDataDeserializer; + } + + public Protocol1RuntimeGoalStateClient getProtocol1RuntimeGoalStateClient() { + return protocol1RuntimeGoalStateClient; + } + + public RuntimeVersionProtocolClient getRuntimeVersionProtocolClient() { + return runtimeVersionProtocolClient; + } + + public RuntimeVersionManager getRuntimeVersionManager() { + return runtimeVersionManager; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java new file mode 100644 index 0000000000000..d0297c64f02a8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java @@ -0,0 +1,69 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RuntimeServerDiscoveryInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RuntimeServerDiscoveryInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <all>
+ *         <element name="RuntimeServerEndpoints" type="{}RuntimeServerEndpointsInfo"/>
+ *       </all>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RuntimeServerDiscoveryInfo", propOrder = { + +}) +class RuntimeServerDiscoveryInfo { + + @XmlElement(name = "RuntimeServerEndpoints", required = true) + protected RuntimeServerEndpointsInfo runtimeServerEndpoints; + + /** + * Gets the value of the runtimeServerEndpoints property. + * + * @return + * possible object is + * {@link RuntimeServerEndpointsInfo } + * + */ + public RuntimeServerEndpointsInfo getRuntimeServerEndpoints() { + return runtimeServerEndpoints; + } + + /** + * Sets the value of the runtimeServerEndpoints property. + * + * @param value + * allowed object is + * {@link RuntimeServerEndpointsInfo } + * + */ + public void setRuntimeServerEndpoints(RuntimeServerEndpointsInfo value) { + this.runtimeServerEndpoints = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java new file mode 100644 index 0000000000000..b6e6b3b87ca6b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java @@ -0,0 +1,92 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RuntimeServerEndpointInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RuntimeServerEndpointInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="path" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RuntimeServerEndpointInfo") +class RuntimeServerEndpointInfo { + + @XmlAttribute(required = true) + protected String version; + @XmlAttribute(required = true) + protected String path; + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + + /** + * Gets the value of the path property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPath() { + return path; + } + + /** + * Sets the value of the path property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPath(String value) { + this.path = value; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java new file mode 100644 index 0000000000000..9942e972becb1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for RuntimeServerEndpointsInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="RuntimeServerEndpointsInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="RuntimeServerEndpoint" type="{}RuntimeServerEndpointInfo" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "RuntimeServerEndpointsInfo", propOrder = { + "runtimeServerEndpoint" +}) +class RuntimeServerEndpointsInfo { + + @XmlElement(name = "RuntimeServerEndpoint") + protected List runtimeServerEndpoint; + + /** + * Gets the value of the runtimeServerEndpoint property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the runtimeServerEndpoint property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getRuntimeServerEndpoint().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link RuntimeServerEndpointInfo } + * + * + */ + public List getRuntimeServerEndpoint() { + if (runtimeServerEndpoint == null) { + runtimeServerEndpoint = new ArrayList(); + } + return this.runtimeServerEndpoint; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java new file mode 100644 index 0000000000000..1f1dea5c523f1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java @@ -0,0 +1,51 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * + */ +class RuntimeVersionManager { + private final RuntimeVersionProtocolClient protocolClient; + private final List supportedVersionList; + + RuntimeVersionManager(RuntimeVersionProtocolClient protocolClient) { + this.protocolClient = protocolClient; + + this.supportedVersionList = new ArrayList(1); + + this.supportedVersionList.add(new RuntimeClientFactory() { + public String getVersion() { + return "2011-03-08"; + } + + public RuntimeClient createRuntimeClient(String path) { + RuntimeKernel kernel = RuntimeKernel.getKernel(); + + return new Protocol1RuntimeClient(kernel + .getProtocol1RuntimeGoalStateClient(), kernel + .getProtocol1RuntimeCurrentStateClient(), path); + } + }); + } + + public RuntimeClient getRuntimeClient(String versionEndpoint) { + Map versionMap = protocolClient + .getVersionMap(versionEndpoint); + + for (RuntimeClientFactory factory : supportedVersionList) { + if (versionMap.containsKey(factory.getVersion())) { + return factory.createRuntimeClient(versionMap.get(factory + .getVersion())); + } + } + + throw new RuntimeException( + "Server does not support any known protocol versions."); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java new file mode 100644 index 0000000000000..41802c95ddb6d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java @@ -0,0 +1,48 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +/** + * + */ +class RuntimeVersionProtocolClient { + private final InputChannel inputChannel; + + public RuntimeVersionProtocolClient(InputChannel inputChannel) { + this.inputChannel = inputChannel; + } + + public Map getVersionMap(String connectionPath) { + try { + Map versions = new HashMap(); + JAXBContext context = JAXBContext + .newInstance(RuntimeServerDiscoveryInfo.class.getPackage() + .getName()); + Unmarshaller unmarshaller = context.createUnmarshaller(); + InputStream input = inputChannel.getInputStream(connectionPath); + + @SuppressWarnings("unchecked") + RuntimeServerDiscoveryInfo discoveryInfo = ((JAXBElement) unmarshaller + .unmarshal(input)).getValue(); + + for (RuntimeServerEndpointInfo endpointInfo : discoveryInfo + .getRuntimeServerEndpoints().getRuntimeServerEndpoint()) { + versions.put(endpointInfo.getVersion(), endpointInfo.getPath()); + } + + return versions; + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java new file mode 100644 index 0000000000000..e5aee0292d421 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java @@ -0,0 +1,156 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.11.14 at 04:34:45 PM PST +// + + +package com.microsoft.windowsazure.serviceruntime; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for StatusLeaseInfo complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="StatusLeaseInfo">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice>
+ *         <element name="Acquire" type="{}AcquireLeaseInfo"/>
+ *         <element name="Release">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </choice>
+ *       <attribute name="ClientId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "StatusLeaseInfo", propOrder = { + "acquire", + "release" +}) +class StatusLeaseInfo { + + @XmlElement(name = "Acquire") + protected AcquireLeaseInfo acquire; + @XmlElement(name = "Release") + protected StatusLeaseInfo.Release release; + @XmlAttribute(name = "ClientId", required = true) + protected String clientId; + + /** + * Gets the value of the acquire property. + * + * @return + * possible object is + * {@link AcquireLeaseInfo } + * + */ + public AcquireLeaseInfo getAcquire() { + return acquire; + } + + /** + * Sets the value of the acquire property. + * + * @param value + * allowed object is + * {@link AcquireLeaseInfo } + * + */ + public void setAcquire(AcquireLeaseInfo value) { + this.acquire = value; + } + + /** + * Gets the value of the release property. + * + * @return + * possible object is + * {@link StatusLeaseInfo.Release } + * + */ + public StatusLeaseInfo.Release getRelease() { + return release; + } + + /** + * Sets the value of the release property. + * + * @param value + * allowed object is + * {@link StatusLeaseInfo.Release } + * + */ + public void setRelease(StatusLeaseInfo.Release value) { + this.release = value; + } + + /** + * Gets the value of the clientId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getClientId() { + return clientId; + } + + /** + * Sets the value of the clientId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setClientId(String value) { + this.clientId = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class Release { + + + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java new file mode 100644 index 0000000000000..0aa9a74754584 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java @@ -0,0 +1,65 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.OutputStream; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +/** + * + */ +class XmlCurrentStateSerializer implements CurrentStateSerializer { + public XmlCurrentStateSerializer() { + } + + public void serialize(CurrentState state, OutputStream stream) { + try { + JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class + .getPackage().getName()); + Marshaller marshaller = context.createMarshaller(); + + ObjectFactory factory = new ObjectFactory(); + CurrentStateInfo info = factory.createCurrentStateInfo(); + StatusLeaseInfo leaseInfo = factory.createStatusLeaseInfo(); + + leaseInfo.setClientId(state.getClientId()); + + if (state instanceof AcquireCurrentState) { + AcquireCurrentState acquireState = (AcquireCurrentState) state; + AcquireLeaseInfo acquire = factory.createAcquireLeaseInfo(); + + acquire.setExpiration(acquireState.getExpiration()); + acquire.setIncarnation(acquireState.getIncarnation()); + + switch (acquireState.getStatus()) { + case BUSY: + acquire.setStatus(CurrentStatusEnum.BUSY); + break; + case RECYCLE: + acquire.setStatus(CurrentStatusEnum.RECYCLE); + break; + case STARTED: + acquire.setStatus(CurrentStatusEnum.STARTED); + break; + case STOPPED: + acquire.setStatus(CurrentStatusEnum.STOPPED); + break; + } + + leaseInfo.setAcquire(acquire); + } else if (state instanceof ReleaseCurrentState) { + leaseInfo.setRelease(factory.createStatusLeaseInfoRelease()); + } + + info.setStatusLease(leaseInfo); + + marshaller.marshal(factory.createCurrentState(info), stream); + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java new file mode 100644 index 0000000000000..e5a3f4608513b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -0,0 +1,44 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.StringReader; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.xml.sax.InputSource; + +/** + * + */ +class XmlGoalStateDeserializer { + public XmlGoalStateDeserializer() { + } + + public GoalState deserialize(String document) { + try { + JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class + .getPackage().getName()); + Unmarshaller unmarshaller = context.createUnmarshaller(); + InputSource source = new InputSource(new StringReader(document)); + + @SuppressWarnings("unchecked") + GoalStateInfo goalStateInfo = ((JAXBElement) unmarshaller + .unmarshal(source)).getValue(); + + return new GoalState(goalStateInfo.incarnation, + Enum.valueOf(ExpectedState.class, + goalStateInfo.expectedState.toString()), + goalStateInfo.getRoleEnvironmentPath(), + goalStateInfo.getDeadline(), + goalStateInfo.getCurrentStateEndpoint()); + + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java new file mode 100644 index 0000000000000..d94952913fbb3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java @@ -0,0 +1,172 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.InputStream; +import java.net.InetSocketAddress; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +/** + * + */ +class XmlRoleEnvironmentDataDeserializer implements + RoleEnvironmentDataDeserializer { + public XmlRoleEnvironmentDataDeserializer() { + } + + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + try { + JAXBContext context = JAXBContext + .newInstance(RoleEnvironmentInfo.class.getPackage() + .getName()); + Unmarshaller unmarshaller = context.createUnmarshaller(); + + @SuppressWarnings("unchecked") + RoleEnvironmentInfo environmentInfo = ((JAXBElement) unmarshaller + .unmarshal(stream)).getValue(); + + Map configurationSettings = translateConfigurationSettings(environmentInfo); + Map localResources = translateLocalResources(environmentInfo); + RoleInstance currentInstance = translateCurrentInstance(environmentInfo); + Map roles = translateRoles(environmentInfo, + currentInstance, environmentInfo.getCurrentInstance() + .getRoleName()); + + return new RoleEnvironmentData(environmentInfo.getDeployment() + .getId(), configurationSettings, localResources, + currentInstance, roles, environmentInfo.getDeployment() + .isEmulated()); + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } + + private Map translateConfigurationSettings( + RoleEnvironmentInfo environmentInfo) { + Map configurationSettings = new HashMap(); + + for (ConfigurationSettingInfo settingInfo : environmentInfo + .getCurrentInstance().getConfigurationSettings() + .getConfigurationSetting()) { + configurationSettings.put(settingInfo.getName(), + settingInfo.getValue()); + } + + return configurationSettings; + } + + private Map translateLocalResources( + RoleEnvironmentInfo environmentInfo) { + Map localResources = new HashMap(); + + for (LocalResourceInfo resourceInfo : environmentInfo + .getCurrentInstance().getLocalResources().getLocalResource()) { + localResources.put(resourceInfo.getName(), new LocalResource( + resourceInfo.getSizeInMB(), resourceInfo.getName(), + resourceInfo.getPath())); + } + + return localResources; + } + + private Map translateRoles( + RoleEnvironmentInfo environmentInfo, RoleInstance currentInstance, + String currentRole) { + Map roles = new HashMap(); + + for (RoleInfo roleInfo : environmentInfo.getRoles().getRole()) { + Map instances = translateRoleInstances(roleInfo + .getInstances()); + + if (roleInfo.getName() == currentRole) { + instances.put(currentInstance.getId(), currentInstance); + } + + Role role = new Role(roleInfo.getName(), instances); + + for (RoleInstance instance : role.getInstances().values()) { + instance.setRole(role); + } + + roles.put(roleInfo.getName(), role); + } + + if (!roles.containsKey(currentRole)) { + Map instances = new HashMap(); + + instances.put(currentInstance.getId(), currentInstance); + + Role singleRole = new Role(currentRole, instances); + + currentInstance.setRole(singleRole); + + roles.put(currentRole, singleRole); + } + + return roles; + } + + private Map translateRoleInstances( + RoleInstancesInfo instancesInfo) { + Map roleInstances = new HashMap(); + + for (RoleInstanceInfo instanceInfo : instancesInfo.getInstance()) { + RoleInstance instance = new RoleInstance(instanceInfo.getId(), + instanceInfo.getFaultDomain(), + instanceInfo.getUpdateDomain(), + translateRoleInstanceEndpoints(instanceInfo.getEndpoints())); + + for (RoleInstanceEndpoint endpoint : instance + .getInstanceEndpoints().values()) { + endpoint.setRoleInstance(instance); + } + + roleInstances.put(instance.getId(), instance); + } + + return roleInstances; + } + + private Map translateRoleInstanceEndpoints( + EndpointsInfo endpointsInfo) { + Map endpoints = new HashMap(); + + for (EndpointInfo endpointInfo : endpointsInfo.getEndpoint()) { + RoleInstanceEndpoint endpoint = new RoleInstanceEndpoint( + endpointInfo.getProtocol().toString(), + new InetSocketAddress(endpointInfo.getAddress(), + endpointInfo.getPort())); + + endpoints.put(endpointInfo.getName(), endpoint); + } + + return endpoints; + } + + private RoleInstance translateCurrentInstance( + RoleEnvironmentInfo environmentInfo) { + CurrentRoleInstanceInfo currentInstanceInfo = environmentInfo + .getCurrentInstance(); + RoleInstance currentInstance = new RoleInstance( + currentInstanceInfo.getId(), + currentInstanceInfo.getFaultDomain(), + currentInstanceInfo.getUpdateDomain(), + translateRoleInstanceEndpoints(environmentInfo + .getCurrentInstance().getEndpoints())); + + for (RoleInstanceEndpoint endpoint : currentInstance + .getInstanceEndpoints().values()) { + endpoint.setRoleInstance(currentInstance); + } + + return currentInstance; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html new file mode 100644 index 0000000000000..6a50090d2e25b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html @@ -0,0 +1,6 @@ + + + +Classes in this namespace enable you to interact with the Windows Azure environment from code running within your role. Copyright (c)2011 Microsoft. All rights reserved. + + \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html new file mode 100644 index 0000000000000..67af5f6cca3f3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html @@ -0,0 +1,16 @@ + + + +This package contains classes and interfaces that allow your roles to interact with the Windows Azure environment. +For example, the {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironment#requestRecycle} method allows an instance of your role to request to be stopped and then restarted. Copyright (c)2011 Microsoft. All rights reserved. + + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java new file mode 100644 index 0000000000000..1d6247ce98c94 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java @@ -0,0 +1,40 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; + +/** + * + */ +public class FileInputChannelTests { + @Test + public void getInputStreamOpensFile() { + InputChannel inputChannel = new FileInputChannel(); + + try { + File tempFile = File.createTempFile("getInputStreamOpensFile", null); + BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); + String expectedData = "test content"; + + writer.write(expectedData); + writer.close(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(inputChannel.getInputStream(tempFile.getAbsolutePath()))); + + assertThat(reader.readLine(), equalTo(expectedData)); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java new file mode 100644 index 0000000000000..39f146c8d0859 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java @@ -0,0 +1,69 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.LinkedList; + +/** + * + */ +public class MockInputChannel implements InputChannel { + private final ByteArrayInputStream inputStream; + + public MockInputChannel(String channelData) { + byte data[] = null; + + try { + data = channelData.getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + this.inputStream = new ByteArrayInputStream(data); + } + + public MockInputChannel(String chunks[]) { + int finalLength = 0; + LinkedList chunkBytes = new LinkedList(); + byte[] crlf = new byte[] { 0x0D, 0x0A }; + + for (String chunk : chunks) { + try { + byte chunkLengthData[] = Integer.toHexString(chunk.length()).getBytes("US-ASCII"); + byte chunkData[] = chunk.getBytes("UTF-8"); + int chunkLength = chunkLengthData.length + chunkData.length + 4; + + chunkBytes.add(chunkLengthData); + chunkBytes.add(chunkData); + + finalLength += chunkLength; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + byte data[] = new byte[finalLength]; + int dataIndex = 0; + + for (byte[] chunk : chunkBytes) { + System.arraycopy(chunk, 0, data, dataIndex, chunk.length); + + dataIndex += chunk.length; + + System.arraycopy(crlf, 0, data, dataIndex, crlf.length); + + dataIndex += crlf.length; + } + + this.inputStream = new ByteArrayInputStream(data); + } + @Override + public InputStream getInputStream(String name) { + return this.inputStream; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java new file mode 100644 index 0000000000000..f3d0f92068021 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java @@ -0,0 +1,102 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; + +/** + * + */ +public class Protocol1RuntimeCurrentStateClientTests { + @Test + public void setCurrentStateSerializesToEndpoint() { + final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); + final OutputStream expectedStream = new ByteArrayOutputStream(); + final String expectedEndpoint = "endpoint"; + final AtomicBoolean serializeCalled = new AtomicBoolean(false); + + CurrentStateSerializer serializer = new CurrentStateSerializer() { + @Override + public void serialize(CurrentState state, OutputStream stream) { + assertThat(state, is(expectedState)); + assertThat(stream, is(expectedStream)); + + serializeCalled.set(true); + } + }; + + OutputChannel outputChannel = new OutputChannel() { + @Override + public OutputStream getOutputStream(String name) { + assertThat(name, is(expectedEndpoint)); + + return expectedStream; + } + }; + + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, outputChannel); + + currentStateClient.setEndpoint(expectedEndpoint); + + currentStateClient.setCurrentState(expectedState); + + assertThat(serializeCalled.get(), is(true)); + } + + @Test + public void streamCloseFailureThrowsNotAvailableException() { + final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); + final OutputStream expectedStream = new OutputStream() { + @Override + public void write(int arg0) throws IOException { + } + + @Override + public void close() throws IOException { + throw new IOException(); + } + }; + + final String expectedEndpoint = "endpoint"; + final AtomicBoolean serializeCalled = new AtomicBoolean(false); + + CurrentStateSerializer serializer = new CurrentStateSerializer() { + @Override + public void serialize(CurrentState state, OutputStream stream) { + assertThat(state, is(expectedState)); + assertThat(stream, is(expectedStream)); + + serializeCalled.set(true); + } + }; + + OutputChannel outputChannel = new OutputChannel() { + @Override + public OutputStream getOutputStream(String name) { + assertThat(name, is(expectedEndpoint)); + + return expectedStream; + } + }; + + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, outputChannel); + + currentStateClient.setEndpoint(expectedEndpoint); + + try { + currentStateClient.setCurrentState(expectedState); + } catch (RoleEnvironmentNotAvailableException e) { + return; + } + + fail(); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java new file mode 100644 index 0000000000000..f9faea365004a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -0,0 +1,269 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + + +import java.io.InputStream; +import java.util.LinkedList; +import java.util.List; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; + +/** + * + */ +public class Protocol1RuntimeGoalStateClientTests { + private final List goalStates = new LinkedList(); + + @Test + public void addGoalStateChangedListenerAddsListener() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "", + "" + + "" + + "2" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "" + }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( + currentStateClient, + goalStateDeserializer, + roleEnvironmentDeserializer, + inputChannel); + + client.addGoalStateChangedListener(new GoalStateChangedListener() { + @Override + public void goalStateChanged(GoalState newGoalState) { + goalStates.add(newGoalState); + } + }); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(1)); + assertThat(goalStates.get(0).getIncarnation().intValue(), is(2)); + } + + @Test + public void goalStateClientRestartsThread() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { + private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); + + @Override + public void initialize(InputStream inputStream) { + deserializer.initialize(inputStream); + } + + @Override + public GoalState deserialize() { + GoalState goalState = deserializer.deserialize(); + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + goalStates.add(goalState); + + return goalState; + } + }; + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "" + }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( + currentStateClient, + goalStateDeserializer, + roleEnvironmentDeserializer, + inputChannel); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + client.getCurrentGoalState(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(3)); + } + + @Test + public void getRoleEnvironmentDataReturnsDeserializedData() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + final RoleEnvironmentData data = new RoleEnvironmentData(null, null, null, null, null, false); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return data; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "" + }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( + currentStateClient, + goalStateDeserializer, + roleEnvironmentDeserializer, + inputChannel); + + try { + assertThat(client.getRoleEnvironmentData(), is(data)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Test + public void removeGoalStateChangedListenerRemovesListener() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "", + "" + + "" + + "2" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "" + }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( + currentStateClient, + goalStateDeserializer, + roleEnvironmentDeserializer, + inputChannel); + + GoalStateChangedListener listener = new GoalStateChangedListener() { + @Override + public void goalStateChanged(GoalState newGoalState) { + goalStates.add(newGoalState); + } + }; + + client.addGoalStateChangedListener(listener); + client.removeGoalStateChangedListener(listener); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(0)); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java new file mode 100644 index 0000000000000..d86f3080455e1 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java @@ -0,0 +1,61 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.lang.reflect.Field; +import java.util.Calendar; +import java.util.Map; +import java.util.TimeZone; + +import org.junit.Before; +//import org.junit.Test; + +/** + * + */ +public class RoleEnvironmentTests { + @Before + public void setupTests() { + horrificEnvironmentModification("\\\\.\\pipe\\578cb0d1-a330-4019-b634-755aa3d1e9d2"); + } + + //@Test + public void roleEnvironmentIsAvailable() { + assertThat(RoleEnvironment.isAvailable(), is(true)); + } + + //@Test + public void roleEnvironmentSetStateSetsState() { + Calendar exp = Calendar.getInstance(TimeZone.getTimeZone("GMT+0:00")); + + exp.add(Calendar.MINUTE, 1); + + RoleEnvironment.setStatus(RoleInstanceStatus.Ready, exp); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void horrificEnvironmentModification(String endpoint) { + try { + Class processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); + Field field = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); + field.setAccessible(true); + Object obj = field.get(null); + Map map = (Map)obj; + map.put("WaRuntimeEndpoint", endpoint); + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java new file mode 100644 index 0000000000000..99d09dce41dc2 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java @@ -0,0 +1,114 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; + +/** + * + */ +public class RuntimeVersionManagerTests { + @Test + public void getRuntimeClientForV1CanParseGoalState() { + RuntimeVersionManager manager = createVersionManagerWithGoalState( + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "", + "2011-03-08"); + + RuntimeClient runtimeClient = manager.getRuntimeClient(""); + GoalState goalState = null; + + try { + goalState = runtimeClient.getCurrentGoalState(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + Calendar expectedDeadline = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); + + expectedDeadline.clear(); + expectedDeadline.set(2011, 2, 8, 3, 27, 44); + + assertThat(goalState.getIncarnation(), equalTo(BigInteger.ONE)); + assertThat(goalState.getExpectedState(), equalTo(ExpectedState.STARTED)); + assertThat(goalState.getEnvironmentPath(), equalTo("envpath")); + assertThat(goalState.getCurrentStateEndpoint(), equalTo("statepath")); + assertThat(goalState.getDeadline().getTimeInMillis(), equalTo(expectedDeadline.getTimeInMillis())); + } + + @Test + public void getRuntimeClientThrowsWhenNoSupportedVersionsFound() { + RuntimeVersionManager manager = createVersionManagerWithGoalState( + "" + + "" + + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + + "", + "notSupported"); + + try { + manager.getRuntimeClient(""); + } catch (RuntimeException ex) { + return; + } + + fail(); + } + + private RuntimeVersionManager createVersionManagerWithGoalState(String goalStateXml, String version) { + File tempGoalState; + + try { + tempGoalState = File.createTempFile("tempGoalState", null); + FileOutputStream output = new FileOutputStream(tempGoalState); + + InputChannel goalStateChannel = new MockInputChannel(new String[] { goalStateXml }); + BufferedInputStream input = new BufferedInputStream(goalStateChannel.getInputStream("")); + + byte buffer[] = new byte[1024]; + int length = 0; + + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + InputChannel inputChannel = new MockInputChannel( + "" + + "" + + "" + + "" + + "" + + ""); + RuntimeVersionProtocolClient protocolClient = new RuntimeVersionProtocolClient(inputChannel); + return new RuntimeVersionManager(protocolClient); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java new file mode 100644 index 0000000000000..d9cd04b49370f --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java @@ -0,0 +1,16 @@ +/** + * + */ +package com.microsoft.windowsazure.serviceruntime; +/* +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; +*/ + +/** + * + */ +public class XmlGoalStateDeserializerTests { + +} From 1fa932bd08c1231bbc143c36f9c7efce30f0c8c0 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 14 Nov 2011 17:30:56 -0800 Subject: [PATCH 192/664] Using FilterableService base interface --- .../windowsazure/services/serviceBus/ServiceBusContract.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index e1ddae8f9b8a4..9a48c4becb217 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.http.ServiceFilter; +import com.microsoft.windowsazure.http.FilterableService; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -23,8 +23,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; -public interface ServiceBusContract { - ServiceBusContract withFilter(ServiceFilter filter); +public interface ServiceBusContract extends FilterableService { void sendQueueMessage(String queueName, Message message) throws ServiceException; From 81b40a5d2f41e52153995f78c19208b61b1a7028 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 15 Nov 2011 11:09:14 -0800 Subject: [PATCH 193/664] Relocating WRAP to be an implementation detail of serviceBus --- .../windowsazure/auth/wrap/Exports.java | 16 -------- .../auth/wrap/contract/WrapContract.java | 7 ---- .../serviceBus/implementation/Exports.java | 13 +++++++ .../implementation/ServiceBusRestProxy.java | 1 - .../WrapAccessTokenResult.java} | 4 +- .../implementation/WrapContract.java | 7 ++++ .../implementation}/WrapFilter.java | 10 ++--- .../implementation/WrapRestProxy.java} | 14 +++---- .../implementation/WrapTokenManager.java} | 33 +++++++---------- ...zure.configuration.builder.Builder$Exports | 2 +- .../contract/WrapContractIntegrationTest.java | 23 ------------ .../WrapRestProxyIntegrationTest.java | 25 +++++++++++++ .../WrapTokenManagerIntegrationTest.java} | 8 ++-- .../implementation/WrapTokenManagerTest.java} | 37 +++++++------------ 14 files changed, 90 insertions(+), 110 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{auth/wrap/contract/WrapResponse.java => services/serviceBus/implementation/WrapAccessTokenResult.java} (85%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{auth/wrap => services/serviceBus/implementation}/WrapFilter.java (74%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{auth/wrap/contract/WrapContractImpl.java => services/serviceBus/implementation/WrapRestProxy.java} (72%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{auth/wrap/WrapClient.java => services/serviceBus/implementation/WrapTokenManager.java} (70%) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/{auth/wrap/WrapClientIntegrationTest.java => services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java} (76%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/{auth/wrap/WrapClientTest.java => services/serviceBus/implementation/WrapTokenManagerTest.java} (67%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java deleted file mode 100644 index 5acaa03325cae..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/Exports.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap; - -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.builder.Builder.Registry; - -public class Exports implements - com.microsoft.windowsazure.configuration.builder.Builder.Exports { - - public void register(Registry registry) { - registry.add(WrapContract.class, WrapContractImpl.class); - registry.add(WrapClient.class); - registry.add(WrapFilter.class); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java deleted file mode 100644 index 7b583d7ef63ae..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContract.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap.contract; - -import com.microsoft.windowsazure.ServiceException; - -public interface WrapContract { - WrapResponse post(String uri, String name, String password, String scope) throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java new file mode 100644 index 0000000000000..0143c7d644580 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java @@ -0,0 +1,13 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import com.microsoft.windowsazure.configuration.builder.Builder; + +public class Exports implements Builder.Exports { + + public void register(Builder.Registry registry) { + registry.add(WrapContract.class, WrapRestProxy.class); + registry.add(WrapTokenManager.class); + registry.add(WrapFilter.class); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index f4c11d9f2b53a..270532b332dd1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -12,7 +12,6 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.WrapFilter; import com.microsoft.windowsazure.http.ClientFilterAdapter; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java index ab06407f92f1d..da241b3ad9cfb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java @@ -1,6 +1,6 @@ -package com.microsoft.windowsazure.auth.wrap.contract; +package com.microsoft.windowsazure.services.serviceBus.implementation; -public class WrapResponse { +public class WrapAccessTokenResult { String accessToken; long expiresIn; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java new file mode 100644 index 0000000000000..c3939e2dce139 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java @@ -0,0 +1,7 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import com.microsoft.windowsazure.ServiceException; + +public interface WrapContract { + WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java similarity index 74% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index dd322619984e1..ea836739c1781 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import com.microsoft.windowsazure.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; @@ -7,10 +7,10 @@ import com.sun.jersey.api.client.filter.ClientFilter; public class WrapFilter extends ClientFilter { - private WrapClient client; + private WrapTokenManager tokenManager; - public WrapFilter(WrapClient client) { - this.client = client; + public WrapFilter(WrapTokenManager tokenManager) { + this.tokenManager = tokenManager; } @Override @@ -19,7 +19,7 @@ public ClientResponse handle(ClientRequest cr) String accessToken; try { - accessToken = client.getAccessToken(); + accessToken = tokenManager.getAccessToken(); } catch (ServiceException e) { // must wrap exception because of base class signature diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java similarity index 72% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index 313d490a9be2c..dca9b912540a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap.contract; +package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.inject.Inject; import javax.ws.rs.core.MediaType; @@ -12,17 +12,17 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; -public class WrapContractImpl implements WrapContract { +public class WrapRestProxy implements WrapContract { Client channel; static Log log = LogFactory.getLog(WrapContract.class); @Inject - public WrapContractImpl(Client channel) { + public WrapRestProxy(Client channel) { this.channel = channel; } - public WrapResponse post(String uri, String name, String password, String scope) throws ServiceException { + public WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) throws ServiceException { Form requestForm = new Form(); requestForm.add("wrap_name", name); requestForm.add("wrap_password", password); @@ -30,9 +30,7 @@ public WrapResponse post(String uri, String name, String password, String scope) Form responseForm; try { - responseForm = channel.resource(uri) - .accept(MediaType.APPLICATION_FORM_URLENCODED) - .type(MediaType.APPLICATION_FORM_URLENCODED) + responseForm = channel.resource(uri).accept(MediaType.APPLICATION_FORM_URLENCODED).type(MediaType.APPLICATION_FORM_URLENCODED) .post(Form.class, requestForm); } catch (UniformInterfaceException e) { @@ -40,7 +38,7 @@ public WrapResponse post(String uri, String name, String password, String scope) throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); } - WrapResponse response = new WrapResponse(); + WrapAccessTokenResult response = new WrapAccessTokenResult(); response.setAccessToken(responseForm.getFirst("wrap_access_token")); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java similarity index 70% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 36bf0683b870d..fd97fd6a50f11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/auth/wrap/WrapClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.Date; @@ -7,29 +7,22 @@ import javax.management.timer.Timer; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; import com.microsoft.windowsazure.utils.DateFactory; -public class WrapClient { +public class WrapTokenManager { WrapContract contract; - private DateFactory dateFactory; - private String uri; - private String name; - private String password; - private String scope; + private final DateFactory dateFactory; + private final String uri; + private final String name; + private final String password; + private final String scope; private ActiveToken activeToken; @Inject - public WrapClient( - WrapContract contract, - DateFactory dateFactory, - @Named("wrap.uri") String uri, - @Named("wrap.scope") String scope, - @Named("wrap.name") String name, - @Named("wrap.password") String password) { + public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, @Named("wrap.scope") String scope, + @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; this.dateFactory = dateFactory; this.uri = uri; @@ -61,7 +54,7 @@ public String getAccessToken() throws ServiceException { return active.getWrapResponse().getAccessToken(); } - WrapResponse wrapResponse = getContract().post(uri, name, password, scope); + WrapAccessTokenResult wrapResponse = getContract().wrapAccessToken(uri, name, password, scope); Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); ActiveToken acquired = new ActiveToken(); @@ -74,7 +67,7 @@ public String getAccessToken() throws ServiceException { class ActiveToken { Date expiresUtc; - WrapResponse wrapResponse; + WrapAccessTokenResult wrapResponse; /** * @return the expiresUtc @@ -94,7 +87,7 @@ public void setExpiresUtc(Date expiresUtc) { /** * @return the wrapResponse */ - public WrapResponse getWrapResponse() { + public WrapAccessTokenResult getWrapResponse() { return wrapResponse; } @@ -102,7 +95,7 @@ public WrapResponse getWrapResponse() { * @param wrapResponse * the wrapResponse to set */ - public void setWrapResponse(WrapResponse wrapResponse) { + public void setWrapResponse(WrapAccessTokenResult wrapResponse) { this.wrapResponse = wrapResponse; } } 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 ce9f1f862db41..0e2672c708145 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,6 +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.services.serviceBus.implementation.Exports com.microsoft.windowsazure.utils.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java deleted file mode 100644 index 46650236ed02a..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/contract/WrapContractIntegrationTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.microsoft.windowsazure.auth.wrap.contract; - -import org.junit.Test; - -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContractImpl; -import com.microsoft.windowsazure.configuration.Configuration; -import com.sun.jersey.api.client.Client; - -public class WrapContractIntegrationTest { - @Test - public void yaaaaargh() throws Exception { - Configuration config = new Configuration(); - - WrapContract contract = new WrapContractImpl(config.create(Client.class)); - - contract.post( - "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", - "owner", - "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", - "http://lodejard.servicebus.windows.net"); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java new file mode 100644 index 0000000000000..5bafb7df76e91 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -0,0 +1,25 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.configuration.Configuration; +import com.sun.jersey.api.client.Client; + +public class WrapRestProxyIntegrationTest { + @Test + public void serviceCanBeCalledToCreateAccessToken() throws Exception { + // Arrange + Configuration config = new Configuration(); + WrapContract contract = new WrapRestProxy(config.create(Client.class)); + + // Act + WrapAccessTokenResult result = contract.wrapAccessToken("https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", "owner", + "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", "http://lodejard.servicebus.windows.net"); + + // Assert + assertNotNull(result); + assertNotNull(result.getAccessToken()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java similarity index 76% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 665d3152297fa..361287d7ef09e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -1,13 +1,13 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import junit.framework.Assert; import org.junit.Test; -import com.microsoft.windowsazure.auth.wrap.WrapClient; import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.implementation.WrapTokenManager; -public class WrapClientIntegrationTest { +public class WrapTokenManagerIntegrationTest { private Configuration createConfiguration() { Configuration config = new Configuration(); config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); @@ -21,7 +21,7 @@ private Configuration createConfiguration() { public void wrapClientWillAcquireAccessToken() throws Exception { // Arrange Configuration config = createConfiguration(); - WrapClient client = config.create(WrapClient.class); + WrapTokenManager client = config.create(WrapTokenManager.class); // Act String accessToken = client.getAccessToken(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java similarity index 67% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 6dc11fd627667..2cae1fad35bbd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/auth/wrap/WrapClientTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.auth.wrap; +package com.microsoft.windowsazure.services.serviceBus.implementation; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -13,14 +13,11 @@ import org.mockito.stubbing.Answer; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.auth.wrap.WrapClient; -import com.microsoft.windowsazure.auth.wrap.contract.WrapContract; -import com.microsoft.windowsazure.auth.wrap.contract.WrapResponse; import com.microsoft.windowsazure.utils.DateFactory; -public class WrapClientTest { +public class WrapTokenManagerTest { private WrapContract contract; - private WrapClient client; + private WrapTokenManager client; private DateFactory dateFactory; private Calendar calendar; @@ -30,13 +27,7 @@ public void init() { dateFactory = mock(DateFactory.class); contract = mock(WrapContract.class); - client = new WrapClient( - contract, - dateFactory, - "testurl", - "testscope", - "testname", - "testpassword"); + client = new WrapTokenManager(contract, dateFactory, "testurl", "testscope", "testname", "testpassword"); when(dateFactory.getDate()).thenAnswer(new Answer() { public Date answer(InvocationOnMock invocation) throws Throwable { @@ -49,11 +40,11 @@ public Date answer(InvocationOnMock invocation) throws Throwable { @Test public void clientUsesContractToGetToken() throws ServiceException { // Arrange - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken"); wrapResponse.setExpiresIn(83); - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); // Act String accessToken = client.getAccessToken(); @@ -66,11 +57,11 @@ public void clientUsesContractToGetToken() throws ServiceException { @Test public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException { // Arrange - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken"); wrapResponse.setExpiresIn(83); - when(contract.post("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); // Act String accessToken1 = client.getAccessToken(); @@ -83,23 +74,23 @@ public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws Servi assertEquals("testaccesstoken", accessToken2); assertEquals("testaccesstoken", accessToken3); - verify(contract, times(1)).post("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); } @Test public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException { // Arrange - doAnswer(new Answer() { + doAnswer(new Answer() { int count = 0; - public WrapResponse answer(InvocationOnMock invocation) throws Throwable { + public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { ++count; - WrapResponse wrapResponse = new WrapResponse(); + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); wrapResponse.setAccessToken("testaccesstoken" + count); wrapResponse.setExpiresIn(83); return wrapResponse; } - }).when(contract).post("testurl", "testname", "testpassword", "testscope"); + }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); // Act String accessToken1 = client.getAccessToken(); @@ -112,7 +103,7 @@ public WrapResponse answer(InvocationOnMock invocation) throws Throwable { assertEquals("testaccesstoken1", accessToken2); assertEquals("testaccesstoken2", accessToken3); - verify(contract, times(2)).post("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(2)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); } } From 9f3d50abdf81b4d257979dea7ba586a6d2abff5f Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Tue, 15 Nov 2011 17:26:49 -0800 Subject: [PATCH 194/664] Testting checkin. --- .../services/serviceBus/models/Message.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java index d0a82299965de..a219f02487738 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java @@ -23,7 +23,8 @@ public Message() { } /** - * Creates an instance of the Message class using the specified InputStream. + * Creates an instance of the Message class using the + * specified InputStream. * * @param body * An InputStream object that represents the body of @@ -149,8 +150,8 @@ public Date getDate() { * Sets the date/time of the message. * * @param date - * A Date object that represents the date/time of the - * object. + * A Date object that represents the date/time of + * the object. * * @return A Message object that reperesents the updated * message. @@ -403,8 +404,8 @@ public String getReplyToSessionId() { * Sets the session ID of the Reply To recipient. * * @param replyToSessionId - * A String object that represents the session ID of - * the Reply To recipient. + * A String object that represents the session ID + * of the Reply To recipient. * * @return A Message object that reperesents the updated * message. From 46480abf63af64c708630de095f1d58e1caecb04 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Tue, 15 Nov 2011 18:53:56 -0800 Subject: [PATCH 195/664] Added Javadoc comments. --- .../services/serviceBus/models/Queue.java | 403 +++++++++++++----- .../services/serviceBus/models/Rule.java | 144 +++++-- 2 files changed, 392 insertions(+), 155 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java index 2bfb8506fe2b0..630c4e9703da4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java @@ -8,120 +8,297 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; +/** + * Represents a queue. + */ public class Queue extends EntryModel { - public Queue() { - super(new Entry(), new QueueDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setQueueDescription(getModel()); - } - - public Queue(Entry entry) { - super(entry, entry.getContent().getQueueDescription()); - } - - public Queue(String name) { - this(); - setName(name); - } - - public String getName() { - return getEntry().getTitle(); - } - - public Queue setName(String value) { - getEntry().setTitle(value); - return this; - } - - public Duration getLockDuration() { - return getModel().getLockDuration(); - } - - public Queue setLockDuration(Duration value) { - getModel().setLockDuration(value); - return this; - } - - public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); - } - - public Queue setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); - return this; - } - - public Boolean isRequiresDuplicateDetection() { - return getModel().isRequiresDuplicateDetection(); - } - - public Queue setRequiresDuplicateDetection(Boolean value) { - getModel().setRequiresDuplicateDetection(value); - return this; - } - - public Boolean isRequiresSession() { - return getModel().isRequiresSession(); - } - - public Queue setRequiresSession(Boolean value) { - getModel().setRequiresSession(value); - return this; - } - - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } - - public Queue setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } - - public Boolean isDeadLetteringOnMessageExpiration() { - return getModel().isDeadLetteringOnMessageExpiration(); - } - - public Queue setDeadLetteringOnMessageExpiration(Boolean value) { - getModel().setDeadLetteringOnMessageExpiration(value); - return this; - } - - public Duration getDuplicateDetectionHistoryTimeWindow() { - return getModel().getDuplicateDetectionHistoryTimeWindow(); - } - - public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { - getModel().setDuplicateDetectionHistoryTimeWindow(value); - return this; - } - - public Integer getMaxDeliveryCount() { - return getModel().getMaxDeliveryCount(); - } - - public Queue setMaxDeliveryCount(Integer value) { - getModel().setMaxDeliveryCount(value); - return this; - } - - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } - - public Queue setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } - - public Long getSizeInBytes() { - return getModel().getSizeInBytes(); - } - - public Long getMessageCount() { - return getModel().getMessageCount(); - } + /** + * Creates an instance of the Queue class. + */ + public Queue() { + super(new Entry(), new QueueDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setQueueDescription(getModel()); + } + + /** + * Creates an instance of the Queue class using the specified + * entry. + * + * @param entry + * An Entry object. + */ + public Queue(Entry entry) { + super(entry, entry.getContent().getQueueDescription()); + } + + /** + * Creates an instance of the Queue class using the specified + * name. + * + * @param name + * String that represents the name of the queue. + */ + public Queue(String name) { + this(); + setName(name); + } + + /** + * Returns the name of the queue. + * + * @return String that represents the name of the queue. + */ + public String getName() { + return getEntry().getTitle(); + } + + /** + * Sets the name of the queue. + * + * @param value + * A String that represents the name of the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setName(String value) { + getEntry().setTitle(value); + return this; + } + + /** + * Returns the duration of the lock. + * + * @return A Duration object that represents the duration of + * the lock. + */ + public Duration getLockDuration() { + return getModel().getLockDuration(); + } + + /** + * Sets the duration of the lock. + * + * @param value + * The duration, in seconds, of the lock. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setLockDuration(Duration value) { + getModel().setLockDuration(value); + return this; + } + + /** + * Returns the maximum size of the queue. + * + * @return The maximim size, in megabytes, of the queue. + */ + public Long getMaxSizeInMegabytes() { + return getModel().getMaxSizeInMegabytes(); + } + + /** + * Sets the maximum size of the queue. + * + * @param value + * The maximim size, in megabytes, of the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setMaxSizeInMegabytes(Long value) { + getModel().setMaxSizeInMegabytes(value); + return this; + } + + /** + * Indicates whether duplicate message detection is required. + * + * @return true if duplicate message detection is required; + * otherwise, false. + */ + public Boolean isRequiresDuplicateDetection() { + return getModel().isRequiresDuplicateDetection(); + } + + /** + * Specifies whether duplicate message detection is required. + * + * @param value + * true if duplicate message detection is required; + * otherwise, false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setRequiresDuplicateDetection(Boolean value) { + getModel().setRequiresDuplicateDetection(value); + return this; + } + + /** + * Indicates whether the queue is session-aware. + * + * @return true if the queue is session aware; otherwise, + * false. + */ + public Boolean isRequiresSession() { + return getModel().isRequiresSession(); + } + + /** + * Specifies whether the queue is session-aware. + * + * @param value + * true if the queue is session aware; otherwise, + * false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setRequiresSession(Boolean value) { + getModel().setRequiresSession(value); + return this; + } + + /** + * Returns the default message time-to-live (TTL). This applies when dead + * lettering is in effect. + * + * @return A Duration object that represents the default + * message TTL. + */ + public Duration getDefaultMessageTimeToLive() { + return getModel().getDefaultMessageTimeToLive(); + } + + /** + * Sets the default message time-to-live (TTL). This applies when dead + * lettering is in effect. + * + * @param value + * A Duration object that represents the default + * message TTL. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDefaultMessageTimeToLive(Duration value) { + getModel().setDefaultMessageTimeToLive(value); + return this; + } + + /** + * Indicates whether dead lettering is in effect upon message expiration. + * + * @return true if dead lettering is in effect; otherwise, + * false. + */ + public Boolean isDeadLetteringOnMessageExpiration() { + return getModel().isDeadLetteringOnMessageExpiration(); + } + + /** + * Specifies whether dead lettering is in effect upon message expiration. + * + * @param value + * true if dead lettering is in effect; otherwise, + * false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDeadLetteringOnMessageExpiration(Boolean value) { + getModel().setDeadLetteringOnMessageExpiration(value); + return this; + } + + /** + * Returns the time span during which the service bus will detect message + * duplication. This applies when duplicate message detection is in effect. + * + * @return A Duration object that represents the time span for + * detecting message duplication. + */ + public Duration getDuplicateDetectionHistoryTimeWindow() { + return getModel().getDuplicateDetectionHistoryTimeWindow(); + } + + /** + * Sets the time span during which the service bus will detect message + * duplication. This applies when duplicate message detection is in effect. + * + * @param value + * A Duration object that represents the time span + * for detecting message duplication. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { + getModel().setDuplicateDetectionHistoryTimeWindow(value); + return this; + } + + /** + * Returns the maximum delivery count for the queue. + * + * @return The maximum delivery count. + */ + public Integer getMaxDeliveryCount() { + return getModel().getMaxDeliveryCount(); + } + + /** + * Sets the maximum delivery count for the queue. + * + * @param value + * The maximum delivery count for the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setMaxDeliveryCount(Integer value) { + getModel().setMaxDeliveryCount(value); + return this; + } + + /** + * Indicates whether batch operations are enabled. + * + * @return true if batch operations are enabled; otherwise, + * false. + */ + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } + + /** + * Specifies whether batch operations are enabled. + * + * @param value + * true if batch operations are enabled; otherwise, + * false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setEnableBatchedOperations(Boolean value) { + getModel().setEnableBatchedOperations(value); + return this; + } + + /** + * Returns the size of the queue. + * + * @return The size, in bytes, of the queue. + */ + public Long getSizeInBytes() { + return getModel().getSizeInBytes(); + } + + /** + * Returns the number of messages in the queue. + * + * @return The number of messages in the queue. + */ + public Long getMessageCount() { + return getModel().getMessageCount(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java index 20f696d7730e3..8d7c338972777 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java @@ -9,49 +9,109 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; +/** + * Represents a rule. + */ public class Rule extends EntryModel { - public Rule() { - super(new Entry(), new RuleDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setRuleDescription(getModel()); - } - - public Rule(Entry entry) { - super(entry, entry.getContent().getRuleDescription()); - } - - public Rule(String name) { - this(); - setName(name); - } - - public String getName() { - return getEntry().getTitle(); - } - - public Rule setName(String value) { - getEntry().setTitle(value); - return this; - } - - public Filter getFilter() { - return getModel().getFilter(); - } - - public Rule setFilter(Filter value) { - getModel().setFilter(value); - return this; - } - - public RuleAction getAction() { - return getModel().getAction(); - } - - public Rule setAction(RuleAction value) { - getModel().setAction(value); - return this; - } + /** + * Creates an instance of the Rule class. + */ + public Rule() { + super(new Entry(), new RuleDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setRuleDescription(getModel()); + } + + /** + * Creates an instance of the Rule class using the specified + * entry. + * + * @param entry + * An {@link Entry} object. + * + */ + public Rule(Entry entry) { + super(entry, entry.getContent().getRuleDescription()); + } + + /** + * Creates an instance of the Rule class using the specified + * name. + * + * @param name + * A String object that represents the name of the rule. + * + */ public Rule(String name) { + this(); + setName(name); + } + + /** + * Returns the name of the rule. + * + * @return A String object that represents the name of the rule. + */ + public String getName() { + return getEntry().getTitle(); + } + + /** + * Sets the name of the rule. + * + * @param value + * A String object that represents the name of the rule. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setName(String value) { + getEntry().setTitle(value); + return this; + } + + /** + * Returns the filter used for the rule. + * + * @return A Filter object that represents the filter of the rule. + */ + public Filter getFilter() { + return getModel().getFilter(); + } + + /** + * Specifies the filter used for the rule. + * + * @param value + * A Filter object that represents the filter of the rule. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setFilter(Filter value) { + getModel().setFilter(value); + return this; + } + + /** + * Returns the rule action used for the rule. + * + * @return A RuleAction object that represents the rule action. + */ + public RuleAction getAction() { + return getModel().getAction(); + } + + /** + * Specifies the rule action for the rule. + * + * @param value + * A RuleAction object that represents the rule action. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setAction(RuleAction value) { + getModel().setAction(value); + return this; + } } From 716a5461056e9a1ec22077e68f9c19c8b7ffd8dd Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Wed, 16 Nov 2011 08:57:54 -0800 Subject: [PATCH 196/664] Added Javadoc content. --- .../serviceBus/models/CreateQueueResult.java | 40 ++++++++++++++----- .../serviceBus/models/CreateRuleResult.java | 22 +++++++++- .../models/CreateSubscriptionResult.java | 20 +++++++++- .../serviceBus/models/CreateTopicResult.java | 20 +++++++++- 4 files changed, 87 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index 85107629fb02f..6c45047576d10 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -1,20 +1,38 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a createQueue operation. + */ public class CreateQueueResult { - private Queue value; + private Queue value; - public CreateQueueResult(Queue value) { - this.setValue(value); - } + /** + * Creates an instance of the CreateQueueResult class. + * + * @param value + * A {@link Queue} object assigned as the value of the result. + */ + public CreateQueueResult(Queue value) { + this.setValue(value); + } - public void setValue(Queue value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @return A {@link Queue} object assigned as the value of the result. + */ + public void setValue(Queue value) { + this.value = value; + } - public Queue getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link Queue} object that represents the value of the result. + */ + public Queue getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index 114e189b22a3b..85dca821d19df 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -1,17 +1,35 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a createRule operation. + */ public class CreateRuleResult { private Rule value; + /** + * Creates an instance of the CreateRuleResult class. + * + * @param value + * A {@link Rule} object assigned as the value of the result. + */ public CreateRuleResult(Rule value) { this.setValue(value); } + /** + * Specfies the value of the result. + * + * @return A {@link Rule} object assigned as the value of the result. + */ public void setValue(Rule value) { this.value = value; } - + + /** + * Returns the value of the result. + * + * @return A {@link Rule} object that represents the value of the result. + */ public Rule getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 3b74257241380..afa513c413016 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -1,18 +1,36 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a createSubscription operation. + */ public class CreateSubscriptionResult { private Subscription value; + /** + * Creates an instance of the CreateSubscriptionResult class. + * + * @param value + * A {@link Subscription} object assigned as the value of the result. + */ public CreateSubscriptionResult(Subscription value) { this.setValue(value); } + /** + * Specfies the value of the result. + * + * @return A {@link Subscription} object assigned as the value of the result. + */ public void setValue(Subscription value) { this.value = value; } + /** + * Returns the value of the result. + * + * @return A {@link Subscription} object that represents the value of the result. + */ public Subscription getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 10192e3e454a2..3e2e8c9fea171 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -1,18 +1,36 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a createTopic operation. + */ public class CreateTopicResult { private Topic value; + /** + * Creates an instance of the CreateTopicResult class. + * + * @param value + * A {@link Topic} object assigned as the value of the result. + */ public CreateTopicResult(Topic value) { this.setValue(value); } + /** + * Specfies the value of the result. + * + * @return A {@link Topic} object assigned as the value of the result. + */ public void setValue(Topic value) { this.value = value; } + /** + * Returns the value of the result. + * + * @return A {@link Topic} object that represents the value of the result. + */ public Topic getValue() { return value; } From becb7d9c701023fb9e1f70be014a6223fb71f5fc Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 16 Nov 2011 11:20:31 -0800 Subject: [PATCH 197/664] Refactor ExponentialRetryPolicy to use abstract class --- .../common/ExponentialRetryPolicy.java | 55 +++++++++++ .../common/ExponentialRetryPolicyFilter.java | 93 ------------------- .../windowsazure/common/RetryPolicy.java | 14 +++ .../common/RetryPolicyFilter.java | 53 +++++++++++ .../windowsazure/common/ServiceFilter.java | 4 +- .../utils/jersey/ClientFilterAdapter.java | 19 ++-- .../blob/BlobServiceIntegrationTest.java | 14 ++- .../services/blob/IntegrationTestBase.java | 6 +- .../services/queue/IntegrationTestBase.java | 6 +- .../serviceBus/ServiceBusIntegrationTest.java | 12 +-- 10 files changed, 153 insertions(+), 123 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java new file mode 100644 index 0000000000000..ba6f5722efd8a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java @@ -0,0 +1,55 @@ +package com.microsoft.windowsazure.common; + +import java.util.Arrays; +import java.util.Random; + +import com.microsoft.windowsazure.common.ServiceFilter.Response; + +public class ExponentialRetryPolicy extends RetryPolicy { + private final int deltaBackoffIntervalInMs; + private final int maximumAttempts; + private final Random randRef = new Random(); + private final int resolvedMaxBackoff = DEFAULT_MAX_BACKOFF; + private final int resolvedMinBackoff = DEFAULT_MIN_BACKOFF; + private final int[] retryableStatusCodes; + + public ExponentialRetryPolicy(int[] retryableStatusCodes) { + this(DEFAULT_CLIENT_BACKOFF, DEFAULT_CLIENT_RETRY_COUNT, retryableStatusCodes); + } + + public ExponentialRetryPolicy(int deltaBackoff, int maximumAttempts, int[] retryableStatusCodes) { + this.deltaBackoffIntervalInMs = deltaBackoff; + this.maximumAttempts = maximumAttempts; + this.retryableStatusCodes = Arrays.copyOf(retryableStatusCodes, retryableStatusCodes.length); + Arrays.sort(this.retryableStatusCodes); + } + + @Override + public boolean shouldRetry(int retryCount, Response response, Exception error) { + if (response == null) + return false; + + if (retryCount >= this.maximumAttempts) + return false; + + // Don't retry if not retryable status code + if (Arrays.binarySearch(this.retryableStatusCodes, response.getStatus()) < 0) + return false; + + return true; + } + + @Override + public int calculateBackoff(int currentRetryCount, Response response, Exception error) { + // Calculate backoff Interval between 80% and 120% of the desired + // backoff, multiply by 2^n -1 for + // exponential + int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); + int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) + + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - (int) (this.deltaBackoffIntervalInMs * 0.8)); + incrementDelta *= boundedRandDelta; + + // Enforce max / min backoffs + return Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java deleted file mode 100644 index 6ec6c2b3fd1c5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicyFilter.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.microsoft.windowsazure.common; - -import java.util.Arrays; -import java.util.Random; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - - -public class ExponentialRetryPolicyFilter implements ServiceFilter { - private static final Log log = LogFactory.getLog(ExponentialRetryPolicyFilter.class); - - public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; - public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; - public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; - public static final int DEFAULT_MIN_BACKOFF = 100 * 3; - - private final int deltaBackoffIntervalInMs; - private final int maximumAttempts; - private final Random randRef = new Random(); - private final int resolvedMaxBackoff = DEFAULT_MAX_BACKOFF; - private final int resolvedMinBackoff = DEFAULT_MIN_BACKOFF; - private final int[] retryableStatusCodes; - - public ExponentialRetryPolicyFilter(int[] retryableStatusCodes) { - this(DEFAULT_CLIENT_BACKOFF, DEFAULT_CLIENT_RETRY_COUNT, retryableStatusCodes); - } - - public ExponentialRetryPolicyFilter(int deltaBackoff, int maximumAttempts, int[] retryableStatusCodes) { - this.deltaBackoffIntervalInMs = deltaBackoff; - this.maximumAttempts = maximumAttempts; - this.retryableStatusCodes = Arrays.copyOf(retryableStatusCodes, retryableStatusCodes.length); - Arrays.sort(this.retryableStatusCodes); - } - - public Response handle(Request request, Next next) { - // Only the last added retry policy should be active - if (request.getProperties().containsKey("RetryPolicy")) - return next.handle(request); - request.getProperties().put("RetryPolicy", this); - - // Retry the operation up to "getMaximumAttempts" - for (int retryCount = 0;; ++retryCount) { - Response response = next.handle(request); - - boolean shouldRetry = shouldRetry(retryCount, response); - if (!shouldRetry) - return response; - - int backoffTime = calculateBackoff(retryCount); - log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", backoffTime, retryCount)); - backoff(backoffTime); - } - } - - private void backoff(int milliseconds) { - try { - Thread.sleep(milliseconds); - } - catch (InterruptedException e) { - // Restore the interrupted status - Thread.currentThread().interrupt(); - } - } - - private int calculateBackoff(int currentRetryCount) { - // Calculate backoff Interval between 80% and 120% of the desired - // backoff, multiply by 2^n -1 for - // exponential - int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); - int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) - + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - (int) (this.deltaBackoffIntervalInMs * 0.8)); - incrementDelta *= boundedRandDelta; - - // Enforce max / min backoffs - return Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff); - } - - private boolean shouldRetry(int retryCount, Response response) { - if (retryCount >= getMaximumAttempts()) - return false; - - // Don't retry if not retryable status code - if (Arrays.binarySearch(this.retryableStatusCodes, response.getStatus()) < 0) - return false; - - return true; - } - - private int getMaximumAttempts() { - return this.maximumAttempts; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java new file mode 100644 index 0000000000000..c8d1fdee04742 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.common; + +import com.microsoft.windowsazure.common.ServiceFilter.Response; + +public abstract class RetryPolicy { + public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; + public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; + public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; + public static final int DEFAULT_MIN_BACKOFF = 100 * 3; + + public abstract boolean shouldRetry(int retryCount, Response response, Exception error); + + public abstract int calculateBackoff(int retryCount, Response response, Exception error); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java new file mode 100644 index 0000000000000..a4f63de45e533 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java @@ -0,0 +1,53 @@ +package com.microsoft.windowsazure.common; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class RetryPolicyFilter implements ServiceFilter { + private static final Log log = LogFactory.getLog(RetryPolicyFilter.class); + private final RetryPolicy retryPolicy; + + public RetryPolicyFilter(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + } + + public Response handle(Request request, Next next) throws Exception { + // Only the last added retry policy should be active + if (request.getProperties().containsKey("RetryPolicy")) + return next.handle(request); + request.getProperties().put("RetryPolicy", this); + + // Retry the operation as long as retry policy tells us to do so + for (int retryCount = 0;; ++retryCount) { + Response response = null; + Exception error = null; + try { + response = next.handle(request); + } + catch (Exception e) { + error = e; + } + + boolean shouldRetry = retryPolicy.shouldRetry(retryCount, response, error); + if (!shouldRetry) { + if (error != null) + throw error; + return response; + } + + int backoffTime = retryPolicy.calculateBackoff(retryCount, response, error); + log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", backoffTime, retryCount)); + backoff(backoffTime); + } + } + + private void backoff(int milliseconds) { + try { + Thread.sleep(milliseconds); + } + catch (InterruptedException e) { + // Restore the interrupted status + Thread.currentThread().interrupt(); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java index 504f899633584..5538d7be6ddba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java @@ -7,10 +7,10 @@ import javax.ws.rs.core.MultivaluedMap; public interface ServiceFilter { - Response handle(Request request, Next next); + Response handle(Request request, Next next) throws Exception; public interface Next { - Response handle(Request request); + Response handle(Request request) throws Exception; } public interface Request { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java index 6b8df9741c46d..60706db8a584b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java @@ -25,13 +25,18 @@ public ClientFilterAdapter(ServiceFilter filter) { public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { final ClientRequest cr = clientRequest; - Response resp = filter.handle(new ServiceFilterRequest(clientRequest), new ServiceFilter.Next() { - public Response handle(Request request) { - return new ServiceFilterResponse(getNext().handle(cr)); - } - }); - - return ((ServiceFilterResponse) resp).clientResponse; + try { + Response resp = filter.handle(new ServiceFilterRequest(clientRequest), new ServiceFilter.Next() { + public Response handle(Request request) { + return new ServiceFilterResponse(getNext().handle(cr)); + } + }); + + return ((ServiceFilterResponse) resp).clientResponse; + } + catch (Exception e) { + throw new ClientHandlerException(e); + } } } 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 1dc922e13c5f6..44fb7941ee478 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 @@ -22,7 +22,8 @@ import org.junit.Test; import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ExponentialRetryPolicyFilter; +import com.microsoft.windowsazure.common.ExponentialRetryPolicy; +import com.microsoft.windowsazure.common.RetryPolicyFilter; import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.models.AccessCondition; @@ -1273,7 +1274,7 @@ public void breakLeaseWorks() throws Exception { class RetryPolicyObserver implements ServiceFilter { public int requestCount; - public Response handle(Request request, Next next) { + public Response handle(Request request, Next next) throws Exception { requestCount++; return next.handle(request); } @@ -1288,7 +1289,8 @@ public void retryPolicyWorks() throws Exception { service = service.withFilter(observer); // Act - service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 3, new int[] { 400, 500, 503 })); + service = service + .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); ServiceException Error = null; try { @@ -1313,8 +1315,10 @@ public void retryPolicyCompositionWorks() throws Exception { service = service.withFilter(observer); // Act - service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 3, new int[] { 400, 500, 503 })); - service = service.withFilter(new ExponentialRetryPolicyFilter(ExponentialRetryPolicyFilter.DEFAULT_MIN_BACKOFF, 2, new int[] { 400, 500, 503 })); + service = service + .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); + service = service + .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 2/*maximumAttempts*/, new int[] { 400, 500, 503 }))); ServiceException Error = null; try { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 744e7a6f823fe..7cefcb81028c8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -18,9 +18,9 @@ protected static Configuration createConfiguration() { //setConfigValue(config, env, BlobConfiguration.URL, "http://127.0.0.1:10000/devstoreaccount1"); // Storage account support - setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); - setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); - setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "onesdktest"); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "X7jm3ar3rLmrNx4RUnX1/Blf01zdwreldbJNX+bnfmCQD//kR4qcJO+Amc8mS+4+l9L5i2cP215YccjpDogTOQ=="); + setConfigValue(config, env, BlobConfiguration.URL, "http://onesdktest.blob.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); 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 5c96a872956e0..57a3524fa2b7e 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, "X7jm3ar3rLmrNx4RUnX1/Blf01zdwreldbJNX+bnfmCQD//kR4qcJO+Amc8mS+4+l9L5i2cP215YccjpDogTOQ=="); + setConfigValue(config, env, QueueConfiguration.URL, "http://onesdktest.queue.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 47baab63bf9bb..ce3bcc5b44473 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -15,13 +15,6 @@ import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.common.ServiceFilter.Request; import com.microsoft.windowsazure.common.ServiceFilter.Response; -import com.microsoft.windowsazure.services.serviceBus.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.Message; -import com.microsoft.windowsazure.services.serviceBus.Queue; -import com.microsoft.windowsazure.services.serviceBus.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.Topic; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -192,8 +185,7 @@ public void contentTypePassesThrough() throws Exception { service.createQueue(new Queue(queueName)); // Act - service.sendQueueMessage(queueName, - new Message("Hello Again").setContentType("text/xml")); + service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS); @@ -230,7 +222,7 @@ public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { final List responses = new ArrayList(); ServiceBusContract filtered = service.withFilter(new ServiceFilter() { - public Response handle(Request request, Next next) { + public Response handle(Request request, Next next) throws Exception { requests.add(request); Response response = next.handle(request); responses.add(response); From ab0a365a68cd3aa6fc360031f22b8dc98ea4a2af Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 16 Nov 2011 11:20:46 -0800 Subject: [PATCH 198/664] Add missing "return this;" to options class --- .../services/queue/models/CreateMessageOptions.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java index a63f176723a4f..b68ae53dc8530 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.queue.models; - public class CreateMessageOptions extends QueueServiceOptions { private Integer visibilityTimeoutInSeconds; private Integer timeToLiveInSeconds; @@ -9,15 +8,17 @@ public Integer getVisibilityTimeoutInSeconds() { return visibilityTimeoutInSeconds; } - public void setVisibilityTimeoutInSeconds(Integer visibilityTimeoutInSeconds) { + public CreateMessageOptions setVisibilityTimeoutInSeconds(Integer visibilityTimeoutInSeconds) { this.visibilityTimeoutInSeconds = visibilityTimeoutInSeconds; + return this; } public Integer getTimeToLiveInSeconds() { return timeToLiveInSeconds; } - public void setTimeToLiveInSeconds(Integer timeToLiveInSeconds) { + public CreateMessageOptions setTimeToLiveInSeconds(Integer timeToLiveInSeconds) { this.timeToLiveInSeconds = timeToLiveInSeconds; + return this; } } From aca097fa96b74307820093747bb2367789018273 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 16 Nov 2011 11:15:42 -0800 Subject: [PATCH 199/664] Adding standard checkstyle.xml rules to config Defaults for maven checkstyle plugin are defined by the plugin as: http://svn.apache.org/viewvc/maven/plugins/tags/maven-checkstyle-plugin-2.8/src/main/resources/config/sun_checks.xml?view=co&revision=1188083&content-type=text%2Fplain --- microsoft-azure-api/pom.xml | 10 +- microsoft-azure-api/src/config/checkstyle.xml | 187 ++++++++++++++++++ 2 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/config/checkstyle.xml diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b725a1eea6ee1..7cff6a2e1a385 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -109,7 +109,15 @@ true - + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.8 + + src/config/checkstyle.xml + + diff --git a/microsoft-azure-api/src/config/checkstyle.xml b/microsoft-azure-api/src/config/checkstyle.xml new file mode 100644 index 0000000000000..655ed45e76079 --- /dev/null +++ b/microsoft-azure-api/src/config/checkstyle.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 865322cbc808ba5024b5791fba219cbe1d314b80 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 16 Nov 2011 11:17:22 -0800 Subject: [PATCH 200/664] Updating LineLength to validate with same limits as Eclipse settings --- microsoft-azure-api/src/config/checkstyle.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/config/checkstyle.xml b/microsoft-azure-api/src/config/checkstyle.xml index 655ed45e76079..0f628e43c5c52 100644 --- a/microsoft-azure-api/src/config/checkstyle.xml +++ b/microsoft-azure-api/src/config/checkstyle.xml @@ -118,7 +118,9 @@ - + + + From 44175cce02781433f8c8f0a38056ea74638c25a4 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 16 Nov 2011 13:24:21 -0800 Subject: [PATCH 201/664] Adding support for optional properties file Enables default Configuration to flow from a Java properties file. Components that fall-back to Configuration.getInstance() values can be created and used directly. --- .../configuration/Configuration.java | 35 ++++++++++++++++--- .../serviceBus/IntegrationTestBase.java | 16 +-------- .../serviceBus/ServiceBusIntegrationTest.java | 8 ++--- .../WrapRestProxyIntegrationTest.java | 10 ++++-- .../WrapTokenManagerIntegrationTest.java | 14 ++------ .../com.microsoft.windowsazure.properties | 5 +++ 6 files changed, 47 insertions(+), 41 deletions(-) create mode 100644 microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java index fd794ece45585..b7f6da6e63457 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/configuration/Configuration.java @@ -1,7 +1,13 @@ package com.microsoft.windowsazure.configuration; +import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.configuration.builder.Builder; import com.microsoft.windowsazure.configuration.builder.DefaultBuilder; @@ -13,6 +19,8 @@ public class Configuration { Map properties; Builder builder; + static Log log = LogFactory.getLog(Configuration.class); + public Configuration() { this.properties = new HashMap(); this.builder = DefaultBuilder.create(); @@ -38,8 +46,15 @@ private void init() { } public static Configuration getInstance() { - if (instance == null) - instance = Configuration.load(); + if (instance == null) { + try { + instance = Configuration.load(); + } + catch (IOException e) { + log.error("Unable to load META-INF/com.microsoft.windowsazure.properties", e); + instance = new Configuration(); + } + } return instance; } @@ -47,9 +62,19 @@ public static void setInstance(Configuration instance) { Configuration.instance = instance; } - public static Configuration load() { - // TODO - load from somewhere - return new Configuration(); + public static Configuration load() throws IOException { + Configuration config = new Configuration(); + + InputStream stream = Configuration.class.getClassLoader().getResourceAsStream("META-INF/com.microsoft.windowsazure.properties"); + if (stream != null) { + Properties properties = new Properties(); + properties.load(stream); + for (Object key : properties.keySet()) { + config.setProperty(key.toString(), properties.get(key)); + } + } + + return config; } public T create(Class service) throws Exception { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 0dbc7fbb6fceb..93ee9b4d96b71 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -5,25 +5,11 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.Queue; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.Topic; public abstract class IntegrationTestBase { - protected Configuration createConfiguration() { - Configuration config = new Configuration(); - ServiceBusConfiguration.configure(config, "lodejard", "owner", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - - // when mock running - //config.setProperty("serviceBus.uri", "http://localhost:8086"); - //config.setProperty("wrapClient.uri", "http://localhost:8081/WRAPv0.9"); - - return config; - } - @BeforeClass public static void initializeSystem() { System.out.println("initialize"); @@ -40,7 +26,7 @@ public void initialize() throws Exception { System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; - ServiceBusContract service = createConfiguration().create(ServiceBusContract.class); + ServiceBusContract service = new ServiceBusService(); for (Queue queue : iterateQueues(service)) { String queueName = queue.getName(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 0f47e6e3b9ee4..df53c0c953f34 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -11,7 +11,6 @@ import org.junit.Test; import com.microsoft.windowsazure.ServiceException; -import com.microsoft.windowsazure.configuration.Configuration; import com.microsoft.windowsazure.http.ServiceFilter; import com.microsoft.windowsazure.http.ServiceFilter.Request; import com.microsoft.windowsazure.http.ServiceFilter.Response; @@ -28,7 +27,6 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { - private Configuration config; private ServiceBusContract service; static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); @@ -36,8 +34,7 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { @Before public void createService() throws Exception { - config = createConfiguration(); - service = config.create(ServiceBusContract.class); + service = new ServiceBusService(); } @Test @@ -195,8 +192,7 @@ public void contentTypePassesThrough() throws Exception { service.createQueue(new Queue(queueName)); // Act - service.sendQueueMessage(queueName, - new Message("Hello Again").setContentType("text/xml")); + service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 5bafb7df76e91..e53abccec429b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -5,18 +5,22 @@ import org.junit.Test; import com.microsoft.windowsazure.configuration.Configuration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; import com.sun.jersey.api.client.Client; public class WrapRestProxyIntegrationTest { @Test public void serviceCanBeCalledToCreateAccessToken() throws Exception { // Arrange - Configuration config = new Configuration(); + Configuration config = Configuration.getInstance(); WrapContract contract = new WrapRestProxy(config.create(Client.class)); // Act - WrapAccessTokenResult result = contract.wrapAccessToken("https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9", "owner", - "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA=", "http://lodejard.servicebus.windows.net"); + String uri = (String) config.getProperty(ServiceBusConfiguration.WRAP_URI); + String name = (String) config.getProperty(ServiceBusConfiguration.WRAP_NAME); + String password = (String) config.getProperty(ServiceBusConfiguration.WRAP_PASSWORD); + String scope = (String) config.getProperty(ServiceBusConfiguration.WRAP_SCOPE); + WrapAccessTokenResult result = contract.wrapAccessToken(uri, name, password, scope); // Assert assertNotNull(result); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 361287d7ef09e..1769f0cb9c8f7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -5,23 +5,13 @@ import org.junit.Test; import com.microsoft.windowsazure.configuration.Configuration; -import com.microsoft.windowsazure.services.serviceBus.implementation.WrapTokenManager; public class WrapTokenManagerIntegrationTest { - private Configuration createConfiguration() { - Configuration config = new Configuration(); - config.setProperty("wrapClient.uri", "https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9"); - config.setProperty("wrapClient.scope", "http://lodejard.servicebus.windows.net/"); - config.setProperty("wrapClient.name", "owner"); - config.setProperty("wrapClient.password", "Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA="); - return config; - } - @Test public void wrapClientWillAcquireAccessToken() throws Exception { // Arrange - Configuration config = createConfiguration(); - WrapTokenManager client = config.create(WrapTokenManager.class); + Configuration config = Configuration.getInstance(); + WrapTokenManager client = config.create("serviceBus", WrapTokenManager.class); // Act String accessToken = client.getAccessToken(); diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties new file mode 100644 index 0000000000000..15229da1fdfdb --- /dev/null +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -0,0 +1,5 @@ +serviceBus.uri=https://lodejard.servicebus.windows.net/ +serviceBus.wrap.uri=https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9 +serviceBus.wrap.scope=http://lodejard.servicebus.windows.net/ +serviceBus.wrap.name=owner +serviceBus.wrap.password=Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA= From c94413e9ab50865a4f7a2653ddca9b49e0043f6c Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 16 Nov 2011 17:07:57 -0800 Subject: [PATCH 202/664] Change line wrapping to 120 columns --- microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs index 171b944f2d2ac..8b76cb8c6c0f7 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 @@ -#Sat Nov 12 18:37:54 PST 2011 +#Wed Nov 16 15:46:43 PST 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -275,7 +275,7 @@ 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 org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=160 +org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 From 3d025740a857a9dfb6c061efa1d17d08393cb9e8 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 17 Nov 2011 10:37:17 -0800 Subject: [PATCH 203/664] Remove account info --- .../windowsazure/services/blob/IntegrationTestBase.java | 6 +++--- .../windowsazure/services/queue/IntegrationTestBase.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 7cefcb81028c8..744e7a6f823fe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -18,9 +18,9 @@ protected static Configuration createConfiguration() { //setConfigValue(config, env, BlobConfiguration.URL, "http://127.0.0.1:10000/devstoreaccount1"); // Storage account support - setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "onesdktest"); - setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "X7jm3ar3rLmrNx4RUnX1/Blf01zdwreldbJNX+bnfmCQD//kR4qcJO+Amc8mS+4+l9L5i2cP215YccjpDogTOQ=="); - setConfigValue(config, env, BlobConfiguration.URL, "http://onesdktest.blob.core.windows.net"); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); + setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); + setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); // when mock running // config.setProperty("serviceBus.uri", "http://localhost:8086"); 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 57a3524fa2b7e..5c96a872956e0 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, "X7jm3ar3rLmrNx4RUnX1/Blf01zdwreldbJNX+bnfmCQD//kR4qcJO+Amc8mS+4+l9L5i2cP215YccjpDogTOQ=="); - 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 20c2ce214eee03868f029504d0b6dfc38a96a3b0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 17 Nov 2011 10:46:48 -0800 Subject: [PATCH 204/664] Removing unused code --- .../services/blob/IntegrationTestBase.java | 11 ----------- .../services/queue/IntegrationTestBase.java | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 744e7a6f823fe..450f2c428afc1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -22,11 +22,6 @@ protected static Configuration createConfiguration() { setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); - // when mock running - // config.setProperty("serviceBus.uri", "http://localhost:8086"); - // config.setProperty("wrapClient.uri", - // "http://localhost:8081/WRAPv0.9"); - return config; } @@ -41,16 +36,10 @@ private static void setConfigValue(Configuration config, Map pro @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/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java index 5c96a872956e0..0154fda420244 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 @@ -22,11 +22,6 @@ protected static Configuration createConfiguration() { 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; } @@ -41,16 +36,10 @@ private static void setConfigValue(Configuration config, Map pro @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"); } } From 7b0e3a67b63da69374631f55b9d4a3b78f57c918 Mon Sep 17 00:00:00 2001 From: Walter Blaurock Date: Thu, 17 Nov 2011 11:00:25 -0800 Subject: [PATCH 205/664] Following changes were made: removed all instances of @author. Removed all instances of Copyright from doc comments. Applied OneSDK formatting. Change java.util.Calendar to java.util.Date in one public-facing method. --- .../serviceruntime/AcquireCurrentState.java | 3 +- .../ChunkedGoalStateDeserializer.java | 12 +- .../serviceruntime/FileInputChannel.java | 3 +- .../serviceruntime/FileOutputChannel.java | 3 +- .../serviceruntime/GoalState.java | 3 +- .../serviceruntime/LocalResource.java | 4 - .../Protocol1RuntimeClient.java | 9 +- .../Protocol1RuntimeCurrentStateClient.java | 9 +- .../Protocol1RuntimeGoalStateClient.java | 24 +- .../windowsazure/serviceruntime/Role.java | 11 +- .../serviceruntime/RoleEnvironment.java | 336 ++++++------- .../serviceruntime/RoleEnvironmentChange.java | 5 - .../RoleEnvironmentChangedEvent.java | 9 +- .../RoleEnvironmentChangedListener.java | 8 +- .../RoleEnvironmentChangingEvent.java | 27 +- .../RoleEnvironmentChangingListener.java | 23 +- ...EnvironmentConfigurationSettingChange.java | 7 +- .../serviceruntime/RoleEnvironmentData.java | 6 +- .../RoleEnvironmentNotAvailableException.java | 8 +- .../RoleEnvironmentStoppingListener.java | 9 +- .../RoleEnvironmentTopologyChange.java | 7 +- .../serviceruntime/RoleInstance.java | 15 +- .../serviceruntime/RoleInstanceEndpoint.java | 5 - .../serviceruntime/RoleInstanceStatus.java | 8 +- .../serviceruntime/RuntimeClient.java | 3 +- .../RuntimeGoalStateClient.java | 3 +- .../serviceruntime/RuntimeKernel.java | 15 +- .../serviceruntime/RuntimeVersionManager.java | 12 +- .../RuntimeVersionProtocolClient.java | 11 +- .../XmlCurrentStateSerializer.java | 33 +- .../XmlGoalStateDeserializer.java | 18 +- .../XmlRoleEnvironmentDataDeserializer.java | 95 ++-- .../windowsazure/serviceruntime/overview.html | 2 +- .../windowsazure/serviceruntime/package.html | 2 +- .../serviceruntime/FileInputChannelTests.java | 40 +- .../serviceruntime/MockInputChannel.java | 109 ++-- ...otocol1RuntimeCurrentStateClientTests.java | 169 ++++--- .../Protocol1RuntimeGoalStateClientTests.java | 475 +++++++++--------- .../serviceruntime/RoleEnvironmentTests.java | 88 ++-- .../RuntimeVersionManagerTests.java | 169 +++---- .../XmlGoalStateDeserializerTests.java | 9 +- 41 files changed, 804 insertions(+), 1003 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java index 70ec3914a6875..6b8c9b5fb11c0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java @@ -11,8 +11,7 @@ class AcquireCurrentState extends CurrentState { private final CurrentStatus status; private final Calendar expiration; - public AcquireCurrentState(String clientId, BigInteger incarnation, - CurrentStatus status, Calendar expiration) { + public AcquireCurrentState(String clientId, BigInteger incarnation, CurrentStatus status, Calendar expiration) { super(clientId); this.incarnation = incarnation; this.status = status; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java index 10abb5956fb44..f672cc4b7129a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -17,9 +17,9 @@ public ChunkedGoalStateDeserializer() { @Override public void initialize(InputStream inputStream) { try { - reader = new BufferedReader(new InputStreamReader(inputStream, - "UTF-8")); - } catch (UnsupportedEncodingException e) { + reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); + } + catch (UnsupportedEncodingException e) { e.printStackTrace(); } } @@ -38,13 +38,13 @@ public GoalState deserialize() { reader.read(chunkData, 0, length); - GoalState goalState = deserializer - .deserialize(new String(chunkData)); + GoalState goalState = deserializer.deserialize(new String(chunkData)); reader.readLine(); return goalState; - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); return null; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java index 6681d688cf6fc..8a48aa5d3907a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java @@ -17,7 +17,8 @@ public FileInputChannel() { public InputStream getInputStream(String name) { try { return new FileInputStream(name); - } catch (FileNotFoundException e) { + } + catch (FileNotFoundException e) { throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java index 499197828681a..84c3d054c7b8b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java @@ -17,7 +17,8 @@ public FileOutputChannel() { public OutputStream getOutputStream(String name) { try { return new FileOutputStream(name); - } catch (FileNotFoundException e) { + } + catch (FileNotFoundException e) { throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java index ca18e97d2c53b..bbe808ddd784f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java @@ -16,8 +16,7 @@ class GoalState { private final Calendar deadline; private final String currentStateEndpoint; - public GoalState(BigInteger incarnation, ExpectedState expectedState, - String environmentPath, Calendar deadline, + public GoalState(BigInteger incarnation, ExpectedState expectedState, String environmentPath, Calendar deadline, String currentStateEndpoint) { this.incarnation = incarnation; this.expectedState = expectedState; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java index 71a2a5147043d..a52c64f5568ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java @@ -2,10 +2,6 @@ /** * Represents a local storage resource reserved for a service. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok */ public final class LocalResource { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java index de419213f8d50..8576109559799 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java @@ -10,10 +10,8 @@ class Protocol1RuntimeClient implements RuntimeClient { private final Protocol1RuntimeGoalStateClient goalStateClient; private final Protocol1RuntimeCurrentStateClient currentStateClient; - public Protocol1RuntimeClient( - Protocol1RuntimeGoalStateClient goalStateClient, - Protocol1RuntimeCurrentStateClient currentStateClient, - String endpoint) { + public Protocol1RuntimeClient(Protocol1RuntimeGoalStateClient goalStateClient, + Protocol1RuntimeCurrentStateClient currentStateClient, String endpoint) { this.goalStateClient = goalStateClient; this.currentStateClient = currentStateClient; @@ -26,8 +24,7 @@ public GoalState getCurrentGoalState() throws InterruptedException { } @Override - public RoleEnvironmentData getRoleEnvironmentData() - throws InterruptedException { + public RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException { return goalStateClient.getRoleEnvironmentData(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java index 48e33a719258f..fb196429a1b9f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java @@ -15,8 +15,7 @@ class Protocol1RuntimeCurrentStateClient implements RuntimeCurrentStateClient { private final OutputChannel outputChannel; private final AtomicReference endpoint; - public Protocol1RuntimeCurrentStateClient( - CurrentStateSerializer serializer, OutputChannel outputChannel) { + public Protocol1RuntimeCurrentStateClient(CurrentStateSerializer serializer, OutputChannel outputChannel) { this.serializer = serializer; this.outputChannel = outputChannel; this.endpoint = new AtomicReference(); @@ -28,14 +27,14 @@ public void setEndpoint(String endpoint) { @Override public void setCurrentState(CurrentState state) { - OutputStream outputStream = outputChannel.getOutputStream(endpoint - .get()); + OutputStream outputStream = outputChannel.getOutputStream(endpoint.get()); serializer.serialize(state, outputStream); try { outputStream.close(); - } catch (IOException e) { + } + catch (IOException e) { throw new RoleEnvironmentNotAvailableException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java index a1457962c88bb..333304ba268b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java @@ -26,10 +26,8 @@ class Protocol1RuntimeGoalStateClient implements RuntimeGoalStateClient { private AtomicReference currentGoalState; private AtomicReference currentEnvironmentData; - public Protocol1RuntimeGoalStateClient( - Protocol1RuntimeCurrentStateClient currentStateClient, - GoalStateDeserializer goalStateDeserializer, - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer, + public Protocol1RuntimeGoalStateClient(Protocol1RuntimeCurrentStateClient currentStateClient, + GoalStateDeserializer goalStateDeserializer, RoleEnvironmentDataDeserializer roleEnvironmentDeserializer, InputChannel inputChannel) { this.currentStateClient = currentStateClient; this.goalStateDeserializer = goalStateDeserializer; @@ -49,23 +47,19 @@ public GoalState getCurrentGoalState() throws InterruptedException { return currentGoalState.get(); } - public synchronized RoleEnvironmentData getRoleEnvironmentData() - throws InterruptedException { + public synchronized RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException { ensureGoalStateRetrieved(); if (currentEnvironmentData.get() == null) { GoalState current = currentGoalState.get(); if (current.getEnvironmentPath() == null) { - throw new InterruptedException( - "No role environment data for the current goal state."); + throw new InterruptedException("No role environment data for the current goal state."); } - InputStream environmentStream = inputChannel.getInputStream(current - .getEnvironmentPath()); + InputStream environmentStream = inputChannel.getInputStream(current.getEnvironmentPath()); - currentEnvironmentData.set(roleEnvironmentDeserializer - .deserialize(environmentStream)); + currentEnvironmentData.set(roleEnvironmentDeserializer.deserialize(environmentStream)); } return currentEnvironmentData.get(); @@ -118,8 +112,7 @@ public void run() { currentEnvironmentData.set(null); } - currentStateClient.setEndpoint(currentGoalState.get() - .getCurrentStateEndpoint()); + currentStateClient.setEndpoint(currentGoalState.get().getCurrentStateEndpoint()); goalStateLatch.countDown(); @@ -136,8 +129,7 @@ public void run() { currentEnvironmentData.set(null); } - currentStateClient.setEndpoint(currentGoalState.get() - .getCurrentStateEndpoint()); + currentStateClient.setEndpoint(currentGoalState.get().getCurrentStateEndpoint()); for (GoalStateChangedListener listener : listeners) { listener.goalStateChanged(currentGoalState.get()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java index 62aa134e39e87..85c4148b4fba1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java @@ -4,10 +4,6 @@ /** * Represents a role that is defined as part of a hosted service. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok */ public final class Role { private final String name; @@ -27,11 +23,10 @@ public final class Role { /** * Returns the collection of instances for the role. *

- * The number of instances of a role to be deployed to Windows Azure is - * specified in the service's configuration file. + * The number of instances of a role to be deployed to Windows Azure is specified in the service's configuration + * file. *

- * A role must define at least one internal endpoint in order for its set of - * instances to be known at runtime. + * A role must define at least one internal endpoint in order for its set of instances to be known at runtime. * * @return A read-only java.util.Map object that contains the * instances for the role, or null if the instances diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index d8015c1be4cc7..033003d7e1941 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -1,6 +1,7 @@ package com.microsoft.windowsazure.serviceruntime; import java.util.Calendar; +import java.util.Date; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -15,10 +16,6 @@ /** * Represents the Windows Azure environment in which an instance of a role is * running. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok */ public final class RoleEnvironment { private static final String VersionEndpointEnvironmentName = "WaRuntimeEndpoint"; @@ -36,15 +33,14 @@ public final class RoleEnvironment { static { try { - JAXBContext.newInstance(RoleEnvironment.class.getPackage() - .getName()); - } catch (JAXBException e) { + JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName()); + } + catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } clientId = UUID.randomUUID().toString(); - maxDateTime = javax.xml.bind.DatatypeConverter - .parseDateTime("9999-12-31T23:59:59.9999999"); + maxDateTime = javax.xml.bind.DatatypeConverter.parseDateTime("9999-12-31T23:59:59.9999999"); } private RoleEnvironment() { @@ -61,9 +57,9 @@ private static synchronized void initialize() { RuntimeKernel kernel = RuntimeKernel.getKernel(); try { - runtimeClient = kernel.getRuntimeVersionManager() - .getRuntimeClient(endpoint); - } catch (Throwable t) { + runtimeClient = kernel.getRuntimeVersionManager().getRuntimeClient(endpoint); + } + catch (Throwable t) { throw new RoleEnvironmentNotAvailableException(t); } @@ -72,47 +68,42 @@ private static synchronized void initialize() { stoppingListeners = new LinkedList(); try { - currentGoalState = new AtomicReference( - runtimeClient.getCurrentGoalState()); + currentGoalState = new AtomicReference(runtimeClient.getCurrentGoalState()); currentEnvironmentData = new AtomicReference( runtimeClient.getRoleEnvironmentData()); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { throw new RoleEnvironmentNotAvailableException(e); } lastState = new AtomicReference(); - runtimeClient - .addGoalStateChangedListener(new GoalStateChangedListener() { - public void goalStateChanged(GoalState newGoalState) { - switch (newGoalState.getExpectedState()) { - case STARTED: - if (newGoalState.getIncarnation() - .compareTo( - currentGoalState.get() - .getIncarnation()) > 0) { - processGoalStateChange(newGoalState); - } - break; - case STOPPED: - raiseStoppingEvent(); + runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() { + public void goalStateChanged(GoalState newGoalState) { + switch (newGoalState.getExpectedState()) { + case STARTED: + if (newGoalState.getIncarnation().compareTo(currentGoalState.get().getIncarnation()) > 0) { + processGoalStateChange(newGoalState); + } + break; + case STOPPED: + raiseStoppingEvent(); - CurrentState stoppedState = new AcquireCurrentState( - clientId, - newGoalState.getIncarnation(), - CurrentStatus.STOPPED, maxDateTime); + CurrentState stoppedState = new AcquireCurrentState(clientId, + newGoalState.getIncarnation(), CurrentStatus.STOPPED, maxDateTime); - runtimeClient.setCurrentState(stoppedState); - break; - } - } - }); - } else { + runtimeClient.setCurrentState(stoppedState); + break; + } + } + }); + } + else { try { currentGoalState.set(runtimeClient.getCurrentGoalState()); - currentEnvironmentData.set(runtimeClient - .getRoleEnvironmentData()); - } catch (InterruptedException e) { + currentEnvironmentData.set(runtimeClient.getRoleEnvironmentData()); + } + catch (InterruptedException e) { throw new RoleEnvironmentNotAvailableException(e); } } @@ -120,27 +111,27 @@ public void goalStateChanged(GoalState newGoalState) { private static void processGoalStateChange(GoalState newGoalState) { List changes = new LinkedList(); - RoleEnvironmentChangingEvent changingEvent = new RoleEnvironmentChangingEvent( - changes); + RoleEnvironmentChangingEvent changingEvent = new RoleEnvironmentChangingEvent(changes); CurrentState last = lastState.get(); calculateChanges(changes); if (changes.isEmpty()) { acceptLatestIncarnation(newGoalState, last); - } else { + } + else { for (RoleEnvironmentChangingListener listener : changingListeners) { try { listener.roleEnvironmentChanging(changingEvent); - } catch (Throwable t) { + } + catch (Throwable t) { t.printStackTrace(); } } if (changingEvent.isCancelled()) { - CurrentState recycleState = new AcquireCurrentState(clientId, - newGoalState.getIncarnation(), CurrentStatus.RECYCLE, - maxDateTime); + CurrentState recycleState = new AcquireCurrentState(clientId, newGoalState.getIncarnation(), + CurrentStatus.RECYCLE, maxDateTime); runtimeClient.setCurrentState(recycleState); @@ -150,31 +141,29 @@ private static void processGoalStateChange(GoalState newGoalState) { acceptLatestIncarnation(newGoalState, last); try { - currentEnvironmentData.set(runtimeClient - .getRoleEnvironmentData()); - } catch (InterruptedException e) { + currentEnvironmentData.set(runtimeClient.getRoleEnvironmentData()); + } + catch (InterruptedException e) { throw new RoleEnvironmentNotAvailableException(e); } for (RoleEnvironmentChangedListener listener : changedListeners) { try { - listener.roleEnvironmentChanged(new RoleEnvironmentChangedEvent( - changes)); - } catch (Throwable t) { + listener.roleEnvironmentChanged(new RoleEnvironmentChangedEvent(changes)); + } + catch (Throwable t) { t.printStackTrace(); } } } } - private static void acceptLatestIncarnation(GoalState newGoalState, - CurrentState last) { + private static void acceptLatestIncarnation(GoalState newGoalState, CurrentState last) { if (last != null && last instanceof AcquireCurrentState) { AcquireCurrentState acquireState = (AcquireCurrentState) last; - CurrentState acceptState = new AcquireCurrentState(clientId, - newGoalState.getIncarnation(), acquireState.getStatus(), - acquireState.getExpiration()); + CurrentState acceptState = new AcquireCurrentState(clientId, newGoalState.getIncarnation(), + acquireState.getStatus(), acquireState.getExpiration()); runtimeClient.setCurrentState(acceptState); } @@ -188,7 +177,8 @@ private static void calculateChanges(List changes) { try { newData = runtimeClient.getRoleEnvironmentData(); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { throw new RoleEnvironmentNotAvailableException(e); } @@ -200,19 +190,17 @@ private static void calculateChanges(List changes) { for (String setting : currentConfig.keySet()) { if (newConfig.containsKey(setting)) { if (!newConfig.get(setting).equals(currentConfig.get(setting))) { - changes.add(new RoleEnvironmentConfigurationSettingChange( - setting)); + changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); } - } else { - changes.add(new RoleEnvironmentConfigurationSettingChange( - setting)); + } + else { + changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); } } for (String setting : newConfig.keySet()) { if (!currentConfig.containsKey(setting)) { - changes.add(new RoleEnvironmentConfigurationSettingChange( - setting)); + changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); } } @@ -225,45 +213,37 @@ private static void calculateChanges(List changes) { for (String instance : currentRole.getInstances().keySet()) { if (newRole.getInstances().containsKey(instance)) { - RoleInstance currentInstance = currentRole - .getInstances().get(instance); - RoleInstance newInstance = newRole.getInstances().get( - instance); - - if (currentInstance.getUpdateDomain() == newInstance - .getUpdateDomain() - && currentInstance.getFaultDomain() == newInstance - .getFaultDomain()) { - for (String endpoint : currentInstance - .getInstanceEndpoints().keySet()) { - if (newInstance.getInstanceEndpoints() - .containsKey(endpoint)) { - RoleInstanceEndpoint currentEndpoint = currentInstance - .getInstanceEndpoints().get( - endpoint); - RoleInstanceEndpoint newEndpoint = newInstance - .getInstanceEndpoints().get( - endpoint); - - if (!currentEndpoint.getProtocol().equals( - newEndpoint.getProtocol()) - || !currentEndpoint.getIpEndPoint() - .equals(newEndpoint - .getIpEndPoint())) { + RoleInstance currentInstance = currentRole.getInstances().get(instance); + RoleInstance newInstance = newRole.getInstances().get(instance); + + if (currentInstance.getUpdateDomain() == newInstance.getUpdateDomain() + && currentInstance.getFaultDomain() == newInstance.getFaultDomain()) { + for (String endpoint : currentInstance.getInstanceEndpoints().keySet()) { + if (newInstance.getInstanceEndpoints().containsKey(endpoint)) { + RoleInstanceEndpoint currentEndpoint = currentInstance.getInstanceEndpoints().get( + endpoint); + RoleInstanceEndpoint newEndpoint = newInstance.getInstanceEndpoints().get(endpoint); + + if (!currentEndpoint.getProtocol().equals(newEndpoint.getProtocol()) + || !currentEndpoint.getIpEndPoint().equals(newEndpoint.getIpEndPoint())) { changedRoleSet.add(role); } - } else { + } + else { changedRoleSet.add(role); } } - } else { + } + else { changedRoleSet.add(role); } - } else { + } + else { changedRoleSet.add(role); } } - } else { + } + else { changedRoleSet.add(role); } } @@ -275,45 +255,37 @@ private static void calculateChanges(List changes) { for (String instance : newRole.getInstances().keySet()) { if (currentRole.getInstances().containsKey(instance)) { - RoleInstance currentInstance = currentRole - .getInstances().get(instance); - RoleInstance newInstance = newRole.getInstances().get( - instance); - - if (currentInstance.getUpdateDomain() == newInstance - .getUpdateDomain() - && currentInstance.getFaultDomain() == newInstance - .getFaultDomain()) { - for (String endpoint : newInstance - .getInstanceEndpoints().keySet()) { - if (currentInstance.getInstanceEndpoints() - .containsKey(endpoint)) { - RoleInstanceEndpoint currentEndpoint = currentInstance - .getInstanceEndpoints().get( - endpoint); - RoleInstanceEndpoint newEndpoint = newInstance - .getInstanceEndpoints().get( - endpoint); - - if (!currentEndpoint.getProtocol().equals( - newEndpoint.getProtocol()) - || !currentEndpoint.getIpEndPoint() - .equals(newEndpoint - .getIpEndPoint())) { + RoleInstance currentInstance = currentRole.getInstances().get(instance); + RoleInstance newInstance = newRole.getInstances().get(instance); + + if (currentInstance.getUpdateDomain() == newInstance.getUpdateDomain() + && currentInstance.getFaultDomain() == newInstance.getFaultDomain()) { + for (String endpoint : newInstance.getInstanceEndpoints().keySet()) { + if (currentInstance.getInstanceEndpoints().containsKey(endpoint)) { + RoleInstanceEndpoint currentEndpoint = currentInstance.getInstanceEndpoints().get( + endpoint); + RoleInstanceEndpoint newEndpoint = newInstance.getInstanceEndpoints().get(endpoint); + + if (!currentEndpoint.getProtocol().equals(newEndpoint.getProtocol()) + || !currentEndpoint.getIpEndPoint().equals(newEndpoint.getIpEndPoint())) { changedRoleSet.add(role); } - } else { + } + else { changedRoleSet.add(role); } } - } else { + } + else { changedRoleSet.add(role); } - } else { + } + else { changedRoleSet.add(role); } } - } else { + } + else { changedRoleSet.add(role); } } @@ -327,7 +299,8 @@ private static synchronized void raiseStoppingEvent() { for (RoleEnvironmentStoppingListener listener : stoppingListeners) { try { listener.roleEnvironmentStopping(); - } catch (Throwable t) { + } + catch (Throwable t) { t.printStackTrace(); } } @@ -369,7 +342,8 @@ public static String getDeploymentId() { public static boolean isAvailable() { try { initialize(); - } catch (RoleEnvironmentNotAvailableException ex) { + } + catch (RoleEnvironmentNotAvailableException ex) { } return runtimeClient != null; @@ -392,8 +366,8 @@ public static boolean isEmulated() { *

* Roles are defined in the service definition file. * - * @return A java.util.Map object containing the set of - * {@link Role} objects that represent the roles defined for your + * @return A java.util.Map object containing the set of {@link Role} objects that represent the roles + * defined for your * service. */ public static Map getRoles() { @@ -405,12 +379,11 @@ public static Map getRoles() { /** * Retrieves the settings in the service configuration file. *

- * A role's configuration settings are defined in the service definition - * file. Values for configuration settings are set in the service - * configuration file. + * A role's configuration settings are defined in the service definition file. Values for configuration settings are + * set in the service configuration file. * - * @return A java.util.Map object containing the - * String objects that represent the configuration + * @return A java.util.Map object containing the String objects that represent the + * configuration * settings. */ public static Map getConfigurationSettings() { @@ -422,8 +395,8 @@ public static Map getConfigurationSettings() { /** * Retrieves the set of named local storage resources. * - * @return A java.util.Map object containing the - * String objects that represent the local storage + * @return A java.util.Map object containing the String objects that represent the local + * storage * resources. */ public static Map getLocalResources() { @@ -435,21 +408,18 @@ public static Map getLocalResources() { /** * Requests that the current role instance be stopped and restarted. *

- * Before the role instance is recycled, the Windows Azure load balancer - * takes the role instance out of rotation. This ensures that no new - * requests are routed to the instance while it is restarting. + * Before the role instance is recycled, the Windows Azure load balancer takes the role instance out of rotation. + * This ensures that no new requests are routed to the instance while it is restarting. * - * A call to RequestRecycle initiates the normal shutdown - * cycle. Windows Azure raises the Stopping event and calls the - * OnStop method so that you can run the necessary code to + * A call to RequestRecycle initiates the normal shutdown cycle. Windows Azure raises the + * Stopping event and calls the OnStop method so that you can run the necessary code to * prepare the instance to be recycled. */ public static void requestRecycle() { initialize(); - CurrentState recycleState = new AcquireCurrentState(clientId, - currentGoalState.get().getIncarnation(), CurrentStatus.RECYCLE, - maxDateTime); + CurrentState recycleState = new AcquireCurrentState(clientId, currentGoalState.get().getIncarnation(), + CurrentStatus.RECYCLE, maxDateTime); runtimeClient.setCurrentState(recycleState); } @@ -457,35 +427,36 @@ public static void requestRecycle() { /** * Sets the status of the role instance. *

- * An instance may indicate that it is in one of two states: Ready or Busy. - * If an instance's state is Ready, it is prepared to receive requests from - * the load balancer. If the instance's state is Busy, it will not receive + * An instance may indicate that it is in one of two states: Ready or Busy. If an instance's state is Ready, it is + * prepared to receive requests from the load balancer. If the instance's state is Busy, it will not receive * requests from the load balancer. * * @param status * A {@link RoleInstanceStatus} value that indicates whether the * instance is ready or busy. - * @param expiration - * A java.util.Calendar value that specifies the + * @param expiration_utc + * A java.util.Date value that specifies the * expiration date and time of the status. * */ - public static void setStatus(RoleInstanceStatus status, Calendar expiration) { + public static void setStatus(RoleInstanceStatus status, Date expiration_utc) { initialize(); CurrentStatus currentStatus = CurrentStatus.STARTED; switch (status) { - case Busy: - currentStatus = CurrentStatus.BUSY; - break; - case Ready: - currentStatus = CurrentStatus.STARTED; + case Busy: + currentStatus = CurrentStatus.BUSY; + break; + case Ready: + currentStatus = CurrentStatus.STARTED; } - CurrentState newState = new AcquireCurrentState(clientId, - currentGoalState.get().getIncarnation(), currentStatus, - expiration); + Calendar expiration = Calendar.getInstance(); + expiration.setTime(expiration_utc); + + CurrentState newState = new AcquireCurrentState(clientId, currentGoalState.get().getIncarnation(), + currentStatus, expiration); lastState.set(newState); @@ -495,8 +466,7 @@ public static void setStatus(RoleInstanceStatus status, Calendar expiration) { /** * Clears the status of the role instance. *

- * An instance may indicate that it has completed communicating status by - * calling this method. + * An instance may indicate that it has completed communicating status by calling this method. * */ public static void clearStatus() { @@ -513,8 +483,7 @@ public static void clearStatus() { * Adds an event listener for the Changed event, which occurs * after a configuration change has been applied to a role instance. *

- * A Changed event is encapsulated in a - * {@link RoleEnvironmentChangedEvent} object. + * A Changed event is encapsulated in a {@link RoleEnvironmentChangedEvent} object. * * @param listener * A {@link RoleEnvironmentChangedListener} object that @@ -522,8 +491,7 @@ public static void clearStatus() { * * @see #removeRoleEnvironmentChangedListener */ - public static synchronized void addRoleEnvironmentChangedListener( - RoleEnvironmentChangedListener listener) { + public static synchronized void addRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener) { initialize(); changedListeners.add(listener); @@ -538,8 +506,7 @@ public static synchronized void addRoleEnvironmentChangedListener( * * @see #addRoleEnvironmentChangedListener */ - public static synchronized void removeRoleEnvironmentChangedListener( - RoleEnvironmentChangedListener listener) { + public static synchronized void removeRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener) { initialize(); changedListeners.remove(listener); @@ -550,22 +517,17 @@ public static synchronized void removeRoleEnvironmentChangedListener( * before a change to the service configuration is applied to the running * instances of the role. *

- * Service configuration changes are applied on-the-fly to running role - * instances. Configuration changes include changes to the service - * configuration changes and changes to the number of instances in the - * service. + * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include + * changes to the service configuration changes and changes to the number of instances in the service. *

- * This event occurs after the new configuration file has been submitted to - * Windows Azure but before the changes have been applied to each running - * role instance. This event can be cancelled for a given instance to - * prevent the configuration change. + * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes + * have been applied to each running role instance. This event can be cancelled for a given instance to prevent the + * configuration change. *

- * Note that cancelling this event causes the instance to be automatically - * recycled. When the instance is recycled, the configuration change is - * applied when it restarts. + * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, + * the configuration change is applied when it restarts. *

- * A Changing event is encapsulated in a - * {@link RoleEnvironmentChangingEvent} object. + * A Changing event is encapsulated in a {@link RoleEnvironmentChangingEvent} object. * * @param listener * A {@link RoleEnvironmentChangingListener} object that @@ -573,8 +535,7 @@ public static synchronized void removeRoleEnvironmentChangedListener( * * @see #removeRoleEnvironmentChangingListener */ - public static synchronized void addRoleEnvironmentChangingListener( - RoleEnvironmentChangingListener listener) { + public static synchronized void addRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener) { initialize(); changingListeners.add(listener); @@ -589,8 +550,7 @@ public static synchronized void addRoleEnvironmentChangingListener( * * @see #addRoleEnvironmentChangingListener */ - public static void removeRoleEnvironmentChangingListener( - RoleEnvironmentChangingListener listener) { + public static void removeRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener) { initialize(); changingListeners.remove(listener); @@ -606,8 +566,7 @@ public static void removeRoleEnvironmentChangingListener( * * @see #removeRoleEnvironmentStoppingListener */ - public static synchronized void addRoleEnvironmentStoppingListener( - RoleEnvironmentStoppingListener listener) { + public static synchronized void addRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener) { initialize(); stoppingListeners.add(listener); @@ -622,8 +581,7 @@ public static synchronized void addRoleEnvironmentStoppingListener( * * @see #addRoleEnvironmentStoppingListener */ - public static synchronized void removeRoleEnvironmentStoppingListener( - RoleEnvironmentStoppingListener listener) { + public static synchronized void removeRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener) { initialize(); stoppingListeners.remove(listener); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java index 471be6da8a914..6e5c5646518ea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java @@ -2,11 +2,6 @@ /** * Abstract class that represents a change to the service's configuration. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * */ public abstract class RoleEnvironmentChange { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java index 34869c8e614ff..8627ac2768f82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java @@ -5,11 +5,6 @@ /** * Occurs after a change to the service configuration has been applied to the * running instances of the role. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * */ public class RoleEnvironmentChangedEvent { @@ -28,8 +23,8 @@ public class RoleEnvironmentChangedEvent { * Returns a collection of the configuration changes that were applied to * the role instance. * - * @return A java.util.Collection object containing the - * {@link RoleEnvironmentChange} objects that represent the + * @return A java.util.Collection object containing the {@link RoleEnvironmentChange} objects that + * represent the * configuration changes that were applied to the role instance. * * @see RoleEnvironmentChange diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java index 01d1ad226971a..ce3badacf8e3d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java @@ -3,13 +3,7 @@ /** * Represents the listener for the environment changed event. *

- * The environment changed event is encapsulated in a - * {@link RoleEnvironmentChangedEvent} object. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * + * The environment changed event is encapsulated in a {@link RoleEnvironmentChangedEvent} object. */ public interface RoleEnvironmentChangedListener { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java index 4a733eb28b5a0..9159a890944f6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java @@ -7,22 +7,15 @@ * Occurs before a change to the service configuration is applied to the running * instances of the role. *

- * Service configuration changes are applied on-the-fly to running role - * instances. Configuration changes include changes to the service configuration - * changes and changes to the number of instances in the service. + * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include changes + * to the service configuration changes and changes to the number of instances in the service. *

- * This event occurs after the new configuration file has been submitted to - * Windows Azure but before the changes have been applied to each running role - * instance. This event can be cancelled for a given instance to prevent the + * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes have + * been applied to each running role instance. This event can be cancelled for a given instance to prevent the * configuration change. *

- * Note that cancelling this event causes the instance to be automatically - * recycled. When the instance is recycled, the configuration change is applied - * when it restarts. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok + * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, the + * configuration change is applied when it restarts. * * @see RoleEnvironmentChangingListener * @see RoleEnvironmentChangedEvent @@ -40,8 +33,8 @@ public class RoleEnvironmentChangingEvent { /** * Cancel the configuration change. *

- * Cancellation causes the role instance to be immediately recycled. The - * configuration changes are applied when the instance restarts. + * Cancellation causes the role instance to be immediately recycled. The configuration changes are applied when the + * instance restarts. * */ public void cancel() { @@ -56,8 +49,8 @@ boolean isCancelled() { * Returns a collection of the configuration changes that are about to be * applied to the role instance. * - * @return A java.util.Collection object containing - * {@link RoleEnvironmentChange} objects that represent the + * @return A java.util.Collection object containing {@link RoleEnvironmentChange} objects that + * represent the * configuration changes that are about to be applied to the role * instance. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java index 9d541fdbc54d0..4b2ab7adf15b4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java @@ -5,11 +5,6 @@ *

* The environment changing event is encapsulated in an * {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangingEvent} object. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * */ public interface RoleEnvironmentChangingListener { @@ -17,19 +12,15 @@ public interface RoleEnvironmentChangingListener { * Occurs before a change to the service configuration is applied to the * running instances of the role. *

- * Service configuration changes are applied on-the-fly to running role - * instances. Configuration changes include changes to the service - * configuration changes and changes to the number of instances in the - * service. + * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include + * changes to the service configuration changes and changes to the number of instances in the service. *

- * This event occurs after the new configuration file has been submitted to - * Windows Azure but before the changes have been applied to each running - * role instance. This event can be cancelled for a given instance to - * prevent the configuration change. + * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes + * have been applied to each running role instance. This event can be cancelled for a given instance to prevent the + * configuration change. *

- * Note that cancelling this event causes the instance to be automatically - * recycled. When the instance is recycled, the configuration change is - * applied when it restarts. + * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, + * the configuration change is applied when it restarts. * * @param event * A {@link RoleEnvironmentChangingEvent} object that represents diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java index 04a9db5084bd0..caf509e49f9b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java @@ -3,14 +3,9 @@ /** * Represents a change to a configuration setting. * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * * @see RoleEnvironmentTopologyChange */ -public class RoleEnvironmentConfigurationSettingChange extends - RoleEnvironmentChange { +public class RoleEnvironmentConfigurationSettingChange extends RoleEnvironmentChange { private String settingName; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java index 3254c634f311b..8b82dcefec028 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java @@ -16,10 +16,8 @@ class RoleEnvironmentData { private final Map roles; private final boolean isEmulated; - public RoleEnvironmentData(String deploymentId, - Map configurationSettings, - Map localResources, - RoleInstance currentInstance, Map roles, + public RoleEnvironmentData(String deploymentId, Map configurationSettings, + Map localResources, RoleInstance currentInstance, Map roles, boolean isEmulated) { this.deploymentId = deploymentId; this.configurationSettings = configurationSettings; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java index be5b7b73c6fa0..327a19a2b651c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java @@ -5,19 +5,13 @@ /** * Represents an exception indicating the role environment is not available. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * - * */ public class RoleEnvironmentNotAvailableException extends RuntimeException { private static final long serialVersionUID = -6218741025124056882L; /** - * Creates an instance of the - * RoleEnvironmentNotAvailableException class. + * Creates an instance of the RoleEnvironmentNotAvailableException class. * * @param t * A java.lang.Throwable object that represents the diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java index 7257e736c94c0..7f3e17e756922 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java @@ -2,18 +2,13 @@ /** * Represents the listener for the stopping event. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok */ public interface RoleEnvironmentStoppingListener { /** * Occurs when the role instance is about to be stopped. *

- * This event is raised after the instance has been taken out of the load - * balancer's rotation before the OnStop method is called. You - * can use this event to run code that is required for the role instance + * This event is raised after the instance has been taken out of the load balancer's rotation before the + * OnStop method is called. You can use this event to run code that is required for the role instance * to shut down in an orderly fashion. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java index 00d9ff569bbd0..95bc92626c9cb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java @@ -3,12 +3,7 @@ /** * Represents a change to the topology of the service. *

- * The service's topology refers to the number of instances deployed for each - * role that the service defines. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok + * The service's topology refers to the number of instances deployed for each role that the service defines. */ public class RoleEnvironmentTopologyChange extends RoleEnvironmentChange { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java index ac18e2fcce421..bee72e428486b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java @@ -4,11 +4,6 @@ /** * Represents an instance of a role. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * */ public final class RoleInstance { private final String id; @@ -25,8 +20,7 @@ public final class RoleInstance { * @param updateDomain * @param endpoints */ - RoleInstance(String id, int faultDomain, int updateDomain, - Map endpoints) { + RoleInstance(String id, int faultDomain, int updateDomain, Map endpoints) { this.id = id; this.faultDomain = faultDomain; this.updateDomain = updateDomain; @@ -50,10 +44,9 @@ public int getFaultDomain() { /** * Returns the ID of this instance. *

- * The returned ID is unique to the application domain of the role�s - * instance. If an instance is terminated and has been configured to restart - * automatically, the restarted instance will have the same ID as the - * terminated instance. + * The returned ID is unique to the application domain of the role�s instance. If an instance is terminated and has + * been configured to restart automatically, the restarted instance will have the same ID as the terminated + * instance. * * @return A String object that represents the ID of this * instance. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java index 42641d70f75ec..014fa406b61de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java @@ -4,11 +4,6 @@ /** * Represents an endpoint associated with a role instance. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * */ public final class RoleInstanceEndpoint { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java index b7b7be7492a1f..75aaa8e1ee625 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java @@ -3,13 +3,7 @@ /** * Defines role instance status values, such as Busy and Ready. *

- * The {@link RoleEnvironment#setStatus} method - * uses a value from this enumeration. - * - * Copyright (c)2011 Microsoft. All rights reserved. - * - * @author mariok - * + * The {@link RoleEnvironment#setStatus} method uses a value from this enumeration. */ public enum RoleInstanceStatus { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java index 4822fca33f7c6..3f16ff44cd359 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java @@ -6,7 +6,6 @@ /** * */ -interface RuntimeClient extends RuntimeGoalStateClient, - RuntimeCurrentStateClient { +interface RuntimeClient extends RuntimeGoalStateClient, RuntimeCurrentStateClient { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java index 22ec8ab676e18..a73d5d8c9cba7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java @@ -9,8 +9,7 @@ interface RuntimeGoalStateClient { public GoalState getCurrentGoalState() throws InterruptedException; - public RoleEnvironmentData getRoleEnvironmentData() - throws InterruptedException; + public RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException; public void addGoalStateChangedListener(GoalStateChangedListener listener); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java index bb54a99ba5301..c14604888799d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java @@ -24,16 +24,13 @@ private RuntimeKernel() { this.goalStateDeserializer = new ChunkedGoalStateDeserializer(); this.inputChannel = new FileInputChannel(); this.outputChannel = new FileOutputChannel(); - this.protocol1RuntimeCurrentStateClient = new Protocol1RuntimeCurrentStateClient( - currentStateSerializer, outputChannel); + this.protocol1RuntimeCurrentStateClient = new Protocol1RuntimeCurrentStateClient(currentStateSerializer, + outputChannel); this.roleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); - this.protocol1RuntimeGoalStateClient = new Protocol1RuntimeGoalStateClient( - protocol1RuntimeCurrentStateClient, goalStateDeserializer, - roleEnvironmentDataDeserializer, inputChannel); - this.runtimeVersionProtocolClient = new RuntimeVersionProtocolClient( - inputChannel); - this.runtimeVersionManager = new RuntimeVersionManager( - runtimeVersionProtocolClient); + this.protocol1RuntimeGoalStateClient = new Protocol1RuntimeGoalStateClient(protocol1RuntimeCurrentStateClient, + goalStateDeserializer, roleEnvironmentDataDeserializer, inputChannel); + this.runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(inputChannel); + this.runtimeVersionManager = new RuntimeVersionManager(runtimeVersionProtocolClient); } public static RuntimeKernel getKernel() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java index 1f1dea5c523f1..0f674cde0ba13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java @@ -27,25 +27,21 @@ public String getVersion() { public RuntimeClient createRuntimeClient(String path) { RuntimeKernel kernel = RuntimeKernel.getKernel(); - return new Protocol1RuntimeClient(kernel - .getProtocol1RuntimeGoalStateClient(), kernel + return new Protocol1RuntimeClient(kernel.getProtocol1RuntimeGoalStateClient(), kernel .getProtocol1RuntimeCurrentStateClient(), path); } }); } public RuntimeClient getRuntimeClient(String versionEndpoint) { - Map versionMap = protocolClient - .getVersionMap(versionEndpoint); + Map versionMap = protocolClient.getVersionMap(versionEndpoint); for (RuntimeClientFactory factory : supportedVersionList) { if (versionMap.containsKey(factory.getVersion())) { - return factory.createRuntimeClient(versionMap.get(factory - .getVersion())); + return factory.createRuntimeClient(versionMap.get(factory.getVersion())); } } - throw new RuntimeException( - "Server does not support any known protocol versions."); + throw new RuntimeException("Server does not support any known protocol versions."); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java index 41802c95ddb6d..24cd372481525 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java @@ -25,9 +25,7 @@ public RuntimeVersionProtocolClient(InputChannel inputChannel) { public Map getVersionMap(String connectionPath) { try { Map versions = new HashMap(); - JAXBContext context = JAXBContext - .newInstance(RuntimeServerDiscoveryInfo.class.getPackage() - .getName()); + JAXBContext context = JAXBContext.newInstance(RuntimeServerDiscoveryInfo.class.getPackage().getName()); Unmarshaller unmarshaller = context.createUnmarshaller(); InputStream input = inputChannel.getInputStream(connectionPath); @@ -35,13 +33,14 @@ public Map getVersionMap(String connectionPath) { RuntimeServerDiscoveryInfo discoveryInfo = ((JAXBElement) unmarshaller .unmarshal(input)).getValue(); - for (RuntimeServerEndpointInfo endpointInfo : discoveryInfo - .getRuntimeServerEndpoints().getRuntimeServerEndpoint()) { + for (RuntimeServerEndpointInfo endpointInfo : discoveryInfo.getRuntimeServerEndpoints() + .getRuntimeServerEndpoint()) { versions.put(endpointInfo.getVersion(), endpointInfo.getPath()); } return versions; - } catch (JAXBException e) { + } + catch (JAXBException e) { throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java index 0aa9a74754584..28ebf42a3747e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java @@ -18,8 +18,7 @@ public XmlCurrentStateSerializer() { public void serialize(CurrentState state, OutputStream stream) { try { - JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class - .getPackage().getName()); + JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class.getPackage().getName()); Marshaller marshaller = context.createMarshaller(); ObjectFactory factory = new ObjectFactory(); @@ -36,29 +35,31 @@ public void serialize(CurrentState state, OutputStream stream) { acquire.setIncarnation(acquireState.getIncarnation()); switch (acquireState.getStatus()) { - case BUSY: - acquire.setStatus(CurrentStatusEnum.BUSY); - break; - case RECYCLE: - acquire.setStatus(CurrentStatusEnum.RECYCLE); - break; - case STARTED: - acquire.setStatus(CurrentStatusEnum.STARTED); - break; - case STOPPED: - acquire.setStatus(CurrentStatusEnum.STOPPED); - break; + case BUSY: + acquire.setStatus(CurrentStatusEnum.BUSY); + break; + case RECYCLE: + acquire.setStatus(CurrentStatusEnum.RECYCLE); + break; + case STARTED: + acquire.setStatus(CurrentStatusEnum.STARTED); + break; + case STOPPED: + acquire.setStatus(CurrentStatusEnum.STOPPED); + break; } leaseInfo.setAcquire(acquire); - } else if (state instanceof ReleaseCurrentState) { + } + else if (state instanceof ReleaseCurrentState) { leaseInfo.setRelease(factory.createStatusLeaseInfoRelease()); } info.setStatusLease(leaseInfo); marshaller.marshal(factory.createCurrentState(info), stream); - } catch (JAXBException e) { + } + catch (JAXBException e) { throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java index e5a3f4608513b..d8e1a4a001ca2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -21,23 +21,19 @@ public XmlGoalStateDeserializer() { public GoalState deserialize(String document) { try { - JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class - .getPackage().getName()); + JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class.getPackage().getName()); Unmarshaller unmarshaller = context.createUnmarshaller(); InputSource source = new InputSource(new StringReader(document)); @SuppressWarnings("unchecked") - GoalStateInfo goalStateInfo = ((JAXBElement) unmarshaller - .unmarshal(source)).getValue(); + GoalStateInfo goalStateInfo = ((JAXBElement) unmarshaller.unmarshal(source)).getValue(); - return new GoalState(goalStateInfo.incarnation, - Enum.valueOf(ExpectedState.class, - goalStateInfo.expectedState.toString()), - goalStateInfo.getRoleEnvironmentPath(), - goalStateInfo.getDeadline(), - goalStateInfo.getCurrentStateEndpoint()); + return new GoalState(goalStateInfo.incarnation, Enum.valueOf(ExpectedState.class, + goalStateInfo.expectedState.toString()), goalStateInfo.getRoleEnvironmentPath(), + goalStateInfo.getDeadline(), goalStateInfo.getCurrentStateEndpoint()); - } catch (JAXBException e) { + } + catch (JAXBException e) { throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java index d94952913fbb3..28bc89f60d4d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java @@ -16,75 +16,63 @@ /** * */ -class XmlRoleEnvironmentDataDeserializer implements - RoleEnvironmentDataDeserializer { +class XmlRoleEnvironmentDataDeserializer implements RoleEnvironmentDataDeserializer { public XmlRoleEnvironmentDataDeserializer() { } @Override public RoleEnvironmentData deserialize(InputStream stream) { try { - JAXBContext context = JAXBContext - .newInstance(RoleEnvironmentInfo.class.getPackage() - .getName()); + JAXBContext context = JAXBContext.newInstance(RoleEnvironmentInfo.class.getPackage().getName()); Unmarshaller unmarshaller = context.createUnmarshaller(); @SuppressWarnings("unchecked") - RoleEnvironmentInfo environmentInfo = ((JAXBElement) unmarshaller - .unmarshal(stream)).getValue(); + RoleEnvironmentInfo environmentInfo = ((JAXBElement) unmarshaller.unmarshal(stream)) + .getValue(); Map configurationSettings = translateConfigurationSettings(environmentInfo); Map localResources = translateLocalResources(environmentInfo); RoleInstance currentInstance = translateCurrentInstance(environmentInfo); - Map roles = translateRoles(environmentInfo, - currentInstance, environmentInfo.getCurrentInstance() - .getRoleName()); - - return new RoleEnvironmentData(environmentInfo.getDeployment() - .getId(), configurationSettings, localResources, - currentInstance, roles, environmentInfo.getDeployment() - .isEmulated()); - } catch (JAXBException e) { + Map roles = translateRoles(environmentInfo, currentInstance, environmentInfo + .getCurrentInstance().getRoleName()); + + return new RoleEnvironmentData(environmentInfo.getDeployment().getId(), configurationSettings, + localResources, currentInstance, roles, environmentInfo.getDeployment().isEmulated()); + } + catch (JAXBException e) { throw new RuntimeException(e); } } - private Map translateConfigurationSettings( - RoleEnvironmentInfo environmentInfo) { + private Map translateConfigurationSettings(RoleEnvironmentInfo environmentInfo) { Map configurationSettings = new HashMap(); - for (ConfigurationSettingInfo settingInfo : environmentInfo - .getCurrentInstance().getConfigurationSettings() + for (ConfigurationSettingInfo settingInfo : environmentInfo.getCurrentInstance().getConfigurationSettings() .getConfigurationSetting()) { - configurationSettings.put(settingInfo.getName(), - settingInfo.getValue()); + configurationSettings.put(settingInfo.getName(), settingInfo.getValue()); } return configurationSettings; } - private Map translateLocalResources( - RoleEnvironmentInfo environmentInfo) { + private Map translateLocalResources(RoleEnvironmentInfo environmentInfo) { Map localResources = new HashMap(); - for (LocalResourceInfo resourceInfo : environmentInfo - .getCurrentInstance().getLocalResources().getLocalResource()) { - localResources.put(resourceInfo.getName(), new LocalResource( - resourceInfo.getSizeInMB(), resourceInfo.getName(), - resourceInfo.getPath())); + for (LocalResourceInfo resourceInfo : environmentInfo.getCurrentInstance().getLocalResources() + .getLocalResource()) { + localResources.put(resourceInfo.getName(), + new LocalResource(resourceInfo.getSizeInMB(), resourceInfo.getName(), resourceInfo.getPath())); } return localResources; } - private Map translateRoles( - RoleEnvironmentInfo environmentInfo, RoleInstance currentInstance, + private Map translateRoles(RoleEnvironmentInfo environmentInfo, RoleInstance currentInstance, String currentRole) { Map roles = new HashMap(); for (RoleInfo roleInfo : environmentInfo.getRoles().getRole()) { - Map instances = translateRoleInstances(roleInfo - .getInstances()); + Map instances = translateRoleInstances(roleInfo.getInstances()); if (roleInfo.getName() == currentRole) { instances.put(currentInstance.getId(), currentInstance); @@ -114,18 +102,14 @@ private Map translateRoles( return roles; } - private Map translateRoleInstances( - RoleInstancesInfo instancesInfo) { + private Map translateRoleInstances(RoleInstancesInfo instancesInfo) { Map roleInstances = new HashMap(); for (RoleInstanceInfo instanceInfo : instancesInfo.getInstance()) { - RoleInstance instance = new RoleInstance(instanceInfo.getId(), - instanceInfo.getFaultDomain(), - instanceInfo.getUpdateDomain(), - translateRoleInstanceEndpoints(instanceInfo.getEndpoints())); + RoleInstance instance = new RoleInstance(instanceInfo.getId(), instanceInfo.getFaultDomain(), + instanceInfo.getUpdateDomain(), translateRoleInstanceEndpoints(instanceInfo.getEndpoints())); - for (RoleInstanceEndpoint endpoint : instance - .getInstanceEndpoints().values()) { + for (RoleInstanceEndpoint endpoint : instance.getInstanceEndpoints().values()) { endpoint.setRoleInstance(instance); } @@ -135,15 +119,12 @@ private Map translateRoleInstances( return roleInstances; } - private Map translateRoleInstanceEndpoints( - EndpointsInfo endpointsInfo) { + private Map translateRoleInstanceEndpoints(EndpointsInfo endpointsInfo) { Map endpoints = new HashMap(); for (EndpointInfo endpointInfo : endpointsInfo.getEndpoint()) { - RoleInstanceEndpoint endpoint = new RoleInstanceEndpoint( - endpointInfo.getProtocol().toString(), - new InetSocketAddress(endpointInfo.getAddress(), - endpointInfo.getPort())); + RoleInstanceEndpoint endpoint = new RoleInstanceEndpoint(endpointInfo.getProtocol().toString(), + new InetSocketAddress(endpointInfo.getAddress(), endpointInfo.getPort())); endpoints.put(endpointInfo.getName(), endpoint); } @@ -151,19 +132,13 @@ private Map translateRoleInstanceEndpoints( return endpoints; } - private RoleInstance translateCurrentInstance( - RoleEnvironmentInfo environmentInfo) { - CurrentRoleInstanceInfo currentInstanceInfo = environmentInfo - .getCurrentInstance(); - RoleInstance currentInstance = new RoleInstance( - currentInstanceInfo.getId(), - currentInstanceInfo.getFaultDomain(), - currentInstanceInfo.getUpdateDomain(), - translateRoleInstanceEndpoints(environmentInfo - .getCurrentInstance().getEndpoints())); - - for (RoleInstanceEndpoint endpoint : currentInstance - .getInstanceEndpoints().values()) { + private RoleInstance translateCurrentInstance(RoleEnvironmentInfo environmentInfo) { + CurrentRoleInstanceInfo currentInstanceInfo = environmentInfo.getCurrentInstance(); + RoleInstance currentInstance = new RoleInstance(currentInstanceInfo.getId(), + currentInstanceInfo.getFaultDomain(), currentInstanceInfo.getUpdateDomain(), + translateRoleInstanceEndpoints(environmentInfo.getCurrentInstance().getEndpoints())); + + for (RoleInstanceEndpoint endpoint : currentInstance.getInstanceEndpoints().values()) { endpoint.setRoleInstance(currentInstance); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html index 6a50090d2e25b..d7ef5eb2b9629 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html @@ -1,6 +1,6 @@ -Classes in this namespace enable you to interact with the Windows Azure environment from code running within your role. Copyright (c)2011 Microsoft. All rights reserved. +Classes in this namespace enable you to interact with the Windows Azure environment from code running within your role. \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html index 67af5f6cca3f3..a55c41d6e4bfe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html @@ -11,6 +11,6 @@ This package contains classes and interfaces that allow your roles to interact with the Windows Azure environment. -For example, the {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironment#requestRecycle} method allows an instance of your role to request to be stopped and then restarted. Copyright (c)2011 Microsoft. All rights reserved. +For example, the {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironment#requestRecycle} method allows an instance of your role to request to be stopped and then restarted. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java index 1d6247ce98c94..8b25ce274ba67 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java @@ -18,23 +18,25 @@ * */ public class FileInputChannelTests { - @Test - public void getInputStreamOpensFile() { - InputChannel inputChannel = new FileInputChannel(); - - try { - File tempFile = File.createTempFile("getInputStreamOpensFile", null); - BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); - String expectedData = "test content"; - - writer.write(expectedData); - writer.close(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(inputChannel.getInputStream(tempFile.getAbsolutePath()))); - - assertThat(reader.readLine(), equalTo(expectedData)); - } catch (IOException e) { - e.printStackTrace(); - } - } + @Test + public void getInputStreamOpensFile() { + InputChannel inputChannel = new FileInputChannel(); + + try { + File tempFile = File.createTempFile("getInputStreamOpensFile", null); + BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); + String expectedData = "test content"; + + writer.write(expectedData); + writer.close(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(inputChannel.getInputStream(tempFile + .getAbsolutePath()))); + + assertThat(reader.readLine(), equalTo(expectedData)); + } + catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java index 39f146c8d0859..112fd2fab69f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java @@ -12,58 +12,61 @@ * */ public class MockInputChannel implements InputChannel { - private final ByteArrayInputStream inputStream; - - public MockInputChannel(String channelData) { - byte data[] = null; - - try { - data = channelData.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - this.inputStream = new ByteArrayInputStream(data); - } - - public MockInputChannel(String chunks[]) { - int finalLength = 0; - LinkedList chunkBytes = new LinkedList(); - byte[] crlf = new byte[] { 0x0D, 0x0A }; - - for (String chunk : chunks) { - try { - byte chunkLengthData[] = Integer.toHexString(chunk.length()).getBytes("US-ASCII"); - byte chunkData[] = chunk.getBytes("UTF-8"); - int chunkLength = chunkLengthData.length + chunkData.length + 4; - - chunkBytes.add(chunkLengthData); - chunkBytes.add(chunkData); - - finalLength += chunkLength; - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - - byte data[] = new byte[finalLength]; - int dataIndex = 0; - - for (byte[] chunk : chunkBytes) { - System.arraycopy(chunk, 0, data, dataIndex, chunk.length); - - dataIndex += chunk.length; - - System.arraycopy(crlf, 0, data, dataIndex, crlf.length); - - dataIndex += crlf.length; - } - - this.inputStream = new ByteArrayInputStream(data); - } - @Override - public InputStream getInputStream(String name) { - return this.inputStream; - } + private final ByteArrayInputStream inputStream; + + public MockInputChannel(String channelData) { + byte data[] = null; + + try { + data = channelData.getBytes("UTF-8"); + } + catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + this.inputStream = new ByteArrayInputStream(data); + } + + public MockInputChannel(String chunks[]) { + int finalLength = 0; + LinkedList chunkBytes = new LinkedList(); + byte[] crlf = new byte[] { 0x0D, 0x0A }; + + for (String chunk : chunks) { + try { + byte chunkLengthData[] = Integer.toHexString(chunk.length()).getBytes("US-ASCII"); + byte chunkData[] = chunk.getBytes("UTF-8"); + int chunkLength = chunkLengthData.length + chunkData.length + 4; + + chunkBytes.add(chunkLengthData); + chunkBytes.add(chunkData); + + finalLength += chunkLength; + } + catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + + byte data[] = new byte[finalLength]; + int dataIndex = 0; + + for (byte[] chunk : chunkBytes) { + System.arraycopy(chunk, 0, data, dataIndex, chunk.length); + + dataIndex += chunk.length; + + System.arraycopy(crlf, 0, data, dataIndex, crlf.length); + + dataIndex += crlf.length; + } + + this.inputStream = new ByteArrayInputStream(data); + } + + @Override + public InputStream getInputStream(String name) { + return this.inputStream; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java index f3d0f92068021..3f9832c3dd986 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java @@ -16,87 +16,90 @@ * */ public class Protocol1RuntimeCurrentStateClientTests { - @Test - public void setCurrentStateSerializesToEndpoint() { - final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); - final OutputStream expectedStream = new ByteArrayOutputStream(); - final String expectedEndpoint = "endpoint"; - final AtomicBoolean serializeCalled = new AtomicBoolean(false); - - CurrentStateSerializer serializer = new CurrentStateSerializer() { - @Override - public void serialize(CurrentState state, OutputStream stream) { - assertThat(state, is(expectedState)); - assertThat(stream, is(expectedStream)); - - serializeCalled.set(true); - } - }; - - OutputChannel outputChannel = new OutputChannel() { - @Override - public OutputStream getOutputStream(String name) { - assertThat(name, is(expectedEndpoint)); - - return expectedStream; - } - }; - - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, outputChannel); - - currentStateClient.setEndpoint(expectedEndpoint); - - currentStateClient.setCurrentState(expectedState); - - assertThat(serializeCalled.get(), is(true)); - } - - @Test - public void streamCloseFailureThrowsNotAvailableException() { - final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); - final OutputStream expectedStream = new OutputStream() { - @Override - public void write(int arg0) throws IOException { - } - - @Override - public void close() throws IOException { - throw new IOException(); - } - }; - - final String expectedEndpoint = "endpoint"; - final AtomicBoolean serializeCalled = new AtomicBoolean(false); - - CurrentStateSerializer serializer = new CurrentStateSerializer() { - @Override - public void serialize(CurrentState state, OutputStream stream) { - assertThat(state, is(expectedState)); - assertThat(stream, is(expectedStream)); - - serializeCalled.set(true); - } - }; - - OutputChannel outputChannel = new OutputChannel() { - @Override - public OutputStream getOutputStream(String name) { - assertThat(name, is(expectedEndpoint)); - - return expectedStream; - } - }; - - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, outputChannel); - - currentStateClient.setEndpoint(expectedEndpoint); - - try { - currentStateClient.setCurrentState(expectedState); - } catch (RoleEnvironmentNotAvailableException e) { - return; - } - - fail(); - } + @Test + public void setCurrentStateSerializesToEndpoint() { + final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); + final OutputStream expectedStream = new ByteArrayOutputStream(); + final String expectedEndpoint = "endpoint"; + final AtomicBoolean serializeCalled = new AtomicBoolean(false); + + CurrentStateSerializer serializer = new CurrentStateSerializer() { + @Override + public void serialize(CurrentState state, OutputStream stream) { + assertThat(state, is(expectedState)); + assertThat(stream, is(expectedStream)); + + serializeCalled.set(true); + } + }; + + OutputChannel outputChannel = new OutputChannel() { + @Override + public OutputStream getOutputStream(String name) { + assertThat(name, is(expectedEndpoint)); + + return expectedStream; + } + }; + + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, + outputChannel); + + currentStateClient.setEndpoint(expectedEndpoint); + + currentStateClient.setCurrentState(expectedState); + + assertThat(serializeCalled.get(), is(true)); + } + + @Test + public void streamCloseFailureThrowsNotAvailableException() { + final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); + final OutputStream expectedStream = new OutputStream() { + @Override + public void write(int arg0) throws IOException { + } + + @Override + public void close() throws IOException { + throw new IOException(); + } + }; + + final String expectedEndpoint = "endpoint"; + final AtomicBoolean serializeCalled = new AtomicBoolean(false); + + CurrentStateSerializer serializer = new CurrentStateSerializer() { + @Override + public void serialize(CurrentState state, OutputStream stream) { + assertThat(state, is(expectedState)); + assertThat(stream, is(expectedStream)); + + serializeCalled.set(true); + } + }; + + OutputChannel outputChannel = new OutputChannel() { + @Override + public OutputStream getOutputStream(String name) { + assertThat(name, is(expectedEndpoint)); + + return expectedStream; + } + }; + + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, + outputChannel); + + currentStateClient.setEndpoint(expectedEndpoint); + + try { + currentStateClient.setCurrentState(expectedState); + } + catch (RoleEnvironmentNotAvailableException e) { + return; + } + + fail(); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index f9faea365004a..ce62a7475b800 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -3,7 +3,6 @@ */ package com.microsoft.windowsazure.serviceruntime; - import java.io.InputStream; import java.util.LinkedList; import java.util.List; @@ -16,254 +15,228 @@ * */ public class Protocol1RuntimeGoalStateClientTests { - private final List goalStates = new LinkedList(); - - @Test - public void addGoalStateChangedListenerAddsListener() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "", - "" + - "" + - "2" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "" - }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( - currentStateClient, - goalStateDeserializer, - roleEnvironmentDeserializer, - inputChannel); - - client.addGoalStateChangedListener(new GoalStateChangedListener() { - @Override - public void goalStateChanged(GoalState newGoalState) { - goalStates.add(newGoalState); - } - }); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(1)); - assertThat(goalStates.get(0).getIncarnation().intValue(), is(2)); - } - - @Test - public void goalStateClientRestartsThread() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { - private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); - - @Override - public void initialize(InputStream inputStream) { - deserializer.initialize(inputStream); - } - - @Override - public GoalState deserialize() { - GoalState goalState = deserializer.deserialize(); - - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - goalStates.add(goalState); - - return goalState; - } - }; - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "" - }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( - currentStateClient, - goalStateDeserializer, - roleEnvironmentDeserializer, - inputChannel); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - client.getCurrentGoalState(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(3)); - } - - @Test - public void getRoleEnvironmentDataReturnsDeserializedData() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - final RoleEnvironmentData data = new RoleEnvironmentData(null, null, null, null, null, false); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return data; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "" - }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( - currentStateClient, - goalStateDeserializer, - roleEnvironmentDeserializer, - inputChannel); - - try { - assertThat(client.getRoleEnvironmentData(), is(data)); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Test - public void removeGoalStateChangedListenerRemovesListener() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "", - "" + - "" + - "2" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "" - }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient( - currentStateClient, - goalStateDeserializer, - roleEnvironmentDeserializer, - inputChannel); - - GoalStateChangedListener listener = new GoalStateChangedListener() { - @Override - public void goalStateChanged(GoalState newGoalState) { - goalStates.add(newGoalState); - } - }; - - client.addGoalStateChangedListener(listener); - client.removeGoalStateChangedListener(listener); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(0)); - } + private final List goalStates = new LinkedList(); + + @Test + public void addGoalStateChangedListenerAddsListener() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + "" + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "", + "" + "" + "2" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "" }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, + goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); + + client.addGoalStateChangedListener(new GoalStateChangedListener() { + @Override + public void goalStateChanged(GoalState newGoalState) { + goalStates.add(newGoalState); + } + }); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(200); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(1)); + assertThat(goalStates.get(0).getIncarnation().intValue(), is(2)); + } + + @Test + public void goalStateClientRestartsThread() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { + private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); + + @Override + public void initialize(InputStream inputStream) { + deserializer.initialize(inputStream); + } + + @Override + public GoalState deserialize() { + GoalState goalState = deserializer.deserialize(); + + try { + Thread.sleep(200); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + goalStates.add(goalState); + + return goalState; + } + }; + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { "" + + "" + "1" + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "" }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, + goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(1000); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + client.getCurrentGoalState(); + } + catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Thread.sleep(1000); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(3)); + } + + @Test + public void getRoleEnvironmentDataReturnsDeserializedData() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + final RoleEnvironmentData data = new RoleEnvironmentData(null, null, null, null, null, false); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return data; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { "" + + "" + "1" + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "" }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, + goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); + + try { + assertThat(client.getRoleEnvironmentData(), is(data)); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @Test + public void removeGoalStateChangedListenerRemovesListener() { + Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); + + GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); + + RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { + @Override + public RoleEnvironmentData deserialize(InputStream stream) { + return null; + } + }; + + InputChannel inputChannel = new MockInputChannel(new String[] { + "" + "" + "1" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "", + "" + "" + "2" + + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "" }); + + Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, + goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); + + GoalStateChangedListener listener = new GoalStateChangedListener() { + @Override + public void goalStateChanged(GoalState newGoalState) { + goalStates.add(newGoalState); + } + }; + + client.addGoalStateChangedListener(listener); + client.removeGoalStateChangedListener(listener); + + goalStates.clear(); + + try { + client.getCurrentGoalState(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + try { + Thread.sleep(200); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + assertThat(goalStates.size(), is(0)); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java index d86f3080455e1..88d11db6ef29a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java @@ -12,50 +12,56 @@ import java.util.TimeZone; import org.junit.Before; -//import org.junit.Test; + +// import org.junit.Test; /** * */ public class RoleEnvironmentTests { - @Before - public void setupTests() { - horrificEnvironmentModification("\\\\.\\pipe\\578cb0d1-a330-4019-b634-755aa3d1e9d2"); - } - - //@Test - public void roleEnvironmentIsAvailable() { - assertThat(RoleEnvironment.isAvailable(), is(true)); - } - - //@Test - public void roleEnvironmentSetStateSetsState() { - Calendar exp = Calendar.getInstance(TimeZone.getTimeZone("GMT+0:00")); - - exp.add(Calendar.MINUTE, 1); - - RoleEnvironment.setStatus(RoleInstanceStatus.Ready, exp); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void horrificEnvironmentModification(String endpoint) { - try { - Class processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); - Field field = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); - field.setAccessible(true); - Object obj = field.get(null); - Map map = (Map)obj; - map.put("WaRuntimeEndpoint", endpoint); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } + @Before + public void setupTests() { + horrificEnvironmentModification("\\\\.\\pipe\\578cb0d1-a330-4019-b634-755aa3d1e9d2"); + } + + //@Test + public void roleEnvironmentIsAvailable() { + assertThat(RoleEnvironment.isAvailable(), is(true)); + } + + //@Test + public void roleEnvironmentSetStateSetsState() { + Calendar exp = Calendar.getInstance(TimeZone.getTimeZone("GMT+0:00")); + + exp.add(Calendar.MINUTE, 1); + + RoleEnvironment.setStatus(RoleInstanceStatus.Ready, exp.getTime()); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void horrificEnvironmentModification(String endpoint) { + try { + Class processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); + Field field = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); + field.setAccessible(true); + Object obj = field.get(null); + Map map = (Map) obj; + map.put("WaRuntimeEndpoint", endpoint); + } + catch (SecurityException e) { + e.printStackTrace(); + } + catch (NoSuchFieldException e) { + e.printStackTrace(); + } + catch (IllegalArgumentException e) { + e.printStackTrace(); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java index 99d09dce41dc2..f6551843d0469 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java @@ -20,95 +20,82 @@ * */ public class RuntimeVersionManagerTests { - @Test - public void getRuntimeClientForV1CanParseGoalState() { - RuntimeVersionManager manager = createVersionManagerWithGoalState( - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "", - "2011-03-08"); - - RuntimeClient runtimeClient = manager.getRuntimeClient(""); - GoalState goalState = null; - - try { - goalState = runtimeClient.getCurrentGoalState(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - Calendar expectedDeadline = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); - - expectedDeadline.clear(); - expectedDeadline.set(2011, 2, 8, 3, 27, 44); - - assertThat(goalState.getIncarnation(), equalTo(BigInteger.ONE)); - assertThat(goalState.getExpectedState(), equalTo(ExpectedState.STARTED)); - assertThat(goalState.getEnvironmentPath(), equalTo("envpath")); - assertThat(goalState.getCurrentStateEndpoint(), equalTo("statepath")); - assertThat(goalState.getDeadline().getTimeInMillis(), equalTo(expectedDeadline.getTimeInMillis())); - } - - @Test - public void getRuntimeClientThrowsWhenNoSupportedVersionsFound() { - RuntimeVersionManager manager = createVersionManagerWithGoalState( - "" + - "" + - "1" + - "Started" + - "envpath" + - "statepath" + - "2011-03-08T03:27:44.0Z" + - "", - "notSupported"); - - try { - manager.getRuntimeClient(""); - } catch (RuntimeException ex) { - return; - } - - fail(); - } - - private RuntimeVersionManager createVersionManagerWithGoalState(String goalStateXml, String version) { - File tempGoalState; - - try { - tempGoalState = File.createTempFile("tempGoalState", null); - FileOutputStream output = new FileOutputStream(tempGoalState); - - InputChannel goalStateChannel = new MockInputChannel(new String[] { goalStateXml }); - BufferedInputStream input = new BufferedInputStream(goalStateChannel.getInputStream("")); - - byte buffer[] = new byte[1024]; - int length = 0; - - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - InputChannel inputChannel = new MockInputChannel( - "" + - "" + - "" + - "" + - "" + - ""); - RuntimeVersionProtocolClient protocolClient = new RuntimeVersionProtocolClient(inputChannel); - return new RuntimeVersionManager(protocolClient); - } + @Test + public void getRuntimeClientForV1CanParseGoalState() { + RuntimeVersionManager manager = createVersionManagerWithGoalState("" + + "" + "1" + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "", "2011-03-08"); + + RuntimeClient runtimeClient = manager.getRuntimeClient(""); + GoalState goalState = null; + + try { + goalState = runtimeClient.getCurrentGoalState(); + } + catch (InterruptedException e) { + e.printStackTrace(); + } + + Calendar expectedDeadline = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); + + expectedDeadline.clear(); + expectedDeadline.set(2011, 2, 8, 3, 27, 44); + + assertThat(goalState.getIncarnation(), equalTo(BigInteger.ONE)); + assertThat(goalState.getExpectedState(), equalTo(ExpectedState.STARTED)); + assertThat(goalState.getEnvironmentPath(), equalTo("envpath")); + assertThat(goalState.getCurrentStateEndpoint(), equalTo("statepath")); + assertThat(goalState.getDeadline().getTimeInMillis(), equalTo(expectedDeadline.getTimeInMillis())); + } + + @Test + public void getRuntimeClientThrowsWhenNoSupportedVersionsFound() { + RuntimeVersionManager manager = createVersionManagerWithGoalState("" + + "" + "1" + "Started" + + "envpath" + + "statepath" + + "2011-03-08T03:27:44.0Z" + "", "notSupported"); + + try { + manager.getRuntimeClient(""); + } + catch (RuntimeException ex) { + return; + } + + fail(); + } + + private RuntimeVersionManager createVersionManagerWithGoalState(String goalStateXml, String version) { + File tempGoalState; + + try { + tempGoalState = File.createTempFile("tempGoalState", null); + FileOutputStream output = new FileOutputStream(tempGoalState); + + InputChannel goalStateChannel = new MockInputChannel(new String[] { goalStateXml }); + BufferedInputStream input = new BufferedInputStream(goalStateChannel.getInputStream("")); + + byte buffer[] = new byte[1024]; + int length = 0; + + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.close(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + + InputChannel inputChannel = new MockInputChannel("" + "" + + "" + "" + "" + ""); + RuntimeVersionProtocolClient protocolClient = new RuntimeVersionProtocolClient(inputChannel); + return new RuntimeVersionManager(protocolClient); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java index d9cd04b49370f..d70697ee7901a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java @@ -2,11 +2,12 @@ * */ package com.microsoft.windowsazure.serviceruntime; + /* -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; -*/ + * import org.junit.Test; + * import static org.junit.Assert.*; + * import static org.hamcrest.Matchers.*; + */ /** * From b362ea165aa08118bb911fb12433c82ba86c34d7 Mon Sep 17 00:00:00 2001 From: Walter Blaurock Date: Thu, 17 Nov 2011 12:54:03 -0800 Subject: [PATCH 206/664] Updated .settings from java version 1.5 to 1.6 --- microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs index 8b76cb8c6c0f7..3f7604ef3b690 100644 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs @@ -10,10 +10,10 @@ org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 From c7a4c345daacdc7f381c757e1fd01ecfac7126f6 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 17 Nov 2011 17:02:49 -0800 Subject: [PATCH 207/664] Add "raw" response body to service exceptions --- .../windowsazure/common/ServiceException.java | 16 ++++++++++++++++ .../utils/ServiceExceptionFactory.java | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java index 37a6e0be9304f..ed0518534fbc0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java @@ -14,6 +14,7 @@ public class ServiceException extends Exception { String errorCode; String errorMessage; Map errorValues; + String rawResponseBody; public ServiceException() { init(); @@ -38,6 +39,14 @@ private void init() { errorValues = new HashMap(); } + @Override + public String getMessage() { + if (this.rawResponseBody == null) + return super.getMessage(); + else + return super.getMessage() + "\nResponse Body: " + this.rawResponseBody; + } + public int getHttpStatusCode() { return httpStatusCode; } @@ -94,4 +103,11 @@ public void setServiceName(String serviceName) { this.serviceName = serviceName; } + public void setRawResponseBody(String body) { + this.rawResponseBody = body; + } + + public String getRawResponseBody() { + return rawResponseBody; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java index c912956194a5f..51b8eec3a23a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java @@ -24,13 +24,13 @@ else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { return exception; } - static ServiceException populate(ServiceException exception, String serviceName, - UniformInterfaceException cause) { + static ServiceException populate(ServiceException exception, String serviceName, UniformInterfaceException cause) { exception.setServiceName(serviceName); if (cause != null) { ClientResponse response = cause.getResponse(); if (response != null) { + // Set status Status status = response.getClientResponseStatus(); if (status == null) { status = Status.fromStatusCode(response.getStatus()); @@ -42,18 +42,29 @@ static ServiceException populate(ServiceException exception, String serviceName, exception.setHttpStatusCode(status.getStatusCode()); exception.setHttpReasonPhrase(status.getReasonPhrase()); } + + // Set raw response body + if (response.hasEntity()) { + try { + String body = response.getEntity(String.class); + exception.setRawResponseBody(body); + } + catch (Exception e) { + // Skip exceptions as getting the response body as a string is a best effort thing + } + } } } return exception; } - static ServiceException populate(ServiceException exception, String serviceName, - ServiceException cause) { + static ServiceException populate(ServiceException exception, String serviceName, ServiceException cause) { exception.setServiceName(cause.getServiceName()); exception.setHttpStatusCode(cause.getHttpStatusCode()); exception.setHttpReasonPhrase(cause.getHttpReasonPhrase()); exception.setErrorCode(cause.getErrorCode()); exception.setErrorMessage(cause.getErrorMessage()); + exception.setRawResponseBody(cause.getRawResponseBody()); exception.setErrorValues(cause.getErrorValues()); return exception; } From 822f42358e693adaa77b6b99b7a97adf504f31a8 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Thu, 17 Nov 2011 17:03:01 -0800 Subject: [PATCH 208/664] Fix typo --- .../services/blob/models/SetBlobPropertiesOptions.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 2e56aa7a634a8..3171956874bbf 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class SetBlobPropertiesOptions extends BlobServiceOptions { private String leaseId; private String contentType; @@ -71,8 +70,8 @@ public Long getSequenceNumber() { return sequenceNumber; } - public SetBlobPropertiesOptions setSequenceNUmber(Long sequenceNUmber) { - this.sequenceNumber = sequenceNUmber; + public SetBlobPropertiesOptions setSequenceNumber(Long sequenceNumber) { + this.sequenceNumber = sequenceNumber; return this; } From 6af17f70d9fa4be46f2069770da7ac8d325388d2 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 10:03:29 -0800 Subject: [PATCH 209/664] Implement full ShareKey authorization for Blob Service The particular problem we had to solve here is to enable the SharedKey filter to have access to the "Content-Length" of the request, since that header is needed for authorizing the request. Since the "Content-Length" of the request is known only very late in the pipeline, so we had to introduce a new listener interface (EntityStreamingListener) that filters can register into. Filters then get called back later in the pipeline, just before starting sending bytes on the connection. This allows them to access all the headers (and also gives them a last chance to update them). --- .../windowsazure/services/blob/Exports.java | 15 + .../blob/implementation/BlobRestProxy.java | 16 +- .../EntityStreamingListener.java | 14 + .../HttpURLConnectionClient.java | 21 ++ .../HttpURLConnectionClientHandler.java | 267 ++++++++++++++++++ .../blob/implementation/JerseyHelpers.java | 12 +- .../blob/implementation/SharedKeyFilter.java | 265 +++++++++++++++++ .../implementation/SharedKeyLiteFilter.java | 40 +-- .../blob/implementation/SharedKeyUtils.java | 53 ++++ 9 files changed, 671 insertions(+), 32 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java 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 10a7c9948cf3d..2ac8a38de32cf 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 @@ -1,9 +1,14 @@ package com.microsoft.windowsazure.services.blob; +import java.util.Map; + import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; +import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; +import com.sun.jersey.api.client.config.ClientConfig; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { @@ -12,5 +17,15 @@ public void register(Builder.Registry registry) { registry.add(BlobExceptionProcessor.class); registry.add(BlobRestProxy.class); registry.add(SharedKeyLiteFilter.class); + registry.add(SharedKeyFilter.class); + + registry.add(new Builder.Factory() { + public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); + //client.addFilter(new LoggingFilter()); + return client; + } + }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index d69a806095d40..051208e69aecb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -56,26 +56,23 @@ import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; -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 BlobRestProxy implements BlobContract { - // private static Log log = LogFactory.getLog(BlobRestProxy.class); - private static final String API_VERSION = "2011-08-18"; - private final Client channel; + private final HttpURLConnectionClient channel; private final String accountName; private final String url; private final RFC1123DateConverter dateMapper; private final ServiceFilter[] filters; - private final SharedKeyLiteFilter filter; + private final SharedKeyFilter filter; @Inject - public BlobRestProxy(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - SharedKeyLiteFilter filter) { + public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, + SharedKeyFilter filter) { this.channel = channel; this.accountName = accountName; @@ -86,9 +83,10 @@ public BlobRestProxy(Client channel, @Named(BlobConfiguration.ACCOUNT_NAME) Stri channel.addFilter(filter); } - public BlobRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + public BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, String accountName, String url, SharedKeyFilter filter, + RFC1123DateConverter dateMapper) { - this.channel = channel; + this.channel = client; this.filters = filters; this.accountName = accountName; this.url = url; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java new file mode 100644 index 0000000000000..fa5774e5c2a44 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import com.sun.jersey.api.client.ClientRequest; + +public interface EntityStreamingListener { + /** + * This method is called just before the entity is streamed to the underlying connection. This is the last chance + * for filters to inspect and modify the headers of the client request if necessary. + * + * @param clientRequest + * The client request + */ + void onBeforeStreamingEntity(ClientRequest clientRequest); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java new file mode 100644 index 0000000000000..6824d019cf7d1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java @@ -0,0 +1,21 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; + +public class HttpURLConnectionClient extends Client { + private final HttpURLConnectionClientHandler rootHandler; + + public HttpURLConnectionClient(HttpURLConnectionClientHandler handler, ClientConfig config) { + super(handler, config); + this.rootHandler = handler; + } + + public static HttpURLConnectionClient create(ClientConfig config) { + return new HttpURLConnectionClient(new HttpURLConnectionClientHandler(), config); + } + + public HttpURLConnectionClientHandler getRootHandler() { + return rootHandler; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java new file mode 100644 index 0000000000000..cb0c994b85b37 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java @@ -0,0 +1,267 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.util.List; +import java.util.Map; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers.EnumCommaStringBuilder; +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.CommittingOutputStream; +import com.sun.jersey.api.client.TerminatingClientHandler; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.core.header.InBoundHeaders; + +public class HttpURLConnectionClientHandler extends TerminatingClientHandler { + /** + * Empty "no-op" listener if none registered + */ + private static final EntityStreamingListener EMPTY_STREAMING_LISTENER = new EntityStreamingListener() { + public void onBeforeStreamingEntity(ClientRequest clientRequest) { + } + }; + + /** + * OutputStream used for buffering entity body when "Content-Length" is not known in advance. + */ + private final class BufferingOutputStream extends OutputStream { + private final ByteArrayOutputStream outputStream; + private final HttpURLConnection urlConnection; + private final ClientRequest clientRequest; + private final EntityStreamingListener entityStreamingListener; + private boolean closed; + + private BufferingOutputStream(HttpURLConnection urlConnection, ClientRequest clientRequest, + EntityStreamingListener entityStreamingListener) { + this.outputStream = new ByteArrayOutputStream(); + this.urlConnection = urlConnection; + this.clientRequest = clientRequest; + this.entityStreamingListener = entityStreamingListener; + } + + @Override + public void close() throws IOException { + outputStream.close(); + + if (!closed) { + closed = true; + + // Give the listener a last change to modify headers now that the content length is known + setContentLengthHeader(clientRequest, outputStream.size()); + entityStreamingListener.onBeforeStreamingEntity(clientRequest); + + // Write headers, then entity to the http connection. + setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); + + // Since we buffered the entity and we know the content size, we might as well + // use the "fixed length" streaming mode of HttpURLConnection to stream + // the buffer directly. + urlConnection.setFixedLengthStreamingMode(outputStream.size()); + OutputStream httpOutputStream = urlConnection.getOutputStream(); + outputStream.writeTo(httpOutputStream); + httpOutputStream.flush(); + httpOutputStream.close(); + } + } + + @Override + public void flush() throws IOException { + outputStream.flush(); + } + + @Override + public void write(byte[] b, int off, int len) { + outputStream.write(b, off, len); + } + + @Override + public void write(byte[] b) throws IOException { + outputStream.write(b); + } + + @Override + public void write(int b) { + outputStream.write(b); + } + } + + /** + * OutputStream used for directly streaming entity to url connection stream. Headers are written just before sending + * the first bytes to the output stream. + */ + private final class StreamingOutputStream extends CommittingOutputStream { + private final HttpURLConnection urlConnection; + private final ClientRequest clientRequest; + + private StreamingOutputStream(HttpURLConnection urlConnection, ClientRequest clientRequest) { + this.urlConnection = urlConnection; + this.clientRequest = clientRequest; + } + + @Override + protected OutputStream getOutputStream() throws IOException { + return urlConnection.getOutputStream(); + } + + @Override + public void commit() throws IOException { + setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); + } + } + + /** + * Simple response implementation around an HttpURLConnection response + */ + private final class URLConnectionResponse extends ClientResponse { + private final String method; + private final HttpURLConnection urlConnection; + + URLConnectionResponse(int status, InBoundHeaders headers, InputStream entity, String method, + HttpURLConnection urlConnection) { + super(status, headers, entity, getMessageBodyWorkers()); + this.method = method; + this.urlConnection = urlConnection; + } + + @Override + public boolean hasEntity() { + if (method.equals("HEAD") || getEntityInputStream() == null) + return false; + + // Length "-1" means "unknown" + int length = urlConnection.getContentLength(); + return length > 0 || length == -1; + } + + @Override + public String toString() { + return urlConnection.getRequestMethod() + " " + urlConnection.getURL() + " returned a response status of " + + this.getStatus() + " " + this.getClientResponseStatus(); + } + } + + public ClientResponse handle(final ClientRequest ro) throws ClientHandlerException { + try { + return doHandle(ro); + } + catch (Exception e) { + throw new ClientHandlerException(e); + } + } + + private ClientResponse doHandle(final ClientRequest clientRequest) throws IOException, MalformedURLException, + ProtocolException { + final HttpURLConnection urlConnection = (HttpURLConnection) clientRequest.getURI().toURL().openConnection(); + final EntityStreamingListener entityStreamingListener = getEntityStreamingListener(clientRequest); + + urlConnection.setRequestMethod(clientRequest.getMethod()); + + // Write the request headers + setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); + + // Write the entity (if any) + Object entity = clientRequest.getEntity(); + if (entity != null) { + urlConnection.setDoOutput(true); + + writeRequestEntity(clientRequest, new RequestEntityWriterListener() { + private boolean inStreamingMode; + + public void onRequestEntitySize(long size) { + if (size != -1 && size < Integer.MAX_VALUE) { + inStreamingMode = true; + setContentLengthHeader(clientRequest, (int) size); + entityStreamingListener.onBeforeStreamingEntity(clientRequest); + + urlConnection.setFixedLengthStreamingMode((int) size); + } + else { + Integer chunkedEncodingSize = + (Integer) clientRequest.getProperties() + .get(ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE); + if (chunkedEncodingSize != null) { + inStreamingMode = true; + entityStreamingListener.onBeforeStreamingEntity(clientRequest); + + urlConnection.setChunkedStreamingMode(chunkedEncodingSize); + } + } + } + + public OutputStream onGetOutputStream() throws IOException { + if (inStreamingMode) + return new StreamingOutputStream(urlConnection, clientRequest); + else + return new BufferingOutputStream(urlConnection, clientRequest, entityStreamingListener); + } + }); + } + else { + entityStreamingListener.onBeforeStreamingEntity(clientRequest); + setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); + } + + // Return the in-bound response + return new URLConnectionResponse(urlConnection.getResponseCode(), getInBoundHeaders(urlConnection), + getInputStream(urlConnection), clientRequest.getMethod(), urlConnection); + } + + private EntityStreamingListener getEntityStreamingListener(final ClientRequest clientRequest) { + EntityStreamingListener result = + (EntityStreamingListener) clientRequest.getProperties().get(EntityStreamingListener.class.getName()); + + if (result != null) + return result; + + return EMPTY_STREAMING_LISTENER; + } + + private void setContentLengthHeader(ClientRequest clientRequest, int size) { + clientRequest.getHeaders().putSingle("Content-Length", size); + } + + private void setURLConnectionHeaders(MultivaluedMap headers, HttpURLConnection urlConnection) { + for (Map.Entry> e : headers.entrySet()) { + List vs = e.getValue(); + if (vs.size() == 1) { + urlConnection.setRequestProperty(e.getKey(), ClientRequest.getHeaderValue(vs.get(0))); + } + else { + EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); + for (Object v : e.getValue()) { + sb.add(ClientRequest.getHeaderValue(v)); + } + urlConnection.setRequestProperty(e.getKey(), sb.toString()); + } + } + } + + private InBoundHeaders getInBoundHeaders(HttpURLConnection urlConnection) { + InBoundHeaders headers = new InBoundHeaders(); + for (Map.Entry> e : urlConnection.getHeaderFields().entrySet()) { + if (e.getKey() != null) + headers.put(e.getKey(), e.getValue()); + } + return headers; + } + + private InputStream getInputStream(HttpURLConnection urlConnection) throws IOException { + if (urlConnection.getResponseCode() < 300) { + return urlConnection.getInputStream(); + } + else { + InputStream ein = urlConnection.getErrorStream(); + return (ein != null) ? ein : new ByteArrayInputStream(new byte[0]); + } + } +} 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 046af8c0d3875..c480f975be11f 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 @@ -37,12 +37,16 @@ public static WebResource setCanonicalizedResource(WebResource webResource, Stri public static class EnumCommaStringBuilder { private final StringBuilder sb = new StringBuilder(); + public void add(String representation) { + if (sb.length() > 0) { + sb.append(","); + } + sb.append(representation); + } + public void addValue(boolean value, String representation) { if (value) { - if (sb.length() > 0) { - sb.append(","); - } - sb.append(representation); + add(representation); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java new file mode 100644 index 0000000000000..0f2537e444529 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -0,0 +1,265 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import javax.inject.Named; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.windowsazure.services.blob.BlobConfiguration; +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; + +public class SharedKeyFilter extends ClientFilter implements EntityStreamingListener { + private static Log log = LogFactory.getLog(SharedKeyFilter.class); + + private final String accountName; + private final HmacSHA256Sign signer; + + public SharedKeyFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, + @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { + this.accountName = accountName; + this.signer = new HmacSHA256Sign(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) { + sign(cr); + } + + // Register ourselves as listener so we are called back when the entity is + // written to the output stream by the next filter in line. + if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { + cr.getProperties().put(EntityStreamingListener.class.getName(), this); + } + + return this.getNext().handle(cr); + } + + /* + * StringToSign = VERB + "\n" + + * Content-Encoding + "\n" + * Content-Language + "\n" + * Content-Length + "\n" + * Content-MD5 + "\n" + + * Content-Type + "\n" + + * Date + "\n" + + * If-Modified-Since + "\n" + * If-Match + "\n" + * If-None-Match + "\n" + * If-Unmodified-Since + "\n" + * Range + "\n" + * CanonicalizedHeaders + + * CanonicalizedResource; + */ + public void sign(ClientRequest cr) { + // gather signed material + addOptionalDateHeader(cr); + + // build signed string + String stringToSign = + cr.getMethod() + "\n" + getHeader(cr, "Content-Encoding") + "\n" + getHeader(cr, "Content-Language") + + "\n" + getHeader(cr, "Content-Length") + "\n" + getHeader(cr, "Content-MD5") + "\n" + + getHeader(cr, "Content-Type") + "\n" + getHeader(cr, "Date") + "\n" + + getHeader(cr, "If-Modified-Since") + "\n" + getHeader(cr, "If-Match") + "\n" + + getHeader(cr, "If-None-Match") + "\n" + getHeader(cr, "If-Unmodified-Since") + "\n" + + getHeader(cr, "Range") + "\n"; + + stringToSign += getCanonicalizedHeaders(cr); + stringToSign += getCanonicalizedResource(cr); + + if (log.isDebugEnabled()) { + log.debug(String.format("String to sign: \"%s\"", stringToSign)); + } + //System.out.println(String.format("String to sign: \"%s\"", stringToSign)); + + String signature = this.signer.sign(stringToSign); + cr.getHeaders().putSingle("Authorization", "SharedKey " + this.accountName + ":" + signature); + } + + private void addOptionalDateHeader(ClientRequest cr) { + String date = getHeader(cr, "Date"); + if (date == "") { + date = new RFC1123DateConverter().format(new Date()); + cr.getHeaders().add("Date", date); + } + } + + /** + * Constructing the Canonicalized Headers String + * + * To construct the CanonicalizedHeaders portion of the signature string, + * follow these steps: + * + * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header. + * + * 2. Convert each HTTP header name to lowercase. + * + * 3. Sort the headers lexicographically by header name, in ascending order. Note that each header may appear only + * once in the string. + * + * 4. Unfold the string by replacing any breaking white space with a + * single space. + * + * 5. Trim any white space around the colon in the header. + * + * 6. Finally, append a new line character to each canonicalized header in the resulting list. Construct the + * CanonicalizedHeaders string by concatenating all headers in this list into a single string. + */ + private String getCanonicalizedHeaders(ClientRequest cr) { + return SharedKeyUtils.getCanonicalizedHeaders(cr); + } + + /** + * This format supports Shared Key authentication for the 2009-09-19 version of the Blob and Queue services. + * Construct the CanonicalizedResource string in this format as follows: + * + * 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns + * the resource being accessed. + * + * 2. Append the resource's encoded URI path, without any query parameters. + * + * 3. Retrieve all query parameters on the resource URI, including the comp parameter if it exists. + * + * 4. Convert all parameter names to lowercase. + * + * 5. Sort the query parameters lexicographically by parameter name, in ascending order. + * + * 6. URL-decode each query parameter name and value. + * + * 7. Append each query parameter name and value to the string in the following format, making sure to include the + * colon (:) between the name and the value: + * + * parameter-name:parameter-value + * + * 8. If a query parameter has more than one value, sort all values lexicographically, then include them in a + * comma-separated list: + * + * parameter-name:parameter-value-1,parameter-value-2,parameter-value-n + * + * 9. Append a new line character (\n) after each name-value pair. + */ + private String getCanonicalizedResource(ClientRequest cr) { + // 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns + // the resource being accessed. + String result = "/" + this.accountName; + + // 2. Append the resource's encoded URI path, without any query parameters. + result += cr.getURI().getPath(); + + // 3. Retrieve all query parameters on the resource URI, including the comp parameter if it exists. + // 6. URL-decode each query parameter name and value. + List queryParams = getQueryParams(cr.getURI().getQuery()); + + // 4. Convert all parameter names to lowercase. + for (QueryParam param : queryParams) { + param.setName(param.getName().toLowerCase(Locale.US)); + } + + // 5. Sort the query parameters lexicographically by parameter name, in ascending order. + Collections.sort(queryParams); + + // 7. Append each query parameter name and value to the string + // 8. If a query parameter has more than one value, sort all values lexicographically, then include them in a comma-separated list + for (int i = 0; i < queryParams.size(); i++) { + QueryParam param = queryParams.get(i); + + List values = param.getValues(); + //Collections.sort(values); + + // 9. Append a new line character (\n) after each name-value pair. + result += "\n"; + result += param.getName(); + result += ":"; + for (int j = 0; j < values.size(); j++) { + if (j > 0) { + result += ","; + } + result += values.get(j); + } + } + + return result; + } + + private List getQueryParams(String queryString) { + ArrayList result = new ArrayList(); + + if (queryString != null) { + String[] params = queryString.split("&"); + for (String param : params) { + result.add(getQueryParam(param)); + } + } + + return result; + } + + private QueryParam getQueryParam(String param) { + QueryParam result = new QueryParam(); + + int index = param.indexOf("="); + if (index < 0) { + result.setName(param); + } + else { + result.setName(param.substring(0, index)); + + String value = param.substring(index + 1); + int commaIndex = value.indexOf(','); + if (commaIndex < 0) { + result.addValue(value); + } + else { + for (String v : value.split(",")) { + result.addValue(v); + } + } + } + + return result; + } + + private static class QueryParam implements Comparable { + private String name; + private final List values = new ArrayList(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getValues() { + return values; + } + + public void addValue(String value) { + values.add(value); + } + + public int compareTo(QueryParam o) { + return this.name.compareTo(o.name); + } + } + + private String getHeader(ClientRequest cr, String headerKey) { + return SharedKeyUtils.getHeader(cr, headerKey); + } + + public void onBeforeStreamingEntity(ClientRequest clientRequest) { + // All headers should be known at this point, time to sign! + sign(clientRequest); + } +} 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 92d21f6d6ae45..0c86663cac1f2 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 @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import java.util.List; import java.util.Locale; import javax.inject.Named; @@ -23,7 +22,8 @@ public class SharedKeyLiteFilter extends ClientFilter { private final String accountName; private final HmacSHA256Sign signer; - public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { + public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, + @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { this.accountName = accountName; this.signer = new HmacSHA256Sign(accountKey); @@ -74,19 +74,25 @@ public void sign(ClientRequest cr) { cr.getHeaders().putSingle("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); } - /* + /** * Constructing the Canonicalized Headers String - * + * * To construct the CanonicalizedHeaders portion of the signature string, - * follow these steps: 1. Retrieve all headers for the resource that begin - * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header - * name to lowercase. 3. Sort the headers lexicographically by header name, - * in ascending order. Note that each header may appear only once in the - * string. 4. Unfold the string by replacing any breaking white space with a - * single space. 5. Trim any white space around the colon in the header. 6. - * Finally, append a new line character to each canonicalized header in the - * resulting list. Construct the CanonicalizedHeaders string by - * concatenating all headers in this list into a single string. + * follow these steps: + * + * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header. + * + * 2. Convert each HTTP header name to lowercase. + * + * 3. Sort the headers lexicographically by header name in ascending order. Note that each header may appear only + * once in the string. + * + * 4. Unfold the string by replacing any breaking white space with a single space. + * + * 5. Trim any white space around the colon in the header. + * + * 6. Finally, append a new line character to each canonicalized header in the resulting list. Construct the + * CanonicalizedHeaders string by concatenating all headers in this list into a single string. */ private String addCanonicalizedHeaders(ClientRequest cr) { ArrayList msHeaders = new ArrayList(); @@ -95,6 +101,7 @@ private String addCanonicalizedHeaders(ClientRequest cr) { msHeaders.add(key.toLowerCase(Locale.US)); } } + Collections.sort(msHeaders); String result = ""; @@ -110,11 +117,6 @@ private String addCanonicalizedResource(ClientRequest cr) { } private String getHeader(ClientRequest cr, String headerKey) { - List values = cr.getHeaders().get(headerKey); - if (values == null || values.size() != 1) { - return nullEmpty(null); - } - - return nullEmpty(values.get(0).toString()); + return SharedKeyUtils.getHeader(cr, headerKey); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java new file mode 100644 index 0000000000000..b2b736fb30e57 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java @@ -0,0 +1,53 @@ +package com.microsoft.windowsazure.services.blob.implementation; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +import com.sun.jersey.api.client.ClientRequest; + +public class SharedKeyUtils { + /* + * Constructing the Canonicalized Headers String + * + * To construct the CanonicalizedHeaders portion of the signature string, + * follow these steps: 1. Retrieve all headers for the resource that begin + * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header + * name to lowercase. 3. Sort the headers lexicographically by header name, + * in ascending order. Note that each header may appear only once in the + * string. 4. Unfold the string by replacing any breaking white space with a + * single space. 5. Trim any white space around the colon in the header. 6. + * Finally, append a new line character to each canonicalized header in the + * resulting list. Construct the CanonicalizedHeaders string by + * concatenating all headers in this list into a single string. + */ + public static String getCanonicalizedHeaders(ClientRequest cr) { + ArrayList msHeaders = new ArrayList(); + for (String key : cr.getHeaders().keySet()) { + if (key.toLowerCase(Locale.US).startsWith("x-ms-")) { + msHeaders.add(key.toLowerCase(Locale.US)); + } + } + Collections.sort(msHeaders); + + String result = ""; + for (String msHeader : msHeaders) { + result += msHeader + ":" + cr.getHeaders().getFirst(msHeader) + "\n"; + } + return result; + } + + public static String getHeader(ClientRequest cr, String headerKey) { + List values = cr.getHeaders().get(headerKey); + if (values == null || values.size() != 1) { + return nullEmpty(null); + } + + return nullEmpty(values.get(0).toString()); + } + + private static String nullEmpty(String value) { + return value != null ? value : ""; + } +} From 9009cc793c41bc0d48b38d4c09fe1107ebbe1eb1 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 13:57:42 -0800 Subject: [PATCH 210/664] Make integration tests setup/teardown more robust --- .../blob/BlobServiceIntegrationTest.java | 194 +++++++++++------- .../services/blob/IntegrationTestBase.java | 4 +- 2 files changed, 119 insertions(+), 79 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 44fb7941ee478..65a6cb0b0484c 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 @@ -14,6 +14,8 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import junit.framework.Assert; @@ -48,6 +50,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.ListContainersResult.Container; import com.microsoft.windowsazure.services.blob.models.PageRange; import com.microsoft.windowsazure.services.blob.models.ServiceProperties; import com.microsoft.windowsazure.services.blob.models.SetBlobMetadataResult; @@ -94,39 +97,46 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); BlobContract service = config.create(BlobContract.class); - for (int i = 0; i < testContainers.length; i++) { - try { - service.createContainer(testContainers[i]); - } - catch (ServiceException e) { - // Ignore exception as the containers might not exists - } - } + + createContainers(service, testContainersPrefix, testContainers); } @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); BlobContract service = config.create(BlobContract.class); - for (int i = 0; i < testContainers.length; i++) { - try { - service.deleteContainer(testContainers[i]); - } - catch (ServiceException e) { - // Ignore exception as the containers might not exists + + deleteContainers(service, testContainersPrefix, testContainers); + deleteContainers(service, createableContainersPrefix, creatableContainers); + } + + private static void createContainers(BlobContract service, String prefix, String[] list) throws Exception { + Set containers = listContainers(service, testContainersPrefix); + for (String item : testContainers) { + if (!containers.contains(item)) { + service.createContainer(item); } } + } - for (int i = 0; i < creatableContainers.length; i++) { - try { - service.deleteContainer(creatableContainers[i]); - } - catch (ServiceException e) { - // Ignore exception as the containers might not exists + private static void deleteContainers(BlobContract service, String prefix, String[] list) throws Exception { + Set containers = listContainers(service, prefix); + for (String item : list) { + if (containers.contains(item)) { + service.deleteContainer(item); } } } + private static Set listContainers(BlobContract service, String prefix) throws Exception { + HashSet result = new HashSet(); + ListContainersResult list = service.listContainers(new ListContainersOptions().setPrefix(prefix)); + for (Container item : list.getContainers()) { + result.add(item.getName()); + } + return result; + } + @Test public void getServiceProppertiesWorks() throws Exception { // Arrange @@ -190,14 +200,15 @@ public void createContainerWithMetadataWorks() throws Exception { BlobContract service = config.create(BlobContract.class); // Act - service.createContainer(CREATEABLE_CONTAINER_2, - new CreateContainerOptions().setPublicAccess("blob").addMetadata("test", "bar").addMetadata("blah", "bleah")); + service.createContainer(CREATEABLE_CONTAINER_2, new CreateContainerOptions().setPublicAccess("blob") + .addMetadata("test", "bar").addMetadata("blah", "bleah")); 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).setIncludeMetadata(true)); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setPrefix( + CREATEABLE_CONTAINER_2).setIncludeMetadata(true)); service.deleteContainer(CREATEABLE_CONTAINER_2); @@ -322,7 +333,8 @@ public void listContainersWithPaginationWorks() throws Exception { // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results + .getNextMarker())); // Assert assertNotNull(results); @@ -343,7 +355,8 @@ public void listContainersWithPrefixWorks() throws Exception { BlobContract service = config.create(BlobContract.class); // Act - ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix(testContainersPrefix).setMaxResults(3)); + ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix( + testContainersPrefix).setMaxResults(3)); // Assert assertNotNull(results); assertEquals(3, results.getContainers().size()); @@ -351,7 +364,8 @@ public void listContainersWithPrefixWorks() throws Exception { assertEquals(3, results.getMaxResults()); // Act - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results.getNextMarker())); + ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results + .getNextMarker())); // Assert assertNotNull(results2); @@ -460,7 +474,8 @@ public void listBlobsWithPrefixWorks() throws Exception { } // Act - ListBlobsResult results = service.listBlobs(TEST_CONTAINER_FOR_LISTING, new ListBlobsOptions().setPrefix("myblob")); + 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) { @@ -490,7 +505,8 @@ 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); @@ -512,12 +528,18 @@ public void listBlobsWithDelimiterWorks() throws Exception { } // 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-")); + 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); @@ -563,10 +585,12 @@ public void createPageBlobWithOptionsWorks() throws Exception { BlobContract service = config.create(BlobContract.class); // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, 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.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, + 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 result = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test"); @@ -624,8 +648,8 @@ public void createBlobPagesWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 512); - CreateBlobPagesResult result = service.createBlobPages(container, blob, new PageRange(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); @@ -647,10 +671,14 @@ public void listBlobRegionsWorks() throws Exception { String content = new String(new char[512]); service.createPageBlob(container, blob, 16384 + 512); - 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"))); + 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); @@ -710,7 +738,8 @@ public void listBlobBlocksWorks() throws Exception { service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setListType("all")); + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, + new ListBlobBlocksOptions().setListType("all")); // Assert assertNotNull(result); @@ -750,7 +779,8 @@ public void commitBlobBlocksWorks() throws Exception { blockList.addUncommittedEntry(blockId1).addLatestEntry(blockId3); service.commitBlobBlocks(container, blob, blockList); - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions().setListType("all")); + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, + new ListBlobBlocksOptions().setListType("all")); // Assert assertNotNull(result); @@ -806,10 +836,12 @@ 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 result = service.getBlobProperties(TEST_CONTAINER_FOR_BLOBS, "test2"); @@ -863,10 +895,11 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test3"; service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, - new CreateBlobSnapshotOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); + CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions() + .addMetadata("test", "bar").addMetadata("blah", "bleah")); - GetBlobPropertiesResult result = service.getBlobProperties(container, blob, new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); + GetBlobPropertiesResult result = service.getBlobProperties(container, blob, + new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); // Assert assertNotNull(result); @@ -886,10 +919,12 @@ 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 result = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); @@ -922,10 +957,12 @@ public void getPageBlobWorks() throws Exception { BlobContract service = config.create(BlobContract.class); // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, 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.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, + 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 result = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); @@ -959,7 +996,8 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); try { - service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); + service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", + new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -978,8 +1016,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.getProperties().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) { @@ -998,8 +1036,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.getProperties().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) { @@ -1035,7 +1073,8 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception break; } try { - service.getBlob(container, blob, new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); + service.getBlob(container, blob, + new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); Assert.fail("getBlob should throw an exception"); } catch (ServiceException e) { @@ -1086,7 +1125,8 @@ public void getBlobMetadataWorks() throws Exception { // Act String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test"; - service.createPageBlob(container, blob, 4096, new CreateBlobOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); + service.createPageBlob(container, blob, 4096, + new CreateBlobOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); GetBlobMetadataResult props = service.getBlobMetadata(container, blob); // Assert @@ -1111,9 +1151,9 @@ public void setBlobPropertiesWorks() throws Exception { String container = TEST_CONTAINER_FOR_BLOBS; String blob = "test10"; service.createPageBlob(container, blob, 4096); - SetBlobPropertiesResult result = service.setBlobProperties(container, blob, - new SetBlobPropertiesOptions().setCacheControl("test").setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L) - .setContentMD5(null).setContentType("text/plain").setSequenceNumberAction("increment")); + SetBlobPropertiesResult result = service.setBlobProperties(container, blob, new SetBlobPropertiesOptions() + .setCacheControl("test").setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L) + .setContentMD5(null).setContentType("text/plain").setSequenceNumberAction("increment")); GetBlobPropertiesResult getResult = service.getBlobProperties(container, blob); @@ -1289,8 +1329,8 @@ public void retryPolicyWorks() throws Exception { service = service.withFilter(observer); // Act - service = service - .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); + service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, + 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); ServiceException Error = null; try { @@ -1315,10 +1355,10 @@ public void retryPolicyCompositionWorks() throws Exception { service = service.withFilter(observer); // Act - service = service - .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); - service = service - .withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, 2/*maximumAttempts*/, new int[] { 400, 500, 503 }))); + service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, + 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); + service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, + 2/*maximumAttempts*/, new int[] { 400, 500, 503 }))); ServiceException Error = null; try { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 450f2c428afc1..7d552254ecde7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -35,11 +35,11 @@ private static void setConfigValue(Configuration config, Map pro @BeforeClass public static void initializeSystem() { - System.out.println("initialize"); + //System.out.println("initialize"); } @Before public void initialize() throws Exception { - System.out.println("initialize"); + //System.out.println("initialize"); } } From ee1d9f979a26444bafb801764608ea9119677412 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 14:26:27 -0800 Subject: [PATCH 211/664] Make SharedKey and SharedKeyList implementation consistent Also, remove usage of "canonical resource" property in Jersey channel as it is not needed anymore (canonical resource can be inferred from client request, no logic is needed in the rest proxy implementation class). --- .../blob/implementation/BlobRestProxy.java | 156 +++++++++--------- .../blob/implementation/JerseyHelpers.java | 15 -- .../blob/implementation/SharedKeyFilter.java | 108 +++--------- .../implementation/SharedKeyLiteFilter.java | 63 ++++--- .../blob/implementation/SharedKeyUtils.java | 65 ++++++++ .../queue/implementation/QueueRestProxy.java | 64 +++---- 6 files changed, 226 insertions(+), 245 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 051208e69aecb..920b5c6ab9c4f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -71,8 +71,8 @@ public class BlobRestProxy implements BlobContract { private final SharedKeyFilter filter; @Inject - public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URL) String url, - SharedKeyFilter filter) { + public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, + @Named(BlobConfiguration.URL) String url, SharedKeyFilter filter) { this.channel = channel; this.accountName = accountName; @@ -83,8 +83,8 @@ public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.A channel.addFilter(filter); } - public BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, String accountName, String url, SharedKeyFilter filter, - RFC1123DateConverter dateMapper) { + public BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, String accountName, String url, + SharedKeyFilter filter, RFC1123DateConverter dateMapper) { this.channel = client; this.filters = filters; @@ -213,10 +213,6 @@ private WebResource getResource(BlobServiceOptions options) { return webResource; } - private WebResource setCanonicalizedResource(WebResource webResource, String operation) { - return JerseyHelpers.setCanonicalizedResource(webResource, this.accountName, operation); - } - private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { // Specifies the name of the source blob, in one of the following // formats: @@ -244,8 +240,8 @@ public GetServicePropertiesResult getServiceProperties() throws ServiceException } public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, "properties"); + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -258,9 +254,10 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser setServiceProperties(serviceProperties, new BlobServiceOptions()); } - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, "properties"); + public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) + throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -274,7 +271,6 @@ public void createContainer(String container) throws ServiceException { public void createContainer(String container, CreateContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, options.getMetadata()); @@ -290,7 +286,6 @@ public void deleteContainer(String container) throws ServiceException { public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); @@ -302,7 +297,8 @@ public GetContainerPropertiesResult getContainerProperties(String container) thr return getContainerProperties(container, new BlobServiceOptions()); } - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException { + public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) + throws ServiceException { return getContainerPropertiesImpl(container, options, null); } @@ -310,14 +306,15 @@ public GetContainerPropertiesResult getContainerMetadata(String container) throw return getContainerMetadata(container, new BlobServiceOptions()); } - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException { + public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) + throws ServiceException { return getContainerPropertiesImpl(container, options, "metadata"); } - private GetContainerPropertiesResult getContainerPropertiesImpl(String container, BlobServiceOptions options, String operation) throws ServiceException { + private GetContainerPropertiesResult getContainerPropertiesImpl(String container, BlobServiceOptions options, + String operation) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); webResource = addOptionalQueryParam(webResource, "comp", operation); - webResource = setCanonicalizedResource(webResource, operation); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -337,8 +334,8 @@ public GetContainerACLResult getContainerACL(String container) throws ServiceExc } public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, "acl"); + WebResource webResource = getResource(options).path(container).queryParam("resType", "container") + .queryParam("comp", "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -362,8 +359,8 @@ public void setContainerACL(String container, ContainerACL acl) throws ServiceEx } public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "acl"); - webResource = setCanonicalizedResource(webResource, "acl"); + WebResource webResource = getResource(options).path(container).queryParam("resType", "container") + .queryParam("comp", "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); @@ -378,9 +375,10 @@ public void setContainerMetadata(String container, HashMap metad setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); } - public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container").queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, "metadata"); + public void setContainerMetadata(String container, HashMap metadata, + SetContainerMetadataOptions options) throws ServiceException { + WebResource webResource = getResource(options).path(container).queryParam("resType", "container") + .queryParam("comp", "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalMetadataHeader(builder, metadata); @@ -396,7 +394,6 @@ public ListContainersResult listContainers() throws ServiceException { public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { 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); @@ -412,8 +409,8 @@ public ListBlobsResult listBlobs(String container) throws ServiceException { } public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("comp", "list").queryParam("resType", "container"); - webResource = setCanonicalizedResource(webResource, "list"); + WebResource webResource = getResource(options).path(container).queryParam("comp", "list") + .queryParam("resType", "container"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); @@ -429,9 +426,9 @@ public void createPageBlob(String container, String blob, int length) throws Ser createPageBlob(container, blob, length, new CreateBlobOptions()); } - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); @@ -448,9 +445,9 @@ public void createBlockBlob(String container, String blob, InputStream contentSt createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); } - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); - webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -465,9 +462,9 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob) return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); } - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); - webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -484,9 +481,9 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); } - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, "metadata"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -508,9 +505,9 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob) return setBlobProperties(container, blob, new SetBlobPropertiesOptions()); } - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); @@ -539,14 +536,14 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, return result; } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) + throws ServiceException { return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) - throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, + SetBlobMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, "metadata"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -569,7 +566,6 @@ public GetBlobResult getBlob(String container, String blob) throws ServiceExcept public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); - webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -595,11 +591,11 @@ public void deleteBlob(String container, String blob) throws ServiceException { public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" : "include"); + builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" + : "include"); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder.delete(); @@ -609,9 +605,9 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); } - public CreateBlobSnapshotResult 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"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -630,18 +626,20 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob return blobSnapshot; } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) + throws ServiceException { copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, + String sourceBlob, CopyBlobOptions options) { WebResource webResource = getResource(options).path(destinationContainer).path(destinationBlob); - webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); - builder = addOptionalHeader(builder, "x-ms-copy-source", getCopyBlobSourceName(sourceContainer, sourceBlob, options)); + builder = addOptionalHeader(builder, "x-ms-copy-source", + getCopyBlobSourceName(sourceContainer, sourceBlob, options)); builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); @@ -654,7 +652,8 @@ public AcquireLeaseResult acquireLease(String container, String blob) throws Ser return acquireLease(container, blob, new AcquireLeaseOptions()); } - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) + throws ServiceException { return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); } @@ -662,7 +661,8 @@ public AcquireLeaseResult renewLease(String container, String blob, String lease return renewLease(container, blob, leaseId, new BlobServiceOptions()); } - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); } @@ -670,7 +670,8 @@ public void releaseLease(String container, String blob, String leaseId) throws S releaseLease(container, blob, leaseId, new BlobServiceOptions()); } - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); } @@ -678,14 +679,14 @@ public void breakLease(String container, String blob, String leaseId) throws Ser breakLease(container, blob, leaseId, new BlobServiceOptions()); } - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); } - private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, - AccessCondition accessCondition) throws ServiceException { + private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, + BlobServiceOptions options, AccessCondition accessCondition) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "lease"); - webResource = setCanonicalizedResource(webResource, "lease"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); @@ -705,24 +706,25 @@ 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); } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) - throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream) throws ServiceException { return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, - CreateBlobPagesOptions options) throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); } - private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, PageRange range, long length, - InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { + 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, range.getStart(), range.getEnd()); @@ -750,9 +752,9 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro return listBlobRegions(container, blob, new ListBlobRegionsOptions()); } - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "pagelist"); - webResource = setCanonicalizedResource(webResource, "pagelist"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); @@ -770,15 +772,15 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List return result; } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) + throws ServiceException { createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) - throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, + CreateBlobBlockOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "block"); webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - webResource = setCanonicalizedResource(webResource, "block"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -792,9 +794,9 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); } - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, "blocklist"); Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); @@ -814,9 +816,9 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); } - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) + throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - webResource = setCanonicalizedResource(webResource, "blocklist"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); 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 c480f975be11f..88a727ed67aaa 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 @@ -19,21 +19,6 @@ public static void ThrowIfError(ClientResponse 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(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java index 0f2537e444529..ed62583866966 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.implementation; -import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; @@ -12,6 +11,7 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.services.blob.BlobConfiguration; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; @@ -31,20 +31,25 @@ public SharedKeyFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - // Only sign if no other filter has done it yet - if (cr.getHeaders().getFirst("Authorization") == null) { - sign(cr); - } + // Only sign if no other filter is handling authorization + if (cr.getProperties().get(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER) == null) { + cr.getProperties().put(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER, null); + + // Register ourselves as listener so we are called back when the entity is + // written to the output stream by the next filter in line. + if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { + cr.getProperties().put(EntityStreamingListener.class.getName(), this); + } - // Register ourselves as listener so we are called back when the entity is - // written to the output stream by the next filter in line. - if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { - cr.getProperties().put(EntityStreamingListener.class.getName(), this); } - return this.getNext().handle(cr); } + public void onBeforeStreamingEntity(ClientRequest clientRequest) { + // All headers should be known at this point, time to sign! + sign(clientRequest); + } + /* * StringToSign = VERB + "\n" + * Content-Encoding + "\n" @@ -66,13 +71,12 @@ public void sign(ClientRequest cr) { addOptionalDateHeader(cr); // build signed string - String stringToSign = - cr.getMethod() + "\n" + getHeader(cr, "Content-Encoding") + "\n" + getHeader(cr, "Content-Language") - + "\n" + getHeader(cr, "Content-Length") + "\n" + getHeader(cr, "Content-MD5") + "\n" - + getHeader(cr, "Content-Type") + "\n" + getHeader(cr, "Date") + "\n" - + getHeader(cr, "If-Modified-Since") + "\n" + getHeader(cr, "If-Match") + "\n" - + getHeader(cr, "If-None-Match") + "\n" + getHeader(cr, "If-Unmodified-Since") + "\n" - + getHeader(cr, "Range") + "\n"; + String stringToSign = cr.getMethod() + "\n" + getHeader(cr, "Content-Encoding") + "\n" + + getHeader(cr, "Content-Language") + "\n" + getHeader(cr, "Content-Length") + "\n" + + getHeader(cr, "Content-MD5") + "\n" + getHeader(cr, "Content-Type") + "\n" + getHeader(cr, "Date") + + "\n" + getHeader(cr, "If-Modified-Since") + "\n" + getHeader(cr, "If-Match") + "\n" + + getHeader(cr, "If-None-Match") + "\n" + getHeader(cr, "If-Unmodified-Since") + "\n" + + getHeader(cr, "Range") + "\n"; stringToSign += getCanonicalizedHeaders(cr); stringToSign += getCanonicalizedResource(cr); @@ -158,7 +162,7 @@ private String getCanonicalizedResource(ClientRequest cr) { // 3. Retrieve all query parameters on the resource URI, including the comp parameter if it exists. // 6. URL-decode each query parameter name and value. - List queryParams = getQueryParams(cr.getURI().getQuery()); + List queryParams = SharedKeyUtils.getQueryParams(cr.getURI().getQuery()); // 4. Convert all parameter names to lowercase. for (QueryParam param : queryParams) { @@ -191,75 +195,7 @@ private String getCanonicalizedResource(ClientRequest cr) { return result; } - private List getQueryParams(String queryString) { - ArrayList result = new ArrayList(); - - if (queryString != null) { - String[] params = queryString.split("&"); - for (String param : params) { - result.add(getQueryParam(param)); - } - } - - return result; - } - - private QueryParam getQueryParam(String param) { - QueryParam result = new QueryParam(); - - int index = param.indexOf("="); - if (index < 0) { - result.setName(param); - } - else { - result.setName(param.substring(0, index)); - - String value = param.substring(index + 1); - int commaIndex = value.indexOf(','); - if (commaIndex < 0) { - result.addValue(value); - } - else { - for (String v : value.split(",")) { - result.addValue(v); - } - } - } - - return result; - } - - private static class QueryParam implements Comparable { - private String name; - private final List values = new ArrayList(); - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getValues() { - return values; - } - - public void addValue(String value) { - values.add(value); - } - - public int compareTo(QueryParam o) { - return this.name.compareTo(o.name); - } - } - private String getHeader(ClientRequest cr, String headerKey) { return SharedKeyUtils.getHeader(cr, headerKey); } - - public void onBeforeStreamingEntity(ClientRequest clientRequest) { - // All headers should be known at this point, time to sign! - sign(clientRequest); - } } 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 0c86663cac1f2..000f1a3a9f89b 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 @@ -1,9 +1,7 @@ package com.microsoft.windowsazure.services.blob.implementation; -import java.util.ArrayList; -import java.util.Collections; import java.util.Date; -import java.util.Locale; +import java.util.List; import javax.inject.Named; @@ -11,12 +9,13 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.services.blob.BlobConfiguration; +import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; 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; -public class SharedKeyLiteFilter extends ClientFilter { +public class SharedKeyLiteFilter extends ClientFilter implements EntityStreamingListener { private static Log log = LogFactory.getLog(SharedKeyLiteFilter.class); private final String accountName; @@ -31,17 +30,23 @@ public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String account @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - - // Only sign if no other filter has done it yet - if (cr.getHeaders().getFirst("Authorization") == null) { - sign(cr); + // Only sign if no other filter is handling authorization + if (cr.getProperties().get(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER) == null) { + cr.getProperties().put(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER, null); + + // Register ourselves as listener so we are called back when the entity is + // written to the output stream by the next filter in line. + if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { + cr.getProperties().put(EntityStreamingListener.class.getName(), this); + } } return this.getNext().handle(cr); } - private String nullEmpty(String value) { - return value != null ? value : ""; + public void onBeforeStreamingEntity(ClientRequest clientRequest) { + // All headers should be known at this point, time to sign! + sign(clientRequest); } /* @@ -95,27 +100,35 @@ public void sign(ClientRequest cr) { * CanonicalizedHeaders string by concatenating all headers in this list into a single string. */ private String addCanonicalizedHeaders(ClientRequest cr) { - ArrayList msHeaders = new ArrayList(); - for (String key : cr.getHeaders().keySet()) { - if (key.toLowerCase(Locale.US).startsWith("x-ms-")) { - msHeaders.add(key.toLowerCase(Locale.US)); - } - } + return SharedKeyUtils.getCanonicalizedHeaders(cr); + } - Collections.sort(msHeaders); + /** + * This format supports Shared Key and Shared Key Lite for all versions of the Table service, and Shared Key Lite + * for the 2009-09-19 version of the Blob and Queue services. This format is identical to that used with previous + * versions of the storage services. Construct the CanonicalizedResource string in this format as follows: + * + * 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns + * the resource being accessed. + * + * 2. Append the resource's encoded URI path. If the request URI addresses a component of the resource, append the + * appropriate query string. The query string should include the question mark and the comp parameter (for example, + * ?comp=metadata). No other parameters should be included on the query string. + */ + private String addCanonicalizedResource(ClientRequest cr) { + String result = "/" + this.accountName; - String result = ""; - for (String msHeader : msHeaders) { - result += msHeader + ":" + cr.getHeaders().getFirst(msHeader) + "\n"; + result += cr.getURI().getPath(); + + List queryParams = SharedKeyUtils.getQueryParams(cr.getURI().getQuery()); + for (QueryParam p : queryParams) { + if ("comp".equals(p.getName())) { + result += "?" + p.getName() + "=" + p.getValues().get(0); + } } return result; } - private String addCanonicalizedResource(ClientRequest cr) { - String canonicalizedResource = (String) cr.getProperties().get("canonicalizedResource"); - return nullEmpty(canonicalizedResource); - } - private String getHeader(ClientRequest cr, String headerKey) { return SharedKeyUtils.getHeader(cr, headerKey); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java index b2b736fb30e57..b0ca62d7aa767 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java @@ -8,6 +8,8 @@ import com.sun.jersey.api.client.ClientRequest; public class SharedKeyUtils { + public static final String AUTHORIZATION_FILTER_MARKER = SharedKeyUtils.class.getName(); + /* * Constructing the Canonicalized Headers String * @@ -50,4 +52,67 @@ public static String getHeader(ClientRequest cr, String headerKey) { private static String nullEmpty(String value) { return value != null ? value : ""; } + + public static List getQueryParams(String queryString) { + ArrayList result = new ArrayList(); + + if (queryString != null) { + String[] params = queryString.split("&"); + for (String param : params) { + result.add(getQueryParam(param)); + } + } + + return result; + } + + private static QueryParam getQueryParam(String param) { + QueryParam result = new QueryParam(); + + int index = param.indexOf("="); + if (index < 0) { + result.setName(param); + } + else { + result.setName(param.substring(0, index)); + + String value = param.substring(index + 1); + int commaIndex = value.indexOf(','); + if (commaIndex < 0) { + result.addValue(value); + } + else { + for (String v : value.split(",")) { + result.addValue(v); + } + } + } + + return result; + } + + public static class QueryParam implements Comparable { + private String name; + private final List values = new ArrayList(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getValues() { + return values; + } + + public void addValue(String value) { + values.add(value); + } + + public int compareTo(QueryParam o) { + return this.name.compareTo(o.name); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index d61daea82911c..d882cd1d5a001 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -44,8 +44,8 @@ public class QueueRestProxy implements QueueContract { private final SharedKeyLiteFilter filter; @Inject - public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, @Named(QueueConfiguration.URL) String url, - SharedKeyLiteFilter filter) { + public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, + @Named(QueueConfiguration.URL) String url, SharedKeyLiteFilter filter) { this.channel = channel; this.accountName = accountName; @@ -56,7 +56,8 @@ public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) St channel.addFilter(filter); } - public QueueRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + public QueueRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, + SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; @@ -102,28 +103,13 @@ private WebResource getResource(QueueServiceOptions options) { 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 GetServicePropertiesResult getServiceProperties() throws ServiceException { return getServiceProperties(new QueueServiceOptions()); } public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, "properties"); + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -136,9 +122,10 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser setServiceProperties(serviceProperties, new QueueServiceOptions()); } - public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service").queryParam("comp", "properties"); - webResource = setCanonicalizedResource(webResource, "properties"); + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) + throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -153,7 +140,6 @@ public void createQueue(String queue) throws ServiceException { public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { 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()); @@ -168,7 +154,6 @@ public void deleteQueue(String queue) throws ServiceException { public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue); - webResource = setCanonicalizedResource(webResource, null); WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -181,7 +166,6 @@ public ListQueuesResult listQueues() throws ServiceException { public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { 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); @@ -200,7 +184,6 @@ public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceExcep public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata"); - webResource = setCanonicalizedResource(webResource, "metadata"); Builder builder = webResource.header("x-ms-version", API_VERSION); @@ -208,7 +191,8 @@ public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions ThrowIfError(response); GetQueueMetadataResult result = new GetQueueMetadataResult(); - result.setApproximateMessageCount(Integer.parseInt(response.getHeaders().getFirst("x-ms-approximate-messages-count"))); + result.setApproximateMessageCount(Integer.parseInt(response.getHeaders().getFirst( + "x-ms-approximate-messages-count"))); result.setMetadata(getMetadataFromHeaders(response)); return result; @@ -218,9 +202,9 @@ public void setQueueMetadata(String queue, HashMap metadata) thr setQueueMetadata(queue, metadata, new QueueServiceOptions()); } - public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) + throws ServiceException { 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); @@ -235,7 +219,6 @@ public void createMessage(String queue, String messageText) throws ServiceExcept 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()); webResource = addOptionalQueryParam(webResource, "messagettl", options.getTimeToLiveInSeconds()); @@ -248,15 +231,15 @@ public void createMessage(String queue, String messageText, CreateMessageOptions builder.type("application/xml").post(queueMessage); } - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) - throws ServiceException { - return updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, new QueueServiceOptions()); + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds) throws ServiceException { + 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 { + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); - webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt); webResource = addOptionalQueryParam(webResource, "visibilitytimeout", visibilityTimeoutInSeconds); @@ -281,7 +264,6 @@ public ListMessagesResult listMessages(String queue) throws ServiceException { public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue).path("messages"); - webResource = setCanonicalizedResource(webResource, null); webResource = addOptionalQueryParam(webResource, "visibilitytimeout", options.getVisibilityTimeoutInSeconds()); webResource = addOptionalQueryParam(webResource, "numofmessages", options.getNumberOfMessages()); @@ -296,7 +278,6 @@ public PeekMessagesResult peekMessages(String queue) throws ServiceException { public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { 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); @@ -308,9 +289,9 @@ public void deleteMessage(String queue, String messageId, String popReceipt) thr deleteMessage(queue, messageId, popReceipt, new QueueServiceOptions()); } - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) + throws ServiceException { 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); @@ -324,7 +305,6 @@ public void clearMessages(String queue) throws ServiceException { public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(queue).path("messages"); - webResource = setCanonicalizedResource(webResource, null); Builder builder = webResource.header("x-ms-version", API_VERSION); From 00ba77441cca8dc19c53d6d02408cf58e06714f7 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 15:01:31 -0800 Subject: [PATCH 212/664] Clean up blob service code Forcing the Content-Type and empty body for PUT request is not needed anymore, as this is taken care of by our custom HTTP ClientHandler. --- .../blob/implementation/BlobRestProxy.java | 40 +++++++------------ .../HttpURLConnectionClientHandler.java | 28 ++++++++++--- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 920b5c6ab9c4f..527f9fe991dea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -261,8 +261,7 @@ public void setServiceProperties(ServiceProperties serviceProperties, BlobServic 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); + builder.put(serviceProperties); } public void createContainer(String container) throws ServiceException { @@ -276,8 +275,7 @@ public void createContainer(String container, CreateContainerOptions options) th builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + builder.put(); } public void deleteContainer(String container) throws ServiceException { @@ -367,8 +365,8 @@ public void setContainerACL(String container, ContainerACL acl, BlobServiceOptio ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); si.setSignedIdentifiers(acl.getSignedIdentifiers()); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/xml").put(si); + + builder.put(si); } public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { @@ -384,8 +382,7 @@ public void setContainerMetadata(String container, HashMap metad builder = addOptionalMetadataHeader(builder, metadata); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + builder.put(); } public ListContainersResult listContainers() throws ServiceException { @@ -437,8 +434,7 @@ public void createPageBlob(String container, String blob, int length, CreateBlob builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); builder = addPutBlobHeaders(options, builder); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/octet-stream").put(new byte[0]); + builder.put(); } public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { @@ -521,8 +517,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ClientResponse response = builder.put(ClientResponse.class); ThrowIfError(response); SetBlobPropertiesResult result = new SetBlobPropertiesResult(); @@ -550,8 +545,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash builder = addOptionalMetadataHeader(builder, metadata); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ClientResponse response = builder.put(ClientResponse.class); ThrowIfError(response); SetBlobMetadataResult result = new SetBlobMetadataResult(); @@ -614,8 +608,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ClientResponse response = builder.put(ClientResponse.class); ThrowIfError(response); CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); @@ -644,8 +637,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - builder.type("text/plain").put(""); + builder.put(); } public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { @@ -694,7 +686,7 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St builder = addOptionalAccessContitionHeader(builder, accessCondition); // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.type("text/plain").put(ClientResponse.class, ""); + ClientResponse response = builder.put(ClientResponse.class); ThrowIfError(response); AcquireLeaseResult result = new AcquireLeaseResult(); @@ -734,9 +726,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont builder = addOptionalHeader(builder, "x-ms-page-write", action); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - Object content = (contentStream == null ? new byte[0] : contentStream); - ClientResponse response = builder.type("application/octet-stream").put(ClientResponse.class, content); + ClientResponse response = builder.put(ClientResponse.class, contentStream); ThrowIfError(response); CreateBlobPagesResult result = new CreateBlobPagesResult(); @@ -786,8 +776,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/octet-stream").put(contentStream); + builder.put(contentStream); } public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { @@ -808,8 +797,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList, builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/xml").put(blockList); + builder.put(blockList); } public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java index cb0c994b85b37..46bac77e3adb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java @@ -171,6 +171,17 @@ private ClientResponse doHandle(final ClientRequest clientRequest) throws IOExce // Write the entity (if any) Object entity = clientRequest.getEntity(); + + // If no entity and "PUT method, force an empty entity to force the underlying + // connection to set the "Content-Length" header to 0. + // This is needed because some web servers require a "Content-Length" field for + // all PUT method calls (unless chunked encoding is used). + if (entity == null && "PUT".equals(clientRequest.getMethod())) { + entity = new byte[0]; + clientRequest.setEntity(entity); + } + + // Send headers and entity on the wire if (entity != null) { urlConnection.setDoOutput(true); @@ -186,9 +197,8 @@ public void onRequestEntitySize(long size) { urlConnection.setFixedLengthStreamingMode((int) size); } else { - Integer chunkedEncodingSize = - (Integer) clientRequest.getProperties() - .get(ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE); + Integer chunkedEncodingSize = (Integer) clientRequest.getProperties().get( + ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE); if (chunkedEncodingSize != null) { inStreamingMode = true; entityStreamingListener.onBeforeStreamingEntity(clientRequest); @@ -217,8 +227,8 @@ public OutputStream onGetOutputStream() throws IOException { } private EntityStreamingListener getEntityStreamingListener(final ClientRequest clientRequest) { - EntityStreamingListener result = - (EntityStreamingListener) clientRequest.getProperties().get(EntityStreamingListener.class.getName()); + EntityStreamingListener result = (EntityStreamingListener) clientRequest.getProperties().get( + EntityStreamingListener.class.getName()); if (result != null) return result; @@ -227,6 +237,14 @@ private EntityStreamingListener getEntityStreamingListener(final ClientRequest c } private void setContentLengthHeader(ClientRequest clientRequest, int size) { + // Skip if already set + if (clientRequest.getHeaders().getFirst("Content-Length") != null) + return; + + // Skip if size is unknown + if (size < 0) + return; + clientRequest.getHeaders().putSingle("Content-Length", size); } From 3ffb926714bf2c703f461e4be5f0f6f166e6edbc Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 16:19:11 -0800 Subject: [PATCH 213/664] Add support for SharedKey to queue service Also remove extra code for "put" methods (not needed anymore) --- .../windowsazure/services/queue/Exports.java | 15 ++++++++++ .../queue/implementation/QueueRestProxy.java | 29 ++++++++----------- .../queue/implementation/SharedKeyFilter.java | 12 ++++++++ .../implementation/SharedKeyLiteFilter.java | 24 +++------------ 4 files changed, 43 insertions(+), 37 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.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 index d86505cbc46ce..71b4e8f28759f 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,14 @@ package com.microsoft.windowsazure.services.queue; +import java.util.Map; + import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; +import com.microsoft.windowsazure.services.queue.implementation.SharedKeyFilter; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; +import com.sun.jersey.api.client.config.ClientConfig; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { @@ -12,5 +17,15 @@ public void register(Builder.Registry registry) { registry.add(QueueExceptionProcessor.class); registry.add(QueueRestProxy.class); registry.add(SharedKeyLiteFilter.class); + registry.add(SharedKeyFilter.class); + + registry.add(new Builder.Factory() { + public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); + //client.addFilter(new LoggingFilter()); + return client; + } + }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index d882cd1d5a001..6addf20dbf257 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -9,6 +9,7 @@ import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers; import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; import com.microsoft.windowsazure.services.queue.QueueConfiguration; @@ -27,7 +28,6 @@ import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; -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; @@ -36,16 +36,16 @@ public class QueueRestProxy implements QueueContract { //private static Log log = LogFactory.getLog(QueueRestProxy.class); private static final String API_VERSION = "2011-08-18"; - private final Client channel; + private final HttpURLConnectionClient channel; private final String accountName; private final String url; private final RFC1123DateConverter dateMapper; private final ServiceFilter[] filters; - private final SharedKeyLiteFilter filter; + private final SharedKeyFilter filter; @Inject - public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, - @Named(QueueConfiguration.URL) String url, SharedKeyLiteFilter filter) { + public QueueRestProxy(HttpURLConnectionClient channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, + @Named(QueueConfiguration.URL) String url, SharedKeyFilter filter) { this.channel = channel; this.accountName = accountName; @@ -56,8 +56,8 @@ public QueueRestProxy(Client channel, @Named(QueueConfiguration.ACCOUNT_NAME) St channel.addFilter(filter); } - public QueueRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, - SharedKeyLiteFilter filter, RFC1123DateConverter dateMapper) { + public QueueRestProxy(HttpURLConnectionClient channel, ServiceFilter[] filters, String accountName, String url, + SharedKeyFilter filter, RFC1123DateConverter dateMapper) { this.channel = channel; this.filters = filters; @@ -129,8 +129,7 @@ public void setServiceProperties(ServiceProperties serviceProperties, QueueServi 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); + builder.put(serviceProperties); } public void createQueue(String queue) throws ServiceException { @@ -144,8 +143,7 @@ public void createQueue(String queue, CreateQueueOptions options) throws Service 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(""); + builder.put(); } public void deleteQueue(String queue) throws ServiceException { @@ -209,8 +207,7 @@ public void setQueueMetadata(String queue, HashMap metadata, Que 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(""); + builder.put(); } public void createMessage(String queue, String messageText) throws ServiceException { @@ -227,8 +224,7 @@ public void createMessage(String queue, String messageText, CreateMessageOptions QueueMessage queueMessage = new QueueMessage(); queueMessage.setMessageText(messageText); - // Note: Add content type here to enable proper HMAC signing - builder.type("application/xml").post(queueMessage); + builder.post(queueMessage); } public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, @@ -248,8 +244,7 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String 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); + ClientResponse response = builder.put(ClientResponse.class, queueMessage); ThrowIfError(response); UpdateMessageResult result = new UpdateMessageResult(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java new file mode 100644 index 0000000000000..e251bb2b834a3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java @@ -0,0 +1,12 @@ +package com.microsoft.windowsazure.services.queue.implementation; + +import javax.inject.Named; + +import com.microsoft.windowsazure.services.queue.QueueConfiguration; + +public class SharedKeyFilter extends com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter { + public SharedKeyFilter(@Named(QueueConfiguration.ACCOUNT_NAME) String accountName, + @Named(QueueConfiguration.ACCOUNT_KEY) String accountKey) { + super(accountName, accountKey); + } +} 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 3c25464216964..4bbe297f4ee51 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 @@ -3,26 +3,10 @@ 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; -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); +public class SharedKeyLiteFilter extends com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter { + public SharedKeyLiteFilter(@Named(QueueConfiguration.ACCOUNT_NAME) String accountName, + @Named(QueueConfiguration.ACCOUNT_KEY) String accountKey) { + super(accountName, accountKey); } } From 3645daa843426fa1c77e52e1b1c2f034f42380b9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 16:25:37 -0800 Subject: [PATCH 214/664] Moving classes around --- .../windowsazure/services/blob/Exports.java | 13 ------------- .../services/blob/implementation/BlobRestProxy.java | 4 +++- .../blob/implementation/SharedKeyFilter.java | 1 + .../blob/implementation/SharedKeyLiteFilter.java | 1 + .../services/blob/models/BlockList.java | 2 +- .../services/blob/models/ListBlobBlocksResult.java | 2 +- .../windowsazure/services/queue/Exports.java | 13 ------------- .../queue/implementation/QueueRestProxy.java | 4 ++-- .../jersey}/Base64StringAdapter.java | 2 +- .../jersey}/EntityStreamingListener.java | 2 +- .../windowsazure/utils/jersey/Exports.java | 9 +++++++++ .../jersey}/HttpURLConnectionClient.java | 2 +- .../jersey}/HttpURLConnectionClientHandler.java | 4 ++-- .../jersey}/JerseyHelpers.java | 2 +- 14 files changed, 24 insertions(+), 37 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{services/blob/implementation => utils/jersey}/Base64StringAdapter.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{services/blob/implementation => utils/jersey}/EntityStreamingListener.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{services/blob/implementation => utils/jersey}/HttpURLConnectionClient.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{services/blob/implementation => utils/jersey}/HttpURLConnectionClientHandler.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{services/blob/implementation => utils/jersey}/JerseyHelpers.java (98%) 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 2ac8a38de32cf..8238988aedb25 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 @@ -1,14 +1,10 @@ package com.microsoft.windowsazure.services.blob; -import java.util.Map; - import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; -import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; -import com.sun.jersey.api.client.config.ClientConfig; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { @@ -18,14 +14,5 @@ public void register(Builder.Registry registry) { registry.add(BlobRestProxy.class); registry.add(SharedKeyLiteFilter.class); registry.add(SharedKeyFilter.class); - - registry.add(new Builder.Factory() { - public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); - //client.addFilter(new LoggingFilter()); - return client; - } - }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 527f9fe991dea..b037a16c8f273 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -12,7 +12,6 @@ import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.BlobContract; -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.AcquireLeaseResult; @@ -56,6 +55,9 @@ import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; +import com.microsoft.windowsazure.utils.jersey.HttpURLConnectionClient; +import com.microsoft.windowsazure.utils.jersey.JerseyHelpers; +import com.microsoft.windowsazure.utils.jersey.JerseyHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java index ed62583866966..e2879ee5976c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -12,6 +12,7 @@ import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; +import com.microsoft.windowsazure.utils.jersey.EntityStreamingListener; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; 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 000f1a3a9f89b..4173055e93aa8 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 @@ -10,6 +10,7 @@ import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; +import com.microsoft.windowsazure.utils.jersey.EntityStreamingListener; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index 2ef2c88a0a32b..e3da496648545 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.windowsazure.services.blob.implementation.Base64StringAdapter; +import com.microsoft.windowsazure.utils.jersey.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class BlockList { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java index 952ef9a004686..1181bb108b69b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.windowsazure.services.blob.implementation.Base64StringAdapter; +import com.microsoft.windowsazure.utils.jersey.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class ListBlobBlocksResult { 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 71b4e8f28759f..a86d091f21aa9 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,14 +1,10 @@ package com.microsoft.windowsazure.services.queue; -import java.util.Map; - import com.microsoft.windowsazure.common.Builder; -import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyFilter; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; -import com.sun.jersey.api.client.config.ClientConfig; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { @@ -18,14 +14,5 @@ public void register(Builder.Registry registry) { registry.add(QueueRestProxy.class); registry.add(SharedKeyLiteFilter.class); registry.add(SharedKeyFilter.class); - - registry.add(new Builder.Factory() { - public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); - //client.addFilter(new LoggingFilter()); - return client; - } - }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 6addf20dbf257..168f6944cfbbc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -9,8 +9,6 @@ import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; -import com.microsoft.windowsazure.services.blob.implementation.HttpURLConnectionClient; -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.QueueContract; @@ -28,6 +26,8 @@ import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; +import com.microsoft.windowsazure.utils.jersey.HttpURLConnectionClient; +import com.microsoft.windowsazure.utils.jersey.JerseyHelpers; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java index bcfae6ce4fe86..f9386afe00add 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob.implementation; +package com.microsoft.windowsazure.utils.jersey; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java index fa5774e5c2a44..64e37e7cf87bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/EntityStreamingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob.implementation; +package com.microsoft.windowsazure.utils.jersey; import com.sun.jersey.api.client.ClientRequest; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java index aa6cc310da149..004a9dde17e8f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java @@ -29,5 +29,14 @@ public Client create(String profile, Builder builder, Map proper return client; } }); + + registry.add(new Builder.Factory() { + public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { + ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); + HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); + //client.addFilter(new LoggingFilter()); + return client; + } + }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java index 6824d019cf7d1..ee8c27cf541e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob.implementation; +package com.microsoft.windowsazure.utils.jersey; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java index 46bac77e3adb0..75d89e257aebf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob.implementation; +package com.microsoft.windowsazure.utils.jersey; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -13,7 +13,7 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.services.blob.implementation.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.utils.jersey.JerseyHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; 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/utils/jersey/JerseyHelpers.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/JerseyHelpers.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/JerseyHelpers.java index 88a727ed67aaa..9b66713ce92b2 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/utils/jersey/JerseyHelpers.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.blob.implementation; +package com.microsoft.windowsazure.utils.jersey; import java.util.HashMap; import java.util.List; From 5f34af994cce90ae6f53cc0a797c4628d3c890df Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Fri, 18 Nov 2011 16:37:29 -0800 Subject: [PATCH 215/664] Initial Storage Push Signed-off-by: Joe Giardino --- .../blob/client/AccessPolicyResponse.java | 210 ++ .../services/blob/client/BlobAttributes.java | 56 + .../services/blob/client/BlobConstants.java | 343 +++ .../blob/client/BlobContainerAttributes.java | 71 + .../blob/client/BlobContainerPermissions.java | 87 + .../blob/client/BlobContainerProperties.java | 59 + .../client/BlobContainerPublicAccessType.java | 26 + .../client/BlobDeserializationHelper.java | 557 ++++ .../services/blob/client/BlobInputStream.java | 627 +++++ .../blob/client/BlobListingContext.java | 88 + .../blob/client/BlobListingDetails.java | 41 + .../blob/client/BlobOutputStream.java | 614 +++++ .../services/blob/client/BlobProperties.java | 271 ++ .../services/blob/client/BlobRequest.java | 970 +++++++ .../blob/client/BlobRequestOptions.java | 164 ++ .../services/blob/client/BlobResponse.java | 120 + .../services/blob/client/BlobType.java | 50 + .../services/blob/client/BlockEntry.java | 66 + .../blob/client/BlockListingFilter.java | 23 + .../services/blob/client/BlockSearchMode.java | 24 + .../services/blob/client/CloudBlob.java | 2438 +++++++++++++++++ .../services/blob/client/CloudBlobClient.java | 705 +++++ .../blob/client/CloudBlobContainer.java | 1895 +++++++++++++ .../blob/client/CloudBlobDirectory.java | 461 ++++ .../services/blob/client/CloudBlockBlob.java | 648 +++++ .../services/blob/client/CloudPageBlob.java | 679 +++++ .../blob/client/ContainerListingDetails.java | 38 + .../blob/client/ContainerRequest.java | 392 +++ .../blob/client/ContainerResponse.java | 64 + .../blob/client/DeleteSnapshotsOption.java | 26 + .../blob/client/GetBlockListResponse.java | 111 + .../blob/client/GetPageRangesResponse.java | 98 + .../services/blob/client/ListBlobItem.java | 45 + .../blob/client/ListBlobsResponse.java | 144 + .../blob/client/ListContainersResponse.java | 152 + .../blob/client/PageOperationType.java | 18 + .../services/blob/client/PageProperties.java | 56 + .../services/blob/client/PageRange.java | 71 + .../blob/client/SharedAccessPermissions.java | 73 + .../blob/client/SharedAccessPolicy.java | 161 ++ .../client/SharedAccessSignatureHelper.java | 237 ++ .../core/storage/AccessCondition.java | 353 +++ .../core/storage/CloudStorageAccount.java | 686 +++++ .../services/core/storage/Constants.java | 457 +++ .../services/core/storage/Credentials.java | 106 + .../core/storage/DoesServiceRequest.java | 19 + .../services/core/storage/EventListener.java | 20 + .../storage/EventListenerMultiCaster.java | 62 + .../services/core/storage/LeaseStatus.java | 53 + .../core/storage/LoggingOperations.java | 24 + .../core/storage/LoggingProperties.java | 71 + .../services/core/storage/MetricsLevel.java | 23 + .../core/storage/MetricsProperties.java | 68 + .../core/storage/OperationContext.java | 221 ++ .../services/core/storage/RequestOptions.java | 87 + .../services/core/storage/RequestResult.java | 194 ++ .../core/storage/ResponseReceivedEvent.java | 51 + .../core/storage/ResultContinuation.java | 128 + .../core/storage/ResultContinuationType.java | 31 + .../services/core/storage/ResultSegment.java | 113 + .../core/storage/RetryExponentialRetry.java | 131 + .../core/storage/RetryLinearRetry.java | 79 + .../services/core/storage/RetryNoRetry.java | 66 + .../services/core/storage/RetryPolicy.java | 84 + .../core/storage/RetryPolicyFactory.java | 24 + .../services/core/storage/RetryResult.java | 65 + .../services/core/storage/ServiceClient.java | 346 +++ .../core/storage/ServiceProperties.java | 448 +++ .../core/storage/StorageCredentials.java | 326 +++ .../StorageCredentialsAccountAndKey.java | 366 +++ .../storage/StorageCredentialsAnonymous.java | 267 ++ ...orageCredentialsSharedAccessSignature.java | 298 ++ .../core/storage/StorageErrorCode.java | 124 + .../core/storage/StorageErrorCodeStrings.java | 220 ++ .../core/storage/StorageException.java | 244 ++ .../StorageExtendedErrorInformation.java | 83 + .../services/core/storage/StorageKey.java | 200 ++ .../services/core/storage/utils/Base64.java | 294 ++ .../core/storage/utils/PathUtility.java | 449 +++ .../core/storage/utils/StreamDescriptor.java | 48 + .../core/storage/utils/UriQueryBuilder.java | 152 + .../services/core/storage/utils/Utility.java | 929 +++++++ .../utils/implementation/BaseRequest.java | 538 ++++ .../utils/implementation/BaseResponse.java | 126 + .../BlobQueueFullCanonicalizer.java | 54 + .../BlobQueueLiteCanonicalizer.java | 50 + .../utils/implementation/Canonicalizer.java | 378 +++ .../implementation/CanonicalizerFactory.java | 127 + .../implementation/DeserializationHelper.java | 58 + .../utils/implementation/ExecutionEngine.java | 306 +++ .../implementation/LazySegmentedIterator.java | 141 + .../utils/implementation/LeaseAction.java | 48 + .../utils/implementation/ListingContext.java | 83 + .../SegmentedStorageOperation.java | 62 + .../implementation/StorageErrorResponse.java | 142 + .../implementation/StorageOperation.java | 162 ++ .../TableLiteCanonicalizer.java | 54 + .../services/queue/client/CloudQueue.java | 1316 +++++++++ .../queue/client/CloudQueueClient.java | 362 +++ .../queue/client/CloudQueueMessage.java | 240 ++ .../queue/client/ListQueuesResponse.java | 151 + .../queue/client/MessageUpdateFields.java | 34 + .../services/queue/client/QueueConstants.java | 85 + .../client/QueueDeserializationHelper.java | 218 ++ .../queue/client/QueueListingDetails.java | 38 + .../queue/client/QueueMessageType.java | 18 + .../services/queue/client/QueueRequest.java | 391 +++ .../queue/client/QueueRequestOptions.java | 37 + .../services/queue/client/QueueResponse.java | 24 + 109 files changed, 26232 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java new file mode 100644 index 0000000000000..bb1e82a04ab15 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java @@ -0,0 +1,210 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.InputStream; +import java.text.ParseException; +import java.util.HashMap; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class used to parse SharedAccessPolicies from an input stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class AccessPolicyResponse { + /** + * Holds a flag indicating if the response has been parsed or not. + */ + private boolean isParsed; + + /** + * Holds the Hashmap of policies parsed from the stream + */ + private final HashMap policies = new HashMap(); + + /** + * Holds a reference to the input stream to read from. + */ + private final InputStream streamRef; + + /** + * Initializes the AccessPolicyResponse object + * + * @param stream + * the input stream to read error details from. + */ + public AccessPolicyResponse(final InputStream stream) { + this.streamRef = stream; + } + + /** + * Gets the HashMap of SharedAccessPolicies from the response + * + * @return the HashMap of SharedAccessPolicies from the response + * @throws XMLStreamException + * if an XMLStreamException occurs. + * @throws ParseException + * if a date is incorrectly encoded in the stream + */ + public HashMap getAccessIdentifiers() throws XMLStreamException, ParseException { + if (!this.isParsed) { + this.parseResponse(); + } + + return this.policies; + } + + /** + * Parses the response for the Shared Access Policies + * + * @throws XMLStreamException + * if an XMLStreamException occurs. + * @throws ParseException + * if a date is incorrectly encoded in the stream + */ + public void parseResponse() throws XMLStreamException, ParseException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT + && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { + this.readPolicies(xmlr); + } else if (eventType == XMLStreamConstants.END_ELEMENT + && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { + break; + } + } else if (eventType == XMLStreamConstants.END_DOCUMENT) { + break; + } + } + + this.isParsed = true; + } + + /** + * Reads all the policies from the XMLStreamReader + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if an XMLStreamException occurs. + * @throws ParseException + * if a date is incorrectly encoded in the stream + */ + private void readPolicies(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { + int eventType = xmlr.getEventType(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT + && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { + this.readSignedIdentifier(xmlr); + } else if (eventType == XMLStreamConstants.END_ELEMENT + && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { + break; + } + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); + } + + /** + * Populates the object from the XMLStreamReader, reader must be at Start element of AccessPolicy. + * + * @param xmlr + * the XMLStreamReader object + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + */ + private SharedAccessPolicy readPolicyFromXML(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { + int eventType = xmlr.getEventType(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.ACCESS_POLICY); + final SharedAccessPolicy retPolicy = new SharedAccessPolicy(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.PERMISSION)) { + retPolicy.setPermissions(SharedAccessPolicy.permissionsFromString(Utility + .readElementFromXMLReader(xmlr, BlobConstants.PERMISSION))); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.START)) { + final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START); + retPolicy.setSharedAccessStartTime(Utility.parseISO8061LongDateFromString(tempString)); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.EXPIRY)) { + final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.EXPIRY); + retPolicy.setSharedAccessExpiryTime(Utility.parseISO8061LongDateFromString(tempString)); + } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { + break; + } + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.ACCESS_POLICY); + return retPolicy; + } + + /** + * Reads a policy identifier / Shared Access Policy pair from the stream + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if an XMLStreamException occurs. + * @throws ParseException + * if a date is incorrectly encoded in the stream + */ + private void readSignedIdentifier(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIER_ELEMENT); + + String id = null; + SharedAccessPolicy policy = null; + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ID)) { + id = Utility.readElementFromXMLReader(xmlr, Constants.ID); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { + policy = this.readPolicyFromXML(xmlr); + } else if (eventType == XMLStreamConstants.END_ELEMENT + && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { + this.policies.put(id, policy); + break; + } + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIER_ELEMENT); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java new file mode 100644 index 0000000000000..ae4f4fa2415d5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java @@ -0,0 +1,56 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.URI; +import java.util.HashMap; + +/** + * RESERVED FOR INTERNAL USE. Represents a blob's attributes. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobAttributes { + + /** + * Holds the metadata for the blob. + */ + private HashMap metadata; + + /** + * Holds the properties of the blob. + */ + private BlobProperties properties; + + /** + * Holds the snapshot ID + */ + public String snapshotID; + + /** + * Holds the URI of the blob, Setting this is RESERVED for internal use. + */ + protected URI uri; + + /** + * Initializes a new instance of the BlobAttributes class + */ + public BlobAttributes(final BlobType type) { + this.setMetadata(new HashMap()); + this.setProperties(new BlobProperties(type)); + } + + public HashMap getMetadata() { + return this.metadata; + } + + public BlobProperties getProperties() { + return this.properties; + } + + protected void setMetadata(final HashMap metadata) { + this.metadata = metadata; + } + + protected void setProperties(final BlobProperties properties) { + this.properties = properties; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java new file mode 100644 index 0000000000000..81329e0725e36 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java @@ -0,0 +1,343 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Holds the Constants used for the Queue Service. + */ +final class BlobConstants { + /** + * Defines constants for use with query strings. + */ + public static class QueryConstants { + /** + * The query component for the SAS signature. + */ + public static final String SIGNATURE = "sig"; + + /** + * The query component for the signed SAS expiry time. + */ + public static final String SIGNED_EXPIRY = "se"; + + /** + * The query component for the signed SAS identifier. + */ + public static final String SIGNED_IDENTIFIER = "si"; + + /** + * The query component for the signed SAS permissions. + */ + public static final String SIGNED_PERMISSIONS = "sp"; + + /** + * The query component for the signed SAS resource. + */ + public static final String SIGNED_RESOURCE = "sr"; + + /** + * The query component for the signed SAS start time. + */ + public static final String SIGNED_START = "st"; + + /** + * The query component for the signed SAS version. + */ + public static final String SIGNED_VERSION = "sv"; + + /** + * The query component for snapshot time. + */ + public static final String SNAPSHOT = "snapshot"; + } + + /** + * XML element for an access policy. + */ + public static final String ACCESS_POLICY = "AccessPolicy"; + + /** + * XML element for authentication error details. + */ + public static final String AUTHENTICATION_ERROR_DETAIL = "AuthenticationErrorDetail"; + + /** + * The header that specifies blob content MD5. + */ + public static final String BLOB_CONTENT_MD5_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-content-md5"; + + /** + * XML element for a blob. + */ + public static final String BLOB_ELEMENT = "Blob"; + + /** + * XML element for blob prefixes. + */ + public static final String BLOB_PREFIX_ELEMENT = "BlobPrefix"; + + /** + * The header that specifies public access to blobs. + */ + public static final String BLOB_PUBLIC_ACCESS_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-public-access"; + + /** + * XML element for a blob type. + */ + public static final String BLOB_TYPE_ELEMENT = "BlobType"; + /** + * The header for the blob type. + */ + public static final String BLOB_TYPE_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-type"; + + /** + * XML element for blobs. + */ + public static final String BLOBS_ELEMENT = "Blobs"; + + /** + * Specifies the block blob type. + */ + public static final String BLOCK_BLOB = "BlockBlob"; + + /** + * Constant signaling a block blob. + */ + public static final String BLOCK_BLOB_VALUE = "BlockBlob"; + + /** + * XML element for blocks. + */ + public static final String BLOCK_ELEMENT = "Block"; + + /** + * XML element for a block list. + */ + public static final String BLOCK_LIST_ELEMENT = "BlockList"; + + /** + * XML element for committed blocks. + */ + public static final String COMMITTED_BLOCKS_ELEMENT = "CommittedBlocks"; + + /** + * XML element for committed blocks. + */ + public static final String COMMITTED_ELEMENT = "Committed"; + + /** + * XML element for a container. + */ + public static final String CONTAINER_ELEMENT = "Container"; + + /** + * XML element for containers. + */ + public static final String CONTAINERS_ELEMENT = "Containers"; + + /** + * The header that specifies blob content encoding. + */ + public static final String CONTENT_ENCODING_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-encoding"; + + /** + * The header that specifies blob content language. + */ + public static final String CONTENT_LANGUAGE_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-language"; + + /** + * The header that specifies blob content length. + */ + public static final String CONTENT_LENGTH_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-length"; + + /** + * The header that specifies blob content type. + */ + public static final String CONTENT_TYPE_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-content-type"; + + /** + * The number of default concurrent requests for parallel operation. + */ + public static final int DEFAULT_CONCURRENT_REQUEST_COUNT = 1; + + /** + * The default delimiter used to create a virtual directory structure of blobs. + */ + public static final String DEFAULT_DELIMITER = "/"; + + /** + * The default write pages size, in bytes, used by blob stream for page blobs. + */ + public static final int DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES = + 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + + /** + * The default minimum read size, in bytes, for streams. + */ + public static final int DEFAULT_MINIMUM_READ_SIZE_IN_BYTES = + 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + + /** + * The default maximum size, in bytes, of a blob before it must be separated into blocks. + */ + public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = + 32 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + + /** + * The default write block size, in bytes, used by blob streams. + */ + public static final int DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES = + 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + + /** + * XML element for the end time of an access policy. + */ + public static final String EXPIRY = "Expiry"; + + /** + * Specifies snapshots are to be included. + */ + public static final String INCLUDE_SNAPSHOTS_VALUE = "include"; + + /** + * XML element for the latest. + */ + public static final String LATEST_ELEMENT = "Latest"; + + /** + * Maximum number of shared access policy identifiers supported by server. + */ + public static final int MAX_SHARED_ACCESS_POLICY_IDENTIFIERS = 5; + + /** + * The maximum size, in bytes, of a blob before it must be separated into blocks. + */ + public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = + 64 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + + /** + * Specifies the page blob type. + */ + public static final String PAGE_BLOB = "PageBlob"; + + /** + * Constant signaling a page blob. + */ + public static final String PAGE_BLOB_VALUE = "PageBlob"; + + /** + * XML element for page list elements. + */ + public static final String PAGE_LIST_ELEMENT = "PageList"; + + /** + * XML element for a page range. + */ + public static final String PAGE_RANGE_ELEMENT = "PageRange"; + + /** + * The size of a page, in bytes, in a page blob. + */ + public static final int PAGE_SIZE = 512; + + /** + * The header that specifies page write mode. + */ + public static final String PAGE_WRITE = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "page-write"; + + /** + * XML element for the permission of an access policy. + */ + public static final String PERMISSION = "Permission"; + + /** + * XML element for properties. + */ + public static final String PROPERTIES = "Properties"; + + /** + * The header for specifying the sequence number. + */ + public static final String SEQUENCE_NUMBER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-sequence-number"; + + /** + * XML element for a signed identifier. + */ + public static final String SIGNED_IDENTIFIER_ELEMENT = "SignedIdentifier"; + + /** + * XML element for signed identifiers. + */ + public static final String SIGNED_IDENTIFIERS_ELEMENT = "SignedIdentifiers"; + + /** + * The header for the blob content length. + */ + public static final String SIZE = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-length"; + + /** + * XML element for the block length. + */ + public static final String SIZE_ELEMENT = "Size"; + + /** + * The Snapshot value. + */ + public static final String SNAPSHOT = "snapshot"; + + /** + * XML element for a snapshot. + */ + public static final String SNAPSHOT_ELEMENT = "Snapshot"; + + /** + * The header for snapshots. + */ + public static final String SNAPSHOT_HEADER = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "snapshot"; + + /** + * Specifies only snapshots are to be included. + */ + public static final String SNAPSHOTS_ONLY_VALUE = "only"; + + /** + * XML element for the start time of an access policy. + */ + public static final String START = "Start"; + + /** + * XML element for page range start elements. + */ + public static final String START_ELEMENT = "Start"; + + /** + * XML element for uncommitted blocks. + */ + public static final String UNCOMMITTED_BLOCKS_ELEMENT = "UncommittedBlocks"; + + /** + * XML element for uncommitted blocks. + */ + public static final String UNCOMMITTED_ELEMENT = "Uncommitted"; + + /** + * Private Default Ctor + */ + private BlobConstants() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java new file mode 100644 index 0000000000000..138a83e81d988 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java @@ -0,0 +1,71 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.URI; +import java.util.HashMap; + +/** + * RESERVED FOR INTERNAL USE. Represents a container's attributes, including its properties and metadata. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobContainerAttributes { + /** + * Holds the Container Metadata + */ + private HashMap metadata; + + /** + * Holds the Container Properties + */ + private BlobContainerProperties properties; + + /** + * Holds the Name of the Container + */ + private String name; + + /** + * Holds the URI of the container + */ + private URI uri; + + /** + * Initializes a new instance of the BlobContainerAttributes class + */ + public BlobContainerAttributes() { + this.setMetadata(new HashMap()); + this.setProperties(new BlobContainerProperties()); + } + + public HashMap getMetadata() { + return this.metadata; + } + + public String getName() { + return this.name; + } + + public BlobContainerProperties getProperties() { + return this.properties; + } + + public URI getUri() { + return this.uri; + } + + public void setMetadata(final HashMap metadata) { + this.metadata = metadata; + } + + public void setName(final String name) { + this.name = name; + } + + public void setProperties(final BlobContainerProperties properties) { + this.properties = properties; + } + + public void setUri(final URI uri) { + this.uri = uri; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java new file mode 100644 index 0000000000000..d067cfdc5e332 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java @@ -0,0 +1,87 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.HashMap; + +/** + * Represents the permissions for a container. + *

+ * The container's permissions encompass two types of access settings for the container: + *

    + *
  • The container's public access setting, represented by the {@link #publicAccess} property. The public access + * setting indicates whether the container and its blobs can be read via an anonymous request.
  • + *
  • The container's access policies, represented by the {@link #getSharedAccessPolicies} method. This setting + * references a collection of shared access policies for the container. A shared access policy may be used to control + * the start time, expiry time, and permissions for one or more shared access signatures. A shared access signature + * provides delegated access to the container's resources.
  • + *
+ * For more information on managing container permissions, see Managing Access to Containers and Blobs. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobContainerPermissions { + + /** + * Represents the public access setting for the container. + *

+ * The public access setting indicates whether the container and its blobs can be read via an anonymous request. + *

+ * The {@link BlobContainerPublicAccessType} enumeration provides three levels of anonymous read access: + *

    + *
  • {@link BlobContainerPublicAccessType#OFF}, which prevents anonymous access.
  • + *
  • {@link BlobContainerPublicAccessType#BLOB}, which permits anonymous read access to blob resources, but not to + * container metadata or to the list of blobs in the container.
  • + *
  • {@link BlobContainerPublicAccessType#CONTAINER}, which permits anonymous read access to blob resources, + * container metadata, and the list of blobs in the container.
  • + *
+ * For more information on managing anonymous access to Blob service resources, see Setting Access Control for Containers. + */ + private BlobContainerPublicAccessType publicAccess; + + /** + * Gets the set of shared access policies for the container. + */ + private HashMap sharedAccessPolicies; + + /** + * Creates an instance of the BlobContainerPermissions class. + */ + public BlobContainerPermissions() { + this.setPublicAccess(BlobContainerPublicAccessType.OFF); + this.sharedAccessPolicies = new HashMap(); + } + + /** + * @return the publicAccess + */ + public BlobContainerPublicAccessType getPublicAccess() { + return this.publicAccess; + } + + /** + * Returns the set of shared access policies for the container. + * + * @return A HashMap object of {@link SharedAccessPolicy} objects that represent the set of shared + * access policies for the container. + */ + public HashMap getSharedAccessPolicies() { + return this.sharedAccessPolicies; + } + + /** + * @param publicAccess + * the publicAccess to set + */ + public void setPublicAccess(final BlobContainerPublicAccessType publicAccess) { + this.publicAccess = publicAccess; + } + + /** + * @param sharedAccessPolicies + * the sharedAccessPolicies to set + */ + public void setSharedAccessPolicies(final HashMap sharedAccessPolicies) { + this.sharedAccessPolicies = sharedAccessPolicies; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java new file mode 100644 index 0000000000000..b7f66f6e4d4f0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java @@ -0,0 +1,59 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; + +/** + * Represents the system properties for a container. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobContainerProperties { + + /** + * Represents the ETag value for the container. + *

+ * The ETag value is a unique identifier that is updated when a write operation is performed against the container. + * It may be used to perform operations conditionally, providing concurrency control and improved efficiency. + *

+ * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return + * an {@link AccessCondition} object that may be specified on the request. + */ + private String etag; + + /** + * Represents the container's last-modified time. + */ + private Date lastModified; + + /** + * @return the etag + */ + public String getEtag() { + return this.etag; + } + + /** + * @return the lastModified + */ + public Date getLastModified() { + return this.lastModified; + } + + /** + * @param etag + * the etag to set + */ + public void setEtag(final String etag) { + this.etag = etag; + } + + /** + * @param lastModified + * the lastModified to set + */ + public void setLastModified(final Date lastModified) { + this.lastModified = lastModified; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java new file mode 100644 index 0000000000000..4b521d246def0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java @@ -0,0 +1,26 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Specifies the level of public access that is allowed on the container. + * + * Copyright (c)2011 Microsoft. All rights reserved. + * + */ +public enum BlobContainerPublicAccessType { + /** + * Specifies blob-level public access. Clients can read the content and metadata of blobs within this container, but + * cannot read container metadata or list the blobs within the container. + */ + BLOB, + + /** + * Specifies container-level public access. Clients can read blob content and metadata and container metadata, and + * can list the blobs within the container. + **/ + CONTAINER, + + /** + * Specifies no public access. Only the account owner can access resources in this container. + */ + OFF +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java new file mode 100644 index 0000000000000..2f0f7fb68dfe4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java @@ -0,0 +1,557 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.LeaseStatus; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.DeserializationHelper; + +/** + * RESERVED FOR INTERNAL USE. Class to provide object deserialization for blobs and containers. + */ +final class BlobDeserializationHelper { + /** + * Reserved for internal use. Populates the blob from an XMLStreamReader, reader must be at Start element of Blob + * + * @param xmlr + * the XMLStreamReader to read from + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + protected static CloudBlob readBlob( + final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_ELEMENT); + + String blobName = Constants.EMPTY_STRING; + + String snapshotID = null; + String urlString = null; + HashMap metadata = null; + BlobProperties properties = null; + + int eventType = xmlr.getEventType(); + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(Constants.URL_ELEMENT)) { + urlString = Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT); + } else if (name.equals(BlobConstants.SNAPSHOT_ELEMENT)) { + snapshotID = Utility.readElementFromXMLReader(xmlr, BlobConstants.SNAPSHOT_ELEMENT); + } else if (name.equals(Constants.NAME_ELEMENT)) { + blobName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); + } else if (name.equals(BlobConstants.PROPERTIES)) { + properties = BlobDeserializationHelper.readBlobProperties(xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); + } else if (name.equals(Constants.METADATA_ELEMENT)) { + metadata = DeserializationHelper.parseMetadateFromXML(xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.BLOB_ELEMENT)) { + break; + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOB_ELEMENT); + + // Assemble and return + if (properties != null) { + CloudBlob retBlob = null; + final int blobNameSectionIndex = urlString.lastIndexOf("/".concat(blobName)); + final URI baseUri = new URI(urlString.substring(0, blobNameSectionIndex + 1)); + String query = null; + if (blobNameSectionIndex + 1 + blobName.length() < urlString.length()) { + // Snapshot blob URI + // example:http://.blob.core.windows.net//?snapshot=2009-12-03T15%3a26%3a19.4466877Z + query = urlString.substring(blobNameSectionIndex + blobName.length() + 1); + } + + final URI blobURI = + new URI(baseUri.getScheme(), baseUri.getAuthority(), baseUri.getRawPath().concat(blobName), query, + null); + + if (properties.getBlobType() == BlobType.BLOCK_BLOB) { + retBlob = new CloudBlockBlob(blobURI, serviceClient, container); + } else if (properties.getBlobType() == BlobType.PAGE_BLOB) { + retBlob = new CloudPageBlob(blobURI, serviceClient, container); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + retBlob.uri = blobURI; + retBlob.snapshotID = snapshotID; + retBlob.properties = properties; + retBlob.metadata = metadata; + return retBlob; + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } + + /** + * Reads BlobItems from the XMLStreamReader, reader must be at Start element of BlobsElement + * + * @param xmlr + * the XMLStreamReader to read from + * @param searchMode + * the block search mode + * @return BlockEntry from the stream. + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + public static ArrayList readBlobBlocks(final XMLStreamReader xmlr, final BlockSearchMode searchMode) + throws XMLStreamException, StorageException { + int eventType = xmlr.getEventType(); + final ArrayList retBlocks = new ArrayList(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOCK_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext() && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { + String blockName = null; + long blockSize = -1; + + // Read a block + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(Constants.NAME_ELEMENT)) { + blockName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); + } else if (name.equals(BlobConstants.SIZE_ELEMENT)) { + final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.SIZE_ELEMENT); + blockSize = Long.parseLong(sizeString); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT) { + final BlockEntry newBlock = new BlockEntry(blockName, searchMode); + newBlock.setSize(blockSize); + retBlocks.add(newBlock); + break; + } + } + + eventType = xmlr.next(); + } + + return retBlocks; + } + + /** + * Populates the object from the XMLStreamReader + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + */ + protected static BlobContainerAttributes readBlobContainerAttributes(final XMLStreamReader xmlr) + throws XMLStreamException, ParseException, URISyntaxException { + int eventType = xmlr.getEventType(); + + final BlobContainerAttributes attributes = new BlobContainerAttributes(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(BlobConstants.PROPERTIES)) { + attributes.setProperties(BlobDeserializationHelper.readBlobContainerProperties(xmlr)); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); + } else if (name.equals(Constants.URL_ELEMENT)) { + attributes.setUri(new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT))); + } else if (name.equals(Constants.NAME_ELEMENT)) { + attributes.setName(Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT)); + } else if (name.equals(Constants.METADATA_ELEMENT)) { + // parse metadata + attributes.setMetadata(DeserializationHelper.parseMetadateFromXML(xmlr)); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.CONTAINER_ELEMENT)) { + break; + } + } + + return attributes; + } + + /** + * Populates the object from the XMLStreamReader, reader must be at Start element of Properties + * + * @param xmlr + * the XMLStreamReader object + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + */ + protected static BlobContainerProperties readBlobContainerProperties(final XMLStreamReader xmlr) + throws XMLStreamException, ParseException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PROPERTIES); + int eventType = xmlr.getEventType(); + final BlobContainerProperties properties = new BlobContainerProperties(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { + properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility + .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); + } else if (name.equals(Constants.ETAG_ELEMENT)) { + properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); + } + } else { + // expect end of properties + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); + break; + } + } + + return properties; + } + + /** + * Reads BlobItems from the XMLStreamReader, reader must be at Start element of BlobsElement + * + * @param xmlr + * the XMLStreamReader to read from + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @param container + * the container associated with the objects. + * @return the BlobItems from the stream + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + public static ArrayList readBlobItems( + final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + int eventType = xmlr.getEventType(); + final ArrayList retBlobs = new ArrayList(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(BlobConstants.BLOB_ELEMENT)) { + retBlobs.add(BlobDeserializationHelper.readBlob(xmlr, serviceClient, container)); + } else if (name.equals(BlobConstants.BLOB_PREFIX_ELEMENT)) { + retBlobs.add(BlobDeserializationHelper.readDirectory(xmlr, serviceClient, container)); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else { + break; + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); + return retBlobs; + } + + /** + * Populates the object from the XMLStreamReader, reader must be at Start element of Properties + * + * @param xmlr + * the XMLStreamReader object + * @return the BlobProperties that was read. + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + * @throws StorageException + */ + protected static BlobProperties readBlobProperties(final XMLStreamReader xmlr) + throws XMLStreamException, ParseException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PROPERTIES); + int eventType = xmlr.getEventType(); + final BlobProperties properties = new BlobProperties(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { + properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility + .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); + } else if (name.equals(Constants.ETAG_ELEMENT)) { + properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); + } else if (name.equals(Constants.HeaderConstants.CONTENT_LENGTH)) { + final String tempString = + Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_LENGTH); + properties.setLength(Long.parseLong(tempString)); + } else if (name.equals(Constants.HeaderConstants.CONTENT_TYPE)) { + properties.setContentType(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CONTENT_TYPE)); + } else if (name.equals(Constants.HeaderConstants.CONTENT_ENCODING)) { + properties.setContentEncoding(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CONTENT_ENCODING)); + } else if (name.equals(Constants.HeaderConstants.CONTENT_LANGUAGE)) { + properties.setContentLanguage(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CONTENT_LANGUAGE)); + } else if (name.equals(Constants.HeaderConstants.CONTENT_MD5)) { + properties.setContentMD5(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CONTENT_MD5)); + } else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { + properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CACHE_CONTROL)); + } else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { + properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CACHE_CONTROL)); + } else if (name.equals(BlobConstants.SEQUENCE_NUMBER)) { + // TODO what do we do with this? + Utility.readElementFromXMLReader(xmlr, BlobConstants.SEQUENCE_NUMBER); + } else if (name.equals(BlobConstants.BLOB_TYPE_ELEMENT)) { + final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.BLOB_TYPE_ELEMENT); + if (tempString.equals(BlobConstants.BLOCK_BLOB_VALUE)) { + properties.setBlobType(BlobType.BLOCK_BLOB); + } else if (tempString.equals(BlobConstants.PAGE_BLOB_VALUE)) { + properties.setBlobType(BlobType.PAGE_BLOB); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else if (name.equals(Constants.LEASE_STATUS_ELEMENT)) { + final String tempString = Utility.readElementFromXMLReader(xmlr, Constants.LEASE_STATUS_ELEMENT); + if (tempString.equals(Constants.LOCKED_VALUE.toLowerCase())) { + properties.setLeaseStatus(LeaseStatus.LOCKED); + } else if (tempString.equals(Constants.UNLOCKED_VALUE.toLowerCase())) { + properties.setLeaseStatus(LeaseStatus.UNLOCKED); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } + } else if (eventType == XMLStreamConstants.END_ELEMENT) { + // expect end of properties + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); + break; + } + } + + return properties; + } + + /** + * Populates the container from an XMLStreamReader + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + protected static CloudBlobContainer readContainer(final XMLStreamReader xmlr, final CloudBlobClient serviceClient) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.CONTAINER_ELEMENT); + + final BlobContainerAttributes attributes = BlobDeserializationHelper.readBlobContainerAttributes(xmlr); + + final CloudBlobContainer retContainer = new CloudBlobContainer(attributes.getUri(), serviceClient); + retContainer.setMetadata(attributes.getMetadata()); + retContainer.setName(attributes.getName()); + retContainer.setProperties(attributes.getProperties()); + retContainer.setUri(attributes.getUri()); + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINER_ELEMENT); + return retContainer; + } + + /** + * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of + * ContainersElement + * + * @param xmlr + * the XMLStreamReader object + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @return an ArrayList of CloudBlobContainer from the stream. + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + * @throws URISyntaxException + * @throws StorageException + */ + public static ArrayList readContainers( + final XMLStreamReader xmlr, final CloudBlobClient serviceClient) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); + + final ArrayList containers = new ArrayList(); + + eventType = xmlr.next(); + while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() + && BlobConstants.CONTAINER_ELEMENT.equals(xmlr.getName().toString())) { + containers.add(BlobDeserializationHelper.readContainer(xmlr, serviceClient)); + eventType = xmlr.next(); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); + return containers; + } + + /** + * Populates the CloudBlobDirectory from an XMLStreamReader, reader must be at Start element of BlobPrefix + * + * @param xmlr + * the XMLStreamReader to read from + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @param container + * the container associated with the objects. + * @return a CloudBlobDirectory parsed from the stream. + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + protected static CloudBlobDirectory readDirectory( + final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_PREFIX_ELEMENT); + + // Move to Name element + xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.NAME_ELEMENT); + + final String prefixName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); + + // Move from End name element to end prefix element + xmlr.next(); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOB_PREFIX_ELEMENT); + + return container.getDirectoryReference(prefixName); + } + + /** + * Reads PageRanges from the XMLStreamReader, reader must be at Start element of PageRangeElement + * + * @param xmlr + * the XMLStreamReader to read from + * @return the PageRange from the stream. + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + public static ArrayList readPageRanges(final XMLStreamReader xmlr) + throws XMLStreamException, StorageException { + int eventType = xmlr.getEventType(); + final ArrayList retRanges = new ArrayList(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PAGE_RANGE_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext() && BlobConstants.PAGE_RANGE_ELEMENT.equals(xmlr.getName().toString())) { + long startOffset = -1; + long endOffset = -1; + + // Read a Page Range + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(BlobConstants.START_ELEMENT)) { + final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START_ELEMENT); + startOffset = Long.parseLong(sizeString); + } else if (name.equals(Constants.END_ELEMENT)) { + final String sizeString = Utility.readElementFromXMLReader(xmlr, Constants.END_ELEMENT); + endOffset = Long.parseLong(sizeString); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT) { + if (startOffset == -1 || endOffset == -1) { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + final PageRange pageRef = new PageRange(startOffset, endOffset); + retRanges.add(pageRef); + break; + } + } + + eventType = xmlr.next(); + } + + return retRanges; + } + + /** + * Private Default Ctor + */ + private BlobDeserializationHelper() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java new file mode 100644 index 0000000000000..fe35950b96612 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -0,0 +1,627 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCode; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Provides an input stream to read a given blob resource. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobInputStream extends InputStream { + /** + * Holds the reference to the blob this stream is associated with. + */ + private final CloudBlob parentBlobRef; + + /** + * Holds the reference to the MD5 digest for the blob. + */ + private MessageDigest md5Digest; + + /** + * A flag to determine if the stream is faulted, if so the lasterror will be thrown on next operation. + */ + private volatile boolean streamFaulted; + + /** + * Holds the last exception this stream encountered. + */ + private IOException lastError; + + /** + * Holds the OperationContext for the current stream. + */ + private final OperationContext opContext; + + /** + * Holds the options for the current stream + */ + private final BlobRequestOptions options; + + /** + * Holds the stream length. + */ + private long streamLength = -1; + + /** + * Holds the stream read size for both block and page blobs. + */ + private final int readSize; + + /** + * A flag indicating if the Blob MD5 should be validated. + */ + private boolean validateBlobMd5; + + /** + * Holds the reference to the current buffered data. + */ + private ByteArrayInputStream currentBuffer; + + /** + * Holds an absolute byte position for the mark feature. + */ + private long markedPosition; + + /** + * Holds the mark delta for which the mark position is expired. + */ + private int markExpiry; + + /** + * Holds the List of PageRanges when reading a page blob and using the sparse page blob feature. + */ + private ArrayList pageBlobRanges; + + /** + * Holds an index to the current page range. + */ + private int currentPageRangeIndex; + + /** + * Holds an absolute byte position of the current read position. + */ + private long currentAbsoluteReadPosition; + + /** + * Holds the absolute byte position of the start of the current buffer. + */ + private long bufferStartOffset; + + /** + * Holds the length of the current buffer in bytes. + */ + private int bufferSize; + + /** + * Holds the {@link AccessCondition} object that represents the access conditions for the blob. + */ + private AccessCondition accessCondition = null; + + /** + * Initializes a new instance of the BlobInputStream class. + * + * @param parentBlob + * the blob that this stream is associated with. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition accessCondition, + final BlobRequestOptions options, final OperationContext opContext) throws StorageException { + this.parentBlobRef = parentBlob; + this.parentBlobRef.assertCorrectBlobType(); + this.options = new BlobRequestOptions(options); + this.opContext = opContext; + this.streamFaulted = false; + this.currentAbsoluteReadPosition = 0; + this.readSize = parentBlob.blobServiceClient.getStreamMinimumReadSizeInBytes(); + + if (options.getUseTransactionalContentMD5() && this.readSize > 4 * Constants.MB) { + throw new IllegalArgumentException( + "Cannot specify x-ms-range-get-content-md5 header on ranges larger than 4 MB"); + } + + parentBlob.downloadAttributes(accessCondition, this.options, this.opContext); + + final HttpURLConnection attributesRequest = this.opContext.getCurrentRequestObject(); + + final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + + // Will validate it if it was returned + this.validateBlobMd5 = + !options.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(retrievedContentMD5Value); + + // Validates the first option, and sets future requests to use if match + // request option. + + // If there is an existing conditional validate it, as we intend to + // replace if for future requests. + String previousLeaseId = null; + if (accessCondition != null) { + previousLeaseId = accessCondition.getLeaseID(); + + if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef + .getProperties().getLastModified())) { + throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), + "The conditionals specified for this operation did not match server.", + HttpURLConnection.HTTP_PRECON_FAILED, null, null); + } + } + + this.accessCondition = AccessCondition.generateIfMatchCondition(this.parentBlobRef.getProperties().getEtag()); + this.accessCondition.setLeaseID(previousLeaseId); + + this.streamLength = parentBlob.getProperties().getLength(); + + if (this.validateBlobMd5) { + try { + this.md5Digest = MessageDigest.getInstance("MD5"); + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + if (this.parentBlobRef.getProperties().getBlobType() == BlobType.PAGE_BLOB + && this.options.getUseSparsePageBlob()) { + this.pageBlobRanges = + ((CloudPageBlob) parentBlob).downloadPageRanges(this.accessCondition, options, opContext); + } else if (this.parentBlobRef.getProperties().getBlobType() == BlobType.BLOCK_BLOB) { + if (this.options.getUseSparsePageBlob()) { + throw new IllegalArgumentException( + "The UseSparsePageBlob option is not applicable of Block Blob streams."); + } + } + this.reposition(0); + } + + /** + * Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without + * blocking by the next invocation of a method for this input stream. The next invocation might be the same thread + * or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. + * + * @throws IOException + * - if an I/O error occurs. + * @return an estimate of the number of bytes that can be read (or skipped over) from this input stream without + * blocking or 0 when it reaches the end of the input stream. + */ + @Override + public synchronized int available() throws IOException { + return this.bufferSize - (int) (this.currentAbsoluteReadPosition - this.bufferStartOffset); + } + + /** + * Helper function to check if the stream is faulted, if it is it surfaces the exception. + * + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + private synchronized void checkStreamState() throws IOException { + if (this.streamFaulted) { + throw this.lastError; + } + } + + /** + * Closes this input stream and releases any system resources associated with the stream. + * + * @throws IOException + * - if an I/O error occurs. + */ + @Override + public synchronized void close() throws IOException { + this.currentBuffer = null; + this.streamFaulted = true; + this.lastError = new IOException("Stream is closed"); + } + + /** + * Dispatches a read operation of N bytes. When using sparspe page blobs the page ranges are evaluated and zero + * bytes may be generated on the client side for some ranges that do not exist. + * + * @param readLength + * the number of bytes to read. + * @throws IOException + * if an I/O error occurs. + */ + @DoesServiceRequest + private synchronized void dispatchRead(final int readLength) throws IOException { + try { + final byte[] byteBuffer = new byte[readLength]; + if (this.options.getUseSparsePageBlob()) { + long resolvedReadStart = this.currentAbsoluteReadPosition; + long resolvedReadEnd = this.currentAbsoluteReadPosition + readLength; + + PageRange startRange = this.getCurrentRange(); + if (startRange != null) { + resolvedReadStart = startRange.getStartOffset(); + resolvedReadEnd = startRange.getEndOffset() + 1; + + // seek start range + while (this.currentAbsoluteReadPosition > startRange.getEndOffset()) { + this.currentPageRangeIndex++; + startRange = this.getCurrentRange(); + + if (startRange != null) { + resolvedReadStart = startRange.getStartOffset(); + resolvedReadEnd = startRange.getEndOffset() + 1; + } else { + break; + } + } + } + + if (startRange != null) { + // seek end range + int endDex = this.currentPageRangeIndex + 1; + PageRange endRange = endDex < this.pageBlobRanges.size() ? this.pageBlobRanges.get(endDex) : null; + + while (endDex < this.pageBlobRanges.size() - 1 + && this.currentAbsoluteReadPosition + readLength >= endRange.getEndOffset()) { + endDex++; + endRange = this.pageBlobRanges.get(endDex); + resolvedReadEnd = endRange.getEndOffset() + 1; + } + + resolvedReadEnd = Math.min(resolvedReadEnd, this.currentAbsoluteReadPosition + readLength); + + final int bufferOffset = (int) (resolvedReadStart - this.currentAbsoluteReadPosition); + final int opReadLength = + (int) Math.min(readLength - bufferOffset, resolvedReadEnd - resolvedReadStart); + + // Do read + if (opReadLength > 0) { + this.parentBlobRef.downloadRangeInternal(resolvedReadStart, + opReadLength, + byteBuffer, + bufferOffset, + this.accessCondition, + this.options, + this.opContext); + } + } + + // ELSE=> no op, buffer already contains zeros. + + } else { + // Non sparse read, do entire read length + this.parentBlobRef.downloadRangeInternal(this.currentAbsoluteReadPosition, + readLength, + byteBuffer, + 0, + this.accessCondition, + this.options, + this.opContext); + } + + this.currentBuffer = new ByteArrayInputStream(byteBuffer); + this.bufferSize = readLength; + this.bufferStartOffset = this.currentAbsoluteReadPosition; + } catch (final StorageException e) { + this.streamFaulted = true; + this.lastError = Utility.initIOException(e); + throw this.lastError; + } + } + + /** + * A helper method to get the current Page Range based on the current page range index. + * + * @return the current Page Range based on the current page range index. + */ + private PageRange getCurrentRange() { + if (this.currentPageRangeIndex >= this.pageBlobRanges.size()) { + return null; + } + return this.pageBlobRanges.get(this.currentPageRangeIndex); + } + + /** + * Gets a value indicating if MD5 should be validated. + * + * @return a value indicating if MD5 should be validated. + */ + protected synchronized boolean getValidateBlobMd5() { + return this.validateBlobMd5; + } + + /** + * Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at + * the last marked position so that subsequent reads re-read the same bytes. + * + * @param readlimit + * - the maximum limit of bytes that can be read before the mark position becomes invalid. + */ + @Override + public synchronized void mark(final int readlimit) { + this.markedPosition = this.currentAbsoluteReadPosition; + this.markExpiry = readlimit; + } + + /** + * Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an + * invariant property of a particular input stream instance. The markSupported method of InputStream returns false. + * + * @return True if this stream instance supports the mark and reset methods; False + * otherwise. + */ + @Override + public boolean markSupported() { + return true; + } + + /** + * Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If + * no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks + * until input data is available, the end of the stream is detected, or an exception is thrown. + * + * @return the next byte of data, or -1 if the end of the stream is reached. + * @throws IOException + * - if an I/O error occurs. + */ + @Override + @DoesServiceRequest + public int read() throws IOException { + final byte[] tBuff = new byte[1]; + this.read(tBuff, 0, 1); + return tBuff[0]; + } + + /** + * Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes + * actually read is returned as an integer. This method blocks until input data is available, end of file is + * detected, or an exception is thrown. If the length of b is zero, then no bytes are read and 0 is returned; + * otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the + * end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b. + * + * The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, + * at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in + * elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected. + * + * The read(b) method for class InputStream has the same effect as: + * + * read(b, 0, b.length) + * + * @param b + * - the buffer into which the data is read. + * @return the total number of bytes read into the buffer, or -1 is there is no more data because the end of the + * stream has been reached. + * + * @throws IOException + * - If the first byte cannot be read for any reason other than the end of the file, if the input stream + * has been closed, or if some other I/O error occurs. + * @throws NullPointerException + * - if b is null. + */ + @Override + @DoesServiceRequest + public int read(final byte[] b) throws IOException { + return this.read(b, 0, b.length); + } + + /** + * Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as + * len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer. This + * method blocks until input data is available, end of file is detected, or an exception is thrown. + * + * If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one + * byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least + * one byte is read and stored into b. + * + * The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes + * read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in + * elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected. + * + * In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected. + * + * The read(b, off, len) method for class InputStream simply calls the method read() repeatedly. If the first such + * call results in an IOException, that exception is returned from the call to the read(b, off, len) method. If any + * subsequent call to read() results in a IOException, the exception is caught and treated as if it were end of + * file; the bytes read up to that point are stored into b and the number of bytes read before the exception + * occurred is returned. The default implementation of this method blocks until the requested amount of input data + * len has been read, end of file is detected, or an exception is thrown. Subclasses are encouraged to provide a + * more efficient implementation of this method. + * + * @param b + * the buffer into which the data is read. + * @param off + * the start offset in array b at which the data is written. + * @param len + * the maximum number of bytes to read. + * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the + * stream has been reached. + * @throws IOException + * If the first byte cannot be read for any reason other than end of file, or if the input stream has + * been closed, or if some other I/O error occurs. + * @throws NullPointerException + * If b is null. + * @throws IndexOutOfBoundsException + * If off is negative, len is negative, or len is greater than b.length - off + */ + @Override + @DoesServiceRequest + public int read(final byte[] b, final int off, final int len) throws IOException { + if (off < 0 || len < 0 || len > b.length - off) { + throw new IndexOutOfBoundsException(); + } + + return this.readInternal(b, off, len); + } + + /** + * Performs internal read to the given byte buffer. + * + * @param b + * the buffer into which the data is read. + * @param off + * the start offset in array b at which the data is written. + * @param len + * the maximum number of bytes to read. + * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the + * stream has been reached. + * @throws IOException + * If the first byte cannot be read for any reason other than end of file, or if the input stream has + * been closed, or if some other I/O error occurs. + */ + @DoesServiceRequest + private synchronized int readInternal(final byte[] b, final int off, int len) throws IOException { + this.checkStreamState(); + + // if buffer is empty do next get operation + if ((this.currentBuffer == null || this.currentBuffer.available() == 0) + && this.currentAbsoluteReadPosition < this.streamLength) { + this.dispatchRead((int) Math.min(this.readSize, this.streamLength - this.currentAbsoluteReadPosition)); + } + + len = Math.min(len, this.readSize); + + // do read from buffer + final int numberOfBytesRead = this.currentBuffer.read(b, off, len); + + if (numberOfBytesRead > 0) { + this.currentAbsoluteReadPosition += numberOfBytesRead; + + if (this.validateBlobMd5) { + this.md5Digest.update(b, off, numberOfBytesRead); + + if (this.currentAbsoluteReadPosition == this.streamLength) { + // Reached end of stream, validate md5. + final String calculatedMd5 = Base64.encode(this.md5Digest.digest()); + if (!calculatedMd5.equals(this.parentBlobRef.getProperties().getContentMD5())) { + this.lastError = + Utility.initIOException(new StorageException( + StorageErrorCodeStrings.INVALID_MD5, + String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + this.parentBlobRef.getProperties().getContentMD5(), + calculatedMd5), Constants.HeaderConstants.HTTP_UNUSED_306, null, null)); + this.streamFaulted = true; + throw this.lastError; + } + } + } + } + + // update markers + if (this.markExpiry > 0 && this.markedPosition + this.markExpiry < this.currentAbsoluteReadPosition) { + this.markedPosition = 0; + this.markExpiry = 0; + } + + return numberOfBytesRead; + } + + /** + * Repositions the stream to the given absolute byte offset. + * + * @param absolutePosition + * the absolute byte offset to reposition to. + */ + private synchronized void reposition(final long absolutePosition) { + this.currentAbsoluteReadPosition = absolutePosition; + this.currentBuffer = new ByteArrayInputStream(new byte[0]); + } + + /** + * Repositions this stream to the position at the time the mark method was last called on this input stream. Note + * repositioning the blob read stream will disable blob MD5 checking. + * + * @throws IOException + * if this stream has not been marked or if the mark has been invalidated. + */ + @Override + public synchronized void reset() throws IOException { + if (this.markedPosition + this.markExpiry < this.currentAbsoluteReadPosition) { + throw new IOException("Mark expired!"); + } + + this.validateBlobMd5 = false; + this.md5Digest = null; + this.reposition(this.markedPosition); + } + + /** + * Sets a value indicating if MD5 should be validated. + * + * @param validateBlobMd5 + * a value indicating if MD5 should be validated. + */ + protected synchronized void setValidateBlobMd5(final boolean validateBlobMd5) { + this.validateBlobMd5 = validateBlobMd5; + } + + /** + * Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, + * end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of + * conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of + * bytes skipped is returned. If n is negative, no bytes are skipped. + * + * Note repositioning the blob read stream will disable blob MD5 checking. + * + * @param n + * the number of bytes to skip + */ + @Override + public synchronized long skip(final long n) throws IOException { + if (n == 0) { + return 0; + } + + if (n < 0 || this.currentAbsoluteReadPosition + n > this.streamLength) { + throw new IndexOutOfBoundsException(); + } + + this.validateBlobMd5 = false; + this.md5Digest = null; + this.reposition(this.currentAbsoluteReadPosition + n); + return n; + } + + /** + * Writes the entire blob contents from the Windows Azure Blob service to the given output stream. + * + * @param outStream + * the output stream to write to. + * @return the number of bytes written. + * @throws IOException + * if an I/O Error occurs + */ + @DoesServiceRequest + protected long writeTo(final OutputStream outStream) throws IOException { + final byte[] buffer = new byte[Constants.BUFFER_COPY_LENGTH]; + long total = 0; + int count = this.read(buffer); + + while (count != -1) { + outStream.write(buffer, 0, count); + total += count; + count = this.read(buffer); + } + + return total; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java new file mode 100644 index 0000000000000..c34ad91bbd43c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java @@ -0,0 +1,88 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.EnumSet; + +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; + +/** + * RESERVED FOR INTERNAL USE. Provides the listing context for blobs including the delimiter and listingdetails + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobListingContext extends ListingContext { + + /** + * Gets or sets the delimiter for a blob listing operation. The delimiter parameter enables the caller to traverse + * the blob namespace by using a user-configured delimiter. Using this parameter, it is possible to traverse a + * virtual hierarchy of blobs as though it were a file system. + */ + private String delimiter; + + /** + * Gets or sets the details for the listing operation, which indicates the types of data to include in the response. + * The include parameter specifies that the response should include one or more of the following subsets: snapshots, + * metadata, uncommitted blobs. + */ + private EnumSet listingDetails; + + /** + * Initializes a new instance of the BlobListingContext class + * + * @param prefix + * the prefix to use. + * @param maxResults + * the maximum results to download. + */ + public BlobListingContext(final String prefix, final Integer maxResults) { + super(prefix, maxResults); + } + + /** + * Initializes a new instance of the BlobListingContext class + * + * @param prefix + * the prefix to use. + * @param maxResults + * the maximum results to download. + * @param delimiter + * the delimiter to use + * @param listingDetails + * the BlobListingDetails to use. + */ + public BlobListingContext(final String prefix, final Integer maxResults, final String delimiter, + final EnumSet listingDetails) { + super(prefix, maxResults); + this.setDelimiter(delimiter); + this.setListingDetails(listingDetails); + } + + /** + * @return the delimiter + */ + protected String getDelimiter() { + return this.delimiter; + } + + /** + * @return the listingDetails + */ + protected EnumSet getListingDetails() { + return this.listingDetails; + } + + /** + * @param delimiter + * the delimiter to set + */ + protected void setDelimiter(final String delimiter) { + this.delimiter = delimiter; + } + + /** + * @param listingDetails + * the listingDetails to set + */ + protected void setListingDetails(final EnumSet listingDetails) { + this.listingDetails = listingDetails; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java new file mode 100644 index 0000000000000..dbe33cbfce54a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java @@ -0,0 +1,41 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * 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 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(final int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java new file mode 100644 index 0000000000000..33f743087a507 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -0,0 +1,614 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Random; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletionService; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorCompletionService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * The class is an append-only stream for writing into storage. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobOutputStream extends OutputStream { + /** + * Holds the random number generator used to create starting blockIDs. + */ + private static Random blockSequenceGenerator = new Random(); + + /** + * Holds the reference to the blob this stream is associated with. + */ + private final CloudBlob parentBlobRef; + + /** + * Determines if this stream is used against a page blob or block blob. + */ + private BlobType streamType = BlobType.UNSPECIFIED; + + /** + * A flag to determine if the stream is faulted, if so the lasterror will be thrown on next operation. + */ + volatile boolean streamFaulted; + + /** + * Holds the lock for synchronized access to the last error. + */ + Object lastErrorLock = new Object(); + + /** + * Holds the last exception this stream encountered. + */ + IOException lastError; + + /** + * Holds the OperationContext for the current stream. + */ + OperationContext opContext; + + /** + * Holds the options for the current stream. + */ + BlobRequestOptions options; + + /** + * Holds the reference to the MD5 digest for the blob. + */ + private MessageDigest md5Digest; + + /** + * Used for block blobs, holds the current BlockID Sequence number. + */ + private long blockIdSequenceNumber = -1; + + /** + * Used for block blobs, holds the block list. + */ + private ArrayList blockList; + + /** + * Used for page blobs, holds the currentOffset the stream is writing to. + */ + private long currentPageOffset; + + /** + * Used for page blobs, when uploading UseSparsePageBlob is true holds the buffer index of the first non zero byte. + */ + private long firstNonZeroBufferedByte = -1; + + /** + * Used for page blobs, when uploading UseSparsePageBlob is true holds the buffer index of the last non zero byte. + */ + private long lastNonZeroBufferedByte = -1; + + /** + * A private buffer to store data prior to committing to the cloud. + */ + private ByteArrayOutputStream outBuffer; + + /** + * Holds the number of currently buffered bytes. + */ + private int currentBufferedBytes; + + /** + * Holds the write threshold of number of bytes to buffer prior to dispatching a write. For block blob this is the + * block size, for page blob this is the Page commit size. + */ + private int internalWriteThreshold = -1; + + /** + * Holds the number of current outstanding requests. + */ + private volatile int outstandingRequests; + + /** + * The ExecutorService used to schedule tasks for this stream. + */ + private final ExecutorService threadExecutor; + + /** + * The CompletionService used to await task completion for this stream. + */ + private final CompletionService completionService; + + /** + * Holds the {@link AccessCondition} object that represents the access conditions for the blob. + */ + AccessCondition accessCondition = null; + + /** + * Initializes a new instance of the BlobWriteStream class. + * + * @param parentBlob + * the blob that this stream is associated with. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + protected BlobOutputStream(final CloudBlob parentBlob, final AccessCondition accessCondition, + final BlobRequestOptions options, final OperationContext opContext) throws StorageException { + this.accessCondition = accessCondition; + this.parentBlobRef = parentBlob; + this.parentBlobRef.assertCorrectBlobType(); + this.options = new BlobRequestOptions(options); + this.outBuffer = new ByteArrayOutputStream(); + this.opContext = opContext; + this.streamFaulted = false; + + if (this.options.getConcurrentRequestCount() < 1) { + throw new IllegalArgumentException("ConcurrentRequestCount"); + } + + if (this.options.getStoreBlobContentMD5()) { + try { + this.md5Digest = MessageDigest.getInstance("MD5"); + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + // V2 cachedThreadPool for perf. + this.threadExecutor = Executors.newFixedThreadPool(this.options.getConcurrentRequestCount()); + this.completionService = new ExecutorCompletionService(this.threadExecutor); + } + + /** + * Initializes a new instance of the BlobWriteStream class for a CloudBlockBlob + * + * @param parentBlob + * the blob that this stream is associated with. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + protected BlobOutputStream(final CloudBlockBlob parentBlob, final AccessCondition accessCondition, + final BlobRequestOptions options, final OperationContext opContext) throws StorageException { + this((CloudBlob) parentBlob, accessCondition, options, opContext); + this.blockIdSequenceNumber = + (long) (blockSequenceGenerator.nextInt(Integer.MAX_VALUE)) + + blockSequenceGenerator.nextInt(Integer.MAX_VALUE - 100000); + this.blockList = new ArrayList(); + + this.streamType = BlobType.BLOCK_BLOB; + this.internalWriteThreshold = this.parentBlobRef.blobServiceClient.getWriteBlockSizeInBytes(); + } + + /** + * Initializes a new instance of the BlobWriteStream class for a CloudPageBlob + * + * @param parentBlob + * the blob that this stream is associated with. + * @param length + * the length of the page blob in bytes, must be a multiple of 512. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + protected BlobOutputStream(final CloudPageBlob parentBlob, final long length, + final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) + throws StorageException { + this(parentBlob, accessCondition, options, opContext); + this.streamType = BlobType.PAGE_BLOB; + this.internalWriteThreshold = + (int) Math.min(this.parentBlobRef.blobServiceClient.getPageBlobStreamWriteSizeInBytes(), length); + + if (length % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page blob length must be multiple of 512."); + } + + if (this.options.getStoreBlobContentMD5()) { + throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); + } + + parentBlob.create(length, accessCondition, options, opContext); + } + + /** + * Helper function to check if the stream is faulted, if it is it surfaces the exception. + * + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + private void checkStreamState() throws IOException { + synchronized (this.lastErrorLock) { + if (this.streamFaulted) { + throw this.lastError; + } + } + } + + /** + * Closes this output stream and releases any system resources associated with this stream. If any data remains in + * the buffer it is committed to the service. + */ + @Override + @DoesServiceRequest + public void close() throws IOException { + this.flush(); + this.checkStreamState(); + Exception tempException = null; + + synchronized (this.lastErrorLock) { + this.streamFaulted = true; + this.lastError = new IOException("Stream is already closed."); + tempException = this.lastError; + } + + while (this.outstandingRequests > 0) { + this.waitForTaskToComplete(); + } + + this.threadExecutor.shutdown(); + synchronized (this.lastErrorLock) { + // if one of the workers threw an exception, realize it now. + if (tempException != this.lastError) { + throw this.lastError; + } + } + + try { + this.commit(); + } catch (final StorageException e) { + throw Utility.initIOException(e); + } + } + + /** + * Commits the blob, for block blob this uploads the block list. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @DoesServiceRequest + private void commit() throws StorageException, IOException { + if (this.options.getStoreBlobContentMD5()) { + this.parentBlobRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest())); + } + + if (this.streamType == BlobType.BLOCK_BLOB) { + // wait for all blocks to finish + final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; + + blobRef.commitBlockList(this.blockList, this.accessCondition, this.options, this.opContext); + } else if (this.streamType == BlobType.PAGE_BLOB) { + this.parentBlobRef.uploadProperties(this.accessCondition, this.options, this.opContext); + } + } + + /** + * Dispatches a write operation for a given length. + * + * @param writeLength + * the length of the data to write, this is the write threshold that triggered the write. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @DoesServiceRequest + private synchronized void dispatchWrite(final int writeLength) throws IOException { + if (writeLength == 0) { + return; + } + + Callable worker = null; + + if (this.outstandingRequests > this.options.getConcurrentRequestCount() * 2) { + this.waitForTaskToComplete(); + } + + final ByteArrayInputStream bufferRef = new ByteArrayInputStream(this.outBuffer.toByteArray()); + + if (this.streamType == BlobType.BLOCK_BLOB) { + final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; + final String blockID = Base64.encode(Utility.getBytesFromLong(this.blockIdSequenceNumber++)); + this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED)); + + worker = new Callable() { + public Void call() { + try { + blobRef.uploadBlock(blockID, + bufferRef, + writeLength, + BlobOutputStream.this.accessCondition, + BlobOutputStream.this.options, + BlobOutputStream.this.opContext); + } catch (final IOException e) { + synchronized (BlobOutputStream.this.lastErrorLock) { + BlobOutputStream.this.streamFaulted = true; + BlobOutputStream.this.lastError = e; + } + } catch (final StorageException e) { + synchronized (BlobOutputStream.this.lastErrorLock) { + BlobOutputStream.this.streamFaulted = true; + BlobOutputStream.this.lastError = Utility.initIOException(e); + } + } + return null; + } + }; + } else if (this.streamType == BlobType.PAGE_BLOB) { + final CloudPageBlob blobRef = (CloudPageBlob) this.parentBlobRef; + long tempOffset = this.currentPageOffset; + long tempLength = writeLength; + + if (this.options.getUseSparsePageBlob()) { + if (this.lastNonZeroBufferedByte == -1) { + // All zero page range, reset buffer and return + this.firstNonZeroBufferedByte = -1; + this.lastNonZeroBufferedByte = -1; + this.currentBufferedBytes = 0; + this.currentPageOffset += writeLength; + this.outBuffer = new ByteArrayOutputStream(); + return; + } + + // Offset is currentOffset - extra data to page align write + final long bufferOffset = + this.firstNonZeroBufferedByte - this.firstNonZeroBufferedByte % BlobConstants.PAGE_SIZE; + + tempOffset = this.currentPageOffset + bufferOffset; + + // Find end of last full page - to do this Calculate the end of + // last full page of non zero + // data and subtract the bufferStarting offset calculated above + tempLength = + (this.lastNonZeroBufferedByte - bufferOffset) + + (BlobConstants.PAGE_SIZE - (this.lastNonZeroBufferedByte % BlobConstants.PAGE_SIZE)); + + // Reset buffer markers. + this.firstNonZeroBufferedByte = -1; + this.lastNonZeroBufferedByte = -1; + + // Fast forward buffer past zero data if applicable + if (bufferOffset > 0) { + if (bufferOffset != bufferRef.skip(bufferOffset)) { + // Since this buffer is a byte array buffer this should + // always skip the correct number + // of bytes. + throw Utility.initIOException(Utility.generateNewUnexpectedStorageException(null)); + } + } + } + + final long opWriteLength = tempLength; + final long opOffset = tempOffset; + this.currentPageOffset += writeLength; + + worker = new Callable() { + public Void call() { + try { + blobRef.uploadPages(bufferRef, + opOffset, + opWriteLength, + BlobOutputStream.this.accessCondition, + BlobOutputStream.this.options, + BlobOutputStream.this.opContext); + } catch (final IOException e) { + synchronized (BlobOutputStream.this.lastErrorLock) { + BlobOutputStream.this.streamFaulted = true; + BlobOutputStream.this.lastError = e; + } + } catch (final StorageException e) { + synchronized (BlobOutputStream.this.lastErrorLock) { + BlobOutputStream.this.streamFaulted = true; + BlobOutputStream.this.lastError = Utility.initIOException(e); + } + } + return null; + } + }; + } + + // Do work and rest buffer. + this.completionService.submit(worker); + this.outstandingRequests++; + this.currentBufferedBytes = 0; + this.outBuffer = new ByteArrayOutputStream(); + } + + /** + * Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the + * buffer it is committed to the service. + */ + @Override + @DoesServiceRequest + public synchronized void flush() throws IOException { + this.checkStreamState(); + + if (this.streamType == BlobType.PAGE_BLOB && this.currentBufferedBytes > 0 + && (this.currentBufferedBytes % BlobConstants.PAGE_SIZE != 0)) { + throw new IOException( + String.format("Page data must be a multiple of 512 bytes, buffer currently contains %d bytes.", + this.currentBufferedBytes)); + + // Non 512 byte remainder, uncomment to pad with bytes and commit. + /* + * byte[] nullBuff = new byte[BlobConstants.PageSize - this.currentBufferedBytes % BlobConstants.PageSize]; + * this.write(nullBuff); + */ + } + + this.dispatchWrite(this.currentBufferedBytes); + } + + /** + * Waits for one task to complete + * + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + private void waitForTaskToComplete() throws IOException { + try { + final Future future = this.completionService.take(); + future.get(); + } catch (final InterruptedException e) { + throw Utility.initIOException(e); + } catch (final ExecutionException e) { + throw Utility.initIOException(e); + } + + this.outstandingRequests--; + } + + /** + * Writes b.length bytes from the specified byte array to this output stream. + * + * @param data + * the byte array to write. + * + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @Override + @DoesServiceRequest + public void write(final byte[] data) throws IOException { + this.write(data, 0, data.length); + } + + /** + * Writes length bytes from the specified byte array starting at offset to this output stream. + * + * @param data + * the byte array to write. + * @param offset + * the start offset in the data. + * @param length + * the number of bytes to write. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @Override + @DoesServiceRequest + public void write(final byte[] data, final int offset, final int length) throws IOException { + if (offset < 0 || length < 0 || length > data.length - offset) { + throw new IndexOutOfBoundsException(); + } + + this.writeInternal(data, offset, length); + } + + /** + * Writes all data from the InputStream to the Blob. + * + * @param sourceStream + * the InputStram to consume. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + * @throws StorageException + */ + @DoesServiceRequest + public void write(final InputStream sourceStream, final long writeLength) throws IOException, StorageException { + Utility.writeToOutputStream(sourceStream, this, writeLength, false, false, null, this.opContext); + } + + /** + * Writes the specified byte to this output stream. The general contract for write is that one byte is written to + * the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits + * of b are ignored. + * + * @param byteVal + * the byteValue to write. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @Override + public void write(final int byteVal) throws IOException { + this.write(new byte[] { (byte) (byteVal & 0xFF) }); + } + + /** + * Writes the data to the buffer and triggers writes to the service as needed. + * + * @param data + * the byte array to write. + * @param offset + * the start offset in the data. + * @param length + * the number of bytes to write. + * @throws IOException + * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been + * closed. + */ + @DoesServiceRequest + private synchronized void writeInternal(final byte[] data, int offset, int length) throws IOException { + while (length > 0) { + this.checkStreamState(); + final int availableBufferBytes = this.internalWriteThreshold - this.currentBufferedBytes; + final int nextWrite = Math.min(availableBufferBytes, length); + + // If we need to set MD5 then update the digest accordingly + if (this.options.getStoreBlobContentMD5()) { + this.md5Digest.update(data, offset, nextWrite); + } + + // If Page blob and UseSparsePageBlob is true, then track first and + // last non zero bytes. + if (this.options.getUseSparsePageBlob()) { + for (int m = 0; m < nextWrite; m++) { + if (data[m + offset] != 0) { + if (this.firstNonZeroBufferedByte == -1) { + this.firstNonZeroBufferedByte = this.currentBufferedBytes + m; + } + + this.lastNonZeroBufferedByte = this.currentBufferedBytes + m; + } + } + } + + this.outBuffer.write(data, offset, nextWrite); + this.currentBufferedBytes += nextWrite; + offset += nextWrite; + length -= nextWrite; + + if (this.currentBufferedBytes == this.internalWriteThreshold) { + this.dispatchWrite(this.internalWriteThreshold); + } + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java new file mode 100644 index 0000000000000..97684f64a8ea2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -0,0 +1,271 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.LeaseStatus; + +/** + * Represents the system properties for a blob. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobProperties { + + /** + * Represents the type of the blob. + */ + private BlobType blobType = BlobType.UNSPECIFIED; + + /** + * Represents the cache-control value stored for the blob. + */ + private String cacheControl; + + /** + * Represents the content-encoding value stored for the blob. If this field has not been set for the blob, the field + * returns null. + */ + private String contentEncoding; + + /** + * Represents the content-language value stored for the blob. If this field has not been set for the blob, the field + * returns null. + */ + private String contentLanguage; + + /** + * Represents the content MD5 value stored for the blob. + */ + private String contentMD5; + + /** + * Represents the content type value stored for the blob. If this field has not been set for the blob, the field + * returns null. + */ + private String contentType; + + /** + * Represents the blob's ETag value. + *

+ * The ETag value is a unique identifier that is updated when a write operation is performed against the container. + * It may be used to perform operations conditionally, providing concurrency control and improved efficiency. + *

+ * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return + * an {@link AccessCondition} object that may be specified on the request. + */ + private String etag; + + /** + * Represents the last-modified time for the blob. + */ + private Date lastModified; + + /** + * Represents the blob's lease status. + */ + private LeaseStatus leaseStatus = com.microsoft.windowsazure.services.core.storage.LeaseStatus.UNLOCKED; + + /** + * Represents the size, in bytes, of the blob. + */ + private long length; + + /** + * Creates an instance of the BlobProperties class. + */ + public BlobProperties() { + // No op + } + + /** + * Creates an instance of the BlobProperties class by copying values from another instance of the + * BlobProperties class. + * + * @param other + * A BlobProperties object that represents the blob properties to copy. + */ + public BlobProperties(final BlobProperties other) { + this.blobType = other.blobType; + this.contentEncoding = other.contentEncoding; + this.contentLanguage = other.contentLanguage; + this.contentType = other.contentType; + this.etag = other.etag; + this.leaseStatus = other.leaseStatus; + this.length = other.length; + this.lastModified = other.lastModified; + // TODO why not copy cachecontrol, contentmd5? + } + + /** + * Creates an instance of the BlobProperties class. + */ + public BlobProperties(final BlobType type) { + this.blobType = type; + } + + /** + * Returns the blob type for the blob. + * + * @return A {@link BlobType} value that represents the blob type. + */ + public BlobType getBlobType() { + return this.blobType; + } + + /** + * @return the cacheControl + */ + public String getCacheControl() { + return this.cacheControl; + } + + /** + * @return the contentEncoding + */ + public String getContentEncoding() { + return this.contentEncoding; + } + + /** + * @return the contentLanguage + */ + public String getContentLanguage() { + return this.contentLanguage; + } + + /** + * @return the contentMD5 + */ + public String getContentMD5() { + return this.contentMD5; + } + + /** + * @return the contentType + */ + public String getContentType() { + return this.contentType; + } + + /** + * @return the etag + */ + public String getEtag() { + return this.etag; + } + + /** + * @return the lastModified + */ + public Date getLastModified() { + return this.lastModified; + } + + /** + * Reserved for internal use. + * + * @return the leaseStatus + */ + public LeaseStatus getLeaseStatus() { + return this.leaseStatus; + } + + /** + * @return the length + */ + public long getLength() { + return this.length; + } + + /** + * Reserved for internal use. + * + * @param blobType + * the blobType to set + */ + protected void setBlobType(final BlobType blobType) { + this.blobType = blobType; + } + + /** + * @param cacheControl + * the cacheControl to set + */ + public void setCacheControl(final String cacheControl) { + this.cacheControl = cacheControl; + } + + /** + * @param contentEncoding + * the contentEncoding to set + */ + public void setContentEncoding(final String contentEncoding) { + this.contentEncoding = contentEncoding; + } + + /** + * @param contentLanguage + * the contentLanguage to set + */ + public void setContentLanguage(final String contentLanguage) { + this.contentLanguage = contentLanguage; + } + + /** + * @param contentMD5 + * the contentMD5 to set + */ + public void setContentMD5(final String contentMD5) { + this.contentMD5 = contentMD5; + } + + /** + * @param contentType + * the contentType to set + */ + public void setContentType(final String contentType) { + this.contentType = contentType; + } + + /** + * Reserved for internal use. + * + * @param etag + * the etag to set + */ + public void setEtag(final String etag) { + this.etag = etag; + } + + /** + * Reserved for internal use. + * + * @param lastModified + * the lastModified to set + */ + public void setLastModified(final Date lastModified) { + this.lastModified = lastModified; + } + + /** + * Reserved for internal use. + * + * @param leaseStatus + * the leaseStatus to set + */ + public void setLeaseStatus(final LeaseStatus leaseStatus) { + this.leaseStatus = leaseStatus; + } + + /** + * Reserved for internal use. + * + * @param length + * the length to set + */ + public void setLength(final long length) { + this.length = length; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java new file mode 100644 index 0000000000000..b8092d104d292 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java @@ -0,0 +1,970 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.LeaseAction; + +/** + * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing requests for blob operations. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobRequest { + /** + * Adds the metadata. + * + * @param request + * The request. + * @param metadata + * The metadata. + */ + public static void addMetadata( + final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + BaseRequest.addMetadata(request, metadata, opContext); + } + + /** + * Adds the metadata. + * + * @param request + * The request. + * @param name + * The metadata name. + * @param value + * The metadata value. + */ + public static void addMetadata( + final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + BaseRequest.addMetadata(request, name, value, opContext); + } + + /** + * Creates a request to copy a blob, Sign with 0 length. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @param source + * The canonical path to the source blob, in the form ///. + * @param sourceSnapshotID + * The snapshot version, if the source blob is a snapshot. + * @param sourceAccessConditionType + * A type of condition to check on the source blob. + * @param sourceAccessConditionValue + * The value of the condition to check on the source blob + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + * @throws IOException + * @throws URISyntaxException + */ + public static HttpURLConnection copyFrom( + final URI uri, final int timeout, String source, final String sourceSnapshotID, + final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws StorageException, IOException, URISyntaxException { + + if (sourceSnapshotID != null) { + source = source.concat("?snapshot="); + source = source.concat(sourceSnapshotID); + } + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, null, opContext); + + request.setFixedLengthStreamingMode(0); + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + request.setRequestProperty(Constants.HeaderConstants.COPY_SOURCE_HEADER, source); + + if (sourceAccessCondition != null) { + sourceAccessCondition.applyConditionToRequest(request, true); + } + + if (destinationAccessCondition != null) { + destinationAccessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Creates the web request. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @param query + * The query builder to use. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + private static HttpURLConnection createURLConnection( + final URI uri, final int timeout, final UriQueryBuilder query, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + return BaseRequest.createURLConnection(uri, timeout, query, opContext); + } + + /** + * Constructs a HttpURLConnection to delete the blob, Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param deleteSnapshotsOption + * A set of options indicating whether to delete only blobs, only snapshots, or both. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection delete( + final URI uri, final int timeout, final String snapshotVersion, + final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + + if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) { + throw new IllegalArgumentException( + String.format("The option '%s' must be 'None' to delete a specific snapshot specified by '%s'", + "deleteSnapshotsOption", + "snapshot")); + } + + final UriQueryBuilder builder = new UriQueryBuilder(); + BaseRequest.addSnapshot(builder, snapshotVersion); + final HttpURLConnection request = BaseRequest.delete(uri, timeout, builder, opContext); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + switch (deleteSnapshotsOption) { + case NONE: + // nop + break; + case INCLUDE_SNAPSHOTS: + request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER, + BlobConstants.INCLUDE_SNAPSHOTS_VALUE); + break; + case DELETE_SNAPSHOTS_ONLY: + request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER, + BlobConstants.SNAPSHOTS_ONLY_VALUE); + break; + default: + break; + } + + return request; + } + + /** + * Constructs a HttpURLConnection to download the blob, Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param offset + * The offset at which to begin returning content. + * @param count + * The number of bytes to return. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection get( + final URI uri, final int timeout, final String snapshotVersion, final long offset, final long count, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + final HttpURLConnection request = get(uri, timeout, snapshotVersion, accessCondition, blobOptions, opContext); + + final String rangeHeaderValue = + String.format(Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, offset, offset + count + - 1); + + request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, rangeHeaderValue); + + return request; + } + + /** + * Constructs a HttpURLConnection to download the blob, Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection get( + final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + BaseRequest.addSnapshot(builder, snapshotVersion); + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + request.setRequestMethod("GET"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to return a list of the block blobs blocks. Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param blockFilter + * The types of blocks to include in the list: committed, uncommitted, or both. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection getBlockList( + final URI uri, final int timeout, final String snapshotVersion, final BlockListingFilter blockFilter, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws StorageException, IOException, URISyntaxException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + + builder.add("comp", "blocklist"); + builder.add("blocklisttype", blockFilter.toString()); + BaseRequest.addSnapshot(builder, snapshotVersion); + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + request.setRequestMethod("GET"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to return a list of the PageBlob's page ranges. Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection getPageRanges( + final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws StorageException, IOException, URISyntaxException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "pagelist"); + BaseRequest.addSnapshot(builder, snapshotVersion); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + request.setRequestMethod("GET"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + BaseRequest.addOptionalHeader(request, BlobConstants.SNAPSHOT, snapshotVersion); + return request; + } + + /** + * Constructs a HttpURLConnection to return the blob's system properties, Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param snapshotVersion + * The snapshot version, if the blob is a snapshot. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection getProperties( + final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws StorageException, IOException, URISyntaxException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + BaseRequest.addSnapshot(builder, snapshotVersion); + final HttpURLConnection request = BaseRequest.getProperties(uri, timeout, builder, opContext); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a blob lease. Sign with 0 length. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param action + * the LeaseAction to perform + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection lease( + final URI uri, final int timeout, final LeaseAction action, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "lease"); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setDoOutput(true); + request.setRequestMethod("PUT"); + request.setFixedLengthStreamingMode(0); + request.setRequestProperty("x-ms-lease-action", action.toString()); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + return request; + } + + /** + * Constructs a HttpURLConnection to list blobs. Sign with no length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param listingContext + * A set of parameters for the listing operation. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + * */ + public static HttpURLConnection list( + final URI uri, final int timeout, final BlobListingContext listingContext, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = ContainerRequest.getContainerUriQueryBuilder(); + builder.add("comp", "list"); + + if (listingContext != null) { + if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { + builder.add("prefix", listingContext.getPrefix()); + } + + if (!Utility.isNullOrEmpty(listingContext.getDelimiter())) { + builder.add("delimiter", listingContext.getDelimiter()); + } + + if (!Utility.isNullOrEmpty(listingContext.getMarker())) { + builder.add("marker", listingContext.getMarker()); + } + + if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { + builder.add("maxresults", listingContext.getMaxResults().toString()); + } + + if (listingContext.getListingDetails().size() > 0) { + final StringBuilder sb = new StringBuilder(); + + boolean started = false; + + if (listingContext.getListingDetails().contains(BlobListingDetails.SNAPSHOTS)) { + if (!started) { + started = true; + } else { + sb.append(","); + } + + sb.append("snapshots"); + } + + if (listingContext.getListingDetails().contains(BlobListingDetails.UNCOMMITTED_BLOBS)) { + if (!started) { + started = true; + } else { + sb.append(","); + } + + sb.append("uncommittedblobs"); + } + + if (listingContext.getListingDetails().contains(BlobListingDetails.METADATA)) { + if (!started) { + started = true; + } else { + sb.append(","); + } + + sb.append("metadata"); + } + + builder.add("include", sb.toString()); + } + } + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Constructs a HttpURLConnection to upload a blob. Sign with blob length, or -1 for pageblob create. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param properties + * The properties to set for the blob. + * @param blobType + * The type of the blob. + * @param pageBlobSize + * For a page blob, the size of the blob. This parameter is ignored for block blobs. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection put( + final URI uri, final int timeout, final BlobProperties properties, final BlobType blobType, + final long pageBlobSize, final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + if (blobType == BlobType.UNSPECIFIED) { + throw new IllegalArgumentException("The blob type cannot be undefined."); + } + + final HttpURLConnection request = BlobRequest.createURLConnection(uri, timeout, null, blobOptions, opContext); + + request.setDoOutput(true); + + request.setRequestMethod("PUT"); + + // use set optional header + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL, properties.getCacheControl()); + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_TYPE, properties.getContentType()); + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_MD5, properties.getContentMD5()); + BaseRequest.addOptionalHeader(request, + Constants.HeaderConstants.CONTENT_LANGUAGE, + properties.getContentLanguage()); + BaseRequest.addOptionalHeader(request, + Constants.HeaderConstants.CONTENT_ENCODING, + properties.getContentEncoding()); + + if (blobType == BlobType.PAGE_BLOB) { + request.setFixedLengthStreamingMode(0); + request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0"); + + request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.PAGE_BLOB); + request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize)); + + properties.setLength(pageBlobSize); + } else { + request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB); + } + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to upload a block. Sign with length of block data. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param blockId + * the Base64 ID for the block + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection putBlock( + final URI uri, final int timeout, final String blockId, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "block"); + builder.add("blockid", blockId); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection putBlockList( + final URI uri, final int timeout, final BlobProperties properties, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "blocklist"); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + BaseRequest.addOptionalHeader(request, + Constants.HeaderConstants.CACHE_CONTROL_HEADER, + properties.getCacheControl()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); + BaseRequest.addOptionalHeader(request, BlobConstants.BLOB_CONTENT_MD5_HEADER, properties.getContentMD5()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_TYPE_HEADER, properties.getContentType()); + + return request; + } + + /** + * Constructs a HttpURLConnection to upload a block. Sign with page length for update, or 0 for clear. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param properties + * the page properties + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection putPage( + final URI uri, final int timeout, final PageProperties properties, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "page"); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + if (properties.getPageOperation() == PageOperationType.CLEAR) { + request.setFixedLengthStreamingMode(0); + } + + // Page write is either update or clean; required + request.setRequestProperty(BlobConstants.PAGE_WRITE, properties.getPageOperation().toString()); + request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, properties.getRange().toString()); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to set the blob's metadata, Sign with 0 length. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection setMetadata( + final URI uri, final int timeout, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final HttpURLConnection request = BaseRequest.setMetadata(uri, timeout, null, opContext); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param newBlobSize + * The new blob size, if the blob is a page blob. Set this parameter to null to keep the existing blob + * size. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection setProperties( + final URI uri, final int timeout, final BlobProperties properties, final Long newBlobSize, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "properties"); + + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setFixedLengthStreamingMode(0); + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + if (newBlobSize != null) { + request.setRequestProperty(BlobConstants.SIZE, newBlobSize.toString()); + properties.setLength(newBlobSize); + } + + BaseRequest.addOptionalHeader(request, + Constants.HeaderConstants.CACHE_CONTROL_HEADER, + properties.getCacheControl()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); + BaseRequest.addOptionalHeader(request, BlobConstants.BLOB_CONTENT_MD5_HEADER, properties.getContentMD5()); + BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_TYPE_HEADER, properties.getContentType()); + + return request; + } + + /** + * Constructs a HttpURLConnection to create a snapshot of the blob. Sign with 0 length. + * + * @param uri + * The absolute URI to the blob + * @param timeout + * The server timeout interval + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param blobOptions + * the options to use for the request. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection to use to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if the resource URI is invalid + * @throws StorageException + * an exception representing any error which occurred during the operation. + * @throws IllegalArgumentException + */ + public static HttpURLConnection snapshot( + final URI uri, final int timeout, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add(Constants.HeaderConstants.COMP, BlobConstants.SNAPSHOT); + final HttpURLConnection request = + BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + + request.setFixedLengthStreamingMode(0); + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + if (accessCondition != null) { + accessCondition.applyConditionToRequest(request); + } + + return request; + } + + /** + * Writes a Block List and returns the corresponding UTF8 bytes. + * + * @param blockList + * the Iterable of BlockEntry to write + * @param opContext + * a tracking object for the request + * @return a byte array of the UTF8 bytes representing the serialized block list. + * @throws XMLStreamException + * if there is an error writing the block list. + * @throws StorageException + */ + public static byte[] writeBlockListToStream(final Iterable blockList, final OperationContext opContext) + throws XMLStreamException, StorageException { + + final StringWriter outWriter = new StringWriter(); + final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); + final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); + + // default is UTF8 + xmlw.writeStartDocument(); + xmlw.writeStartElement(BlobConstants.BLOCK_LIST_ELEMENT); + + for (final BlockEntry block : blockList) { + if (block.searchMode == BlockSearchMode.COMMITTED) { + xmlw.writeStartElement(BlobConstants.COMMITTED_ELEMENT); + } else if (block.searchMode == BlockSearchMode.UNCOMMITTED) { + xmlw.writeStartElement(BlobConstants.UNCOMMITTED_ELEMENT); + } else if (block.searchMode == BlockSearchMode.LATEST) { + xmlw.writeStartElement(BlobConstants.LATEST_ELEMENT); + } + + xmlw.writeCharacters(block.getId()); + xmlw.writeEndElement(); + } + + // end BlockListElement + xmlw.writeEndElement(); + + // end doc + xmlw.writeEndDocument(); + try { + return outWriter.toString().getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * Private Default Ctor + */ + private BlobRequest() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java new file mode 100644 index 0000000000000..7b5d453e768fc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java @@ -0,0 +1,164 @@ +/** + * + */ +package com.microsoft.windowsazure.services.blob.client; + +import com.microsoft.windowsazure.services.core.storage.RequestOptions; + +/** + * Represents a set of options that may be specified on a request. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlobRequestOptions extends RequestOptions { + + /** + * Represents the concurrent number of simultaneous requests per operation. If it's null, it will be set to the + * value specified by the cloud blob client's {@link CloudBlobClient#getConcurrentRequestCount} method during upload + * operations. + */ + private Integer concurrentRequestCount = null; + + /** + * Specifies whether a range PUT or GET operation will use the Content-MD5 header to enforce transactional security. + * All partial blob uploads or downloads will be restricted to 4 MB. The default value is false. + */ + private Boolean useTransactionalContentMD5 = false; + + /** + * Specifies whether the blob's ContentMD5 header should be set on uploads. This field is not supported for page + * blobs. The default value is false. + */ + private Boolean storeBlobContentMD5 = false; + + /** + * Specifies whether download and {@link BlobInputStream} methods should ignore the blob's ContentMD5 header. The + * default value is false. + */ + private Boolean disableContentMD5Validation = false; + + /** + * Specifies whether to use sparse page blobs. + * + * When true, "zero" pages are not explicitly uploaded for a page blob; additionally, GET page ranges + * are used only to download explicit information for the page blob. The default value is false. + */ + private Boolean useSparsePageBlob = false; + + /** + * Creates an instance of the BlobRequestOptions class. + */ + public BlobRequestOptions() { + // Empty Default Ctor + } + + /** + * Creates an instance of the BlobRequestOptions class by copying values from another + * BlobRequestOptions instance. + * + * @param other + * A BlobRequestOptions object that represents the blob request options to copy. + */ + public BlobRequestOptions(final BlobRequestOptions other) { + super(other); + this.setConcurrentRequestCount(other.getConcurrentRequestCount()); + this.setStoreBlobContentMD5(other.getStoreBlobContentMD5()); + this.setUseTransactionalContentMD5(other.getUseTransactionalContentMD5()); + this.setUseSparsePageBlob(other.getUseSparsePageBlob()); + this.disableContentMD5Validation = other.disableContentMD5Validation; + } + + /** + * Uses the default timeout interval and retry policy from the specified client if the timeout interval and retry + * policy are null, and also sets the concurrent request count (whether or not it has already been + * assigned a value). + * + * @param client + * A {@link CloudBlobClient} object that represents the service client used to set the default timeout + * interval and retry policy, if they are null. Additionally, if the + * {@link #concurrentRequestCount} field's value is null, it will be set to the value specified by the + * cloud blob client's {@link CloudBlobClient#getConcurrentRequestCount} method. + */ + protected void applyDefaults(final CloudBlobClient client) { + super.applyBaseDefaults(client); + + if (this.getConcurrentRequestCount() == null) { + this.setConcurrentRequestCount(client.getConcurrentRequestCount()); + } + } + + /** + * @return the concurrentRequestCount + */ + public Integer getConcurrentRequestCount() { + return this.concurrentRequestCount; + } + + /** + * @return the disableContentMD5Validation + */ + protected Boolean getDisableContentMD5Validation() { + return this.disableContentMD5Validation; + } + + /** + * @return the storeBlobContentMD5 + */ + public Boolean getStoreBlobContentMD5() { + return this.storeBlobContentMD5; + } + + /** + * @return the useSparsePageBlob + */ + public Boolean getUseSparsePageBlob() { + return this.useSparsePageBlob; + } + + /** + * @return the useTransactionalContentMD5 + */ + public Boolean getUseTransactionalContentMD5() { + return this.useTransactionalContentMD5; + } + + /** + * @param concurrentRequestCount + * the concurrentRequestCount to set + */ + public void setConcurrentRequestCount(final Integer concurrentRequestCount) { + this.concurrentRequestCount = concurrentRequestCount; + } + + /** + * @param disableContentMD5Validation + * the disableContentMD5Validation to set + */ + public void setDisableContentMD5Validation(final Boolean disableContentMD5Validation) { + this.disableContentMD5Validation = disableContentMD5Validation; + } + + /** + * @param storeBlobContentMD5 + * the storeBlobContentMD5 to set + */ + public void setStoreBlobContentMD5(final Boolean storeBlobContentMD5) { + this.storeBlobContentMD5 = storeBlobContentMD5; + } + + /** + * @param useSparsePageBlob + * the useSparsePageBlob to set + */ + public void setUseSparsePageBlob(final Boolean useSparsePageBlob) { + this.useSparsePageBlob = useSparsePageBlob; + } + + /** + * @param useTransactionalContentMD5 + * the useTransactionalContentMD5 to set + */ + public void setUseTransactionalContentMD5(final Boolean useTransactionalContentMD5) { + this.useTransactionalContentMD5 = useTransactionalContentMD5; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java new file mode 100644 index 0000000000000..34c8bd5c42e15 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java @@ -0,0 +1,120 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.HttpURLConnection; +import java.net.URI; +import java.util.Calendar; +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; + +/** + * RESERVED FOR INTERNAL USE. A class for parsing various responses from the blob service + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobResponse extends BaseResponse { + + /** + * Gets the BlobAttributes from the given request + * + * @param request + * The response from server. + * @param resourceURI + * The blob uri to set. + * @param snapshotID + * The snapshot version, if the blob is a snapshot. + * @param opContext + * a tracking object for the request + * @return the BlobAttributes from the given request + */ + public static BlobAttributes getAttributes( + final HttpURLConnection request, final URI resourceURI, final String snapshotID, + final OperationContext opContext) { + + final String blobType = request.getHeaderField(BlobConstants.BLOB_TYPE_HEADER); + final BlobAttributes attributes = new BlobAttributes(BlobType.parse(blobType)); + final BlobProperties properties = attributes.getProperties(); + + properties.setCacheControl(request.getHeaderField(Constants.HeaderConstants.CACHE_CONTROL)); + properties.setContentEncoding(request.getHeaderField(Constants.HeaderConstants.CONTENT_ENCODING)); + properties.setContentLanguage(request.getHeaderField(Constants.HeaderConstants.CONTENT_LANGUAGE)); + properties.setContentMD5(request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5)); + properties.setContentType(request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE)); + properties.setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); + + final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); + lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); + lastModifiedCalendar.setTime(new Date(request.getLastModified())); + properties.setLastModified(lastModifiedCalendar.getTime()); + + final String leaseStatus = request.getHeaderField(Constants.HeaderConstants.LEASE_STATUS); + if (!Utility.isNullOrEmpty(leaseStatus)) { + properties.setLeaseStatus(com.microsoft.windowsazure.services.core.storage.LeaseStatus.parse(leaseStatus)); + } + + final String rangeHeader = request.getHeaderField(Constants.HeaderConstants.CONTENT_RANGE); + final String xContentLengthHeader = request.getHeaderField(BlobConstants.CONTENT_LENGTH_HEADER); + + if (!Utility.isNullOrEmpty(rangeHeader)) { + properties.setLength(Long.parseLong(rangeHeader)); + } else if (!Utility.isNullOrEmpty(xContentLengthHeader)) { + properties.setLength(Long.parseLong(xContentLengthHeader)); + } else { + // using this instead of the request property since the request + // property only returns an int. + final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + + if (!Utility.isNullOrEmpty(contentLength)) { + properties.setLength(Long.parseLong(contentLength)); + } + } + + attributes.uri = resourceURI; + attributes.snapshotID = snapshotID; + + attributes.setMetadata(getMetadata(request)); + return attributes; + } + + /** + * Gets the lease id from the request header. + * + * @param request + * The response from server. + * @param opContext + * a tracking object for the request + * @return the lease id from the request header. + */ + public static String getLeaseID(final HttpURLConnection request, final OperationContext opContext) { + return request.getHeaderField("x-ms-lease-id"); + } + + /** + * Gets the lease Time from the request header. + * + * @param request + * The response from server. + * @param opContext + * a tracking object for the request + * @return the lease Time from the request header. + */ + public static String getLeaseTime(final HttpURLConnection request, final OperationContext opContext) { + return request.getHeaderField("x-ms-lease-time"); + } + + /** + * Gets the snapshot ID from the request header. + * + * @param request + * The response from server. + * @param opContext + * a tracking object for the request + * @return the snapshot ID from the request header. + */ + public static String getSnapshotTime(final HttpURLConnection request, final OperationContext opContext) { + return request.getHeaderField("x-ms-snapshot"); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java new file mode 100644 index 0000000000000..1b77be9e4b419 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java @@ -0,0 +1,50 @@ +/** + * + */ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.Locale; + +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Specifies the type of a blob. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum BlobType { + /** + * Specifies the blob type is not specified. + */ + UNSPECIFIED, + + /** + * Specifies the blob is a block blob. + */ + BLOCK_BLOB, + + /** + * Specifies the blob is a page blob. + */ + PAGE_BLOB; + + /** + * Returns the enum value representing the blob type for the specified string. + * + * @param typeString + * A String that represents a blob type, such as "blockblob" or "pageblob". + * + * @return A BlobType value corresponding to the string specified by typeString. + */ + public static BlobType parse(final String typeString) { + if (Utility.isNullOrEmpty(typeString)) { + return UNSPECIFIED; + } else if ("blockblob".equals(typeString.toLowerCase(Locale.US))) { + return BLOCK_BLOB; + } else if ("pageblob".equals(typeString.toLowerCase(Locale.US))) { + return PAGE_BLOB; + } else { + return UNSPECIFIED; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java new file mode 100644 index 0000000000000..713fd924d200f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java @@ -0,0 +1,66 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * A class which is used to list and commit blocks of a {@link CloudBlockBlob}. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BlockEntry { + /** + * Represents the name of the block. + */ + private String id; + + /** + * Represents the size, in bytes, of the block. + */ + private long size; + + /** + * Represents the block search mode. The default value is {@link BlockSearchMode#LATEST}. + */ + public BlockSearchMode searchMode = BlockSearchMode.LATEST; + + /** + * Creates an instance of the BlockEntry class. + * + * @param id + * A String that represents the name of the block. + * @param searchMode + * A {@link BlockSearchMode} value that represents the block search mode. + */ + public BlockEntry(final String id, final BlockSearchMode searchMode) { + this.setId(id); + this.searchMode = searchMode; + } + + /** + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * @return the size + */ + public long getSize() { + return this.size; + } + + /** + * @param id + * the id to set + */ + public void setId(final String id) { + this.id = id; + } + + /** + * @param size + * the size to set + */ + public void setSize(final long size) { + this.size = size; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java new file mode 100644 index 0000000000000..860ce3e905f32 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java @@ -0,0 +1,23 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Specifies whether to list only committed blocks, only uncommitted blocks, or all blocks. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum BlockListingFilter { + /** + * List only committed blocks. + */ + COMMITTED, + + /** + * List only uncommitted blocks. + */ + UNCOMMITTED, + + /** + * List both committed and uncommitted blocks. + */ + ALL +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java new file mode 100644 index 0000000000000..26df47e7a5164 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java @@ -0,0 +1,24 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Specifies which block lists should be searched to find a specified block. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum BlockSearchMode { + /** + * Specifies searching only the committed block list. + */ + COMMITTED, + + /** + * Specifies searching only the uncommitted block list. + */ + UNCOMMITTED, + + /** + * Specifies searching the uncommitted block list first, and if the block is not found, then search the committed + * block list. + */ + LATEST +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java new file mode 100644 index 0000000000000..39c250c36754e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -0,0 +1,2438 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.LeaseStatus; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; +import com.microsoft.windowsazure.services.core.storage.RetryPolicy; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.LeaseAction; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * + * Represents a Windows Azure blob. This is the base class for the {@link CloudBlockBlob} and {@link CloudPageBlob} + * classes. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class CloudBlob implements ListBlobItem { + /** + * Holds the metadata for the blob. + */ + HashMap metadata; + + /** + * Holds the properties of the blob. + */ + BlobProperties properties; + + /** + * Holds the URI of the blob, Setting this is RESERVED for internal use. + */ + URI uri; + + /** + * Holds the snapshot ID. + */ + String snapshotID; + + /** + * Holds the Blobs container Reference. + */ + private CloudBlobContainer container; + + /** + * Represents the blob's directory. + */ + protected CloudBlobDirectory parent; + + /** + * Holds the Blobs Name. + */ + private String name; + + /** + * Represents the blob client. + */ + protected CloudBlobClient blobServiceClient; + + /** + * Creates an instance of the CloudBlob class. + * + * @param type + * the type of the blob. + */ + protected CloudBlob(final BlobType type) { + this.metadata = new HashMap(); + this.properties = new BlobProperties(type); + } + + /** + * Creates an instance of the CloudBlob class using the specified URI and cloud blob client. + * + * @param type + * the type of the blob. + * @param uri + * A java.net.URI object that represents the URI to the blob, beginning with the container + * name. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + */ + protected CloudBlob(final BlobType type, final URI uri, final CloudBlobClient client) throws StorageException { + this(type); + + Utility.assertNotNull("blobAbsoluteUri", uri); + Utility.assertNotNull("serviceClient", client); + + this.blobServiceClient = client; + this.uri = uri; + + this.parseURIQueryStringAndVerify(uri, client, client.isUsePathStyleUris()); + } + + /** + * Creates an instance of the CloudBlob class using the specified URI, cloud blob client, and cloud + * blob container. + * + * @param type + * the type of the blob. + * @param uri + * A java.net.URI object that represents the absolute URI to the blob, beginning with the + * container name. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * @param container + * A {@link CloudBlobContainer} object that represents the container to use for the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + protected CloudBlob(final BlobType type, final URI uri, final CloudBlobClient client, + final CloudBlobContainer container) throws StorageException { + this(type, uri, client); + this.container = container; + } + + /** + * Creates an instance of the CloudBlob class using the specified URI, snapshot ID, and cloud blob + * client. + * + * @param type + * the type of the blob. + * @param uri + * A java.net.URI object that represents the absolute URI to the blob, beginning with the + * container name. + * @param snapshotID + * A String that represents the snapshot version, if applicable. + * @param client + * A {@link CloudBlobContainer} object that represents the container to use for the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + protected CloudBlob(final BlobType type, final URI uri, final String snapshotID, final CloudBlobClient client) + throws StorageException { + this(type, uri, client); + if (snapshotID != null) { + if (this.snapshotID != null) { + throw new IllegalArgumentException( + "Snapshot query parameter is already defined in the blobUri. Either pass in a snapshotTime parameter or use a full URL with a snapshot query parameter."); + } else { + this.snapshotID = snapshotID; + } + } + } + + /** + * Creates an instance of the CloudBlob class by copying values from another blob. + * + * @param otherBlob + * A CloudBlob object that represents the blob to copy. + */ + protected CloudBlob(final CloudBlob otherBlob) { + this.metadata = new HashMap(); + this.properties = new BlobProperties(otherBlob.properties); + + if (otherBlob.metadata != null) { + this.metadata = new HashMap(); + for (final String key : otherBlob.metadata.keySet()) { + this.metadata.put(key, otherBlob.metadata.get(key)); + } + } + + this.snapshotID = otherBlob.snapshotID; + this.uri = otherBlob.uri; + this.container = otherBlob.container; + this.parent = otherBlob.parent; + this.blobServiceClient = otherBlob.blobServiceClient; + this.name = otherBlob.name; + } + + /** + * Acquires a new lease on the blob. + * + * @return A String that represents the lease ID. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final String acquireLease() throws StorageException { + return this.acquireLease(null, null, null); + } + + /** + * Acquires a new lease on the blob using the specified request options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the lease ID. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final String acquireLease( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public String execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.lease(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + LeaseAction.ACQUIRE, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + blob.properties.setLeaseStatus(LeaseStatus.LOCKED); + + return BlobResponse.getLeaseID(request, opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Asserts that the blob has the correct blob type specified in the blob attributes. + * + * @throws StorageException + * If an incorrect blob type is used. + */ + protected final void assertCorrectBlobType() throws StorageException { + if (this instanceof CloudBlockBlob && this.properties.getBlobType() != BlobType.BLOCK_BLOB) { + throw new StorageException( + StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, + String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + BlobType.BLOCK_BLOB, + this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + if (this instanceof CloudPageBlob && this.properties.getBlobType() != BlobType.PAGE_BLOB) { + throw new StorageException( + StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, + String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + BlobType.PAGE_BLOB, + this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + + } + } + + /** + * Breaks the lease but ensures that another client cannot acquire a new lease until the current lease period has + * expired. + * + * @return The time, in seconds, remaining in the lease period, or -1 if the lease has already been broken. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final long breakLease() throws StorageException { + return this.breakLease(null, null, null); + } + + /** + * Breaks the lease, using the specified request options and operation context, but ensures that another client + * cannot acquire a new lease until the current lease period has expired. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return The time, in seconds, remaining in the lease period, or -1 if the lease has already been broken. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final long breakLease( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Long execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.lease(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + LeaseAction.BREAK, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return -1L; + } + + blob.updatePropertiesFromResponse(request); + final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + + blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); + return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Copies an existing blob's contents, properties, and metadata to this instance of the CloudBlob + * class. + * + * @param sourceBlob + * A CloudBlob object that represents the source blob to copy. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void copyFromBlob(final CloudBlob sourceBlob) throws StorageException { + this.copyFromBlob(sourceBlob, null, null, null, null); + } + + /** + * Copies an existing blob's contents, properties, and metadata to this instance of the CloudBlob + * class, using the specified access conditions, lease ID, request options, and operation context. + * + * @param sourceBlob + * A CloudBlob object that represents the source blob to copy. + * @param sourceAccessCondition + * An {@link AccessCondition} object that represents the access conditions for the source blob. + * @param destinationAccessCondition + * An {@link AccessCondition} object that represents the access conditions for the destination blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + * + */ + @DoesServiceRequest + public final void copyFromBlob( + final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, + final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.copyFrom(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + sourceBlob.getCanonicalName(false), + blob.snapshotID, + sourceAccessCondition, + destinationAccessCondition, + blobOptions, + opContext); + + BlobRequest.addMetadata(request, sourceBlob.metadata, opContext); + client.getCredentials().signRequest(request, 0); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Creates a snapshot of the blob. + * + * @return A CloudBlob object that represents the snapshot of the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final CloudBlob createSnapshot() throws StorageException { + return this.createSnapshot(null, null, null); + } + + /** + * Creates a snapshot of the blob using the specified request options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A CloudBlob object that represents the snapshot of the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final CloudBlob createSnapshot( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public CloudBlob execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.snapshot(blob.getTransformedAddress(opContext), this.getRequestOptions() + .getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + CloudBlob snapshot = null; + final String snapshotTime = BlobResponse.getSnapshotTime(request, opContext); + if (blob instanceof CloudBlockBlob) { + snapshot = new CloudBlockBlob(blob.getUri(), snapshotTime, client); + } else if (blob instanceof CloudPageBlob) { + snapshot = new CloudPageBlob(blob.getUri(), snapshotTime, client); + } + + blob.updatePropertiesFromResponse(request); + return snapshot; + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Deletes the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void delete() throws StorageException { + this.delete(DeleteSnapshotsOption.NONE, null, null, null); + } + + /** + * Deletes the blob using the specified snapshot and request options, and operation context. + *

+ * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use + * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value + * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob + * is deleted. + * + * @param deleteSnapshotsOption + * A {@link DeleteSnapshotsOption} object that indicates whether to delete only blobs, only snapshots, or + * both. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void delete( + final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException { + Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.delete(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.snapshotID, + deleteSnapshotsOption, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Deletes the blob if it exists. + *

+ * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use + * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value + * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob + * is deleted. + * + * @return true if the blob was deleted; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + * + */ + @DoesServiceRequest + public final Boolean deleteIfExists() throws StorageException { + return this.deleteIfExists(DeleteSnapshotsOption.NONE, null, null, null); + } + + /** + * Deletes the blob if it exists, using the specified snapshot and request options, and operation context. + *

+ * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use + * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value + * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob + * is deleted. + * + * @param deleteSnapshotsOption + * A {@link DeleteSnapshotsOption} object that indicates whether to delete only blobs, only snapshots, or + * both. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the blob was deleted; otherwise, false + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final Boolean deleteIfExists( + final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException { + Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Boolean execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.delete(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.snapshotID, + deleteSnapshotsOption, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + blob.updatePropertiesFromResponse(request); + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } else { + this.setNonExceptionedRetryableFailure(true); + + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Downloads the contents of a blob to a stream. + * + * @param outStream + * An OutputStream object that represents the target stream. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void download(final OutputStream outStream) throws StorageException, IOException { + this.download(outStream, null, null, null); + } + + /** + * Downloads the contents of a blob to a stream using the specified request options and operation context. + * + * @param outStream + * An OutputStream object that represents the target stream. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void download( + final OutputStream outStream, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException, IOException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.get(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blob.snapshotID, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); + this.setResult(opContext.getLastResult()); + + final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + final Boolean validateMD5 = + !blobOptions.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(contentMD5); + + final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + final long expectedLength = Long.parseLong(contentLength); + + final StreamDescriptor descriptor = + Utility.writeToOutputStream(streamRef, + outStream, + -1, + false, + validateMD5, + this.getResult(), + opContext); + + ExecutionEngine.getResponseCode(this.getResult(), request, opContext); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + + if (descriptor.getLength() != expectedLength) { + throw new StorageException( + StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect number of bytes was read from the connection. The connection may have been closed", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + if (validateMD5 && !contentMD5.equals(descriptor.getMd5())) { + throw new StorageException( + StorageErrorCodeStrings.INVALID_MD5, + String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + contentMD5, + descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + return null; + } + }; + + try { + // Executed with no retries so that the first failure will move out + // to the read Stream. + ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, RetryNoRetry.getInstance(), opContext); + opContext.setIntermediateMD5(null); + } catch (final StorageException ex) { + // Check if users has any retries specified. + final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext); + if (!dummyPolicy.shouldRetry(0, + opContext.getLastResult().getStatusCode(), + (Exception) ex.getCause(), + opContext).isShouldRetry()) { + opContext.setIntermediateMD5(null); + throw ex; + } + + // Continuation, fail gracefully into a read stream. This needs to + // be outside the operation above as it would get retried resulting + // in a nested retry + + // 1. Open Read Stream + final BlobInputStream streamRef = this.openInputStream(accessCondition, options, opContext); + + // Cache value indicating if we need + final boolean validateMd5 = streamRef.getValidateBlobMd5(); + + streamRef.setValidateBlobMd5(false); + streamRef.mark(Integer.MAX_VALUE); + + try { + // 2. Seek to current position, this will disable read streams + // internal content md5 checks. + if (opContext.getCurrentOperationByteCount() > 0) { + // SCA will say this if a failure as we do not validate the + // return of skip. + // The Blob class repositioning a virtual pointer and will + // always skip the correct + // number of bytes. + streamRef.skip(opContext.getCurrentOperationByteCount()); + } + + // 3. Continue copying + final StreamDescriptor descriptor = + Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMd5, null, opContext); + + if (validateMd5 && !this.properties.getContentMD5().equals(descriptor.getMd5())) { + throw new StorageException( + StorageErrorCodeStrings.INVALID_MD5, + String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + this.properties.getContentMD5(), + descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } catch (final IOException secondEx) { + opContext.setIntermediateMD5(null); + if (secondEx.getCause() != null && secondEx.getCause() instanceof StorageException) { + throw (StorageException) secondEx.getCause(); + } else { + throw secondEx; + } + } + } + } + + /** + * Populates a blob's properties and metadata. + *

+ * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties + * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and + * metadata from the Windows Azure storage service. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void downloadAttributes() throws StorageException { + this.downloadAttributes(null, null, null); + } + + /** + * Populates a blob's properties and metadata using the specified request options and operation context. + *

+ * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties + * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and + * metadata from the Windows Azure storage service. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void downloadAttributes( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.getProperties(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.snapshotID, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + // Set attributes + final BlobAttributes retrievedAttributes = + BlobResponse.getAttributes(request, blob.getUri(), blob.snapshotID, opContext); + + if (retrievedAttributes.getProperties().getBlobType() != blob.properties.getBlobType()) { + throw new StorageException( + StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, + String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + blob.properties.getBlobType(), + retrievedAttributes.getProperties().getBlobType()), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + blob.properties = retrievedAttributes.getProperties(); + blob.metadata = retrievedAttributes.getMetadata(); + + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Downloads a range of bytes from the blob to the given byte buffer. + * + * @param offset + * The byte offset to use as the starting point for the source. + * @param length + * The number of bytes to read. + * @param buffer + * The byte buffer, as an array of bytes, to which the blob bytes are downloaded. + * @param bufferOffet + * The byte offset to use as the starting point for the target. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void downloadRange(final long offset, final int length, final byte[] buffer, final int bufferOffet) + throws StorageException { + this.downloadRangeInternal(offset, length, buffer, bufferOffet, null, null, null); + } + + /** + * Downloads a range of bytes from the blob to the given byte buffer, using the specified request options and + * operation context. + * + * @param offset + * The byte offset to use as the starting point for the source. + * @param length + * The number of bytes to read. + * @param buffer + * The byte buffer, as an array of bytes, to which the blob bytes are downloaded. + * @param bufferOffet + * The byte offset to use as the starting point for the target. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void downloadRange( + final long offset, final int length, final byte[] buffer, final int bufferOffet, + final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) + throws StorageException { + if (offset < 0 || length <= 0) { + throw new IndexOutOfBoundsException(); + } + + Utility.assertNotNull("buffer", buffer); + + if (length + bufferOffet > buffer.length) { + throw new IndexOutOfBoundsException(); + } + + opContext.initialize(); + this.downloadRangeInternal(offset, length, buffer, bufferOffet, accessCondition, options, opContext); + } + + /** + * Downloads a range of bytes from the blob to the given byte buffer. + * + * @param blobOffset + * the offset of the blob to begin downloading at + * @param length + * the number of bytes to read + * @param buffer + * the byte buffer to write to. + * @param bufferOffet + * the offset in the byte buffer to begin writing. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + protected final void downloadRangeInternal( + final long blobOffset, final int length, final byte[] buffer, final int bufferOffset, + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (blobOffset < 0 || length <= 0) { + throw new IndexOutOfBoundsException(); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + if (options.getUseTransactionalContentMD5() && length > 4 * Constants.MB) { + throw new IllegalArgumentException( + "Cannot specify x-ms-range-get-content-md5 header on ranges larger than 4 MB. Either use a BlobReadStream via openRead, or disable TransactionalMD5 checking via the BlobRequestOptions."); + } + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.get(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blob.snapshotID, + blobOffset, + length, + accessCondition, + blobOptions, + opContext); + + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); + } + + client.getCredentials().signRequest(request, -1L); + + final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext); + this.setResult(opContext.getLastResult()); + + int totalRead = 0; + int nextRead = buffer.length - bufferOffset; + int count = sourceStream.read(buffer, bufferOffset, nextRead); + + while (count > 0) { + totalRead += count; + nextRead = buffer.length - (bufferOffset + totalRead); + + if (nextRead == 0) { + // check for case where more data is returned + if (sourceStream.read(new byte[1], 0, 1) != -1) { + throw new StorageException( + StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect number of bytes was read from the connection. The connection may have been closed", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } + count = sourceStream.read(buffer, bufferOffset + totalRead, nextRead); + } + + ExecutionEngine.getResponseCode(this.getResult(), request, opContext); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_PARTIAL) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + final long expectedLength = Long.parseLong(contentLength); + if (totalRead != expectedLength) { + throw new StorageException( + StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect number of bytes was read from the connection. The connection may have been closed", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + if (blobOptions.getUseTransactionalContentMD5()) { + final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + + try { + final MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(buffer, bufferOffset, length); + final String calculatedMD5 = Base64.encode(digest.digest()); + if (!contentMD5.equals(calculatedMD5)) { + throw new StorageException( + StorageErrorCodeStrings.INVALID_MD5, + String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + contentMD5, + calculatedMD5), Constants.HeaderConstants.HTTP_UNUSED_306, null, + null); + } + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Checks to see if the blob exists. + * + * @return true if the blob exists, other wise false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final boolean exists() throws StorageException { + return this.exists(null, null, null); + } + + /** + * Checks to see if the blob exists, using the specified request options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the blob exists, other wise false. + * + * @throws StorageException + * f a storage service error occurred. + */ + @DoesServiceRequest + public final boolean exists( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.getProperties(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.snapshotID, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + blob.updatePropertiesFromResponse(request); + return Boolean.valueOf(true); + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } else { + this.setNonExceptionedRetryableFailure(true); + + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Returns a shared access signature for the blob using the specified shared access policy. Note this does not + * contain the leading "?". + * + * @param policy + * A SharedAccessPolicy object that represents the access policy for the shared access + * signature. + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are unable to sign the request or if the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public final String generateSharedAccessSignature(final SharedAccessPolicy policy) + throws InvalidKeyException, StorageException { + return this.generateSharedAccessSignature(policy, null); + } + + /** + * Returns a shared access signature for the blob using the specified shared access policy and operation context. + * Note this does not contain the leading "?". + * + * @param policy + * A SharedAccessPolicy object that represents the access policy for the shared access + * signature. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are unable to sign the request or if the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public final String generateSharedAccessSignature(final SharedAccessPolicy policy, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + return this.generateSharedAccessSignatureCore(policy, null, opContext); + } + + /** + * Returns a shared access signature for the blob using the specified group policy identifier. Note this does not + * contain the leading "?". + * + * @param groupPolicyIdentifier + * A String that represents the container-level access policy. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are unable to sign the request or if the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public final String generateSharedAccessSignature(final String groupPolicyIdentifier) + throws InvalidKeyException, StorageException { + return this.generateSharedAccessSignature(groupPolicyIdentifier, null); + } + + /** + * Returns a shared access signature for the blob using the specified group policy identifier and operation context. + * Note this does not contain the leading "?". + * + * @param groupPolicyIdentifier + * A String that represents the container-level access policy. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are unable to sign the request or if the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public final String generateSharedAccessSignature(final String groupPolicyIdentifier, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + return this.generateSharedAccessSignatureCore(null, groupPolicyIdentifier, opContext); + } + + /** + * Returns a shared access signature for the blob using the specified group policy identifier and operation context. + * Note this does not contain the leading "?". + * + * @param policy + * A SharedAccessPolicy object that represents the access policy for the shared access + * signature. + * @param groupPolicyIdentifier + * A String that represents the container-level access policy. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are invalid or the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + private String generateSharedAccessSignatureCore( + final SharedAccessPolicy policy, final String groupPolicyIdentifier, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (!this.blobServiceClient.getCredentials().canCredentialsSignRequest()) { + throw new IllegalArgumentException( + "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."); + } + + if (this.isSnapshot()) { + throw new IllegalArgumentException( + "Cannot create Shared Access Signature for snapshots. Perform the operation on the root blob instead."); + } + + final String resourceName = this.getCanonicalName(true); + + final String signature = + SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, + groupPolicyIdentifier, + resourceName, + this.blobServiceClient, + opContext); + + final UriQueryBuilder builder = + SharedAccessSignatureHelper + .generateSharedAccessSignature(policy, groupPolicyIdentifier, "b", signature); + + return builder.toString(); + } + + /** + * Returns the canonical name of the blob in the format of + * /<account-name>/<container-name>/<blob-name>. + *

+ * This format is used by both Shared Access and Copy blob operations. + * + * @param ignoreSnapshotTime + * true if the snapshot time is ignored; otherwise, false. + * + * @return The canonical name in the format of /<account-name>/<container + * -name>/<blob-name>. + */ + String getCanonicalName(final boolean ignoreSnapshotTime) { + String canonicalName; + if (this.blobServiceClient.isUsePathStyleUris()) { + canonicalName = this.getUri().getRawPath(); + } else { + canonicalName = + PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this.getUri() + .getRawPath()); + } + + if (!ignoreSnapshotTime && this.snapshotID != null) { + canonicalName = canonicalName.concat("?snapshot="); + canonicalName = canonicalName.concat(this.snapshotID); + } + + return canonicalName; + } + + /** + * Returns the blob's container. + * + * @return A {@link CloudBlobContainer} object that represents the container of the blob. + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { + if (this.container == null) { + final URI containerURI = + PathUtility.getContainerURI(this.getUri(), this.blobServiceClient.isUsePathStyleUris()); + this.container = new CloudBlobContainer(containerURI, this.blobServiceClient); + } + + return this.container; + } + + /** + * Returns the metadata for the blob. + * + * @return A java.util.HashMap object that represents the metadata for the blob. + */ + public final HashMap getMetadata() { + return this.metadata; + } + + /** + * Returns the name of the blob. + * + * @return A String that represents the name of the blob. + * + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public final String getName() throws URISyntaxException { + if (Utility.isNullOrEmpty(this.name)) { + this.name = PathUtility.getBlobNameFromURI(this.getUri(), this.blobServiceClient.isUsePathStyleUris()); + } + return this.name; + } + + /** + * Returns the blob item's parent. + * + * @return A {@link CloudBlobDirectory} object that represents the parent directory for the blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException { + if (this.parent == null) { + final URI parentURI = + PathUtility.getParentAddress(this.getUri(), + this.blobServiceClient.getDirectoryDelimiter(), + this.blobServiceClient.isUsePathStyleUris()); + this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); + } + return this.parent; + } + + /** + * Returns the blob's properties. + * + * @return A {@link BlobProperties} object that represents the properties of the blob. + */ + public final BlobProperties getProperties() { + return this.properties; + } + + /** + * Returns the snapshot or shared access signature qualified URI for this blob. + * + * @return A java.net.URI object that represents the snapshot or shared access signature. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public final URI getQualifiedUri() throws URISyntaxException, StorageException { + if (this.isSnapshot()) { + return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); + } else if (this.blobServiceClient.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { + return this.blobServiceClient.getCredentials().transformUri(this.getUri()); + } else { + return this.getUri(); + } + } + + /** + * Returns the Blob service client associated with the blob. + * + * @return A {@link CloudBlobClient} object that represents the client. + */ + public final CloudBlobClient getServiceClient() { + return this.blobServiceClient; + } + + /** + * Gets the Blob Snapshot ID. + * + * @return the Blob Snapshot ID. + */ + public final String getSnapshotID() { + return this.snapshotID; + } + + /** + * Returns the transformed URI for the resource if the given credentials require transformation. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A java.net.URI object that represents the transformed URI. + * + * @throws IllegalArgumentException + * If the URI is not absolute. + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + protected final URI getTransformedAddress(final OperationContext opContext) + throws URISyntaxException, StorageException { + if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { + if (this.getUri().isAbsolute()) { + return this.blobServiceClient.getCredentials().transformUri(this.getUri(), opContext); + } else { + final StorageException ex = Utility.generateNewUnexpectedStorageException(null); + ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); + throw ex; + } + } else { + return this.getUri(); + } + } + + /** + * Returns the URI for this blob. + * + * @return A java.net.URI object that represents the URI for the blob. + */ + public final URI getUri() { + return this.uri; + } + + /** + * Indicates whether this blob is a snapshot. + * + * @return true if the blob is a snapshot, otherwise false. + * + * @see DeleteSnapshotsOption + */ + public final boolean isSnapshot() { + return this.snapshotID != null; + } + + /** + * Opens a blob input stream to download the blob. + *

+ * Use {@link CloudBlobClient#setStreamMinimumReadSizeInBytes} to configure the read size. + * + * @return An InputStream object that represents the stream to use for reading from the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final BlobInputStream openInputStream() throws StorageException { + return this.openInputStream(null, null, null); + } + + /** + * Opens a blob input stream to download the blob using the specified request options and operation context. + *

+ * Use {@link CloudBlobClient#setStreamMinimumReadSizeInBytes} to configure the read size. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An InputStream object that represents the stream to use for reading from the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final BlobInputStream openInputStream( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + return new BlobInputStream(this, accessCondition, options, opContext); + } + + /** + * Parse Uri for SAS (Shared access signature) information. + * + * Validate that no other query parameters are passed in. Any SAS information will be recorded as corresponding + * credentials instance. If existingClient is passed in, any SAS information found will not be supported. Otherwise + * a new client is created based on SAS information or as anonymous credentials. + * + * @param completeUri + * The complete Uri. + * @param existingClient + * The client to use. + * @param usePathStyleUris + * If true, path style Uris are used. + * @throws StorageException + * If a storage service error occurred. + * */ + private void parseURIQueryStringAndVerify( + final URI completeUri, final CloudBlobClient existingClient, final boolean usePathStyleUris) + throws StorageException { + Utility.assertNotNull("resourceUri", completeUri); + + if (!completeUri.isAbsolute()) { + final String errorMessage = + String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", + completeUri.toString()); + throw new IllegalArgumentException(errorMessage); + } + + this.uri = PathUtility.stripURIQueryAndFragment(completeUri); + + final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); + + final StorageCredentialsSharedAccessSignature sasCreds = + SharedAccessSignatureHelper.parseQuery(queryParameters); + + final String[] snapshotIDs = queryParameters.get(BlobConstants.SNAPSHOT); + if (snapshotIDs != null && snapshotIDs.length > 0) { + this.snapshotID = snapshotIDs[0]; + } + + if (sasCreds == null) { + return; + } + + final Boolean sameCredentials = + existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, existingClient.getCredentials()); + + if (existingClient == null || !sameCredentials) { + try { + this.blobServiceClient = + new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress(this.getUri(), + usePathStyleUris)), sasCreds); + } catch (final URISyntaxException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + if (existingClient != null && !sameCredentials) { + this.blobServiceClient + .setPageBlobStreamWriteSizeInBytes(existingClient.getPageBlobStreamWriteSizeInBytes()); + this.blobServiceClient.setSingleBlobPutThresholdInBytes(existingClient.getSingleBlobPutThresholdInBytes()); + this.blobServiceClient.setStreamMinimumReadSizeInBytes(existingClient.getStreamMinimumReadSizeInBytes()); + this.blobServiceClient.setWriteBlockSizeInBytes(existingClient.getWriteBlockSizeInBytes()); + this.blobServiceClient.setConcurrentRequestCount(existingClient.getConcurrentRequestCount()); + this.blobServiceClient.setDirectoryDelimiter(existingClient.getDirectoryDelimiter()); + this.blobServiceClient.setRetryPolicyFactory(existingClient.getRetryPolicyFactory()); + this.blobServiceClient.setTimeoutInMs(existingClient.getTimeoutInMs()); + } + } + + void updatePropertiesFromResponse(HttpURLConnection request) { + String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); + + // ETag + if (Utility.isNullOrEmpty(tempStr)) { + this.getProperties().setEtag(tempStr); + } + + // Last Modified + final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); + lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); + lastModifiedCalendar.setTime(new Date(request.getLastModified())); + this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + + // using this instead of the request property since the request + // property only returns an int. + tempStr = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + + if (!Utility.isNullOrEmpty(tempStr)) { + this.getProperties().setLength(Long.parseLong(tempStr)); + } + } + + /** + * Releases the lease on the blob. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is + * required to be set on the AccessCondition. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void releaseLease(final AccessCondition accessCondition) throws StorageException { + this.releaseLease(accessCondition, null, null); + } + + /** + * Releases the lease on the blob using the specified request options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob.The LeaseID is + * required to be set on the AccessCondition. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void releaseLease( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + Utility.assertNotNull("accessCondition", accessCondition); + Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.lease(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + LeaseAction.RELEASE, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Renews an existing lease. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is + * required to be set on the AccessCondition. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void renewLease(final AccessCondition accessCondition) throws StorageException { + this.renewLease(accessCondition, null, null); + } + + /** + * Renews an existing lease using the specified request options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is + * required to be set on the AccessCondition. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void renewLease( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + Utility.assertNotNull("accessCondition", accessCondition); + Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.lease(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + LeaseAction.RENEW, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Sets the container for the blob. + * + * @param container + * A {@link CloudBlobContainer} object that represents the container being assigned to the blob. + */ + protected final void setContainer(final CloudBlobContainer container) { + this.container = container; + } + + /** + * Sets the metadata for the blob. + * + * @param metadata + * A java.util.HashMap object that contains the metadata being assigned to the blob. + */ + public final void setMetadata(final HashMap metadata) { + this.metadata = metadata; + } + + /** + * Sets the properties for the blob. + * + * @param properties + * A {@link BlobProperties} object that represents the properties being assigned to the blob. + */ + protected final void setProperties(final BlobProperties properties) { + this.properties = properties; + } + + /** + * Sets the blob snapshot ID. + * + * @param snapshotID + * A String that represents the snapshot ID being assigned to the blob. + */ + public final void setSnapshotID(final String snapshotID) { + this.snapshotID = snapshotID; + } + + /** + * Attempts to break the lease and ensure that another client cannot acquire a new lease until the current lease + * period has expired. + * + * @return Time, in seconds, remaining in the lease period, or -1 if the lease is already broken. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final long tryBreakLease() throws StorageException { + return this.tryBreakLease(null, null, null); + } + + /** + * Attempts to breaks the lease using the specified request options and operation context, and ensure that another + * client cannot acquire a new lease until the current lease period has expired. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return Time, in seconds, remaining in the lease period, -1 if the lease is already broken. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final long tryBreakLease( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Long execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.lease(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + LeaseAction.BREAK, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = + StorageException.translateException(request, null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + } + + return -1L; + } + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return -1L; + } + + blob.updatePropertiesFromResponse(request); + final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + + return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Uploads the source stream data to the blob. + * + * @param sourceStream + * An InputStream object that represents the source stream to upload. + * + * @param length + * The length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a + * multiple of 512 for page blobs. + * + * @throws IOException + * If an I/O exception occurred. + * + * @throws StorageException + * If a storage service error occurred. + * + */ + @DoesServiceRequest + public abstract void upload(InputStream sourceStream, long length) throws StorageException, IOException; + + /** + * Uploads the source stream data to the blob using the specified lease ID, request options, and operation context. + * + * @param sourceStream + * An InputStream object that represents the source stream to upload. + * @param length + * The length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a + * multiple of 512 for page blobs. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public abstract void upload( + InputStream sourceStream, long length, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException, IOException; + + /** + * Uploads a blob in a single operation. + * + * @param sourceStream + * A InputStream object that represents the source stream to upload. + * @param length + * The length, in bytes, of the stream, or -1 if unknown. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + protected final void uploadFullBlob( + final InputStream sourceStream, final long length, final AccessCondition accessCondition, + final BlobRequestOptions options, final OperationContext opContext) throws StorageException, IOException { + // Mark sourceStream for current position. + sourceStream.mark(Integer.MAX_VALUE); + + if (length < 0) { + throw new IllegalArgumentException("Invalid stream length, specify a positive number of bytes"); + } + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.put(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.properties, + blob.properties.getBlobType(), + 0, + accessCondition, + blobOptions, + opContext); + + BlobRequest.addMetadata(request, blob.metadata, opContext); + + client.getCredentials().signRequest(request, length); + + final StreamDescriptor descriptor = + Utility.writeToOutputStream(sourceStream, + request.getOutputStream(), + length, + true, + false, + null, + opContext); + + if (length != descriptor.getLength()) { + throw new StorageException( + StorageErrorCodeStrings.INVALID_INPUT, + "An incorrect stream length was specified, resulting in an authentication failure. Please specify correct length, or -1.", + HttpURLConnection.HTTP_FORBIDDEN, null, null); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Uploads the blob's metadata to the storage service. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void uploadMetadata() throws StorageException { + this.uploadMetadata(null, null, null); + } + + /** + * Uploads the blob's metadata to the storage service using the specified lease ID, request options, and operation + * context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void uploadMetadata( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.setMetadata(blob.getTransformedAddress(opContext), this.getRequestOptions() + .getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + + BlobRequest.addMetadata(request, blob.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Updates the blob's properties to the storage service. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void uploadProperties() throws StorageException { + this.uploadProperties(null, null, null); + } + + /** + * Updates the blob's properties using the specified lease ID, request options, and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public final void uploadProperties( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.setProperties(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.properties, + null, + accessCondition, + blobOptions, + opContext); + + BlobRequest.addMetadata(request, blob.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java new file mode 100644 index 0000000000000..f49ca4bcf1ed3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -0,0 +1,705 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RequestOptions; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; +import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; +import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.ServiceClient; +import com.microsoft.windowsazure.services.core.storage.StorageCredentials; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAnonymous; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Provides a client for accessing the Windows Azure Blob service. + *

+ * This class provides a point of access to the Blob service. The service client encapsulates the base URI for the Blob + * service. If the service client will be used for authenticated access, it also encapsulates the credentials for + * accessing the storage account. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudBlobClient extends ServiceClient { + /** + * Holds the maximum size of a blob in bytes that may be uploaded as a single blob. + */ + private int singleBlobPutThresholdInBytes = BlobConstants.DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES; + + /** + * Holds the maximum block size for writing to a block blob. + */ + private int writeBlockSizeInBytes = BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES; + + /** + * Holds the number of bytes a BlobStream will write at once for a page blob. + */ + private int pageBlobStreamWriteSizeInBytes = BlobConstants.DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES; + + /** + * Holds the minimum read size when using a BlobReadStream. + */ + private int streamMinimumReadSizeInBytes = BlobConstants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES; + + /** + * Holds the number of simultaneous operations a given blob operation may perform. + */ + private int concurrentRequestCount = BlobConstants.DEFAULT_CONCURRENT_REQUEST_COUNT; + + /** + * Holds the default delimiter that may be used to create a virtual directory structure of blobs. + */ + private String directoryDelimiter = BlobConstants.DEFAULT_DELIMITER; + + /** + * Creates an instance of the CloudBlobClient class using the specified Blob service endpoint. + * + * @param baseUri + * A java.net.URI object that represents the Blob service endpoint used to create the + * client. + */ + public CloudBlobClient(final URI baseUri) { + this(baseUri, null); + } + + /** + * Creates an instance of the CloudBlobClient class using the specified Blob service endpoint and + * account credentials. + * + * @param baseUri + * A java.net.URI object that represents the Blob service endpoint used to create the + * client. + * @param credentials + * A {@link StorageCredentials} object that represents the account credentials. + */ + public CloudBlobClient(final URI baseUri, StorageCredentials credentials) { + super(baseUri, credentials); + + if (credentials == null) { + credentials = StorageCredentialsAnonymous.ANONYMOUS; + } + + this.directoryDelimiter = BlobConstants.DEFAULT_DELIMITER; + this.streamMinimumReadSizeInBytes = BlobConstants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES; + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) + throws URISyntaxException, StorageException { + return this.getBlockBlobReference(blobAddressUri, null); + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container, using the + * specified snapshot ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) + throws StorageException, URISyntaxException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI completeUri = PathUtility.appendPathToUri(this.endpoint, blobAddressUri); + + return new CloudBlockBlob(completeUri, snapshotID, this); + } + + /** + * Returns the number of maximum concurrent requests allowed. + * + * @return The number of maximum concurrent requests allowed. + */ + public int getConcurrentRequestCount() { + return this.concurrentRequestCount; + } + + /** + * Returns a reference to a {@link CloudBlobContainer} object that represents the cloud blob container for the + * specified address. + * + * @param containerAddress + * A String that represents the name of the container, or the absolute URI to the container. + * @return A {@link CloudBlobContainer} object that represents a reference to the cloud blob container. + * + * @throws URISyntaxException + * If the resource URI is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public CloudBlobContainer getContainerReference(final String containerAddress) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("containerAddress", containerAddress); + return new CloudBlobContainer(containerAddress, this); + } + + /** + * Returns the value for the default delimiter used for cloud blob directories. The default is '/'. + * + * @return The value for the default delimiter. + */ + public String getDirectoryDelimiter() { + return this.directoryDelimiter; + } + + /** + * Returns a reference to the specified virtual blob directory. + *

+ * A blob directory simplifies working with a hierarchical organization of blobs. A blob directory is a blob name + * prefix that can be used to navigate a hierarchy. The prefix may end in a delimiter character, but a delimiter is + * not required; the directory can end in any character. + * + * @param relativeAddress + * A String that represents the name of the virtual blob directory, or the absolute URI to + * the virtual blob directory. + * + * @return A {@link CloudBlobDirectory} object that represents the specified virtual blob directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobDirectory getDirectoryReference(final String relativeAddress) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); + + return new CloudBlobDirectory(relativeAddress, this); + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { + return this.getPageBlobReference(blobAddressUri, null); + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob, using the specified snapshot + * ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI completeUri = PathUtility.appendPathToUri(this.endpoint, blobAddressUri); + + return new CloudPageBlob(completeUri, snapshotID, this); + } + + /** + * Returns the write page size in use for this Blob service client. + * + * @return The maximum block size, in bytes, for writing to a page blob. + */ + public int getPageBlobStreamWriteSizeInBytes() { + return this.pageBlobStreamWriteSizeInBytes; + } + + /** + * Returns the threshold size used for writing a single blob for this Blob service client. + * + * @return The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 to 64 MB + * inclusive. The default value is 32 MBs. + *

+ * If a blob size is above the threshold, it will be uploaded as blocks. + */ + public int getSingleBlobPutThresholdInBytes() { + return this.singleBlobPutThresholdInBytes; + } + + /** + * Returns the minimum read size in use for this Blob service client. + * + * @return The minimum read size, in bytes, when using a {@link BlobInputStream} object. + */ + public int getStreamMinimumReadSizeInBytes() { + return this.streamMinimumReadSizeInBytes; + } + + /** + * Returns the write block size in use for this Blob service client. + * + * @return The maximum block size, in bytes, for writing to a block blob while using a {@link BlobOutputStream} + * object. + */ + public int getWriteBlockSizeInBytes() { + return this.writeBlockSizeInBytes; + } + + /** + * Returns an enumerable collection of blob containers for this Blob service client. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for this + * client. + */ + @DoesServiceRequest + public Iterable listContainers() { + return this.listContainersWithPrefix(null, ContainerListingDetails.NONE, null, null); + } + + /** + * Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob + * service client. + * + * @param prefix + * A String that represents the container name prefix. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for this + * client whose names begin with the specified prefix. + */ + @DoesServiceRequest + public Iterable listContainers(final String prefix) { + return this.listContainersWithPrefix(prefix, ContainerListingDetails.NONE, null, null); + } + + /** + * Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob + * service client, using the specified details setting, request options, and operation context. + * + * @param prefix + * A String that represents the container name prefix. + * @param detailsIncluded + * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represents the containers for this + * client. + */ + @DoesServiceRequest + public Iterable listContainers( + final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, + final OperationContext opContext) { + return this.listContainersWithPrefix(prefix, detailsIncluded, options, opContext); + } + + /** + * Returns a result segment containing a collection of containers whose names begin with the specified prefix. + * + * @param prefix + * A String that represents the container name prefix. + * @param detailsIncluded + * A value that indicates whether to return container metadata with the listing. + * @param maxResults + * the maximum results to retrieve. + * @param continuationToken + * A continuation token returned by a previous listing operation. + * @param options + * the request options to use for the operation + * @param taskReference + * a reference to the encapsulating task + * @param opContext + * a tracking object for the operation + * @return a result segment containing a collection of containers whose names begin with the specified prefix. + * @throws IOException + * @throws URISyntaxException + * @throws XMLStreamException + * @throws InvalidKeyException + * @throws StorageException + */ + @DoesServiceRequest + ResultSegment listContainersCore( + final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, final RequestOptions options, + final StorageOperation> taskReference, + final OperationContext opContext) + throws IOException, URISyntaxException, XMLStreamException, InvalidKeyException, StorageException { + + Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); + + final ListingContext listingContext = new ListingContext(prefix, maxResults); + listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); + + final HttpURLConnection listContainerRequest = + ContainerRequest.list(this.getEndpoint(), + options.getTimeoutIntervalInMs(), + listingContext, + detailsIncluded, + opContext); + + this.getCredentials().signRequest(listContainerRequest, -1L); + + taskReference.setResult(ExecutionEngine.processRequest(listContainerRequest, opContext)); + + if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + taskReference.setNonExceptionedRetryableFailure(true); + return null; + } + + final ListContainersResponse response = new ListContainersResponse(listContainerRequest.getInputStream()); + response.parseResponse(this); + + ResultContinuation newToken = null; + + if (response.getNextMarker() != null) { + newToken = new ResultContinuation(); + newToken.setNextMarker(response.getNextMarker()); + newToken.setContinuationType(ResultContinuationType.CONTAINER); + } + + final ResultSegment resSegment = + new ResultSegment(response.getContainers(this), maxResults, newToken); + + return resSegment; + } + + /** + * Returns a result segment of an enumerable collection of blob containers for this Blob service client. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers in this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented() throws StorageException { + return this.listContainersSegmented(null, ContainerListingDetails.NONE, 0, null, null, null); + } + + /** + * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified + * prefix for this Blob service client. + * + * @param prefix + * A String that represents the prefix of the container name. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified + * prefix. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented(final String prefix) throws StorageException { + return this.listContainersWithPrefixSegmented(prefix, null, 0, null, null, null); + } + + /** + * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified + * prefix for this container, using the specified listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the container name. + * @param detailsIncluded + * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers in this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented( + final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, final BlobRequestOptions options, + final OperationContext opContext) throws StorageException { + + return this.listContainersWithPrefixSegmented(prefix, + detailsIncluded, + maxResults, + continuationToken, + options, + opContext); + } + + /** + * Returns an enumerable collection of blob containers whose names begin with the specified prefix, using the + * specified details setting, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the container name. + * @param detailsIncluded + * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers whose names + * begin with the specified prefix. + */ + @DoesServiceRequest + protected Iterable listContainersWithPrefix( + final String prefix, final ContainerListingDetails detailsIncluded, BlobRequestOptions options, + OperationContext opContext) { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this); + + final SegmentedStorageOperation> impl = + new SegmentedStorageOperation>(options, null) { + @Override + public ResultSegment execute( + final CloudBlobClient client, final Void dontCare, final OperationContext opContext) + throws Exception { + + final ResultSegment result = + CloudBlobClient.this.listContainersCore(prefix, + detailsIncluded, + -1, + this.getToken(), + this.getRequestOptions(), + this, + opContext); + + // Note, setting the token on the SegmentedStorageOperation is + // key, this is how the iterator + // will share the token across executions + this.setToken(result.getContinuationToken()); + return result; + } + }; + + return new LazySegmentedIterator(impl, this, null, + options.getRetryPolicyFactory(), opContext); + } + + /** + * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified + * prefix for this container, using the specified listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the container name. + * @param detailsIncluded + * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers in this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + protected ResultSegment listContainersWithPrefixSegmented( + final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this); + + Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); + + final StorageOperation> impl = + new StorageOperation>(options) { + @Override + public ResultSegment execute( + final CloudBlobClient client, final Void dontCare, final OperationContext opContext) + throws Exception { + return CloudBlobClient.this.listContainersCore(prefix, + detailsIncluded, + maxResults, + continuationToken, + this.getRequestOptions(), + this, + opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Sets the maximum number of concurrent requests allowed for the Blob service client. + * + * @param concurrentRequestCount + * The value being assigned as the maximum number of concurrent requests allowed for the Blob service + * client. + */ + public void setConcurrentRequestCount(final int concurrentRequestCount) { + this.concurrentRequestCount = concurrentRequestCount; + } + + /** + * Sets the value for the default delimiter used for cloud blob directories. + * + * @param directoryDelimiter + * A String that represents the value for the default directory delimiter. + */ + public void setDirectoryDelimiter(final String directoryDelimiter) { + this.directoryDelimiter = directoryDelimiter; + } + + /** + * Sets the write page size in use for this Blob Service client. + * + * @param pageBlobStreamWriteSizeInBytes + * The maximum block size, in bytes, for writing to a page blob. This value must be a multiple of 512 and + * less than or equal to 4 MB. + */ + public void setPageBlobStreamWriteSizeInBytes(final int pageBlobStreamWriteSizeInBytes) { + if (pageBlobStreamWriteSizeInBytes > BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES + || pageBlobStreamWriteSizeInBytes < BlobConstants.PAGE_SIZE + || pageBlobStreamWriteSizeInBytes % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("PageBlobStreamWriteSizeInBytes"); + } + + this.pageBlobStreamWriteSizeInBytes = pageBlobStreamWriteSizeInBytes; + } + + /** + * Sets the threshold size used for writing a single blob to use with this Blob service client. + * + * @param singleBlobPutThresholdInBytes + * The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 MB to 64 + * MB inclusive. If a blob size is above the threshold, it will be uploaded as blocks. + * + * @throws IllegalArgumentException + * If minimumReadSize is less than 1 MB or greater than 64 MB. + */ + public void setSingleBlobPutThresholdInBytes(final int singleBlobPutThresholdInBytes) { + if (singleBlobPutThresholdInBytes > BlobConstants.MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES + || singleBlobPutThresholdInBytes < 1 * Constants.MB) { + throw new IllegalArgumentException("SingleBlobUploadThresholdInBytes"); + } + + this.singleBlobPutThresholdInBytes = singleBlobPutThresholdInBytes; + } + + /** + * Sets the minimum read block size to use with this Blob service client. + * + * @param minimumReadSize + * The maximum block size, in bytes, for reading from a block blob while using a {@link BlobInputStream} + * object, ranging from 512 bytes to 64 MB, inclusive. + */ + public void setStreamMinimumReadSizeInBytes(final int minimumReadSize) { + if (minimumReadSize > 64 * Constants.MB || minimumReadSize < BlobConstants.PAGE_SIZE) { + throw new IllegalArgumentException("MinimumReadSize"); + } + + this.streamMinimumReadSizeInBytes = minimumReadSize; + } + + /** + * Sets the write block size to use with this Blob service client. + * + * @param writeBlockSizeInBytes + * The maximum block size, in bytes, for writing to a block blob while using a {@link BlobOutputStream} + * object, ranging from 1 MB to 4 MB, inclusive. + * + * @throws IllegalArgumentException + * If writeBlockSizeInBytes is less than 1 MB or greater than 4 MB. + */ + public void setWriteBlockSizeInBytes(final int writeBlockSizeInBytes) { + if (writeBlockSizeInBytes > BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES + || writeBlockSizeInBytes < 1 * Constants.MB) { + throw new IllegalArgumentException("WriteBlockSizeInBytes"); + } + + this.writeBlockSizeInBytes = writeBlockSizeInBytes; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java new file mode 100644 index 0000000000000..83071b7b749b8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -0,0 +1,1895 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.Calendar; +import java.util.Date; +import java.util.EnumSet; +import java.util.HashMap; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; +import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; +import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Represents a container in the Windows Azure Blob service. + *

+ * Containers hold directories, which are encapsulated as {@link CloudBlobDirectory} objects, and directories hold block + * blobs and page blobs. Directories can also contain sub-directories. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudBlobContainer { + + /** + * Converts the ACL string to a BlobContainerPermissions object. + * + * @param aclString + * the string to convert. + * @return The resulting BlobContainerPermissions object. + */ + static BlobContainerPermissions getContainerAcl(final String aclString) { + BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.OFF; + + if (!Utility.isNullOrEmpty(aclString)) { + final String lowerAclString = aclString.toLowerCase(); + if ("container".equals(lowerAclString)) { + accessType = BlobContainerPublicAccessType.CONTAINER; + } else if ("blob".equals(lowerAclString)) { + accessType = BlobContainerPublicAccessType.BLOB; + } else { + throw new IllegalArgumentException( + String.format("Invalid acl public access type returned '%s'. Expected blob or container.", + aclString)); + } + } + + final BlobContainerPermissions retVal = new BlobContainerPermissions(); + retVal.setPublicAccess(accessType); + + return retVal; + } + + /** + * Represents the container metadata. + */ + protected HashMap metadata; + + /** + * Holds the container properties. + */ + BlobContainerProperties properties; + + /** + * Holds the name of the container. + */ + String name; + + /** + * Holds the URI of the container. + */ + URI uri; + + /** + * Holds a reference to the associated service client. + */ + private CloudBlobClient blobServiceClient; + + /** + * Initializes a new instance of the CloudBlobContainer class. + * + * @param client + * the reference to the associated service client. + */ + private CloudBlobContainer(final CloudBlobClient client) { + this.metadata = new HashMap(); + this.properties = new BlobContainerProperties(); + this.blobServiceClient = client; + } + + /** + * Creates an instance of the CloudBlobContainer class using the specified address and client. + * + * @param containerAddress + * A String that represents either the absolute URI to the container, or the container name. + * @param client + * A {@link CloudBlobClient} object that represents the associated service client, and that specifies the + * endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobContainer(final String containerAddress, final CloudBlobClient client) throws URISyntaxException, + StorageException { + this(client); + + final URI resURI = PathUtility.appendPathToUri(client.getEndpoint(), containerAddress); + + this.uri = resURI; + this.name = PathUtility.getContainerNameFromUri(resURI, client.isUsePathStyleUris()); + + this.parseQueryAndVerify(this.uri, client, client.isUsePathStyleUris()); + } + + /** + * Creates an instance of the CloudBlobContainer class using the specified URI and client. + * + * @param uri + * A java.net.URI object that represents the URI of the container. + * @param client + * A {@link CloudBlobClient} object that represents the associated service client, and that specifies the + * endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobContainer(final URI uri, final CloudBlobClient client) throws URISyntaxException, StorageException { + this(client); + + this.uri = uri; + this.name = PathUtility.getContainerNameFromUri(uri, client.isUsePathStyleUris()); + + this.parseQueryAndVerify(this.uri, client, client.isUsePathStyleUris()); + } + + /** + * Creates the container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void create() throws StorageException { + this.create(null, null); + } + + /** + * Creates the container using the specified options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void create(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = + ContainerRequest.create(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + // Set attributes + final BlobContainerAttributes attributes = + ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); + container.setMetadata(attributes.getMetadata()); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Creates the container if it does not exist. + * + * @return true if the container did not already exist and was created; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean createIfNotExist() throws StorageException { + return this.createIfNotExist(null, null); + } + + /** + * Creates the container if it does not exist, using the specified request options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the container did not already exist and was created; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean createIfNotExist(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Boolean execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = + ContainerRequest.create(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + // Validate response code here + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + // Set attributes + final BlobContainerAttributes attributes = + ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); + container.metadata = attributes.getMetadata(); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = + StorageException.translateException(request, null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + + // return false instead of null to avoid SCA issues + return false; + } + + return false; + } else { + throw StorageException.translateException(request, null, opContext); + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Deletes the container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void delete() throws StorageException { + this.delete(null, null); + } + + /** + * Deletes the container using the specified request options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void delete(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final HttpURLConnection request = + ContainerRequest.delete(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + + } + + /** + * Deletes the container if it exists. + * + * @return true if the container did not already exist and was created; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean deleteIfExists() throws StorageException { + return this.deleteIfExists(null, null); + } + + /** + * Deletes the container if it exists using the specified request options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the container did not already exist and was created; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean deleteIfExists(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final HttpURLConnection request = + ContainerRequest.delete(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { + container.updatePropertiesFromResponse(request); + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Downloads the container's attributes, which consist of metadata and properties. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void downloadAttributes() throws StorageException { + this.downloadAttributes(null, null); + } + + /** + * Downloads the container's attributes, which consist of metadata and properties, using the specified request + * options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void downloadAttributes(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = + ContainerRequest.getProperties(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + // Set attributes + final BlobContainerAttributes attributes = + ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); + container.metadata = attributes.getMetadata(); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Downloads the permission settings for the container. + * + * @return A {@link BlobContainerPermissions} object that represents the container's permissions. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public BlobContainerPermissions downloadPermissions() throws StorageException { + return this.downloadPermissions(null, null); + } + + /** + * Downloads the permissions settings for the container using the specified request options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link BlobContainerPermissions} object that represents the container's permissions. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public BlobContainerPermissions downloadPermissions(BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public BlobContainerPermissions execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final HttpURLConnection request = + ContainerRequest.getAcl(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } + + container.updatePropertiesFromResponse(request); + final String aclString = ContainerResponse.getAcl(request); + final BlobContainerPermissions containerAcl = getContainerAcl(aclString); + + final AccessPolicyResponse response = new AccessPolicyResponse(request.getInputStream()); + + for (final String key : response.getAccessIdentifiers().keySet()) { + containerAcl.getSharedAccessPolicies().put(key, response.getAccessIdentifiers().get(key)); + } + + return containerAcl; + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Returns a value that indicates whether the container exists. + * + * @return true if the container exists, otherwise false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public boolean exists() throws StorageException { + return this.exists(null, null); + } + + /** + * Returns a value that indicates whether the container exists, using the specified request options and operation + * context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the container exists, otherwise false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public boolean exists(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = + ContainerRequest.getProperties(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + container.updatePropertiesFromResponse(request); + return Boolean.valueOf(true); + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Returns a shared access signature for the blob using the specified shared access policy. Note this does not + * contain the leading "?". + *

+ * A shared access signature is a token that provides delegated access to blob resources. You can provide this token + * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared + * access signature created for a blob grants access just to the content and metadata of that blob. A shared access + * signature created for a container grants access to the content and metadata of any blob in the container, and to + * the list of blobs in the container. + *

+ * The parameters of the shared access signature that govern access are: + *

    + *
  • The start time at which the signature becomes valid.
  • + *
  • The time at which it expires.
  • + *
  • The permissions that it grants.
  • + *
+ * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There + * are two ways to specify an access policy: + *
    + *
  • + * You can specify it on a single shared access signature. In this case, the interval over which the signature may + * be valid is limited to one hour.
  • + *
  • + * You can specify it by creating a container-level access policy, which can be associated with one or more shared + * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if + * it should be compromised. To specify that the access policy should be used by the signature, call an overload + * that includes the groupPolicyIdentifier parameter.
  • + *
+ * You can also specify some parameters of the access policy on the signature and some on a container-level access + * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides + * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For + * details on container-level access policies, see Specifying a Container-Level Access Policy. + * + * @param policy + * A SharedAccessPolicy object that represents the access policy for the shared access + * signature. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are invalid or the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public String generateSharedAccessSignature(final SharedAccessPolicy policy) + throws InvalidKeyException, StorageException { + return this.generateSharedAccessSignature(policy, null); + } + + /** + * Returns a shared access signature for the blob using the shared access policy and operation context. Note this + * does not contain the leading "?". + *

+ * A shared access signature is a token that provides delegated access to blob resources. You can provide this token + * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared + * access signature created for a blob grants access just to the content and metadata of that blob. A shared access + * signature created for a container grants access to the content and metadata of any blob in the container, and to + * the list of blobs in the container. + *

+ * The parameters of the shared access signature that govern access are: + *

    + *
  • The start time at which the signature becomes valid.
  • + *
  • The time at which it expires.
  • + *
  • The permissions that it grants.
  • + *
+ * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There + * are two ways to specify an access policy: + *
    + *
  • + * You can specify it on a single shared access signature. In this case, the interval over which the signature may + * be valid is limited to one hour.
  • + *
  • + * You can specify it by creating a container-level access policy, which can be associated with one or more shared + * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if + * it should be compromised. To specify that the access policy should be used by the signature, call an overload + * that includes the groupPolicyIdentifier parameter.
  • + *
+ * You can also specify some parameters of the access policy on the signature and some on a container-level access + * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides + * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For + * details on container-level access policies, see Specifying a Container-Level Access Policy. + * + * @param policy + * A SharedAccessPolicy object that represents the access policy for the shared access + * signature. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are invalid or the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public String generateSharedAccessSignature(final SharedAccessPolicy policy, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + return this.generateSharedAccessSignatureCore(policy, null, opContext); + } + + /** + * Returns a shared access signature for the blob using the specified group policy identifier. Note this does not + * contain the leading "?". + *

+ * A shared access signature is a token that provides delegated access to blob resources. You can provide this token + * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared + * access signature created for a blob grants access just to the content and metadata of that blob. A shared access + * signature created for a container grants access to the content and metadata of any blob in the container, and to + * the list of blobs in the container. + *

+ * The parameters of the shared access signature that govern access are: + *

    + *
  • The start time at which the signature becomes valid.
  • + *
  • The time at which it expires.
  • + *
  • The permissions that it grants.
  • + *
+ * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There + * are two ways to specify an access policy: + *
    + *
  • + * You can specify it on a single shared access signature. In this case, the interval over which the signature may + * be valid is limited to one hour.
  • + *
  • + * You can specify it by creating a container-level access policy, which can be associated with one or more shared + * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if + * it should be compromised. To specify that the access policy should be used by the signature, call an overload + * that includes the groupPolicyIdentifier parameter.
  • + *
+ * You can also specify some parameters of the access policy on the signature and some on a container-level access + * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides + * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For + * details on container-level access policies, see Specifying a Container-Level Access Policy. + * + * @param groupPolicyIdentifier + * A String that represents the container-level access policy. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are invalid or the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public String generateSharedAccessSignature(final String groupPolicyIdentifier) + throws InvalidKeyException, StorageException { + return this.generateSharedAccessSignature(groupPolicyIdentifier, null); + } + + /** + * Returns a shared access signature for the blob using the specified group policy identifier and operation context. + * Note this does not contain the leading "?". + *

+ * A shared access signature is a token that provides delegated access to blob resources. You can provide this token + * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared + * access signature created for a blob grants access just to the content and metadata of that blob. A shared access + * signature created for a container grants access to the content and metadata of any blob in the container, and to + * the list of blobs in the container. + *

+ * The parameters of the shared access signature that govern access are: + *

    + *
  • The start time at which the signature becomes valid.
  • + *
  • The time at which it expires.
  • + *
  • The permissions that it grants.
  • + *
+ * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There + * are two ways to specify an access policy: + *
    + *
  • + * You can specify it on a single shared access signature. In this case, the interval over which the signature may + * be valid is limited to one hour.
  • + *
  • + * You can specify it by creating a container-level access policy, which can be associated with one or more shared + * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if + * it should be compromised. To specify that the access policy should be used by the signature, call an overload + * that includes the groupPolicyIdentifier parameter.
  • + *
+ * You can also specify some parameters of the access policy on the signature and some on a container-level access + * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides + * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For + * details on container-level access policies, see Specifying a Container-Level Access Policy. + * + * @param groupPolicyIdentifier + * A String that represents the container-level access policy. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that represents the shared access signature. + * + * @throws IllegalArgumentException + * If the credentials are invalid or the blob is a snapshot. + * @throws InvalidKeyException + * If the credentials are invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public String generateSharedAccessSignature(final String groupPolicyIdentifier, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + return this.generateSharedAccessSignatureCore(null, groupPolicyIdentifier, opContext); + } + + /** + * Returns a shared access signature for the container. Note this does not contain the leading "?". + * + * @param policy + * The access policy for the shared access signature. + * @param groupPolicyIdentifier + * A container-level access policy. + * @return a shared access signature for the container. + * @throws InvalidKeyException + * @throws StorageException + * @throws IllegalArgumentException + */ + private String generateSharedAccessSignatureCore( + final SharedAccessPolicy policy, final String groupPolicyIdentifier, OperationContext opContext) + throws InvalidKeyException, StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (!this.blobServiceClient.getCredentials().canCredentialsSignRequest()) { + final String errorMessage = + "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."; + throw new IllegalArgumentException(errorMessage); + } + + final String resourceName = this.getSharedAccessCanonicalName(); + + final String signature = + SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, + groupPolicyIdentifier, + resourceName, + this.blobServiceClient, + opContext); + + final UriQueryBuilder builder = + SharedAccessSignatureHelper + .generateSharedAccessSignature(policy, groupPolicyIdentifier, "c", signature); + + return builder.toString(); + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); + + return new CloudBlockBlob(address, this.blobServiceClient, this); + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container, using the + * specified snapshot ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); + + final CloudBlockBlob retBlob = new CloudBlockBlob(address, snapshotID, this.blobServiceClient); + retBlob.setContainer(this); + return retBlob; + } + + /** + * Returns a reference to a {@link CloudBlobDirectory} object that represents a virtual blob directory within this + * container. + * + * @param relativeAddress + * A String that represents the name of the virtual blob directory, or the absolute URI to + * the virtual blob directory. + * + * @return A {@link CloudBlobDirectory} that represents a virtual blob directory within this container. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobDirectory getDirectoryReference(final String relativeAddress) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); + final URI address = PathUtility.appendPathToUri(this.uri, relativeAddress); + + return new CloudBlobDirectory(address, null, this.blobServiceClient); + } + + /** + * Returns the metadata for the container. + * + * @return A java.util.HashMap object that represents the metadata for the container. + */ + public HashMap getMetadata() { + return this.metadata; + } + + /** + * Returns the name of the container. + * + * @return A String that represents the name of the container. + */ + public String getName() { + return this.name; + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in this container. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); + + return new CloudPageBlob(address, this.blobServiceClient, this); + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the + * specified snapshot ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); + + final CloudPageBlob retBlob = new CloudPageBlob(address, snapshotID, this.blobServiceClient); + retBlob.setContainer(this); + return retBlob; + } + + /** + * Returns the properties for the container. + * + * @return A {@link BlobContainerProperties} object that represents the properties for the container. + */ + public BlobContainerProperties getProperties() { + return this.properties; + } + + /** + * Returns the Blob service client associated with this container. + * + * @return A {@link CloudBlobClient} object that represents the service client associated with this container. + */ + public CloudBlobClient getServiceClient() { + return this.blobServiceClient; + } + + /** + * Returns the canonical name for shared access. + * + * @return the canonical name for shared access. + */ + private String getSharedAccessCanonicalName() { + if (this.blobServiceClient.isUsePathStyleUris()) { + return this.getUri().getPath(); + } else { + return PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this.getUri() + .getPath()); + } + } + + /** + * Returns the URI after applying the authentication transformation. + * + * @return A java.net.URI object that represents the URI after applying the authentication + * transformation. + * + * @throws IllegalArgumentException + * If an unexpected value is passed. + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + protected URI getTransformedAddress() throws URISyntaxException, StorageException { + if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { + if (this.uri.isAbsolute()) { + return this.blobServiceClient.getCredentials().transformUri(this.uri); + } else { + final StorageException ex = Utility.generateNewUnexpectedStorageException(null); + ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); + throw ex; + } + } else { + return this.uri; + } + } + + /** + * Returns the URI for this container. + * + * @return The absolute URI to the container. + */ + public URI getUri() { + return this.uri; + } + + /** + * Returns an enumerable collection of blob items for the container. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represents the items in this container. + */ + @DoesServiceRequest + public Iterable listBlobs() { + return this.listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null); + } + + /** + * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix. + * + * @param prefix + * A String that represents the blob name prefix. This value must be preceded either by the + * name of the container or by the absolute path to the container. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represents the items whose names begin with + * the specified prefix in this container. + */ + @DoesServiceRequest + public Iterable listBlobs(final String prefix) { + return this.listBlobs(prefix, false, EnumSet.noneOf(BlobListingDetails.class), null, null); + } + + /** + * Returns an enumerable collection of blob items whose names begin with the specified prefix, using the specified + * flat or hierarchical option, listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the blob name prefix. This value must be preceded either by the + * name of the container or by the absolute path to the container. + * @param useFlatBlobListing + * true to indicate that the returned list will be flat; false to indicate that + * the returned list will be hierarchical. + * @param listingDetails + * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate + * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always + * returned. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin + * with the specified prefix in this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public Iterable listBlobs( + final String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, + BlobRequestOptions options, OperationContext opContext) { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + if (!useFlatBlobListing && listingDetails != null && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { + throw new IllegalArgumentException( + "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); + } + + final SegmentedStorageOperation> impl = + new SegmentedStorageOperation>( + options, null) { + + @Override + public ResultSegment execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final ResultSegment result = + CloudBlobContainer.this.listBlobsCore(prefix, + useFlatBlobListing, + listingDetails, + -1, + this.getToken(), + (BlobRequestOptions) this.getRequestOptions(), + this, + opContext); + + // Note, setting the token on the SegmentedStorageOperation is + // key, this is how the iterator + // will share the token across executions + if (result != null) { + this.setToken(result.getContinuationToken()); + } + return result; + } + }; + + return new LazySegmentedIterator(impl, + this.blobServiceClient, this, options.getRetryPolicyFactory(), opContext); + } + + /** + * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. + * + * @param prefix + * The blob name prefix. This value must be preceded either by the name of the container or by the + * absolute path to the container. + * @param useFlatBlobListing + * a value indicating whether the blob listing operation will list all blobs in a container in a flat + * listing, or whether it will list blobs hierarchically, by virtual directory. + * @param listingDetails + * a EnumSet BlobListingDetails that indicates what items a listing operation will return. + * @param maxResults + * the maximum results to retrieve. + * @param continuationToken + * A continuation token returned by a previous listing operation. + * @param options + * An object that specifies any additional options for the request + * @param taskReference + * a reference to the encapsulating task + * @param opContext + * a tracking object for the operation + * @return a result segment containing a collection of blob items whose names begin with the specified + * @throws IllegalArgumentException + * @throws URISyntaxException + * @throws IOException + * @throws StorageException + * @throws InvalidKeyException + * @throws XMLStreamException + */ + @DoesServiceRequest + ResultSegment listBlobsCore( + final String prefix, final boolean useFlatBlobListing, EnumSet listingDetails, + final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, + final StorageOperation> taskReference, + final OperationContext opContext) + throws URISyntaxException, IOException, StorageException, InvalidKeyException, XMLStreamException { + Utility.assertContinuationType(continuationToken, ResultContinuationType.BLOB); + Utility.assertNotNull("options", options); + + if (listingDetails == null) { + listingDetails = EnumSet.noneOf(BlobListingDetails.class); + } + + if (!useFlatBlobListing && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { + throw new IllegalArgumentException( + "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); + } + + final String delimiter = useFlatBlobListing ? null : this.blobServiceClient.getDirectoryDelimiter(); + + final BlobListingContext listingContext = new BlobListingContext(prefix, maxResults, delimiter, listingDetails); + listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); + + final HttpURLConnection listBlobsRequest = + BlobRequest.list(this.getTransformedAddress(), + options.getTimeoutIntervalInMs(), + listingContext, + options, + opContext); + + this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); + + taskReference.setResult(ExecutionEngine.processRequest(listBlobsRequest, opContext)); + + if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + taskReference.setNonExceptionedRetryableFailure(true); + return null; + } + + final ListBlobsResponse response = new ListBlobsResponse(listBlobsRequest.getInputStream()); + response.parseResponse(this.blobServiceClient, this); + + ResultContinuation newToken = null; + + if (response.getNextMarker() != null) { + newToken = new ResultContinuation(); + newToken.setNextMarker(response.getNextMarker()); + newToken.setContinuationType(ResultContinuationType.BLOB); + } + + final ResultSegment resSegment = + new ResultSegment(response.getBlobs(this.blobServiceClient, this), maxResults, newToken); + + return resSegment; + } + + /** + * Returns a result segment of an enumerable collection of blob items in the container. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the blob items in the container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented() throws StorageException { + return this.listBlobsSegmented(null, false, EnumSet.noneOf(BlobListingDetails.class), -1, null, null, null); + } + + /** + * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. + * + * @param prefix + * A String that represents the prefix of the blob name. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the blob items whose names begin with the specified prefix in + * the container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented(final String prefix) throws StorageException { + return this.listBlobsSegmented(prefix, false, EnumSet.noneOf(BlobListingDetails.class), -1, null, null, null); + } + + /** + * Returns a result segment containing a collection of blob items whose names begin with the specified prefix, using + * the specified flat or hierarchical option, listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the blob name. + * @param useFlatBlobListing + * true to indicate that the returned list will be flat; false to indicate that + * the returned list will be hierarchical. + * @param listingDetails + * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate + * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always + * returned. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the block items whose names begin with the specified prefix + * in the container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented( + final String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, + final int maxResults, final ResultContinuation continuationToken, BlobRequestOptions options, + OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + Utility.assertContinuationType(continuationToken, ResultContinuationType.BLOB); + + if (!useFlatBlobListing && listingDetails != null && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { + throw new IllegalArgumentException( + "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); + } + + final StorageOperation> impl = + new StorageOperation>(options) { + + @Override + public ResultSegment execute( + final CloudBlobClient client, final CloudBlobContainer parent, + final OperationContext opContext) throws Exception { + + return CloudBlobContainer.this.listBlobsCore(prefix, + useFlatBlobListing, + listingDetails, + maxResults, + continuationToken, + (BlobRequestOptions) this.getRequestOptions(), + this, + opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Returns an enumerable collection of containers for the service client associated with this container. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for the + * service client associated with this container. + */ + @DoesServiceRequest + public Iterable listContainers() { + return this.blobServiceClient.listContainers(); + } + + /** + * Returns an enumerable collection of containers whose names begin with the specified prefix for the service client + * associated with this container. + * + * @param prefix + * A String that represents the container name prefix. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers whose names + * begin with the specified prefix for the service client associated with this container. + */ + @DoesServiceRequest + public Iterable listContainers(final String prefix) { + return this.blobServiceClient.listContainers(prefix); + } + + /** + * Returns an enumerable collection of containers whose names begin with the specified prefix for the service client + * associated with this container, using the specified details setting, request options, and operation context. + * + * @param prefix + * A String that represents the container name prefix. + * @param detailsIncluded + * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudBlobContainer} objects that represents the containers for the + * service client associated with this container. + */ + @DoesServiceRequest + public Iterable listContainers( + final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, + final OperationContext opContext) { + return this.blobServiceClient.listContainers(prefix, detailsIncluded, options, opContext); + } + + /** + * Returns a result segment of an enumerable collection of containers for the service client associated with this + * container. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers for the service client associated with + * this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented() throws StorageException { + return this.blobServiceClient.listContainersSegmented(); + } + + /** + * Returns a result segment of an enumerable collection of containers whose names begin with the specified prefix + * for the service client associated with this container. + * + * @param prefix + * A String that represents the blob name prefix. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified + * prefix for the service client associated with this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented(final String prefix) throws StorageException { + return this.blobServiceClient.listContainersSegmented(prefix); + } + + /** + * Returns a result segment containing a collection of containers whose names begin with the specified prefix for + * the service client associated with this container, using the specified listing details options, request options, + * and operation context. + * + * @param prefix + * A String that represents the prefix of the container name. + * @param detailsIncluded + * A {@link ContainerListingDetails} object that indicates whether metadata is included. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified + * prefix for the service client associated with this container. + * + * @throws StorageException + * If a storage service error occurred. + * + */ + @DoesServiceRequest + public ResultSegment listContainersSegmented( + final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, final BlobRequestOptions options, + final OperationContext opContext) throws StorageException { + return this.blobServiceClient.listContainersSegmented(prefix, + detailsIncluded, + maxResults, + continuationToken, + options, + opContext); + } + + /** + * Parse Uri for SAS (Shared access signature) information. + * + * Validate that no other query parameters are passed in. Any SAS information will be recorded as corresponding + * credentials instance. If existingClient is passed in, any SAS information found will not be supported. Otherwise + * a new client is created based on SAS information or as anonymous credentials. + * + * @param completeUri + * The complete Uri. + * @param existingClient + * The client to use. + * @param usePathStyleUris + * If true, path style Uris are used. + * @throws URISyntaxException + * @throws StorageException + */ + private void parseQueryAndVerify( + final URI completeUri, final CloudBlobClient existingClient, final boolean usePathStyleUris) + throws URISyntaxException, StorageException { + Utility.assertNotNull("completeUri", completeUri); + + if (!completeUri.isAbsolute()) { + final String errorMessage = + String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", + completeUri.toString()); + throw new IllegalArgumentException(errorMessage); + } + + this.uri = PathUtility.stripURIQueryAndFragment(completeUri); + + final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); + final StorageCredentialsSharedAccessSignature sasCreds = + SharedAccessSignatureHelper.parseQuery(queryParameters); + + if (sasCreds == null) { + return; + } + + final Boolean sameCredentials = + existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, existingClient.getCredentials()); + + if (existingClient == null || !sameCredentials) { + this.blobServiceClient = + new CloudBlobClient(new URI( + PathUtility.getServiceClientBaseAddress(this.getUri(), usePathStyleUris)), sasCreds); + } + + if (existingClient != null && !sameCredentials) { + this.blobServiceClient + .setPageBlobStreamWriteSizeInBytes(existingClient.getPageBlobStreamWriteSizeInBytes()); + this.blobServiceClient.setSingleBlobPutThresholdInBytes(existingClient.getSingleBlobPutThresholdInBytes()); + this.blobServiceClient.setStreamMinimumReadSizeInBytes(existingClient.getStreamMinimumReadSizeInBytes()); + this.blobServiceClient.setWriteBlockSizeInBytes(existingClient.getWriteBlockSizeInBytes()); + this.blobServiceClient.setConcurrentRequestCount(existingClient.getConcurrentRequestCount()); + this.blobServiceClient.setDirectoryDelimiter(existingClient.getDirectoryDelimiter()); + this.blobServiceClient.setRetryPolicyFactory(existingClient.getRetryPolicyFactory()); + this.blobServiceClient.setTimeoutInMs(existingClient.getTimeoutInMs()); + } + } + + void updatePropertiesFromResponse(HttpURLConnection request) { + String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); + + // ETag + if (Utility.isNullOrEmpty(tempStr)) { + this.getProperties().setEtag(tempStr); + } + + // Last Modified + final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); + lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); + lastModifiedCalendar.setTime(new Date(request.getLastModified())); + this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + } + + /** + * Sets the metadata for the container. + * + * @param metadata + * A java.util.HashMap object that represents the metadata being assigned to the container. + */ + public void setMetadata(final HashMap metadata) { + this.metadata = metadata; + } + + /** + * Sets the name of the container. + * + * @param name + * A String that represents the name being assigned to the container. + */ + protected void setName(final String name) { + this.name = name; + } + + /** + * Sets the properties for the container. + * + * @param properties + * A {@link BlobContainerProperties} object that represents the properties being assigned to the + * container. + */ + protected void setProperties(final BlobContainerProperties properties) { + this.properties = properties; + } + + /** + * Sets the URI of the container. + * + * @param uri + * A java.net.URI object that represents the URI being assigned to the container. + */ + protected void setUri(final URI uri) { + this.uri = uri; + } + + /** + * Uploads the container's metadata. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadMetadata() throws StorageException { + this.uploadMetadata(null, null); + } + + /** + * Uploads the container's metadata using the specified request options and operation context. + * + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadMetadata(BlobRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final HttpURLConnection request = + ContainerRequest.setMetadata(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } + + container.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + + } + + /** + * Uploads the container's permissions. + * + * @param permissions + * A {@link BlobContainerPermissions} object that represents the permissions to upload. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadPermissions(final BlobContainerPermissions permissions) throws StorageException { + this.uploadPermissions(permissions, null, null); + } + + /** + * Uploads the container's permissions using the specified request options and operation context. + * + * @param permissions + * A {@link BlobContainerPermissions} object that represents the permissions to upload. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadPermissions( + final BlobContainerPermissions permissions, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + + final HttpURLConnection request = + ContainerRequest.setAcl(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), permissions.getPublicAccess(), opContext); + + final StringWriter outBuffer = new StringWriter(); + + ContainerRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), + outBuffer); + + final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); + client.getCredentials().signRequest(request, aclBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(aclBytes); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } + + container.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java new file mode 100644 index 0000000000000..5e0ad33b8d56e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java @@ -0,0 +1,461 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.EnumSet; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; +import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Represents a virtual directory of blobs, designated by a delimiter character. + *

+ * Containers, which are encapsulated as {@link CloudBlobContainer} objects, hold directories, and directories hold + * block blobs and page blobs. Directories can also contain sub-directories. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudBlobDirectory implements ListBlobItem { + + /** + * Holds the Blobs container Reference. + */ + private CloudBlobContainer container; + + /** + * Represents the blob's directory. + */ + protected CloudBlobDirectory parent; + + /** + * Represents the blob client. + */ + protected CloudBlobClient blobServiceClient; + + /** + * Holds the URI of the directory. + */ + private final URI uri; + + /** + * Holds the prefix for the directory. + */ + private String prefix; + + /** + * Creates an instance of the CloudBlobDirectory class using the specified address and client. + * + * @param relativeAddress + * A String that represents the blob directory's relative address. + * @param client + * A {@link CloudBlobClient} object that represents the associated service client. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + protected CloudBlobDirectory(String relativeAddress, final CloudBlobClient client) throws URISyntaxException, + StorageException { + Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); + Utility.assertNotNull("client", client); + + this.blobServiceClient = client; + + if (this.blobServiceClient.getDirectoryDelimiter() != null + && !relativeAddress.endsWith(this.blobServiceClient.getDirectoryDelimiter())) { + relativeAddress = relativeAddress.concat(this.blobServiceClient.getDirectoryDelimiter()); + } + + this.uri = PathUtility.appendPathToUri(this.blobServiceClient.getEndpoint(), relativeAddress); + } + + /** + * Creates an instance of the CloudBlobDirectory class using the specified address, directory parent, + * and client. + * + * @param uri + * A String that represents the blob directory's address. + * @param parent + * A CloudBlobDirectory object that represents the parent directory, if applicable. + * @param client + * A {@link CloudBlobClient} object that represents the associated service client. + */ + protected CloudBlobDirectory(final URI uri, final CloudBlobDirectory parent, final CloudBlobClient client) { + Utility.assertNotNull("uri", uri); + Utility.assertNotNull("client", client); + + this.blobServiceClient = client; + this.uri = uri; + this.parent = parent; + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) + throws URISyntaxException, StorageException { + return this.getBlockBlobReference(blobAddressUri, null); + } + + /** + * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory, using the + * specified snapshot ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = + PathUtility.appendPathToUri(this.uri, blobAddressUri, this.blobServiceClient.getDirectoryDelimiter()); + + final CloudBlockBlob retBlob = new CloudBlockBlob(address, snapshotID, this.blobServiceClient); + retBlob.setContainer(this.container); + return retBlob; + } + + /** + * Returns the container for this directory. + * + * @return A {@link CloudBlobContainer} that represents the container for this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobContainer getContainer() throws StorageException, URISyntaxException { + if (this.container == null) { + final URI containerURI = PathUtility.getContainerURI(this.uri, this.blobServiceClient.isUsePathStyleUris()); + this.container = new CloudBlobContainer(containerURI, this.blobServiceClient); + } + + return this.container; + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { + return this.getPageBlobReference(blobAddressUri, null); + } + + /** + * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the + * specified snapshot ID. + * + * @param blobAddressUri + * A String that represents the name of the blob, or the absolute URI to the blob. + * @param snapshotID + * A String that represents the snapshot ID of the blob. + * + * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) + throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); + + final URI address = + PathUtility.appendPathToUri(this.uri, blobAddressUri, this.blobServiceClient.getDirectoryDelimiter()); + + final CloudPageBlob retBlob = new CloudPageBlob(address, snapshotID, this.blobServiceClient); + retBlob.setContainer(this.container); + + return retBlob; + } + + /** + * Returns the parent directory of this directory. + * + * @return A {@link CloudBlobDirectory} object that represents the parent of this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobDirectory getParent() throws URISyntaxException, StorageException { + if (this.parent == null) { + final URI parentURI = + PathUtility.getParentAddress(this.uri, + this.blobServiceClient.getDirectoryDelimiter(), + this.blobServiceClient.isUsePathStyleUris()); + this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); + } + return this.parent; + } + + /** + * Returns the prefix for this directory. + * + * @return A String that represents the prefix for this directory. + * + * @throws StorageException + * If a storage service error occurred. + */ + protected String getPrefix() throws StorageException { + if (this.prefix == null) { + try { + final String containerUri = this.getContainer().getUri().toString().concat("/"); + this.prefix = Utility.safeRelativize(new URI(containerUri), this.uri); + } catch (final URISyntaxException e) { + final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); + throw wrappedUnexpectedException; + } + } + + return this.prefix; + } + + /** + * Returns the Blob service client associated with this directory. + * + * @return An {@link CloudBlobClient} object that represents the service client associated with the directory. + */ + public CloudBlobClient getServiceClient() { + return this.blobServiceClient; + } + + /** + * Returns a reference to a virtual blob directory beneath this directory. + * + * @param relativeAddress + * A String that represents the name of the virtual blob directory, or the absolute URI to + * the virtual blob directory. + * + * @return A CloudBlobDirectory object that represents a virtual blob directory beneath this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudBlobDirectory getSubDirectoryReference(final String relativeAddress) + throws StorageException, URISyntaxException { + Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); + + final URI address = + PathUtility.appendPathToUri(this.uri, relativeAddress, this.blobServiceClient.getDirectoryDelimiter()); + + return new CloudBlobDirectory(address, this, this.blobServiceClient); + } + + /** + * Returns the URI for this directory. + * + * @return A java.net.URI object that represents the URI for this directory. + */ + public URI getUri() { + return this.uri; + } + + /** + * Returns an enumerable collection of blob items for the directory. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this + * container. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public Iterable listBlobs() throws StorageException, URISyntaxException { + return this.getContainer().listBlobs(this.getPrefix()); + } + + /** + * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. + * + * @param prefix + * A String that represents the blob name prefix. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin + * with the specified prefix in this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public Iterable listBlobs(String prefix) throws URISyntaxException, StorageException { + prefix = prefix == null ? Constants.EMPTY_STRING : prefix; + return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); + } + + /** + * Returns an enumerable collection of blob items whose names begin with the specified prefix, using the specified + * flat or hierarchical option, listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the blob name. + * @param useFlatBlobListing + * true to indicate that the returned list will be flat; false to indicate that + * the returned list will be hierarchical. + * @param listingDetails + * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate + * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always + * returned. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin + * with the specified prefix in this directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public Iterable listBlobs( + String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, + final BlobRequestOptions options, final OperationContext opContext) + throws URISyntaxException, StorageException { + prefix = prefix == null ? Constants.EMPTY_STRING : prefix; + return this.getContainer().listBlobs(this.getPrefix().concat(prefix), + useFlatBlobListing, + listingDetails, + options, + opContext); + } + + /** + * Returns a result segment of an enumerable collection of blob items in the directory. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the blob items in the directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented() throws StorageException, URISyntaxException { + return this.getContainer().listBlobsSegmented(this.getPrefix()); + } + + /** + * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. + * + * @param prefix + * A String that represents the prefix of the blob name. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the blob items whose names begin with the specified prefix in + * the directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented(String prefix) throws StorageException, URISyntaxException { + prefix = prefix == null ? Constants.EMPTY_STRING : prefix; + return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix)); + } + + /** + * Returns a result segment containing a collection of blob items whose names begin with the specified prefix, using + * the specified flat or hierarchical option, listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the blob name. + * @param useFlatBlobListing + * true to indicate that the returned list will be flat; false to indicate that + * the returned list will be hierarchical. + * @param listingDetails + * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate + * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always + * returned. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of + * {@link ListBlobItem} objects that represent the block items whose names begin with the specified prefix + * in the directory. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + @DoesServiceRequest + public ResultSegment listBlobsSegmented( + String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, + final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, + final OperationContext opContext) throws StorageException, URISyntaxException { + prefix = prefix == null ? Constants.EMPTY_STRING : prefix; + return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix), + useFlatBlobListing, + listingDetails, + maxResults, + continuationToken, + options, + opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java new file mode 100644 index 0000000000000..53fecee4947b2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -0,0 +1,648 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URI; +import java.util.ArrayList; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Represents a blob that is uploaded as a set of blocks. + * + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudBlockBlob extends CloudBlob { + + /** + * Creates an instance of the CloudBlockBlob class by copying values from another cloud block blob. + * + * @param otherBlob + * A CloudBlockBlob object that represents the block blob to copy. + * + * @throws StorageException + * If a storage service error occurs. + */ + public CloudBlockBlob(final CloudBlockBlob otherBlob) throws StorageException { + super(otherBlob); + } + + /** + * Creates an instance of the CloudBlockBlob class using the specified relative URI and storage service + * client. + * + * @param uri + * A java.net.URI object that represents the relative URI to the blob, beginning with the + * container name. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudBlockBlob(final URI uri, final CloudBlobClient client) throws StorageException { + super(BlobType.BLOCK_BLOB, uri, client); + } + + /** + * Creates an instance of the CloudBlockBlob class using the specified relative URI, storage service + * client and container. + * + * @param uri + * A java.net.URI object that represents the relative URI to the blob. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * @param container + * A {@link CloudBlobContainer} object that represents the container to use for the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudBlockBlob(final URI uri, final CloudBlobClient client, final CloudBlobContainer container) + throws StorageException { + super(BlobType.BLOCK_BLOB, uri, client, container); + } + + /** + * Creates an instance of the CloudBlockBlob class using the specified relative URI, snapshot ID, and + * storage service client. + * + * @param uri + * A java.net.URI object that represents the relative URI to the blob. + * @param snapshotID + * A String that represents the snapshot version, if applicable. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudBlockBlob(final URI uri, final String snapshotID, final CloudBlobClient client) throws StorageException { + super(BlobType.BLOCK_BLOB, uri, snapshotID, client); + } + + /** + * Commits a block list to the storage service. + * + * @param blockList + * An enumerable collection of BlockEntry objects that represents the list block items being + * committed. The size field is ignored. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void commitBlockList(final Iterable blockList) throws StorageException { + this.commitBlockList(blockList, null, null, null); + } + + /** + * Commits a block list to the storage service using the specified lease ID, request options, and operation context. + * + * @param blockList + * An enumerable collection of BlockEntry objects that represents the list block items being + * committed. The size field is ignored. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void commitBlockList( + final Iterable blockList, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.putBlockList(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blob.properties, + accessCondition, + blobOptions, + opContext); + BlobRequest.addMetadata(request, blob.metadata, opContext); + + // Potential optimization, we can write this stream outside of + // the StorageOperation, so it wont need to be rewritten for each retry. Because it would + // need to be a final member this would require refactoring into an internal method which + // receives the block list bytestream as a final param. + + final byte[] blockListBytes = BlobRequest.writeBlockListToStream(blockList, opContext); + + final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(blockListBytes); + + final StreamDescriptor descriptor = + Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); + + client.getCredentials().signRequest(request, descriptor.getLength()); + Utility.writeToOutputStream(blockListInputStream, + request.getOutputStream(), + descriptor.getLength(), + false, + false, + null, + opContext); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Downloads the committed block list from the block blob. + *

+ * The committed block list includes the list of blocks that have been successfully committed to the block blob. The + * list of committed blocks is returned in the same order that they were committed to the blob. No block may appear + * more than once in the committed block list. + * + * @return An ArrayList object of BlockEntry objects that represent the committed list + * block items downloaded from the block blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ArrayList downloadBlockList() throws StorageException { + return this.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); + } + + /** + * Downloads the block list from the block blob using the specified block listing filter, request options, and + * operation context. + * + * @param blockListingFilter + * A {@link BlockListingFilter} value that specifies whether to download committed blocks, uncommitted + * blocks, or all blocks. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An ArrayList object of BlockEntry objects that represent the list block items + * downloaded from the block blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ArrayList downloadBlockList( + final BlockListingFilter blockListingFilter, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException { + Utility.assertNotNull("blockListingFilter", blockListingFilter); + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + + final StorageOperation> impl = + new StorageOperation>(options) { + + @Override + public ArrayList execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.getBlockList(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blob.snapshotID, + blockListingFilter, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + final GetBlockListResponse response = new GetBlockListResponse(request.getInputStream()); + return response.getBlocks(); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Creates and opens an output stream to write data to the block blob. + * + * @return A {@link BlobOutputStream} object used to write data to the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + public BlobOutputStream openOutputStream() throws StorageException { + return this.openOutputStream(null, null, null); + } + + /** + * Creates and opens an output stream to write data to the block blob using the specified request options and + * operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link BlobOutputStream} object used to write data to the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + public BlobOutputStream openOutputStream( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + return new BlobOutputStream(this, accessCondition, options, opContext); + } + + /** + * Uploads the source stream data to the block blob. + * + * @param sourceStream + * An InputStream object that represents the input stream to write to the block blob. + * @param length + * The length, in bytes, of the stream data, or -1 if unknown. + * + * @throws IOException + * If an I/O error occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + @DoesServiceRequest + public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException { + this.upload(sourceStream, length, null, null, null); + } + + /** + * Uploads the source stream data to the blob, using the specified lease ID, request options, and operation context. + * + * @param sourceStream + * An InputStream object that represents the input stream to write to the block blob. + * @param length + * The length, in bytes, of the stream data, or -1 if unknown. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O error occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + @DoesServiceRequest + public void upload( + final InputStream sourceStream, final long length, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { + if (length < -1) { + throw new IllegalArgumentException( + "Invalid stream length, specify -1 for unkown length stream, or a positive number of bytes"); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.blobServiceClient); + // Mark sourceStream for current position. + sourceStream.mark(Integer.MAX_VALUE); + + StreamDescriptor descriptor = new StreamDescriptor(); + descriptor.setLength(length); + + // If the stream is rewindable and the length is unknown or we need to + // set md5, then analyze the stream. + // Note this read will abort at + // serviceClient.getSingleBlobPutThresholdInBytes() bytes and return + // -1 as length in which case we will revert to using a stream as it is + // over the single put threshold. + if (sourceStream.markSupported() && (length < 0 || options.getStoreBlobContentMD5())) { + // If the stream is of unknown length or we need to calculate + // the MD5, then we we need to read the stream contents first + + descriptor = + Utility.analyzeStream(sourceStream, + length, + this.blobServiceClient.getSingleBlobPutThresholdInBytes(), + true, + options.getStoreBlobContentMD5()); + + if (descriptor.getMd5() != null && options.getStoreBlobContentMD5()) { + this.properties.setContentMD5(descriptor.getMd5()); + } + } + + // If the stream is rewindable, and the length is known and less than + // threshold the upload in a single put, otherwise use a stream. + if (sourceStream.markSupported() && descriptor.getLength() != -1 + && descriptor.getLength() < this.blobServiceClient.getSingleBlobPutThresholdInBytes()) { + this.uploadFullBlob(sourceStream, descriptor.getLength(), accessCondition, options, opContext); + } else { + final BlobOutputStream writeStream = this.openOutputStream(accessCondition, options, opContext); + writeStream.write(sourceStream, length); + writeStream.close(); + } + } + + /** + * Uploads a block to the block blob, using the specified block ID and lease ID. + * + * @param blockId + * A String that represents the Base-64 encoded block ID. Note for a given blob the length + * of all Block IDs must be identical. + * @param sourceStream + * An InputStream object that represents the input stream to write to the block blob. + * @param length + * The length, in bytes, of the stream data, or -1 if unknown. + * @throws IOException + * If an I/O error occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadBlock(final String blockId, final InputStream sourceStream, final long length) + throws StorageException, IOException { + this.uploadBlock(blockId, sourceStream, length, null, null, null); + } + + /** + * Uploads a block to the block blob, using the specified block ID, lease ID, request options, and operation + * context. + * + * @param blockId + * A String that represents the Base-64 encoded block ID. Note for a given blob the length + * of all Block IDs must be identical. + * + * @param sourceStream + * An InputStream object that represents the input stream to write to the block blob. + * @param length + * The length, in bytes, of the stream data, or -1 if unknown. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O error occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadBlock( + final String blockId, final InputStream sourceStream, final long length, + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException, IOException { + if (length < -1) { + throw new IllegalArgumentException( + "Invalid stream length, specify -1 for unkown length stream, or a positive number of bytes"); + } + + if (length > 4 * Constants.MB) { + throw new IllegalArgumentException( + "Invalid stream length, length must be less than or equal to 4 MB in size."); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + // Assert block length + if (Utility.isNullOrEmpty(blockId) || !Base64.validateIsBase64String(blockId)) { + throw new IllegalArgumentException("Invalid blockID, BlockID must be a valid Base64 String."); + } + + // Mark sourceStream for current position. + sourceStream.mark(Integer.MAX_VALUE); + + InputStream bufferedStreamReference = sourceStream; + StreamDescriptor descriptor = new StreamDescriptor(); + descriptor.setLength(length); + + if (!sourceStream.markSupported()) { + // needs buffering + final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); + descriptor = + Utility.writeToOutputStream(sourceStream, + byteStream, + length, + false, + options.getUseTransactionalContentMD5(), + null, + opContext); + + bufferedStreamReference = new ByteArrayInputStream(byteStream.toByteArray()); + } else if (length < 0 || options.getUseTransactionalContentMD5()) { + // If the stream is of unknown length or we need to calculate the + // MD5, then we we need to read + // the stream contents first + + descriptor = + Utility.analyzeStream(sourceStream, length, -1L, true, options.getUseTransactionalContentMD5()); + } + + if (descriptor.getLength() > 4 * Constants.MB) { + throw new IllegalArgumentException( + "Invalid stream length, length must be less than or equal to 4 MB in size."); + } + + this.uploadBlockInternal(blockId, + descriptor.getMd5(), + bufferedStreamReference, + descriptor.getLength(), + accessCondition, + options, + opContext); + } + + /** + * Uploads a block of the blob to the server. + * + * @param blockId + * the Base64 Encoded Block ID + * @param md5 + * the MD5 to use if it will be set. + * @param sourceStream + * the InputStream to read from + * @param length + * the OutputStream to write the blob to. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * An object that specifies any additional options for the request + * @param opContext + * an object used to track the execution of the operation + * @throws StorageException + * If a storage service error occurred. + * @throws IOException + */ + @DoesServiceRequest + private void uploadBlockInternal( + final String blockId, final String md5, final InputStream sourceStream, final long length, + final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) + throws StorageException, IOException { + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.putBlock(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blockId, + accessCondition, + blobOptions, + opContext); + + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); + } + + client.getCredentials().signRequest(request, length); + + Utility.writeToOutputStream(sourceStream, + request.getOutputStream(), + length, + true, + false, + null, + opContext); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java new file mode 100644 index 0000000000000..ac252a5f7ce6e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -0,0 +1,679 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URI; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; + +import com.microsoft.windowsazure.services.core.storage.AccessCondition; +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Represents a Windows Azure page blob. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudPageBlob extends CloudBlob { + + /** + * Creates an instance of the CloudPageBlob class by copying values from another page blob. + * + * @param otherBlob + * A CloudPageBlob object that represents the page blob to copy. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudPageBlob(final CloudPageBlob otherBlob) throws StorageException { + super(otherBlob); + } + + /** + * Creates an instance of the CloudPageBlob class using the specified URI and cloud blob client. + * + * @param uri + * A java.net.URI object that represents the absolute URI to the blob, beginning with the + * container name. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudPageBlob(final URI uri, final CloudBlobClient client) throws StorageException { + super(BlobType.PAGE_BLOB, uri, client); + } + + /** + * Creates an instance of the CloudPageBlob class using the specified URI, cloud blob client, and cloud + * blob container. + * + * @param uri + * A java.net.URI object that represents the relative URI to the blob, beginning with the + * container name. + * @param client + * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. + * @param container + * A {@link CloudBlobContainer} object that represents the container to use for the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudPageBlob(final URI uri, final CloudBlobClient client, final CloudBlobContainer container) + throws StorageException { + super(BlobType.PAGE_BLOB, uri, client, container); + } + + /** + * Creates an instance of the CloudPageBlob class using the specified URI, snapshot ID, and cloud blob + * client. + * + * @param uri + * A java.net.URI object that represents the absolute URI to the blob, beginning with the + * container name. + * @param snapshotID + * A String that represents the snapshot version, if applicable. + * @param client + * A {@link CloudBlobContainer} object that represents the container to use for the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + public CloudPageBlob(final URI uri, final String snapshotID, final CloudBlobClient client) throws StorageException { + super(BlobType.PAGE_BLOB, uri, snapshotID, client); + } + + /** + * Clears pages from a page blob. + *

+ * Calling clearPages releases the storage space used by the specified pages. Pages that have been + * cleared are no longer tracked as part of the page blob, and no longer incur a charge against the storage account. + * + * @param offset + * The offset, in bytes, at which to begin clearing pages. This value must be a multiple of 512. + * @param length + * The length, in bytes, of the data range to be cleared. This value must be a multiple of 512. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void clearPages(final long offset, final long length) throws StorageException, IOException { + this.clearPages(offset, length, null, null, null); + } + + /** + * Clears pages from a page blob using the specified lease ID, request options, and operation context. + *

+ * Calling clearPages releases the storage space used by the specified pages. Pages that have been + * cleared are no longer tracked as part of the page blob, and no longer incur a charge against the storage account. + * + * @param offset + * The offset, in bytes, at which to begin clearing pages. This value must be a multiple of 512. + * @param length + * The length, in bytes, of the data range to be cleared. This value must be a multiple of 512. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void clearPages( + final long offset, final long length, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException, IOException { + if (offset % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page start offset must be multiple of 512!"); + } + + if (length % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page data must be multiple of 512!"); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + final PageProperties pageProps = new PageProperties(); + pageProps.setPageOperation(PageOperationType.CLEAR); + pageProps.getRange().setStartOffset(offset); + pageProps.getRange().setEndOffset(offset + length - 1); + + this.putPagesInternal(pageProps, null, length, null, accessCondition, options, opContext); + } + + /** + * Creates a page blob. + * + * @param length + * The size, in bytes, of the page blob. + * + * @throws IllegalArgumentException + * If the length is not a multiple of 512. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void create(final long length) throws StorageException { + this.create(length, null, null, null); + } + + /** + * Creates a page blob using the specified request options and operation context. + * + * @param length + * The size, in bytes, of the page blob. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IllegalArgumentException + * If the length is not a multiple of 512. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void create( + final long length, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { + if (length % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page blob length must be multiple of 512."); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.put(blob.getTransformedAddress(opContext), + this.getRequestOptions().getTimeoutIntervalInMs(), + blob.properties, + BlobType.PAGE_BLOB, + length, + accessCondition, + blobOptions, + opContext); + + BlobRequest.addMetadata(request, blob.metadata, opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Returns a collection of page ranges and their starting and ending byte offsets. + *

+ * The start and end byte offsets for each page range are inclusive. + * + * @return An ArrayList object that represents the set of page ranges and their starting and ending + * byte offsets. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ArrayList downloadPageRanges() throws StorageException { + return this.downloadPageRanges(null, null, null); + } + + /** + * Returns a collection of page ranges and their starting and ending byte offsets using the specified request + * options and operation context. + * + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An ArrayList object that represents the set of page ranges and their starting and ending + * byte offsets. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ArrayList downloadPageRanges( + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + final StorageOperation> impl = + new StorageOperation>(options) { + + @Override + public ArrayList execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.getPageRanges(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + blob.snapshotID, + accessCondition, + blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + final GetPageRangesResponse response = new GetPageRangesResponse(request.getInputStream()); + return response.getPageRanges(); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Opens an input stream object to write data to the page blob. + * + * @param length + * The length, in bytes, of the stream to create. This value must be a multiple of 512. + * + * @return A {@link BlobOutputStream} object used to write data to the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public BlobOutputStream openOutputStream(final long length) throws StorageException { + return this.openOutputStream(length, null, null, null); + } + + /** + * Opens an input stream object to write data to the page blob, using the specified lease ID, request options and + * operation context. + * + * @param length + * The length, in bytes, of the stream to create. This value must be a multiple of 512. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link BlobOutputStream} object used to write data to the blob. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public BlobOutputStream openOutputStream( + final long length, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + if (options.getStoreBlobContentMD5()) { + throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); + } + + return new BlobOutputStream(this, length, accessCondition, options, opContext); + } + + /** + * Used for both uploadPages and clearPages. + * + * @param pageProperties + * The page properties. + * @param data + * The data to write. + * @param length + * The number of bytes to write. + * @param md5 + * the MD5 hash for the data. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + private void putPagesInternal( + final PageProperties pageProperties, final byte[] data, final long length, final String md5, + final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) + throws StorageException { + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = + BlobRequest.putPage(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), + pageProperties, + accessCondition, + blobOptions, + opContext); + + if (pageProperties.getPageOperation() == PageOperationType.UPDATE) { + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); + } + + client.getCredentials().signRequest(request, length); + request.getOutputStream().write(data); + } else { + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; + + ExecutionEngine + .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Uploads the source stream data to the page blob. + * + * @param sourceStream + * An IntputStream object to read from. + * @param length + * The length, in bytes, of the stream data, must be non zero and a multiple of 512. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + @DoesServiceRequest + public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException { + this.upload(sourceStream, length, null, null, null); + } + + /** + * Uploads the source stream data to the page blob using the specified lease ID, request options, and operation + * context. + * + * @param sourceStream + * An IntputStream object to read from. + * @param length + * The length, in bytes, of the stream data. This must be great than zero and a multiple of 512. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + @DoesServiceRequest + public void upload( + final InputStream sourceStream, final long length, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + if (length <= 0 || length % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page data must be multiple of 512!"); + } + + if (options.getStoreBlobContentMD5()) { + throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); + } + + // Mark sourceStream for current position. + sourceStream.mark(Integer.MAX_VALUE); + + if (length <= 4 * Constants.MB) { + this.create(length, accessCondition, options, opContext); + this.uploadPages(sourceStream, 0, length, accessCondition, options, opContext); + } else { + final OutputStream streamRef = this.openOutputStream(length, accessCondition, options, opContext); + Utility.writeToOutputStream(sourceStream, streamRef, length, false, false, null, opContext); + streamRef.close(); + } + } + + /** + * Uploads a range of contiguous pages, up to 4 MB in size, at the specified offset in the page blob. + * + * @param sourceStream + * An InputStream object that represents the input stream to write to the page blob. + * @param offset + * The offset, in number of bytes, at which to begin writing the data. This value must be a multiple of + * 512. + * @param length + * The length, in bytes, of the data to write. This value must be a multiple of 512. + * + * @throws IllegalArgumentException + * If the offset or length are not multiples of 512, or if the length is greater than 4 MB. + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadPages(final InputStream sourceStream, final long offset, final long length) + throws StorageException, IOException { + this.uploadPages(sourceStream, offset, length, null, null, null); + } + + /** + * Uploads a range of contiguous pages, up to 4 MB in size, at the specified offset in the page blob, using the + * specified lease ID, request options, and operation context. + * + * @param sourceStream + * An InputStream object that represents the input stream to write to the page blob. + * @param offset + * The offset, in number of bytes, at which to begin writing the data. This value must be a multiple of + * 512. + * @param length + * The length, in bytes, of the data to write. This value must be a multiple of 512. + * @param accessCondition + * An {@link AccessCondition} object that represents the access conditions for the blob. + * @param options + * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws IllegalArgumentException + * If the offset or length are not multiples of 512, or if the length is greater than 4 MB. + * @throws IOException + * If an I/O exception occurred. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadPages( + final InputStream sourceStream, final long offset, final long length, + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException, IOException { + + if (offset % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page start offset must be multiple of 512!"); + } + + if (length % BlobConstants.PAGE_SIZE != 0) { + throw new IllegalArgumentException("Page data must be multiple of 512!"); + } + + if (length > 4 * Constants.MB) { + throw new IllegalArgumentException("Max write size is 4MB. Please specify a smaller range."); + } + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new BlobRequestOptions(); + } + + options.applyDefaults(this.blobServiceClient); + + final PageProperties pageProps = new PageProperties(); + pageProps.setPageOperation(PageOperationType.UPDATE); + pageProps.getRange().setStartOffset(offset); + pageProps.getRange().setEndOffset(offset + length - 1); + final byte[] data = new byte[(int) length]; + String md5 = null; + + int count = 0; + long total = 0; + while (total < length) { + count = sourceStream.read(data, 0, (int) Math.min(length - total, Integer.MAX_VALUE)); + total += count; + } + + if (options.getUseTransactionalContentMD5()) { + try { + final MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(data, 0, data.length); + md5 = Base64.encode(digest.digest()); + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + this.putPagesInternal(pageProps, data, length, md5, accessCondition, options, opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java new file mode 100644 index 0000000000000..1187fdf7e6552 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java @@ -0,0 +1,38 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * 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 all available details. + */ + ALL(1), + + /** + * Specifies including container metadata. + */ + METADATA(1), + + /** + * Specifies including no additional details. + */ + NONE(0); + + /** + * Returns the value of this enum. + */ + public int value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + ContainerListingDetails(final int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java new file mode 100644 index 0000000000000..1fc3ade1af858 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java @@ -0,0 +1,392 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.IOException; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.Credentials; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; + +/** + * RESERVED FOR INTERNAL USE. A class used to generate requests for contianer objects. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class ContainerRequest { + /** + * Adds user-defined metadata to the request as one or more name-value pairs. + * + * @param request + * The web request. + * @param metadata + * The user-defined metadata. + * */ + public static void addMetadata( + final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + BaseRequest.addMetadata(request, metadata, opContext); + } + + /** + * Adds user-defined metadata to the request as a single name-value pair. + * + * @param request + * The web request. + * @param name + * The metadata name. + * @param value + * The metadata value. + * */ + public static void addMetadata( + final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + BaseRequest.addMetadata(request, name, value, opContext); + } + + /** + * Constructs a web request to create a new container. Sign with 0 length. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection create(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); + return BaseRequest.create(uri, timeout, containerBuilder, opContext); + } + + /** + * Creates the web request. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @param query + * The query builder to use. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + private static HttpURLConnection createURLConnection( + final URI uri, final int timeout, final UriQueryBuilder query, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.createURLConnection(uri, timeout, query, opContext); + } + + /** + * Constructs a web request to delete the container and all of blobs within it. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection delete(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); + return BaseRequest.delete(uri, timeout, containerBuilder, opContext); + } + + /** + * Constructs a web request to return the ACL for this container. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + */ + public static HttpURLConnection getAcl(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = getContainerUriQueryBuilder(); + builder.add("comp", "acl"); + + final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Gets the container Uri query builder. + * + * A UriQueryBuilder for the container. + * + * @throws StorageException + */ + protected static UriQueryBuilder getContainerUriQueryBuilder() throws StorageException { + final UriQueryBuilder uriBuilder = new UriQueryBuilder(); + try { + uriBuilder.add("restype", "container"); + } catch (final IllegalArgumentException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + return uriBuilder; + } + + /** + * Constructs a web request to retrieve the container's metadata. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + */ + public static HttpURLConnection getMetadata(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); + return BaseRequest.getMetadata(uri, timeout, containerBuilder, opContext); + } + + /** + * Constructs a web request to return the user-defined metadata for this container. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * */ + public static HttpURLConnection getProperties(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); + return BaseRequest.getProperties(uri, timeout, containerBuilder, opContext); + } + + /** + * Constructs a request to return a listing of all containers in this storage account. Sign with no length + * specified. + * + * @param uri + * The absolute URI for the account. + * @param timeout + * The absolute URI for the account. + * @param listingContext + * A set of parameters for the listing operation. + * @param detailsIncluded + * Additional details to return with the listing. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection list( + final URI uri, final int timeout, final ListingContext listingContext, + final ContainerListingDetails detailsIncluded, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = getContainerUriQueryBuilder(); + builder.add("comp", "list"); + + if (listingContext != null) { + if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { + builder.add("prefix", listingContext.getPrefix()); + } + + if (!Utility.isNullOrEmpty(listingContext.getMarker())) { + builder.add("marker", listingContext.getMarker()); + } + + if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { + builder.add("maxresults", listingContext.getMaxResults().toString()); + } + } + + if (detailsIncluded == ContainerListingDetails.ALL || detailsIncluded == ContainerListingDetails.METADATA) { + builder.add("include", "metadata"); + } + + final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Sets the ACL for the container. , Sign with length of aclBytes. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @param publicAccess + * The type of public access to allow for the container. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * */ + public static HttpURLConnection setAcl( + final URI uri, final int timeout, final BlobContainerPublicAccessType publicAccess, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder builder = getContainerUriQueryBuilder(); + builder.add("comp", "acl"); + + final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("PUT"); + request.setDoOutput(true); + + if (publicAccess != BlobContainerPublicAccessType.OFF) { + request.setRequestProperty(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER, publicAccess.toString().toLowerCase()); + } + + return request; + } + + /** + * Constructs a web request to set user-defined metadata for the container, Sign with 0 Length. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * */ + public static HttpURLConnection setMetadata(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); + return BaseRequest.setMetadata(uri, timeout, containerBuilder, opContext); + } + + /** + * Signs the request for Shared Key authentication. + * + * @param request + * The web request. + * @param credentials + * The account credentials. + * @throws StorageException + * */ + public static void signRequest( + final HttpURLConnection request, final Credentials credentials, final Long contentLength, + final OperationContext opContext) throws InvalidKeyException, StorageException { + BaseRequest.signRequestForBlobAndQueue(request, credentials, contentLength, opContext); + } + + /** + * Signs the request for Shared Key Lite authentication. + * + * @param request + * The web request. + * @param credentials + * The account credentials. + * @throws StorageException + * @throws InvalidKeyException + * */ + public static void signRequestForSharedKeyLite( + final HttpURLConnection request, final Credentials credentials, final Long contentLength, + final OperationContext opContext) throws InvalidKeyException, StorageException { + BaseRequest.signRequestForBlobAndQueueSharedKeyLite(request, credentials, contentLength, opContext); + } + + /** + * Writes a collection of shared access policies to the specified stream in XML format. + * + * @param sharedAccessPolicies + * A collection of shared access policies + * @param outWriter + * an sink to write the output to. + * @throws XMLStreamException + */ + public static void writeSharedAccessIdentifiersToStream( + final HashMap sharedAccessPolicies, final StringWriter outWriter) + throws XMLStreamException { + Utility.assertNotNull("sharedAccessPolicies", sharedAccessPolicies); + Utility.assertNotNull("outWriter", outWriter); + + final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); + final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); + + if (sharedAccessPolicies.keySet().size() > BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS) { + final String errorMessage = + String.format("Too many %d shared access policy identifiers provided. Server does not support setting more than %d on a single container.", + sharedAccessPolicies.keySet().size(), + BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS); + + throw new IllegalArgumentException(errorMessage); + } + + // default is UTF8 + xmlw.writeStartDocument(); + xmlw.writeStartElement(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); + + for (final Entry entry : sharedAccessPolicies.entrySet()) { + final SharedAccessPolicy policy = entry.getValue(); + xmlw.writeStartElement(BlobConstants.SIGNED_IDENTIFIER_ELEMENT); + + // Set the identifier + xmlw.writeStartElement(Constants.ID); + xmlw.writeCharacters(entry.getKey()); + xmlw.writeEndElement(); + + xmlw.writeStartElement(BlobConstants.ACCESS_POLICY); + + // Set the Start Time + xmlw.writeStartElement(BlobConstants.START); + xmlw.writeCharacters(Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime())); + // end Start + xmlw.writeEndElement(); + + // Set the Expiry Time + xmlw.writeStartElement(BlobConstants.EXPIRY); + xmlw.writeCharacters(Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime())); + // end Expiry + xmlw.writeEndElement(); + + // Set the Permissions + xmlw.writeStartElement(BlobConstants.PERMISSION); + xmlw.writeCharacters(SharedAccessPolicy.permissionsToString(policy.getPermissions())); + // end Permission + xmlw.writeEndElement(); + + // end AccessPolicy + xmlw.writeEndElement(); + // end SignedIdentifier + xmlw.writeEndElement(); + } + + // end SignedIdentifiers + xmlw.writeEndElement(); + // end doc + xmlw.writeEndDocument(); + } + + /** + * Private Default Ctor + */ + private ContainerRequest() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java new file mode 100644 index 0000000000000..4d37a999a5b89 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java @@ -0,0 +1,64 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; + +/** + * RESERVED FOR INTERNAL USE. A class used to parse the response from container operations + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class ContainerResponse extends BaseResponse { + + /** + * Gets the ACL for the container from the response. + * + * @param request + * the request object for this operation + * @return the ACL value indicating the public access level for the container + */ + public static String getAcl(final HttpURLConnection request) { + return request.getHeaderField(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER); + } + + /** + * Gets the BlobContainerAttributes from the given request. + * + * @param request + * the request to get attributes from. + * @param usePathStyleUris + * a value indicating if the account is using pathSytleUris. + * @return the BlobContainerAttributes from the given request. + * @throws StorageException + */ + public static + BlobContainerAttributes getAttributes(final HttpURLConnection request, final boolean usePathStyleUris) + throws StorageException { + final BlobContainerAttributes containerAttributes = new BlobContainerAttributes(); + URI tempURI; + try { + tempURI = PathUtility.stripURIQueryAndFragment(request.getURL().toURI()); + } catch (final URISyntaxException e) { + final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); + throw wrappedUnexpectedException; + } + + containerAttributes.setUri(tempURI); + containerAttributes.setName(PathUtility.getContainerNameFromUri(tempURI, usePathStyleUris)); + + final BlobContainerProperties containerProperties = containerAttributes.getProperties(); + containerProperties.setEtag(BaseResponse.getEtag(request)); + containerProperties.setLastModified(new Date(request.getLastModified())); + + containerAttributes.setMetadata(getMetadata(request)); + + return containerAttributes; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java new file mode 100644 index 0000000000000..ea772491a7380 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java @@ -0,0 +1,26 @@ +/** + * + */ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Specifies options when calling delete operations. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum DeleteSnapshotsOption { + /** + * Specifies deleting only the blob's snapshots. + */ + DELETE_SNAPSHOTS_ONLY, + + /** + * Specifies deleting the blob and its snapshots. + */ + INCLUDE_SNAPSHOTS, + + /** + * Specifies deleting the blob but not its snapshots. + */ + NONE +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java new file mode 100644 index 0000000000000..5b10f08a3b5d5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java @@ -0,0 +1,111 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.InputStream; +import java.util.ArrayList; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class used to parse a get block list response stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class GetBlockListResponse { + /** + * Holds the ArrayList of CloudBlobs from the response. + */ + private final ArrayList blocks = new ArrayList(); + + /** + * Stores the value indicating if the response has been fully parsed. + */ + private boolean isParsed; + + /** + * Stores the InputStream to read from. + */ + private final InputStream streamRef; + + /** + * Constructs the response from the inputstream. + * + * @param stream + * the inputstream for the response the server returned. + */ + public GetBlockListResponse(final InputStream stream) { + this.streamRef = stream; + } + + /** + * Returns an ArrayList of BlockEntrys for the given block blob. + * + * @return an ArrayList of BlockEntrys for the given block blob. + * @throws XMLStreamException + * @throws StorageException + */ + public ArrayList getBlocks() throws XMLStreamException, StorageException { + if (!this.isParsed) { + this.parseResponse(); + } + + return this.blocks; + } + + /** + * Parses the XML stream. + * + * @throws XMLStreamException + * @throws StorageException + */ + public void parseResponse() throws XMLStreamException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get BlockList Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOCK_LIST_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + if (name.equals(BlobConstants.COMMITTED_BLOCKS_ELEMENT)) { + // Move to block element + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.START_ELEMENT + && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { + this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.COMMITTED)); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.COMMITTED_BLOCKS_ELEMENT); + } + } else if (name.equals(BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT)) { + // Move to block element + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.START_ELEMENT + && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { + this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.UNCOMMITTED)); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT); + } + } else if (name.equals(BlobConstants.BLOCK_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { + break; + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } + } + + this.isParsed = true; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java new file mode 100644 index 0000000000000..ac09e9e70561f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java @@ -0,0 +1,98 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.InputStream; +import java.util.ArrayList; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class used to parse a get page ranges response stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class GetPageRangesResponse { + /** + * Holds the ArrayList of Page Ranges from the response. + */ + private ArrayList pageRanges = new ArrayList(); + + /** + * Stores the value indicating if the response has been fully parsed. + */ + private boolean isParsed; + + /** + * Stores the InputStream to read from. + */ + private final InputStream streamRef; + + /** + * Constructs the response from the inputstream. + * + * @param stream + * the inputstream for the response the server returned. + */ + public GetPageRangesResponse(final InputStream stream) { + this.streamRef = stream; + } + + /** + * Returns an ArrayList of Page Ranges for the given page blob. + * + * @return an ArrayList of Page Ranges for the given page blob. + * @throws XMLStreamException + * @throws StorageException + */ + public ArrayList getPageRanges() throws XMLStreamException, StorageException { + if (!this.isParsed) { + this.parseResponse(); + } + + return this.pageRanges; + } + + /** + * Parses the XML stream. + * + * @throws XMLStreamException + * @throws StorageException + */ + public void parseResponse() throws XMLStreamException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get BlockList Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PAGE_LIST_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (name.equals(BlobConstants.PAGE_RANGE_ELEMENT)) { + this.pageRanges = BlobDeserializationHelper.readPageRanges(xmlr); + } else if (name.equals(BlobConstants.PAGE_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { + break; + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } + } + + this.isParsed = true; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java new file mode 100644 index 0000000000000..28243830d39fd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java @@ -0,0 +1,45 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.net.URI; +import java.net.URISyntaxException; + +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * Represents an item that may be returned by a blob listing operation. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public interface ListBlobItem { + + /** + * Returns the container for the blob item. + * + * @return A {@link CloudBlobContainer} object that represents the blob item's container. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + CloudBlobContainer getContainer() throws URISyntaxException, StorageException; + + /** + * Returns the parent for the blob item. + * + * @return A {@link CloudBlobDirectory} object that represents the blob item's parent. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is invalid. + */ + CloudBlobDirectory getParent() throws URISyntaxException, StorageException; + + /** + * Returns the URI for the blob item. + * + * @return A java.net.URI object that represents the blob item's URI. + */ + URI getUri(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java new file mode 100644 index 0000000000000..b8623900cc665 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java @@ -0,0 +1,144 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.InputStream; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.ArrayList; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class used to parse a list blobs response stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class ListBlobsResponse { + + /** + * Holds the ArrayList of CloudBlobs from the response. + */ + private ArrayList blobs = new ArrayList(); + + /** + * Stores the value indicating if the response has been fully parsed. + */ + private boolean isParsed; + + /** + * Stores the marker. + */ + private String marker; + + /** + * Stores the max results. + */ + private int maxResults; + + /** + * Stores the next marker. + */ + private String nextMarker; + + /** + * Stores the container prefix. + */ + private String prefix; + + /** + * Stores the InputStream to read from. + */ + private final InputStream streamRef; + + /** + * Stores the blob delimiter. + */ + private String delimiter; + + public ListBlobsResponse(final InputStream stream) { + this.streamRef = stream; + } + + public ArrayList getBlobs(final CloudBlobClient serviceClient, final CloudBlobContainer container) + throws XMLStreamException, StorageException { + if (!this.isParsed) { + this.parseResponse(serviceClient, container); + } + + return this.blobs; + } + + public String getDelimiter() { + return this.delimiter; + } + + public String getMarker() { + return this.marker; + } + + public int getMaxResults() { + return this.maxResults; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public String getPrefix() { + return this.prefix; + } + + public void parseResponse(final CloudBlobClient serviceClient, final CloudBlobContainer container) + throws XMLStreamException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + String tempParseString = null; + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get enumerationResults Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); + this.maxResults = Integer.parseInt(tempParseString); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.DELIMITER_ELEMENT)) { + this.delimiter = Utility.readElementFromXMLReader(xmlr, Constants.DELIMITER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.BLOBS_ELEMENT)) { + try { + this.blobs = BlobDeserializationHelper.readBlobItems(xmlr, serviceClient, container); + } catch (final URISyntaxException e) { + throw new XMLStreamException(e); + } catch (final ParseException e) { + throw new XMLStreamException(e); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); + } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + break; + } + } + } + + this.isParsed = true; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java new file mode 100644 index 0000000000000..9e100b01ebe20 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java @@ -0,0 +1,152 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.io.InputStream; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.ArrayList; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class for parsing a list containers response stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class ListContainersResponse { + + /** + * Holds the list of containers. + */ + private ArrayList containers = new ArrayList(); + + /** + * Stores the value indicating if the response has been fully parsed. + */ + private boolean isParsed; + + /** + * Stores the marker. + */ + private String marker; + + /** + * Stores the max results. + */ + private int maxResults; + + /** + * Stores the next marker. + */ + private String nextMarker; + + /** + * Stores the container prefix. + */ + private String prefix; + + /** + * Stores the InputStream to read from. + */ + private final InputStream streamRef; + + public ListContainersResponse(final InputStream stream) { + this.streamRef = stream; + } + + /** + * Returns an ArrayList of CloudBlobContainer + * + * @param serviceClient + * a reference to the client object associated with this object. + * @return an ArrayList of CloudBlobContainer + * @throws XMLStreamException + * @throws StorageException + */ + public ArrayList getContainers(final CloudBlobClient serviceClient) + throws XMLStreamException, StorageException { + if (!this.isParsed) { + this.parseResponse(serviceClient); + } + + return this.containers; + } + + public String getMarker() { + return this.marker; + } + + public int getMaxResults() { + return this.maxResults; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public String getPrefix() { + return this.prefix; + } + + /** + * Parses the XML stream. + * + * @param serviceClient + * a reference to the client object associated with this object. + * @throws XMLStreamException + * @throws StorageException + */ + public void parseResponse(final CloudBlobClient serviceClient) throws XMLStreamException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + String tempParseString = null; + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get enumerationResults Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); + this.maxResults = Integer.parseInt(tempParseString); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT + && name.equals(BlobConstants.CONTAINERS_ELEMENT)) { + try { + this.containers = BlobDeserializationHelper.readContainers(xmlr, serviceClient); + } catch (final URISyntaxException e) { + throw new XMLStreamException(e); + } catch (final ParseException e) { + throw new XMLStreamException(e); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); + // eventType = xmlr.next(); + } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + break; + } + } + } + + this.isParsed = true; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java new file mode 100644 index 0000000000000..9fd233de11486 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java @@ -0,0 +1,18 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * RESERVED FOR INTERNAL USE. Describes actions that may be used for writing to a page blob or clearing a set of pages. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +enum PageOperationType { + /** + * Update the page with new data. + */ + UPDATE, + + /** + * Clear the page. + */ + CLEAR +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java new file mode 100644 index 0000000000000..61baa16d685c1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java @@ -0,0 +1,56 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * RESERVED FOR INTERNAL USE. Represents properties for writing to a page blob. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class PageProperties { + + /** + * Gets or sets the type of write operation. + */ + private PageOperationType pageOperation = PageOperationType.UPDATE; + + /** + * Gets or sets the range of bytes to write to. + */ + private PageRange range = new PageRange(-1, -1); + + /** + * Initializes a new instance of the PageProperties class. + */ + public PageProperties() { + // Empty Default Ctor + } + + /** + * @return the pageOperation + */ + public PageOperationType getPageOperation() { + return this.pageOperation; + } + + /** + * @return the range + */ + public PageRange getRange() { + return this.range; + } + + /** + * @param pageOperation + * the pageOperation to set + */ + public void setPageOperation(final PageOperationType pageOperation) { + this.pageOperation = pageOperation; + } + + /** + * @param range + * the range to set + */ + public void setRange(final PageRange range) { + this.range = range; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java new file mode 100644 index 0000000000000..a02ee9d5c6229 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java @@ -0,0 +1,71 @@ +package com.microsoft.windowsazure.services.blob.client; + +/** + * Represents a range of pages in a page blob. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class PageRange { + /** + * Represents the ending offset of the page range. + */ + private long endOffset; + + /** + * Represents the starting offset of the page range. + */ + private long startOffset; + + /** + * Creates an instance of the PageRange class. + * + * @param start + * The starting offset. + * @param end + * The ending offset. + */ + public PageRange(final long start, final long end) { + this.setStartOffset(start); + this.setEndOffset(end); + } + + /** + * @return the endOffset + */ + public long getEndOffset() { + return this.endOffset; + } + + /** + * @return the startOffset + */ + public long getStartOffset() { + return this.startOffset; + } + + /** + * @param endOffset + * the endOffset to set + */ + public void setEndOffset(final long endOffset) { + this.endOffset = endOffset; + } + + /** + * @param startOffset + * the startOffset to set + */ + public void setStartOffset(final long startOffset) { + this.startOffset = startOffset; + } + + /** + * Returns the content of the page range as a string. + * + * @return A String that represents the contents of the page range. + */ + @Override + public String toString() { + return String.format("bytes=%d-%d", this.getStartOffset(), this.getEndOffset()); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java new file mode 100644 index 0000000000000..119039d451d9a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java @@ -0,0 +1,73 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.EnumSet; + +/** + * Specifies the set of possible permissions for a shared access policy. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum SharedAccessPermissions { + /** + * Specifies Read access granted. + */ + READ((byte) 0x1), + + /** + * Specifies Write access granted. + */ + WRITE((byte) 0x2), + + /** + * Specifies Delete access granted for blobs. + */ + DELETE((byte) 0x4), + + /** + * Specifies List access granted. + */ + LIST((byte) 0x8); + + /** + * Returns the enum set representing the shared access permissions for the specified byte value. + * + * @param value + * The byte value to convert to the corresponding enum set. + * @return A java.util.EnumSet object that contains the SharedAccessPermissions values + * corresponding to the specified byte value. + */ + protected static EnumSet fromByte(final byte value) { + final EnumSet retSet = EnumSet.noneOf(SharedAccessPermissions.class); + + if (value == READ.value) { + retSet.add(READ); + } + + if (value == WRITE.value) { + retSet.add(WRITE); + } + if (value == DELETE.value) { + retSet.add(DELETE); + } + if (value == LIST.value) { + retSet.add(LIST); + } + + return retSet; + } + + /** + * Returns the value of this enum. + */ + private byte value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + SharedAccessPermissions(final byte val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java new file mode 100644 index 0000000000000..b86a4c149f731 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java @@ -0,0 +1,161 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.util.Date; +import java.util.EnumSet; + +import com.microsoft.windowsazure.services.core.storage.Constants; + +/** + * Represents a shared access policy, which specifies the start time, expiry time, and permissions for a shared access + * signature. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class SharedAccessPolicy { + + /** + * Assigns shared access permissions using the specified permissions string. + * + * @param value + * A String that represents the shared access permissions. The string must contain one or + * more of the following values. Note they must be lowercase, and the order that they are specified must + * be in the order of "rwdl". + *

    + *
  • d: Delete access.
  • + *
  • l: List access.
  • + *
  • r: Read access.
  • + *
  • w: Write access.
  • + *
+ * + * @return A java.util.EnumSet object that contains {@link SharedAccessPermissions} values that + * represents the set of shared access permissions. + */ + public static EnumSet permissionsFromString(final String value) { + final char[] chars = value.toCharArray(); + final EnumSet retSet = EnumSet.noneOf(SharedAccessPermissions.class); + + for (final char c : chars) { + switch (c) { + case 'r': + retSet.add(SharedAccessPermissions.READ); + break; + case 'w': + retSet.add(SharedAccessPermissions.WRITE); + break; + case 'd': + retSet.add(SharedAccessPermissions.DELETE); + break; + case 'l': + retSet.add(SharedAccessPermissions.LIST); + break; + default: + throw new IllegalArgumentException("value"); + } + } + + return retSet; + } + + /** + * Converts the permissions specified for the shared access policy to a string. + * + * @param permissions + * A {@link SharedAccessPermissions} object that represents the shared access permissions. + * + * @return A String that represents the shared access permissions in the "rwdl" format, which is + * described at {@link SharedAccessPolicy#permissionsFromString}. + */ + public static String permissionsToString(final EnumSet permissions) { + if (permissions == null) { + return Constants.EMPTY_STRING; + } + + // The service supports a fixed order => rwdl + final StringBuilder builder = new StringBuilder(); + + if (permissions.contains(SharedAccessPermissions.READ)) { + builder.append("r"); + } + + if (permissions.contains(SharedAccessPermissions.WRITE)) { + builder.append("w"); + } + + if (permissions.contains(SharedAccessPermissions.DELETE)) { + builder.append("d"); + } + + if (permissions.contains(SharedAccessPermissions.LIST)) { + builder.append("l"); + } + + return builder.toString(); + } + + /** + * The permissions for a shared access signature associated with this shared access policy. + */ + private EnumSet permissions; + + /** + * The expiry time for a shared access signature associated with this shared access policy. + */ + private Date sharedAccessExpiryTime; + + /** + * The start time for a shared access signature associated with this shared access policy. + */ + private Date sharedAccessStartTime; + + /** + * Creates an instance of the SharedAccessPolicy class. + * */ + public SharedAccessPolicy() { + // Empty Default Ctor + } + + /** + * @return the permissions + */ + public EnumSet getPermissions() { + return this.permissions; + } + + /** + * @return the sharedAccessExpiryTime + */ + public Date getSharedAccessExpiryTime() { + return this.sharedAccessExpiryTime; + } + + /** + * @return the sharedAccessStartTime + */ + public Date getSharedAccessStartTime() { + return this.sharedAccessStartTime; + } + + /** + * @param permissions + * the permissions to set + */ + public void setPermissions(final EnumSet permissions) { + this.permissions = permissions; + } + + /** + * @param sharedAccessExpiryTime + * the sharedAccessExpiryTime to set + */ + public void setSharedAccessExpiryTime(final Date sharedAccessExpiryTime) { + this.sharedAccessExpiryTime = sharedAccessExpiryTime; + } + + /** + * @param sharedAccessStartTime + * the sharedAccessStartTime to set + */ + public void setSharedAccessStartTime(final Date sharedAccessStartTime) { + this.sharedAccessStartTime = sharedAccessStartTime; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java new file mode 100644 index 0000000000000..09df6f0020295 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java @@ -0,0 +1,237 @@ +package com.microsoft.windowsazure.services.blob.client; + +import java.security.InvalidKeyException; +import java.util.HashMap; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Contains helper methods for implementing shared access signatures. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class SharedAccessSignatureHelper { + /** + * Get the complete query builder for creating the Shared Access Signature query. + * + * @param policy + * The shared access policy to hash. + * @param groupPolicyIdentifier + * An optional identifier for the policy. + * @param resourceType + * Either "b" for blobs or "c" for containers. + * @param signature + * The signature to use. + * @return The finished query builder + * @throws IllegalArgumentException + * @throws StorageException + */ + protected static UriQueryBuilder generateSharedAccessSignature( + final SharedAccessPolicy policy, final String groupPolicyIdentifier, final String resourceType, + final String signature) throws StorageException { + Utility.assertNotNullOrEmpty("resourceType", resourceType); + Utility.assertNotNull("signature", signature); + + final UriQueryBuilder builder = new UriQueryBuilder(); + if (policy != null) { + String permissions = SharedAccessPolicy.permissionsToString(policy.getPermissions()); + + if (Utility.isNullOrEmpty(permissions)) { + permissions = null; + } + + final String startString = Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()); + if (!Utility.isNullOrEmpty(startString)) { + builder.add(BlobConstants.QueryConstants.SIGNED_START, startString); + } + + final String stopString = Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()); + if (!Utility.isNullOrEmpty(stopString)) { + builder.add(BlobConstants.QueryConstants.SIGNED_EXPIRY, stopString); + } + + if (!Utility.isNullOrEmpty(permissions)) { + builder.add(BlobConstants.QueryConstants.SIGNED_PERMISSIONS, permissions); + } + } + + builder.add(BlobConstants.QueryConstants.SIGNED_RESOURCE, resourceType); + + if (!Utility.isNullOrEmpty(groupPolicyIdentifier)) { + builder.add(BlobConstants.QueryConstants.SIGNED_IDENTIFIER, groupPolicyIdentifier); + } + + if (!Utility.isNullOrEmpty(signature)) { + builder.add(BlobConstants.QueryConstants.SIGNATURE, signature); + } + + return builder; + } + + /** + * Get the signature hash embedded inside the Shared Access Signature. + * + * @param policy + * The shared access policy to hash. + * @param groupPolicyIdentifier + * An optional identifier for the policy. + * @param resourceName + * the resource name. + * @param client + * the CloudBlobClient associated with the object. + * @param opContext + * an object used to track the execution of the operation + * @return the signature hash embedded inside the Shared Access Signature. + * @throws InvalidKeyException + * @throws StorageException + */ + protected static String generateSharedAccessSignatureHash( + final SharedAccessPolicy policy, final String groupPolicyIdentifier, final String resourceName, + final CloudBlobClient client, final OperationContext opContext) + throws InvalidKeyException, StorageException { + Utility.assertNotNullOrEmpty("resourceName", resourceName); + Utility.assertNotNull("client", client); + + String stringToSign = null; + + if (policy == null) { + // Revokable access + Utility.assertNotNullOrEmpty("groupPolicyIdentifier", groupPolicyIdentifier); + stringToSign = + String.format("%s\n%s\n%s\n%s\n%s", + Constants.EMPTY_STRING, + Constants.EMPTY_STRING, + Constants.EMPTY_STRING, + resourceName, + groupPolicyIdentifier); + } else { + // Non Revokable access + if (policy.getSharedAccessExpiryTime() == null) { + throw new IllegalArgumentException("Policy Expiry time is mandatory and cannot be null"); + } + + if (policy.getPermissions() == null) { + throw new IllegalArgumentException("Policy permissions are mandatory and cannot be null"); + } + + stringToSign = + String.format("%s\n%s\n%s\n%s\n%s", + SharedAccessPolicy.permissionsToString(policy.getPermissions()), + Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()), + Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()), + resourceName, + groupPolicyIdentifier == null ? Constants.EMPTY_STRING : groupPolicyIdentifier); + } + + stringToSign = Utility.safeDecode(stringToSign); + final String signature = client.getCredentials().computeHmac256(stringToSign, opContext); + + // add logging + return signature; + } + + /** + * Parses the query parameters and populates a StorageCredentialsSharedAccessSignature object if one is present. + * + * @param queryParams + * the parameters to parse + * @return the StorageCredentialsSharedAccessSignature if one is present, otherwise null + * @throws IllegalArgumentException + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + protected static StorageCredentialsSharedAccessSignature parseQuery(final HashMap queryParams) + throws StorageException { + String signature = null; + String signedStart = null; + String signedExpiry = null; + String signedResource = null; + String sigendPermissions = null; + String signedIdentifier = null; + String signedVersion = null; + + boolean sasParameterFound = false; + + StorageCredentialsSharedAccessSignature credentials = null; + + for (final Entry entry : queryParams.entrySet()) { + final String lowerKey = entry.getKey().toLowerCase(Utility.LOCALE_US); + + if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_START)) { + signedStart = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_EXPIRY)) { + signedExpiry = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_PERMISSIONS)) { + sigendPermissions = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_RESOURCE)) { + signedResource = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_IDENTIFIER)) { + signedIdentifier = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNATURE)) { + signature = entry.getValue()[0]; + sasParameterFound = true; + } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_VERSION)) { + signedVersion = entry.getValue()[0]; + sasParameterFound = true; + } + } + + if (sasParameterFound) { + if (signature == null || signedResource == null) { + final String errorMessage = "Missing mandatory parameters for valid Shared Access Signature"; + throw new IllegalArgumentException(errorMessage); + } + + final UriQueryBuilder builder = new UriQueryBuilder(); + + if (!Utility.isNullOrEmpty(signedStart)) { + builder.add(BlobConstants.QueryConstants.SIGNED_START, signedStart); + } + + if (!Utility.isNullOrEmpty(signedExpiry)) { + builder.add(BlobConstants.QueryConstants.SIGNED_EXPIRY, signedExpiry); + } + + if (!Utility.isNullOrEmpty(sigendPermissions)) { + builder.add(BlobConstants.QueryConstants.SIGNED_PERMISSIONS, sigendPermissions); + } + + builder.add(BlobConstants.QueryConstants.SIGNED_RESOURCE, signedResource); + + if (!Utility.isNullOrEmpty(signedIdentifier)) { + builder.add(BlobConstants.QueryConstants.SIGNED_IDENTIFIER, signedIdentifier); + } + + if (!Utility.isNullOrEmpty(signedVersion)) { + builder.add(BlobConstants.QueryConstants.SIGNED_VERSION, signedVersion); + } + + if (!Utility.isNullOrEmpty(signature)) { + builder.add(BlobConstants.QueryConstants.SIGNATURE, signature); + } + + final String token = builder.toString(); + credentials = new StorageCredentialsSharedAccessSignature(token); + } + + return credentials; + } + + /** + * Private Default Ctor. + */ + private SharedAccessSignatureHelper() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java new file mode 100644 index 0000000000000..1bbc17d3394e2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -0,0 +1,353 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.HttpURLConnection; +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; + +/** + * Represents a set of access conditions to be used for operations against the storage services. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class AccessCondition { + /** + * Generates a new empty AccessCondition. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @return An AccessCondition object that has no conditions set. + */ + public static AccessCondition generateEmptyCondition() { + return new AccessCondition(); + } + + /** + * Returns an access condition such that an operation will be performed only if the resource's ETag value matches + * the specified ETag value. + *

+ * Setting this access condition modifies the request to include the HTTP If-Match conditional header. If + * this access condition is set, the operation is performed only if the ETag of the resource matches the specified + * ETag. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param etag + * A String that represents the ETag value to check. + * + * @return An AccessCondition object that represents the If-Match condition. + */ + public static AccessCondition generateIfMatchCondition(final String etag) { + AccessCondition retCondition = new AccessCondition(); + retCondition.setIfMatch(etag); + return retCondition; + } + + /** + * Returns an access condition such that an operation will be performed only if the resource has been modified since + * the specified time. + *

+ * Setting this access condition modifies the request to include the HTTP If-Modified-Since conditional + * header. If this access condition is set, the operation is performed only if the resource has been modified since + * the specified time. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param lastMotified + * A java.util.Date object that represents the last-modified time to check for the resource. + * + * @return An AccessCondition object that represents the If-Modified-Since condition. + */ + public static AccessCondition generateIfModifiedSinceCondition(final Date lastMotified) { + AccessCondition retCondition = new AccessCondition(); + retCondition.ifModifiedSinceDate = lastMotified; + return retCondition; + } + + /** + * Returns an access condition such that an operation will be performed only if the resource's ETag value does not + * match the specified ETag value. + *

+ * Setting this access condition modifies the request to include the HTTP If-None-Match conditional header. + * If this access condition is set, the operation is performed only if the ETag of the resource does not match the + * specified ETag. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param etag + * A String that represents the ETag value to check. + * + * @return An AccessCondition object that represents the If-None-Match condition. + */ + public static AccessCondition generateIfNoneMatchCondition(final String etag) { + AccessCondition retCondition = new AccessCondition(); + retCondition.setIfNoneMatch(etag); + return retCondition; + } + + /** + * Returns an access condition such that an operation will be performed only if the resource has not been modified + * since the specified time. + *

+ * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional + * header. If this access condition is set, the operation is performed only if the resource has not been modified + * since the specified time. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param lastMotified + * A java.util.Date object that represents the last-modified time to check for the resource. + * + * @return An AccessCondition object that represents the If-Unmodified-Since condition. + */ + public static AccessCondition generateIfNotModifiedSinceCondition(final Date lastMotified) { + AccessCondition retCondition = new AccessCondition(); + retCondition.ifUnmodifiedSinceDate = lastMotified; + return retCondition; + } + + /** + * Returns an access condition such that an operation will be performed only if the resource is accessible under the + * specified lease id. + *

+ * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional + * header. If this access condition is set, the operation is performed only if the resource has not been modified + * since the specified time. + *

+ * For more information, see Specifying + * Conditional Headers for Blob Service Operations. + * + * @param leaseID + * The lease id to specify. + * + */ + public static AccessCondition generateLeaseCondition(final String leaseID) { + AccessCondition retCondition = new AccessCondition(); + retCondition.leaseID = leaseID; + return retCondition; + } + + private String leaseID = null; + + /** + * Represents the etag of the resource for if [none] match conditions + */ + private String etag = null; + + /** + * Represents the date for IfModifiedSince conditions. + */ + private Date ifModifiedSinceDate = null; + + /** + * Represents the date for IfUn,odifiedSince conditions. + */ + private Date ifUnmodifiedSinceDate = null; + + /** + * Represents the ifMatchHeaderType type. + */ + private String ifMatchHeaderType = null; + + /** + * Creates an instance of the AccessCondition class. + */ + public AccessCondition() { + // Empty Default Ctor + } + + /** + * RESERVED FOR INTERNAL USE. Applies the access condition to the request. + * + * @param request + * A java.net.HttpURLConnection object that represents the request to which the condition is + * being applied. + * + * @throws StorageException + * If there is an error parsing the date value of the access condition. + */ + public void applyConditionToRequest(final HttpURLConnection request) { + applyConditionToRequest(request, false); + } + + /** + * RESERVED FOR INTERNAL USE. Applies the access condition to the request. + * + * @param request + * A java.net.HttpURLConnection object that represents the request to which the condition is + * being applied. + * @param useSourceAccessHeaders + * If true will use the Source_ headers for the conditions, otherwise standard headers are used. + * @throws StorageException + * If there is an error parsing the date value of the access condition. + */ + public void applyConditionToRequest(final HttpURLConnection request, boolean useSourceAccessHeaders) { + // When used as a source access condition + if (useSourceAccessHeaders) { + if (!Utility.isNullOrEmpty(this.leaseID)) { + request.setRequestProperty(Constants.HeaderConstants.SOURCE_LEASE_ID_HEADER, this.leaseID); + } + + if (this.ifModifiedSinceDate != null) { + request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, + Utility.getGMTTime(this.ifModifiedSinceDate)); + } + + if (this.ifUnmodifiedSinceDate != null) { + request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, + Utility.getGMTTime(this.ifUnmodifiedSinceDate)); + } + + if (!Utility.isNullOrEmpty(this.etag)) { + if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH)) { + request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_MATCH_HEADER, this.etag); + } else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { + request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, this.etag); + } + } + } else { + if (!Utility.isNullOrEmpty(this.leaseID)) { + BaseRequest.addLeaseId(request, this.leaseID); + } + + if (this.ifModifiedSinceDate != null) { + // The IfModifiedSince has a special helper in HttpURLConnection, use it instead of manually setting the + // header. + request.setIfModifiedSince(this.ifModifiedSinceDate.getTime()); + } + + if (this.ifUnmodifiedSinceDate != null) { + request.setRequestProperty(Constants.HeaderConstants.IF_UNMODIFIED_SINCE, + Utility.getGMTTime(this.ifUnmodifiedSinceDate)); + } + + if (!Utility.isNullOrEmpty(this.etag)) { + request.setRequestProperty(this.ifMatchHeaderType, this.etag); + } + } + } + + /** + * @return the etag when the If-Match condition is set. + */ + public String getIfMatch() { + return this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH) ? this.etag : null; + } + + /** + * @return the ifModifiedSinceDate + */ + public Date getIfModifiedSinceDate() { + return this.ifModifiedSinceDate; + } + + /** + * @return the etag when the If-None-Match condition is set. + */ + public String getIfNoneMatch() { + return this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH) ? this.etag : null; + } + + /** + * @return the ifUnmodifiedSinceDate + */ + public Date getIfUnmodifiedSinceDate() { + return this.ifUnmodifiedSinceDate; + } + + /** + * @return the leaseID + */ + public String getLeaseID() { + return this.leaseID; + } + + /** + * @param etag + * the etag to set + */ + public void setIfMatch(String etag) { + this.etag = etag; + this.ifMatchHeaderType = Constants.HeaderConstants.IF_MATCH; + } + + /** + * @param ifModifiedSinceDate + * the ifModifiedSinceDate to set + */ + public void setIfModifiedSinceDate(Date ifModifiedSinceDate) { + this.ifModifiedSinceDate = ifModifiedSinceDate; + } + + /** + * @param etag + * the etag to set + */ + public void setIfNoneMatch(String etag) { + this.etag = etag; + this.ifMatchHeaderType = Constants.HeaderConstants.IF_NONE_MATCH; + } + + /** + * @param ifUnmodifiedSinceDate + * the ifUnmodifiedSinceDate to set + */ + public void setIfUnmodifiedSinceDate(Date ifUnmodifiedSinceDate) { + this.ifUnmodifiedSinceDate = ifUnmodifiedSinceDate; + } + + /** + * @param leaseID + * the leaseID to set + */ + public void setLeaseID(String leaseID) { + this.leaseID = leaseID; + } + + /** + * Reserved for internal use. Verifies the condition is satisfied. + * + * @param etag + * A String that represents the ETag to check. + * @param lastModified + * A java.util.Date object that represents the last modified date/time. + * + * @return true if the condition is satisfied; otherwise, false. + * + */ + public boolean verifyConditional(final String etag, final Date lastModified) { + if (this.ifModifiedSinceDate != null) { + // The IfModifiedSince has a special helper in HttpURLConnection, use it instead of manually setting the + // header. + if (!lastModified.after(this.ifModifiedSinceDate)) { + return false; + } + } + + if (this.ifUnmodifiedSinceDate != null) { + if (lastModified.after(this.ifUnmodifiedSinceDate)) { + return false; + } + } + + if (!Utility.isNullOrEmpty(this.etag)) { + if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH)) { + if (!this.etag.equals(etag) && !this.etag.equals("*")) { + return false; + } + } else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { + if (this.etag.equals(etag)) { + return false; + } + } + } + + return true; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java new file mode 100644 index 0000000000000..12aff46bea89d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -0,0 +1,686 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.queue.client.CloudQueueClient; + +/** + * Represents a Windows Azure storage account. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudStorageAccount { + /** + * Represents the setting name for the account key. + */ + protected static final String ACCOUNT_KEY_NAME = "AccountKey"; + + /** + * Represents the setting name for the account name. + */ + protected static final String ACCOUNT_NAME_NAME = "AccountName"; + + /** + * The root blob storage DNS name. + */ + private static final String BLOB_BASE_DNS_NAME = "blob.core.windows.net"; + + /** + * Represents the setting name for a custom blob storage endpoint. + */ + protected static final String BLOB_ENDPOINT_NAME = "BlobEndpoint"; + + /** + * The setting name for using the default storage endpoints with the specified protocol. + */ + private static final String DEFAULT_ENDPOINTS_PROTOCOL_NAME = "DefaultEndpointsProtocol"; + + /** + * The setting name for specifying a development storage proxy Uri. + */ + private static final String DEVELOPMENT_STORAGE_PROXY_URI_NAME = "DevelopmentStorageProxyUri"; + /** + * The default account key for the development storage. + */ + private static final String DEVSTORE_ACCOUNT_KEY = + "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; + + /** + * The default account name for the development storage. + */ + private static final String DEVSTORE_ACCOUNT_NAME = "devstoreaccount1"; + + /** + * The credentials string used to test for the development storage credentials. + */ + private static final String DEVSTORE_CREDENTIALS_IN_STRING = CloudStorageAccount.ACCOUNT_NAME_NAME + "=" + + CloudStorageAccount.DEVSTORE_ACCOUNT_NAME + ";" + CloudStorageAccount.ACCOUNT_KEY_NAME + "=" + + CloudStorageAccount.DEVSTORE_ACCOUNT_KEY; + + /** + * A CloudStorageAccount that represents the development storage account. + */ + private static CloudStorageAccount devStoreAccount; + + /** + * Represents the root queue DNS name. + */ + protected static final String QUEUE_BASE_DNS_NAME = "queue.core.windows.net"; + + /** + * Represents the setting name for a custom queue endpoint. + */ + protected static final String QUEUE_ENDPOINT_NAME = "QueueEndpoint"; + + /** + * Represents the setting name for a shared access key. + */ + protected static final String SHARED_ACCESS_SIGNATURE_NAME = "SharedAccessSignature"; + + /** + * Represents the root table storage DNS name. + */ + protected static final String TABLE_BASE_DNS_NAME = "table.core.windows.net"; + + /** + * Represents the setting name for a custom table storage endpoint. + */ + protected static final String TABLE_ENDPOINT_NAME = "TableEndpoint"; + + /** + * The setting name for using the development storage. + */ + private static final String USE_DEVELOPMENT_STORAGE_NAME = "UseDevelopmentStorage"; + + /** + * Gets the default blob endpoint using specified settings. + * + * @param settings + * The settings to use + * @return The default blob endpoint. + */ + private static String getDefaultBlobEndpoint(final HashMap settings) { + final String scheme = + settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + final String accountName = + settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + + return getDefaultBlobEndpoint(scheme, accountName); + } + + /** + * Gets the default blob endpoint using the specified protocol and account name. + * + * @param scheme + * The protocol to use. + * @param accountName + * The name of the storage account. + * @return The default blob endpoint. + */ + private static String getDefaultBlobEndpoint(final String scheme, final String accountName) { + return String.format("%s://%s.%s", scheme, accountName, BLOB_BASE_DNS_NAME); + } + + /** + * Gets the default queue endpoint using the specified settings. + * + * @param settings + * The settings. + * @return The default queue endpoint. + */ + private static String getDefaultQueueEndpoint(final HashMap settings) { + final String scheme = + settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + + final String accountName = + settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + + return getDefaultQueueEndpoint(scheme, accountName); + } + + /** + * Gets the default queue endpoint using the specified protocol and account name. + * + * @param scheme + * The protocol to use. + * @param accountName + * The name of the storage account. + * @return The default queue endpoint. + */ + private static String getDefaultQueueEndpoint(final String scheme, final String accountName) { + return String.format("%s://%s.%s", scheme, accountName, QUEUE_BASE_DNS_NAME); + } + + /** + * Gets the default table endpoint using the specified settings. + * + * @param settings + * The settings. + * @return The default table endpoint. + */ + private static String getDefaultTableEndpoint(final HashMap settings) { + final String scheme = + settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + final String accountName = + settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + + return getDefaultTableEndpoint(scheme, accountName); + } + + /** + * Gets the default table endpoint using the specified protocol and account name. + * + * @param scheme + * The protocol to use. + * @param accountName + * The name of the storage account. + * @return The default table endpoint, + */ + private static String getDefaultTableEndpoint(final String scheme, final String accountName) { + return String.format("%s://%s.%s", scheme, accountName, TABLE_BASE_DNS_NAME); + } + + /** + * Returns a {@link CloudStorageAccount} object that represents the development storage credentials. + * + * @return A {@link CloudStorageAccount} object for the development storage credentials. + */ + public static CloudStorageAccount getDevelopmentStorageAccount() { + if (devStoreAccount == null) { + try { + devStoreAccount = getDevelopmentStorageAccount(new URI("http://127.0.0.1")); + } catch (final URISyntaxException e) { + // this wont happen since we know the uri above. + } + } + return devStoreAccount; + } + + /** + * Returns a {@link CloudStorageAccount} object that represents the development storage credentials, using the + * specified proxy URI. + * + * @param proxyUri + * A java.net.URI object that represents the proxy endpoint to use. + * + * @return A {@link CloudStorageAccount} object for the development storage credentials. + * + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public static CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUri) throws URISyntaxException { + if (proxyUri == null) { + return getDevelopmentStorageAccount(); + } + + String prefix = proxyUri.getScheme().concat("://"); + prefix = prefix.concat(proxyUri.getHost()); + + return new CloudStorageAccount( + new StorageCredentialsAccountAndKey(DEVSTORE_ACCOUNT_NAME, DEVSTORE_ACCOUNT_KEY), new URI( + prefix.concat(":10000/devstoreaccount1")), new URI(prefix.concat(":10001/devstoreaccount1")), + new URI(prefix.concat(":10002/devstoreaccount1"))); + + } + + /** + * Parses a connection string and returns a cloud storage account created from the connection string. + *

+ * Note this method is not supported for shared access signature credentials as they do not contain the required + * endpoint configuration parameters. + * + * @param connectionString + * A String that represents the connection string to parse. + * + * @return A {@link CloudStorageAccount} object that represents the cloud storage account constructed from the + * values provided in the connection string. + * + * @throws InvalidKeyException + * If credentials in the connection string contain an invalid key. + * @throws URISyntaxException + * If the connection string specifies an invalid URI. + */ + public static CloudStorageAccount parse(final String connectionString) + throws URISyntaxException, InvalidKeyException { + if (connectionString == null || connectionString.length() == 0) { + throw new IllegalArgumentException("Invalid Connection String"); + } + + // 1. Parse connection string in to key / value pairs + final HashMap settings = Utility.parseAccountString(connectionString); + + // 2 Validate General Settings rules, + // - only setting value per key + // - setting must have value + for (final Entry entry : settings.entrySet()) { + if (entry.getValue() == null || entry.getValue().equals(Constants.EMPTY_STRING)) { + throw new IllegalArgumentException("Invalid Connection String"); + } + } + + // 3. Validate scenario specific constraints + CloudStorageAccount retVal = tryConfigureDevStore(settings); + if (retVal != null) { + return retVal; + } + + retVal = tryConfigureServiceAccount(settings); + if (retVal != null) { + return retVal; + } + + throw new IllegalArgumentException("Invalid Connection String"); + } + + /** + * Evaluates connection settings and returns a CloudStorageAccount representing Development Storage. + * + * @param settings + * A Hashmap of key value pairs representing the connection. + * @return A CloudStorageAccount object constructed from the values provided in the connection settings, or null if + * one cannot be constructed. + * @throws URISyntaxException + * if the connection settings contains an invalid URI + */ + private static CloudStorageAccount tryConfigureDevStore(final HashMap settings) + throws URISyntaxException { + if (settings.containsKey(USE_DEVELOPMENT_STORAGE_NAME)) { + final String useDevStoreSetting = settings.get(USE_DEVELOPMENT_STORAGE_NAME); + URI devStoreProxyUri = null; + + if (!Boolean.parseBoolean(useDevStoreSetting)) { + return null; + } + + if (settings.containsKey(DEVELOPMENT_STORAGE_PROXY_URI_NAME)) { + devStoreProxyUri = new URI(settings.get(DEVELOPMENT_STORAGE_PROXY_URI_NAME)); + } + + return getDevelopmentStorageAccount(devStoreProxyUri); + + } else { + return null; + } + } + + /** + * Evaluates connection settings and configures a CloudStorageAccount accordingly. + * + * @param settings + * A Hashmap of key value pairs representing the connection. + * @return A CloudStorageAccount represented by the settings. + * @throws URISyntaxException + * if the connectionString specifies an invalid URI. + * @throws InvalidKeyException + * if credentials in the connection settings contain an invalid key. + */ + private static CloudStorageAccount tryConfigureServiceAccount(final HashMap settings) + throws URISyntaxException, InvalidKeyException { + + final String defaultEndpointSetting = + settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME).toLowerCase() : null; + + if (defaultEndpointSetting != null && !defaultEndpointSetting.equals(Constants.HTTP) + && !defaultEndpointSetting.equals(Constants.HTTPS)) { + return null; + } + + final StorageCredentials credentials = StorageCredentials.tryParseCredentials(settings); + final URI blobURI = + settings.containsKey(CloudStorageAccount.BLOB_ENDPOINT_NAME) ? new URI( + settings.get(CloudStorageAccount.BLOB_ENDPOINT_NAME)) : null; + final URI queueURI = + settings.containsKey(CloudStorageAccount.QUEUE_ENDPOINT_NAME) ? new URI( + settings.get(CloudStorageAccount.QUEUE_ENDPOINT_NAME)) : null; + final URI tableURI = + settings.containsKey(CloudStorageAccount.TABLE_ENDPOINT_NAME) ? new URI( + settings.get(CloudStorageAccount.TABLE_ENDPOINT_NAME)) : null; + + if (credentials != null) { + // Automatic endpoint Case + if (defaultEndpointSetting != null && settings.containsKey(CloudStorageAccount.ACCOUNT_NAME_NAME) + && settings.containsKey(CloudStorageAccount.ACCOUNT_KEY_NAME)) { + return new CloudStorageAccount(credentials, blobURI == null ? new URI(getDefaultBlobEndpoint(settings)) + : blobURI, queueURI == null ? new URI(getDefaultQueueEndpoint(settings)) : queueURI, + tableURI == null ? new URI(getDefaultTableEndpoint(settings)) : tableURI); + } + + // Explicit endpoint Case + if (settings.containsKey(CloudStorageAccount.BLOB_ENDPOINT_NAME) + || settings.containsKey(CloudStorageAccount.QUEUE_ENDPOINT_NAME) + || settings.containsKey(CloudStorageAccount.TABLE_ENDPOINT_NAME)) { + return new CloudStorageAccount(credentials, blobURI, queueURI, tableURI); + } + } + + return null; + } + + /** + * The internal Blob endpoint. + */ + private final URI blobEndpoint; + + /** + * The internal Storage Credentials. + */ + private StorageCredentials credentials; + + /** + * The internal Queue endpoint. + */ + private final URI queueEndpoint; + + /** + * The internal Table endpoint. + */ + private final URI tableEndpoint; + + /** + * Creates an instance of the CloudStorageAccount class using the specified account credentials. + *

+ * With this constructor, the CloudStorageAccount object is constructed using the default HTTP storage + * service endpoints. The default HTTP storage service endpoints are + * http://myaccount.blob.core.windows.net, + * http://myaccount.queue.core.windows.net, and + * http://myaccount.table.core.windows.net, where myaccount is the name of + * your storage account. + *

+ * The credentials provided when constructing the CloudStorageAccount object are used to authenticate + * all further requests against resources that are accessed via the CloudStorageAccount object or a + * client object created from it. A client object may be a {@link CloudBlobClient} object. + * + * @param storageCredentials + * A {@link StorageCredentials} object that represents the storage credentials to use to authenticate + * this account. + * + * @throws URISyntaxException + * If storageCredentials specify an invalid account name. + */ + public CloudStorageAccount(final StorageCredentials storageCredentials) throws URISyntaxException { + this.credentials = storageCredentials; + + this.blobEndpoint = new URI(getDefaultBlobEndpoint(Constants.HTTP, this.credentials.getAccountName())); + + this.queueEndpoint = new URI(getDefaultQueueEndpoint(Constants.HTTP, this.credentials.getAccountName())); + + this.tableEndpoint = new URI(getDefaultTableEndpoint(Constants.HTTP, this.credentials.getAccountName())); + } + + /** + * Creates an instance of the CloudStorageAccount class using the specified account credentials and + * service endpoints. + *

+ * Use this constructor to construct a CloudStorageAccount object using custom endpoints, in the case + * where you've configured a custom domain name for your storage account. + *

+ * The credentials provided when constructing the CloudStorageAccount object are used to authenticate + * all further requests against resources that are accessed via the CloudStorageAccount object or a + * client object created from it. A client object may be a {@link CloudBlobClient} object. + * + * @param storageCredentials + * A {@link StorageCredentials} object that represents the storage credentials to use to authenticate + * this account. + * @param blobEndpoint + * A java.net.URI object that represents the Blob service endpoint. + * @param queueEndpoint + * A java.net.URI object that represents the Queue service endpoint. + * @param tableEndpoint + * A java.net.URI object that represents the Table service endpoint. + */ + public CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, + final URI queueEndpoint, final URI tableEndpoint) { + this.credentials = storageCredentials; + this.blobEndpoint = blobEndpoint; + this.queueEndpoint = queueEndpoint; + this.tableEndpoint = tableEndpoint; + } + + /** + * Creates an instance of the CloudStorageAccount class using the specified account credentials and the + * default service endpoints, using HTTP or HTTPS as specified. + *

+ * With this constructor, the CloudStorageAccount object is constructed using the default storage + * service endpoints. The default storage service endpoints are + * [http|https]://myaccount.blob.core.windows.net; + * [http|https]://myaccount.queue.core.windows.net; and + * [http|https]://myaccount.table.core.windows.net, where myaccount is the + * name of your storage account. Access to the cloud storage account may be via HTTP or HTTPS, as specified by the + * useHttps parameter. + *

+ * The credentials provided when constructing the CloudStorageAccount object are used to authenticate + * all further requests against resources that are accessed via the CloudStorageAccount object or a + * client object created from it. A client object may be a {@link CloudBlobClient} object. + * + * @param storageCredentials + * A {@link StorageCredentialsAccountAndKey} object that represents the storage credentials to use to + * authenticate this account. + * @param useHttps + * true to use HTTPS to connect to the storage service endpoints; otherwise, + * false. + * + * @throws URISyntaxException + * If storageCredentials specify an invalid account name. + */ + + // In order to call another constructor the this() must be the first + // statement and cannot be wrapped with a try catch + // as such, the URI constructors could technically throw a + // URISyntaxException, but wont since we are using our internal default + // endpoints. + // We are forced to document the URISyntaxException as a throws, but it + // won't ever really happen. + + // Also eclipse's auto formatting below is horrible + public CloudStorageAccount(final StorageCredentialsAccountAndKey storageCredentials, final Boolean useHttps) + throws URISyntaxException { + this(storageCredentials, new URI(getDefaultBlobEndpoint(useHttps ? Constants.HTTPS : Constants.HTTP, + storageCredentials.getAccountName())), new URI(getDefaultQueueEndpoint(useHttps ? Constants.HTTPS + : Constants.HTTP, storageCredentials.getAccountName())), new URI( + getDefaultTableEndpoint(useHttps ? Constants.HTTPS : Constants.HTTP, + storageCredentials.getAccountName()))); + } + + /** + * Creates a new Blob service client. + * + * @return A {@link CloudBlobClient} that represents the cloud blob client. + * + */ + public CloudBlobClient createCloudBlobClient() { + if (this.getBlobEndpoint() == null) { + throw new IllegalArgumentException("No blob endpoint configured."); + } + + if (this.credentials == null) { + throw new IllegalArgumentException("No credentials provided."); + } + + if (!this.credentials.canCredentialsSignRequest()) { + throw new IllegalArgumentException("CloudBlobClient requires a credential that can sign request"); + } + return new CloudBlobClient(this.getBlobEndpoint(), this.getCredentials()); + } + + /** + * Creates a new queue service client. + * + * @return A client object that uses the Queue service endpoint. + */ + public CloudQueueClient createCloudQueueClient() { + if (this.getQueueEndpoint() == null) { + throw new IllegalArgumentException("No queue endpoint configured."); + } + + if (this.credentials == null) { + throw new IllegalArgumentException("No credentials provided."); + } + + if (!this.credentials.canCredentialsSignRequest()) { + throw new IllegalArgumentException("CloudQueueClient requires a credential that can sign request"); + } + return new CloudQueueClient(this.getQueueEndpoint(), this.getCredentials()); + } + + /** + * Returns the endpoint for the Blob service, as configured for the storage account. This method is not supported + * when using shared access signature credentials. + * + * @return A java.net.URI object that represents the blob endpoint associated with this account. + */ + public URI getBlobEndpoint() { + if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { + throw new IllegalArgumentException( + "Endpoint information not available for Account using Shared Access Credentials."); + } + + return this.blobEndpoint; + } + + /** + * Returns the credentials for the Blob service, as configured for the storage account. + * + * @return A {@link StorageCredentials} object that represents the credentials for this storage account. + */ + public StorageCredentials getCredentials() { + return this.credentials; + } + + /** + * Returns the endpoint for the Queue service, as configured for the storage account. + * + * @return A java.net.URI object that represents the queue endpoint associated with this account. + */ + public URI getQueueEndpoint() { + if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { + throw new IllegalArgumentException( + "Endpoint information not available for Account using Shared Access Credentials."); + } + + return this.queueEndpoint; + } + + /** + * Returns the endpoint for the table service, as configured for the storage account. + * + * @return A java.net.URI object that represents the table endpoint associated with this account. + */ + public URI getTableEndpoint() { + if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { + throw new IllegalArgumentException( + "Endpoint information not available for Account using Shared Access Credentials."); + } + + return this.tableEndpoint; + } + + // + // Sets the StorageCredentials to use with this account. Warning internal + // use only, updating the credentials to a new account can potentially + // invalidate a bunch of pre-existingobjects. + // + // @param credentials + // the credentials to set + // + /** + * Reserved for internal use. + * + * @param credentials + * Reserved. + */ + protected void setCredentials(final StorageCredentials credentials) { + this.credentials = credentials; + } + + /** + * Returns a connection string for this storage account, without sensitive data. + * + * @return A String that represents the connection string for this storage account, without sensitive + * data. + */ + @Override + public String toString() { + return this.toString(false); + } + + /** + * Returns a connection string for this storage account, optionally with sensitive data. + * + * @return A String that represents the connection string for this storage account, optionally with + * sensitive data. + * @param exportSecrets + * true to include sensitive data in the string; otherwise, false. + */ + public String toString(final Boolean exportSecrets) { + if (this.credentials != null && Utility.isNullOrEmpty(this.credentials.getAccountName())) { + return this.credentials.toString(exportSecrets); + } + + final ArrayList retVals = new ArrayList(); + if (this == devStoreAccount) { + retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); + } else if (this.credentials != null && DEVSTORE_ACCOUNT_NAME.equals(this.credentials.getAccountName()) + && this.credentials.toString(true).equals(CloudStorageAccount.DEVSTORE_CREDENTIALS_IN_STRING) + && this.blobEndpoint != null + && this.getBlobEndpoint().getHost().equals(this.getQueueEndpoint().getHost()) + && this.getQueueEndpoint().getHost().equals(this.getTableEndpoint().getHost()) + && this.getBlobEndpoint().getScheme().equals(this.getQueueEndpoint().getScheme()) + && this.getQueueEndpoint().getScheme().equals(this.getTableEndpoint().getScheme())) { + retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); + retVals.add(String.format("%s=%s://%s", DEVELOPMENT_STORAGE_PROXY_URI_NAME, this.getBlobEndpoint() + .getScheme(), this.getBlobEndpoint().getHost())); + } else if (this.getBlobEndpoint().getHost().endsWith(BLOB_BASE_DNS_NAME) + && this.getQueueEndpoint().getHost().endsWith(QUEUE_BASE_DNS_NAME) + && this.getTableEndpoint().getHost().endsWith(TABLE_BASE_DNS_NAME) + && this.getBlobEndpoint().getScheme().equals(this.getQueueEndpoint().getScheme()) + && this.getQueueEndpoint().getScheme().equals(this.getTableEndpoint().getScheme())) { + retVals.add(String.format("%s=%s", DEFAULT_ENDPOINTS_PROTOCOL_NAME, this.getBlobEndpoint().getScheme())); + if (this.getCredentials() != null) { + retVals.add(this.getCredentials().toString(exportSecrets)); + } + } else { + if (this.getBlobEndpoint() != null) { + retVals.add(String.format("%s=%s", BLOB_ENDPOINT_NAME, this.getBlobEndpoint())); + } + + if (this.getQueueEndpoint() != null) { + retVals.add(String.format("%s=%s", QUEUE_ENDPOINT_NAME, this.getQueueEndpoint())); + } + + if (this.getTableEndpoint() != null) { + retVals.add(String.format("%s=%s", TABLE_ENDPOINT_NAME, this.getTableEndpoint())); + } + + if (this.getCredentials() != null) { + retVals.add(this.getCredentials().toString(exportSecrets)); + } + } + + final StringBuilder returnString = new StringBuilder(); + for (final String val : retVals) { + returnString.append(val); + returnString.append(';'); + } + + // Remove trailing ';' + if (retVals.size() > 0) { + returnString.deleteCharAt(returnString.length() - 1); + } + + return returnString.toString(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java new file mode 100644 index 0000000000000..0295b12044846 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -0,0 +1,457 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Defines constants for use with blob operations, HTTP headers, and query strings. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class Constants { + /** + * Defines constants for use Analytics requests. + */ + public static class AnalyticsConstants { + /** + * The XML element for the Analytics RetentionPolicy Days. + */ + public static final String DAYS_ELEMENT = "Days"; + + /** + * The XML element for the Default Service Version. + */ + public static final String DEFAULT_SERVICE_VERSION = "DefaultServiceVersion"; + + /** + * The XML element for the Analytics Logging Delete type. + */ + public static final String DELETE_ELEMENT = "Delete"; + + /** + * The XML element for the Analytics RetentionPolicy Enabled. + */ + public static final String ENABLED_ELEMENT = "Enabled"; + + /** + * The XML element for the Analytics Metrics IncludeAPIs. + */ + public static final String INCLUDE_APIS_ELEMENT = "IncludeAPIs"; + + /** + * The XML element for the Analytics Logging + */ + public static final String LOGGING_ELEMENT = "Logging"; + + /** + * The XML element for the Analytics Metrics + */ + public static final String METRICS_ELEMENT = "Metrics"; + + /** + * The XML element for the Analytics Logging Read type. + */ + public static final String READ_ELEMENT = "Read"; + + /** + * The XML element for the Analytics RetentionPolicy. + */ + public static final String RETENTION_POLICY_ELEMENT = "RetentionPolicy"; + + /** + * The XML element for the StorageServiceProperties + */ + public static final String STORAGE_SERVICE_PROPERTIES_ELEMENT = "StorageServiceProperties"; + + /** + * The XML element for the Analytics Version + */ + public static final String VERSION_ELEMENT = "Version"; + + /** + * The XML element for the Analytics Logging Write type. + */ + public static final String WRITE_ELEMENT = "Write"; + } + + /** + * Defines constants for use with HTTP headers. + */ + public static class HeaderConstants { + /** + * The Accept header. + */ + public static final String ACCEPT = "Accept"; + + /** + * The Accept header. + */ + public static final String ACCEPT_CHARSET = "Accept-Charset"; + + /** + * The Authorization header. + */ + public static final String AUTHORIZATION = "Authorization"; + + /** + * The CacheControl header. + */ + public static final String CACHE_CONTROL = "Cache-Control"; + + /** + * The header that specifies blob caching control. + */ + public static final String CACHE_CONTROL_HEADER = PREFIX_FOR_STORAGE_HEADER + "blob-cache-control"; + + /** + * The Comp value. + */ + public static final String COMP = "comp"; + + /** + * The ContentEncoding header. + */ + public static final String CONTENT_ENCODING = "Content-Encoding"; + + /** + * The ContentLangauge header. + */ + public static final String CONTENT_LANGUAGE = "Content-Language"; + + /** + * The ContentLength header. + */ + public static final String CONTENT_LENGTH = "Content-Length"; + + /** + * The ContentMD5 header. + */ + public static final String CONTENT_MD5 = "Content-MD5"; + + /** + * The ContentRange header. + */ + public static final String CONTENT_RANGE = "Cache-Range"; + + /** + * The ContentType header. + */ + public static final String CONTENT_TYPE = "Content-Type"; + + /** + * The header for copy source. + */ + public static final String COPY_SOURCE_HEADER = PREFIX_FOR_STORAGE_HEADER + "copy-source"; + + /** + * The header that specifies the date. + */ + public static final String DATE = PREFIX_FOR_STORAGE_HEADER + "date"; + + /** + * The header to delete snapshots. + */ + public static final String DELETE_SNAPSHOT_HEADER = PREFIX_FOR_STORAGE_HEADER + "delete-snapshots"; + + /** + * The ETag header. + */ + public static final String ETAG = "ETag"; + + /** + * Buffer width used to copy data to output streams. + */ + public static final int HTTP_UNUSED_306 = 306; + + /** + * The IfMatch header. + */ + public static final String IF_MATCH = "If-Match"; + + /** + * The IfModifiedSince header. + */ + public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; + + /** + * The IfNoneMatch header. + */ + public static final String IF_NONE_MATCH = "If-None-Match"; + + /** + * The IfUnmodifiedSince header. + */ + public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; + + /** + * The header that specifies lease ID. + */ + public static final String LEASE_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "lease-id"; + + /** + * The header that specifies lease status. + */ + public static final String LEASE_STATUS = PREFIX_FOR_STORAGE_HEADER + "lease-status"; + + /** + * The header prefix for metadata. + */ + public static final String PREFIX_FOR_STORAGE_METADATA = "x-ms-meta-"; + + /** + * The header prefix for properties. + */ + public static final String PREFIX_FOR_STORAGE_PROPERTIES = "x-ms-prop-"; + + /** + * The Range header. + */ + public static final String RANGE = "Range"; + + /** + * The header that specifies if the request will populate the ContentMD5 header for range gets. + */ + public static final String RANGE_GET_CONTENT_MD5 = PREFIX_FOR_STORAGE_HEADER + "range-get-content-md5"; + + /** + * The format string for specifying ranges. + */ + public static final String RANGE_HEADER_FORMAT = "bytes=%d-%d"; + + /** + * The header that indicates the request ID. + */ + public static final String REQUEST_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "request-id"; + + /** + * The header for the If-Match condition. + */ + public static final String SOURCE_IF_MATCH_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-if-match"; + + /** + * The header for the If-Modified-Since condition. + */ + public static final String SOURCE_IF_MODIFIED_SINCE_HEADER = PREFIX_FOR_STORAGE_HEADER + + "source-if-modified-since"; + + /** + * The header for the If-None-Match condition. + */ + public static final String SOURCE_IF_NONE_MATCH_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-if-none-match"; + + /** + * The header for the If-Unmodified-Since condition. + */ + public static final String SOURCE_IF_UNMODIFIED_SINCE_HEADER = PREFIX_FOR_STORAGE_HEADER + + "source-if-unmodified-since"; + + /** + * The header for the source lease id. + */ + public static final String SOURCE_LEASE_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-lease-id"; + + /** + * The header for data ranges. + */ + public static final String STORAGE_RANGE_HEADER = PREFIX_FOR_STORAGE_HEADER + "range"; + + /** + * The header for storage version. + */ + public static final String STORAGE_VERSION_HEADER = PREFIX_FOR_STORAGE_HEADER + "version"; + + /** + * The current storage version header value. + */ + public static final String TARGET_STORAGE_VERSION = "2011-08-18"; + + /** + * The UserAgent header. + */ + public static final String USER_AGENT = "User-Agent"; + + /** + * Specifies the value to use for UserAgent header. + */ + public static final String USER_AGENT_PREFIX = "WA-Storage"; + + /** + * Specifies the value to use for UserAgent header. + */ + public static final String USER_AGENT_VERSION = "Client v0.1"; + } + + /** + * The master Windows Azure Storage header prefix. + */ + public static final String PREFIX_FOR_STORAGE_HEADER = "x-ms-"; + + /** + * Constant representing a kilobyte (Non-SI version). + */ + public static final int KB = 1024; + + /** + * Constant representing a megabyte (Non-SI version). + */ + public static final int MB = 1024 * KB; + + /** + * Constant representing a gigabyte (Non-SI version). + */ + public static final int GB = 1024 * MB; + + /** + * Buffer width used to copy data to output streams. + */ + public static final int BUFFER_COPY_LENGTH = 8 * KB; + + /** + * Default client side timeout, in milliseconds, for all service clients. + */ + public static final int DEFAULT_TIMEOUT_IN_MS = 90 * 1000; + + /** + * XML element for delimiters. + */ + public static final String DELIMITER_ELEMENT = "Delimiter"; + + /** + * An empty String to use for comparison. + */ + public static final String EMPTY_STRING = ""; + + /** + * XML element for page range end elements. + */ + public static final String END_ELEMENT = "End"; + + /** + * XML element for error codes. + */ + public static final String ERROR_CODE = "Code"; + + /** + * XML element for exception details. + */ + public static final String ERROR_EXCEPTION = "ExceptionDetails"; + + /** + * XML element for exception messages. + */ + public static final String ERROR_EXCEPTION_MESSAGE = "ExceptionMessage"; + + /** + * XML element for stack traces. + */ + public static final String ERROR_EXCEPTION_STACK_TRACE = "StackTrace"; + + /** + * XML element for error messages. + */ + public static final String ERROR_MESSAGE = "Message"; + + /** + * XML root element for errors. + */ + public static final String ERROR_ROOT_ELEMENT = "Error"; + + /** + * XML element for the ETag. + */ + public static final String ETAG_ELEMENT = "Etag"; + + /** + * Constant for False. + */ + public static final String FALSE = "false"; + + /** + * Specifies HTTP. + */ + public static final String HTTP = "http"; + + /** + * Specifies HTTPS. + */ + public static final String HTTPS = "https"; + + /** + * XML attribute for IDs. + */ + public static final String ID = "Id"; + + /** + * XML element for an invalid metadata name. + */ + public static final String INVALID_METADATA_NAME = "x-ms-invalid-name"; + + /** + * XML element for the last modified date. + */ + public static final String LAST_MODIFIED_ELEMENT = "Last-Modified"; + + /** + * XML element for the lease status. + */ + public static final String LEASE_STATUS_ELEMENT = "LeaseStatus"; + + /** + * Constant signaling the resource is locked. + */ + public static final String LOCKED_VALUE = "Locked"; + + /** + * XML element for a marker. + */ + public static final String MARKER_ELEMENT = "Marker"; + + /** + * XML element for maximum results. + */ + public static final String MAX_RESULTS_ELEMENT = "MaxResults"; + + /** + * Number of default concurrent requests for parallel operation. + */ + public static final int MAXIMUM_SEGMENTED_RESULTS = 5000; + + /** + * XML element for the metadata. + */ + public static final String METADATA_ELEMENT = "Metadata"; + + /** + * XML element for names. + */ + public static final String NAME_ELEMENT = "Name"; + + /** + * XML element for the next marker. + */ + public static final String NEXT_MARKER_ELEMENT = "NextMarker"; + + /** + * XML element for a prefix. + */ + public static final String PREFIX_ELEMENT = "Prefix"; + + /** + * Constant for True. + */ + public static final String TRUE = "true"; + + /** + * Constant signaling the resource is unlocked. + */ + public static final String UNLOCKED_VALUE = "Unlocked"; + + /** + * XML element for the URL. + */ + public static final String URL_ELEMENT = "Url"; + + /** + * Private Default Ctor + */ + private Constants() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java new file mode 100644 index 0000000000000..eb3fd1c792cdb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java @@ -0,0 +1,106 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import com.microsoft.windowsazure.services.core.storage.utils.Base64; + +/** + * Represents the credentials used to sign a request against the storage services. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class Credentials { + /** + * Stores the Account name for the credentials. + */ + private String accountName; + + /** + * Stores the StorageKey for the credentials. + */ + private final StorageKey key; + + /** + * Creates an instance of the Credentials class, using the specified storage account name and access + * key; the specified access key is in the form of a byte array. + * + * @param accountName + * A String that represents the name of the storage account. + * @param key + * An array of bytes that represent the account access key. + * + */ + public Credentials(final String accountName, final byte[] key) { + if (accountName == null || accountName.length() == 0) { + throw new IllegalArgumentException("Invalid accountName"); + } + + if (key == null) { + throw new IllegalArgumentException("Invalid key"); + } + + this.accountName = accountName; + this.key = new StorageKey(key); + } + + /** + * Creates an instance of the Credentials class, using the specified storage account name and access + * key; the specified access key is stored as a String. + * + * @param accountName + * A String that represents the name of the storage account. + * @param key + * A String that represents the Base-64-encoded account access key. + * + */ + public Credentials(final String accountName, final String key) { + this(accountName, Base64.decode(key)); + } + + /** + * Exports the value of the access key to a Base64-encoded string. + * + * @return A String that represents the Base64-encoded access key. + */ + public String exportBase64EncodedKey() { + return this.getKey().getBase64EncodedKey(); + } + + /** + * Exports the value of the access key to an array of bytes. + * + * @return A byte array that represents the access key. + */ + public byte[] exportKey() { + return this.getKey().getKey(); + } + + /** + * Returns the account name to be used in signing the request. + * + * @return A String that represents the account name to be used in signing the request. + */ + public String getAccountName() { + return this.accountName; + } + + /** + * Returns the access key to be used in signing the request. + * + * @return A String that represents the access key to be used in signing the request. + */ + public StorageKey getKey() { + return this.key; + } + + /** + * Sets the account name to be used in signing the request. + * + * @param accountName + * A String that represents the account name being set. + */ + protected void setAccountName(final String accountName) { + this.accountName = accountName; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java new file mode 100644 index 0000000000000..b7268b5bc0277 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java @@ -0,0 +1,19 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * An attribute used to describe a method that will make a request to the storage service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface DoesServiceRequest { + // No attributes +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java new file mode 100644 index 0000000000000..9aeae0c0e7212 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java @@ -0,0 +1,20 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * + * Abstract class that represents a generic event listener. + * + * @param + * The type of the event to be received. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class EventListener { + /** + * Represents an event that occurred. + * + * @param eventArg + * The event object. + */ + public abstract void eventOccurred(T eventArg); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java new file mode 100644 index 0000000000000..574566050b16b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java @@ -0,0 +1,62 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.ArrayList; + +/** + * Represents a generic event multi-caster that allows event listeners to be dynamically added and removed. + * + * @param + * An object that represents the type of the event. + * @param + * An object that represents the type of the event listener. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class EventListenerMultiCaster> { + + /** + * Holds the list of listeners. + */ + private final ArrayList listeners = new ArrayList(); + + /** + * Adds a listener to the event chain. + * + * @param listener + * An EventListenerType object that represents the listener to add. + */ + public synchronized void addListener(final EVENT_LISTENTER_TYPE listener) { + this.listeners.add(listener); + } + + /** + * Fires the event to all subscribed event listeners. + * + * @param event + * An EVENTTYPEobject that represents the event being multi-casted. + */ + public synchronized void fireEvent(final EVENT_TYPE event) { + for (final EventListener listener : this.listeners) { + listener.eventOccurred(event); + } + } + + /** + * Returns a value that indicates whether any event listeners are registered for events. + * + * @return true if any event listeners are registered; otherwise, false. + */ + public synchronized boolean hasListeners() { + return this.listeners.size() > 0; + } + + /** + * Removes an event listener from the event chain. + * + * @param listener + * An EventListenerType object that represents the listener to remove. + */ + public synchronized void removeListener(final EVENT_LISTENTER_TYPE listener) { + this.listeners.remove(listener); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java new file mode 100644 index 0000000000000..9ed740ee765de --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java @@ -0,0 +1,53 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.Locale; + +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Specifies the lease status of a blob. + *

+ * You can check the lease status of a blob to determine whether it currently has an active lease (locked for + * exclusive-write access), or whether it is available for exclusive-write access. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum LeaseStatus { + /** + * Specifies the blob is locked for exclusive-write access. + */ + LOCKED, + + /** + * Specifies the blob is available to be locked for exclusive-write access. + */ + UNLOCKED, + + /** + * Specifies the lease status is not specified. + */ + UNSPECIFIED; + + /** + * Parses a lease status from the given string. + * + * @param typeString + * A String that represents the string to parse. + * + * @return A LeaseStatus value that represents the lease status. + */ + public static LeaseStatus parse(final String typeString) { + if (Utility.isNullOrEmpty(typeString)) { + return UNSPECIFIED; + } else if ("unlocked".equals(typeString.toLowerCase(Locale.US))) { + return UNLOCKED; + } else if ("locked".equals(typeString.toLowerCase(Locale.US))) { + return LOCKED; + } else { + return UNSPECIFIED; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java new file mode 100644 index 0000000000000..3c6eecff13ddf --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java @@ -0,0 +1,24 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * + * Specifies which types of operations the service should log. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum LoggingOperations { + /** + * Log Read Operations . + */ + READ, + + /** + * Log Write Operations. + */ + WRITE, + + /** + * Log Delete Operations. + */ + DELETE; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java new file mode 100644 index 0000000000000..0df26372b07e5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java @@ -0,0 +1,71 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.EnumSet; + +/** + * Represents the logging properties for the analytics service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class LoggingProperties { + + /** + * The analytics version to use. + */ + private String version = "1.0"; + + /** + * A EnumSet of LoggingOperationTypes that represent which storage operations should be logged. + */ + private EnumSet logOperationTypes = EnumSet.noneOf(LoggingOperations.class); + + /** + * The Retention policy for the logging data. + */ + private Integer retentionIntervalInDays; + + /** + * @return the logOperationTypes + */ + public EnumSet getLogOperationTypes() { + return this.logOperationTypes; + } + + /** + * @return the retentionIntervalInDays + */ + public Integer getRetentionIntervalInDays() { + return this.retentionIntervalInDays; + } + + /** + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * @param logOperationTypes + * the logOperationTypes to set + */ + public void setLogOperationTypes(final EnumSet logOperationTypes) { + this.logOperationTypes = logOperationTypes; + } + + /** + * @param retentionIntervalInDays + * the retentionIntervalInDays to set + */ + public void setRetentionIntervalInDays(final Integer retentionIntervalInDays) { + this.retentionIntervalInDays = retentionIntervalInDays; + } + + /** + * @param version + * the version to set + */ + public void setVersion(final String version) { + this.version = version; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java new file mode 100644 index 0000000000000..593e2e889f9a5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java @@ -0,0 +1,23 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Enumeration representing the state of metrics collection in a service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum MetricsLevel { + /** + * Metrics collection is disabled. + */ + DISABLED, + + /** + * Service-level metrics collection is enabled. + */ + SERVICE, + + /** + * Service-level and API metrics collection are enabled. + */ + SERVICE_AND_API; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java new file mode 100644 index 0000000000000..39193f46b5fbd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java @@ -0,0 +1,68 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents the metrics properties for the analytics service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class MetricsProperties { + /** + * The analytics version to use. + */ + private String version = "1.0"; + + /** + * A used to enable Metric and API logging // todo do xref see to enum values. + */ + private MetricsLevel metricsLevel = com.microsoft.windowsazure.services.core.storage.MetricsLevel.DISABLED; + + /** + * The Retention policy for the Metrics data. + */ + private Integer retentionIntervalInDays; + + /** + * @return the metricsLevel + */ + public MetricsLevel getMetricsLevel() { + return this.metricsLevel; + } + + /** + * @return the retentionIntervalInDays + */ + public Integer getRetentionIntervalInDays() { + return this.retentionIntervalInDays; + } + + /** + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * @param metricsLevel + * the metricsLevel to set + */ + public void setMetricsLevel(final MetricsLevel metricsLevel) { + this.metricsLevel = metricsLevel; + } + + /** + * @param retentionIntervalInDays + * the retentionIntervalInDays to set + */ + public void setRetentionIntervalInDays(final Integer retentionIntervalInDays) { + this.retentionIntervalInDays = retentionIntervalInDays; + } + + /** + * @param version + * the version to set + */ + public void setVersion(final String version) { + this.version = version; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java new file mode 100644 index 0000000000000..0627a2c847ced --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -0,0 +1,221 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.HttpURLConnection; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.UUID; +import java.util.logging.Logger; + +/** + * Represents the current logical operation. A logical operation has potentially a one-to-many relationship with + * individual physical requests. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class OperationContext { + + /** + * Represents the operation latency, in milliseconds, from the client's perspective. This may include any potential + * retries. + */ + private long clientTimeInMs; + + /** + * The UUID representing the client side trace ID. + */ + // V2 expose when logging is available. + @SuppressWarnings("unused") + private final String clientTraceID; + + /** + * The Logger object associated with this operation. + */ + private Logger logger; + + /** + * Represents request results, in the form of an ArrayList object that contains the + * {@link RequestResult} objects, for each physical request that is made. + */ + private ArrayList requestResults; + + /** + * Represents an event that is triggered when a response is received from the storage service while processing a + * request. + * + * @see EventListener + * @see EventListenerMultiCaster + * @see ResponseReceivedEvent + */ + private EventListenerMultiCaster> responseReceivedEventHandler = + new EventListenerMultiCaster>(); + + /** + * Reserved for internal use. + */ + // Represents the intermediate MD5 value, which is used in resuming downloads. + private MessageDigest intermediateMD5; + + /** + * Reserved for internal use. Represents the current request object, which is used in continuation. + */ + private HttpURLConnection currentRequestObject; + + /** + * Represents the current operation state object. + */ + protected Object operationState; + + /** + * Reserved for internal use. + */ + // Used internally for download resume. + private volatile int currentOperationByteCount; + + /** + * Creates an instance of the OperationContext class. + */ + public OperationContext() { + this.clientTraceID = UUID.randomUUID().toString(); + this.requestResults = new ArrayList(); + } + + /** + * @return the clientTimeInMs + */ + public long getClientTimeInMs() { + return this.clientTimeInMs; + } + + /** + * @return the currentOperationByteCount + */ + public int getCurrentOperationByteCount() { + return this.currentOperationByteCount; + } + + /** + * @return the currentRequestObject + */ + public HttpURLConnection getCurrentRequestObject() { + return this.currentRequestObject; + } + + /** + * @return the intermediateMD5 + */ + public MessageDigest getIntermediateMD5() { + return this.intermediateMD5; + } + + /** + * Returns the last request result encountered for the operation. + * + * @return A {@link RequestResult} object that represents the last request result. + */ + public RequestResult getLastResult() { + if (this.requestResults == null || this.requestResults.size() == 0) { + return null; + } else { + return this.requestResults.get(this.requestResults.size() - 1); + } + } + + /** + * Gets the Logger associated with this operation. + * + * @return the Logger associated with this operation + */ + @SuppressWarnings("unused") + private Logger getLogger() { + // V2 throw on null logger reference , use default dummy logger. + return this.logger; + } + + /** + * Returns the set of request results that the current operation has created. + * + * @return An ArrayList object that contains {@link RequestResult} objects that represent the request + * results created by the current operation. + */ + public ArrayList getRequestResults() { + return this.requestResults; + } + + /** + * @return the responseReceivedEventHandler + */ + public + EventListenerMultiCaster> + getResponseReceivedEventHandler() { + return this.responseReceivedEventHandler; + } + + /** + * Initializes the OperationContext in order to begin processing a new operation. All operation specific information + * is erased. + */ + public void initialize() { + this.setClientTimeInMs(0); + this.requestResults.clear(); + this.setIntermediateMD5(null); + this.operationState = null; + this.setCurrentRequestObject(null); + } + + /** + * @param clientTimeInMs + * the clientTimeInMs to set + */ + public void setClientTimeInMs(final long clientTimeInMs) { + this.clientTimeInMs = clientTimeInMs; + } + + /** + * @param currentOperationByteCount + * the currentOperationByteCount to set + */ + public void setCurrentOperationByteCount(final int currentOperationByteCount) { + this.currentOperationByteCount = currentOperationByteCount; + } + + /** + * @param currentRequestObject + * the currentRequestObject to set + */ + public void setCurrentRequestObject(final HttpURLConnection currentRequestObject) { + this.currentRequestObject = currentRequestObject; + } + + /** + * @param intermediateMD5 + * the intermediateMD5 to set + */ + public void setIntermediateMD5(final MessageDigest intermediateMD5) { + this.intermediateMD5 = intermediateMD5; + } + + /** + * Sets the Logger for this operation. + * + * @param logger + * the Logger to use for this operation + */ + @SuppressWarnings("unused") + private void setLogger(final Logger logger) { + this.logger = logger; + } + + /** + * @param responseReceivedEventHandler + * the responseReceivedEventHandler to set + */ + public + void + setResponseReceivedEventHandler( + final EventListenerMultiCaster> responseReceivedEventHandler) { + this.responseReceivedEventHandler = responseReceivedEventHandler; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java new file mode 100644 index 0000000000000..48eab58ba69a3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java @@ -0,0 +1,87 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents the options to use while processing a given request. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public class RequestOptions { + + /** + * The instance of the {@link RetryPolicyFactory} interface to use for the request. + */ + private RetryPolicyFactory retryPolicyFactory; + + /** + * The timeout interval, in milliseconds, to use for the request. + */ + private Integer timeoutIntervalInMs; + + /** + * Creates an instance of the RequestOptions class. + */ + public RequestOptions() { + // Empty Default Ctor + } + + /** + * Creates an instance of the RequestOptions class by copying values from another + * RequestOptions instance. + * + * @param other + * A RequestOptions object that represents the request options to copy. + */ + public RequestOptions(final RequestOptions other) { + this.setTimeoutIntervalInMs(other.getTimeoutIntervalInMs()); + this.setRetryPolicyFactory(other.getRetryPolicyFactory()); + } + + /** + * Populates the default timeout and retry policy from client if they are null. + * + * @param client + * the service client to populate from + */ + protected final void applyBaseDefaults(final ServiceClient client) { + if (this.getRetryPolicyFactory() == null) { + this.setRetryPolicyFactory(client.getRetryPolicyFactory()); + } + + if (this.getTimeoutIntervalInMs() == null) { + this.setTimeoutIntervalInMs(client.getTimeoutInMs()); + } + } + + /** + * @return the retryPolicyFactory + */ + public final RetryPolicyFactory getRetryPolicyFactory() { + return this.retryPolicyFactory; + } + + /** + * @return the timeoutIntervalInMs + */ + public final Integer getTimeoutIntervalInMs() { + return this.timeoutIntervalInMs; + } + + /** + * @param retryPolicyFactory + * the retryPolicyFactory to set + */ + public final void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) { + this.retryPolicyFactory = retryPolicyFactory; + } + + /** + * @param timeoutIntervalInMs + * the timeoutIntervalInMs to set + */ + public final void setTimeoutIntervalInMs(final Integer timeoutIntervalInMs) { + this.timeoutIntervalInMs = timeoutIntervalInMs; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java new file mode 100644 index 0000000000000..18c739479917e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java @@ -0,0 +1,194 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.Date; + +/** + * Represents the result of a physical request. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class RequestResult { + + /** + * Represents an exception that occurred while processing the request. This field may be null. + */ + private Exception exception; + + /** + * Represents the request ID supplied by the storage service. + */ + private String serviceRequestID; + + /** + * Represents the ContentMD5 header returned by the storage service. + */ + private String contentMD5; + + /** + * Represents the date header returned by the storage service. + */ + private String requestDate; + + /** + * Represents the ETag header returned by the storage service. + */ + private String etag; + + /** + * Represents the start date of the operation. + */ + private Date startDate; + + /** + * Represents the HTTP status code for the request. + */ + private int statusCode = -1; + + /** + * Represents the HTTP status message for the request. + */ + private String statusMessage; + + /** + * Represents the stop date of the operation. + */ + private Date stopDate; + + /** + * @return the contentMD5 + */ + public String getContentMD5() { + return this.contentMD5; + } + + /** + * @return the etag + */ + public String getEtag() { + return this.etag; + } + + /** + * @return the exception + */ + public Exception getException() { + return this.exception; + } + + /** + * @return the requestDate + */ + public String getRequestDate() { + return this.requestDate; + } + + /** + * @return the serviceRequestID + */ + public String getServiceRequestID() { + return this.serviceRequestID; + } + + /** + * @return the startDate + */ + public Date getStartDate() { + return this.startDate; + } + + /** + * @return the statusCode + */ + public int getStatusCode() { + return this.statusCode; + } + + /** + * @return the statusMessage + */ + public String getStatusMessage() { + return this.statusMessage; + } + + /** + * @return the stopDate + */ + public Date getStopDate() { + return this.stopDate; + } + + /** + * @param contentMD5 + * the contentMD5 to set + */ + public void setContentMD5(final String contentMD5) { + this.contentMD5 = contentMD5; + } + + /** + * @param etag + * the etag to set + */ + public void setEtag(final String etag) { + this.etag = etag; + } + + /** + * @param exception + * the exception to set + */ + public void setException(final Exception exception) { + this.exception = exception; + } + + /** + * @param requestDate + * the date to set + */ + public void setRequestDate(final String requestDate) { + this.requestDate = requestDate; + } + + /** + * @param serviceRequestID + * the serviceRequestID to set + */ + public void setServiceRequestID(final String serviceRequestID) { + this.serviceRequestID = serviceRequestID; + } + + /** + * @param startDate + * the startDate to set + */ + public void setStartDate(final Date startDate) { + this.startDate = startDate; + } + + /** + * @param statusCode + * the statusCode to set + */ + public void setStatusCode(final int statusCode) { + this.statusCode = statusCode; + } + + /** + * @param statusMessage + * the statusMessage to set + */ + public void setStatusMessage(final String statusMessage) { + this.statusMessage = statusMessage; + } + + /** + * @param stopDate + * the stopDate to set + */ + public void setStopDate(final Date stopDate) { + this.stopDate = stopDate; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java new file mode 100644 index 0000000000000..b026d0dd2462a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -0,0 +1,51 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents an event that is fired when a response is received. + * + * Copyright (c)2011 Microsoft + */ +public final class ResponseReceivedEvent { + + /** + * Represents a connection object. Currently only java.net.HttpURLConnection is supported as a + * connection object. + */ + private Object connectionObject; + + /** + * Represents a context for the current operation. This object is used to track requests to the storage service, and + * to provide additional runtime information about the operation. + */ + private OperationContext opContext; + + /** + * Creates an instance of the ResponseReceivedEvent class. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * @param connectionObject + * Represents a connection object. Currently only java.net.HttpURLConnection is supported as + * a connection object. + */ + public ResponseReceivedEvent(final OperationContext opContext, final Object connectionObject) { + this.opContext = opContext; + this.connectionObject = connectionObject; + } + + /** + * @return the connectionObject + */ + public Object getConnectionObject() { + return this.connectionObject; + } + + /** + * @return the opContext + */ + public OperationContext getOpContext() { + return this.opContext; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java new file mode 100644 index 0000000000000..85357a99936d1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java @@ -0,0 +1,128 @@ +package com.microsoft.windowsazure.services.core.storage; + +import com.microsoft.windowsazure.services.blob.client.CloudBlobDirectory; + +/** + * Represents a continuation token for listing operations. Continuation tokens are used in methods that return a + * {@link ResultSegment} object, such as {@link CloudBlobDirectory#listBlobsSegmented}. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class ResultContinuation { + /** + * Represents the next marker for continuing results of listing operations. + */ + private String nextMarker; + + /** + * Gets or sets the NextPartitionKey for TableServiceEntity enumeration operations. + */ + private String nextPartitionKey; + + /** + * Gets or sets the NextRowKey for TableServiceEntity enumeration operations. + */ + private String nextRowKey; + + /** + * Gets or sets the NextTableName for Table enumeration operations. + */ + private String nextTableName; + + /** + * Gets or sets the type of the continuation token. + */ + private ResultContinuationType continuationType; + + /** + * Creates an instance of the ResultContinuation class. + */ + public ResultContinuation() { + // Empty Default Ctor + } + + /** + * @return the continuationType + */ + public ResultContinuationType getContinuationType() { + return this.continuationType; + } + + /** + * @return the nextMarker + */ + public String getNextMarker() { + return this.nextMarker; + } + + /** + * @return the nextPartitionKey + */ + public String getNextPartitionKey() { + return this.nextPartitionKey; + } + + /** + * @return the nextRowKey + */ + public String getNextRowKey() { + return this.nextRowKey; + } + + /** + * @return the nextTableName + */ + public String getNextTableName() { + return this.nextTableName; + } + + /** + * Returns a value that indicates whether continuation information is available. + * + * @return true if any continuation information is available; otherwise false. + */ + public boolean hasContinuation() { + return this.getNextMarker() != null || this.nextPartitionKey != null || this.nextRowKey != null + || this.nextTableName != null; + } + + /** + * @param continuationType + * the continuationType to set + */ + public void setContinuationType(final ResultContinuationType continuationType) { + this.continuationType = continuationType; + } + + /** + * @param nextMarker + * the nextMarker to set + */ + public void setNextMarker(final String nextMarker) { + this.nextMarker = nextMarker; + } + + /** + * @param nextPartitionKey + * the nextPartitionKey to set + */ + public void setNextPartitionKey(final String nextPartitionKey) { + this.nextPartitionKey = nextPartitionKey; + } + + /** + * @param nextRowKey + * the nextRowKey to set + */ + public void setNextRowKey(final String nextRowKey) { + this.nextRowKey = nextRowKey; + } + + /** + * @param nextTableName + * the nextTableName to set + */ + public void setNextTableName(final String nextTableName) { + this.nextTableName = nextTableName; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java new file mode 100644 index 0000000000000..9607279122f15 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java @@ -0,0 +1,31 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Specifies the type of a continuation token. + */ +public enum ResultContinuationType { + /** + * Specifies no continuation. + */ + NONE, + + /** + * Specifies the token is a blob listing continuation token. + */ + BLOB, + + /** + * Specifies the token is a container listing continuation token. + */ + CONTAINER, + + /** + * Specifies the token is a queue listing continuation token (reserved for future use). + */ + QUEUE, + + /** + * Specifies the token is a table query continuation token (reserved for future use). + */ + TABLE +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java new file mode 100644 index 0000000000000..f99001107c5d7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java @@ -0,0 +1,113 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.ArrayList; + +/** + * Represents a segment of results and contains continuation and pagination information. + * + * @param + * The type of the result that the segment contains. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public class ResultSegment { + /** + * Stores the continuation token used to retrieve the next segment of results. + */ + private final ResultContinuation continuationToken; + + /** + * Holds the number of the results. + */ + private final int length; + + /** + * Holds the size of the requested page. + */ + private final int pageSize; + + /** + * Holds the Iterable collection of results. + */ + private final Iterable results; + + /** + * Reserved for internal use. Creates an instance of the ResultSegment class. + * + * @param results + * An ArrayList object that represents the results for the segment. + * @param pageSize + * The number of elements in a page of results. + * @param token + * A {@link ResultContinuation} object that represents the continuation token. + */ + public ResultSegment(final ArrayList results, final int pageSize, final ResultContinuation token) { + this.results = results; + this.length = results.size(); + this.pageSize = pageSize; + this.continuationToken = token; + } + + /** + * Returns the continuation token for the result segment. + * + * @return A {@link ResultContinuation} object that represents the continuation token. + */ + public ResultContinuation getContinuationToken() { + return this.continuationToken; + } + + /** + * Returns a value that indicates whether there are more results available from the server. + * + * @return true if there are more results available from the server; otherwise, false. + */ + public boolean getHasMoreResults() { + return this.continuationToken != null; + } + + /** + * Returns a value that indicates whether the page has more results. + * + * @return true if the page has more results; otherwise, false. + */ + public boolean getIsPageComplete() { + return this.length == this.pageSize; + } + + /** + * Returns the number of results in the segment. + * + * @return The actual number of the results in the segment. + */ + public int getLength() { + return this.length; + } + + /** + * Returns the size of the requested page. + * + * @return The size of the requested page. + */ + public int getPageSize() { + return this.pageSize; + } + + /** + * Returns the count of remaining results needed to fulfill the requested page size. + * + * @return The count of remaining results needed to fulfill the requested page size. + */ + public int getRemainingPageResults() { + return this.pageSize - this.length; + } + + /** + * Returns an enumerable set of results from the blob service. + * + * @return The results retrieved from the blob service. + */ + public Iterable getResults() { + return this.results; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java new file mode 100644 index 0000000000000..542bec26aea72 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java @@ -0,0 +1,131 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.util.Random; + +/** + * Represents a retry policy that performs a specified number of retries, using a randomized exponential backoff scheme + * to determine the interval between retries. + * + * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the + * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class RetryExponentialRetry extends RetryPolicy implements RetryPolicyFactory { + + /** + * Holds the random number generator used to calculate randomized backoff interavals. + */ + private final Random randRef = new Random(); + + /** + * Holds the actual maximum backoff interval to enforce. + */ + private int resolvedMaxBackoff = RetryPolicy.DEFAULT_MAX_BACKOFF; + + /** + * Holds the actual minimum backoff interval to enforce. + */ + private int resolvedMinBackoff = RetryPolicy.DEFAULT_MIN_BACKOFF; + + /** + * Creates an instance of the RetryExponentialRetry class. + */ + public RetryExponentialRetry() { + this(RetryPolicy.DEFAULT_CLIENT_BACKOFF, RetryPolicy.DEFAULT_CLIENT_RETRY_COUNT); + } + + /** + * Creates an instance of the RetryExponentialRetry class using the specified delta backoff and maximum + * retry attempts. + * + * @param deltaBackoff + * The backoff interval, in milliseconds, between retries. + * @param maxAttempts + * The maximum number of retry attempts. + */ + public RetryExponentialRetry(final int deltaBackoff, final int maxAttempts) { + super(deltaBackoff, maxAttempts); + } + + /** + * Creates an instance of the RetryExponentialRetry class using the specified minimum, maximum, and + * delta backoff amounts, and maximum number of retry attempts. + * + * @param minBackoff + * The minimum backoff interval, in milliseconds, between retries. + * @param deltaBackoff + * The backoff interval, in milliseconds, between retries. + * @param maxBackOff + * The maximum backoff interval, in milliseconds, between retries. + * @param maxAttempts + * The maximum retry attempts, in milliseconds, between retries. + */ + public RetryExponentialRetry(final int minBackoff, final int deltaBackoff, final int maxBackOff, + final int maxAttempts) { + super(deltaBackoff, maxAttempts); + this.resolvedMinBackoff = minBackoff; + this.resolvedMaxBackoff = maxBackOff; + } + + /** + * Generates a new retry policy for the current request attempt. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. + */ + public RetryPolicy createInstance(final OperationContext opContext) { + return new RetryExponentialRetry(this.resolvedMinBackoff, this.deltaBackoffIntervalInMs, + this.resolvedMaxBackoff, this.maximumAttempts); + } + + /** + * Determines if the operation should be retried and how long to wait until the next retry. + * + * @param currentRetryCount + * The number of retries for the given operation. A value of zero signifies this is the first error + * encountered. + * @param statusCode + * The status code for the last operation. + * @param lastException + * A Exception object that represents the last exception encountered. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be + * retried and how long to backoff. + */ + @Override + public RetryResult shouldRetry( + final int currentRetryCount, final int statusCode, final Exception lastException, + final OperationContext opContext) { + + if (statusCode >= 400 && statusCode < 500) { + return new RetryResult(0, false); + } + + if (currentRetryCount < this.maximumAttempts) { + + // Calculate backoff Interval between 80% and 120% of the desired + // backoff, multiply by 2^n -1 for + // exponential + int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); + final int boundedRandDelta = + (int) (this.deltaBackoffIntervalInMs * 0.8) + + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) + - (int) (this.deltaBackoffIntervalInMs * 0.8)); + incrementDelta *= boundedRandDelta; + + // Enforce max / min backoffs + return new RetryResult(Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff), true); + } else { + return new RetryResult(-1, false); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java new file mode 100644 index 0000000000000..f93159d9efbb4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java @@ -0,0 +1,79 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents a retry policy that performs a specified number of retries, using a specified fixed time interval between + * retries. + * + * This class extends the {@link RetryPolicy} class and implements the {@link RetryPolicyFactory} interface. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class RetryLinearRetry extends RetryPolicy implements RetryPolicyFactory { + + /** + * Creates an instance of the RetryLinearRetry class. + */ + public RetryLinearRetry() { + this(RetryPolicy.DEFAULT_CLIENT_BACKOFF, RetryPolicy.DEFAULT_CLIENT_RETRY_COUNT); + } + + /** + * Creates an instance of the RetryLinearRetry class using the specified delta backoff and maximum + * retry attempts. + * + * @param deltaBackoff + * The backoff interval, in milliseconds, between retries. + * @param maxAttempts + * The maximum number of retry attempts. + */ + public RetryLinearRetry(final int deltaBackoff, final int maxAttempts) { + super(deltaBackoff, maxAttempts); + } + + /** + * Generates a new retry policy for the current request attempt. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. + */ + public RetryPolicy createInstance(final OperationContext opContext) { + return new RetryLinearRetry(this.deltaBackoffIntervalInMs, this.maximumAttempts); + } + + /** + * Determines if the operation should be retried and how long to wait until the next retry. + * + * @param currentRetryCount + * The number of retries for the given operation. A value of zero signifies this is the first error + * encountered. + * @param statusCode + * The status code for the last operation. + * @param lastException + * A Exception object that represents the last exception encountered. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be + * retried and how long to backoff. + */ + @Override + public RetryResult shouldRetry( + final int currentRetryCount, final int statusCode, final Exception lastException, + final OperationContext opContext) { + if (statusCode >= 400 && statusCode < 500) { + return new RetryResult(0, false); + } + + final int backoff = + Math.max(Math.min(this.deltaBackoffIntervalInMs, RetryPolicy.DEFAULT_MAX_BACKOFF), + RetryPolicy.DEFAULT_MIN_BACKOFF); + + return new RetryResult(backoff, currentRetryCount < this.maximumAttempts); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java new file mode 100644 index 0000000000000..db54ea1cda4e4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java @@ -0,0 +1,66 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents a retry policy that performs no retries. + * + * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the + * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class RetryNoRetry extends RetryPolicy implements RetryPolicyFactory { + + /** + * Holds the static instance of the no retry policy. + */ + private static RetryNoRetry instance = new RetryNoRetry(); + + /** + * Returns the static instance of a no retry policy. + * + * @return A RetryNoRetry object that represents a no retry policy. + */ + public static RetryNoRetry getInstance() { + return instance; + } + + /** + * Generates a new retry policy for the current request attempt. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. + */ + public RetryPolicy createInstance(final OperationContext opContext) { + return getInstance(); + } + + /** + * Determines if the operation should be retried and how long to wait until the next retry. + * + * @param currentRetryCount + * The number of retries for the given operation. A value of zero signifies this is the first error + * encountered. + * @param statusCode + * The status code for the last operation. + * @param lastException + * A Exception object that represents the last exception encountered. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be + * retried and how long to backoff. + * + */ + @Override + public RetryResult shouldRetry( + final int currentRetryCount, final int statusCode, final Exception lastException, + final OperationContext opContext) { + return new RetryResult(0, false); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java new file mode 100644 index 0000000000000..26da7d9047b57 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java @@ -0,0 +1,84 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Abstract class that represents a retry policy. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class RetryPolicy { + + /** + * Represents the default client backoff interval, in milliseconds. + */ + public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; + + /** + * Represents the default client retry count. + */ + public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; + + /** + * Represents the default maximum backoff interval, in milliseconds. + */ + public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; + + /** + * Represents the default minimum backoff interval, in milliseconds. + */ + public static final int DEFAULT_MIN_BACKOFF = 1000 * 3; + + /** + * Represents the realized backoff interval, in milliseconds. + */ + protected int deltaBackoffIntervalInMs; + + /** + * Represents the maximum retries that the retry policy should attempt. + */ + protected int maximumAttempts; + + /** + * Creates an instance of the RetryPolicy class. + */ + public RetryPolicy() { + // Empty Default Ctor + } + + /** + * Creates an instance of the RetryPolicy class using the specified delta backoff and maximum retry + * attempts. + * + * @param deltaBackoff + * The backoff interval, in milliseconds, between retries. + * @param maxAttempts + * The maximum number of retry attempts. + */ + public RetryPolicy(final int deltaBackoff, final int maxAttempts) { + this.deltaBackoffIntervalInMs = deltaBackoff; + this.maximumAttempts = maxAttempts; + } + + /** + * Determines if the operation should be retried and how long to wait until the next retry. + * + * @param currentRetryCount + * The number of retries for the given operation. A value of zero signifies this is the first error + * encountered. + * @param statusCode + * The status code for the last operation. + * @param lastException + * A Exception object that represents the last exception encountered. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryResult} object that indicates whether the operation should be retried and how long to + * backoff. + */ + public abstract RetryResult shouldRetry( + int currentRetryCount, int statusCode, Exception lastException, OperationContext opContext); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java new file mode 100644 index 0000000000000..e7656a7c68a34 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java @@ -0,0 +1,24 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents a retry policy factory that creates a new {@link RetryPolicy} object per transaction. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public interface RetryPolicyFactory { + + /** + * Creates a new {@link RetryPolicy} object for the current request attempt. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link RetryPolicy} object that represents the new retry policy for the current request attempt. + */ + RetryPolicy createInstance(OperationContext opContext); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java new file mode 100644 index 0000000000000..dfd4c1c709b3c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java @@ -0,0 +1,65 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents the result of a retry policy evaluation. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class RetryResult { + /** + * Represents the backoff interval in milliseconds. + */ + private int backOffIntervalInMs; + + /** + * Indicates whether to retry the operation. Set to true to retry; otherwise, false. + */ + private boolean shouldRetry; + + /** + * Creates an instance of the RetryResult class. + * + * @param backOff + * The backoff interval, in milliseconds, to wait before attempting the retry. + * @param shouldRetry + * true if the operation should be retried, otherwise, false. + * + */ + public RetryResult(final int backOff, final boolean shouldRetry) { + this.backOffIntervalInMs = backOff; + this.setShouldRetry(shouldRetry); + } + + /** + * Sleeps the amount of time specified by the backoff interval, if the retry policy indicates the operation should + * be retried. + */ + public void doSleep() { + if (this.isShouldRetry()) { + try { + Thread.sleep(this.backOffIntervalInMs); + } catch (final InterruptedException e) { + // Restore the interrupted status + Thread.currentThread().interrupt(); + } + } + } + + /** + * @return the shouldRetry + */ + public boolean isShouldRetry() { + return this.shouldRetry; + } + + /** + * @param shouldRetry + * the shouldRetry to set + */ + public void setShouldRetry(final boolean shouldRetry) { + this.shouldRetry = shouldRetry; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java new file mode 100644 index 0000000000000..15c8535879de1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -0,0 +1,346 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.io.ByteArrayInputStream; +import java.net.HttpURLConnection; +import java.net.URI; + +import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; +import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; +import com.microsoft.windowsazure.services.queue.client.CloudQueueClient; + +/** + * Reserved for internal use. Provides a client for accessing the Windows Azure Storage service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class ServiceClient { + + /** + * Holds the base URI for the Service Client. + */ + protected URI endpoint; + + /** + * Holds the StorageCredentials associated with this Service Client. + */ + protected StorageCredentials credentials; + + /** + * Reserved for internal use. An internal flag which indicates if path style uris should be used. + */ + private boolean usePathStyleUris; + + /** + * Holds the default retry policy for requests made via the service client to set. + */ + protected RetryPolicyFactory retryPolicyFactory = new RetryExponentialRetry(); + + /** + * Holds the default server and client timeout for requests made by the service client. + */ + protected int timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; + + /** + * Creates an instance of the ServiceClient class using the specified service endpoint. + * + * @param baseUri + * A java.net.URI object that represents the service endpoint used to create the client. + */ + public ServiceClient(final URI baseUri) { + this(baseUri, null); + } + + /** + * Creates an instance of the ServiceClient class using the specified service endpoint and account + * credentials. + * + * @param baseUri + * A java.net.URI object that represents the service endpoint used to create the client. + * + * @param credentials + * A {@link StorageCredentials} object that represents the account credentials. + */ + public ServiceClient(final URI baseUri, final StorageCredentials credentials) { + Utility.assertNotNull("baseUri", baseUri); + + if (!baseUri.isAbsolute()) { + throw new IllegalArgumentException( + String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", + baseUri)); + } + + this.retryPolicyFactory = new RetryExponentialRetry(); + this.timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; + + this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, credentials.getAccountName()); + this.endpoint = baseUri; + + this.credentials = credentials; + } + + /** + * Retrieves the current ServiceProperties for the given storage service. This includes Metrics and Logging + * Configurations. + * + * @return the ServiceProperties object representing the current configuration of the service. + * @throws StorageException + * If a storage service error occurred. + */ + public final ServiceProperties downloadServiceProperties() throws StorageException { + return this.downloadServiceProperties(null, null); + } + + /** + * Retrieves the current ServiceProperties for the given storage service. This includes Metrics and Logging + * Configurations. + * + * @param options + * A {@link RequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}{@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * @return the ServiceProperties object representing the current configuration of the service. + * @throws StorageException + * If a storage service error occurred. + */ + public final ServiceProperties downloadServiceProperties(RequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new RequestOptions(); + } + + opContext.initialize(); + options.applyBaseDefaults(this); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public ServiceProperties execute( + final ServiceClient client, final Void v, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + BaseRequest.getServiceProperties(client.getEndpoint(), this.getRequestOptions() + .getTimeoutIntervalInMs(), null, opContext); + + client.getCredentials().signRequest(request, -1); + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return BaseResponse.readServicePropertiesFromStream(request.getInputStream(), opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Returns the storage credentials associated with this service client. + * + * @return A {@link StorageCredentials} object that represents the storage credentials associated with this client. + */ + public final StorageCredentials getCredentials() { + return this.credentials; + } + + /** + * Returns the base URI for this service client. + * + * @return A java.net.URI object that represents the base URI for the service client. + */ + public final URI getEndpoint() { + return this.endpoint; + } + + /** + * Returns the retry policy currently in effect for this Blob service client. + * + * @return An {@link RetryPolicyFactory} object that represents the current retry policy. + * + * @see RetryPolicy + * @see RetryExponentialRetry + * @see RetryLinearRetry + * @see RetryNoRetry + */ + public final RetryPolicyFactory getRetryPolicyFactory() { + return this.retryPolicyFactory; + } + + /** + * Returns the timeout value for requests made to the service. For more information about the timeout, see + * {@link #setTimeoutInMs}. + * + * @return The current timeout value, in milliseconds, for requests made to the storage service. + */ + public final int getTimeoutInMs() { + return this.timeoutInMs; + } + + /** + * @return the usePathStyleUris + */ + public final boolean isUsePathStyleUris() { + return this.usePathStyleUris; + } + + /** + * Sets the base URI for the service client. + * + * @param baseUri + * A java.net.URI object that represents the base URI being assigned to the service client. + */ + protected final void setBaseURI(final URI baseUri) { + this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, this.credentials.getAccountName()); + this.endpoint = baseUri; + } + + /** + * Sets the credentials to use with this service client. + * + * @param credentials + * A Credentials object that represents the credentials being assigned for the service + * client. + */ + protected final void setCredentials(final StorageCredentials credentials) { + this.credentials = credentials; + } + + /** + * Sets the RetryPolicyFactory object to use when making service requests. + * + * @param retryPolicyFactory + * the RetryPolicyFactory object to use when making service requests. + */ + public void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) { + this.retryPolicyFactory = retryPolicyFactory; + } + + /** + * Sets the timeout to use when making requests to the storage service. + *

+ * The server timeout interval begins at the time that the complete request has been received by the service, and + * the server begins processing the response. If the timeout interval elapses before the response is returned to the + * client, the operation times out. The timeout interval resets with each retry, if the request is retried. + * + * The default timeout interval for a request made via the service client is 90 seconds. You can change this value + * on the service client by setting this property, so that all subsequent requests made via the service client will + * use the new timeout interval. You can also change this value for an individual request, by setting the + * {@link RequestOptions#timeoutIntervalInMs} property. + * + * If you are downloading a large blob, you should increase the value of the timeout beyond the default value. + * + * @param timeoutInMs + * The timeout, in milliseconds, to use when making requests to the storage service. + */ + public final void setTimeoutInMs(final int timeoutInMs) { + this.timeoutInMs = timeoutInMs; + } + + /** + * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * + * @param properties + * The ServiceProperties to upload. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { + this.uploadServiceProperties(properties, null, null); + } + + /** + * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * + * @param properties + * The ServiceProperties to upload. + * @param options + * A {@link RequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}{@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadServiceProperties( + final ServiceProperties properties, RequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new RequestOptions(); + } + + opContext.initialize(); + options.applyBaseDefaults(this); + + Utility.assertNotNull("properties", properties); + Utility.assertNotNull("properties.Logging", properties.getLogging()); + Utility.assertNotNull("properties.Logging.LogOperationTypes", properties.getLogging().getLogOperationTypes()); + Utility.assertNotNull("properties.Merics", properties.getMetrics()); + Utility.assertNotNull("properties.Merics.Configuration", properties.getMetrics().getMetricsLevel()); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute(final ServiceClient client, final Void v, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + BaseRequest.setServiceProperties(client.getEndpoint(), this.getRequestOptions() + .getTimeoutIntervalInMs(), null, opContext); + + final byte[] propertiesBytes = + BaseRequest.serializeServicePropertiesToByteArray(properties, opContext); + + final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(propertiesBytes); + + final StreamDescriptor descriptor = + Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); + + client.getCredentials().signRequest(request, descriptor.getLength()); + Utility.writeToOutputStream(blockListInputStream, + request.getOutputStream(), + descriptor.getLength(), + false, + false, + null, + opContext); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java new file mode 100644 index 0000000000000..9b1f18397b28f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java @@ -0,0 +1,448 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.io.InputStream; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Represents the analytics properties for the service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class ServiceProperties { + /** + * Populates the Logging Properties form the xml reader. XmlStreamReader must be at start of Logging element. + * + * @param retProps + * the ServiceProperties to populate + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if the xml is invalid. + * @throws StorageException + * if unexpected xml is found. + */ + private static void readLoggingProperties(final ServiceProperties retProps, final XMLStreamReader xmlr) + throws XMLStreamException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); + + int eventType = xmlr.getEventType(); + String tempParseString = null; + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + final String name = xmlr.getName().toString(); + if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { + retProps.getLogging().setVersion(Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.VERSION_ELEMENT)); + } else if (name.equals(Constants.AnalyticsConstants.DELETE_ELEMENT)) { + tempParseString = + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.DELETE_ELEMENT); + if (Boolean.parseBoolean(tempParseString)) { + retProps.getLogging().getLogOperationTypes().add(LoggingOperations.DELETE); + } + } else if (name.equals(Constants.AnalyticsConstants.READ_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.READ_ELEMENT); + if (Boolean.parseBoolean(tempParseString)) { + retProps.getLogging().getLogOperationTypes().add(LoggingOperations.READ); + } + } else if (name.equals(Constants.AnalyticsConstants.WRITE_ELEMENT)) { + tempParseString = + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.WRITE_ELEMENT); + if (Boolean.parseBoolean(tempParseString)) { + retProps.getLogging().getLogOperationTypes().add(LoggingOperations.WRITE); + } + } else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { + retProps.getLogging().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else { + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); + break; + } + } + } + + /** + * Populates the Metrics Properties form the xml reader. XmlStreamReader must be at start of Metrics element. + * + * @param retProps + * the ServiceProperties to populate + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if the xml is invalid. + * @throws StorageException + * if unexpected xml is found. + */ + private static void readMetricsProperties(final ServiceProperties retProps, final XMLStreamReader xmlr) + throws XMLStreamException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); + + int eventType = xmlr.getEventType(); + String tempParseString = null; + retProps.getMetrics().setMetricsLevel(null); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + final String name = xmlr.getName().toString(); + if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { + retProps.getMetrics().setVersion(Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.VERSION_ELEMENT)); + } else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { + tempParseString = + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.ENABLED_ELEMENT); + + if (Boolean.parseBoolean(tempParseString)) { + retProps.getMetrics() + .setMetricsLevel(retProps.getMetrics().getMetricsLevel() != MetricsLevel.SERVICE_AND_API ? MetricsLevel.SERVICE + : MetricsLevel.SERVICE_AND_API); + } else { + retProps.getMetrics().setMetricsLevel(MetricsLevel.DISABLED); + } + } else if (name.equals(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT)) { + tempParseString = + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); + if (Boolean.parseBoolean(tempParseString) + && retProps.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED) { + retProps.getMetrics().setMetricsLevel(MetricsLevel.SERVICE_AND_API); + } + } else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { + retProps.getMetrics().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else { + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); + break; + } + } + } + + /** + * Parses the retention policy from the xml reader. XmlStreamReader must be at start of retention policy element. + * + * @param xmlr + * the XMLStreamReader to read from + * @return a nullable Integer representing the retention policy + * @throws XMLStreamException + * if the xml is invalid. + * @throws StorageException + * if unexpected xml is found. + */ + private static Integer readRetentionPolicy(final XMLStreamReader xmlr) throws XMLStreamException, StorageException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); + + Integer retVal = -1; + int eventType = xmlr.getEventType(); + String tempParseString = null; + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT) { + final String name = xmlr.getName().toString(); + + if (name.equals(Constants.AnalyticsConstants.DAYS_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.DAYS_ELEMENT); + + // if we have already detected that the retention policy is disabled dont return a value; + if (retVal != null) { + retVal = Integer.parseInt(tempParseString); + } + } else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { + tempParseString = + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.ENABLED_ELEMENT); + + if (!Boolean.parseBoolean(tempParseString)) { + retVal = null; + } + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else { + xmlr.require(XMLStreamConstants.END_ELEMENT, + null, + Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); + break; + } + } + + return retVal; + } + + /** + * Deserializes the ServiceProperties object from an input stream. + * + * @param inStream + * the stream to read from. + * @param opContext + * an object used to track the execution of the operation + * @return a ServiceProperties object representing the Analytics configuration for the client. + * @throws XMLStreamException + * if the xml is invalid. + * @throws StorageException + * if unexpected xml is found. + */ + public static ServiceProperties readServicePropertiesFromStream( + final InputStream inStream, final OperationContext opContext) throws XMLStreamException, StorageException { + final ServiceProperties retProps = new ServiceProperties(); + + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get StorageServiceProperties Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, + null, + Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + final String name = xmlr.getName().toString(); + if (name.equals(Constants.AnalyticsConstants.LOGGING_ELEMENT)) { + readLoggingProperties(retProps, xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); + } else if (name.equals(Constants.AnalyticsConstants.METRICS_ELEMENT)) { + readMetricsProperties(retProps, xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); + } else if (name.equals(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)) { + retProps.setDefaultServiceVersion(Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)); + } else { + throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, + "The response recieved is invalid or improperly formatted.", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT) { + if (xmlr.getName().toString().equals(Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT)) { + break; + } + } + } + + return retProps; + } + + /** + * Writes the retention policy to the XMLStreamWriter. + * + * @param xmlw + * the XMLStreamWriter to write to. + * @param val + * the nullable Integer indicating if the retention policy is enabled, and how long + * @throws XMLStreamException + */ + private static void writeRetentionPolicy(final XMLStreamWriter xmlw, final Integer val) throws XMLStreamException { + xmlw.writeStartElement(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); + + // Enabled + xmlw.writeStartElement(Constants.AnalyticsConstants.ENABLED_ELEMENT); + xmlw.writeCharacters(val != null ? Constants.TRUE : Constants.FALSE); + xmlw.writeEndElement(); + + if (val != null) { + // Days + xmlw.writeStartElement(Constants.AnalyticsConstants.DAYS_ELEMENT); + xmlw.writeCharacters(val.toString()); + xmlw.writeEndElement(); + } + + // End Retention Policy + xmlw.writeEndElement(); + } + + /** + * The service logging properties. This may not be null. + */ + private LoggingProperties logging; + + /** + * The service metrics properties. + */ + private MetricsProperties metrics; + + /** + * The default service version for the blob service, or null if no default is specified. This must be null for queue + * and table service properties. + */ + private String defaultServiceVersion; + + public ServiceProperties() { + this.setLogging(new LoggingProperties()); + this.setMetrics(new MetricsProperties()); + } + + /** + * @return the defaultServiceVersion + */ + public String getDefaultServiceVersion() { + return this.defaultServiceVersion; + } + + /** + * @return the logging + */ + public LoggingProperties getLogging() { + return this.logging; + } + + /** + * @return the metrics + */ + public MetricsProperties getMetrics() { + return this.metrics; + } + + /** + * Writes the contents of the ServiceProperties to the stream in xml format. + * + * @param opContext + * a tracking object for the request + * @return a byte array of the content to write to the stream. + * @throws XMLStreamException + * if there is an error writing content to the stream. + * @throws StorageException + */ + public byte[] serializeToByteArray(final OperationContext opContext) throws XMLStreamException, StorageException { + Utility.assertNotNull("Logging", this.getLogging()); + Utility.assertNotNull("Logging.LogOperationTypes", this.getLogging().getLogOperationTypes()); + Utility.assertNotNull("Merics", this.getMetrics()); + Utility.assertNotNull("Merics.Configuration", this.getMetrics().getMetricsLevel()); + + final StringWriter outWriter = new StringWriter(); + final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); + final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); + + // default is UTF8 + xmlw.writeStartDocument(); + xmlw.writeStartElement(Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT); + + // Logging + xmlw.writeStartElement(Constants.AnalyticsConstants.LOGGING_ELEMENT); + + // Version + xmlw.writeStartElement(Constants.AnalyticsConstants.VERSION_ELEMENT); + xmlw.writeCharacters(this.getLogging().getVersion()); + xmlw.writeEndElement(); + + // Delete + xmlw.writeStartElement(Constants.AnalyticsConstants.DELETE_ELEMENT); + xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.DELETE) ? Constants.TRUE + : Constants.FALSE); + xmlw.writeEndElement(); + + // Read + xmlw.writeStartElement(Constants.AnalyticsConstants.READ_ELEMENT); + xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.READ) ? Constants.TRUE + : Constants.FALSE); + xmlw.writeEndElement(); + + // Write + xmlw.writeStartElement(Constants.AnalyticsConstants.WRITE_ELEMENT); + xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.WRITE) ? Constants.TRUE + : Constants.FALSE); + xmlw.writeEndElement(); + + // Retention Policy + writeRetentionPolicy(xmlw, this.getLogging().getRetentionIntervalInDays()); + + // end Logging + xmlw.writeEndElement(); + + // Metrics + xmlw.writeStartElement(Constants.AnalyticsConstants.METRICS_ELEMENT); + + // Version + xmlw.writeStartElement(Constants.AnalyticsConstants.VERSION_ELEMENT); + xmlw.writeCharacters(this.getMetrics().getVersion()); + xmlw.writeEndElement(); + + // Enabled + xmlw.writeStartElement(Constants.AnalyticsConstants.ENABLED_ELEMENT); + xmlw.writeCharacters(this.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED ? Constants.TRUE + : Constants.FALSE); + xmlw.writeEndElement(); + + if (this.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED) { + // Include APIs + xmlw.writeStartElement(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); + xmlw.writeCharacters(this.getMetrics().getMetricsLevel() == MetricsLevel.SERVICE_AND_API ? Constants.TRUE + : Constants.FALSE); + xmlw.writeEndElement(); + } + + // Retention Policy + writeRetentionPolicy(xmlw, this.getMetrics().getRetentionIntervalInDays()); + + // end Metrics + xmlw.writeEndElement(); + + // Default Service Version + if (this.getDefaultServiceVersion() != null) { + xmlw.writeStartElement(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION); + xmlw.writeCharacters(this.getDefaultServiceVersion()); + xmlw.writeEndElement(); + } + + // end StorageServiceProperties + xmlw.writeEndElement(); + + // end doc + xmlw.writeEndDocument(); + + try { + return outWriter.toString().getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * @param defaultServiceVersion + * the defaultServiceVersion to set + */ + public void setDefaultServiceVersion(final String defaultServiceVersion) { + this.defaultServiceVersion = defaultServiceVersion; + } + + /** + * @param logging + * the logging to set + */ + public void setLogging(final LoggingProperties logging) { + this.logging = logging; + } + + /** + * @param metrics + * the metrics to set + */ + public void setMetrics(final MetricsProperties metrics) { + this.metrics = metrics; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java new file mode 100644 index 0000000000000..e58c646b271e5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -0,0 +1,326 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.HashMap; + +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Represents a set of credentials used to authenticate access to a Windows Azure storage account. This is the base + * class for the {@link StorageCredentialsAccountAndKey} and {@link StorageCredentialsSharedAccessSignature} classes. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class StorageCredentials { + + /** + * Tries to determine the storage credentials from a collection of name/value pairs. + * + * @param settings + * A HashMap object of the name/value pairs that represent the settings to use to configure + * the credentials. + *

+ * Either include an account name with an account key (specifying values for + * {@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a + * shared access signature (specifying a value for + * {@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account + * key, do not include a shared access signature, and vice versa. + * + * @return A {@link StorageCredentials} object representing the storage credentials determined from the name/value + * pairs. + * + * @throws InvalidKeyException + * If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid + * Base64-encoded string. + */ + protected static StorageCredentials tryParseCredentials(final HashMap settings) + throws InvalidKeyException { + final String accountName = + settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + + final String accountKey = + settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null; + + final String sasSignature = + settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ? settings + .get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null; + + if (accountName != null && accountKey != null && sasSignature == null) { + if (Base64.validateIsBase64String(accountKey)) { + return new StorageCredentialsAccountAndKey(accountName, accountKey); + } else { + throw new InvalidKeyException("Storage Key is not a valid base64 encoded string."); + } + } + if (accountName == null && accountKey == null && sasSignature != null) { + return new StorageCredentialsSharedAccessSignature(sasSignature); + } + + return null; + } + + /** + * Tries to determine the storage credentials from a connection string. + * + * @param connectionString + * A String that contains the key/value pairs that represent the storage credentials. + *

+ * The format for the connection string is in the pattern "keyname=value". Multiple key/value + * pairs can be separated by a semi-colon, for example, "keyname1=value1;keyname2=value2". + * + * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection + * string. + * + * @throws InvalidKeyException + * If the account key specified in connectionString is not valid. + * @throws StorageException + * If a storage service error occurred. + */ + public static StorageCredentials tryParseCredentials(final String connectionString) + throws InvalidKeyException, StorageException { + return tryParseCredentials(Utility.parseAccountString(connectionString)); + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // ComputeHmac method will return a valid HMAC-encoded + // signature string when called using the specified credentials. + // + // @return True if these credentials will yield a valid + // signature string; otherwise, false + // + /** Reserved. */ + public abstract Boolean canCredentialsComputeHmac(); + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key authentication scheme using + // the specified credentials. + // + // @return True if a request can be signed with these + // credentials; otherwise, false + // + /** Reserved. */ + public abstract Boolean canCredentialsSignRequest(); + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key Lite authentication scheme + // using the specified credentials. + // + // @return true if a request can be signed with these + // credentials; otherwise, false + // + /** Reserved. */ + public abstract Boolean canCredentialsSignRequestLite(); + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA256-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + public abstract String computeHmac256(String value) throws InvalidKeyException; + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation + * context. + * + * @param value + * The UTF-8-encoded string to sign. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that contains the HMAC-SHA256-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + public abstract String computeHmac256(String value, OperationContext opContext) throws InvalidKeyException; + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA512-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + public abstract String computeHmac512(String value) throws InvalidKeyException; + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation + * context. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that contains the HMAC-SHA512-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + public abstract String computeHmac512(String value, OperationContext opContext) throws InvalidKeyException; + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // TransformUri method should be called to transform a resource + // URI to a URI that includes a token for a shared access signature. + // + // @return True if the URI must be transformed; otherwise, + // false + // + /** Reserved. */ + public abstract Boolean doCredentialsNeedTransformUri(); + + /** + * Returns the associated account name for the credentials. + * + * @return A String that represents the associated account name for the credentials + */ + public abstract String getAccountName(); + + /** + * Signs a request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signRequest(HttpURLConnection request, long contentLength) + throws InvalidKeyException, StorageException; + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signRequest(HttpURLConnection request, long contentLength, OperationContext opContext) + throws InvalidKeyException, StorageException; + + /** + * Signs a request under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + public abstract void signRequestLite(HttpURLConnection request, long contentLength) + throws StorageException, InvalidKeyException; + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public abstract void signRequestLite(HttpURLConnection request, long contentLength, OperationContext opContext) + throws StorageException, InvalidKeyException; + + /** + * Returns a String that represents this instance. + * + * @param exportSecrets + * true to include sensitive data in the return string; otherwise, false. + * @return A String that represents this object, optionally including sensitive data. + */ + public abstract String toString(Boolean exportSecrets); + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + public abstract URI transformUri(URI resourceUri) throws URISyntaxException, StorageException; + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the + * specified operation context. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + public abstract URI transformUri(URI resourceUri, OperationContext opContext) + throws URISyntaxException, StorageException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java new file mode 100644 index 0000000000000..ce60e67a9568c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -0,0 +1,366 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; + +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; + +/** + * Represents storage account credentials, based on storage account and access key, for accessing the Windows Azure + * storage services. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageCredentialsAccountAndKey extends StorageCredentials { + + /** + * The internal Credentials associated with the StorageCredentials. + */ + private Credentials credentials; + + /** + * Creates an instance of the StorageCredentialsAccountAndKey class, using the specified storage + * account name and access key; the specified access key is in the form of a byte array. + * + * @param accountName + * A String that represents the name of the storage account. + * @param key + * An array of bytes that represent the account access key. + */ + public StorageCredentialsAccountAndKey(final String accountName, final byte[] key) { + this.credentials = new Credentials(accountName, key); + } + + /** + * Creates an instance of the StorageCredentialsAccountAndKey class, using the specified storage + * account name and access key; the specified access key is stored as a String. + * + * @param accountName + * A String that represents the name of the storage account. + * @param key + * A String that represents the Base-64-encoded account access key. + */ + public StorageCredentialsAccountAndKey(final String accountName, final String key) { + this(accountName, Base64.decode(key)); + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // ComputeHmac method will return a valid HMAC-encoded + // signature string when called using the specified credentials. + // + // @return True + // + /** Reserved. */ + @Override + public Boolean canCredentialsComputeHmac() { + return true; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key authentication scheme using + // the specified credentials. + // + // @return True + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequest() { + return true; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key Lite authentication scheme + // using the specified credentials. + // + // @return True + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequestLite() { + return true; + } + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA256-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + @Override + public String computeHmac256(final String value) throws InvalidKeyException { + return this.computeHmac256(value, null); + } + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation + * context. + * + * @param value + * The UTF-8-encoded string to sign. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that contains the HMAC-SHA256-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + @Override + public String computeHmac256(final String value, final OperationContext opContext) throws InvalidKeyException { + return StorageKey.computeMacSha256(this.credentials.getKey(), value); + } + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA512-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + @Override + public String computeHmac512(final String value) throws InvalidKeyException { + return this.computeHmac512(value, null); + } + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation + * context. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A String that contains the HMAC-SHA512-encoded signature. + * + * @throws InvalidKeyException + * If the key is not a valid Base64-encoded string. + */ + @Override + public String computeHmac512(final String value, final OperationContext opContext) throws InvalidKeyException { + return StorageKey.computeMacSha512(this.credentials.getKey(), value); + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // TransformUri method should be called to transform a resource + // URI to a URI that includes a token for a shared access signature. + // + // @return False. + // + /** Reserved. */ + @Override + public Boolean doCredentialsNeedTransformUri() { + return false; + } + + /** + * Returns the associated account name for the credentials. + * + * @return A String that contains the account name for the credentials. + */ + @Override + public String getAccountName() { + return this.credentials.getAccountName(); + } + + /** + * Returns the Base64-encoded key for the credentials. + * + * @return A String that contains the Base64-encoded key. + */ + protected String getBase64EncodedKey() { + return this.credentials.getKey().getBase64EncodedKey(); + } + + /** + * Returns the internal credentials associated with the storage credentials. + * + * @return A Credentials object that contains the internal credentials associated with this instance of + * the StorageCredentialsAccountAndKey class. + */ + public Credentials getCredentials() { + return this.credentials; + } + + /** + * Sets the credentials. + * + * @param credentials + * A Credentials object that represents the credentials to set for this instance of the + * StorageCredentialsAccountAndKey class. + */ + public void setCredentials(final Credentials credentials) { + this.credentials = credentials; + } + + /** + * Signs a request under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signRequest(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signRequest(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signRequest( + final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext) + throws InvalidKeyException, StorageException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForBlobAndQueue(request, this.credentials, contentLength, opContext); + } + + /** + * Signs a request using the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If an unspecified storage exception occurs. + */ + @Override + public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) + throws InvalidKeyException, StorageException { + this.signRequestLite(request, contentLength, null); + } + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws InvalidKeyException + * If the given key is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + @Override + public void signRequestLite( + final java.net.HttpURLConnection request, final long contentLength, OperationContext opContext) + throws StorageException, InvalidKeyException { + opContext = opContext == null ? new OperationContext() : opContext; + BaseRequest.signRequestForTableSharedKeyLite(request, this.credentials, contentLength, opContext); + } + + /** + * Returns a String that represents this instance, optionally including sensitive data. + * + * @param exportSecrets + * true to include sensitive data in the return string; otherwise, false. + * + * @return A String that represents this object, optionally including sensitive data. + */ + @Override + public String toString(final Boolean exportSecrets) { + return String.format("%s=%s;%s=%s", + CloudStorageAccount.ACCOUNT_NAME_NAME, + this.getAccountName(), + CloudStorageAccount.ACCOUNT_KEY_NAME, + exportSecrets ? this.credentials.getKey().getBase64EncodedKey() : "[key hidden]"); + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + @Override + public URI transformUri(final URI resourceUri) { + return this.transformUri(resourceUri, null); + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the + * specified operation context. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + @Override + public URI transformUri(final URI resourceUri, final OperationContext opContext) { + return resourceUri; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java new file mode 100644 index 0000000000000..cff7534710b3a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -0,0 +1,267 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.URI; + +/** + * *RESERVED FOR INTERNAL USE* Represents credentials for anonymous access. This class is used by the internal + * implementation (not a public class, so its comments are not built into the Javadoc output). + * + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageCredentialsAnonymous extends StorageCredentials { + + /** + * Stores the singleton instance of this class. + */ + public static final StorageCredentials ANONYMOUS = new StorageCredentialsAnonymous(); + + /** + * Returns the singleton instance of the StorageCredentials class. + * + * @return the singleton instance of this class + */ + protected static StorageCredentials getInstance() { + return StorageCredentialsAnonymous.ANONYMOUS; + } + + /** + * Enforces the singleton pattern via a private constructor. + */ + protected StorageCredentialsAnonymous() { + // Empty Default Ctor + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // ComputeHmac method will return a valid HMAC-encoded + // signature string when called using the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsComputeHmac() { + return false; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key authentication scheme using + // the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequest() { + return false; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key Lite authentication scheme + // using the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequestLite() { + return false; + } + + /** + * Encodes a Shared Key or Shared Key Lite signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded + * string-to-sign. This is not a valid operation for objects of type StorageCredentialsAnonymous so the + * method merely returns null. + * + * @param value + * the UTF-8-encoded string-to-sign + * @return null for objects of type StorageCredentialsAnonymous + */ + @Override + public String computeHmac256(final String value) { + return null; + } + + /** + * Encodes a Shared Key or Shared Key Lite signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded + * string-to-sign and the specified operation context. This is not a valid operation for objects of type + * StorageCredentialsAnonymous so the method merely returns null. + * + * @param value + * the UTF-8-encoded string-to-sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + * @return null for objects of type StorageCredentialsAnonymous + */ + @Override + public String computeHmac256(final String value, final OperationContext opContext) { + return null; + } + + /** + * Encodes a Shared Key signature string by using the HMAC-SHA512 algorithm over a UTF-8-encoded string-to-sign. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method merely + * returns null. + * + * @param value + * the UTF-8-encoded string-to-sign + * @return null for objects of type StorageCredentialsAnonymous + */ + @Override + public String computeHmac512(final String value) { + return null; + } + + /** + * Encodes a Shared Key signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded string-to-sign. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method merely + * returns null. + * + * @param value + * the UTF-8-encoded string-to-sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + * + * @return null for objects of type StorageCredentialsAnonymous + */ + @Override + public String computeHmac512(final String value, final OperationContext opContext) { + return null; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // TransformUri method should be called to transform a resource + // URI to a URI that includes a token for a shared access signature. + // + // @return False. + // + /** Reserved. */ + @Override + public Boolean doCredentialsNeedTransformUri() { + return false; + } + + /** + * Returns the associated account name for the credentials. This is null for anonymous credentials. + * + * @return null for anonymous credentials + */ + @Override + public String getAccountName() { + return null; + } + + /** + * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid + * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signRequest(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials and operation context under the Shared Key authentication scheme. + * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs + * a no-op. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param contentLength + * the length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + public void signRequest( + final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. + * + * @param connection + * the request, as an HttpURLConnection object, to sign + */ + @Override + public void signRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @param request + * the request, as an HttpURLConnection object, to sign + * @param opContext + * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} + * object, that represents the current operation + */ + @Override + public void signRequestLite( + final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { + // No op + } + + /** + * Returns a String object that represents this instance. + * + * @param exportSecrets + * true to include sensitive data in the string; otherwise, false + * @return a string representation of the credentials, optionally including sensitive data. + */ + @Override + public String toString(final Boolean exportSecrets) { + return Constants.EMPTY_STRING; + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token. No transform + * occurs for anonymous credentials, so this method returns the same URI that is passed in. + * + * @param resourceUri + * the resource URI to be transformed + * @return the unmodified value passed in for the resourceUri parameter + */ + @Override + public URI transformUri(final URI resourceUri) { + return this.transformUri(resourceUri, null); + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token. No transform + * occurs for anonymous credentials, so this method returns the same URI that is passed in. + * + * @param resourceUri + * the resource URI to be transformed + * @param opContext + * the an operation context, as a + * {@link com.microsoft.windowsazure.services.core.storage.OperationContext} object, that represents the + * current operation + * + * @return the unmodified value passed in for the resourceUri parameter + */ + @Override + public URI transformUri(final URI resourceUri, final OperationContext opContext) { + return resourceUri; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java new file mode 100644 index 0000000000000..ddb1fa7ac1e2b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -0,0 +1,298 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.net.URI; +import java.net.URISyntaxException; + +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; + +/** + * Represents storage credentials for delegated access to Blob service resources via a shared access signature. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageCredentialsSharedAccessSignature extends StorageCredentials { + + /** + * Stores the shared access signature token. + */ + private final String token; + + /** + * Creates an instance of the StorageCredentialsSharedAccessSignature class using the specified shared + * access signature token. + * + * @param token + * A String that represents shared access signature token. + */ + public StorageCredentialsSharedAccessSignature(final String token) { + this.token = token; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // ComputeHmac method will return a valid HMAC-encoded + // signature string when called using the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsComputeHmac() { + return false; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key authentication scheme using + // the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequest() { + return false; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether a + // request can be signed under the Shared Key Lite authentication scheme + // using the specified credentials. + // + // @return False + // + /** Reserved. */ + @Override + public Boolean canCredentialsSignRequestLite() { + return false; + } + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm. This is not a valid operation for + * objects of type StorageCredentialsSharedAccessSignature so the method merely returns + * null. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return null for objects of type StorageCredentialsSharedAccessSignature. + */ + @Override + public String computeHmac256(final String value) { + return null; + } + + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation + * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature + * so the method merely returns null. + * + * @param value + * The UTF-8-encoded string to sign. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return null for objects of type StorageCredentialsSharedAccessSignature. + */ + @Override + public String computeHmac256(final String value, final OperationContext opContext) { + return null; + } + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm. This is not a valid operation for + * objects of type StorageCredentialsSharedAccessSignature so the method merely returns + * null. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @return null for objects of type StorageCredentialsSharedAccessSignature. + */ + @Override + public String computeHmac512(final String value) { + return null; + } + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation + * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature + * so the method merely returns null. + * + * @param value + * The UTF-8-encoded string to sign. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return null for objects of type StorageCredentialsSharedAccessSignature. + */ + @Override + public String computeHmac512(final String value, final OperationContext opContext) { + return null; + } + + // + // RESERVED, for internal use only. Gets a value indicating whether the + // TransformUri method should be called to transform a resource + // URI to a URI that includes a token for a shared access signature. + // + // @return True. + // + /** Reserved. */ + @Override + public Boolean doCredentialsNeedTransformUri() { + return true; + } + + /** + * Returns the associated account name for the credentials. This is not a valid operation for objects of type + * StorageCredentialsSharedAccessSignature so the method merely returns null. + * + * @return null for objects of type StorageCredentialsSharedAccessSignature. + */ + @Override + public String getAccountName() { + return null; + } + + /** + * Returns the shared access signature token. + * + * @return A String that contains the token. + */ + public String getToken() { + return this.token; + } + + /** + * Signs a request under the Shared Key authentication scheme. This is not a valid operation for objects of type + * StorageCredentialsSharedAccessSignature so the method performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signRequest(final java.net.HttpURLConnection request, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified operation context under the Shared Key authentication scheme. This is not a + * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a + * no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + */ + @Override + public void signRequest( + final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { + // No op + } + + /** + * Signs a request under the Shared Key Lite authentication scheme. This is not a valid operation for objects of + * type StorageCredentialsSharedAccessSignature so the method performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + */ + @Override + public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) { + // No op + } + + /** + * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. This is + * not a valid operation for objects of type StorageCredentialsSharedAccessSignature so the method + * performs a no-op. + * + * @param request + * An HttpURLConnection object that represents the request to sign. + * @param contentLength + * The length of the content written to the output stream. If unknown, specify -1. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + */ + @Override + public void signRequestLite( + final java.net.HttpURLConnection request, final long contentLength, final OperationContext opContext) { + // No op + } + + /** + * Returns a String that represents this instance, optionally including sensitive data. + * + * @param exportSecrets + * true to include sensitive data in the return string; otherwise, false. + * @return A String that represents this object, optionally including sensitive data. + */ + @Override + public String toString(final Boolean exportSecrets) { + return String.format("%s=%s", CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME, exportSecrets ? this.token + : "[signature hidden]"); + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws IllegalArgumentException + * If a parameter is invalid. + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + @Override + public URI transformUri(final URI resourceUri) throws URISyntaxException, StorageException { + return this.transformUri(resourceUri, null); + } + + /** + * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the + * specified operation context. + * + * @param resourceUri + * A java.net.URI object that represents the resource URI to be transformed. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A java.net.URI object that represents the signature, including the resource URI and the + * shared access token. + * + * @throws StorageException + * If a storage service error occurred. + * @throws URISyntaxException + * If the resource URI is not properly formatted. + */ + @Override + public URI transformUri(final URI resourceUri, final OperationContext opContext) + throws URISyntaxException, StorageException { + return PathUtility.addToQuery(resourceUri, this.token); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java new file mode 100644 index 0000000000000..3eae71b7668d2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java @@ -0,0 +1,124 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * + * Represents error codes that may be returned by the Windows Azure storage services or the storage client library. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum StorageErrorCode { + /** + * Access was denied (client-side error). + */ + ACCESS_DENIED(12), + + /** + * The specified account was not found (client-side error). + */ + ACCOUNT_NOT_FOUND(8), + + /** + * An authentication error occurred (client-side error). + */ + AUTHENTICATION_FAILURE(11), + + /** + * There was an error with the gateway used for the request (client-side error). + */ + BAD_GATEWAY(18), + + /** + * The request was incorrect or badly formed (client-side error). + */ + BAD_REQUEST(16), + + /** + * The specified blob already exists (client-side error). + */ + BLOB_ALREADY_EXISTS(15), + + /** + * The specified blob was not found (client-side error). + */ + BLOB_NOT_FOUND(10), + + /** + * The specified condition failed (client-side error). + */ + CONDITION_FAILED(17), + + /** + * The specified container already exists (client-side error). + */ + CONTAINER_ALREADY_EXISTS(14), + + /** + * The specified container was not found (client-side error). + */ + CONTAINER_NOT_FOUND(9), + + /** + * The request version header is not supported (client-side error). + */ + HTTP_VERSION_NOT_SUPPORTED(20), + + /** + * No error specified. + */ + NONE(0), + + /** + * The requested operation is not implemented on the specified resource (client-side error). + */ + NOT_IMPLEMENTED(19), + + /** + * The specified resource already exists (client-side error). + */ + RESOURCE_ALREADY_EXISTS(13), + + /** + * The specified resource was not found (client-side error). + */ + RESOURCE_NOT_FOUND(7), + + /** + * The service returned a bad response (server-side error). + */ + SERVICE_BAD_REQUEST(6), + + /** + * A service integrity check failed (server-side error). + */ + SERVICE_INTEGRITY_CHECK_FAILED(4), + + /** + * An internal server error occurred (server-side error). + */ + SERVICE_INTERNAL_ERROR(1), + + /** + * The service timed out (server-side error). + */ + SERVICE_TIMEOUT(3), + + /** + * A transport error occurred (server-side error). + */ + TRANSPORT_ERROR(5); + + /** + * Returns the value of this enum. + */ + public int value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + StorageErrorCode(final int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java new file mode 100644 index 0000000000000..60f0b09615f4c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java @@ -0,0 +1,220 @@ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents error code strings that are common to all storage services. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageErrorCodeStrings { + /** + * Authentication failed. + */ + public static final String AUTHENTICATION_FAILED = "AuthenticationFailed"; + + /** + * The specified condition was not met. + */ + public static final String CONDITION_NOT_MET = "ConditionNotMet"; + + /** + * The specified container already exists. + */ + public static final String CONTAINER_ALREADY_EXISTS = "ContainerAlreadyExists"; + + /** + * The specified queue already exists. + */ + public static final String QUEUE_ALREADY_EXISTS = "QueueAlreadyExists"; + + /** + * The specified container is being deleted. + */ + public static final String CONTAINER_BEING_DELETED = "ContainerBeingDeleted"; + + /** + * The specified queue is being deleted. + */ + public static final String QUEUE_BEING_DELETED = "QueueBeingDeleted"; + + /** + * The specified container is disabled. + */ + public static final String CONTAINER_DISABLED = "ContainerDisabled"; + + /** + * The specified container was not found. + */ + public static final String CONTAINER_NOT_FOUND = "ContainerNotFound"; + + /** + * An incorrect blob type was specified. + */ + public static final String INCORRECT_BLOB_TYPE = "IncorrectBlobType"; + + /** + * An incorrect blob type was specified. + */ + public static final String INVALID_BLOB_TYPE = "InvalidBlobType"; + + /** + * The metadata key is empty. + */ + public static final String EMPTY_METADATA_KEY = "EmptyMetadataKey"; + + /** + * An internal error occurred. + */ + public static final String INTERNAL_ERROR = "InternalError"; + + /** + * One or more header values are invalid. + */ + public static final String INVALID_HEADER_VALUE = "InvalidHeaderValue"; + + /** + * The HTTP verb is invalid. + */ + public static final String INVALID_HTTP_VERB = "InvalidHttpVerb"; + + /** + * The input is invalid. + */ + public static final String INVALID_INPUT = "InvalidInput"; + + /** + * The specified MD5 hash is invalid. + */ + public static final String INVALID_MD5 = "InvalidMd5"; + + /** + * The specified metadata is invalid. + */ + public static final String INVALID_METADATA = "InvalidMetadata"; + + /** + * One or more query parameters are invalid. + */ + public static final String INVALID_QUERY_PARAMETER_VALUE = "InvalidQueryParameterValue"; + + /** + * The specified range is invalid. + */ + public static final String INVALID_RANGE = "InvalidRange"; + + /** + * The URI is invalid. + */ + public static final String INVALID_URI = "InvalidUri"; + + /** + * The specified XML document is invalid. + */ + public static final String INVALID_XML_DOCUMENT = "InvalidXmlDocument"; + + /** + * One or more XML node values are invalid. + */ + public static final String INVALID_XML_NODE_VALUE = "InvalidXmlNodeValue"; + + /** + * The specified MD5 hash does not match the server value. + */ + public static final String MD5_MISMATCH = "Md5Mismatch"; + + /** + * The specified metadata is too large. + */ + public static final String METADATA_TOO_LARGE = "MetadataTooLarge"; + + /** + * The Content-Length header is required for this request. + */ + public static final String MISSING_CONTENT_LENGTH_HEADER = "MissingContentLengthHeader"; + + /** + * A required header was missing. + */ + public static final String MISSING_REQUIRED_HEADER = "MissingRequiredHeader"; + + /** + * A required query parameter is missing. + */ + public static final String MISSING_REQUIRED_QUERY_PARAMETER = "MissingRequiredQueryParameter"; + + /** + * A required XML node was missing. + */ + public static final String MISSING_REQUIRED_XML_NODE = "MissingRequiredXmlNode"; + + /** + * The operation timed out. + */ + public static final String OPERATION_TIMED_OUT = "OperationTimedOut"; + + /** + * The input is out of range. + */ + public static final String OUT_OF_RANGE_INPUT = "OutOfRangeInput"; + + /** + * One or more query parameters are out of range. + */ + public static final String OUT_OF_RANGE_QUERY_PARAMETER_VALUE = "OutOfRangeQueryParameterValue"; + + /** + * The request body is too large. + */ + public static final String REQUEST_BODY_TOO_LARGE = "RequestBodyTooLarge"; + + /** + * The specified resource was not found. + */ + public static final String RESOURCE_NOT_FOUND = "ResourceNotFound"; + + /** + * The server is busy. + */ + public static final String SERVER_BUSY = "ServerBusy"; + + /** + * One or more header values are not supported. + */ + public static final String UNSUPPORTED_HEADER = "UnsupportedHeader"; + + /** + * The specified HTTP verb is not supported. + */ + public static final String UNSUPPORTED_HTTP_VERB = "UnsupportedHttpVerb"; + + /** + * One or more query parameters is not supported. + */ + public static final String UNSUPPORTED_QUERY_PARAMETER = "UnsupportedQueryParameter"; + + /** + * One or more XML nodes are not supported. + */ + public static final String UNSUPPORTED_XML_NODE = "UnsupportedXmlNode"; + + /** + * The lease is already broken. + */ + public static final String LEASE_ALREADY_BROKEN = "LeaseAlreadyBroken"; + + /** + * The lease is already present. + */ + public static final String LEASE_ALREADY_PRESENT = "LeaseAlreadyPresent"; + + /** + * The lease ID is missing. + */ + public static final String LEASE_ID_MISSING = "LeaseIdMissing"; + + /** + * Private Default Ctor. + */ + private StorageErrorCodeStrings() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java new file mode 100644 index 0000000000000..f8cf4fc0c5a64 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java @@ -0,0 +1,244 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.io.IOException; +import java.net.HttpURLConnection; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse; + +/** + * Represents an exception for the Windows Azure storage service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageException extends Exception { + + /** + * Represents the serialization version number. + */ + private static final long serialVersionUID = 7972747254288274928L; + + /** + * Returns extended error information from the specified request and operation context. + * + * @param request + * An HttpURLConnection object that represents the request whose extended error information + * is being retrieved. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link StorageExtendedErrorInformation} object that represents the error details for the specified + * request. + */ + protected static StorageExtendedErrorInformation getErrorDetailsFromRequest( + final HttpURLConnection request, final OperationContext opContext) { + if (request == null) { + return null; + } + try { + final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream()); + return response.getExtendedErrorInformation(); + } catch (final XMLStreamException e) { + return null; + } + } + + /** + * Translates the specified exception into a storage exception. + * + * @param request + * An HttpURLConnection object that represents the request whose exception is being + * translated. + * @param cause + * An Exception object that represents the exception to translate. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A StorageException object that represents translated exception. + */ + public static StorageException translateException( + final HttpURLConnection request, final Exception cause, final OperationContext opContext) { + if (request == null) { + return new StorageException("Client error", + "A Client side exception occurred, please check the inner exception for details", + Constants.HeaderConstants.HTTP_UNUSED_306, null, cause); + } + + final StorageExtendedErrorInformation extendedError = getErrorDetailsFromRequest(request, opContext); + StorageException translatedException = null; + + String responseMessage = Constants.EMPTY_STRING; + int responseCode = 0; + try { + responseCode = request.getResponseCode(); + responseMessage = request.getResponseMessage(); + } catch (final IOException e) { + // ignore errors + } + + if (responseMessage == null) { + responseMessage = Constants.EMPTY_STRING; + } + + // 1. If extended information is available use it + if (extendedError != null) { + translatedException = + new StorageException(extendedError.getErrorCode(), responseMessage, responseCode, extendedError, + cause); + + if (translatedException != null) { + return translatedException; + } + } + + // 2. If extended information is unavailable, translate exception based + // on status code + translatedException = translateFromHttpStatus(responseCode, responseMessage, null, cause); + + if (translatedException != null) { + return translatedException; + } + + return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), + "The server encountered an unknown failure: ".concat(responseMessage), + HttpURLConnection.HTTP_INTERNAL_ERROR, null, cause); + } + + /** + * Translates the specified HTTP status code into a storage exception. + * + * @param statusCode + * The HTTP status code returned by the operation. + * @param statusDescription + * A String that represents the status description. + * @param details + * A {@link StorageExtendedErrorInformation} object that represents the errror details returned by the + * operation. + * @param inner + * An Exception object that represents a reference to the initial exception, if one exists. + * + * @return A StorageException object that represents translated exception. + **/ + protected static StorageException translateFromHttpStatus( + final int statusCode, final String statusDescription, final StorageExtendedErrorInformation details, + final Exception inner) { + switch (statusCode) { + case HttpURLConnection.HTTP_FORBIDDEN: + return new StorageException(StorageErrorCode.ACCESS_DENIED.toString(), statusDescription, statusCode, + details, inner); + + case HttpURLConnection.HTTP_GONE: + case HttpURLConnection.HTTP_NOT_FOUND: + return new StorageException(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), statusDescription, + statusCode, details, inner); + + case HttpURLConnection.HTTP_BAD_REQUEST: + return new StorageException(StorageErrorCode.BAD_REQUEST.toString(), statusDescription, statusCode, + details, inner); + + case HttpURLConnection.HTTP_PRECON_FAILED: + case HttpURLConnection.HTTP_NOT_MODIFIED: + return new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), statusDescription, + statusCode, details, inner); + + case HttpURLConnection.HTTP_CONFLICT: + return new StorageException(StorageErrorCode.RESOURCE_ALREADY_EXISTS.toString(), statusDescription, + statusCode, details, inner); + + case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: + return new StorageException(StorageErrorCode.SERVICE_TIMEOUT.toString(), statusDescription, statusCode, + details, inner); + + case 416: + // RequestedRangeNotSatisfiable - No corresponding enum in HttpURLConnection + return new StorageException(StorageErrorCode.BAD_REQUEST.toString(), statusDescription, statusCode, + details, inner); + + case HttpURLConnection.HTTP_INTERNAL_ERROR: + return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), statusDescription, + statusCode, details, inner); + + case HttpURLConnection.HTTP_NOT_IMPLEMENTED: + return new StorageException(StorageErrorCode.NOT_IMPLEMENTED.toString(), statusDescription, statusCode, + details, inner); + + case HttpURLConnection.HTTP_BAD_GATEWAY: + return new StorageException(StorageErrorCode.BAD_GATEWAY.toString(), statusDescription, statusCode, + details, inner); + + case HttpURLConnection.HTTP_VERSION: + return new StorageException(StorageErrorCode.HTTP_VERSION_NOT_SUPPORTED.toString(), statusDescription, + statusCode, details, inner); + default: + return null; + } + } + + /** + * Represents the error code returned by the operation. + */ + private final String errorCode; + + /** + * Represents the extended error information returned by the operation. + * + * @see StorageExtendedErrorInformation + */ + private final StorageExtendedErrorInformation extendedErrorInformation; + + /** + * Represents the HTTP status code returned by the operation. + */ + private final int httpStatusCode; + + /** + * Creates an instance of the StorageException class using the specified parameters. + * + * @param errorCode + * A String that represents the error code returned by the operation. + * @param message + * A String that represents the error message returned by the operation. + * @param statusCode + * The HTTP status code returned by the operation. + * @param extendedErrorInfo + * A {@link StorageExtendedErrorInformation} object that represents the extended error information + * returned by the operation. + * @param innerException + * An Exception object that represents a reference to the initial exception, if one exists. + * + * @see StorageExtendedErrorInformation + */ + public StorageException(final String errorCode, final String message, final int statusCode, + final StorageExtendedErrorInformation extendedErrorInfo, final Exception innerException) { + super(message, innerException); + this.errorCode = errorCode; + this.httpStatusCode = statusCode; + this.extendedErrorInformation = extendedErrorInfo; + } + + /** + * @return the errorCode + */ + public String getErrorCode() { + return this.errorCode; + } + + /** + * @return the extendedErrorInformation + */ + public StorageExtendedErrorInformation getExtendedErrorInformation() { + return this.extendedErrorInformation; + } + + /** + * @return the httpStatusCode + */ + public int getHttpStatusCode() { + return this.httpStatusCode; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java new file mode 100644 index 0000000000000..d768cfbb74601 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java @@ -0,0 +1,83 @@ +package com.microsoft.windowsazure.services.core.storage; + +import java.io.Serializable; +import java.util.HashMap; + +/** + * Represents extended error information returned by the Windows Azure storage service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageExtendedErrorInformation implements Serializable { + /** + * The serialization version number. + */ + private static final long serialVersionUID = 1527013626991334677L; + + /** + * Represents additional error details, as a java.util.HashMap object. + */ + private HashMap additionalDetails; + + /** + * Represents the storage service error code. + */ + private String errorCode; + + /** + * Represents the storage service error message. + */ + private String errorMessage; + + /** + * Creates an instance of the StorageExtendedErrorInformation class. + */ + public StorageExtendedErrorInformation() { + this.setAdditionalDetails(new HashMap()); + } + + /** + * @return the additionalDetails + */ + public HashMap getAdditionalDetails() { + return this.additionalDetails; + } + + /** + * @return the errorCode + */ + public String getErrorCode() { + return this.errorCode; + } + + /** + * @return the errorMessage + */ + protected String getErrorMessage() { + return this.errorMessage; + } + + /** + * @param additionalDetails + * the additionalDetails to set + */ + protected void setAdditionalDetails(final HashMap additionalDetails) { + this.additionalDetails = additionalDetails; + } + + /** + * @param errorCode + * the errorCode to set + */ + public void setErrorCode(final String errorCode) { + this.errorCode = errorCode; + } + + /** + * @param errorMessage + * the errorMessage to set + */ + public void setErrorMessage(final String errorMessage) { + this.errorMessage = errorMessage; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java new file mode 100644 index 0000000000000..17ca96d3941dd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java @@ -0,0 +1,200 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.Mac; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; + +import com.microsoft.windowsazure.services.core.storage.utils.Base64; + +/** + * Represents a container for a storage key. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageKey { + /** + * Computes a signature for the specified string using the HMAC-SHA256 algorithm. + * + * @param storageKey + * A StorageKey object that represents the storage key to use. + * @param stringToSign + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA256-encoded signature. + * + * @throws IllegalArgumentException + * If the string to sign is not a valid Base64-encoded string. + * @throws InvalidKeyException + * If the key is not a valid storage key. + */ + public static synchronized String computeMacSha256(final StorageKey storageKey, final String stringToSign) + throws InvalidKeyException { + if (storageKey.hmacSha256 == null) { + storageKey.initHmacSha256(); + } + + byte[] utf8Bytes = null; + try { + utf8Bytes = stringToSign.getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw new IllegalArgumentException(e); + } + + return Base64.encode(storageKey.hmacSha256.doFinal(utf8Bytes)); + } + + /** + * Computes a signature for the specified string using the HMAC-SHA512 algorithm. + * + * @param storageKey + * A StorageKey object that represents the storage key to use. + * @param stringToSign + * The UTF-8-encoded string to sign. + * + * @return A String that contains the HMAC-SHA512-encoded signature. + * + * @throws IllegalArgumentException + * If the string to sign is not a valid Base64-encoded string. + * @throws InvalidKeyException + * If the key is not a valid storage key. + */ + public static synchronized String computeMacSha512(final StorageKey storageKey, final String stringToSign) + throws InvalidKeyException { + if (storageKey.hmacSha512 == null) { + storageKey.initHmacSha512(); + } + + byte[] utf8Bytes = null; + try { + utf8Bytes = stringToSign.getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw new IllegalArgumentException(e); + } + + return Base64.encode(storageKey.hmacSha512.doFinal(utf8Bytes)); + } + + /** + * Stores a reference to the hmacsha256 Mac. + */ + private Mac hmacSha256; + + /** + * Stores a reference to the hmacsha512 Mac. + */ + private Mac hmacSha512; + + /** + * Stores a reference to the hmacsha256 SecretKey. + */ + private SecretKey key256; + + /** + * Stores a reference to the hmacsha512 SecretKey. + */ + private SecretKey key512; + + /** + * Stores the key. + */ + private byte[] key; + + /** + * Creates an instance of the StorageKey class. + * + * @param key + * An array of bytes that represent the storage key. + */ + public StorageKey(final byte[] key) { + this.setKey(key); + } + + /** + * Returns the Base64-encoded key. + * + * @return A String that represents the Base64-encoded key. + */ + public String getBase64EncodedKey() { + return Base64.encode(this.key); + } + + /** + * Returns the key. + * + * @return A byte array that represents the key. + */ + public byte[] getKey() { + final byte[] copy = this.key.clone(); + return copy; + } + + /** + * Initializes the hmacsha256 Mac and SecretKey. + * + * @throws InvalidKeyException + * if the key is not a valid SecretKey according to spec. + */ + private void initHmacSha256() throws InvalidKeyException { + this.key256 = new SecretKeySpec(this.key, "HmacSHA256"); + try { + this.hmacSha256 = Mac.getInstance("HmacSHA256"); + } catch (final NoSuchAlgorithmException e) { + throw new IllegalArgumentException(); + } + this.hmacSha256.init(this.key256); + } + + /** + * Initializes the hmacsha512 Mac and SecretKey. + * + * @throws InvalidKeyException + * if the key is not a valid SecretKey according to spec. + */ + private void initHmacSha512() throws InvalidKeyException { + this.key512 = new SecretKeySpec(this.key, "HmacSHA512"); + try { + this.hmacSha512 = Mac.getInstance("HmacSHA512"); + } catch (final NoSuchAlgorithmException e) { + throw new IllegalArgumentException(); + } + this.hmacSha512.init(this.key512); + } + + /** + * Sets the key to be used, using the specified byte array as the key. + *

+ * This method is provided to support key rotation. This method is not thread-safe. + * + * @param key + * A byte array that represents the key being assigned. + */ + public void setKey(final byte[] key) { + this.key = key; + this.hmacSha256 = null; + this.hmacSha512 = null; + this.key256 = null; + this.key512 = null; + } + + /** + * Sets the key to be used, using the specified String as the key. + *

+ * This method is provided to support key rotation. This method is not thread-safe. + * + * @param key + * A String that represents the key being assigned. + * @throws IOException + * If the specified key is not a valid Base64-encoded string. + */ + public void setKey(final String key) throws IOException { + this.key = Base64.decode(key); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java new file mode 100644 index 0000000000000..86bed726877ed --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -0,0 +1,294 @@ +package com.microsoft.windowsazure.services.core.storage.utils; + +/** + * RESERVED FOR INTERNAL USE. Provides Base64 encoding, decoding, and validation functionality. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class Base64 { + /** + * The Base 64 Characters. + */ + private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + /** + * Decoded values, -1 is invalid character, -2 is = pad character. + */ + private static final byte DECODE_64[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* + * 16- 31 + */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* + * 32- 47 + */ + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, /* + * 48- 63 + */ + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 64-79 */ + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* + * 80- 95 + */ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* + * 96- 111 + */ + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* + * 112- 127 + */ + }; + + /** + * Decodes a given Base64 string into its corresponding byte array. + * + * @param data + * the Base64 string, as a String object, to decode + * + * @return the corresponding decoded byte array + * @throws IllegalArgumentException + * If the string is not a valid base64 encoded string + */ + public static byte[] decode(final String data) { + int byteArrayLength = 3 * data.length() / 4; + + if (data.endsWith("==")) { + byteArrayLength -= 2; + } else if (data.endsWith("=")) { + byteArrayLength -= 1; + } + + final byte[] retArray = new byte[byteArrayLength]; + int byteDex = 0; + int charDex = 0; + + for (; charDex < data.length(); charDex += 4) { + // get 4 chars, convert to 3 bytes + final int char1 = DECODE_64[(byte) data.charAt(charDex)]; + final int char2 = DECODE_64[(byte) data.charAt(charDex + 1)]; + final int char3 = DECODE_64[(byte) data.charAt(charDex + 2)]; + final int char4 = DECODE_64[(byte) data.charAt(charDex + 3)]; + + if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { + // invalid character(-1), or bad padding (-2) + throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); + } + + int tVal = char1 << 18; + tVal += char2 << 12; + tVal += (char3 & 0xff) << 6; + tVal += char4 & 0xff; + + if (char3 == -2) { + // two "==" pad chars, check bits 12-24 + tVal &= 0x00FFF000; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + } else if (char4 == -2) { + // one pad char "=" , check bits 6-24. + tVal &= 0x00FFFFC0; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + + } else { + // No pads take all 3 bytes, bits 0-24 + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + retArray[byteDex++] = (byte) (tVal & 0xFF); + } + } + return retArray; + } + + /** + * Decodes a given Base64 string into its corresponding byte array. + * + * @param data + * the Base64 string, as a String object, to decode + * + * @return the corresponding decoded byte array + * @throws IllegalArgumentException + * If the string is not a valid base64 encoded string + */ + public static Byte[] decodeAsByteObjectArray(final String data) { + int byteArrayLength = 3 * data.length() / 4; + + if (data.endsWith("==")) { + byteArrayLength -= 2; + } else if (data.endsWith("=")) { + byteArrayLength -= 1; + } + + final Byte[] retArray = new Byte[byteArrayLength]; + int byteDex = 0; + int charDex = 0; + + for (; charDex < data.length(); charDex += 4) { + // get 4 chars, convert to 3 bytes + final int char1 = DECODE_64[(byte) data.charAt(charDex)]; + final int char2 = DECODE_64[(byte) data.charAt(charDex + 1)]; + final int char3 = DECODE_64[(byte) data.charAt(charDex + 2)]; + final int char4 = DECODE_64[(byte) data.charAt(charDex + 3)]; + + if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { + // invalid character(-1), or bad padding (-2) + throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); + } + + int tVal = char1 << 18; + tVal += char2 << 12; + tVal += (char3 & 0xff) << 6; + tVal += char4 & 0xff; + + if (char3 == -2) { + // two "==" pad chars, check bits 12-24 + tVal &= 0x00FFF000; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + } else if (char4 == -2) { + // one pad char "=" , check bits 6-24. + tVal &= 0x00FFFFC0; + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + + } else { + // No pads take all 3 bytes, bits 0-24 + retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); + retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); + retArray[byteDex++] = (byte) (tVal & 0xFF); + } + } + return retArray; + } + + /** + * Encodes a byte array as a Base64 string. + * + * @param data + * the byte array to encode + * @return the Base64-encoded string, as a String object + */ + public static String encode(final byte[] data) { + final StringBuilder builder = new StringBuilder(); + final int dataRemainder = data.length % 3; + + int j = 0; + int n = 0; + for (; j < data.length; j += 3) { + + if (j < data.length - dataRemainder) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); + } else { + if (dataRemainder == 1) { + n = (data[j] & 0xFF) << 16; + } else if (dataRemainder == 2) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); + } + } + + // Left here for readability + // byte char1 = (byte) ((n >>> 18) & 0x3F); + // byte char2 = (byte) ((n >>> 12) & 0x3F); + // byte char3 = (byte) ((n >>> 6) & 0x3F); + // byte char4 = (byte) (n & 0x3F); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); + } + + final int bLength = builder.length(); + + // append '=' to pad + if (data.length % 3 == 1) { + builder.replace(bLength - 2, bLength, "=="); + } else if (data.length % 3 == 2) { + builder.replace(bLength - 1, bLength, "="); + } + + return builder.toString(); + } + + /** + * Encodes a byte array as a Base64 string. + * + * @param data + * the byte array to encode + * @return the Base64-encoded string, as a String object + */ + public static String encode(final Byte[] data) { + final StringBuilder builder = new StringBuilder(); + final int dataRemainder = data.length % 3; + + int j = 0; + int n = 0; + for (; j < data.length; j += 3) { + + if (j < data.length - dataRemainder) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); + } else { + if (dataRemainder == 1) { + n = (data[j] & 0xFF) << 16; + } else if (dataRemainder == 2) { + n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); + } + } + + // Left here for readability + // byte char1 = (byte) ((n >>> 18) & 0x3F); + // byte char2 = (byte) ((n >>> 12) & 0x3F); + // byte char3 = (byte) ((n >>> 6) & 0x3F); + // byte char4 = (byte) (n & 0x3F); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); + builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); + } + + final int bLength = builder.length(); + + // append '=' to pad + if (data.length % 3 == 1) { + builder.replace(bLength - 2, bLength, "=="); + } else if (data.length % 3 == 2) { + builder.replace(bLength - 1, bLength, "="); + } + + return builder.toString(); + } + + /** + * Determines whether the given string contains only Base64 characters. + * + * @param data + * the string, as a String object, to validate + * @return true if data is a valid Base64 string, otherwise false + */ + public static Boolean validateIsBase64String(final String data) { + + if (data == null || data.length() % 4 != 0) { + return false; + } + + for (int m = 0; m < data.length(); m++) { + final byte charByte = (byte) data.charAt(m); + + // pad char detected + if (DECODE_64[charByte] == -2) { + if (m < data.length() - 2) { + return false; + } else if (m == data.length() - 2 && DECODE_64[(byte) data.charAt(m + 1)] != -2) { + return false; + } + } + + if (charByte < 0 || DECODE_64[charByte] == -1) { + return false; + } + } + + return true; + } + + /** + * Private Default Ctor. + */ + private Base64() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java new file mode 100644 index 0000000000000..508b8c2f5efbe --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -0,0 +1,449 @@ +package com.microsoft.windowsazure.services.core.storage.utils; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageCredentials; +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. A class to help modify paths + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class PathUtility { + /** + * Adds a queryString to an URI. + * + * @param resourceURI + * the URI of the resource + * @param fieldCollection + * the key/ values collection to append. + * @return an appended URI. + * @throws URISyntaxException + * if the resulting URI is invalid. + * @throws StorageException + */ + public static URI addToQuery(final URI resourceURI, final HashMap fieldCollection) + throws URISyntaxException, StorageException { + final UriQueryBuilder outUri = new UriQueryBuilder(); + + // Generate new queryString + for (final Entry entry : fieldCollection.entrySet()) { + for (final String val : entry.getValue()) { + outUri.add(entry.getKey(), val); + } + } + + return outUri.addToURI(resourceURI); + } + + /** + * Adds a queryString to an URI. + * + * @param resourceURI + * the URI of the resource + * @param queryString + * the query string to add + * @return an appended URI. + * @throws URISyntaxException + * if the resulting URI is invalid. + * @throws StorageException + */ + public static URI addToQuery(final URI resourceURI, final String queryString) + throws URISyntaxException, StorageException { + return addToQuery(resourceURI, parseQueryString(queryString)); + } + + /** + * Appends a path to a Uri correctly using "/" as separator. + * + * @param uri + * The base Uri. + * @param relativeOrAbslouteUri + * The relative or absloute URI. + * @return The appended Uri. + * @throws URISyntaxException + */ + public static URI appendPathToUri(final URI uri, final String relativeOrAbslouteUri) throws URISyntaxException { + return appendPathToUri(uri, relativeOrAbslouteUri, "/"); + } + + /** + * Appends a path to a Uri correctly using the given separator. + * + * @param uri + * The base Uri. + * @param relativeOrAbsoluteUri + * The relative or absloute URI. + * @param separator + * the separator to use. + * @return The appended Uri. + * @throws URISyntaxException + */ + public static URI appendPathToUri(final URI uri, final String relativeOrAbsoluteUri, final String separator) + throws URISyntaxException { + + int hostNameBeginIndex = -1; + if (relativeOrAbsoluteUri.length() > 8) { + final String header = relativeOrAbsoluteUri.substring(0, 8).toLowerCase(); + if ("https://".equals(header)) { + hostNameBeginIndex = 8; + } else if ("http://".equals(header.substring(0, 7))) { + hostNameBeginIndex = 7; + } + } + + // absolute URI + if (hostNameBeginIndex > 0) { + final int authorityLength = relativeOrAbsoluteUri.substring(hostNameBeginIndex).indexOf(separator); + final String authorityName = + relativeOrAbsoluteUri.substring(hostNameBeginIndex, hostNameBeginIndex + authorityLength); + final URI absoluteUri = new URI(relativeOrAbsoluteUri); + + if (uri.getAuthority().equals(authorityName)) { + return absoluteUri; + } else { + // Happens when using fiddler, DNS aliases, or potentially NATs + return new URI(uri.getScheme(), uri.getAuthority(), absoluteUri.getPath(), absoluteUri.getRawQuery(), + absoluteUri.getRawFragment()); + } + } else { + // relative URI + // used by directory + if (uri.getPath().length() == 0 && relativeOrAbsoluteUri.startsWith(separator)) { + return new URI(uri.getScheme(), uri.getAuthority(), relativeOrAbsoluteUri, uri.getRawQuery(), + uri.getRawFragment()); + } + + final StringBuilder pathString = new StringBuilder(uri.getPath()); + + if (uri.getPath().endsWith(separator)) { + pathString.append(relativeOrAbsoluteUri); + } else { + pathString.append(separator); + pathString.append(relativeOrAbsoluteUri); + } + + return new URI(uri.getScheme(), uri.getAuthority(), pathString.toString(), uri.getQuery(), + uri.getFragment()); + } + } + + /** + * Gets the blob name from the URI. + * + * @param inURI + * the resource address + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return the blobs name + * @throws URISyntaxException + */ + public static String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris) throws URISyntaxException { + return Utility.safeRelativize(new URI(getContainerURI(inURI, usePathStyleUris).toString().concat("/")), inURI); + } + + /** + * Gets the canonical path for an object from the credentials. + * + * @param credentials + * the credentials to use. + * @param absolutePath + * the Absolute path of the object. + * @return the canonical path for an object from the credentials + */ + public static + String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath) { + final String account = credentials.getAccountName(); + + if (account == null) { + final String errorMessage = + "Cannot create Shared Access Signature as the credentials does not have account name information. Please check that the credentials used support creating Shared Access Signature."; + throw new IllegalArgumentException(errorMessage); + } + final StringBuilder builder = new StringBuilder("/"); + builder.append(account); + builder.append(absolutePath); + return builder.toString(); + } + + /** + * Get the container name from address from the URI. + * + * @param resourceAddress + * The container Uri. + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return container name from address from the URI. + * @throws IllegalArgumentException + */ + public static String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { + return getContainerOrQueueNameFromUri(resourceAddress, + usePathStyleUris, + String.format("Invalid blob address '%s', missing container information", resourceAddress)); + } + + /** + * Get the container or queue name from address from the URI. + * + * @param resourceAddress + * The queue Uri. + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return container name from address from the URI. + * @throws IllegalArgumentException + */ + private static String getContainerOrQueueNameFromUri( + final URI resourceAddress, final boolean usePathStyleUris, final String error) { + Utility.assertNotNull("resourceAddress", resourceAddress); + + final String[] pathSegments = resourceAddress.getRawPath().split("/"); + + final int expectedPartsLength = usePathStyleUris ? 3 : 2; + + if (pathSegments.length < expectedPartsLength) { + throw new IllegalArgumentException(error); + } + + final String containerOrQueueName = usePathStyleUris ? pathSegments[2] : pathSegments[1]; + + return Utility.trimEnd(containerOrQueueName, '/'); + } + + /** + * Gets the container URI from a blob address + * + * @param blobAddress + * the blob address + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return the container URI from a blob address + * @throws URISyntaxException + */ + public static URI getContainerURI(final URI blobAddress, final boolean usePathStyleUris) throws URISyntaxException { + final String containerName = getContainerNameFromUri(blobAddress, usePathStyleUris); + + final URI containerUri = + appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), containerName); + return containerUri; + } + + /** + * Retrieves the parent address for a blob Uri. + * + * @param blobAddress + * The blob address + * @param delimiter + * The delimiter. + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return The address of the parent. + * @throws URISyntaxException + * @throws StorageException + */ + public static URI getParentAddress(final URI blobAddress, final String delimiter, final boolean usePathStyleUris) + throws URISyntaxException, StorageException { + final String parentName = getParentNameFromURI(blobAddress, delimiter, usePathStyleUris); + + final URI parentUri = + appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), parentName); + return parentUri; + } + + /** + * Retrieves the parent name for a blob Uri. + * + * @param resourceAddress + * The resource Uri. + * @param delimiter + * the directory delimiter to use + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return the parent address for a blob Uri. + * @throws URISyntaxException + * @throws StorageException + */ + public static String getParentNameFromURI( + final URI resourceAddress, final String delimiter, final boolean usePathStyleUris) + throws URISyntaxException, StorageException { + Utility.assertNotNull("resourceAddress", resourceAddress); + Utility.assertNotNullOrEmpty("delimiter", delimiter); + + final String containerName = getContainerNameFromUri(resourceAddress, usePathStyleUris); + + /* + * URI baseURI = appendPathToUri( new URI(getServiceClientBaseAddress(resourceAddress, usePathStyleUris)), + * containerName); + */ + URI baseURI = new URI(getServiceClientBaseAddress(resourceAddress, usePathStyleUris)); + if (usePathStyleUris && !baseURI.getRawPath().endsWith("/")) { + baseURI = + new URI(baseURI.getScheme(), baseURI.getRawAuthority(), baseURI.getRawPath().concat("/"), null, + null); + } + + final URI relativeURI = new URI(Utility.safeRelativize(baseURI, resourceAddress)); + + String relativeURIString = relativeURI.toString(); + + if (relativeURIString.endsWith(delimiter)) { + relativeURIString = relativeURIString.substring(0, relativeURIString.length() - delimiter.length()); + } + + String parentName = Constants.EMPTY_STRING; + + if (Utility.isNullOrEmpty(relativeURIString)) { + // Case 1 /[Delimiter]*? => / + // Parent of container is container itself + parentName = containerName.concat(delimiter); + } else { + final int lastDelimiterDex = relativeURIString.lastIndexOf(delimiter); + + if (lastDelimiterDex <= 0) { + // Case 2 // + // Parent of a folder is container + parentName = containerName.concat(delimiter); + } else { + // Case 3 ///[/]* + // Parent of blob is folder + parentName = relativeURIString.substring(0, lastDelimiterDex + delimiter.length()); + } + } + + return parentName; + } + + /** + * Get the queue name from address from the URI. + * + * @param resourceAddress + * The queue Uri. + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return container name from address from the URI. + * @throws IllegalArgumentException + */ + public static String getQueueNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { + return getContainerOrQueueNameFromUri(resourceAddress, + usePathStyleUris, + String.format("Invalid queue URI '%s'.", resourceAddress)); + } + + /** + * Get the service client address from a complete Uri. + * + * @param address + * Complete address of the resource. + * @param usePathStyleUris + * a value indicating if the address is a path style uri. + * @return the service client address from a complete Uri. + * @throws URISyntaxException + */ + public static String getServiceClientBaseAddress(final URI address, final boolean usePathStyleUris) + throws URISyntaxException { + if (usePathStyleUris) { + final String[] pathSegments = address.getRawPath().split("/"); + + if (pathSegments.length < 2) { + final String error = + String.format("Missing account name information inside path style uri. Path style uris should be of the form http:///"); + throw new IllegalArgumentException(error); + } + + final StringBuilder completeAddress = + new StringBuilder(new URI(address.getScheme(), address.getAuthority(), null, null, null).toString()); + completeAddress.append("/"); + completeAddress.append(Utility.trimEnd(pathSegments[1], '/')); + + return completeAddress.toString(); + } else { + return new URI(address.getScheme(), address.getAuthority(), null, null, null).toString(); + } + } + + /** + * Parses a query string into a one to many hashmap. + * + * @param parseString + * the string to parse + * @return a HashMap of the key values. + * @throws StorageException + */ + public static HashMap parseQueryString(String parseString) throws StorageException { + final HashMap retVals = new HashMap(); + if (Utility.isNullOrEmpty(parseString)) { + return retVals; + } + + // 1. Remove ? if present + final int queryDex = parseString.indexOf("?"); + if (queryDex >= 0 && parseString.length() > 0) { + parseString = parseString.substring(queryDex + 1); + } + + // 2. split name value pairs by splitting on the 'c&' character + final String[] valuePairs = parseString.contains("&") ? parseString.split("&") : parseString.split(";"); + + // 3. for each field value pair parse into appropriate map entries + for (int m = 0; m < valuePairs.length; m++) { + final int equalDex = valuePairs[m].indexOf("="); + + if (equalDex < 0 || equalDex == valuePairs[m].length() - 1) { + // TODO should throw here? + continue; + } + + String key = valuePairs[m].substring(0, equalDex); + String value = valuePairs[m].substring(equalDex + 1); + + key = Utility.safeDecode(key); + value = Utility.safeDecode(value); + + // 3.1 add to map + String[] values = retVals.get(key); + + if (values == null) { + values = new String[] { value }; + if (!value.equals(Constants.EMPTY_STRING)) { + retVals.put(key, values); + } + } else if (!value.equals(Constants.EMPTY_STRING)) { + final String[] newValues = new String[values.length + 1]; + for (int j = 0; j < values.length; j++) { + newValues[j] = values[j]; + } + + newValues[newValues.length] = value; + } + } + + return retVals; + } + + /** + * Strips the Query and Fragment from the uri. + * + * @param inUri + * the uri to alter + * @return the stripped uri. + * @throws StorageException + */ + public static URI stripURIQueryAndFragment(final URI inUri) throws StorageException { + try { + return new URI(inUri.getScheme(), inUri.getAuthority(), inUri.getPath(), null, null); + } catch (final URISyntaxException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * Private Default Ctor. + */ + private PathUtility() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java new file mode 100644 index 0000000000000..09d1e68656ddc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java @@ -0,0 +1,48 @@ +package com.microsoft.windowsazure.services.core.storage.utils; + +/** + * RESERVED FOR INTERNAL USE. Represents a stream descriptor that contains the stream size and MD5 hash. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StreamDescriptor { + /** + * Contains the MD5 hash for the stream data. + */ + private String streamMd5; + + /** + * Contains the length, in bytes, for the stream. + */ + private long streamLength; + + /** + * @return the length + */ + public long getLength() { + return this.streamLength; + } + + /** + * @return the md5 + */ + public String getMd5() { + return this.streamMd5; + } + + /** + * @param length + * the length to set + */ + public void setLength(final long length) { + this.streamLength = length; + } + + /** + * @param md5 + * the md5 to set + */ + public void setMd5(final String md5) { + this.streamMd5 = md5; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java new file mode 100644 index 0000000000000..b436bcb84f32b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java @@ -0,0 +1,152 @@ +package com.microsoft.windowsazure.services.core.storage.utils; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. A helper class to help modify the query string of a URI + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class UriQueryBuilder { + /** + * Stores the one to one key/ value collection of query parameters. + */ + private final HashMap> parameters = new HashMap>(); + + /** + * Adds a value to the URI with escaping. + * + * @param name + * the query key name. + * @param value + * the query value. + * @throws StorageException + */ + public void add(final String name, final String value) throws StorageException { + if (Utility.isNullOrEmpty(name)) { + throw new IllegalArgumentException("Cannot encode a query parameter with a null or empty key"); + } + + this.insertKeyValue(name, value); + } + + /** + * Add query parameter to an existing Uri. This takes care of any existing query parameters in the Uri. + * + * @param uri + * the original uri. + * @return the appended uri + * @throws URISyntaxException + * if the resulting uri is invalid. + * @throws StorageException + */ + public URI addToURI(final URI uri) throws URISyntaxException, StorageException { + final String origRawQuery = uri.getRawQuery(); + final String rawFragment = uri.getRawFragment(); + final String uriString = uri.resolve(uri).toASCIIString(); + + final HashMap origQueryMap = PathUtility.parseQueryString(origRawQuery); + + // Try/Insert original queries to map + + for (final Entry entry : origQueryMap.entrySet()) { + for (final String val : entry.getValue()) { + this.insertKeyValue(entry.getKey(), val); + } + } + + final StringBuilder retBuilder = new StringBuilder(); + + // has a fragment + if (Utility.isNullOrEmpty(origRawQuery) && !Utility.isNullOrEmpty(rawFragment)) { + final int bangDex = uriString.indexOf('#'); + retBuilder.append(uriString.substring(0, bangDex)); + } else if (!Utility.isNullOrEmpty(origRawQuery)) { + // has a query + final int queryDex = uriString.indexOf('?'); + retBuilder.append(uriString.substring(0, queryDex)); + } else { + // no fragment or query + retBuilder.append(uriString); + if (uri.getRawPath().length() <= 0) { + retBuilder.append("/"); + } + } + + final String finalQuery = this.toString(); + + if (finalQuery.length() > 0) { + retBuilder.append("?"); + retBuilder.append(finalQuery); + } + + if (!Utility.isNullOrEmpty(rawFragment)) { + retBuilder.append("#"); + retBuilder.append(rawFragment); + } + + return new URI(retBuilder.toString()); + } + + /** + * Inserts a key / value in the Hashmap, assumes the value is already utf-8 encoded. + * + * @param key + * the key to insert + * @param value + * the value to insert + * @throws StorageException + */ + private void insertKeyValue(String key, String value) throws StorageException { + if (value != null) { + value = Utility.safeEncode(value); + } + if (!key.startsWith("$")) { + key = Utility.safeEncode(key); + } + + ArrayList list = this.parameters.get(key); + if (list == null) { + list = new ArrayList(); + list.add(value); + this.parameters.put(key, list); + } else { + if (!list.contains(value)) { + list.add(value); + } + } + } + + /** + * Returns a string that represents this instance. This will construct the full URI. + * + * @return a string that represents this instance. + */ + @Override + public String toString() { + final StringBuilder outString = new StringBuilder(); + Boolean isFirstPair = true; + + for (final String key : this.parameters.keySet()) { + if (this.parameters.get(key) != null) { + for (final String val : this.parameters.get(key)) { + if (isFirstPair) { + isFirstPair = false; + } else { + outString.append("&"); + } + + outString.append(String.format("%s=%s", key, val)); + } + } + } + + return outString.toString(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java new file mode 100644 index 0000000000000..05d5170e8d5a0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -0,0 +1,929 @@ +package com.microsoft.windowsazure.services.core.storage.utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.TimeZone; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RequestResult; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; +import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; +import com.microsoft.windowsazure.services.core.storage.StorageCredentials; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAccountAndKey; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAnonymous; +import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCode; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse; + +/** + * RESERVED FOR INTERNAL USE. A class which provides utility methods. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class Utility { + /** + * Stores a reference to the GMT time zone. + */ + public static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT"); + + /** + * Stores a reference to the UTC time zone. + */ + public static final TimeZone UTC_ZONE = TimeZone.getTimeZone("UTC"); + + /** + * Stores a reference to the US locale. + */ + public static final Locale LOCALE_US = Locale.US; + + /** + * Stores a reference to the RFC1123 date/time pattern. + */ + private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; + + /** + * Stores a reference to the ISO8061 date/time pattern. + */ + public static final String ISO8061_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + /** + * Stores a reference to the ISO8061_LONG date/time pattern. + */ + public static final String ISO8061_LONG_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; + + /** + * + * Determines the size of an input stream, and optionally calculates the MD5 hash for the stream. + * + * @param sourceStream + * A InputStream object that represents the stream to measure. + * @param writeLength + * The number of bytes to read from the stream. + * @param abandonLength + * The number of bytes to read before the analysis is abandoned. Set this value to -1 to + * force the entire stream to be read. This parameter is provided to support upload thresholds. + * @param rewindSourceStream + * true if the stream should be rewound after it is read; otherwise, false. + * @param calculateMD5 + * true if an MD5 hash will be calculated; otherwise, false. + * + * @return A {@link StreamDescriptor} object that contains the stream length, and optionally the MD5 hash. + * + * @throws IOException + * If an I/O error occurs. + * @throws StorageException + * If a storage service error occurred. + */ + public static StreamDescriptor analyzeStream( + final InputStream sourceStream, long writeLength, long abandonLength, final boolean rewindSourceStream, + final boolean calculateMD5) throws IOException, StorageException { + if (abandonLength < 0) { + abandonLength = Long.MAX_VALUE; + } + + if (rewindSourceStream) { + if (!sourceStream.markSupported()) { + throw new IllegalArgumentException("Input stream must be markable!"); + } + sourceStream.mark(Integer.MAX_VALUE); + } + + MessageDigest digest = null; + if (calculateMD5) { + try { + digest = MessageDigest.getInstance("MD5"); + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + if (writeLength < 0) { + writeLength = Long.MAX_VALUE; + } + + final StreamDescriptor retVal = new StreamDescriptor(); + int count = -1; + final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; + + int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); + count = sourceStream.read(retrievedBuff, 0, nextCopy); + + while (nextCopy > 0 && count != -1) { + if (calculateMD5) { + digest.update(retrievedBuff, 0, count); + } + retVal.setLength(retVal.getLength() + count); + + if (retVal.getLength() > abandonLength) { + // Abandon operation + retVal.setLength(-1); + retVal.setMd5(null); + break; + } + + nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); + count = sourceStream.read(retrievedBuff, 0, nextCopy); + } + + if (retVal.getLength() != -1 && calculateMD5) { + retVal.setMd5(Base64.encode(digest.digest())); + } + + if (retVal.getLength() != -1 && writeLength > 0) { + retVal.setLength(Math.min(retVal.getLength(), writeLength)); + } + + if (rewindSourceStream) { + sourceStream.reset(); + sourceStream.mark(Integer.MAX_VALUE); + } + + return retVal; + } + + /** + * Returns a value that indicates whether the specified credentials are equal. + * + * @param thisCred + * An object derived from {@link StorageCredentials} that represents the first set of credentials being + * compared for equality. + * @param thatCred + * An object derived from StorageCredentials that represents the second set of credentials + * being compared for equality. + * + * @return true if the credentials are equal; otherwise, false. + */ + public static boolean areCredentialsEqual(final StorageCredentials thisCred, final StorageCredentials thatCred) { + if (thisCred == thatCred) { + return true; + } + + if (thatCred == null || thisCred.getClass() != thatCred.getClass()) { + return false; + } + + if (thisCred instanceof StorageCredentialsAccountAndKey) { + return ((StorageCredentialsAccountAndKey) thisCred).toString(true) + .equals(((StorageCredentialsAccountAndKey) thatCred).toString(true)); + } else if (thisCred instanceof StorageCredentialsSharedAccessSignature) { + return ((StorageCredentialsSharedAccessSignature) thisCred).getToken() + .equals(((StorageCredentialsSharedAccessSignature) thatCred).getToken()); + } else if (thisCred instanceof StorageCredentialsAnonymous) { + return true; + } + + return thisCred.equals(thatCred); + } + + /** + * Asserts a continuation token is of the specified type. + * + * @param continuationToken + * A {@link ResultContinuation} object that represents the continuation token whose type is being + * examined. + * @param continuationType + * A {@link ResultContinuationType} value that represents the continuation token type being asserted with + * the specified continuation token. + */ + public static void assertContinuationType( + final ResultContinuation continuationToken, final ResultContinuationType continuationType) { + if (continuationToken != null) { + if (!(continuationToken.getContinuationType() == ResultContinuationType.NONE || continuationToken + .getContinuationType() == continuationType)) { + final String errorMessage = + String.format(Utility.LOCALE_US, + "The continuation type passed in is unexpected. Please verify that the correct continuation type is passed in. Expected {%s}, found {%s}", + continuationToken.getContinuationType(), + continuationType); + throw new IllegalArgumentException(errorMessage); + } + } + } + + /** + * Asserts that a value is not null. + * + * @param param + * A String that represents the name of the parameter, which becomes the exception message + * text if the value parameter is null. + * @param value + * An Object object that represents the value of the specified parameter. This is the value + * being asserted as not null. + */ + public static void assertNotNull(final String param, final Object value) { + if (value == null) { + throw new IllegalArgumentException(param); + } + } + + /** + * Asserts that the specified string is not null or empty. + * + * @param param + * A String that represents the name of the parameter, which becomes the exception message + * text if the value parameter is null or an empty string. + * @param value + * A String that represents the value of the specified parameter. This is the value being + * asserted as not null and not an empty string. + */ + public static void assertNotNullOrEmpty(final String param, final String value) { + assertNotNull(param, value); + + if (Utility.isNullOrEmpty(value)) { + throw new IllegalArgumentException("The argument must not be an empty string or null:".concat(param)); + } + } + + /** + * Creates an XML stream reader from the specified input stream. + * + * @param streamRef + * An InputStream object that represents the input stream to use as the source. + * + * @return A java.xml.stream.XMLStreamReader object that represents the XML stream reader created from + * the specified input stream. + * + * @throws XMLStreamException + * If the XML stream reader could not be created. + */ + public static XMLStreamReader createXMLStreamReaderFromStream(final InputStream streamRef) + throws XMLStreamException { + XMLInputFactory xmlif = null; + + xmlif = XMLInputFactory.newInstance(); + xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); + xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); + // set the IS_COALESCING property to true , if application desires to + // get whole text data as one event. + xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); + + return xmlif.createXMLStreamReader(streamRef); + } + + /** + * Returns a value that indicates whether a specified URI is a path-style URI. + * + * @param baseURI + * A java.net.URI value that represents the URI being checked. + * @param knownAccountName + * A String that represents the known account name to examine with baseURI, or + * null to examine baseURI on its own for being a path-style URI. + * + * @return true if the specified URI is path-style; otherwise, false. + */ + public static boolean determinePathStyleFromUri(final URI baseURI, final String knownAccountName) { + if (knownAccountName == null) { + return !Utility.isNullOrEmpty(baseURI.getPath()); + } + + String path = baseURI.getPath(); + if (!Utility.isNullOrEmpty(path) && path.startsWith("/")) { + path = path.substring(1); + } + + if (Utility.isNullOrEmpty(path) || baseURI.getHost().startsWith(knownAccountName)) { + return false; + } else if (!Utility.isNullOrEmpty(path) && path.startsWith(knownAccountName)) { + return true; + } + + return false; + } + + /** + * Returns an unexpected storage exception. + * + * @param cause + * An Exception object that represents the initial exception that caused the unexpected + * error. + * + * @return A {@link StorageException} object that represents the unexpected storage exception being thrown. + */ + public static StorageException generateNewUnexpectedStorageException(final Exception cause) { + final StorageException exceptionRef = + new StorageException(StorageErrorCode.NONE.toString(), "Unexpected internal storage client error.", + 306, // unused + null, null); + exceptionRef.initCause(cause); + return exceptionRef; + } + + /** + * Returns a byte array that represents the data of a long value. + * + * @param value + * The value from which the byte array will be returned. + * + * @return A byte array that represents the data of the specified long value. + */ + public static byte[] getBytesFromLong(final long value) { + final byte[] tempArray = new byte[8]; + + for (int m = 0; m < 8; m++) { + tempArray[7 - m] = (byte) ((value >> (8 * m)) & 0xFF); + } + + return tempArray; + } + + /** + * Returns extended error information from the specified request. + * + * @param request + * An HttpURLConnection object that represents the request. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link StorageExtendedErrorInformation} object that represents the extended error information from the + * request. + */ + protected static StorageExtendedErrorInformation getErrorDetailsFromRequest( + final HttpURLConnection request, final OperationContext opContext) { + if (request == null) { + return null; + } + try { + final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream()); + return response.getExtendedErrorInformation(); + } catch (final XMLStreamException e) { + return null; + } + } + + /** + * Returns the current GMT date/time using the RFC1123 pattern. + * + * @return A String that represents the current GMT date/time using the RFC1123 pattern. + */ + public static String getGMTTime() { + final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + rfc1123Format.setTimeZone(GMT_ZONE); + return rfc1123Format.format(new Date()); + } + + /** + * Returns the GTM date/time for the specified value using the RFC1123 pattern. + * + * @param inDate + * A Date object that represents the date to convert to GMT date/time in the RFC1123 + * pattern. + * + * @return A String that represents the GMT date/time for the specified value using the RFC1123 + * pattern. + */ + public static String getGMTTime(final Date inDate) { + final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + rfc1123Format.setTimeZone(GMT_ZONE); + return rfc1123Format.format(inDate); + } + + /** + * Returns the standard header value from the specified connection request, or an empty string if no header value + * has been specified for the request. + * + * @param conn + * An HttpURLConnection object that represents the request. + * @param headerName + * A String that represents the name of the header being requested. + * + * @return A String that represents the header value, or null if there is no corresponding + * header value for headerName. + */ + public static String getStandardHeaderValue(final HttpURLConnection conn, final String headerName) { + final String headerValue = conn.getRequestProperty(headerName); + + // Coalesce null value + return headerValue == null ? Constants.EMPTY_STRING : headerValue; + } + + /** + * Returns the current UTC date/time using the RFC1123 pattern. + * + * @return A String that represents the current UTC date/time using the RFC1123 pattern. + */ + protected static String getUTCTime() { + final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + rfc1123Format.setTimeZone(UTC_ZONE); + return rfc1123Format.format(new Date()); + } + + /** + * Returns the UTC date/time for the specified value using the RFC1123 pattern. + * + * @param inDate + * A Date object that represents the date to convert to UTC date/time in the RFC1123 + * pattern. + * + * @return A String that represents the UTC date/time for the specified value using the RFC1123 + * pattern. + */ + protected static String getUTCTime(final Date inDate) { + final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); + rfc1123Format.setTimeZone(UTC_ZONE); + return rfc1123Format.format(inDate); + } + + /** + * Returns the UTC date/time for the specified value using the ISO8061 pattern. + * + * @param value + * A Date object that represents the date to convert to UTC date/time in the ISO8061 + * pattern. If this value is null, this method returns an empty string. + * + * @return A String that represents the UTC date/time for the specified value using the ISO8061 + * pattern, or an empty string if value is null. + */ + public static String getUTCTimeOrEmpty(final Date value) { + if (value == null) { + return Constants.EMPTY_STRING; + } + + final DateFormat iso8061Format = new SimpleDateFormat(ISO8061_PATTERN, LOCALE_US); + iso8061Format.setTimeZone(UTC_ZONE); + + return iso8061Format.format(value); + } + + /** + * Creates an instance of the IOException class using the specified exception. + * + * @param ex + * An Exception object that represents the exception used to create the IO exception. + * + * @return A java.io.IOException object that represents the created IO exception. + */ + public static IOException initIOException(final Exception ex) { + final IOException retEx = new IOException(); + retEx.initCause(ex); + return retEx; + } + + /** + * Returns a value that indicates whether the specified string is null or empty. + * + * @param value + * A String being examined for null or empty. + * + * @return true if the specified value is null or empty; otherwise, false + */ + public static boolean isNullOrEmpty(final String value) { + return value == null || value.length() == 0; + } + + /** + * Parses a connection string and returns its values as a hash map of key/value pairs. + * + * @param parseString + * A String that represents the connection string to parse. + * + * @return A java.util.HashMap object that represents the hash map of the key / value pairs parsed from + * the connection string. + */ + public static HashMap parseAccountString(final String parseString) { + + // 1. split name value pairs by splitting on the ';' character + final String[] valuePairs = parseString.split(";"); + final HashMap retVals = new HashMap(); + + // 2. for each field value pair parse into appropriate map entries + for (int m = 0; m < valuePairs.length; m++) { + final int equalDex = valuePairs[m].indexOf("="); + if (equalDex < 1) { + throw new IllegalArgumentException("Invalid Connection String"); + } + + final String key = valuePairs[m].substring(0, equalDex); + final String value = valuePairs[m].substring(equalDex + 1); + + // 2.1 add to map + retVals.put(key, value); + } + + return retVals; + } + + /** + * Returns a GMT date in the specified format + * + * @param value + * the string to parse + * @return the GMT date, as a Date + * @throws ParseException + * If the specified string is invalid + */ + public static Date parseDateFromString(final String value, final String pattern, final TimeZone timeZone) + throws ParseException { + final DateFormat rfc1123Format = new SimpleDateFormat(pattern, Utility.LOCALE_US); + rfc1123Format.setTimeZone(timeZone); + return rfc1123Format.parse(value); + } + + /** + * Returns a date in the ISO8061 long pattern for the specified string. + * + * @param value + * A String that represents the string to parse. + * + * @return A Date object that represents the date in the ISO8061 long pattern. + * + * @throws ParseException + * If the specified string is invalid. + */ + public static Date parseISO8061LongDateFromString(final String value) throws ParseException { + return parseDateFromString(value, ISO8061_LONG_PATTERN, Utility.UTC_ZONE); + } + + /** + * Returns a GMT date in the RFC1123 pattern for the specified string. + * + * @param value + * A String that represents the string to parse. + * + * @return A Date object that represents the GMT date in the RFC1123 pattern. + * + * @throws ParseException + * If the specified string is invalid. + */ + public static Date parseRFC1123DateFromStringInGMT(final String value) throws ParseException { + return parseDateFromString(value, RFC1123_PATTERN, Utility.GMT_ZONE); + } + + /** + * Reads character data for the specified XML element from an XML stream reader. This method will read start events, + * characters, and end events from a stream. + * + * @param xmlr + * An XMLStreamReader object that represents the source XML stream reader. + * + * @param elementName + * A String that represents XML element name. + * + * @return A String that represents the character data for the specified element. + * + * @throws XMLStreamException + * If an XML stream failure occurs. + */ + public static String readElementFromXMLReader(final XMLStreamReader xmlr, final String elementName) + throws XMLStreamException { + xmlr.require(XMLStreamConstants.START_ELEMENT, null, elementName); + int eventType = xmlr.next(); + final StringBuilder retVal = new StringBuilder(); + + if (eventType == XMLStreamConstants.CHARACTERS) { + // This do while is in case the XMLStreamReader does not have + // the IS_COALESCING property set + // to true which may result in text being read in multiple events + // If we ensure all xmlreaders have this property we can optimize + // the StringBuilder and while loop + // away + do { + retVal.append(xmlr.getText()); + eventType = xmlr.next(); + + } while (eventType == XMLStreamConstants.CHARACTERS); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, elementName); + return retVal.length() == 0 ? null : retVal.toString(); + } + + /** + * Performs safe decoding of the specified string, taking care to preserve each + character, rather + * than replacing it with a space character. + * + * @param stringToDecode + * A String that represents the string to decode. + * + * @return A String that represents the decoded string. + * + * @throws StorageException + * If a storage service error occurred. + */ + public static String safeDecode(final String stringToDecode) throws StorageException { + if (stringToDecode == null) { + return null; + } + + if (stringToDecode.length() == 0) { + return Constants.EMPTY_STRING; + } + + try { + if (stringToDecode.contains("+")) { + final StringBuilder outBuilder = new StringBuilder(); + + int startDex = 0; + for (int m = 0; m < stringToDecode.length(); m++) { + if (stringToDecode.charAt(m) == '+') { + if (m > startDex) { + outBuilder.append(URLDecoder.decode(stringToDecode.substring(startDex, m), "UTF-8")); + } + + outBuilder.append("+"); + startDex = m + 1; + } + } + + if (startDex != stringToDecode.length()) { + outBuilder.append(URLDecoder.decode(stringToDecode.substring(startDex, stringToDecode.length()), + "UTF-8")); + } + + return outBuilder.toString(); + } else { + return URLDecoder.decode(stringToDecode, "UTF-8"); + } + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * Performs safe encoding of the specified string, taking care to insert %20 for each space character, + * instead of inserting the + character. + * + * @param stringToEncode + * A String that represents the string to encode. + * + * @return A String that represents the encoded string. + * + * @throws StorageException + * If a storage service error occurred. + */ + public static String safeEncode(final String stringToEncode) throws StorageException { + if (stringToEncode == null) { + return null; + } + if (stringToEncode.length() == 0) { + return Constants.EMPTY_STRING; + } + + try { + final String tString = URLEncoder.encode(stringToEncode, "UTF-8"); + + if (stringToEncode.contains(" ")) { + final StringBuilder outBuilder = new StringBuilder(); + + int startDex = 0; + for (int m = 0; m < stringToEncode.length(); m++) { + if (stringToEncode.charAt(m) == ' ') { + if (m > startDex) { + outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, m), "UTF-8")); + } + + outBuilder.append("%20"); + startDex = m + 1; + } + } + + if (startDex != stringToEncode.length()) { + outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, stringToEncode.length()), + "UTF-8")); + } + + return outBuilder.toString(); + } else { + return tString; + } + + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * Determines the relative difference between the two specified URIs. + * + * @param baseURI + * A java.net.URI object that represents the base URI for which toUri will be + * made relative. + * @param toUri + * A java.net.URI object that represents the URI to make relative to baseURI. + * + * @return A String that either represents the relative URI of toUri to + * baseURI, or the URI of toUri itself, depending on whether the hostname and + * scheme are identical for toUri and baseURI. If the hostname and scheme of + * baseURI and toUri are identical, this method returns a relative URI such that + * if appended to baseURI, it will yield toUri. If the hostname or scheme of + * baseURI and toUri are not identical, this method returns the full URI specified + * by toUri. + * + * @throws URISyntaxException + * If baseURI or toUri is invalid. + */ + public static String safeRelativize(final URI baseURI, final URI toUri) throws URISyntaxException { + // For compatibility followed + // http://msdn.microsoft.com/en-us/library/system.uri.makerelativeuri.aspx + + // if host and scheme are not identical return from uri + if (!baseURI.getHost().equals(toUri.getHost()) || !baseURI.getScheme().equals(toUri.getScheme())) { + return toUri.toString(); + } + + final String basePath = baseURI.getPath(); + String toPath = toUri.getPath(); + + int truncatePtr = 1; + + // Seek to first Difference + // int maxLength = Math.min(basePath.length(), toPath.length()); + int m = 0; + int ellipsesCount = 0; + for (; m < basePath.length(); m++) { + if (m >= toPath.length()) { + if (basePath.charAt(m) == '/') { + ellipsesCount++; + } + } else { + if (basePath.charAt(m) != toPath.charAt(m)) { + break; + } else if (basePath.charAt(m) == '/') { + truncatePtr = m + 1; + } + } + } + + if (m == toPath.length()) { + // No path difference, return query + fragment + return new URI(null, null, null, toUri.getQuery(), toUri.getFragment()).toString(); + } else { + toPath = toPath.substring(truncatePtr); + final StringBuilder sb = new StringBuilder(); + while (ellipsesCount > 0) { + sb.append("../"); + ellipsesCount--; + } + + if (!Utility.isNullOrEmpty(toPath)) { + sb.append(toPath); + } + + if (!Utility.isNullOrEmpty(toUri.getQuery())) { + sb.append("?"); + sb.append(toUri.getQuery()); + } + if (!Utility.isNullOrEmpty(toUri.getFragment())) { + sb.append("#"); + sb.append(toUri.getRawFragment()); + } + + return sb.toString(); + } + } + + /** + * Trims the specified character from the end of a string. + * + * @param value + * A String that represents the string to trim. + * @param trimChar + * The character to trim from the end of the string. + * + * @return The string with the specified character trimmed from the end. + */ + protected static String trimEnd(final String value, final char trimChar) { + int stopDex = value.length() - 1; + while (stopDex > 0 && value.charAt(stopDex) == trimChar) { + stopDex--; + } + + return stopDex == value.length() - 1 ? value : value.substring(stopDex); + } + + /** + * Trims whitespace from the beginning of a string. + * + * @param value + * A String that represents the string to trim. + * + * @return The string with whitespace trimmed from the beginning. + */ + public static String trimStart(final String value) { + int spaceDex = 0; + while (spaceDex < value.length() && value.charAt(spaceDex) == ' ') { + spaceDex++; + } + + return value.substring(spaceDex); + } + + /** + * Reads data from an input stream and writes it to an output stream, calculates the length of the data written, and + * optionally calculates the MD5 hash for the data. + * + * @param sourceStream + * An InputStream object that represents the input stream to use as the source. + * @param outStream + * An OutputStream object that represents the output stream to use as the destination. + * @param writeLength + * The number of bytes to read from the stream. + * @param rewindSourceStream + * true if the input stream should be rewound after it is read; otherwise, + * false. + * @param calculateMD5 + * true if an MD5 hash will be calculated; otherwise, false. + * @param currentResult + * A {@link RequestResult} object that represents the result for the current request. + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link StreamDescriptor} object that contains the output stream length, and optionally the MD5 hash. + * + * @throws IOException + * If an I/O error occurs. + * @throws StorageException + * If a storage service error occurred. + */ + public static StreamDescriptor writeToOutputStream( + final InputStream sourceStream, final OutputStream outStream, long writeLength, + final boolean rewindSourceStream, final boolean calculateMD5, final RequestResult currentResult, + final OperationContext opContext) throws IOException, StorageException { + if (opContext != null) { + opContext.setCurrentOperationByteCount(0); + } + + if (rewindSourceStream && sourceStream.markSupported()) { + sourceStream.reset(); + sourceStream.mark(Integer.MAX_VALUE); + } + + if (calculateMD5 && opContext.getIntermediateMD5() == null) { + try { + opContext.setIntermediateMD5(MessageDigest.getInstance("MD5")); + } catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + final StreamDescriptor retVal = new StreamDescriptor(); + + if (writeLength < 0) { + writeLength = Long.MAX_VALUE; + } + + int count = -1; + final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; + int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); + + count = sourceStream.read(retrievedBuff, 0, nextCopy); + + while (nextCopy > 0 && count != -1) { + outStream.write(retrievedBuff, 0, count); + if (calculateMD5) { + opContext.getIntermediateMD5().update(retrievedBuff, 0, count); + } + + retVal.setLength(retVal.getLength() + count); + if (opContext != null) { + opContext.setCurrentOperationByteCount(opContext.getCurrentOperationByteCount() + count); + } + + nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); + count = sourceStream.read(retrievedBuff, 0, nextCopy); + } + + outStream.flush(); + + if (calculateMD5) { + retVal.setMd5(Base64.encode(opContext.getIntermediateMD5().digest())); + } + + return retVal; + } + + /** + * Private Default Ctor. + */ + private Utility() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java new file mode 100644 index 0000000000000..10ecfe8c3cbb6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -0,0 +1,538 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.security.InvalidKeyException; +import java.util.HashMap; +import java.util.Map.Entry; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.Credentials; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.ServiceProperties; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.StorageKey; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. The Base Request class for the protocol layer. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class BaseRequest { + /** + * Adds the lease id. + * + * @param request + * a HttpURLConnection for the operation. + * @param leaseId + * the lease id to add to the HttpURLConnection. + */ + public static void addLeaseId(final HttpURLConnection request, final String leaseId) { + if (leaseId != null) { + BaseRequest.addOptionalHeader(request, "x-ms-lease-id", leaseId); + } + } + + /** + * Stores the user agent to send over the wire to identify the client. + */ + private static String userAgent; + + /** + * Adds the metadata. + * + * @param request + * The request. + * @param metadata + * The metadata. + */ + public static void addMetadata( + final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + if (metadata != null) { + for (final Entry entry : metadata.entrySet()) { + addMetadata(request, entry.getKey(), entry.getValue(), opContext); + } + } + } + + /** + * Adds the metadata. + * + * @param opContext + * an object used to track the execution of the operation + * @param request + * The request. + * @param name + * The metadata name. + * @param value + * The metadata value. + */ + public static void addMetadata( + final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + Utility.assertNotNullOrEmpty("value", value); + + request.setRequestProperty(Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA + name, value); + } + + /** + * Adds the optional header. + * + * @param request + * a HttpURLConnection for the operation. + * @param name + * the metadata name. + * @param value + * the metadata value. + */ + public static void addOptionalHeader(final HttpURLConnection request, final String name, final String value) { + if (value != null && !value.equals(Constants.EMPTY_STRING)) { + request.setRequestProperty(name, value); + } + } + + /** + * Adds the snapshot. + * + * @param builder + * a query builder. + * @param snapshotVersion + * the snapshot version to the query builder. + * @throws StorageException + */ + public static void addSnapshot(final UriQueryBuilder builder, final String snapshotVersion) throws StorageException { + if (snapshotVersion != null) { + builder.add("snapshot", snapshotVersion); + } + } + + /** + * Creates the specified resource. Note request is set to setFixedLengthStreamingMode(0); Sign with 0 length. + * + * @param uri + * the request Uri. + * @param timeout + * the timeout for the request + * @param builder + * the UriQueryBuilder for the request + * @param opContext + * an object used to track the execution of the operation + * @return a HttpURLConnection to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if there is an improperly formated URI + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection create( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + retConnection.setFixedLengthStreamingMode(0); + retConnection.setDoOutput(true); + retConnection.setRequestMethod("PUT"); + + return retConnection; + } + + /** + * Creates the web request. + * + * @param uri + * the request Uri. + * @param timeoutInMs + * the timeout for the request + * @param builder + * the UriQueryBuilder for the request + * @param opContext + * an object used to track the execution of the operation + * @return a HttpURLConnection to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if there is an improperly formated URI + * @throws StorageException + */ + public static HttpURLConnection createURLConnection( + final URI uri, final int timeoutInMs, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + if (timeoutInMs != 0) { + builder.add("timeout", String.valueOf(timeoutInMs / 1000)); + } + + final URL resourceUrl = builder.addToURI(uri).toURL(); + + final HttpURLConnection retConnection = (HttpURLConnection) resourceUrl.openConnection(); + + retConnection.setReadTimeout(timeoutInMs); + // Note : accept behavior, java by default sends Accept behavior + // as text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 + // + // to override set retConnection.setRequestProperty("Accept", + // "application/atom+xml"); + + retConnection.setRequestProperty(Constants.HeaderConstants.STORAGE_VERSION_HEADER, + Constants.HeaderConstants.TARGET_STORAGE_VERSION); + retConnection.setRequestProperty(Constants.HeaderConstants.USER_AGENT, getUserAgent()); + + // Java6 TODO remove me, this has to be manually set or it will + // sometimes default to application/x-www-form-urlencoded without us + // knowing causing auth fails in Java5. + retConnection.setRequestProperty(Constants.HeaderConstants.CONTENT_TYPE, ""); + return retConnection; + } + + /** + * Deletes the specified resource. Sign with no length specified. + * + * @param uri + * the request Uri. + * @param timeout + * the timeout for the request + * @param builder + * the UriQueryBuilder for the request + * @param opContext + * an object used to track the execution of the operation + * @return a HttpURLConnection to perform the operation. + * @throws IOException + * if there is an error opening the connection + * @throws URISyntaxException + * if there is an improperly formated URI + * @throws StorageException + */ + public static HttpURLConnection delete( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setDoOutput(true); + retConnection.setRequestMethod("DELETE"); + + return retConnection; + } + + /** + * Gets the metadata. Sign with no length specified. + * + * @param uri + * The Uri to query. + * @param timeout + * The timeout. + * @param builder + * The builder. + * @param opContext + * an object used to track the execution of the operation + * @return a web request for performing the operation. + * @throws StorageException + * @throws URISyntaxException + * @throws IOException + * */ + public static HttpURLConnection getMetadata( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws StorageException, IOException, URISyntaxException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + builder.add("comp", "metadata"); + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setDoOutput(true); + retConnection.setRequestMethod("HEAD"); + + return retConnection; + } + + /** + * Gets the properties. Sign with no length specified. + * + * @param uri + * The Uri to query. + * @param timeout + * The timeout. + * @param builder + * The builder. + * @param opContext + * an object used to track the execution of the operation + * @return a web request for performing the operation. + * @throws StorageException + * @throws URISyntaxException + * @throws IOException + * */ + public static HttpURLConnection getProperties( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setDoOutput(true); + retConnection.setRequestMethod("HEAD"); + + return retConnection; + } + + /** + * Creates a HttpURLConnection used to retrieve the Analytics service properties from the storage service. + * + * @param uri + * The service endpoint. + * @param timeout + * The timeout. + * @param builder + * The builder. + * @param opContext + * an object used to track the execution of the operation + * @return a web request for performing the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + */ + public static HttpURLConnection getServiceProperties( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + builder.add("comp", "properties"); + builder.add("restype", "service"); + + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setDoOutput(true); + retConnection.setRequestMethod("GET"); + + return retConnection; + } + + /** + * Gets the user agent to send over the wire to identify the client. + * + * @return the user agent to send over the wire to identify the client. + */ + public static String getUserAgent() { + if (userAgent == null) { + userAgent = + String.format("%s/%s", + Constants.HeaderConstants.USER_AGENT_PREFIX, + Constants.HeaderConstants.USER_AGENT_VERSION); + } + return userAgent; + } + + /** + * Writes the contents of the ServiceProperties object to a byte array in XML form. + * + * @param properties + * the ServiceProperties to write to the stream. + * @param opContext + * an object used to track the execution of the operation + * @return the number of bytes written to the output stream. + * @throws XMLStreamException + * if there is an error writing the content to the stream. + * @throws StorageException + */ + public static byte[] serializeServicePropertiesToByteArray( + final ServiceProperties properties, final OperationContext opContext) + throws XMLStreamException, StorageException { + return properties.serializeToByteArray(opContext); + } + + /** + * Sets the metadata. Sign with 0 length. + * + * @param uri + * The blob Uri. + * @param timeout + * The timeout. + * @param builder + * The builder. + * @param opContext + * an object used to track the execution of the operation + * @return a web request for performing the operation. + * @throws StorageException + * @throws URISyntaxException + * @throws IOException + * */ + public static HttpURLConnection setMetadata( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + + if (builder == null) { + builder = new UriQueryBuilder(); + } + + builder.add("comp", "metadata"); + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setFixedLengthStreamingMode(0); + retConnection.setDoOutput(true); + retConnection.setRequestMethod("PUT"); + + return retConnection; + } + + /** + * Creates a HttpURLConnection used to set the Analytics service properties on the storage service. + * + * @param uri + * The service endpoint. + * @param timeout + * The timeout. + * @param builder + * The builder. + * @param opContext + * an object used to track the execution of the operation + * @return a web request for performing the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + */ + public static HttpURLConnection setServiceProperties( + final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + if (builder == null) { + builder = new UriQueryBuilder(); + } + + builder.add("comp", "properties"); + builder.add("restype", "service"); + + final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); + + retConnection.setDoOutput(true); + retConnection.setRequestMethod("PUT"); + + return retConnection; + } + + /** + * Signs the request appropriately to make it an authenticated request for Blob and Queue. + * + * @param request + * a HttpURLConnection for the operation. + * @param credentials + * the credentials to use for signing. + * @param contentLength + * the length of the content written to the output stream, -1 if unknown. + * @param opContext + * an object used to track the execution of the operation + * @throws InvalidKeyException + * if the credentials key is invalid. + * @throws StorageException + */ + public static void signRequestForBlobAndQueue( + final HttpURLConnection request, final Credentials credentials, final Long contentLength, + final OperationContext opContext) throws InvalidKeyException, StorageException { + request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); + final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueFullCanonicalizer(request); + + final String stringToSign = + canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + + final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); + + // V2 add logging + // System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); + request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, + String.format("%s %s:%s", "SharedKey", credentials.getAccountName(), computedBase64Signature)); + } + + /** + * + * Signs the request appropriately to make it an authenticated request for Blob and Queue. + * + * @param request + * a HttpURLConnection for the operation. + * @param credentials + * the credentials to use for signing. + * @param contentLength + * the length of the content written to the output stream, -1 if unknown. + * @param opContext + * an object used to track the execution of the operation + * @throws InvalidKeyException + * if the credentials key is invalid. + * @throws StorageException + */ + public static void signRequestForBlobAndQueueSharedKeyLite( + final HttpURLConnection request, final Credentials credentials, final Long contentLength, + final OperationContext opContext) throws InvalidKeyException, StorageException { + request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); + + final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueLiteCanonicalizer(request); + + final String stringToSign = + canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + + final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); + + // V2 add logging + // System.out.println(String.format("Signing %s\r\n%s\r\n", + // stringToSign, computedBase64Signature)); + request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, + String.format("%s %s:%s", "SharedKeyLite", credentials.getAccountName(), computedBase64Signature)); + } + + /** + * + * Signs the request appropriately to make it an authenticated request for Blob and Queue. + * + * @param request + * a HttpURLConnection for the operation. + * @param credentials + * the credentials to use for signing. + * @param contentLength + * the length of the content written to the output stream, -1 if unknown. + * @param opContext + * an object used to track the execution of the operation + * @throws InvalidKeyException + * if the credentials key is invalid. + * @throws StorageException + */ + public static void signRequestForTableSharedKeyLite( + final HttpURLConnection request, final Credentials credentials, final Long contentLength, + final OperationContext opContext) throws InvalidKeyException, StorageException { + request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); + + final Canonicalizer canonicalizer = CanonicalizerFactory.getTableLiteCanonicalizer(request); + + final String stringToSign = + canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + + final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); + + // TODO V2 add logging + System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); + request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, + String.format("%s %s:%s", "SharedKeyLite", credentials.getAccountName(), computedBase64Signature)); + } + + /** + * Private Default Ctor + */ + private BaseRequest() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java new file mode 100644 index 0000000000000..3ee401673de00 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java @@ -0,0 +1,126 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.ServiceProperties; +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. The base response class for the protocol layer + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public class BaseResponse { + /** + * Gets the ContentMD5 + * + * @param request + * The response from server. + * @return The ContentMD5. + */ + public static String getContentMD5(final HttpURLConnection request) { + return request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + } + + /** + * Gets the Date + * + * @param request + * The response from server. + * @return The Date. + */ + public static String getDate(final HttpURLConnection request) { + final String retString = request.getHeaderField("Date"); + return retString == null ? request.getHeaderField(Constants.HeaderConstants.DATE) : retString; + } + + /** + * Gets the Etag + * + * @param request + * The response from server. + * @return The Etag. + */ + public static String getEtag(final HttpURLConnection request) { + return request.getHeaderField(Constants.ETAG_ELEMENT); + } + + /** + * Gets the metadata from the request The response from server. + * + * @return the metadata from the request + */ + public static HashMap getMetadata(final HttpURLConnection request) { + return getValuesByHeaderPrefix(request, Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA); + } + + /** + * Gets the request id. + * + * @param request + * The response from server. + * @return The request ID. + */ + public static String getRequestId(final HttpURLConnection request) { + return request.getHeaderField(Constants.HeaderConstants.REQUEST_ID_HEADER); + } + + /** + * Returns all the header/value pairs with the given prefix. + * + * @param request + * the request object containing headers to parse. + * @param prefix + * the prefix for headers to be returned. + * @return all the header/value pairs with the given prefix. + */ + private static + HashMap getValuesByHeaderPrefix(final HttpURLConnection request, final String prefix) { + final HashMap retVals = new HashMap(); + final Map> headerMap = request.getHeaderFields(); + final int prefixLength = prefix.length(); + + for (final Entry> entry : headerMap.entrySet()) { + if (entry.getKey() != null && entry.getKey().startsWith(prefix)) { + final List currHeaderValues = entry.getValue(); + retVals.put(entry.getKey().substring(prefixLength), currHeaderValues.get(0)); + } + } + + return retVals; + } + + /** + * Deserializes the ServiceProperties object from an input stream. + * + * @param inStream + * the stream to read from. + * @param opContext + * an object used to track the execution of the operation + * @return a ServiceProperties object representing the Analytics configuration for the client. + * @throws XMLStreamException + * if the xml is invalid. + * @throws StorageException + * if unexpected xml is found. + */ + public static ServiceProperties readServicePropertiesFromStream( + final InputStream inStream, final OperationContext opContext) throws XMLStreamException, StorageException { + return ServiceProperties.readServicePropertiesFromStream(inStream, opContext); + } + + /** + * Private Default Ctor + */ + protected BaseResponse() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java new file mode 100644 index 0000000000000..2bf783e461c06 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java @@ -0,0 +1,54 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.security.InvalidParameterException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue + * Service under the Shared Key authentication scheme. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobQueueFullCanonicalizer extends Canonicalizer { + + /** + * Constructs a canonicalized string for signing a request. + * + * @param conn + * the HttpURLConnection to canonicalize + * @param accountName + * the account name associated with the request + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param opContext + * the OperationContext for the given request + * @return a canonicalized string. + * @throws StorageException + */ + @Override + protected String canonicalize( + final HttpURLConnection conn, final String accountName, final Long contentLength, + final OperationContext opContext) throws StorageException { + + if (contentLength < -1) { + throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); + } + + return canonicalizeHttpRequest(conn.getURL(), + accountName, + conn.getRequestMethod(), + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), + contentLength, + null, + conn, + opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java new file mode 100644 index 0000000000000..afa14aca2ad87 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java @@ -0,0 +1,50 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.security.InvalidParameterException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue + * Service under the Shared Key authentication scheme. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class BlobQueueLiteCanonicalizer extends Canonicalizer { + + /** + * Constructs a canonicalized string for signing a request. + * + * @param conn + * the HttpURLConnection to canonicalize + * @param accountName + * the account name associated with the request + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param opContext + * the OperationContext for the given request + * @return a canonicalized string. + * @throws StorageException + */ + @Override + protected String canonicalize( + final HttpURLConnection conn, final String accountName, final Long contentLength, + final OperationContext opContext) throws StorageException { + if (contentLength < -1) { + throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); + } + + return canonicalizeHttpRequestLite(conn.getURL(), + accountName, + conn.getRequestMethod(), + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), + contentLength, + null, + conn, + opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java new file mode 100644 index 0000000000000..19c03b7643a7e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -0,0 +1,378 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. This is a Version 2 Canoncicalization strategy conforming to the PDC 2009-09-19 + * specification + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +abstract class Canonicalizer { + + /** + * Add x-ms- prefixed headers in a fixed order. + * + * @param conn + * the HttpURLConnection for the operation + * @param canonicalizedString + * the canonicalized string to add the canonicalized headerst to. + */ + private static void addCanonicalizedHeaders(final HttpURLConnection conn, final StringBuilder canonicalizedString) { + // Look for header names that start with + // HeaderNames.PrefixForStorageHeader + // Then sort them in case-insensitive manner. + + final Map> headers = conn.getRequestProperties(); + final ArrayList httpStorageHeaderNameArray = new ArrayList(); + + for (final String key : headers.keySet()) { + if (key.toLowerCase(Utility.LOCALE_US).startsWith(Constants.PREFIX_FOR_STORAGE_HEADER)) { + httpStorageHeaderNameArray.add(key.toLowerCase(Utility.LOCALE_US)); + } + } + + Collections.sort(httpStorageHeaderNameArray); + + // Now go through each header's values in the sorted order and append + // them to the canonicalized string. + for (final String key : httpStorageHeaderNameArray) { + final StringBuilder canonicalizedElement = new StringBuilder(key); + String delimiter = ":"; + final ArrayList values = getHeaderValues(headers, key); + + // Go through values, unfold them, and then append them to the + // canonicalized element string. + for (final String value : values) { + // Unfolding is simply removal of CRLF. + final String unfoldedValue = value.replace("\r\n", Constants.EMPTY_STRING); + + // Append it to the canonicalized element string. + canonicalizedElement.append(delimiter); + canonicalizedElement.append(unfoldedValue); + delimiter = ","; + } + + // Now, add this canonicalized element to the canonicalized header + // string. + appendCanonicalizedElement(canonicalizedString, canonicalizedElement.toString()); + } + } + + /** + * Append a string to a string builder with a newline constant + * + * @param builder + * the StringBuilder object + * @param element + * the string to append. + */ + protected static void appendCanonicalizedElement(final StringBuilder builder, final String element) { + builder.append("\n"); + builder.append(element); + } + + /** + * Constructs a canonicalized string from the request's headers that will be used to construct the signature string + * for signing a Blob or Queue service request under the Shared Key Full authentication scheme. + * + * @param address + * the request URI + * @param accountName + * the account name associated with the request + * @param method + * the verb to be used for the HTTP request. + * @param contentType + * the content type of the HTTP request. + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param date + * the date/time specification for the HTTP request + * @param conn + * the HttpURLConnection for the operation. + * @param opContext + * the OperationContext for the request. + * @return A canonicalized string. + * @throws StorageException + */ + protected static + String canonicalizeHttpRequest( + final java.net.URL address, final String accountName, final String method, + final String contentType, final long contentLength, final String date, + final HttpURLConnection conn, final OperationContext opContext) throws StorageException { + + // The first element should be the Method of the request. + // I.e. GET, POST, PUT, or HEAD. + final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); + + // The next elements are + // If any element is missing it may be empty. + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_ENCODING)); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_LANGUAGE)); + appendCanonicalizedElement(canonicalizedString, + contentLength == -1 ? Constants.EMPTY_STRING : String.valueOf(contentLength)); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5)); + appendCanonicalizedElement(canonicalizedString, contentType != null ? contentType : Constants.EMPTY_STRING); + + final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); + // If x-ms-date header exists, Date should be empty string + appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date + : Constants.EMPTY_STRING); + + String modifiedSinceString = Constants.EMPTY_STRING; + if (conn.getIfModifiedSince() > 0) { + modifiedSinceString = Utility.getGMTTime(new Date(conn.getIfModifiedSince())); + } + + appendCanonicalizedElement(canonicalizedString, modifiedSinceString); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_MATCH)); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_NONE_MATCH)); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_UNMODIFIED_SINCE)); + appendCanonicalizedElement(canonicalizedString, + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.RANGE)); + + addCanonicalizedHeaders(conn, canonicalizedString); + + appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName)); + + return canonicalizedString.toString(); + } + + /** + * Constructs a canonicalized string from the request's headers that will be used to construct the signature string + * for signing a Blob or Queue service request under the Shared Key Lite authentication scheme. + * + * @param address + * the request URI + * @param accountName + * the account name associated with the request + * @param method + * the verb to be used for the HTTP request. + * @param contentType + * the content type of the HTTP request. + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param date + * the date/time specification for the HTTP request + * @param conn + * the HttpURLConnection for the operation. + * @param opContext + * the OperationContext for the request. + * @return A canonicalized string. + * @throws StorageException + */ + protected static + String canonicalizeHttpRequestLite( + final java.net.URL address, final String accountName, final String method, + final String contentType, final long contentLength, final String date, + final HttpURLConnection conn, final OperationContext opContext) throws StorageException { + // The first element should be the Method of the request. + // I.e. GET, POST, PUT, or HEAD. + final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); + + // The second element should be the MD5 value. + // This is optional and may be empty. + final String httpContentMD5Value = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5); + appendCanonicalizedElement(canonicalizedString, httpContentMD5Value); + + // The third element should be the content type. + appendCanonicalizedElement(canonicalizedString, contentType); + + // The fourth element should be the request date. + // See if there's an storage date header. + // If there's one, then don't use the date header. + + final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); + // If x-ms-date header exists, Date should be empty string + appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date + : Constants.EMPTY_STRING); + + addCanonicalizedHeaders(conn, canonicalizedString); + + appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName)); + + return canonicalizedString.toString(); + } + + /** + * Gets the canonicalized resource string for a Blob or Queue service request under the Shared Key Lite + * authentication scheme. + * + * @param address + * the resource URI. + * @param accountName + * the account name for the request. + * @return the canonicalized resource string. + * @throws StorageException + */ + protected static String getCanonicalizedResource(final java.net.URL address, final String accountName) + throws StorageException { + // Resource path + final StringBuilder resourcepath = new StringBuilder("/"); + resourcepath.append(accountName); + + // Note that AbsolutePath starts with a '/'. + resourcepath.append(address.getPath()); + final StringBuilder canonicalizedResource = new StringBuilder(resourcepath.toString()); + + // query parameters + final Map queryVariables = PathUtility.parseQueryString(address.getQuery()); + + final Map lowercasedKeyNameValue = new HashMap(); + + for (final Entry entry : queryVariables.entrySet()) { + // sort the value and organize it as comma separated values + final List sortedValues = Arrays.asList(entry.getValue()); + Collections.sort(sortedValues); + + final StringBuilder stringValue = new StringBuilder(); + + for (final String value : sortedValues) { + if (stringValue.length() > 0) { + stringValue.append(","); + } + + stringValue.append(value); + } + + // key turns out to be null for ?a&b&c&d + lowercasedKeyNameValue.put(entry.getKey() == null ? null : entry.getKey().toLowerCase(Utility.LOCALE_US), + stringValue.toString()); + } + + final ArrayList sortedKeys = new ArrayList(lowercasedKeyNameValue.keySet()); + + Collections.sort(sortedKeys); + + for (final String key : sortedKeys) { + final StringBuilder queryParamString = new StringBuilder(); + + queryParamString.append(key); + queryParamString.append(":"); + queryParamString.append(lowercasedKeyNameValue.get(key)); + + appendCanonicalizedElement(canonicalizedResource, queryParamString.toString()); + } + + return canonicalizedResource.toString(); + } + + /** + * Gets the canonicalized resource string for a Blob or Queue service request under the Shared Key Lite + * authentication scheme. + * + * @param address + * the resource URI. + * @param accountName + * the account name for the request. + * @return the canonicalized resource string. + * @throws StorageException + */ + protected static String getCanonicalizedResourceLite(final java.net.URL address, final String accountName) + throws StorageException { + // Resource path + final StringBuilder resourcepath = new StringBuilder("/"); + resourcepath.append(accountName); + + // Note that AbsolutePath starts with a '/'. + resourcepath.append(address.getPath()); + final StringBuilder canonicalizedResource = new StringBuilder(resourcepath.toString()); + + // query parameters + final Map queryVariables = PathUtility.parseQueryString(address.getQuery()); + + final String[] compVals = queryVariables.get("comp"); + + if (compVals != null) { + + final List sortedValues = Arrays.asList(compVals); + Collections.sort(sortedValues); + + canonicalizedResource.append("?comp="); + + final StringBuilder stringValue = new StringBuilder(); + for (final String value : sortedValues) { + if (stringValue.length() > 0) { + stringValue.append(","); + } + + stringValue.append(value); + } + + appendCanonicalizedElement(canonicalizedResource, stringValue.toString()); + } + + return canonicalizedResource.toString(); + } + + /** + * Gets all the values for the given header in the one to many map, performs a trimStart() on each return value + * + * @param headers + * a one to many map of key / values representing the header values for the connection. + * @param headerName + * the name of the header to lookup + * @return an ArrayList of all trimmed values cooresponding to the requested headerName. This may be empty + * if the header is not found. + */ + private static ArrayList getHeaderValues(final Map> headers, final String headerName) { + + final ArrayList arrayOfValues = new ArrayList(); + List values = null; + + for (final Entry> entry : headers.entrySet()) { + if (entry.getKey().toLowerCase(Utility.LOCALE_US).equals(headerName)) { + values = entry.getValue(); + break; + } + } + if (values != null) { + for (final String value : values) { + // canonicalization formula requires the string to be left + // trimmed. + arrayOfValues.add(Utility.trimStart(value)); + } + } + return arrayOfValues; + } + + /** + * Constructs a canonicalized string for signing a request. + * + * @param conn + * the HttpURLConnection to canonicalize + * @param accountName + * the account name associated with the request + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param opContext + * the OperationContext for the given request + * @return a canonicalized string. + */ + protected abstract String canonicalize( + HttpURLConnection conn, String accountName, Long contentLength, OperationContext opContext) + throws StorageException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java new file mode 100644 index 0000000000000..798a16f5c6a20 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -0,0 +1,127 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Retrieve appropriate version of CanonicalizationStrategy based on the webrequest for Blob + * and Queue. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class CanonicalizerFactory { + /** + * The Canonicalizer instance for Blob & Queue + */ + private static final BlobQueueFullCanonicalizer BLOB_QUEUE_FULL_V2_INSTANCE = new BlobQueueFullCanonicalizer(); + + /** + * The Canonicalizer instance for Blob & Queue Shared Key Lite + */ + private static final BlobQueueLiteCanonicalizer BLOB_QUEUE_LITE_INSTANCE = new BlobQueueLiteCanonicalizer(); + + /** + * The Canonicalizer instance for Table + */ + private static final TableLiteCanonicalizer TABLE_LITE_INSTANCE = new TableLiteCanonicalizer(); + + /** + * Gets the Blob queue Canonicalizer full version 2. + * + * @param conn + * the HttpURLConnection for the current operation + * @return the appropriate Canonicalizer for the operation. + */ + protected static Canonicalizer getBlobQueueFullCanonicalizer(final HttpURLConnection conn) { + if (validateVersionIsSupported(conn)) { + return BLOB_QUEUE_FULL_V2_INSTANCE; + } else { + throw new UnsupportedOperationException("Storage protocol version prior to 2009-09-19 are not supported."); + } + } + + /** + * Gets the Blob queue lite Canonicalizer + * + * @param conn + * the HttpURLConnection for the current operation + * @return the appropriate Canonicalizer for the operation. + */ + protected static Canonicalizer getBlobQueueLiteCanonicalizer(final HttpURLConnection conn) { + if (validateVersionIsSupported(conn)) { + return BLOB_QUEUE_LITE_INSTANCE; + } else { + throw new UnsupportedOperationException( + "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); + } + } + + /** + * Gets the Blob queue lite Canonicalizer + * + * @param conn + * the HttpURLConnection for the current operation + * @return the appropriate Canonicalizer for the operation. + */ + protected static Canonicalizer getTableLiteCanonicalizer(final HttpURLConnection conn) { + if (validateVersionIsSupported(conn)) { + return TABLE_LITE_INSTANCE; + } else { + throw new UnsupportedOperationException( + "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); + } + } + + /** + * Determines if the current request is using a protocol post PDC 2009. + * + * @param conn + * the HttpURLConnection for the current operation + * @return true if is greater or equal PDC 09'; otherwise, false. + */ + private static Boolean validateVersionIsSupported(final HttpURLConnection conn) { + final String versionString = + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.STORAGE_VERSION_HEADER); + + if (versionString.length() == 0 || versionString.length() == 0) { + return true; + } + + try { + final Calendar versionThresholdCalendar = Calendar.getInstance(Utility.LOCALE_US); + versionThresholdCalendar.set(2009, Calendar.SEPTEMBER, 19, 0, 0, 0); + versionThresholdCalendar.set(Calendar.MILLISECOND, 0); + + final DateFormat versionFormat = new SimpleDateFormat("yyyy-MM-dd"); + final Date versionDate = versionFormat.parse(versionString); + final Calendar requestVersionCalendar = Calendar.getInstance(Utility.LOCALE_US); + requestVersionCalendar.setTime(versionDate); + requestVersionCalendar.set(Calendar.HOUR_OF_DAY, 0); + requestVersionCalendar.set(Calendar.MINUTE, 0); + requestVersionCalendar.set(Calendar.SECOND, 0); + requestVersionCalendar.set(Calendar.MILLISECOND, 1); + + return requestVersionCalendar.compareTo(versionThresholdCalendar) >= 0; + + } catch (final ParseException e) { + return false; + } + } + + /** + * Private Default Ctor + */ + private CanonicalizerFactory() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java new file mode 100644 index 0000000000000..d3bf310926292 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java @@ -0,0 +1,58 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.util.HashMap; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. An internal helper class used to parse objects from responses. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class DeserializationHelper { + /** + * Reads Metadata from the XMLStreamReader. + * + * @param xmlr + * the XMLStreamReader object + * @return the metadata as a hashmap. + * @throws XMLStreamException + * if there is a parsing exception + */ + public static HashMap parseMetadateFromXML(final XMLStreamReader xmlr) throws XMLStreamException { + final HashMap retVals = new HashMap(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.METADATA_ELEMENT); + + int eventType = xmlr.getEventType(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.END_ELEMENT && Constants.METADATA_ELEMENT.equals(name)) { + break; + } else if (Constants.INVALID_METADATA_NAME.equals(name)) { + // no op , skip + } else if (eventType == XMLStreamConstants.START_ELEMENT) { + final String tValue = Utility.readElementFromXMLReader(xmlr, name); + if (!Utility.isNullOrEmpty(tValue)) { + retVals.put(name, tValue); + } + } + } + + return retVals; + } + + /** + * Private Default Ctor + */ + private DeserializationHelper() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java new file mode 100644 index 0000000000000..0ed8b385404bf --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -0,0 +1,306 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; +import java.util.Date; +import java.util.concurrent.TimeoutException; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RequestResult; +import com.microsoft.windowsazure.services.core.storage.ResponseReceivedEvent; +import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; +import com.microsoft.windowsazure.services.core.storage.RetryPolicy; +import com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory; +import com.microsoft.windowsazure.services.core.storage.RetryResult; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. A class that handles execution of StorageOperations and enforces retry policies. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class ExecutionEngine { + + /** + * Executes an operation without a retry policy. + * + * @param + * The service client type + * @param + * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. + * @param + * The type of the expected result + * @param client + * the service client associated with the request + * @param parentObject + * the parent object + * @param task + * the StorageOperation to execute + * @param opContext + * an object used to track the execution of the operation + * @return the result of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + protected static RESULT_TYPE execute( + final CLIENT_TYPE client, final PARENT_TYPE parentObject, + final StorageOperation task, final OperationContext opContext) + throws StorageException { + return executeWithRetry(client, parentObject, task, RetryNoRetry.getInstance(), opContext); + } + + /** + * Executes an operation and enforces a retrypolicy to handle any potential errors + * + * @param + * The service client type + * @param + * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. + * @param + * The type of the expected result + * @param client + * the service client associated with the request + * @param parentObject + * the parent object + * @param task + * the StorageOperation to execute + * @param policyFactory + * the factory used to generate a new retry policy instance + * @param opContext + * an object used to track the execution of the operation + * @return the result of the operation + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + public static RESULT_TYPE executeWithRetry( + final CLIENT_TYPE client, final PARENT_TYPE parentObject, + final StorageOperation task, final RetryPolicyFactory policyFactory, + final OperationContext opContext) throws StorageException { + + final RetryPolicy policy = policyFactory.createInstance(opContext); + RetryResult retryRes; + int currentRetryCount = 0; + StorageException translatedException = null; + final long startTime = new Date().getTime(); + + while (true) { + try { + // reset result flags + task.initialize(); + + final RESULT_TYPE result = task.execute(client, parentObject, opContext); + + opContext.setClientTimeInMs(new Date().getTime() - startTime); + + if (!task.isNonExceptionedRetryableFailure()) { + // Success return result, the rest of the return paths throw. + return result; + } else { + // The task may have already parsed an exception. + translatedException = task.materializeException(getLastRequestObject(opContext), opContext); + setLastException(opContext, translatedException); + + // throw on non retryable status codes: 501, 505, blob type + // mismatch + if (task.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_IMPLEMENTED + || task.getResult().getStatusCode() == HttpURLConnection.HTTP_VERSION + || translatedException.getErrorCode().equals(StorageErrorCodeStrings.INVALID_BLOB_TYPE)) { + throw translatedException; + } + } + } catch (final TimeoutException e) { + // Retryable + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + } catch (final SocketTimeoutException e) { + // Retryable + translatedException = + new StorageException(StorageErrorCodeStrings.OPERATION_TIMED_OUT, + "The operation did not complete in the specified time.", -1, null, e); + setLastException(opContext, translatedException); + } catch (final IOException e) { + // Retryable + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + } catch (final XMLStreamException e) { + // Retryable + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + } catch (final InvalidKeyException e) { + // Non Retryable, just throw + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + throw translatedException; + } catch (final URISyntaxException e) { + // Non Retryable, just throw + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + throw translatedException; + } catch (final StorageException e) { + // Non Retryable, just throw + // do not translate StorageException + setLastException(opContext, e); + throw e; + } catch (final Exception e) { + // Non Retryable, just throw + // TODO Should this be retried? + translatedException = + StorageException.translateException(getLastRequestObject(opContext), e, opContext); + setLastException(opContext, translatedException); + throw translatedException; + } + + // Evaluate Retry Policy + retryRes = + policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), opContext.getLastResult() + .getException(), opContext); + + if (!retryRes.isShouldRetry()) { + throw translatedException; + } else { + retryRes.doSleep(); + currentRetryCount++; + } + } + } + + /** + * Gets the input stream from the request + * + * @param request + * the request to process + * @param opContext + * an object used to track the execution of the operation + * @return the input stream from the request + * @throws IOException + * if there is an error making the connection + */ + public static InputStream getInputStream(final HttpURLConnection request, final OperationContext opContext) + throws IOException { + final RequestResult currResult = new RequestResult(); + opContext.setCurrentRequestObject(request); + currResult.setStartDate(new Date()); + opContext.getRequestResults().add(currResult); + try { + return request.getInputStream(); + } catch (final IOException ex) { + getResponseCode(currResult, request, opContext); + throw ex; + } + } + + /** + * Gets the last request object in a safe way, returns null if there was not last request result. + * + * @param opContext + * an object used to track the execution of the operation + * @return the last request object in a safe way, returns null if there was not last request result. + */ + private static HttpURLConnection getLastRequestObject(final OperationContext opContext) { + if (opContext == null || opContext.getCurrentRequestObject() == null) { + return null; + } + + return opContext.getCurrentRequestObject(); + } + + /** + * Gets the response code form the request + * + * @param currResult + * the current RequestResult object + * @param request + * the request to process + * @param opContext + * an object used to track the execution of the operation + * @throws IOException + * if there is an error making the connection + */ + public static void getResponseCode( + final RequestResult currResult, final HttpURLConnection request, final OperationContext opContext) + throws IOException { + // Send the request + currResult.setStatusCode(request.getResponseCode()); + currResult.setStatusMessage(request.getResponseMessage()); + + currResult.setStopDate(new Date()); + currResult.setServiceRequestID(BaseResponse.getRequestId(request)); + currResult.setEtag(BaseResponse.getEtag(request)); + currResult.setRequestDate(BaseResponse.getDate(request)); + currResult.setContentMD5(BaseResponse.getContentMD5(request)); + + if (opContext.getResponseReceivedEventHandler().hasListeners()) { + opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); + } + } + + /** + * Gets the response for a given HttpURLConnection, populates the opContext with the result, and fires an event if + * it has listeners. + * + * @param request + * the request to process + * @param opContext + * an object used to track the execution of the operation + * @return a RequestResult object representing the status code/ message of the current request + * @throws IOException + * if there is an error making the connection + */ + public static RequestResult processRequest(final HttpURLConnection request, final OperationContext opContext) + throws IOException { + final RequestResult currResult = new RequestResult(); + currResult.setStartDate(new Date()); + opContext.getRequestResults().add(currResult); + opContext.setCurrentRequestObject(request); + + // Send the request + currResult.setStatusCode(request.getResponseCode()); + currResult.setStatusMessage(request.getResponseMessage()); + + currResult.setStopDate(new Date()); + currResult.setServiceRequestID(BaseResponse.getRequestId(request)); + currResult.setEtag(BaseResponse.getEtag(request)); + currResult.setRequestDate(BaseResponse.getDate(request)); + currResult.setContentMD5(BaseResponse.getContentMD5(request)); + + if (opContext.getResponseReceivedEventHandler().hasListeners()) { + opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); + } + + return currResult; + } + + /** + * Sets the exception on the last request result in a safe way, if there is no last result one is added. + * + * @param opContext + * an object used to track the execution of the operation + * @param exceptionToSet + * the exception to set on the result. + */ + private static void setLastException(final OperationContext opContext, final Exception exceptionToSet) { + if (opContext.getLastResult() == null) { + opContext.getRequestResults().add(new RequestResult()); + } + opContext.getLastResult().setException(exceptionToSet); + } + + /** + * Private default Ctor for Utility Class + */ + private ExecutionEngine() { + // private ctor + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java new file mode 100644 index 0000000000000..59d9f87dedcad --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java @@ -0,0 +1,141 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory; +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. Provides a lazy iterator which will retrieve the next segment of a result as the iterator + * is consumed + * + * @param + * The service client type + * @param + * The type of the parent object, i.e. CloudBlobClient for ListContainers etc. + * @param + * The type of the objects the resulting iterable objects + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class LazySegmentedIterator implements Iterator, + Iterable { + + /** + * Holds the current segment of results. + */ + private ResultSegment currentSegment; + + /** + * Holds the iterator for the current Segment. + */ + private Iterator currentSegmentIterator; + + /** + * Holds the service client associated with the operations. + */ + private final CLIENT_TYPE client; + + /** + * Holds a reference to the parent object, i.e. CloudBlobContainer for list blobs. + */ + private final PARENT_TYPE parentObject; + + /** + * Holds the reference to the RetryPolicyFactory object. + */ + private final RetryPolicyFactory policyFactory; + + /** + * Holds the SegmentedStorageOperation which is used to retrieve the next segment of results. + */ + private final SegmentedStorageOperation> segmentGenerator; + + /** + * Holds an object used to track the execution of the operation + */ + private final OperationContext opContext; + + /** + * Initializes the LazySegmentedIterator. + * + * @param segmentGenerator + * a SegmentedStorageOperation to execute in order to retrieve the next segment of the result. + * @param client + * the service client associated with the request + * @param parent + * the parent object + * @param policyFactory + * the factory used to generate a new retry policy instance + * @param opContext + * an object used to track the execution of the operation + */ + public LazySegmentedIterator( + final SegmentedStorageOperation> segmentGenerator, + final CLIENT_TYPE client, final PARENT_TYPE parent, final RetryPolicyFactory policyFactory, + final OperationContext opContext) { + this.segmentGenerator = segmentGenerator; + this.parentObject = parent; + this.opContext = opContext; + this.policyFactory = policyFactory; + this.client = client; + } + + /** + * Indicates if the iterator has another element. + */ + @DoesServiceRequest + public boolean hasNext() { + while (this.currentSegment == null + || (!this.currentSegmentIterator.hasNext() && this.currentSegment != null && this.currentSegment + .getHasMoreResults())) { + try { + this.currentSegment = + ExecutionEngine.executeWithRetry(this.client, + this.parentObject, + this.segmentGenerator, + this.policyFactory, + this.opContext); + } catch (final StorageException e) { + final NoSuchElementException ex = + new NoSuchElementException( + "An error occurred while enumerating the result, check the original exception for details."); + ex.initCause(e); + throw ex; + } + this.currentSegmentIterator = this.currentSegment.getResults().iterator(); + + if (!this.currentSegmentIterator.hasNext() && !this.currentSegment.getHasMoreResults()) { + return false; + } + } + + return this.currentSegmentIterator.hasNext(); + } + + /** + * Gets a reference to the iterator. + */ + public Iterator iterator() { + return this; + } + + /** + * Returns the next element. + */ + public ENTITY_TYPE next() { + return this.currentSegmentIterator.next(); + } + + /** + * Removes an element, not supported + */ + public void remove() { + // read only, no-op + throw new UnsupportedOperationException(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java new file mode 100644 index 0000000000000..6c346e67f7165 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java @@ -0,0 +1,48 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import com.microsoft.windowsazure.services.core.storage.Constants; + +/** + * RESERVED FOR INTERNAL USE. Describes actions that can be performed on a lease. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum LeaseAction { + + /** + * Acquire the lease. + */ + ACQUIRE, + + /** + * Renew the lease. + */ + RENEW, + + /** + * Release the lease. + */ + RELEASE, + + /** + * Break the lease. + */ + BREAK; + + @Override + public String toString() { + switch (this) { + case ACQUIRE: + return "Acquire"; + case RENEW: + return "Renew"; + case RELEASE: + return "Release"; + case BREAK: + return "Break"; + default: + // Wont Happen, all possible values covered above. + return Constants.EMPTY_STRING; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java new file mode 100644 index 0000000000000..384fb72f9d2fd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java @@ -0,0 +1,83 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +/** + * RESERVED FOR INTERNAL USE. A class which holds the current context of a listing + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public class ListingContext { + + /** + * The Marker value. + */ + private String marker; + + /** + * The MaxResults value. + */ + private Integer maxResults; + + /** + * The Prefix value. + */ + private String prefix; + + /** + * Initializes a new instance of the ListingContext class. + * + * @param prefix + * the listing prefix to use + * @param maxResults + * the maximum number of results to retrieve. + */ + public ListingContext(final String prefix, final Integer maxResults) { + this.setPrefix(prefix); + this.setMaxResults(maxResults); + this.setMarker(null); + } + + /** + * @return the marker + */ + public final String getMarker() { + return this.marker; + } + + /** + * @return the maxResults + */ + public final Integer getMaxResults() { + return this.maxResults; + } + + /** + * @return the prefix + */ + public final String getPrefix() { + return this.prefix; + } + + /** + * @param marker + * the marker to set + */ + public final void setMarker(final String marker) { + this.marker = marker; + } + + /** + * @param maxResults + * the maxResults to set + */ + protected final void setMaxResults(final Integer maxResults) { + this.maxResults = maxResults; + } + + /** + * @param prefix + * the prefix to set + */ + public final void setPrefix(final String prefix) { + this.prefix = prefix; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java new file mode 100644 index 0000000000000..c6e3ce77c7b6b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java @@ -0,0 +1,62 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import com.microsoft.windowsazure.services.core.storage.RequestOptions; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; + +/** + * RESERVED FOR INTERNAL USE. A base class which encapsulate the execution of a given segmented storage operation. + * + * @param + * The service client type + * @param

+ * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. + * @param + * The type of the expected result + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class SegmentedStorageOperation extends StorageOperation { + + /** + * Holds the ResultContinuation between executions. + */ + private ResultContinuation token; + + /** + * Initializes a new instance of the SegmentedStorageOperation class. + * + * @param options + * the RequestOptions to use + */ + public SegmentedStorageOperation(final RequestOptions options) { + super(options); + } + + /** + * Initializes a new instance of the SegmentedStorageOperation class. + * + * @param options + * the RequestOptions to use + * @param token + * the ResultContinuation to use + */ + public SegmentedStorageOperation(final RequestOptions options, final ResultContinuation token) { + super(options); + this.setToken(token); + } + + /** + * @return the token. + */ + protected final ResultContinuation getToken() { + return this.token; + } + + /** + * @param token + * the token to set. + */ + protected final void setToken(final ResultContinuation token) { + this.token = token; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java new file mode 100644 index 0000000000000..c2e63a55d4c2c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java @@ -0,0 +1,142 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.io.InputStream; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/*** + * RESERVED FOR INTERNAL USE. A class to help parse the Error details from an input stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class StorageErrorResponse { + /** + * Holds the StorageExtendedErrorInformation to return. + */ + private final StorageExtendedErrorInformation errorInfo; + + /** + * Holds a flag indicating if the response has been parsed or not. + */ + private boolean isParsed; + + /** + * Holds a reference to the input stream to read from. + */ + private final InputStream streamRef; + + /** + * Initializes the StorageErrorResponse object. + * + * @param stream + * the input stream to read error details from. + */ + public StorageErrorResponse(final InputStream stream) { + this.streamRef = stream; + this.errorInfo = new StorageExtendedErrorInformation(); + } + + /** + * Gets the Extended Error information from the response stream. + * + * @return the Extended Error information from the response stream + * @throws XMLStreamException + * if an xml exception occurs + */ + public StorageExtendedErrorInformation getExtendedErrorInformation() throws XMLStreamException { + if (!this.isParsed) { + this.parseResponse(); + } + + return this.errorInfo; + } + + /** + * Parses the Error Exception details from the response. + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if an xml exception occurs + */ + private void parseErrorException(final XMLStreamReader xmlr) throws XMLStreamException { + int eventType = xmlr.getEventType(); + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.ERROR_EXCEPTION); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION_MESSAGE)) { + final String errorExceptionMessage = + Utility.readElementFromXMLReader(xmlr, Constants.ERROR_EXCEPTION_MESSAGE); + this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_MESSAGE, + new String[] { errorExceptionMessage }); + + } else if (eventType == XMLStreamConstants.START_ELEMENT + && name.equals(Constants.ERROR_EXCEPTION_STACK_TRACE)) { + final String errorExceptionStack = + Utility.readElementFromXMLReader(xmlr, Constants.ERROR_EXCEPTION_STACK_TRACE); + this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_STACK_TRACE, + new String[] { errorExceptionStack }); + } else if (eventType == XMLStreamConstants.END_ELEMENT) { + break; + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ERROR_EXCEPTION); + } + + /** + * Parses the extended error information from the response stream. + * + * @throws XMLStreamException + * if an xml exception occurs + */ + private void parseResponse() throws XMLStreamException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + String tempParseString; + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get Error Root Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.ERROR_ROOT_ELEMENT); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + if (eventType == XMLStreamConstants.END_ELEMENT) { + break; + } + + final String name = xmlr.getName().toString(); + + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_CODE)) { + this.errorInfo.setErrorCode(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_CODE)); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_MESSAGE)) { + this.errorInfo.setErrorMessage(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_MESSAGE)); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION)) { + // get error exception + this.parseErrorException(xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ERROR_EXCEPTION); + } else if (eventType == XMLStreamConstants.START_ELEMENT) { + // get additional details + tempParseString = Utility.readElementFromXMLReader(xmlr, name); + + this.errorInfo.getAdditionalDetails().put(name, new String[] { tempParseString }); + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, null); + } + + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java new file mode 100644 index 0000000000000..337c0cd5b854b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -0,0 +1,162 @@ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; + +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RequestOptions; +import com.microsoft.windowsazure.services.core.storage.RequestResult; +import com.microsoft.windowsazure.services.core.storage.StorageException; + +/** + * RESERVED FOR INTERNAL USE. A base class which encapsulate the execution of a given storage operation. + * + * @param + * The service client type + * @param

+ * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. + * @param + * The type of the expected result + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public abstract class StorageOperation { + + /** + * Holds a reference to a realized exception which occurred during execution. + */ + private StorageException exceptionReference; + + /** + * A flag to indicate a failure which did not result in an exceptin, i.e a 400 class status code. + */ + private boolean nonExceptionedRetryableFailure; + + /** + * The RequestOptions to use for the request. + */ + private RequestOptions requestOptions; + + /** + * Holds the result for the operation. + */ + private RequestResult result; + + /** + * Default Ctor. + */ + protected StorageOperation() { + // no op + } + + /** + * Initializes a new instance of the StorageOperation class. + * + * @param options + * the RequestOptions to use + */ + public StorageOperation(final RequestOptions options) { + this.setRequestOptions(options); + } + + /** + * Executes the operation. + * + * @param client + * a reference to the service client associated with the object being operated against + * @param parentObject + * a reference to the parent object of the operation, (i.e. CloudBlobContainer for Create) + * @param opContext + * an object used to track the execution of the operation + * @return the result from the operation + * @throws Exception + * an error which occurred during execution + */ + public abstract R execute(C client, P parentObject, OperationContext opContext) throws Exception; + + /** + * @return the exception + */ + public final StorageException getException() { + return this.exceptionReference; + } + + /** + * @return the requestOptions + */ + public final RequestOptions getRequestOptions() { + return this.requestOptions; + } + + /** + * @return the result + */ + public final RequestResult getResult() { + return this.result; + } + + /** + * Resets the operation status flags between operations. + */ + protected final void initialize() { + this.setResult(new RequestResult()); + this.setException(null); + this.setNonExceptionedRetryableFailure(false); + } + + /** + * @return the nonExceptionedRetryableFailure + */ + public final boolean isNonExceptionedRetryableFailure() { + return this.nonExceptionedRetryableFailure; + } + + /** + * Returns either the held exception from the operation if it is set, othwerwise the translated exception. + * + * @param request + * the reference to the HttpURLConnection for the operation. + * @param opContext + * an object used to track the execution of the operation + * @return the exception to throw. + */ + protected final StorageException materializeException( + final HttpURLConnection request, final OperationContext opContext) { + if (this.getException() != null) { + return this.getException(); + } + + return StorageException.translateException(request, null, opContext); + } + + /** + * @param exceptionReference + * the exception to set + */ + protected final void setException(final StorageException exceptionReference) { + this.exceptionReference = exceptionReference; + } + + /** + * @param nonExceptionedRetryableFailure + * the nonExceptionedRetryableFailure to set + */ + public final void setNonExceptionedRetryableFailure(final boolean nonExceptionedRetryableFailure) { + this.nonExceptionedRetryableFailure = nonExceptionedRetryableFailure; + } + + /** + * @param requestOptions + * the requestOptions to set + */ + protected final void setRequestOptions(final RequestOptions requestOptions) { + this.requestOptions = requestOptions; + } + + /** + * @param result + * the result to set + */ + public final void setResult(final RequestResult result) { + this.result = result; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java new file mode 100644 index 0000000000000..f83b936ffa9c9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -0,0 +1,54 @@ +/** + * + */ +package com.microsoft.windowsazure.services.core.storage.utils.implementation; + +import java.net.HttpURLConnection; +import java.security.InvalidParameterException; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Table Service + * under the Shared Key Lite authentication scheme. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +class TableLiteCanonicalizer extends Canonicalizer { + /** + * Constructs a canonicalized string for signing a request. + * + * @param conn + * the HttpURLConnection to canonicalize + * @param accountName + * the account name associated with the request + * @param contentLength + * the length of the content written to the outputstream in bytes, -1 if unknown + * @param opContext + * the OperationContext for the given request + * @return a canonicalized string. + * @throws StorageException + */ + @Override + protected String canonicalize( + final HttpURLConnection conn, final String accountName, final Long contentLength, + final OperationContext opContext) throws StorageException { + if (contentLength < -1) { + throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); + } + + final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); + if (Utility.isNullOrEmpty(dateString)) { + throw new IllegalArgumentException( + "Canonicalization did not find a non empty x-ms-date header in the request. Please use a request with a valid x-ms-date header in RFC 123 format."); + } + + final StringBuilder canonicalizedString = new StringBuilder(dateString); + appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(conn.getURL(), accountName)); + + return canonicalizedString.toString(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java new file mode 100644 index 0000000000000..027ac7b66e0f0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -0,0 +1,1316 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.HashMap; + +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Represents a queue in the Windows Azure Queue service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudQueue { + + static CloudQueueMessage getFirstOrNull(final Iterable messages) { + for (final CloudQueueMessage m : messages) { + return m; + } + + return null; + } + + /** + * Holds the Name of the queue + */ + private String name; + + /** + * Holds the URI of the queue + */ + URI uri; + + /** + * Holds a reference to the associated service client. + */ + private CloudQueueClient queueServiceClient; + + /** + * Holds the Queue Metadata + */ + HashMap metadata; + + /** + * Holds the Queue ApproximateMessageCount + */ + long approximateMessageCount; + + /** + * Uri for the messages. + */ + private URI messageRequestAddress; + + /** + * Holds for the flag weather the message should be encoded. + */ + Boolean shouldEncodeMessage; + + /** + * Creates an instance of the CloudQueue class using the specified address and client. + * + * @param queueAddress + * A String that represents either the absolute URI to the queue, or the queue name. + * @param client + * A {@link CloudQueueClient} object that represents the associated service client, and that specifies + * the endpoint for the Queue service. + * + * @throws URISyntaxException + * If the resource URI is invalid. + */ + public CloudQueue(final String queueAddress, final CloudQueueClient client) throws URISyntaxException { + this(PathUtility.appendPathToUri(client.getEndpoint(), queueAddress), client); + } + + /** + * Creates an instance of the CloudQueue class using the specified address and client. + * + * @param uri + * A java.net.URI object that represents the URI of the queue. + * @param client + * A {@link CloudQueueClient} object that represents the associated service client, and that specifies + * the endpoint for the Queue service. + */ + public CloudQueue(final URI uri, final CloudQueueClient client) { + this.uri = uri; + this.name = PathUtility.getQueueNameFromUri(uri, client.isUsePathStyleUris()); + this.queueServiceClient = client; + this.shouldEncodeMessage = true; + } + + /** + * Adds a message to the queue. + * + * @param message + * A {@link CloudQueueMessage} object that specifies the message to add. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void addMessage(final CloudQueueMessage message) throws StorageException { + this.addMessage(message, 0, 0, null, null); + } + + /** + * Adds a message to the queue. + * + * @param message + * A {@link CloudQueueMessage} object that specifies the message to add. + * + * @param timeToLiveInSeconds + * The maximum time to allow the message to be in the queue, or null if the service default time is to be + * used. + * + * @param initialVisibilityDelayInSeconds + * The length of time from now during which the message will be invisible, or null if the message is to + * be visible immediately. This must be greater than or equal to zero and less than the value of + * timeToLive (if not null). + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void addMessage( + final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, + QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.putMessage(queue.getMessageRequestAddress(), + this.getRequestOptions().getTimeoutIntervalInMs(), + initialVisibilityDelayInSeconds, + timeToLiveInSeconds, + opContext); + + final byte[] messageBytes = + QueueRequest.generateMessageRequestBody(message + .getMessageContentForTransfer(queue.shouldEncodeMessage)); + + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Clears all messages from the queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void clear() throws StorageException { + this.clear(null, null); + } + + /** + * Clears all messages from the queue, using the specified request options and operation context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void clear(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.clearMessages(queue.getMessageRequestAddress(), this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Creates the queue. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public void create() throws StorageException { + this.create(null, null); + } + + /** + * Creates the queue. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public void create(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.create(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED + && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Creates the queue if it does not exist. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public Boolean createIfNotExist() throws StorageException { + return this.createIfNotExist(null, null); + } + + /** + * Creates the queue if it does not exist. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public Boolean createIfNotExist(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.create(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = + StorageException.translateException(request, null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + } + } + + return false; + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Deletes the queue. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public void delete() throws StorageException { + this.delete(null, null); + } + + /** + * Deletes the queue. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public void delete(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.delete(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + + } + + /** + * Deletes the queue if it exists. + * + * @throws StorageException + * an exception representing any error which occurred during the operation. + */ + @DoesServiceRequest + public Boolean deleteIfExists() throws StorageException { + return this.deleteIfExists(null, null); + } + + /** + * Deletes the queue if it exists using the specified request options and operation context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the queue did not already exist and was created; otherwise, false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.delete(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } else { + this.setNonExceptionedRetryableFailure(true); + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + + } + + /** + * Deletes a message in a queue. + * + * @param message + * A {@link CloudQueueMessage} object that specifies the message to delete. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void deleteMessage(final CloudQueueMessage message) throws StorageException { + this.deleteMessage(message, null, null); + } + + /** + * Deletes a message in a queue, using the specified request options and operation context. + * + * @param message + * A {@link CloudQueueMessage} object that specifies the message to delete. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final String messageId = message.getId(); + final String messagePopReceipt = message.getPopReceipt(); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.deleteMessage(queue.getIndividualMessageAddress(messageId), this + .getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Downloads the queue's metadata and ApproximateMessageCount. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void downloadAttributes() throws StorageException { + this.downloadAttributes(null, null); + } + + /** + * Downloads the queue's metadata and ApproximateMessageCount, using the specified request options and operation + * context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueue}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void downloadAttributes(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + queue.metadata = BaseResponse.getMetadata(request); + queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Returns a value that indicates whether the queue exists. + * + * @return true if the queue exists, otherwise false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean exist() throws StorageException { + return this.exist(null, null); + } + + /** + * Returns a value that indicates whether the queue exists, using the specified request options and operation + * context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return true if the queue exists, otherwise false. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Boolean exist(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + return Boolean.valueOf(true); + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Gets the approximate messages count of the queue. + * + * @return A Long object that represents the approximate messages count of the queue. + */ + public long getApproximateMessageCount() { + return this.approximateMessageCount; + } + + /** + * Get a single message request(Used internally only). + * + * @return the single message request. + * + * @throws URISyntaxException + * If the resource URI is invalid. + */ + URI getIndividualMessageAddress(final String messageId) throws URISyntaxException { + return PathUtility.appendPathToUri(this.messageRequestAddress, messageId); + } + + /** + * Get the message request base address(Used internally only). + * + * @return the message request. + * + * @throws URISyntaxException + * If the resource URI is invalid. + */ + URI getMessageRequestAddress() throws URISyntaxException { + if (this.messageRequestAddress == null) { + this.messageRequestAddress = PathUtility.appendPathToUri(this.uri, QueueConstants.MESSAGES); + } + + return this.messageRequestAddress; + } + + /** + * Returns the metadata for the queue. + * + * @return A java.util.HashMap object that represents the metadata for the queue. + */ + public HashMap getMetadata() { + return this.metadata; + } + + /** + * Gets the name of the queue + * + * @return A String object that represents the name of the queue. + */ + public String getName() { + return this.name; + } + + /** + * Returns the queue service client associated with this queue. + * + * @return A {@link CloudQueueClient} object that represents the service client associated with this queue. + */ + public CloudQueueClient getServiceClient() { + return this.queueServiceClient; + } + + /** + * Gets the value indicating whether the message should be encoded. + * + * @return A Boolean that represents whether the message should be encoded. + */ + public Boolean getShouldEncodeMessage() { + return this.shouldEncodeMessage; + } + + /** + * Gets the uri for this queue. + * + * @return A URI object that represents the uri for this queue. + */ + public URI getUri() { + return this.uri; + } + + /** + * Peeks a message from the queue. + * + * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public CloudQueueMessage peekMessage() throws StorageException { + return this.peekMessage(null, null); + } + + /** + * Peeks a message from the queue, using the specified request options and operation context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public CloudQueueMessage peekMessage(final QueueRequestOptions options, final OperationContext opContext) + throws StorageException { + return getFirstOrNull(this.peekMessages(1, null, null)); + } + + /** + * Peeks a set of messages from the queue. + * + * @param numberOfMessages + * The number of messages. + * + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Iterable peekMessages(final int numberOfMessages) throws StorageException { + return this.peekMessages(numberOfMessages, null, null); + } + + /** + * Peeks a set of messages from the queue, using the specified request options and operation context. + * + * @param numberOfMessages + * The number of messages. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Iterable peekMessages( + final int numberOfMessages, QueueRequestOptions options, OperationContext opContext) + throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation> impl = + new StorageOperation>(options) { + + @Override + public ArrayList execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.peekMessages(queue.getMessageRequestAddress(), this.getRequestOptions() + .getTimeoutIntervalInMs(), numberOfMessages, opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), + queue.shouldEncodeMessage); + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Retrieves a message from the queue. + * + * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public CloudQueueMessage retrieveMessage() throws StorageException { + return this.retrieveMessage(0, null, null); + } + + /** + * Retrieves a message from the queue, using the specified request options and operation context. + * + * @param visibilityTimeoutInSeconds + * Specifies the visibility timeout for the message, in seconds. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public CloudQueueMessage retrieveMessage( + final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext) + throws StorageException { + return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, null, null)); + } + + /** + * Retrieves a list of messages from the queue. + * + * @param numberOfMessages + * The number of messages. + * + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { + return this.retrieveMessages(numberOfMessages, 0, null, null); + } + + /** + * Retrieves a list of messages from the queue, using the specified request options and operation context. + * + * @param numberOfMessages + * The number of messages. + * + * @param visibilityTimeoutInSeconds + * Specifies the visibility timeout for the message, in seconds. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public Iterable retrieveMessages( + final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, + OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation> impl = + new StorageOperation>(options) { + + @Override + public ArrayList execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), + this.getRequestOptions().getTimeoutIntervalInMs(), + numberOfMessages, + visibilityTimeoutInSeconds, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), + queue.shouldEncodeMessage); + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Sets the metadata for the queue. + * + * @param metadata + * A java.util.HashMap object that represents the metadata being assigned to the queue. + */ + public void setMetadata(final HashMap metadata) { + this.metadata = metadata; + } + + /** + * Sets the name of the queue. + * + * @param name + * A String that represents the name being assigned to the queue. + */ + void setName(final String name) { + this.name = name; + } + + /** + * Updates a message in the queue. + * + * @throws StorageException + * If a storage service error occurred. + */ + public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds) + throws StorageException { + this.updateMessage(message, visibilityTimeoutInSeconds, EnumSet.of(MessageUpdateFields.VISIBILITY), null, null); + } + + /** + * Updates a message in the queue, using the specified request options and operation context. + * + * @param visibilityTimeoutInSeconds + * Specifies the visibility timeout for the message, in seconds. + * + * @param messageUpdateFields + * Specifies which parts of the message are to be updated. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void updateMessage( + final CloudQueueMessage message, final int visibilityTimeoutInSeconds, + final EnumSet messageUpdateFields, QueueRequestOptions options, + OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.updateMessage(queue.getIndividualMessageAddress(message.getId()), + this.getRequestOptions().getTimeoutIntervalInMs(), + message.getPopReceipt(), + visibilityTimeoutInSeconds, + opContext); + + if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { + final byte[] messageBytes = + QueueRequest.generateMessageRequestBody(message + .getMessageContentForTransfer(queue.shouldEncodeMessage)); + + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); + } else { + request.setFixedLengthStreamingMode(0); + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + } + + /** + * Uploads the queue's metadata. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadMetadata() throws StorageException { + this.uploadMetadata(null, null); + } + + /** + * Uploads the queue's metadata using the specified request options and operation context. + * + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public void uploadMetadata(QueueRequestOptions options, OperationContext opContext) throws StorageException { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this.queueServiceClient); + + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.setMetadata(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), + opContext); + + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java new file mode 100644 index 0000000000000..3cdb0201923de --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -0,0 +1,362 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidKeyException; + +import javax.xml.stream.XMLStreamException; + +import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; +import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.RequestOptions; +import com.microsoft.windowsazure.services.core.storage.ResultContinuation; +import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; +import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.ServiceClient; +import com.microsoft.windowsazure.services.core.storage.ServiceProperties; +import com.microsoft.windowsazure.services.core.storage.StorageCredentials; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; + +/** + * Provides a client for accessing the Windows Azure Queue service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class CloudQueueClient extends ServiceClient { + + /** + * Initializes a new instance of the CloudQueueClient class using the specified Queue service endpoint and account + * credentials. + * + * @param baseUri + * The Queue service endpoint to use to create the client + * @param credentials + * The account credentials. + */ + public CloudQueueClient(final URI baseUri, final StorageCredentials credentials) { + super(baseUri, credentials); + this.setTimeoutInMs(QueueConstants.DEFAULT_QUEUE_CLIENT_TIMEOUT_IN_MS); + + if (credentials == null) { + throw new IllegalArgumentException("StorageCredentials can't be null for the queue service."); + } + } + + /** + * Returns a reference to a {@link CloudQueue} object that represents the cloud queue for the specified address. + * + * @param queueAddress + * A String that represents the name of the queue, or the absolute URI to the queue. + * @return A {@link CloudQueue} object that represents a reference to the cloud queue. + * + * @throws URISyntaxException + * If the resource URI is invalid. + * @throws StorageException + * If a storage service error occurred. + */ + public CloudQueue getQueueReference(final String queueAddress) throws URISyntaxException, StorageException { + Utility.assertNotNullOrEmpty("queueAddress", queueAddress); + return new CloudQueue(queueAddress, this); + } + + /** + * Returns an enumerable collection of queues for this queue service client. + * + * @return An enumerable collection of {@link CloudQueue} objects that represent the queues for this client. + */ + @DoesServiceRequest + public Iterable listQueues() { + return this.listQueues(null, QueueListingDetails.NONE, null, null); + } + + /** + * Returns an enumerable collection of queues whose names begin with the specified prefix for this Queue service + * client. + * + * @param prefix + * A String that represents the queue name prefix. + * + * @return An enumerable collection of {@link CloudQueue} objects that represent the queues for this client whose + * names begin with the specified prefix. + */ + @DoesServiceRequest + public Iterable listQueues(final String prefix) { + return this.listQueues(prefix, QueueListingDetails.NONE, null, null); + } + + /** + * Returns an enumerable collection of queues whose names begin with the specified prefix for this Queue service + * client, using the specified details setting, request options, and operation context. + * + * @param prefix + * A String that represents the queue name prefix. + * @param detailsIncluded + * A {@link QueueListingDetails} value that indicates whether queue metadata will be returned. + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueue}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return An enumerable collection of {@link CloudQueue} objects that represents the queues for this client. + */ + @DoesServiceRequest + public Iterable listQueues( + final String prefix, final QueueListingDetails detailsIncluded, QueueRequestOptions options, + OperationContext opContext) { + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this); + + final SegmentedStorageOperation> impl = + new SegmentedStorageOperation>(options, null) { + @Override + public ResultSegment execute( + final CloudQueueClient client, final Void dontCare, final OperationContext opContext) + throws Exception { + + final ResultSegment result = + CloudQueueClient.this.listQueuesCore(prefix, + detailsIncluded, + -1, + this.getToken(), + this.getRequestOptions(), + this, + opContext); + + this.setToken(result.getContinuationToken()); + return result; + } + }; + + return new LazySegmentedIterator(impl, this, null, + options.getRetryPolicyFactory(), opContext); + } + + /** + * Returns a result segment containing a collection of queues. + * + * @param prefix + * A String that represents the queue name prefix. + * @param detailsIncluded + * A value that indicates whether to return queue metadata with the listing. + * @param maxResults + * the maximum results to retrieve. + * @param continuationToken + * A continuation token returned by a previous listing operation. + * @param options + * the request options to use for the operation + * @param taskReference + * a reference to the encapsulating task + * @param opContext + * a tracking object for the operation + * @return a result segment containing a collection of queues whose names begin with the specified prefix. + * @throws IOException + * @throws URISyntaxException + * @throws XMLStreamException + * @throws InvalidKeyException + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + ResultSegment listQueuesCore( + final String prefix, final QueueListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, final RequestOptions options, + final StorageOperation> taskReference, + final OperationContext opContext) + throws IOException, URISyntaxException, XMLStreamException, InvalidKeyException, StorageException { + + Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); + + final ListingContext listingContext = new ListingContext(prefix, maxResults); + listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); + + final HttpURLConnection listQueueRequest = + QueueRequest.list(this.getEndpoint(), + options.getTimeoutIntervalInMs(), + listingContext, + detailsIncluded, + opContext); + + this.getCredentials().signRequest(listQueueRequest, -1L); + + taskReference.setResult(ExecutionEngine.processRequest(listQueueRequest, opContext)); + + if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + taskReference.setNonExceptionedRetryableFailure(true); + return null; + } + + final ListQueuesResponse response = new ListQueuesResponse(listQueueRequest.getInputStream()); + response.parseResponse(this); + + ResultContinuation newToken = null; + + if (response.getNextMarker() != null) { + newToken = new ResultContinuation(); + newToken.setNextMarker(response.getNextMarker()); + newToken.setContinuationType(ResultContinuationType.QUEUE); + } + + final ResultSegment resSegment = + new ResultSegment(response.getQueues(this), maxResults, newToken); + + return resSegment; + } + + /** + * Returns a result segment of an enumerable collection of queues for this Queue service client. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} + * objects that represent the queues in this collection. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listQueuesSegmented() throws StorageException { + return this.listQueuesSegmented(null, QueueListingDetails.NONE, 0, null, null, null); + } + + /** + * Returns a result segment of an enumerable collection of queues whose names begin with the specified prefix for + * this Queue service client. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} + * objects that represent the queues in this collection. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listQueuesSegmented(final String prefix) throws StorageException { + return this.listQueuesSegmented(prefix, QueueListingDetails.NONE, 0, null, null, null); + } + + /** + * Returns a result segment of an enumerable collection of queues whose names begin with the specified prefix for + * this queue, using the specified listing details options, request options, and operation context. + * + * @param prefix + * A String that represents the prefix of the queue name. + * @param detailsIncluded + * A {@link QueueListingDetails} value that indicates whether queue metadata will be returned. + * @param maxResults + * The maximum number of results to retrieve. + * @param continuationToken + * A {@link ResultContinuation} object that represents a continuation token returned by a previous + * listing operation. + * @param options + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueue}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * + * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} + * objects that represent the containers in this container. + * + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + public ResultSegment listQueuesSegmented( + final String prefix, final QueueListingDetails detailsIncluded, final int maxResults, + final ResultContinuation continuationToken, QueueRequestOptions options, OperationContext opContext) + throws StorageException { + + if (opContext == null) { + opContext = new OperationContext(); + } + + if (options == null) { + options = new QueueRequestOptions(); + } + + opContext.initialize(); + options.applyDefaults(this); + + Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); + + final StorageOperation> impl = + new StorageOperation>(options) { + @Override + public ResultSegment execute( + final CloudQueueClient client, final Void dontCare, final OperationContext opContext) + throws Exception { + return CloudQueueClient.this.listQueuesCore(prefix, + detailsIncluded, + maxResults, + continuationToken, + this.getRequestOptions(), + this, + opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); + } + + /** + * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * + * @param properties + * The ServiceProperties to upload. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + @Override + public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { + this.uploadServiceProperties(properties, null, null); + } + + /** + * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * + * @param properties + * The ServiceProperties to upload. + * @param options + * A {@link RequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudBlobClient}{@link CloudQueueClient}). + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * @throws StorageException + * If a storage service error occurred. + */ + @DoesServiceRequest + @Override + public void uploadServiceProperties( + final ServiceProperties properties, final RequestOptions options, final OperationContext opContext) + throws StorageException { + if (!Utility.isNullOrEmpty(properties.getDefaultServiceVersion())) { + throw new IllegalArgumentException( + "DefaultServiceVersion can only be set for the Blob service and the request must be made using the 2011-08-18 version"); + } + super.uploadServiceProperties(properties, options, opContext); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java new file mode 100644 index 0000000000000..35885dc787cd2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java @@ -0,0 +1,240 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.UnsupportedEncodingException; +import java.util.Date; + +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * Represents a message in the Windows Azure Queue service. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public class CloudQueueMessage { + + /** + * Holds the message ID. + */ + protected String id; + + /** + * Holds the message's pop receipt. + */ + protected String popReceipt; + + /** + * Holds the time that the message was added to the queue. + */ + protected Date insertionTime; + + /** + * Holds the time that the message expires. + */ + protected Date expirationTime; + + /** + * Holds the time that the message will next be visible. + */ + protected Date nextVisibleTime; + + /** + * Holds the message content. + */ + protected String messageContent; + + /** + * Holds the dequeue count. + */ + protected int dequeueCount; + + /** + * Holds the message type. + */ + protected QueueMessageType messageType; + + /** + * Initializes a new instance of the CloudQueueMessage class(used internaly). + */ + CloudQueueMessage() { + // no op + } + + /** + * Initializes a new instance of the CloudQueueMessage class. + * + * @param content + * The content of the message. + */ + public CloudQueueMessage(final byte[] content) { + this.messageContent = Base64.encode(content); + this.messageType = QueueMessageType.BASE_64_ENCODED; + } + + /** + * Initializes a new instance of the CloudQueueMessage class. + * + * @param content + * The content of the message. + */ + public CloudQueueMessage(final String content) { + this.messageContent = content; + this.messageType = QueueMessageType.RAW_STRING; + } + + /** + * Gets the dequeue count. + * + * @return the dequeue count. + */ + public final int getDequeueCount() { + return this.dequeueCount; + } + + /** + * Gets the time that the message expires. + * + * @return the time that the message expires. + */ + public final Date getExpirationTime() { + return this.expirationTime; + } + + /** + * Gets the message ID. + * + * @return the message ID. + */ + public final String getId() { + return this.id; + } + + /** + * Gets the time that the message was added to the queue. + * + * @return the time that the message was added to the queue. + */ + public final Date getInsertionTime() { + return this.insertionTime; + } + + /** + * Gets the content of the message, as a byte array. + * + * @return the content of the message. + * + * @throws StorageException + * If a storage service error occurred. + */ + public final byte[] getMessageContentAsByte() throws StorageException { + if (Utility.isNullOrEmpty(this.messageContent)) { + return null; + } + + if (this.messageType == QueueMessageType.RAW_STRING) { + try { + return this.messageContent.getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } else { + return Base64.decode(this.messageContent); + } + } + + /** + * Gets the content of the message, as a string. + * + * @return the content of the message. + * + * @throws StorageException + * If a storage service error occurred. + */ + public final String getMessageContentAsString() throws StorageException { + if (Utility.isNullOrEmpty(this.messageContent)) { + return null; + } + + if (this.messageType == QueueMessageType.RAW_STRING) { + return this.messageContent; + } else { + try { + return new String(Base64.decode(this.messageContent), "UTF-8"); + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + } + + /** + * Gets the content of the message for transfer(internal use only). + * + * @throws StorageException + */ + protected final String getMessageContentForTransfer(final boolean shouldEncodeMessage) throws StorageException { + if (this.messageType == QueueMessageType.RAW_STRING) { + if (shouldEncodeMessage) { + return Base64.encode(this.getMessageContentAsByte()); + } + } + + return this.messageContent; + } + + /** + * Gets the time that the message will next be visible. + * + * @return the time that the message will next be visible. + */ + public final Date getNextVisibleTime() { + return this.nextVisibleTime; + } + + /** + * Gets the message's pop receipt. + * + * @return the message's pop receipt. + */ + public final String getPopReceipt() { + return this.popReceipt; + } + + /** + * @param expirationTime + * the expirationTime to set + */ + public final void setExpirationTime(final Date expirationTime) { + this.expirationTime = expirationTime; + } + + /** + * Sets the content of the message. + * + * @param content + * The content of the message. + */ + public final void setMessageContent(final byte[] content) { + this.messageContent = Base64.encode(content); + this.messageType = QueueMessageType.BASE_64_ENCODED; + } + + /** + * Sets the content of the message. + * + * @param content + * The content of the message. + */ + public final void setMessageContent(final String content) { + this.messageContent = content; + this.messageType = QueueMessageType.RAW_STRING; + } + + /** + * @param nextVisibleTime + * the nextVisibleTime to set + */ + public final void setNextVisibleTime(final Date nextVisibleTime) { + this.nextVisibleTime = nextVisibleTime; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java new file mode 100644 index 0000000000000..9fa73aa07cf98 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java @@ -0,0 +1,151 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.InputStream; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.ArrayList; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; + +/** + * RESERVED FOR INTERNAL USE. A class for parsing a list queues response stream. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class ListQueuesResponse { + + /** + * Holds the list of queues. + */ + private ArrayList queues = new ArrayList(); + + /** + * Stores the value indicating if the response has been fully parsed. + */ + private boolean isParsed; + + /** + * Stores the marker. + */ + private String marker; + + /** + * Stores the max results. + */ + private int maxResults; + + /** + * Stores the next marker. + */ + private String nextMarker; + + /** + * Stores the container prefix. + */ + private String prefix; + + /** + * Stores the InputStream to read from. + */ + private final InputStream streamRef; + + public ListQueuesResponse(final InputStream stream) { + this.streamRef = stream; + } + + public String getMarker() { + return this.marker; + } + + public int getMaxResults() { + return this.maxResults; + } + + public String getNextMarker() { + return this.nextMarker; + } + + public String getPrefix() { + return this.prefix; + } + + /** + * Returns an ArrayList of CloudQueue + * + * @param serviceClient + * a reference to the client object associated with this object. + * @return an ArrayList of CloudQueue + * @throws XMLStreamException + * @throws StorageException + */ + public ArrayList getQueues(final CloudQueueClient serviceClient) + throws XMLStreamException, StorageException { + if (!this.isParsed) { + this.parseResponse(serviceClient); + } + + return this.queues; + } + + /** + * Parses the XML stream. + * + * @param serviceClient + * a reference to the client object associated with this object. + * @throws XMLStreamException + * @throws StorageException + */ + public void parseResponse(final CloudQueueClient serviceClient) throws XMLStreamException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); + String tempParseString = null; + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + // 1. get enumerationResults Header + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); + + // check if there are more events in the input stream + while (xmlr.hasNext()) { + eventType = xmlr.next(); + + if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); + this.maxResults = Integer.parseInt(tempParseString); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); + } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(QueueConstants.QUEUES_ELEMENT)) { + try { + this.queues = QueueDeserializationHelper.readQueues(xmlr, serviceClient); + } catch (final URISyntaxException e) { + throw new XMLStreamException(e); + } catch (final ParseException e) { + throw new XMLStreamException(e); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); + // eventType = xmlr.next(); + } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + break; + } + } + } + + this.isParsed = true; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java new file mode 100644 index 0000000000000..3dd45b80c1e15 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java @@ -0,0 +1,34 @@ +package com.microsoft.windowsazure.services.queue.client; + +/** + * + * Represents a set of flags for updating messages. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum MessageUpdateFields { + /** + * Update the message visibility timeout. + */ + VISIBILITY(1), + + /** + * Update the message content. + */ + CONTENT(2); + + /** + * Returns the value of this enum. + */ + public int value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + MessageUpdateFields(final int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java new file mode 100644 index 0000000000000..1a66760f9055c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -0,0 +1,85 @@ +package com.microsoft.windowsazure.services.queue.client; + +/** + * RESERVED FOR INTERNAL USE. Holds the Constants used for the Queue Service. + */ +final class QueueConstants { + /** + * Default client side timeout, in milliseconds, for queue service. + */ + public static final int DEFAULT_QUEUE_CLIENT_TIMEOUT_IN_MS = 30 * 1000; + + /** + * XML element for a queue. + */ + public static final String QUEUE_ELEMENT = "Queue"; + + /** + * XML element for queues. + */ + public static final String QUEUES_ELEMENT = "Queues"; + + /** + * XML element for QueueMessagesList. + */ + public static final String QUEUE_MESSAGES_LIST_ELEMENT = "QueueMessagesList"; + + /** + * XML element for QueueMessage. + */ + public static final String QUEUE_MESSAGE_ELEMENT = "QueueMessage"; + + /** + * XML element for MessageId. + */ + public static final String MESSAGE_ID_ELEMENT = "MessageId"; + + /** + * XML element for InsertionTime. + */ + public static final String INSERTION_TIME_ELEMENT = "InsertionTime"; + + /** + * XML element for ExpirationTime. + */ + public static final String EXPIRATION_TIME_ELEMENT = "ExpirationTime"; + + /** + * XML element for PopReceipt. + */ + public static final String POP_RECEIPT_ELEMENT = "PopReceipt"; + + /** + * XML element for TimeNextVisible. + */ + public static final String TIME_NEXT_VISIBLE_ELEMENT = "TimeNextVisible"; + + /** + * XML element for DequeueCount. + */ + public static final String DEQUEUE_COUNT_ELEMENT = "DequeueCount"; + + /** + * XML element for MessageText. + */ + public static final String MESSAGE_TEXT_ELEMENT = "MessageText"; + + /** + * The URI path component to access the messages in a queue. + */ + public static final String MESSAGES = "messages"; + + /** + * The header that specifies the approximate message count of a queue. + */ + public static final String APPROXIMATE_MESSAGES_COUNT = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "approximate-messages-count"; + + /** + * Private Default Ctor. + */ + private QueueConstants() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java new file mode 100644 index 0000000000000..0292aaad2fdb6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java @@ -0,0 +1,218 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.HashMap; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.DeserializationHelper; + +/** + * RESERVED FOR INTERNAL USE. Class to provide object deserialization for queues. + */ +final class QueueDeserializationHelper { + /** + * Populates the message from an XMLStreamReader. + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + protected static CloudQueueMessage readMessage(final XMLStreamReader xmlr, final boolean shouldEncodeMessage) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_MESSAGE_ELEMENT); + + final CloudQueueMessage message = new CloudQueueMessage(); + message.messageType = shouldEncodeMessage ? QueueMessageType.BASE_64_ENCODED : QueueMessageType.RAW_STRING; + + int eventType = xmlr.getEventType(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(QueueConstants.MESSAGE_ID_ELEMENT)) { + message.id = Utility.readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_ID_ELEMENT); + } else if (name.equals(QueueConstants.INSERTION_TIME_ELEMENT)) { + message.insertionTime = + Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, + QueueConstants.INSERTION_TIME_ELEMENT)); + } else if (name.equals(QueueConstants.EXPIRATION_TIME_ELEMENT)) { + message.expirationTime = + Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, + QueueConstants.EXPIRATION_TIME_ELEMENT)); + } else if (name.equals(QueueConstants.POP_RECEIPT_ELEMENT)) { + message.popReceipt = Utility.readElementFromXMLReader(xmlr, QueueConstants.POP_RECEIPT_ELEMENT); + } else if (name.equals(QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)) { + message.nextVisibleTime = + Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, + QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)); + } else if (name.equals(QueueConstants.DEQUEUE_COUNT_ELEMENT)) { + message.dequeueCount = + Integer.parseInt(Utility.readElementFromXMLReader(xmlr, + QueueConstants.DEQUEUE_COUNT_ELEMENT)); + } else if (name.equals(QueueConstants.MESSAGE_TEXT_ELEMENT)) { + message.messageContent = + Utility.readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_TEXT_ELEMENT); + } + + } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_MESSAGE_ELEMENT)) { + break; + } + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_MESSAGE_ELEMENT); + return message; + } + + /** + * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of + * ContainersElement. + * + * @param xmlr + * the XMLStreamReader object + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @return an ArrayList of CloudBlobContainer from the stream. + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + * @throws URISyntaxException + * @throws StorageException + */ + public static + ArrayList readMessages(final InputStream stream, final boolean shouldEncodeMessage) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(stream); + + // Start document + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); + + eventType = xmlr.next(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_MESSAGES_LIST_ELEMENT); + + final ArrayList messages = new ArrayList(); + + eventType = xmlr.next(); + while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() + && QueueConstants.QUEUE_MESSAGE_ELEMENT.equals(xmlr.getName().toString())) { + messages.add(QueueDeserializationHelper.readMessage(xmlr, shouldEncodeMessage)); + eventType = xmlr.next(); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_MESSAGES_LIST_ELEMENT); + return messages; + } + + /** + * Reserved for internal use. + * + * Populates the queue from an XMLStreamReader + * + * @param xmlr + * the XMLStreamReader to read from + * @throws XMLStreamException + * if there is an error parsing the stream + * @throws ParseException + * if there is an error in parsing a date + * @throws URISyntaxException + * if the uri is invalid + * @throws StorageException + */ + protected static CloudQueue readQueue(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + + xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_ELEMENT); + + String queueName = null; + URI queueUri = null; + HashMap queueMetadata = null; + + int eventType = xmlr.getEventType(); + + while (xmlr.hasNext()) { + eventType = xmlr.next(); + final String name = xmlr.getName().toString(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + if (name.equals(Constants.URL_ELEMENT)) { + queueUri = new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT)); + } else if (name.equals(Constants.NAME_ELEMENT)) { + queueName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); + } else if (name.equals(Constants.METADATA_ELEMENT)) { + // parse metadata + queueMetadata = DeserializationHelper.parseMetadateFromXML(xmlr); + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); + } + } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_ELEMENT)) { + break; + } + } + + final CloudQueue queue = new CloudQueue(queueUri, serviceClient); + queue.setMetadata(queueMetadata); + queue.setName(queueName); + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_ELEMENT); + return queue; + } + + /** + * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of + * ContainersElement. + * + * @param xmlr + * the XMLStreamReader object + * @param serviceClient + * the CloudBlobClient associated with the objects. + * @return an ArrayList of CloudBlobContainer from the stream. + * @throws XMLStreamException + * if there is a parsing exception + * @throws ParseException + * if a date value is not correctly encoded + * @throws URISyntaxException + * @throws StorageException + */ + public static ArrayList readQueues(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { + int eventType = xmlr.getEventType(); + xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); + + final ArrayList queues = new ArrayList(); + + eventType = xmlr.next(); + while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() + && QueueConstants.QUEUE_ELEMENT.equals(xmlr.getName().toString())) { + queues.add(readQueue(xmlr, serviceClient)); + eventType = xmlr.next(); + } + + xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); + return queues; + } + + /** + * Private Default Ctor. + */ + private QueueDeserializationHelper() { + // No op + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java new file mode 100644 index 0000000000000..8349e47c07eb0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java @@ -0,0 +1,38 @@ +package com.microsoft.windowsazure.services.queue.client; + +/** + * Specifies which details to include when listing the queues in this storage account. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum QueueListingDetails { + /** + * Specifies including all available details. + */ + ALL(1), + + /** + * Specifies including queue metadata. + */ + METADATA(1), + + /** + * Specifies including no additional details. + */ + NONE(0); + + /** + * Returns the value of this enum. + */ + public int value; + + /** + * Sets the value of this enum. + * + * @param val + * The value being assigned. + */ + QueueListingDetails(final int val) { + this.value = val; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java new file mode 100644 index 0000000000000..75d5bae540de5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java @@ -0,0 +1,18 @@ +package com.microsoft.windowsazure.services.queue.client; + +/** + * Reserved for internal use. Specifies queue message type. Used internally. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public enum QueueMessageType { + /** + * Indicates the message object stores the raw text string. + */ + RAW_STRING, + + /** + * Indicates the message object stores the Base64-Encoded representation of the raw data. + */ + BASE_64_ENCODED +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java new file mode 100644 index 0000000000000..1fd1c34efd8a0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -0,0 +1,391 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import com.microsoft.windowsazure.services.core.storage.Constants; +import com.microsoft.windowsazure.services.core.storage.OperationContext; +import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; +import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; + +/** + * RESERVED FOR INTERNAL USE. A class used to generate requests for queue objects. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class QueueRequest { + /** + * Adds user-defined metadata to the request as one or more name-value pairs. + * + * @param request + * The web request. + * @param metadata + * The user-defined metadata. + * */ + public static void addMetadata( + final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + BaseRequest.addMetadata(request, metadata, opContext); + } + + /** + * Constructs a request to clear messages. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection clearMessages(final URI uri, final int timeout, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, null, opContext); + + request.setRequestMethod("DELETE"); + + return request; + } + + /** + * Constructs a web request to create a new queue. Sign with 0 length. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection create(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.create(uri, timeout, null, opContext); + } + + /** + * Constructs a web request to delete the queue. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection delete(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.delete(uri, timeout, null, opContext); + } + + /** + * Constructs a request to delete a message. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection deleteMessage( + final URI uri, final int timeout, final String popReceipt, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("popreceipt", popReceipt); + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("DELETE"); + + return request; + } + + /** + * Constructs a web request to download user-defined metadata and ApproximateMessageCount for the queue. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * */ + public static HttpURLConnection downloadAttributes( + final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.getMetadata(uri, timeout, null, opContext); + } + + /** + * Constructs a web request to delete the queue. Sign with no length specified. + * + * @param uri + * The absolute URI to the container. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection exist(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.delete(uri, timeout, null, opContext); + } + + /** + * Parse message request body. + * + */ + public static byte[] generateMessageRequestBody(final String message) throws XMLStreamException, StorageException { + final StringWriter outWriter = new StringWriter(); + final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); + final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); + + // default is UTF8 + xmlw.writeStartDocument(); + xmlw.writeStartElement(QueueConstants.QUEUE_MESSAGE_ELEMENT); + + xmlw.writeStartElement(QueueConstants.MESSAGE_TEXT_ELEMENT); + xmlw.writeCharacters(message); + xmlw.writeEndElement(); + + // end QueueMessage_ELEMENT + xmlw.writeEndElement(); + + // end doc + xmlw.writeEndDocument(); + try { + return outWriter.toString().getBytes("UTF8"); + } catch (final UnsupportedEncodingException e) { + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + /** + * Constructs a request to return a listing of all queues in this storage account. Sign with no length specified. + * + * @param uri + * The absolute URI for the account. + * @param timeout + * The absolute URI for the account. + * @param listingContext + * A set of parameters for the listing operation. + * @param detailsIncluded + * Additional details to return with the listing. + * @param opContext + * a tracking object for the request + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection list( + final URI uri, final int timeout, final ListingContext listingContext, + final QueueListingDetails detailsIncluded, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("comp", "list"); + + if (listingContext != null) { + if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { + builder.add("prefix", listingContext.getPrefix()); + } + + if (!Utility.isNullOrEmpty(listingContext.getMarker())) { + builder.add("marker", listingContext.getMarker()); + } + + if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { + builder.add("maxresults", listingContext.getMaxResults().toString()); + } + } + + if (detailsIncluded == QueueListingDetails.ALL || detailsIncluded == QueueListingDetails.METADATA) { + builder.add("include", "metadata"); + } + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Constructs a request to peek messages. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection peekMessages( + final URI uri, final int timeout, final int numberOfMessages, final OperationContext opContext) + throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + builder.add("peekonly", "true"); + + if (numberOfMessages != 0) { + builder.add("numofmessages", Integer.toString(numberOfMessages)); + } + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Constructs a web request to create a new message. Sign with 0 length. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection putMessage( + final URI uri, final int timeout, final int visibilityTimeoutInSeconds, final int timeToLiveInSeconds, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + + if (visibilityTimeoutInSeconds != 0) { + builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); + } + + if (timeToLiveInSeconds != 0) { + builder.add("messagettl", Integer.toString(timeToLiveInSeconds)); + } + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setDoOutput(true); + request.setRequestMethod("POST"); + + return request; + } + + /** + * Constructs a request to retrieve messages. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection retrieveMessages( + final URI uri, final int timeout, final int numberOfMessages, final int visibilityTimeoutInSeconds, + final OperationContext opContext) throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + + if (numberOfMessages != 0) { + builder.add("numofmessages", Integer.toString(numberOfMessages)); + } + + if (visibilityTimeoutInSeconds != 0) { + builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); + } + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setRequestMethod("GET"); + + return request; + } + + /** + * Constructs a web request to set user-defined metadata for the queue, Sign with 0 Length. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * + * @return a HttpURLConnection configured for the operation. + * @throws StorageException + * */ + public static HttpURLConnection setMetadata(final URI uri, final int timeout, final OperationContext opContext) + throws IOException, URISyntaxException, StorageException { + return BaseRequest.setMetadata(uri, timeout, null, opContext); + } + + /** + * Constructs a request to update message. + * + * @param uri + * The absolute URI to the queue. + * @param timeout + * The server timeout interval. + * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * @throws StorageException + * @throws IllegalArgumentException + */ + public static HttpURLConnection updateMessage( + final URI uri, final int timeout, final String popReceipt, final int visibilityTimeoutInSeconds, + final OperationContext opContext) throws URISyntaxException, IOException, StorageException { + + final UriQueryBuilder builder = new UriQueryBuilder(); + + builder.add("popreceipt", popReceipt); + + builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); + + final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); + + request.setRequestProperty(Constants.HeaderConstants.STORAGE_VERSION_HEADER, "2011-08-18"); + + request.setDoOutput(true); + request.setRequestMethod("PUT"); + + return request; + } + + /** + * Private Default Ctor. + */ + private QueueRequest() { + // No op + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java new file mode 100644 index 0000000000000..9d9611b5b4f60 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java @@ -0,0 +1,37 @@ +/** + * + */ +package com.microsoft.windowsazure.services.queue.client; + +import com.microsoft.windowsazure.services.core.storage.RequestOptions; + +/** + * Represents a set of options that may be specified on a request. + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +public final class QueueRequestOptions extends RequestOptions { + /** + * Initializes a new instance of the QueueRequestOptions class. + */ + public QueueRequestOptions() { + // no op + } + + /** + * Initializes a new instance of the QueueRequestOptions class. + */ + public QueueRequestOptions(final QueueRequestOptions other) { + super(other); + } + + /** + * Populates the default timeout and retry policy from client if they are null. + * + * @param client + * the service client to populate from + */ + protected void applyDefaults(final CloudQueueClient client) { + super.applyBaseDefaults(client); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java new file mode 100644 index 0000000000000..d9630b48af929 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java @@ -0,0 +1,24 @@ +package com.microsoft.windowsazure.services.queue.client; + +import java.net.HttpURLConnection; + +import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; + +/** + * RESERVED FOR INTERNAL USE. A class for parsing various responses from the queue service + * + * Copyright (c)2011 Microsoft. All rights reserved. + */ +final class QueueResponse extends BaseResponse { + + /** + * Gets the approximate messages count from the request header. + * + * @param request + * The response from server. + * @return the lease id from the request header. + */ + public static long getApproximateMessageCount(final HttpURLConnection request) { + return Long.parseLong(request.getHeaderField("x-ms-approximate-messages-count")); + } +} From dfe901e0e04cb5af6f6f05022e695f10597332e9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 16:39:01 -0800 Subject: [PATCH 216/664] Make integration tests smarter about creating/deleting queues --- .../blob/BlobServiceIntegrationTest.java | 4 +- .../queue/QueueServiceIntegrationTest.java | 84 +++++++++++-------- 2 files changed, 52 insertions(+), 36 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 65a6cb0b0484c..98579bb4ed56d 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 @@ -111,8 +111,8 @@ public static void cleanup() throws Exception { } private static void createContainers(BlobContract service, String prefix, String[] list) throws Exception { - Set containers = listContainers(service, testContainersPrefix); - for (String item : testContainers) { + Set containers = listContainers(service, prefix); + for (String item : list) { if (!containers.contains(item)) { service.createContainer(item); } 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 2933ea52de1a4..447acf7bafe30 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 @@ -5,6 +5,8 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import java.util.TimeZone; import org.junit.AfterClass; @@ -12,7 +14,6 @@ import org.junit.Test; import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; import com.microsoft.windowsazure.services.queue.models.ListMessagesOptions; @@ -20,6 +21,7 @@ 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.ListQueuesResult.Queue; import com.microsoft.windowsazure.services.queue.models.PeekMessagesOptions; import com.microsoft.windowsazure.services.queue.models.PeekMessagesResult; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; @@ -72,14 +74,8 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); QueueContract service = config.create(QueueContract.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 - } - } + + createQueues(service, testQueuesPrefix, testQueues); } @AfterClass @@ -87,25 +83,37 @@ public static void cleanup() throws Exception { Configuration config = createConfiguration(); QueueContract service = config.create(QueueContract.class); - for (int i = 0; i < testQueues.length; i++) { - try { - service.deleteQueue(testQueues[i]); - } - catch (ServiceException e) { - // Ignore exception as the containers might not exists + deleteQueues(service, testQueuesPrefix, testQueues); + deleteQueues(service, createableQueuesPrefix, creatableQueues); + } + + private static void createQueues(QueueContract service, String prefix, String[] list) throws Exception { + Set containers = listQueues(service, prefix); + for (String item : list) { + if (!containers.contains(item)) { + service.createQueue(item); } } + } - for (int i = 0; i < creatableQueues.length; i++) { - try { - service.deleteQueue(creatableQueues[i]); - } - catch (ServiceException e) { - // Ignore exception as the containers might not exists + private static void deleteQueues(QueueContract service, String prefix, String[] list) throws Exception { + Set containers = listQueues(service, prefix); + for (String item : list) { + if (containers.contains(item)) { + service.deleteQueue(item); } } } + private static Set listQueues(QueueContract service, String prefix) throws Exception { + HashSet result = new HashSet(); + ListQueuesResult list = service.listQueues(new ListQueuesOptions().setPrefix(prefix)); + for (Queue item : list.getQueues()) { + result.add(item.getName()); + } + return result; + } + @Test public void getServicePropertiesWorks() throws Exception { // Arrange @@ -173,7 +181,8 @@ public void createQueueWithOptionsWorks() throws Exception { QueueContract service = config.create(QueueContract.class); // Act - service.createQueue(CREATABLE_QUEUE_2, new CreateQueueOptions().addMetadata("foo", "bar").addMetadata("test", "blah")); + 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); @@ -211,9 +220,10 @@ public void listQueuesWithOptionsWorks() throws Exception { QueueContract service = config.create(QueueContract.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)); + 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); @@ -334,8 +344,8 @@ public void listMessagesWithOptionsWorks() throws Exception { 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)); + ListMessagesResult result = service.listMessages(TEST_QUEUE_FOR_MESSAGES_3, new ListMessagesOptions() + .setNumberOfMessages(4).setVisibilityTimeoutInSeconds(20)); // Assert assertNotNull(result); @@ -380,7 +390,8 @@ public void peekMessagesWorks() throws Exception { assertNotNull(result); assertEquals(1, result.getQueueMessages().size()); - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(0); + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result + .getQueueMessages().get(0); assertNotNull(entry.getMessageId()); assertNotNull(entry.getMessageText()); @@ -408,13 +419,15 @@ public void peekMessagesWithOptionsWorks() throws Exception { 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)); + PeekMessagesResult result = service.peekMessages(TEST_QUEUE_FOR_MESSAGES_5, + new PeekMessagesOptions().setNumberOfMessages(4)); // Assert assertNotNull(result); assertEquals(4, result.getQueueMessages().size()); for (int i = 0; i < 4; i++) { - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result.getQueueMessages().get(i); + com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result + .getQueueMessages().get(i); assertNotNull(entry.getMessageId()); assertNotNull(entry.getMessageText()); @@ -461,8 +474,10 @@ public void deleteMessageWorks() throws Exception { 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)); + 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); @@ -483,8 +498,9 @@ public void updateMessageWorks() throws Exception { 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); + 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 From 323b7332f362e3697915bc2d1de9c42cfa420160 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 17:12:10 -0800 Subject: [PATCH 217/664] Throw on parsing invalid date value --- .../blob/implementation/BlobRestProxy.java | 20 +++++++++---------- .../implementation/RFC1123DateConverter.java | 11 ++++------ .../queue/implementation/QueueRestProxy.java | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index b037a16c8f273..4f6f4a182902e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -179,7 +179,7 @@ private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { // Properties BlobProperties properties = new BlobProperties(); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); @@ -323,7 +323,7 @@ private GetContainerPropertiesResult getContainerPropertiesImpl(String container GetContainerPropertiesResult properties = new GetContainerPropertiesResult(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setMetadata(getMetadataFromHeaders(response)); return properties; @@ -347,7 +347,7 @@ public GetContainerACLResult getContainerACL(String container, BlobServiceOption acl.setSignedIdentifiers(si.getSignedIdentifiers()); acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); GetContainerACLResult result = new GetContainerACLResult(); result.setValue(acl); @@ -493,7 +493,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetB GetBlobMetadataResult properties = new GetBlobMetadataResult(); properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); properties.setMetadata(getMetadataFromHeaders(response)); return properties; @@ -525,7 +525,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesResult result = new SetBlobPropertiesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); } @@ -552,7 +552,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash SetBlobMetadataResult result = new SetBlobMetadataResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -616,7 +616,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob 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"))); + blobSnapshot.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return blobSnapshot; } @@ -733,7 +733,7 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont CreateBlobPagesResult result = new CreateBlobPagesResult(); result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); @@ -759,7 +759,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } @@ -822,7 +822,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl result.setEtag(response.getHeaders().getFirst("ETag")); result.setContentType(response.getHeaders().getFirst("Content-Type")); result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parseNoThrow(response.getHeaders().getFirst("Last-Modified"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); return result; } 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 48545adfcb5bc..f8dc6fc29c31c 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 @@ -17,16 +17,13 @@ public String format(Date date) { return getFormat().format(date); } - public Date parse(String date) throws ParseException { - return getFormat().parse(date); - } - - public Date parseNoThrow(String date) { + public Date parse(String date) { try { - return parse(date); + return getFormat().parse(date); } catch (ParseException e) { - return null; + String msg = String.format("The value \"%s\" is not a valid RFC 1123 date.", date); + throw new IllegalArgumentException(msg, e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 168f6944cfbbc..76c004da179d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -249,7 +249,7 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String UpdateMessageResult result = new UpdateMessageResult(); result.setPopReceipt(response.getHeaders().getFirst("x-ms-popreceipt")); - result.setTimeNextVisible(dateMapper.parseNoThrow(response.getHeaders().getFirst("x-ms-time-next-visible"))); + result.setTimeNextVisible(dateMapper.parse(response.getHeaders().getFirst("x-ms-time-next-visible"))); return result; } From 49dc9f01c34583350bbf605c3b197089ac9683db Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 18 Nov 2011 17:43:25 -0800 Subject: [PATCH 218/664] Removing non-RuntimeException throws from Configuration. Fixes #3 ConfigurationException class catches all non-runtime issues, enabling users to avoid dealing with explicit exception throws statements when configuration is used --- .../windowsazure/common/Builder.java | 6 ++--- .../windowsazure/common/Configuration.java | 17 ++++--------- .../common/ConfigurationException.java | 22 ++++++++++++++++ .../windowsazure/common/DefaultBuilder.java | 25 ++++++++++++++----- .../services/serviceBus/Exports.java | 3 +-- .../builder/AlterClassWithProperties.java | 3 +-- 6 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java index 6047f230e230a..4fe8de2011e5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java @@ -4,14 +4,14 @@ public interface Builder { - public abstract T build(String profile, Class service, Map properties) throws Exception; + public abstract T build(String profile, Class service, Map properties); public interface Factory { - T create(String profile, Builder builder, Map properties) throws Exception; + T create(String profile, Builder builder, Map properties); } public interface Alteration { - T alter(T instance, Builder builder, Map properties) throws Exception; + T alter(T instance, Builder builder, Map properties); } public interface Registry { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java index b0770ccf96b8c..323a0c6f44d8a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java @@ -32,15 +32,7 @@ public Configuration(Builder builder) { } private void init() { - // DefaultClientConfig clientConfig = new DefaultClientConfig(); - // clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - try { - setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); - } - catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); } public static Configuration getInstance() { @@ -63,7 +55,8 @@ public static void setInstance(Configuration instance) { public static Configuration load() throws IOException { Configuration config = new Configuration(); - InputStream stream = Configuration.class.getClassLoader().getResourceAsStream("META-INF/com.microsoft.windowsazure.properties"); + InputStream stream = Configuration.class.getClassLoader().getResourceAsStream( + "META-INF/com.microsoft.windowsazure.properties"); if (stream != null) { Properties properties = new Properties(); properties.load(stream); @@ -75,11 +68,11 @@ public static Configuration load() throws IOException { return config; } - public T create(Class service) throws Exception { + public T create(Class service) { return builder.build("", service, properties); } - public T create(String profile, Class service) throws Exception { + public T create(String profile, Class service) { return builder.build(profile, service, properties); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java new file mode 100644 index 0000000000000..b21d4b5147ad6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java @@ -0,0 +1,22 @@ +package com.microsoft.windowsazure.common; + +public class ConfigurationException extends RuntimeException { + + private static final long serialVersionUID = -5570476914992165380L; + + public ConfigurationException() { + } + + public ConfigurationException(String message) { + super(message); + } + + public ConfigurationException(Throwable cause) { + super(cause); + } + + public ConfigurationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java index 74eef8182403f..5d65f4f8170a3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java @@ -2,6 +2,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; @@ -13,7 +14,6 @@ import javax.inject.Inject; import javax.inject.Named; - public class DefaultBuilder implements Builder, Builder.Registry { Map, Factory> factories; Map, List>> alterations; @@ -50,7 +50,8 @@ Constructor findInjectConstructor(Class implementation) { for (Constructor ctor : implementation.getConstructors()) { if (ctor.getAnnotation(Inject.class) != null) { if (withInject != null) { - throw new RuntimeException("Class must not have multple @Inject annotations: " + implementation.getName()); + throw new RuntimeException("Class must not have multple @Inject annotations: " + + implementation.getName()); } withInject = ctor; } @@ -63,7 +64,8 @@ Constructor findInjectConstructor(Class implementation) { return withInject; } if (count != 1) { - throw new RuntimeException("Class without @Inject annotation must have one constructor: " + implementation.getName()); + throw new RuntimeException("Class without @Inject annotation must have one constructor: " + + implementation.getName()); } return withoutInject; } @@ -75,7 +77,7 @@ public Builder.Registry add(Class service, final Class impl addFactory(service, new Builder.Factory() { @SuppressWarnings("unchecked") - public T create(String profile, Builder builder, Map properties) throws Exception { + public T create(String profile, Builder builder, Map properties) { Object[] initargs = new Object[parameterTypes.length]; for (int i = 0; i != parameterTypes.length; ++i) { @@ -106,7 +108,18 @@ public T create(String profile, Builder builder, Map properties) } } - return (T) ctor.newInstance(initargs); + try { + return (T) ctor.newInstance(initargs); + } + catch (InstantiationException e) { + throw new ConfigurationException(e); + } + catch (IllegalAccessException e) { + throw new ConfigurationException(e); + } + catch (InvocationTargetException e) { + throw new ConfigurationException(e); + } } }); return this; @@ -143,7 +156,7 @@ public Registry add(Factory factory) { } @SuppressWarnings("unchecked") - public T build(String profile, Class service, Map properties) throws Exception { + public T build(String profile, Class service, Map properties) { Factory factory = (Factory) factories.get(service); if (factory == null) { throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index 679a7d324b7a1..c94c8f68af704 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -23,8 +23,7 @@ public void register(Builder.Registry registry) { // alter jersey client config for serviceBus registry.alter(ClientConfig.class, new Builder.Alteration() { - public ClientConfig alter(ClientConfig instance, Builder builder, - Map properties) throws Exception { + public ClientConfig alter(ClientConfig instance, Builder builder, Map properties) { // enable this feature for unattributed json object serialization instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index 8c847bfbc5c31..5a85851c8308d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -6,8 +6,7 @@ public class AlterClassWithProperties implements Builder.Alteration { - public ClassWithProperties alter(ClassWithProperties instance, - Builder builder, Map properties) throws Exception { + public ClassWithProperties alter(ClassWithProperties instance, Builder builder, Map properties) { instance.setFoo(instance.getFoo() + " - changed"); return instance; } From c9cc992e5bb97c0a93bacde78abbdfafe37354c0 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 18 Nov 2011 17:50:19 -0800 Subject: [PATCH 219/664] Remove all credentials information from source code. Fixes #67 There are credentials in integration tests right now for example. --- .../META-INF/com.microsoft.windowsazure.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index 15229da1fdfdb..5cb494f2985eb 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -1,5 +1,5 @@ -serviceBus.uri=https://lodejard.servicebus.windows.net/ -serviceBus.wrap.uri=https://lodejard-sb.accesscontrol.windows.net/WRAPv0.9 -serviceBus.wrap.scope=http://lodejard.servicebus.windows.net/ -serviceBus.wrap.name=owner -serviceBus.wrap.password=Zo3QCZ5jLlJofibEiifZyz7B3x6a5Suv2YoS1JAWopA= +serviceBus.uri=https://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ +serviceBus.wrap.uri=https://%SERVICEBUS_NAMESPACE%-sb.accesscontrol.windows.net/WRAPv0.9 +serviceBus.wrap.scope=http://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ +serviceBus.wrap.name=%SERVICEBUS_SERVICEIDENTITY% +serviceBus.wrap.password=%SERVICEBUS_SHAREDSECRET% From 3b854cf864d6b22eaf3666a1c14a5a0a57d0132c Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 18 Nov 2011 17:54:01 -0800 Subject: [PATCH 220/664] subscription Messagecount should be a readonly property. fixes #61 Currently we have subscription.setMessageCount() which I feel doesn't make sense. Also from .net msdn doc this is a readonly property http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.subscriptiondescription.messagecount.aspx --- .../services/serviceBus/models/Subscription.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java index 5076f7f350b88..a168e233aa0ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java @@ -94,11 +94,6 @@ public Long getMessageCount() { return getModel().getMessageCount(); } - public Subscription setMessageCount(Long value) { - getModel().setMessageCount(value); - return this; - } - public Integer getMaxDeliveryCount() { return getModel().getMaxDeliveryCount(); } From d736a73f3ca794b38f6c0ed69c67710460070079 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 18:01:28 -0800 Subject: [PATCH 221/664] Replace magic string with boolean options Issue #43 --- .../blob/implementation/BlobRestProxy.java | 10 ++++- .../blob/models/ListBlobBlocksOptions.java | 21 ++++++--- .../blob/BlobServiceIntegrationTest.java | 45 +++++++++++++++++-- 3 files changed, 65 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 4f6f4a182902e..aa4ab0da8e605 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -810,7 +810,15 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - webResource = addOptionalQueryParam(webResource, "blocklisttype", options.getListType()); + if (options.isCommittedList() && options.isUncommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "all"); + } + else if (options.isCommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "committed"); + } + else if (options.isUncommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "uncommitted"); + } Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); 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 33eb6b47e54d2..4c26fd7d34cf4 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,10 +1,10 @@ package com.microsoft.windowsazure.services.blob.models; - public class ListBlobBlocksOptions extends BlobServiceOptions { private String leaseId; private String snapshot; - private String listType; // "committed", "uncommitted", "all" + private boolean committedList; + private boolean uncommittedList; public String getLeaseId() { return leaseId; @@ -24,12 +24,21 @@ public ListBlobBlocksOptions setSnapshot(String snapshot) { return this; } - public String getListType() { - return listType; + public boolean isCommittedList() { + return committedList; + } + + public ListBlobBlocksOptions setCommittedList(boolean committedList) { + this.committedList = committedList; + return this; + } + + public boolean isUncommittedList() { + return uncommittedList; } - public ListBlobBlocksOptions setListType(String listType) { - this.listType = listType; + public ListBlobBlocksOptions setUncommittedList(boolean uncommittedList) { + this.uncommittedList = uncommittedList; return this; } } 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 98579bb4ed56d..d4e20814401da 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 @@ -738,8 +738,8 @@ public void listBlobBlocksWorks() throws Exception { service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, - new ListBlobBlocksOptions().setListType("all")); + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() + .setCommittedList(true).setUncommittedList(true)); // Assert assertNotNull(result); @@ -758,6 +758,43 @@ public void listBlobBlocksWorks() throws Exception { assertEquals(195, result.getUncommittedBlocks().get(2).getBlockLength()); } + @Test + public void listBlobBlocksWithOptionsWorks() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract service = config.create(BlobContract.class); + + // Act + String container = TEST_CONTAINER_FOR_BLOBS; + String blob = "test14"; + service.createBlockBlob(container, blob, null); + service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(new byte[256])); + + BlockList blockList = new BlockList(); + blockList.addUncommittedEntry("123"); + service.commitBlobBlocks(container, blob, blockList); + + service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); + service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); + + ListBlobBlocksResult result1 = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() + .setCommittedList(true).setUncommittedList(true)); + ListBlobBlocksResult result2 = service.listBlobBlocks(container, blob, + new ListBlobBlocksOptions().setCommittedList(true)); + ListBlobBlocksResult result3 = service.listBlobBlocks(container, blob, + new ListBlobBlocksOptions().setUncommittedList(true)); + + // Assert + assertEquals(1, result1.getCommittedBlocks().size()); + assertEquals(2, result1.getUncommittedBlocks().size()); + + assertEquals(1, result2.getCommittedBlocks().size()); + assertEquals(0, result2.getUncommittedBlocks().size()); + + assertEquals(0, result3.getCommittedBlocks().size()); + assertEquals(2, result3.getUncommittedBlocks().size()); + } + @Test public void commitBlobBlocksWorks() throws Exception { // Arrange @@ -779,8 +816,8 @@ public void commitBlobBlocksWorks() throws Exception { blockList.addUncommittedEntry(blockId1).addLatestEntry(blockId3); service.commitBlobBlocks(container, blob, blockList); - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, - new ListBlobBlocksOptions().setListType("all")); + ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() + .setCommittedList(true).setUncommittedList(true)); // Assert assertNotNull(result); From ce7d2a458e264745f84e4d01014822c1bfdd3df9 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 18 Nov 2011 18:17:51 -0800 Subject: [PATCH 222/664] Replace magic string with enum Issue #42 --- .../blob/implementation/BlobRestProxy.java | 18 ++++++++++++++++-- .../services/blob/models/ContainerACL.java | 10 +++++++--- .../blob/BlobServiceIntegrationTest.java | 5 +++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index aa4ab0da8e605..bc522234f974a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -20,6 +20,7 @@ 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.ContainerACL.PublicAccessType; import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; @@ -345,7 +346,15 @@ public GetContainerACLResult getContainerACL(String container, BlobServiceOption ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); ContainerACL acl = new ContainerACL(); acl.setSignedIdentifiers(si.getSignedIdentifiers()); - acl.setPublicAccess(response.getHeaders().getFirst("x-ms-blob-public-access")); + if ("container".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { + acl.setPublicAccess(PublicAccessType.CONTAINER_AND_BLOBS); + } + else if ("blob".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { + acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); + } + else { + acl.setPublicAccess(PublicAccessType.NONE); + } acl.setEtag(response.getHeaders().getFirst("ETag")); acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); @@ -363,7 +372,12 @@ public void setContainerACL(String container, ContainerACL acl, BlobServiceOptio .queryParam("comp", "acl"); Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-public-access", acl.getPublicAccess()); + if (acl.getPublicAccess() == PublicAccessType.BLOBS_ONLY) { + builder = addOptionalHeader(builder, "x-ms-blob-public-access", "blob"); + } + else if (acl.getPublicAccess() == PublicAccessType.CONTAINER_AND_BLOBS) { + builder = addOptionalHeader(builder, "x-ms-blob-public-access", "container"); + } ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); si.setSignedIdentifiers(acl.getSignedIdentifiers()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java index 6f4dd818f30be..ce247cd084a8c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java @@ -13,7 +13,7 @@ public class ContainerACL { private String etag; private Date lastModified; - private String publicAccess; // "blob", "container" or null + private PublicAccessType publicAccess; private List signedIdentifiers = new ArrayList(); public String getEtag() { @@ -32,11 +32,11 @@ public void setLastModified(Date lastModified) { this.lastModified = lastModified; } - public String getPublicAccess() { + public PublicAccessType getPublicAccess() { return publicAccess; } - public void setPublicAccess(String publicAccess) { + public void setPublicAccess(PublicAccessType publicAccess) { this.publicAccess = publicAccess; } @@ -132,4 +132,8 @@ public void setPermission(String permission) { this.permission = permission; } } + + public static enum PublicAccessType { + NONE, BLOBS_ONLY, CONTAINER_AND_BLOBS, + } } 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 d4e20814401da..89288c84eb78f 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 @@ -32,6 +32,7 @@ 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.ContainerACL.PublicAccessType; import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.blob.models.CreateBlobPagesResult; import com.microsoft.windowsazure.services.blob.models.CreateBlobSnapshotOptions; @@ -285,7 +286,7 @@ public void setContainerACLWorks() throws Exception { service.createContainer(container); ContainerACL acl = new ContainerACL(); - acl.setPublicAccess("blob"); + acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); acl.addSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); service.setContainerACL(container, acl); @@ -297,7 +298,7 @@ public void setContainerACLWorks() throws Exception { assertNotNull(acl2.getEtag()); assertNotNull(acl2.getLastModified()); assertNotNull(acl2.getPublicAccess()); - assertEquals("blob", acl2.getPublicAccess()); + assertEquals(PublicAccessType.BLOBS_ONLY, acl2.getPublicAccess()); assertEquals(1, acl2.getSignedIdentifiers().size()); assertEquals("test", acl2.getSignedIdentifiers().get(0).getId()); assertEquals(expiryStartDate, acl2.getSignedIdentifiers().get(0).getAccessPolicy().getStart()); From c78e91048b9822b95c8109185b110c06112c33ea Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 18 Nov 2011 18:23:50 -0800 Subject: [PATCH 223/664] Add support for continuation uri (skip and top). fixes #4 Should be implemented as a state machine that iterates over blocks of entries and fetches more blocks at boundaries Should also have mechanisms to skip/take/order based on capabilites of the service in question --- .../serviceBus/ServiceBusContract.java | 14 +++ .../serviceBus/ServiceBusService.java | 68 +++++++----- .../ServiceBusExceptionProcessor.java | 103 +++++++++++++----- .../implementation/ServiceBusRestProxy.java | 55 ++++++++-- .../models/AbstractListOptions.java | 26 +++++ .../serviceBus/models/ListQueuesOptions.java | 5 + .../serviceBus/models/ListRulesOptions.java | 5 + .../models/ListSubscriptionsOptions.java | 5 + .../serviceBus/models/ListTopicsOptions.java | 5 + 9 files changed, 216 insertions(+), 70 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 8cfd244373ca1..5db7be986897a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -10,9 +10,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.Queue; @@ -52,6 +56,8 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St ListQueuesResult listQueues() throws ServiceException; + ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException; + CreateTopicResult createTopic(Topic topic) throws ServiceException; void deleteTopic(String topicName) throws ServiceException; @@ -60,6 +66,8 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St ListTopicsResult listTopics() throws ServiceException; + ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException; + CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException; void deleteSubscription(String topicName, String subscriptionName) throws ServiceException; @@ -68,6 +76,9 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; + ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) + throws ServiceException; + CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException; void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; @@ -75,4 +86,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException; + + ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) + throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 2dd3efd126508..f214391de0ac3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -13,9 +13,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.Queue; @@ -54,36 +58,31 @@ public ServiceBusContract withFilter(ServiceFilter filter) { return next.withFilter(filter); } - public void sendQueueMessage(String queueName, Message message) - throws ServiceException { + public void sendQueueMessage(String queueName, Message message) throws ServiceException { next.sendQueueMessage(queueName, message); } - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) - throws ServiceException { + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { return next.receiveQueueMessage(queueName); } - public ReceiveQueueMessageResult receiveQueueMessage(String queueName, - ReceiveMessageOptions options) throws ServiceException { + public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) + throws ServiceException { return next.receiveQueueMessage(queueName, options); } - public void sendTopicMessage(String topicName, Message message) - throws ServiceException { + public void sendTopicMessage(String topicName, Message message) throws ServiceException { next.sendTopicMessage(topicName, message); } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) + throws ServiceException { return next.receiveSubscriptionMessage(topicName, subscriptionName); } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - return next.receiveSubscriptionMessage(topicName, subscriptionName, - options); + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, + ReceiveMessageOptions options) throws ServiceException { + return next.receiveSubscriptionMessage(topicName, subscriptionName, options); } public void unlockMessage(Message message) throws ServiceException { @@ -126,17 +125,16 @@ public ListTopicsResult listTopics() throws ServiceException { return next.listTopics(); } - public CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException { + public CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) + throws ServiceException { return next.createSubscription(topicName, subscription); } - public void deleteSubscription(String topicName, String subscriptionName) - throws ServiceException { + public void deleteSubscription(String topicName, String subscriptionName) throws ServiceException { next.deleteSubscription(topicName, subscriptionName); } - public GetSubscriptionResult getSubscription(String topicName, String subscriptionName) - throws ServiceException { + public GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException { return next.getSubscription(topicName, subscriptionName); } @@ -144,23 +142,37 @@ public ListSubscriptionsResult listSubscriptions(String topicName) throws Servic return next.listSubscriptions(topicName); } - public CreateRuleResult createRule(String topicName, String subscriptionName, - Rule rule) throws ServiceException { + public CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException { return next.createRule(topicName, subscriptionName, rule); } - public void deleteRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { + public void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { next.deleteRule(topicName, subscriptionName, ruleName); } - public GetRuleResult getRule(String topicName, String subscriptionName, - String ruleName) throws ServiceException { + public GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { return next.getRule(topicName, subscriptionName, ruleName); } - public ListRulesResult listRules(String topicName, String subscriptionName) - throws ServiceException { + public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { return next.listRules(topicName, subscriptionName); } + + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + return next.listQueues(options); + } + + public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { + return next.listTopics(options); + } + + public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) + throws ServiceException { + return next.listSubscriptions(topicName, options); + } + + public ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) + throws ServiceException { + return next.listRules(topicName, subscriptionName, options); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index e0dcbd501eaad..befbc7817a183 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -16,9 +16,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.Queue; @@ -55,8 +59,7 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("serviceBus", e); } - public void sendQueueMessage(String path, Message message) - throws ServiceException { + public void sendQueueMessage(String path, Message message) throws ServiceException { try { next.sendQueueMessage(path, message); } @@ -68,8 +71,7 @@ public void sendQueueMessage(String path, Message message) } } - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) - throws ServiceException { + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { try { return next.receiveQueueMessage(queueName); } @@ -81,8 +83,8 @@ public ReceiveQueueMessageResult receiveQueueMessage(String queueName) } } - public ReceiveQueueMessageResult receiveQueueMessage(String queueName, - ReceiveMessageOptions options) throws ServiceException { + public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) + throws ServiceException { try { return next.receiveQueueMessage(queueName, options); } @@ -94,8 +96,7 @@ public ReceiveQueueMessageResult receiveQueueMessage(String queueName, } } - public void sendTopicMessage(String path, Message message) - throws ServiceException { + public void sendTopicMessage(String path, Message message) throws ServiceException { try { next.sendTopicMessage(path, message); } @@ -107,11 +108,10 @@ public void sendTopicMessage(String path, Message message) } } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) + throws ServiceException { try { - return next.receiveSubscriptionMessage(topicName, - subscriptionName); + return next.receiveSubscriptionMessage(topicName, subscriptionName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -121,12 +121,10 @@ public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicN } } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, + ReceiveMessageOptions options) throws ServiceException { try { - return next.receiveSubscriptionMessage(topicName, - subscriptionName, options); + return next.receiveSubscriptionMessage(topicName, subscriptionName, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -256,7 +254,8 @@ public ListTopicsResult listTopics() throws ServiceException { } } - public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) throws ServiceException { + public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) + throws ServiceException { try { return next.createSubscription(topicPath, subscription); } @@ -268,8 +267,7 @@ public CreateSubscriptionResult createSubscription(String topicPath, Subscriptio } } - public void deleteSubscription(String topicPath, String subscriptionName) - throws ServiceException { + public void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException { try { next.deleteSubscription(topicPath, subscriptionName); } @@ -281,8 +279,7 @@ public void deleteSubscription(String topicPath, String subscriptionName) } } - public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) - throws ServiceException { + public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException { try { return next.getSubscription(topicPath, subscriptionName); } @@ -306,8 +303,7 @@ public ListSubscriptionsResult listSubscriptions(String topicPath) throws Servic } } - public CreateRuleResult createRule(String topicPath, String subscriptionName, - Rule rule) throws ServiceException { + public CreateRuleResult createRule(String topicPath, String subscriptionName, Rule rule) throws ServiceException { try { return next.createRule(topicPath, subscriptionName, rule); } @@ -319,8 +315,7 @@ public CreateRuleResult createRule(String topicPath, String subscriptionName, } } - public void deleteRule(String topicPath, String subscriptionName, - String ruleName) throws ServiceException { + public void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { next.deleteRule(topicPath, subscriptionName, ruleName); } @@ -332,8 +327,7 @@ public void deleteRule(String topicPath, String subscriptionName, } } - public GetRuleResult getRule(String topicPath, String subscriptionName, - String ruleName) throws ServiceException { + public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { return next.getRule(topicPath, subscriptionName, ruleName); } @@ -345,8 +339,7 @@ public GetRuleResult getRule(String topicPath, String subscriptionName, } } - public ListRulesResult listRules(String topicPath, String subscriptionName) - throws ServiceException { + public ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException { try { return next.listRules(topicPath, subscriptionName); } @@ -358,4 +351,54 @@ public ListRulesResult listRules(String topicPath, String subscriptionName) } } + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + try { + return next.listQueues(options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { + try { + return next.listTopics(options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) + throws ServiceException { + try { + return next.listSubscriptions(topicName, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + public ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) + throws ServiceException { + try { + return next.listRules(topicName, subscriptionName, 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/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 135d3e9c8ddc1..e7b51c7d4c886 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -13,6 +13,7 @@ import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.models.AbstractListOptions; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -21,9 +22,13 @@ import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; +import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.Queue; @@ -225,9 +230,9 @@ public GetQueueResult getQueue(String queuePath) throws ServiceException { .get(Queue.class)); } - public ListQueuesResult listQueues() throws ServiceException { - Feed feed = getResource() - .path("$Resources/Queues") + public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { + Feed feed = listOptions(options, getResource() + .path("$Resources/Queues")) .get(Feed.class); ArrayList queues = new ArrayList(); for (Entry entry : feed.getEntries()) { @@ -238,6 +243,16 @@ public ListQueuesResult listQueues() throws ServiceException { return result; } + private WebResource listOptions(AbstractListOptions options, WebResource path) { + if (options.getTop() != null) { + path = path.queryParam("$top", options.getTop().toString()); + } + if (options.getSkip() != null) { + path = path.queryParam("$skip", options.getSkip().toString()); + } + return path; + } + public CreateTopicResult createTopic(Topic entry) throws ServiceException { return new CreateTopicResult(getResource() .path(entry.getName()) @@ -257,9 +272,9 @@ public GetTopicResult getTopic(String TopicPath) throws ServiceException { .get(Topic.class)); } - public ListTopicsResult listTopics() throws ServiceException { - Feed feed = getResource() - .path("$Resources/Topics") + public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { + Feed feed = listOptions(options, getResource() + .path("$Resources/Topics")) .get(Feed.class); ArrayList Topics = new ArrayList(); for (Entry entry : feed.getEntries()) { @@ -295,10 +310,10 @@ public GetSubscriptionResult getSubscription(String topicPath, String subscripti .get(Subscription.class)); } - public ListSubscriptionsResult listSubscriptions(String topicPath) { - Feed feed = getResource() + public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) { + Feed feed = listOptions(options, getResource() .path(topicPath) - .path("subscriptions") + .path("subscriptions")) .get(Feed.class); ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { @@ -343,12 +358,12 @@ public GetRuleResult getRule(String topicPath, String subscriptionName, .get(Rule.class)); } - public ListRulesResult listRules(String topicPath, String subscriptionName) { - Feed feed = getResource() + public ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) { + Feed feed = listOptions(options, getResource() .path(topicPath) .path("subscriptions") .path(subscriptionName) - .path("rules") + .path("rules")) .get(Feed.class); ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { @@ -359,4 +374,20 @@ public ListRulesResult listRules(String topicPath, String subscriptionName) { return result; } + public ListQueuesResult listQueues() throws ServiceException { + return listQueues(ListQueuesOptions.DEFAULT); + } + + public ListTopicsResult listTopics() throws ServiceException { + return listTopics(ListTopicsOptions.DEFAULT); + } + + public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { + return listSubscriptions(topicName, ListSubscriptionsOptions.DEFAULT); + } + + public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { + return listRules(topicName, subscriptionName, ListRulesOptions.DEFAULT); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java new file mode 100644 index 0000000000000..285d60bcc89c9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java @@ -0,0 +1,26 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public abstract class AbstractListOptions { + Integer skip; + Integer top; + + public Integer getSkip() { + return skip; + } + + @SuppressWarnings("unchecked") + public T setSkip(Integer skip) { + this.skip = skip; + return (T) this; + } + + public Integer getTop() { + return top; + } + + @SuppressWarnings("unchecked") + public T setTop(Integer top) { + this.top = top; + return (T) this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java new file mode 100644 index 0000000000000..ae44c1e3e74ce --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class ListQueuesOptions extends AbstractListOptions { + public static final ListQueuesOptions DEFAULT = new ListQueuesOptions(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java new file mode 100644 index 0000000000000..1720a3051145b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class ListRulesOptions extends AbstractListOptions { + public static final ListRulesOptions DEFAULT = new ListRulesOptions(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java new file mode 100644 index 0000000000000..57532efcb586e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class ListSubscriptionsOptions extends AbstractListOptions { + public static final ListSubscriptionsOptions DEFAULT = new ListSubscriptionsOptions(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java new file mode 100644 index 0000000000000..3a65872bd67ef --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +public class ListTopicsOptions extends AbstractListOptions { + public static final ListTopicsOptions DEFAULT = new ListTopicsOptions(); +} From 3632576ed3ed8f2df1abad9af95ed300469e99c6 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Wed, 16 Nov 2011 10:47:03 -0800 Subject: [PATCH 224/664] Added Javadoc comments. --- .../serviceBus/models/CreateQueueResult.java | 3 +- .../serviceBus/models/CreateRuleResult.java | 26 ++++++----- .../models/CreateSubscriptionResult.java | 4 +- .../serviceBus/models/CreateTopicResult.java | 27 ++++++------ .../serviceBus/models/GetQueueResult.java | 41 ++++++++++++----- .../serviceBus/models/GetRuleResult.java | 40 ++++++++++++----- .../models/GetSubscriptionResult.java | 44 ++++++++++++++----- .../serviceBus/models/GetTopicResult.java | 41 ++++++++++++----- .../serviceBus/models/ListQueuesResult.java | 31 +++++++++---- .../serviceBus/models/ListRulesResult.java | 16 +++++++ .../models/ListSubscriptionsResult.java | 17 ++++++- .../serviceBus/models/ListTopicsResult.java | 19 +++++++- 12 files changed, 228 insertions(+), 81 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index 6c45047576d10..31335b14fe4cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -20,7 +20,8 @@ public CreateQueueResult(Queue value) { /** * Specfies the value of the result. * - * @return A {@link Queue} object assigned as the value of the result. + * @param value + * A {@link Queue} object assigned as the value of the result. */ public void setValue(Queue value) { this.value = value; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index 85dca821d19df..e9de6d7a26fce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -1,10 +1,11 @@ package com.microsoft.windowsazure.services.serviceBus.models; + /** * Represents the result of a createRule operation. */ public class CreateRuleResult { - private Rule value; + private Rule value; /** * Creates an instance of the CreateRuleResult class. @@ -12,26 +13,27 @@ public class CreateRuleResult { * @param value * A {@link Rule} object assigned as the value of the result. */ - public CreateRuleResult(Rule value) { - this.setValue(value); - } + public CreateRuleResult(Rule value) { + this.setValue(value); + } /** * Specfies the value of the result. * - * @return A {@link Rule} object assigned as the value of the result. + * @param value + * A {@link Rule} object assigned as the value of the result. */ - public void setValue(Rule value) { - this.value = value; - } - + public void setValue(Rule value) { + this.value = value; + } + /** * Returns the value of the result. * * @return A {@link Rule} object that represents the value of the result. */ - public Rule getValue() { - return value; - } + public Rule getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index afa513c413016..668d696d80657 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -20,7 +20,9 @@ public CreateSubscriptionResult(Subscription value) { /** * Specfies the value of the result. * - * @return A {@link Subscription} object assigned as the value of the result. + * @param value + * A {@link Subscription} object assigned as the value of the + * result. */ public void setValue(Subscription value) { this.value = value; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 3e2e8c9fea171..ce8b09d04c3ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -5,34 +5,35 @@ */ public class CreateTopicResult { - private Topic value; + private Topic value; /** * Creates an instance of the CreateTopicResult class. * * @param value * A {@link Topic} object assigned as the value of the result. - */ - public CreateTopicResult(Topic value) { - this.setValue(value); - } + */ + public CreateTopicResult(Topic value) { + this.setValue(value); + } /** * Specfies the value of the result. * - * @return A {@link Topic} object assigned as the value of the result. - */ - public void setValue(Topic value) { - this.value = value; - } + * @param value + * A {@link Topic} object assigned as the value of the result. + */ + public void setValue(Topic value) { + this.value = value; + } /** * Returns the value of the result. * * @return A {@link Topic} object that represents the value of the result. */ - public Topic getValue() { - return value; - } + public Topic getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index 005b5a5a8c1f0..26b50e60454aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -1,20 +1,39 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a getQueue operation. + */ public class GetQueueResult { - private Queue value; + private Queue value; - public GetQueueResult(Queue value) { - this.setValue(value); - } + /** + * Creates an instance of the GetQueueResult class. + * + * @param value + * A {@link Queue} object assigned as the value of the result. + */ + public GetQueueResult(Queue value) { + this.setValue(value); + } - public void setValue(Queue value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link Queue} object assigned as the value of the result. + */ + public void setValue(Queue value) { + this.value = value; + } - public Queue getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link Queue} object that represents the value of the result. + */ + public Queue getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java index d4d49839298a0..b366687050154 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -1,19 +1,39 @@ package com.microsoft.windowsazure.services.serviceBus.models; +/** + * Represents the result of a getRule operation. + */ public class GetRuleResult { - private Rule value; + private Rule value; - public GetRuleResult(Rule value) { - this.setValue(value); - } + /** + * Creates an instance of the GetRuleResult class. + * + * @param value + * A {@link Rule} object assigned as the value of the result. + */ + public GetRuleResult(Rule value) { + this.setValue(value); + } - public void setValue(Rule value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link Rule} object assigned as the value of the result. + */ + public void setValue(Rule value) { + this.value = value; + } - public Rule getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link Rule} object that represents the value of the result. + */ + public Rule getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index 4e28a6137f1ca..adb72db33bfaa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -1,20 +1,42 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a getSubscription operation. + */ public class GetSubscriptionResult { - private Subscription value; + private Subscription value; - public GetSubscriptionResult(Subscription value) { - this.setValue(value); - } + /** + * Creates an instance of the GetSubscriptionResult class. + * + * @param value + * A {@link Subscription} object assigned as the value of the + * result. + */ + public GetSubscriptionResult(Subscription value) { + this.setValue(value); + } - public void setValue(Subscription value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link Subscription} object assigned as the value of the + * result. + */ + public void setValue(Subscription value) { + this.value = value; + } - public Subscription getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link Subscription} object that represents the value of the + * result. + */ + public Subscription getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index 5c6a0af54619c..c2d8a9198e192 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -1,20 +1,39 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a getTopic operation. + */ public class GetTopicResult { - private Topic value; + private Topic value; - public GetTopicResult(Topic value) { - this.setValue(value); - } + /** + * Creates an instance of the GetTopicResult class. + * + * @param value + * A {@link Topic} object assigned as the value of the result. + */ + public GetTopicResult(Topic value) { + this.setValue(value); + } - public void setValue(Topic value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link Topic} object assigned as the value of the result. + */ + public void setValue(Topic value) { + this.value = value; + } - public Topic getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link Topic} object that represents the value of the result. + */ + public Topic getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index cfe755389d9ad..89e28d150db9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -2,16 +2,31 @@ import java.util.List; - +/** + * Represents the result of a listQueues operation. + */ public class ListQueuesResult { - private List items; + private List items; - public List getItems() { - return items; - } + /** + * Returns the items in the result list. + * + * @return A List of {@link Queue} objects that represent the + * items in the result list. + */ + public List getItems() { + return items; + } - public void setItems(List items) { - this.items = items; - } + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link Queue} + * objects assigned as the value of the result. + */ + public void setItems(List items) { + this.items = items; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java index 8917fc0b04111..b35f96252c23a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -2,14 +2,30 @@ import java.util.List; +/** + * Represents the result of a listRules operation. + */ public class ListRulesResult { private List items; + /** + * Returns the items in the result list. + * + * @return A List of {@link Rule} objects that represent the + * items in the result list. + */ public List getItems() { return items; } + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link Rule} + * objects assigned as the value of the result. + */ public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 4624ba154806e..9bfcd91abec14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -2,15 +2,30 @@ import java.util.List; - +/** + * Represents the result of a listSubscriptions operation. + */ public class ListSubscriptionsResult { private List items; + /** + * Returns the items in the result list. + * + * @return A List of {@link Subscription} objects that represent the + * items in the result list. + */ public List getItems() { return items; } + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link Subscription} + * objects assigned as the value of the result. + */ public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index 5d3047674426e..4a1fe1a04fea6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -2,15 +2,30 @@ import java.util.List; - +/** + * Represents the result of a listTopics operation. + */ public class ListTopicsResult { private List items; + /** + * Returns the items in the result list. + * + * @return A List of {@link Topic} objects that represent the + * items in the result list. + */ public List getItems() { return items; } - + + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link Topic} + * objects assigned as the value of the result. + */ public void setItems(List items) { this.items = items; } From a7a187d33335c271b1074afb625295305cdc17f3 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 11:01:49 -0800 Subject: [PATCH 225/664] Added Javadoc content. Conflicts: microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java --- .../models/ReceiveMessageOptions.java | 56 +++++- .../serviceBus/models/ReceiveMode.java | 10 + .../models/ReceiveQueueMessageResult.java | 21 +- .../ReceiveSubscriptionMessageResult.java | 20 ++ .../services/serviceBus/models/Rule.java | 183 +++++++++--------- 5 files changed, 196 insertions(+), 94 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java index f9bda855f4ea9..96be7360a7c6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java @@ -1,43 +1,97 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * + * Specifies options when receiving messages. + * + */ public class ReceiveMessageOptions { Integer timeout; private ReceiveMode receiveMode = ReceiveMode.RECEIVE_AND_DELETE; + /** + * Returns a new instance of the ReceiveMessageOptions class. + */ public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); + /** + * Returns the timeout when receiving messages. + * + * @return The timeout, in seconds. + */ public Integer getTimeout() { return timeout; } + /** + * Sets the timeout when receiving messages. + * + * @param timeout + * The timeout, in seconds. + * + * @return A ReceiveMessageOptions object that represents the updated receive message options. + */ public ReceiveMessageOptions setTimeout(Integer timeout) { this.timeout = timeout; return this; } + /** + * Returns the receive mode when receiving messages. + * + * @return A {@link ReceiveMode} value that represents the receive mode. + */ public ReceiveMode getReceiveMode() { return receiveMode; } + /** + * Sets the receive mode when receiving messages. + * + * @param receiveMode + * A {@link ReceiveMode} value that specifies the receive mode. + * + * @return A ReceiveMessageOptions object that represents the updated receive message options. + */ public ReceiveMessageOptions setReceiveMode(ReceiveMode receiveMode) { this.receiveMode = receiveMode; return this; } + /** + * Indicates whether the receive mode is receive and delete. + * + * @return true if the receive mode is {@link ReceiveMode#RECEIVE_AND_DELETE}; otherwise, + * false. + */ public boolean isReceiveAndDelete() { return receiveMode == ReceiveMode.RECEIVE_AND_DELETE; } + /** + * Sets the receive mode to receive and delete. + * + * @return A ReceiveMessageOptions object that represents the updated receive message options. + */ public ReceiveMessageOptions setReceiveAndDelete() { this.receiveMode = ReceiveMode.RECEIVE_AND_DELETE; return this; } + /** + * Indicates whether the receive mode is peek/lock. + * + * @return true if the receive mode is {@link ReceiveMode#PEEK_LOCK}; otherwise, false. + */ public boolean isPeekLock() { return receiveMode == ReceiveMode.PEEK_LOCK; } + /** + * Sets the receive mode to peek/lock. + * + * @return A ReceiveMessageOptions object that represents the updated receive message options. + */ public ReceiveMessageOptions setPeekLock() { this.receiveMode = ReceiveMode.PEEK_LOCK; return this; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java index 195c2fa8ad7c6..7dfd2cffe1f16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java @@ -1,6 +1,16 @@ package com.microsoft.windowsazure.services.serviceBus.models; +/** + * Specifies the mode when a message is received. + */ public enum ReceiveMode { + /** + * The message is retrieved and locked for processing, until either the receiver deletes the message, unlocks it, or + * the lock duration expires. + */ PEEK_LOCK, + /** + * The message is retrieved and deleted. + */ RECEIVE_AND_DELETE, } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java index 5e6e31989fbc7..1357f740ab2ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -1,18 +1,37 @@ package com.microsoft.windowsazure.services.serviceBus.models; - +/** + * Represents the result of a receiveQueueMessage operation. + */ public class ReceiveQueueMessageResult { private Message value; + /** + * Creates an instance of the ReceiveQueueMessageResult class. + * + * @param value + * A {@link Message} object assigned as the value of the result. + */ public ReceiveQueueMessageResult(Message value) { this.setValue(value); } + /** + * Specifies the value of the result. + * + * @param value + * A {@link Message} object assigned as the value of the result. + */ public void setValue(Message value) { this.value = value; } + /** + * Returns the value of the result. + * + * @return A {@link Message} object that represents the value of the result. + */ public Message getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java index 3666750e431eb..dcef5ecdc3da6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -1,17 +1,37 @@ package com.microsoft.windowsazure.services.serviceBus.models; +/** + * Represents the result of a receiveSubscriptionMessage operation. + */ public class ReceiveSubscriptionMessageResult { private Message value; + /** + * Creates an instance of the ReceiveSubscriptionMessageResult class. + * + * @param value + * A {@link Message} object assigned as the value of the result. + */ public ReceiveSubscriptionMessageResult(Message value) { this.setValue(value); } + /** + * Specifies the value of the result. + * + * @param value + * A {@link Message} object assigned as the value of the result. + */ public void setValue(Message value) { this.value = value; } + /** + * Returns the value of the result. + * + * @return A {@link Message} object that represents the value of the result. + */ public Message getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java index 8d7c338972777..8d0bcca44b820 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java @@ -14,104 +14,103 @@ */ public class Rule extends EntryModel { - /** - * Creates an instance of the Rule class. - */ - public Rule() { - super(new Entry(), new RuleDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setRuleDescription(getModel()); - } + /** + * Creates an instance of the Rule class. + */ + public Rule() { + super(new Entry(), new RuleDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setRuleDescription(getModel()); + } - /** - * Creates an instance of the Rule class using the specified - * entry. - * - * @param entry - * An {@link Entry} object. - * - */ - public Rule(Entry entry) { - super(entry, entry.getContent().getRuleDescription()); - } + /** + * Creates an instance of the Rule class using the specified entry. + * + * @param entry + * An Entry object. + * + */ + public Rule(Entry entry) { + super(entry, entry.getContent().getRuleDescription()); + } - /** - * Creates an instance of the Rule class using the specified - * name. - * - * @param name - * A String object that represents the name of the rule. - * - */ public Rule(String name) { - this(); - setName(name); - } + /** + * Creates an instance of the Rule class using the specified name. + * + * @param name + * A String object that represents the name of the rule. + * + */ + public Rule(String name) { + this(); + setName(name); + } - /** - * Returns the name of the rule. - * - * @return A String object that represents the name of the rule. - */ - public String getName() { - return getEntry().getTitle(); - } + /** + * Returns the name of the rule. + * + * @return A String object that represents the name of the rule. + */ + public String getName() { + return getEntry().getTitle(); + } - /** - * Sets the name of the rule. - * - * @param value - * A String object that represents the name of the rule. - * - * @return A Rule object that represents the updated rule. - */ - public Rule setName(String value) { - getEntry().setTitle(value); - return this; - } + /** + * Sets the name of the rule. + * + * @param value + * A String object that represents the name of the rule. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setName(String value) { + getEntry().setTitle(value); + return this; + } - /** - * Returns the filter used for the rule. - * - * @return A Filter object that represents the filter of the rule. - */ - public Filter getFilter() { - return getModel().getFilter(); - } + /** + * Returns the filter used for the rule. + * + * @return A Filter object that represents the filter of the rule. + */ + public Filter getFilter() { + return getModel().getFilter(); + } - /** - * Specifies the filter used for the rule. - * - * @param value - * A Filter object that represents the filter of the rule. - * - * @return A Rule object that represents the updated rule. - */ - public Rule setFilter(Filter value) { - getModel().setFilter(value); - return this; - } - - /** - * Returns the rule action used for the rule. - * - * @return A RuleAction object that represents the rule action. - */ - public RuleAction getAction() { - return getModel().getAction(); - } + /** + * Specifies the filter used for the rule. + * + * @param value + * A Filter object that represents the filter of the rule. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setFilter(Filter value) { + getModel().setFilter(value); + return this; + } - /** - * Specifies the rule action for the rule. - * - * @param value - * A RuleAction object that represents the rule action. - * - * @return A Rule object that represents the updated rule. - */ - public Rule setAction(RuleAction value) { - getModel().setAction(value); - return this; - } + /** + * Returns the rule action used for the rule. + * + * @return A RuleAction object that represents the rule action. + */ + public RuleAction getAction() { + return getModel().getAction(); + } + + /** + * Specifies the rule action for the rule. + * + * @param value + * A RuleAction object that represents the rule action. + * + * @return A Rule object that represents the updated rule. + */ + public Rule setAction(RuleAction value) { + getModel().setAction(value); + return this; + } } From a112b6f2df74bc26391d9017814e479c4694185b Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 11:32:03 -0800 Subject: [PATCH 226/664] Added Javadoc comments. Conflicts: microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java --- .../services/serviceBus/models/Message.java | 96 ++-- .../services/serviceBus/models/Queue.java | 503 +++++++++--------- .../serviceBus/models/Subscription.java | 142 +++++ .../services/serviceBus/models/Topic.java | 102 ++++ 4 files changed, 520 insertions(+), 323 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java index a219f02487738..1c0f65d698e80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Message.java @@ -23,12 +23,10 @@ public Message() { } /** - * Creates an instance of the Message class using the - * specified InputStream. + * Creates an instance of the Message class using the specified InputStream. * * @param body - * An InputStream object that represents the body of - * the message. + * An InputStream object that represents the body of the message. */ public Message(InputStream body) { this.properties = new BrokerProperties(); @@ -36,8 +34,7 @@ public Message(InputStream body) { } /** - * Creates an instance of the Message class using the specified - * byte array. + * Creates an instance of the Message class using the specified byte array. * * @param body * A byte array that represents the body of the message. @@ -52,13 +49,11 @@ public Message(byte[] body) { * string. * * @param body - * A String object that represents the body of the - * message. + * A String object that represents the body of the message. */ public Message(String body) { this.properties = new BrokerProperties(); - this.body = (body == null) ? null : new ByteArrayInputStream( - body.getBytes()); + this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); } Message(BrokerProperties properties, InputStream body) { @@ -69,8 +64,7 @@ public Message(String body) { /** * Returns the properties of the message. * - * @return A {@link BrokerProperties} object that represents the properties - * of the message. + * @return A {@link BrokerProperties} object that represents the properties of the message. */ public BrokerProperties getProperties() { return properties; @@ -80,8 +74,7 @@ public BrokerProperties getProperties() { * Sets the properties of the message. * * @param properties - * A {@link BrokerProperties} object that represents the - * properties of the message. + * A {@link BrokerProperties} object that represents the properties of the message. */ public Message setProperties(BrokerProperties properties) { this.properties = properties; @@ -91,8 +84,7 @@ public Message setProperties(BrokerProperties properties) { /** * Returns the body of the message. * - * @return An InputStream object that represents the body of - * the message. + * @return An InputStream object that represents the body of the message. */ public InputStream getBody() { return body; @@ -102,11 +94,9 @@ public InputStream getBody() { * Specifies the body of the message. * * @param body - * An InputStream object that represents the body of - * the message. + * An InputStream object that represents the body of the message. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setBody(InputStream body) { this.body = body; @@ -128,8 +118,7 @@ public String getContentType() { * @param contentType * A String object that represents the content type. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setContentType(String contentType) { this.contentType = contentType; @@ -139,8 +128,7 @@ public Message setContentType(String contentType) { /** * Returns the date/time of the message. * - * @return A Date object that represents the date/time of the - * object. + * @return A Date object that represents the date/time of the object. */ public Date getDate() { return date; @@ -150,11 +138,9 @@ public Date getDate() { * Sets the date/time of the message. * * @param date - * A Date object that represents the date/time of - * the object. + * A Date object that represents the date/time of the object. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setDate(Date date) { this.date = date; @@ -185,8 +171,7 @@ public String getMessageId() { * @param messageId * A String object that represents the message ID. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setMessageId(String messageId) { properties.setMessageId(messageId); @@ -218,8 +203,7 @@ public Double getTimeToLive() { * @param timeToLive * The time, in seconds, for the message to live. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setTimeToLive(Double timeToLive) { properties.setTimeToLive(timeToLive); @@ -238,8 +222,7 @@ public String getLockToken() { /** * Returns the locked-until date/time. * - * @return A Date object that represents the locked-until - * date/time, in UTC format. + * @return A Date object that represents the locked-until date/time, in UTC format. */ public Date getLockedUntilUtc() { return properties.getLockedUntilUtc(); @@ -259,11 +242,9 @@ public String getCorrelationId() { * Sets the correlation ID. * * @param correlationId - * A String object that represents the correlation - * ID. + * A String object that represents the correlation ID. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setCorrelationId(String correlationId) { properties.setCorrelationId(correlationId); @@ -286,8 +267,7 @@ public String getSessionId() { * @param sessionId * A String object that represents the session ID. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setSessionId(String sessionId) { properties.setSessionId(sessionId); @@ -309,8 +289,7 @@ public String getLabel() { * @param label * A String object that represents the label. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setLabel(String label) { properties.setLabel(label); @@ -320,8 +299,7 @@ public Message setLabel(String label) { /** * Returns the Reply-To recipient of the message. * - * @return A String object that represents the Reply-To - * recipient. + * @return A String object that represents the Reply-To recipient. */ public String getReplyTo() { return properties.getReplyTo(); @@ -331,11 +309,9 @@ public String getReplyTo() { * Sets the Reply-To recipient for the message. * * @param replyTo - * A String object that represents the Reply-To - * recipient. + * A String object that represents the Reply-To recipient. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setReplyTo(String replyTo) { properties.setReplyTo(replyTo); @@ -357,8 +333,7 @@ public String getTo() { * @param A * String object that represents the To recipient. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setTo(String to) { properties.setTo(to); @@ -368,8 +343,7 @@ public Message setTo(String to) { /** * Returns the scheduled enqueue date/time. * - * @return A Date object that represents the date/time of the - * message in UTC format. + * @return A Date object that represents the date/time of the message in UTC format. */ public Date getScheduledEnqueueTimeUtc() { return properties.getScheduledEnqueueTimeUtc(); @@ -379,11 +353,9 @@ public Date getScheduledEnqueueTimeUtc() { * Sets the scheduled enqueue time. * * @param scheduledEnqueueTimeUtc - * A Date object that represents the date/time of - * the message in UTC format. + * A Date object that represents the date/time of the message in UTC format. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); @@ -393,8 +365,7 @@ public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { /** * Returns the session ID of the Reply To recipient. * - * @return A String object that represents the session ID of - * the Reply To recipient. + * @return A String object that represents the session ID of the Reply To recipient. */ public String getReplyToSessionId() { return properties.getReplyToSessionId(); @@ -404,11 +375,9 @@ public String getReplyToSessionId() { * Sets the session ID of the Reply To recipient. * * @param replyToSessionId - * A String object that represents the session ID - * of the Reply To recipient. + * A String object that represents the session ID of the Reply To recipient. * - * @return A Message object that reperesents the updated - * message. + * @return A Message object that represents the updated message. */ public Message setReplyToSessionId(String replyToSessionId) { properties.setReplyToSessionId(replyToSessionId); @@ -418,8 +387,7 @@ public Message setReplyToSessionId(String replyToSessionId) { /** * Returns the message location. * - * @return A String object that represents the message - * location. + * @return A String object that represents the message location. */ public String getMessageLocation() { return properties.getMessageLocation(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java index 630c4e9703da4..65db41f838df2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java @@ -13,292 +13,277 @@ */ public class Queue extends EntryModel { - /** - * Creates an instance of the Queue class. - */ - public Queue() { - super(new Entry(), new QueueDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setQueueDescription(getModel()); - } + /** + * Creates an instance of the Queue class. + */ + public Queue() { + super(new Entry(), new QueueDescription()); + getEntry().setContent(new Content()); + getEntry().getContent().setType(MediaType.APPLICATION_XML); + getEntry().getContent().setQueueDescription(getModel()); + } - /** - * Creates an instance of the Queue class using the specified - * entry. - * - * @param entry - * An Entry object. - */ - public Queue(Entry entry) { - super(entry, entry.getContent().getQueueDescription()); - } + /** + * Creates an instance of the Queue class using the specified entry. + * + * @param entry + * An Entry object. + */ + public Queue(Entry entry) { + super(entry, entry.getContent().getQueueDescription()); + } - /** - * Creates an instance of the Queue class using the specified - * name. - * - * @param name - * String that represents the name of the queue. - */ - public Queue(String name) { - this(); - setName(name); - } + /** + * Creates an instance of the Queue class using the specified name. + * + * @param name + * A String object that represents the name of the queue. + */ + public Queue(String name) { + this(); + setName(name); + } - /** - * Returns the name of the queue. - * - * @return String that represents the name of the queue. - */ - public String getName() { - return getEntry().getTitle(); - } + /** + * Returns the name of the queue. + * + * @return A String object that represents the name of the queue. + */ + public String getName() { + return getEntry().getTitle(); + } - /** - * Sets the name of the queue. - * - * @param value - * A String that represents the name of the queue. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setName(String value) { - getEntry().setTitle(value); - return this; - } + /** + * Sets the name of the queue. + * + * @param value + * A String that represents the name of the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setName(String value) { + getEntry().setTitle(value); + return this; + } - /** - * Returns the duration of the lock. - * - * @return A Duration object that represents the duration of - * the lock. - */ - public Duration getLockDuration() { - return getModel().getLockDuration(); - } + /** + * Returns the duration of the lock. + * + * @return A Duration object that represents the duration of the lock. + */ + public Duration getLockDuration() { + return getModel().getLockDuration(); + } - /** - * Sets the duration of the lock. - * - * @param value - * The duration, in seconds, of the lock. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setLockDuration(Duration value) { - getModel().setLockDuration(value); - return this; - } + /** + * Sets the duration of the lock. + * + * @param value + * The duration, in seconds, of the lock. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setLockDuration(Duration value) { + getModel().setLockDuration(value); + return this; + } - /** - * Returns the maximum size of the queue. - * - * @return The maximim size, in megabytes, of the queue. - */ - public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); - } + /** + * Returns the maximum size of the queue. + * + * @return The maximum size, in megabytes, of the queue. + */ + public Long getMaxSizeInMegabytes() { + return getModel().getMaxSizeInMegabytes(); + } - /** - * Sets the maximum size of the queue. - * - * @param value - * The maximim size, in megabytes, of the queue. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); - return this; - } + /** + * Sets the maximum size of the queue. + * + * @param value + * The maximum size, in megabytes, of the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setMaxSizeInMegabytes(Long value) { + getModel().setMaxSizeInMegabytes(value); + return this; + } - /** - * Indicates whether duplicate message detection is required. - * - * @return true if duplicate message detection is required; - * otherwise, false. - */ - public Boolean isRequiresDuplicateDetection() { - return getModel().isRequiresDuplicateDetection(); - } + /** + * Indicates whether duplicate message detection is required. + * + * @return true if duplicate message detection is required; otherwise, false. + */ + public Boolean isRequiresDuplicateDetection() { + return getModel().isRequiresDuplicateDetection(); + } - /** - * Specifies whether duplicate message detection is required. - * - * @param value - * true if duplicate message detection is required; - * otherwise, false. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setRequiresDuplicateDetection(Boolean value) { - getModel().setRequiresDuplicateDetection(value); - return this; - } + /** + * Specifies whether duplicate message detection is required. + * + * @param value + * true if duplicate message detection is required; otherwise, false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setRequiresDuplicateDetection(Boolean value) { + getModel().setRequiresDuplicateDetection(value); + return this; + } - /** - * Indicates whether the queue is session-aware. - * - * @return true if the queue is session aware; otherwise, - * false. - */ - public Boolean isRequiresSession() { - return getModel().isRequiresSession(); - } + /** + * Indicates whether the queue is session-aware. + * + * @return true if the queue is session aware; otherwise, false. + */ + public Boolean isRequiresSession() { + return getModel().isRequiresSession(); + } - /** - * Specifies whether the queue is session-aware. - * - * @param value - * true if the queue is session aware; otherwise, - * false. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setRequiresSession(Boolean value) { - getModel().setRequiresSession(value); - return this; - } + /** + * Specifies whether the queue is session-aware. + * + * @param value + * true if the queue is session aware; otherwise, false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setRequiresSession(Boolean value) { + getModel().setRequiresSession(value); + return this; + } - /** - * Returns the default message time-to-live (TTL). This applies when dead - * lettering is in effect. - * - * @return A Duration object that represents the default - * message TTL. - */ - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } + /** + * Returns the default message time-to-live (TTL). This applies when dead + * lettering is in effect. + * + * @return A Duration object that represents the default message TTL. + */ + public Duration getDefaultMessageTimeToLive() { + return getModel().getDefaultMessageTimeToLive(); + } - /** - * Sets the default message time-to-live (TTL). This applies when dead - * lettering is in effect. - * - * @param value - * A Duration object that represents the default - * message TTL. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } + /** + * Sets the default message time-to-live (TTL). This applies when dead lettering is in effect. + * + * @param value + * A Duration object that represents the default message TTL. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDefaultMessageTimeToLive(Duration value) { + getModel().setDefaultMessageTimeToLive(value); + return this; + } - /** - * Indicates whether dead lettering is in effect upon message expiration. - * - * @return true if dead lettering is in effect; otherwise, - * false. - */ - public Boolean isDeadLetteringOnMessageExpiration() { - return getModel().isDeadLetteringOnMessageExpiration(); - } + /** + * Indicates whether dead lettering is in effect upon message expiration. + * + * @return true if dead lettering is in effect; otherwise, false. + */ + public Boolean isDeadLetteringOnMessageExpiration() { + return getModel().isDeadLetteringOnMessageExpiration(); + } - /** - * Specifies whether dead lettering is in effect upon message expiration. - * - * @param value - * true if dead lettering is in effect; otherwise, - * false. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setDeadLetteringOnMessageExpiration(Boolean value) { - getModel().setDeadLetteringOnMessageExpiration(value); - return this; - } + /** + * Specifies whether dead lettering is in effect upon message expiration. + * + * @param value + * true if dead lettering is in effect; otherwise, false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDeadLetteringOnMessageExpiration(Boolean value) { + getModel().setDeadLetteringOnMessageExpiration(value); + return this; + } - /** - * Returns the time span during which the service bus will detect message - * duplication. This applies when duplicate message detection is in effect. - * - * @return A Duration object that represents the time span for - * detecting message duplication. - */ - public Duration getDuplicateDetectionHistoryTimeWindow() { - return getModel().getDuplicateDetectionHistoryTimeWindow(); - } + /** + * Returns the time span during which the service bus will detect message duplication. This applies when duplicate + * message detection is in effect. + * + * @return A Duration object that represents the time span for + * detecting message duplication. + */ + public Duration getDuplicateDetectionHistoryTimeWindow() { + return getModel().getDuplicateDetectionHistoryTimeWindow(); + } - /** - * Sets the time span during which the service bus will detect message - * duplication. This applies when duplicate message detection is in effect. - * - * @param value - * A Duration object that represents the time span - * for detecting message duplication. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { - getModel().setDuplicateDetectionHistoryTimeWindow(value); - return this; - } + /** + * Sets the time span during which the service bus will detect message duplication. This applies when duplicate + * message detection is in effect. + * + * @param value + * A Duration object that represents the time span for detecting message duplication. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { + getModel().setDuplicateDetectionHistoryTimeWindow(value); + return this; + } - /** - * Returns the maximum delivery count for the queue. - * - * @return The maximum delivery count. - */ - public Integer getMaxDeliveryCount() { - return getModel().getMaxDeliveryCount(); - } + /** + * Returns the maximum delivery count for the queue. + * + * @return The maximum delivery count. + */ + public Integer getMaxDeliveryCount() { + return getModel().getMaxDeliveryCount(); + } - /** - * Sets the maximum delivery count for the queue. - * - * @param value - * The maximum delivery count for the queue. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setMaxDeliveryCount(Integer value) { - getModel().setMaxDeliveryCount(value); - return this; - } + /** + * Sets the maximum delivery count for the queue. + * + * @param value + * The maximum delivery count for the queue. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setMaxDeliveryCount(Integer value) { + getModel().setMaxDeliveryCount(value); + return this; + } - /** - * Indicates whether batch operations are enabled. - * - * @return true if batch operations are enabled; otherwise, - * false. - */ - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } + /** + * Indicates whether batch operations are enabled. + * + * @return true if batch operations are enabled; otherwise, false. + */ + public Boolean isEnableBatchedOperations() { + return getModel().isEnableBatchedOperations(); + } - /** - * Specifies whether batch operations are enabled. - * - * @param value - * true if batch operations are enabled; otherwise, - * false. - * - * @return A Queue object that represents the updated queue. - */ - public Queue setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } + /** + * Specifies whether batch operations are enabled. + * + * @param value + * true if batch operations are enabled; otherwise, false. + * + * @return A Queue object that represents the updated queue. + */ + public Queue setEnableBatchedOperations(Boolean value) { + getModel().setEnableBatchedOperations(value); + return this; + } - /** + /** * Returns the size of the queue. * * @return The size, in bytes, of the queue. */ - public Long getSizeInBytes() { - return getModel().getSizeInBytes(); - } + public Long getSizeInBytes() { + return getModel().getSizeInBytes(); + } - /** - * Returns the number of messages in the queue. - * - * @return The number of messages in the queue. - */ - public Long getMessageCount() { - return getModel().getMessageCount(); - } + /** + * Returns the number of messages in the queue. + * + * @return The number of messages in the queue. + */ + public Long getMessageCount() { + return getModel().getMessageCount(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java index a168e233aa0ec..1af7f72d7f07e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java @@ -9,8 +9,14 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; +/** + * Represents a subscription. + */ public class Subscription extends EntryModel { + /** + * Creates an instance of the Subscription class. + */ public Subscription() { super(new Entry(), new SubscriptionDescription()); getEntry().setContent(new Content()); @@ -18,95 +24,231 @@ public Subscription() { getEntry().getContent().setSubscriptionDescription(getModel()); } + /** + * Creates an instance of the Subscription class using the specified entry. + * + * @param entry + * An Entry object. + */ public Subscription(Entry entry) { super(entry, entry.getContent().getSubscriptionDescription()); } + /** + * Creates an instance of the Subscription class using the specified name. + * + * @param name + * A String object that represents the name of the subscription. + */ public Subscription(String name) { this(); setName(name); } + /** + * Returns the name of the subscription. + * + * @return A String object that represents the name of the subscription. + */ public String getName() { return getEntry().getTitle(); } + /** + * Sets the name of the subscription. + * + * @param value + * A String that represents the name of the subscription. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setName(String value) { getEntry().setTitle(value); return this; } + /** + * Returns the duration of the lock. + * + * @return A Duration object that represents the duration of the lock. + */ public Duration getLockDuration() { return getModel().getLockDuration(); } + /** + * Sets the duration of the lock. + * + * @param value + * The duration, in seconds, of the lock. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setLockDuration(Duration value) { getModel().setLockDuration(value); return this; } + /** + * Indicates whether the subscription is session-aware. + * + * @return true if the subscription is session aware; otherwise, false. + */ public Boolean isRequiresSession() { return getModel().isRequiresSession(); } + /** + * Specifies whether the subscription is session-aware. + * + * @param value + * true if the subscription is session aware; otherwise, false. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setRequiresSession(Boolean value) { getModel().setRequiresSession(value); return this; } + /** + * Returns the default message time-to-live (TTL). This applies when dead + * lettering is in effect. + * + * @return A Duration object that represents the default message TTL. + */ public Duration getDefaultMessageTimeToLive() { return getModel().getDefaultMessageTimeToLive(); } + /** + * Sets the default message time-to-live (TTL). This applies when dead lettering is in effect. + * + * @param value + * A Duration object that represents the default message TTL. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setDefaultMessageTimeToLive(Duration value) { getModel().setDefaultMessageTimeToLive(value); return this; } + /** + * Indicates whether dead lettering is in effect upon message expiration. + * + * @return true if dead lettering is in effect; otherwise, false. + */ public Boolean isDeadLetteringOnMessageExpiration() { return getModel().isDeadLetteringOnMessageExpiration(); } + /** + * Specifies whether dead lettering is in effect upon message expiration. + * + * @param value + * true if dead lettering is in effect; otherwise, false. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setDeadLetteringOnMessageExpiration(Boolean value) { getModel().setDeadLetteringOnMessageExpiration(value); return this; } + /** + * Indicates whether dead lettering is in effect when filter evaluation exceptions are encountered. + * + * @return true if dead lettering is in effect; otherwise, false. + */ public Boolean isDeadLetteringOnFilterEvaluationExceptions() { return getModel().isDeadLetteringOnFilterEvaluationExceptions(); } + /** + * Specifies whether dead lettering is in effect when filter evaluation exceptions are encountered. + * + * @param value + * true if dead lettering is in effect; otherwise, false. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setDeadLetteringOnFilterEvaluationExceptions(Boolean value) { getModel().setDeadLetteringOnFilterEvaluationExceptions(value); return this; } + /** + * Returns the description of the default rule. + * + * @return A RuleDescription object that represents the default rule description. + */ public RuleDescription getDefaultRuleDescription() { return getModel().getDefaultRuleDescription(); } + /** + * Specifies the description for the default rule. + * + * @param value + * A RuleDescription object that represents the default rule description. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setDefaultRuleDescription(RuleDescription value) { getModel().setDefaultRuleDescription(value); return this; } + /** + * Returns the number of messages in the subscription. + * + * @return The number of messages in the subscription. + */ public Long getMessageCount() { return getModel().getMessageCount(); } + + /** + * Returns the maximum delivery count for the subscription. + * + * @return The maximum delivery count. + */ public Integer getMaxDeliveryCount() { return getModel().getMaxDeliveryCount(); } + /** + * Sets the maximum delivery count for the subscription. + * + * @param value + * The maximum delivery count for the subscription. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setMaxDeliveryCount(Integer value) { getModel().setMaxDeliveryCount(value); return this; } + /** + * Indicates whether batch operations are enabled. + * + * @return true if batch operations are enabled; otherwise, false. + */ public Boolean isEnableBatchedOperations() { return getModel().isEnableBatchedOperations(); } + /** + * Specifies whether batch operations are enabled. + * + * @param value + * true if batch operations are enabled; otherwise, false. + * + * @return A Subscription object that represents the updated subscription. + */ public Subscription setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java index c8b08f1d585ad..d01cb0bf5413d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java @@ -8,7 +8,13 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; +/** + * Represents a topic. + */ public class Topic extends EntryModel { + /** + * Creates an instance of the Topic class. + */ public Topic() { super(new Entry(), new TopicDescription()); getEntry().setContent(new Content()); @@ -16,69 +22,165 @@ public Topic() { getEntry().getContent().setTopicDescription(getModel()); } + /** + * Creates an instance of the Topic class using the specified entry. + * + * @param entry + * An Entry object that represents the entry for the topic. + */ public Topic(Entry entry) { super(entry, entry.getContent().getTopicDescription()); } + /** + * Creates an instance of the Topic class using the specified name. + * + * @param name + * A String object that represents the name for the topic. + */ public Topic(String name) { this(); setName(name); } + /** + * Returns the name of the topic. + * + * @return A String object that represents the name of the topic. + */ public String getName() { return getEntry().getTitle(); } + /** + * Sets the name of the topic. + * + * @param value + * A String that represents the name of the topic. + * + * @return A Topic object that represents the updated topic. + */ public Topic setName(String value) { getEntry().setTitle(value); return this; } + /** + * Returns the default message time-to-live (TTL). + * + * @return A Duration object that represents the default message TTL. + */ public Duration getDefaultMessageTimeToLive() { return getModel().getDefaultMessageTimeToLive(); } + /** + * Sets the default message time-to-live (TTL). + * + * @param value + * A Duration object that represents the default message TTL. + * + * @return A Topic object that represents the updated topic. + */ public Topic setDefaultMessageTimeToLive(Duration value) { getModel().setDefaultMessageTimeToLive(value); return this; } + /** + * Returns the maximum size of the topic. + * + * @return The maximum size, in megabytes, of the topic. + */ public Long getMaxSizeInMegabytes() { return getModel().getMaxSizeInMegabytes(); } + /** + * Sets the maximum size of the topic. + * + * @param value + * The maximum size, in megabytes, of the topic. + * + * @return A Topic object that represents the updated topic. + */ public Topic setMaxSizeInMegabytes(Long value) { getModel().setMaxSizeInMegabytes(value); return this; } + /** + * Indicates whether duplicate message detection is required. + * + * @return true if duplicate message detection is required; otherwise, false. + */ public Boolean isRequiresDuplicateDetection() { return getModel().isRequiresDuplicateDetection(); } + /** + * Specifies whether duplicate message detection is required. + * + * @param value + * true if duplicate message detection is required; otherwise, false. + * + * @return A Topic object that represents the updated topic. + */ public Topic setRequiresDuplicateDetection(Boolean value) { getModel().setRequiresDuplicateDetection(value); return this; } + /** + * Returns the time span during which the service bus will detect message duplication. + * + * @return A Duration object that represents the time span for + * detecting message duplication. + */ public Duration getDuplicateDetectionHistoryTimeWindow() { return getModel().getDuplicateDetectionHistoryTimeWindow(); } + /** + * Sets the time span during which the service bus will detect message duplication. + * + * @param value + * A Duration object that represents the time span for detecting message duplication. + * + * @return A Topic object that represents the updated topic. + */ public Topic setDuplicateDetectionHistoryTimeWindow(Duration value) { getModel().setDuplicateDetectionHistoryTimeWindow(value); return this; } + /** + * Indicates whether batch operations are enabled. + * + * @return true if batch operations are enabled; otherwise, false. + */ public Boolean isEnableBatchedOperations() { return getModel().isEnableBatchedOperations(); } + /** + * Specifies whether batch operations are enabled. + * + * @param value + * true if batch operations are enabled; otherwise, false. + * + * @return A Topic object that represents the updated topic. + */ public Topic setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; } + /** + * Returns the size of the topic. + * + * @return The size, in bytes, of the topic. + */ public Long getSizeInBytes() { return getModel().getSizeInBytes(); } From 44f2b767af4a8bd28ee9b139036dca46b651cf4c Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 12:37:41 -0800 Subject: [PATCH 227/664] Added package-level html pages. --- .../windowsazure/services/serviceBus/models/package.html | 5 +++++ .../microsoft/windowsazure/services/serviceBus/paackage.html | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html new file mode 100644 index 0000000000000..b4b1d74369518 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html @@ -0,0 +1,5 @@ + + +This package contains the service bus data transfer object classes. + + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html new file mode 100644 index 0000000000000..f52907554adf7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html @@ -0,0 +1,5 @@ + + +This package contains the service bus service class, interface, and the associated configuration and utility classes. + + From 3d538b36205a7d2ffbf7fb2e33cbcd7c7096d427 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 12:52:31 -0800 Subject: [PATCH 228/664] Updated files, for Javadoc purposes. --- .../windowsazure/services/serviceBus/paackage.html | 5 ----- .../microsoft/windowsazure/services/serviceBus/package.html | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html deleted file mode 100644 index f52907554adf7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/paackage.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This package contains the service bus service class, interface, and the associated configuration and utility classes. - - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html new file mode 100644 index 0000000000000..f320abf4cc9a2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html @@ -0,0 +1,6 @@ + + +This package contains the service bus service class, + interface, and associated configuration and utility classes. + + From c760823080e3190d48ffb91ba2dc1b42ef3de08c Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 13:03:22 -0800 Subject: [PATCH 229/664] Updated Javadoc comment. --- .../windowsazure/services/serviceBus/models/package.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html index b4b1d74369518..6d230ea5af324 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html @@ -1,5 +1,6 @@ - -This package contains the service bus data transfer object classes. + +This package contains the service bus data transfer object + classes. From 4a270cf6a591cc9160c1bfa3f7ce23a00f7f2a87 Mon Sep 17 00:00:00 2001 From: Walter Poupore Date: Thu, 17 Nov 2011 16:28:02 -0800 Subject: [PATCH 230/664] Added Javadoc comments. Conflicts: microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java --- .../serviceBus/ServiceBusConfiguration.java | 117 +++++- .../serviceBus/ServiceBusContract.java | 291 +++++++++++++++ .../serviceBus/ServiceBusService.java | 335 ++++++++++++++++++ 3 files changed, 725 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index 486ceca26b0c8..cf1f3877a26bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -2,30 +2,113 @@ import com.microsoft.windowsazure.common.Configuration; +/** + * Provides functionality to create a service bus configuration. + * + */ public class ServiceBusConfiguration { + + /** + * Defines the configuration URI constant. + * + */ public final static String URI = "serviceBus.uri"; + + /** + * Defines the configuration wrap URI constant. + * + */ public final static String WRAP_URI = "serviceBus.wrap.uri"; + + /** + * Defines the configuration wrap name constant. + * + */ public final static String WRAP_NAME = "serviceBus.wrap.name"; + + /** + * Defines the configuration wrap password constant. + * + */ public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; + + /** + * Defines the configuration wrap scope constant. + * + */ public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; - public static Configuration configure( - String namespace, String authenticationName, - String authenticationPassword) { - return configure(null, Configuration.getInstance(), namespace, authenticationName, - authenticationPassword); + /** + * Creates a service bus configuration using the specified namespace, name, and password. + * + * @param namespace + * A String object that represents the namespace. + * + * @param authenticationName + * A String object that represents the authentication name. + * + * @param authenticationPassword + * A String object that represents the authentication password. + * + * @return + * A Configuration object that can be used when creating an instance of the + * ServiceBusService class. + * + */ + public static Configuration configure(String namespace, String authenticationName, String authenticationPassword) { + return configure(null, Configuration.getInstance(), namespace, authenticationName, authenticationPassword); } - public static Configuration configure(Configuration configuration, - String namespace, String authenticationName, + /** + * Creates a service bus configuration using the specified configuration, namespace, name, and password. + * + * @param configuration + * A previously instantiated Configuration object. + * + * @param namespace + * A String object that represents the namespace. + * + * @param authenticationName + * A String object that represents the authentication name. + * + * @param authenticationPassword + * A String object that represents the authentication password. + * + * @return + * A Configuration object that can be used when creating an instance of the + * ServiceBusService class. + * + */ + public static Configuration configure(Configuration configuration, String namespace, String authenticationName, String authenticationPassword) { - return configure(null, configuration, namespace, authenticationName, - authenticationPassword); + return configure(null, configuration, namespace, authenticationName, authenticationPassword); } - public static Configuration configure(String profile, Configuration configuration, - String namespace, String authenticationName, - String authenticationPassword) { + /** + * Creates a service bus configuration using the specified profile, configuration, namespace, name, and password. + * + * @param profile + * A String object that represents the profile. + * + * @param configuration + * A previously instantiated Configuration object. + * + * @param namespace + * A String object that represents the namespace. + * + * @param authenticationName + * A String object that represents the authentication name. + * + * @param authenticationPassword + * A String object that represents the authentication password. + * + * @return + * A Configuration object that can be used when creating an instance of the + * ServiceBusService class. + * + */ + public static Configuration configure(String profile, Configuration configuration, String namespace, + String authenticationName, String authenticationPassword) { if (profile == null) { profile = ""; @@ -34,16 +117,14 @@ else if (profile.length() != 0 && !profile.endsWith(".")) { profile = profile + "."; } - configuration.setProperty(profile + URI, "https://" + namespace - + ".servicebus.windows.net/"); + configuration.setProperty(profile + URI, "https://" + namespace + ".servicebus.windows.net/"); - configuration.setProperty(profile + WRAP_URI, "https://" + namespace - + "-sb.accesscontrol.windows.net/WRAPv0.9"); + configuration + .setProperty(profile + WRAP_URI, "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"); configuration.setProperty(profile + WRAP_NAME, authenticationName); configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); - configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace - + ".servicebus.windows.net/"); + configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace + ".servicebus.windows.net/"); return configuration; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 5db7be986897a..76357d462942a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -27,64 +27,355 @@ import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; +/** + * + * Defines the service bus contract. + * + */ public interface ServiceBusContract extends FilterableService { + /** + * Sends a queue message. + * + * @param queueName + * A String object that represents the name of the queue to which the message will be sent. + * @param message + * A Message object that represents the message to send. + * + * @exception ServiceException + * If a service exception is encountered. + */ void sendQueueMessage(String queueName, Message message) throws ServiceException; + /** + * Receives a queue message. + * + * @param queueName + * A String object that represents the name of the queue from which to receive the message. + * + * @return A ReceiveQueueMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException; + /** + * Receives a queue message using the specified receive message options. + * + * @param queueName + * A String object that represents the name of the queue from which to receive the message. + * + * @param options + * A ReceiveMessageOptions object that represents the receive message options. + * + * @return A ReceiveQueueMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException; + /** + * Sends a topic message. + * + * @param topicName + * A String object that represents the name of the topic to which the message will be sent. + * @param message + * A Message object that represents the message to send. + * + * @exception ServiceException + * If a service exception is encountered. + */ void sendTopicMessage(String topicName, Message message) throws ServiceException; + + /** + * Receives a subscription message. + * + * @param topicName + * A String object that represents the name of the topic to receive. + * @param subscriptionName + * A String object that represents the name of the subscription from the message will be + * received. + * + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException; + /** + * Receives a subscription message using the specified receive message options. + * + * @param topicName + * A String object that represents the name of the topic to receive. + * @param subscriptionName + * A String object that represents the name of the subscription from the message will be + * received. + * @param options + * A ReceiveMessageOptions object that represents the receive message options. + * + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; + /** + * Unlocks a message. + * + * @param message + * A Message object that represents the message to unlock. + * + * @exception ServiceException + * If a service exception is encountered. + */ void unlockMessage(Message message) throws ServiceException; + /** + * Deletes a message. + * + * @param message + * A Message object that represents the message to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ void deleteMessage(Message message) throws ServiceException; + /** + * Creates a queue. + * + * @param queue + * A Queue object that represents the queue to create. + * + * @return A CreateQueueResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ CreateQueueResult createQueue(Queue queue) throws ServiceException; + /** + * Deletes a queue. + * + * @param queueName + * A String object that represents the name of the queue to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ void deleteQueue(String queueName) throws ServiceException; + /** + * Retrieves a queue. + * + * @param queueName + * A String object that represents the name of the queue to retrieve. + * + * @return A GetQueueResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ GetQueueResult getQueue(String queueName) throws ServiceException; + /** + * Returns a list of queues. + * + * @return A ListQueuesResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ListQueuesResult listQueues() throws ServiceException; ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException; + /** + * Creates a topic. + * + * @param topic + * A Topic object that represents the topic to create. + * + * @return A CreateTopicResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ CreateTopicResult createTopic(Topic topic) throws ServiceException; + /** + * Deletes a topic. + * + * @param topicName + * A String object that represents the name of the queue to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ void deleteTopic(String topicName) throws ServiceException; + /** + * Retrieves a topic. + * + * @param topicName + * A String object that represents the name of the topic to retrieve. + * + * @return A GetTopicResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ GetTopicResult getTopic(String topicName) throws ServiceException; + /** + * Returns a list of topics. + * + * @return A ListTopicsResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ListTopicsResult listTopics() throws ServiceException; ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException; + /** + * Creates a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscription + * A Subscription object that represents the subscription to create. + * + * @return A CreateSubscriptionResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException; + /** + * Deletes a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * + * @param subscriptionName + * A String object that represents the name of the subscription to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ void deleteSubscription(String topicName, String subscriptionName) throws ServiceException; + /** + * Retrieves a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription to retrieve. + * + * @return A GetSubscriptionResult object that represents the result. + * A String object that represents the name of the subscription to retrieve. + * + * @exception ServiceException + * If a service exception is encountered. + */ GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException; + /** + * Returns a list of subscriptions. + * + * @param topicName + * A String object that represents the name of the topic for the subscriptions to retrieve. + * + * @return A ListSubscriptionsResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) throws ServiceException; + /** + * Creates a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * created. + * @param rule + * A Rule object that represents the rule to create. + * + * @return A CreateRuleResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException; + /** + * Deletes a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * deleted. + * @param ruleName + * A String object that represents the name of the rule to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + /** + * Retrieves a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * retrieved. + * @param ruleName + * A String object that represents the name of the rule to retrieve. + * + * @return A GetRuleResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + /** + * Returns a list of rules. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription whose rules are being + * retrieved. + * + * @return A ListRulesResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException; ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index f214391de0ac3..4e0c05d281d34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -30,21 +30,62 @@ import com.microsoft.windowsazure.services.serviceBus.models.Subscription; import com.microsoft.windowsazure.services.serviceBus.models.Topic; +/** + * + * Provides service bus functionality. + * + */ public class ServiceBusService implements ServiceBusContract { final ServiceBusContract next; + /** + * Creates an instance of the ServiceBusService class. + * + * @exception Exception + * If an exception is encountered. + */ public ServiceBusService() throws Exception { this(null, Configuration.getInstance()); } + /** + * Creates an instance of the ServiceBusService class using the specified configuration. + * + * @param config + * A Configuration object that represents the configuration for the service bus service. + * + * @exception Exception + * If an exception is encountered. + */ public ServiceBusService(Configuration config) throws Exception { this(null, config); } + /** + * Creates an instance of the ServiceBusService class using the specified profile. + * + * @param profile + * A String object that represents the profile for the service bus service. + * + * @exception Exception + * If an exception is encountered. + */ public ServiceBusService(String profile) throws Exception { this(profile, Configuration.getInstance()); } + /** + * Creates an instance of the ServiceBusService class using the specified profile and configuration. + * + * @param profile + * A String object that represents the profile for the service bus service. + * + * @param config + * A Configuration object that represents the configuration for the service bus service. + * + * @exception Exception + * If an exception is encountered. + */ public ServiceBusService(String profile, Configuration config) throws Exception { next = config.create(profile, ServiceBusService.class); } @@ -54,106 +95,400 @@ public ServiceBusService(ServiceBusContract next) throws Exception { this.next = next; } + /** + * Returns a service bus contract with the specified filter. + * + * @param filter + * A ServiceFilter object that represents the filter to use. + * + * @return A ServiceBusContract object that represents the service bus contract with the + * specified filter applied. + */ public ServiceBusContract withFilter(ServiceFilter filter) { return next.withFilter(filter); } + /** + * Sends a queue message. + * + * @param queueName + * A String object that represents the name of the queue to which the message will be sent. + * @param message + * A Message object that represents the message to send. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void sendQueueMessage(String queueName, Message message) throws ServiceException { next.sendQueueMessage(queueName, message); } + /** + * Receives a queue message. + * + * @param queueName + * A String object that represents the name of the queue from which to receive the message. + * + * @return A ReceiveQueueMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { return next.receiveQueueMessage(queueName); } + /** + * Receives a queue message using the specified receive message options. + * + * @param queueName + * A String object that represents the name of the queue from which to receive the message. + * + * @param options + * A ReceiveMessageOptions object that represents the receive message options. + * + * @return A ReceiveQueueMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException { return next.receiveQueueMessage(queueName, options); } + /** + * Sends a topic message. + * + * @param topicName + * A String object that represents the name of the topic to which the message will be sent. + * @param message + * A Message object that represents the message to send. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void sendTopicMessage(String topicName, Message message) throws ServiceException { next.sendTopicMessage(topicName, message); } + /** + * Receives a subscription message. + * + * @param topicName + * A String object that represents the name of the topic to receive. + * @param subscriptionName + * A String object that represents the name of the subscription from the message will be + * received. + * + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { return next.receiveSubscriptionMessage(topicName, subscriptionName); } + /** + * Receives a subscription message using the specified receive message options. + * + * @param topicName + * A String object that represents the name of the topic to receive. + * @param subscriptionName + * A String object that represents the name of the subscription from the message will be + * received. + * @param options + * A ReceiveMessageOptions object that represents the receive message options. + * + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { return next.receiveSubscriptionMessage(topicName, subscriptionName, options); } + /** + * Unlocks a message. + * + * @param message + * A Message object that represents the message to unlock. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void unlockMessage(Message message) throws ServiceException { next.unlockMessage(message); } + /** + * Deletes a message. + * + * @param message + * A Message object that represents the message to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void deleteMessage(Message message) throws ServiceException { next.deleteMessage(message); } + /** + * Creates a queue. + * + * @param queue + * A Queue object that represents the queue to create. + * + * @return A CreateQueueResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public CreateQueueResult createQueue(Queue queue) throws ServiceException { return next.createQueue(queue); } + /** + * Deletes a queue. + * + * @param queueName + * A String object that represents the name of the queue to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void deleteQueue(String queueName) throws ServiceException { next.deleteQueue(queueName); } + /** + * Retrieves a queue. + * + * @param queueName + * A String object that represents the name of the queue to retrieve. + * + * @return A GetQueueResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public GetQueueResult getQueue(String queueName) throws ServiceException { return next.getQueue(queueName); } + /** + * Returns a list of queues. + * + * @return A ListQueuesResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ListQueuesResult listQueues() throws ServiceException { return next.listQueues(); } + /** + * Creates a topic. + * + * @param topic + * A Topic object that represents the topic to create. + * + * @return A CreateTopicResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public CreateTopicResult createTopic(Topic topic) throws ServiceException { return next.createTopic(topic); } + /** + * Deletes a topic. + * + * @param topicName + * A String object that represents the name of the queue to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void deleteTopic(String topicName) throws ServiceException { next.deleteTopic(topicName); } + /** + * Retrieves a topic. + * + * @param topicName + * A String object that represents the name of the topic to retrieve. + * + * @return A GetTopicResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public GetTopicResult getTopic(String topicName) throws ServiceException { return next.getTopic(topicName); } + /** + * Returns a list of topics. + * + * @return A ListTopicsResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ListTopicsResult listTopics() throws ServiceException { return next.listTopics(); } + /** + * Creates a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscription + * A Subscription object that represents the subscription to create. + * + * @return A CreateSubscriptionResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException { return next.createSubscription(topicName, subscription); } + /** + * Deletes a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * + * @param subscriptionName + * A String object that represents the name of the subscription to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void deleteSubscription(String topicName, String subscriptionName) throws ServiceException { next.deleteSubscription(topicName, subscriptionName); } + /** + * Retrieves a subscription. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription to retrieve. + * + * @return A GetSubscriptionResult object that represents the result. + * A String object that represents the name of the subscription to retrieve. + * + * @exception ServiceException + * If a service exception is encountered. + */ public GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException { return next.getSubscription(topicName, subscriptionName); } + /** + * Returns a list of subscriptions. + * + * @param topicName + * A String object that represents the name of the topic for the subscriptions to retrieve. + * + * @return A ListSubscriptionsResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { return next.listSubscriptions(topicName); } + /** + * Creates a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * created. + * @param rule + * A Rule object that represents the rule to create. + * + * @return A CreateRuleResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException { return next.createRule(topicName, subscriptionName, rule); } + /** + * Deletes a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * deleted. + * @param ruleName + * A String object that represents the name of the rule to delete. + * + * @exception ServiceException + * If a service exception is encountered. + */ public void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { next.deleteRule(topicName, subscriptionName, ruleName); } + /** + * Retrieves a rule. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription for which the rule will be + * retrieved. + * @param ruleName + * A String object that represents the name of the rule to retrieve. + * + * @return A GetRuleResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { return next.getRule(topicName, subscriptionName, ruleName); } + /** + * Returns a list of rules. + * + * @param topicName + * A String object that represents the name of the topic for the subscription. + * @param subscriptionName + * A String object that represents the name of the subscription whose rules are being + * retrieved. + * + * @return A ListRulesResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + */ public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { return next.listRules(topicName, subscriptionName); } From 3e93da58b56d5689f63e31033742af33ce576588 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:35:47 -0800 Subject: [PATCH 231/664] Renaming Queue domain data object to QueueInfo SB API review --- .../serviceBus/ServiceBusContract.java | 4 +-- .../serviceBus/ServiceBusService.java | 4 +-- .../services/serviceBus/Util.java | 4 +-- .../ServiceBusExceptionProcessor.java | 4 +-- .../implementation/ServiceBusRestProxy.java | 12 ++++---- .../serviceBus/models/CreateQueueResult.java | 14 +++++----- .../serviceBus/models/GetQueueResult.java | 14 +++++----- .../serviceBus/models/ListQueuesResult.java | 10 +++---- .../models/{Queue.java => QueueInfo.java} | 28 +++++++++---------- .../serviceBus/IntegrationTestBase.java | 6 ++-- .../serviceBus/ServiceBusIntegrationTest.java | 24 ++++++++-------- 11 files changed, 62 insertions(+), 62 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/{Queue.java => QueueInfo.java} (91%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 76357d462942a..ad002583b5c77 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -19,7 +19,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; @@ -162,7 +162,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - CreateQueueResult createQueue(Queue queue) throws ServiceException; + CreateQueueResult createQueue(QueueInfo queue) throws ServiceException; /** * Deletes a queue. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 4e0c05d281d34..189f78a862a6f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -22,7 +22,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; @@ -251,7 +251,7 @@ public void deleteMessage(Message message) throws ServiceException { * @exception ServiceException * If a service exception is encountered. */ - public CreateQueueResult createQueue(Queue queue) throws ServiceException { + public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { return next.createQueue(queue); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 8ff5f44fec824..21a1bc198cc72 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,11 +1,11 @@ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.Topic; public class Util { - public static Iterable iterateQueues(ServiceBusContract service) + public static Iterable iterateQueues(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listQueues().getItems(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index befbc7817a183..2cae759d3f0ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -25,7 +25,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; @@ -158,7 +158,7 @@ public void deleteMessage(Message message) throws ServiceException { } } - public CreateQueueResult createQueue(Queue queue) throws ServiceException { + public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { try { return next.createQueue(queue); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index e7b51c7d4c886..b12a1a28b01fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -31,7 +31,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; @@ -211,11 +211,11 @@ public void deleteMessage(Message message) throws ServiceException { .delete(); } - public CreateQueueResult createQueue(Queue entry) throws ServiceException { + public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { return new CreateQueueResult(getResource() .path(entry.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Queue.class, entry)); + .put(QueueInfo.class, entry)); } public void deleteQueue(String queuePath) throws ServiceException { @@ -227,16 +227,16 @@ public void deleteQueue(String queuePath) throws ServiceException { public GetQueueResult getQueue(String queuePath) throws ServiceException { return new GetQueueResult(getResource() .path(queuePath) - .get(Queue.class)); + .get(QueueInfo.class)); } public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { Feed feed = listOptions(options, getResource() .path("$Resources/Queues")) .get(Feed.class); - ArrayList queues = new ArrayList(); + ArrayList queues = new ArrayList(); for (Entry entry : feed.getEntries()) { - queues.add(new Queue(entry)); + queues.add(new QueueInfo(entry)); } ListQueuesResult result = new ListQueuesResult(); result.setItems(queues); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index 31335b14fe4cd..71a2f7b2ddc90 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -5,15 +5,15 @@ */ public class CreateQueueResult { - private Queue value; + private QueueInfo value; /** * Creates an instance of the CreateQueueResult class. * * @param value - * A {@link Queue} object assigned as the value of the result. + * A {@link QueueInfo} object assigned as the value of the result. */ - public CreateQueueResult(Queue value) { + public CreateQueueResult(QueueInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public CreateQueueResult(Queue value) { * Specfies the value of the result. * * @param value - * A {@link Queue} object assigned as the value of the result. + * A {@link QueueInfo} object assigned as the value of the result. */ - public void setValue(Queue value) { + public void setValue(QueueInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Queue} object that represents the value of the result. + * @return A {@link QueueInfo} object that represents the value of the result. */ - public Queue getValue() { + public QueueInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index 26b50e60454aa..ddb5da06d5a11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -5,15 +5,15 @@ */ public class GetQueueResult { - private Queue value; + private QueueInfo value; /** * Creates an instance of the GetQueueResult class. * * @param value - * A {@link Queue} object assigned as the value of the result. + * A {@link QueueInfo} object assigned as the value of the result. */ - public GetQueueResult(Queue value) { + public GetQueueResult(QueueInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public GetQueueResult(Queue value) { * Specfies the value of the result. * * @param value - * A {@link Queue} object assigned as the value of the result. + * A {@link QueueInfo} object assigned as the value of the result. */ - public void setValue(Queue value) { + public void setValue(QueueInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Queue} object that represents the value of the result. + * @return A {@link QueueInfo} object that represents the value of the result. */ - public Queue getValue() { + public QueueInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index 89e28d150db9e..877e0f105bae5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -7,15 +7,15 @@ */ public class ListQueuesResult { - private List items; + private List items; /** * Returns the items in the result list. * - * @return A List of {@link Queue} objects that represent the + * @return A List of {@link QueueInfo} objects that represent the * items in the result list. */ - public List getItems() { + public List getItems() { return items; } @@ -23,10 +23,10 @@ public List getItems() { * Specfies the items in the result list. * * @param value - * A List object that contains the {@link Queue} + * A List object that contains the {@link QueueInfo} * objects assigned as the value of the result. */ - public void setItems(List items) { + public void setItems(List items) { this.items = items; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 65db41f838df2..67d7db2bf4407 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Queue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -11,12 +11,12 @@ /** * Represents a queue. */ -public class Queue extends EntryModel { +public class QueueInfo extends EntryModel { /** * Creates an instance of the Queue class. */ - public Queue() { + public QueueInfo() { super(new Entry(), new QueueDescription()); getEntry().setContent(new Content()); getEntry().getContent().setType(MediaType.APPLICATION_XML); @@ -29,7 +29,7 @@ public Queue() { * @param entry * An Entry object. */ - public Queue(Entry entry) { + public QueueInfo(Entry entry) { super(entry, entry.getContent().getQueueDescription()); } @@ -39,7 +39,7 @@ public Queue(Entry entry) { * @param name * A String object that represents the name of the queue. */ - public Queue(String name) { + public QueueInfo(String name) { this(); setName(name); } @@ -61,7 +61,7 @@ public String getName() { * * @return A Queue object that represents the updated queue. */ - public Queue setName(String value) { + public QueueInfo setName(String value) { getEntry().setTitle(value); return this; } @@ -83,7 +83,7 @@ public Duration getLockDuration() { * * @return A Queue object that represents the updated queue. */ - public Queue setLockDuration(Duration value) { + public QueueInfo setLockDuration(Duration value) { getModel().setLockDuration(value); return this; } @@ -105,7 +105,7 @@ public Long getMaxSizeInMegabytes() { * * @return A Queue object that represents the updated queue. */ - public Queue setMaxSizeInMegabytes(Long value) { + public QueueInfo setMaxSizeInMegabytes(Long value) { getModel().setMaxSizeInMegabytes(value); return this; } @@ -127,7 +127,7 @@ public Boolean isRequiresDuplicateDetection() { * * @return A Queue object that represents the updated queue. */ - public Queue setRequiresDuplicateDetection(Boolean value) { + public QueueInfo setRequiresDuplicateDetection(Boolean value) { getModel().setRequiresDuplicateDetection(value); return this; } @@ -149,7 +149,7 @@ public Boolean isRequiresSession() { * * @return A Queue object that represents the updated queue. */ - public Queue setRequiresSession(Boolean value) { + public QueueInfo setRequiresSession(Boolean value) { getModel().setRequiresSession(value); return this; } @@ -172,7 +172,7 @@ public Duration getDefaultMessageTimeToLive() { * * @return A Queue object that represents the updated queue. */ - public Queue setDefaultMessageTimeToLive(Duration value) { + public QueueInfo setDefaultMessageTimeToLive(Duration value) { getModel().setDefaultMessageTimeToLive(value); return this; } @@ -194,7 +194,7 @@ public Boolean isDeadLetteringOnMessageExpiration() { * * @return A Queue object that represents the updated queue. */ - public Queue setDeadLetteringOnMessageExpiration(Boolean value) { + public QueueInfo setDeadLetteringOnMessageExpiration(Boolean value) { getModel().setDeadLetteringOnMessageExpiration(value); return this; } @@ -219,7 +219,7 @@ public Duration getDuplicateDetectionHistoryTimeWindow() { * * @return A Queue object that represents the updated queue. */ - public Queue setDuplicateDetectionHistoryTimeWindow(Duration value) { + public QueueInfo setDuplicateDetectionHistoryTimeWindow(Duration value) { getModel().setDuplicateDetectionHistoryTimeWindow(value); return this; } @@ -241,7 +241,7 @@ public Integer getMaxDeliveryCount() { * * @return A Queue object that represents the updated queue. */ - public Queue setMaxDeliveryCount(Integer value) { + public QueueInfo setMaxDeliveryCount(Integer value) { getModel().setMaxDeliveryCount(value); return this; } @@ -263,7 +263,7 @@ public Boolean isEnableBatchedOperations() { * * @return A Queue object that represents the updated queue. */ - public Queue setEnableBatchedOperations(Boolean value) { + public QueueInfo setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 93ee9b4d96b71..53926858d8d1d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.Topic; @@ -27,7 +27,7 @@ public void initialize() throws Exception { boolean testAlphaExists = false; ServiceBusContract service = new ServiceBusService(); - for (Queue queue : iterateQueues(service)) { + for (QueueInfo queue : iterateQueues(service)) { String queueName = queue.getName(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { if (queueName.equalsIgnoreCase("TestAlpha")) { @@ -49,7 +49,7 @@ public void initialize() throws Exception { } } if (!testAlphaExists) { - service.createQueue(new Queue("TestAlpha")); + service.createQueue(new QueueInfo("TestAlpha")); } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 5874952f7b2e1..906e43cbc335a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -20,7 +20,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; import com.microsoft.windowsazure.services.serviceBus.models.Message; -import com.microsoft.windowsazure.services.serviceBus.models.Queue; +import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; @@ -43,7 +43,7 @@ public void fetchQueueAndListQueuesWorks() throws Exception { // Arrange // Act - Queue entry = service.getQueue("TestAlpha").getValue(); + QueueInfo entry = service.getQueue("TestAlpha").getValue(); ListQueuesResult feed = service.listQueues(); // Assert @@ -56,8 +56,8 @@ public void createQueueWorks() throws Exception { // Arrange // Act - Queue queue = new Queue("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); - Queue saved = service.createQueue(queue).getValue(); + QueueInfo queue = new QueueInfo("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); + QueueInfo saved = service.createQueue(queue).getValue(); // Assert assertNotNull(saved); @@ -68,7 +68,7 @@ public void createQueueWorks() throws Exception { @Test public void deleteQueueWorks() throws Exception { // Arrange - service.createQueue(new Queue("TestDeleteQueueWorks")); + service.createQueue(new QueueInfo("TestDeleteQueueWorks")); // Act service.deleteQueue("TestDeleteQueueWorks"); @@ -91,7 +91,7 @@ public void sendMessageWorks() throws Exception { public void receiveMessageWorks() throws Exception { // Arrange String queueName = "TestReceiveMessageWorks"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new Message("Hello World")); // Act @@ -108,7 +108,7 @@ public void receiveMessageWorks() throws Exception { public void peekLockMessageWorks() throws Exception { // Arrange String queueName = "TestPeekLockMessageWorks"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); // Act @@ -125,7 +125,7 @@ public void peekLockMessageWorks() throws Exception { public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeCompleted"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); @@ -146,7 +146,7 @@ public void peekLockedMessageCanBeCompleted() throws Exception { public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeUnlocked"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); @@ -168,7 +168,7 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { public void peekLockedMessageCanBeDeleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeDeleted"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); service.sendQueueMessage(queueName, new Message("Hello Again")); Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); @@ -190,7 +190,7 @@ public void peekLockedMessageCanBeDeleted() throws Exception { public void contentTypePassesThrough() throws Exception { // Arrange String queueName = "TestContentTypePassesThrough"; - service.createQueue(new Queue(queueName)); + service.createQueue(new QueueInfo(queueName)); // Act service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); @@ -239,7 +239,7 @@ public Response handle(Request request, Next next) throws Exception { }); // Act - Queue created = filtered.createQueue(new Queue("TestFilterCanSeeAndChangeRequestOrResponse")).getValue(); + QueueInfo created = filtered.createQueue(new QueueInfo("TestFilterCanSeeAndChangeRequestOrResponse")).getValue(); // Assert assertNotNull(created); From c9e504fc64cdfbe21f42000fb6e2ddeae13df32e Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:36:44 -0800 Subject: [PATCH 232/664] Renaming Topic domain data object to TopicInfo SB API review --- .../serviceBus/ServiceBusContract.java | 4 ++-- .../serviceBus/ServiceBusService.java | 4 ++-- .../services/serviceBus/Util.java | 4 ++-- .../ServiceBusExceptionProcessor.java | 4 ++-- .../implementation/ServiceBusRestProxy.java | 12 +++++----- .../serviceBus/models/CreateTopicResult.java | 14 +++++------ .../serviceBus/models/GetTopicResult.java | 14 +++++------ .../serviceBus/models/ListTopicsResult.java | 10 ++++---- .../models/{Topic.java => TopicInfo.java} | 20 ++++++++-------- .../serviceBus/IntegrationTestBase.java | 4 ++-- .../serviceBus/ServiceBusIntegrationTest.java | 24 +++++++++---------- 11 files changed, 57 insertions(+), 57 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/{Topic.java => TopicInfo.java} (90%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index ad002583b5c77..394a25873c685 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -25,7 +25,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; /** * @@ -211,7 +211,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - CreateTopicResult createTopic(Topic topic) throws ServiceException; + CreateTopicResult createTopic(TopicInfo topic) throws ServiceException; /** * Deletes a topic. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 189f78a862a6f..b8f8cd7bee41d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -28,7 +28,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; /** * @@ -306,7 +306,7 @@ public ListQueuesResult listQueues() throws ServiceException { * @exception ServiceException * If a service exception is encountered. */ - public CreateTopicResult createTopic(Topic topic) throws ServiceException { + public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { return next.createTopic(topic); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 21a1bc198cc72..321e5948cc31f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -2,7 +2,7 @@ import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public class Util { public static Iterable iterateQueues(ServiceBusContract service) @@ -11,7 +11,7 @@ public static Iterable iterateQueues(ServiceBusContract service) return service.listQueues().getItems(); } - public static Iterable iterateTopics(ServiceBusContract service) + public static Iterable iterateTopics(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listTopics().getItems(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 2cae759d3f0ca..cec7c56cc1b03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -31,7 +31,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; @@ -206,7 +206,7 @@ public ListQueuesResult listQueues() throws ServiceException { } } - public CreateTopicResult createTopic(Topic topic) throws ServiceException { + public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { try { return next.createTopic(topic); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index b12a1a28b01fc..4818734fe7121 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -37,7 +37,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; @@ -253,11 +253,11 @@ private WebResource listOptions(AbstractListOptions options, WebResource path return path; } - public CreateTopicResult createTopic(Topic entry) throws ServiceException { + public CreateTopicResult createTopic(TopicInfo entry) throws ServiceException { return new CreateTopicResult(getResource() .path(entry.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Topic.class, entry)); + .put(TopicInfo.class, entry)); } public void deleteTopic(String TopicPath) throws ServiceException { @@ -269,16 +269,16 @@ public void deleteTopic(String TopicPath) throws ServiceException { public GetTopicResult getTopic(String TopicPath) throws ServiceException { return new GetTopicResult(getResource() .path(TopicPath) - .get(Topic.class)); + .get(TopicInfo.class)); } public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { Feed feed = listOptions(options, getResource() .path("$Resources/Topics")) .get(Feed.class); - ArrayList Topics = new ArrayList(); + ArrayList Topics = new ArrayList(); for (Entry entry : feed.getEntries()) { - Topics.add(new Topic(entry)); + Topics.add(new TopicInfo(entry)); } ListTopicsResult result = new ListTopicsResult(); result.setItems(Topics); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index ce8b09d04c3ec..263eb7b3e0d1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -5,15 +5,15 @@ */ public class CreateTopicResult { - private Topic value; + private TopicInfo value; /** * Creates an instance of the CreateTopicResult class. * * @param value - * A {@link Topic} object assigned as the value of the result. + * A {@link TopicInfo} object assigned as the value of the result. */ - public CreateTopicResult(Topic value) { + public CreateTopicResult(TopicInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public CreateTopicResult(Topic value) { * Specfies the value of the result. * * @param value - * A {@link Topic} object assigned as the value of the result. + * A {@link TopicInfo} object assigned as the value of the result. */ - public void setValue(Topic value) { + public void setValue(TopicInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Topic} object that represents the value of the result. + * @return A {@link TopicInfo} object that represents the value of the result. */ - public Topic getValue() { + public TopicInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index c2d8a9198e192..bce289b148853 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -5,15 +5,15 @@ */ public class GetTopicResult { - private Topic value; + private TopicInfo value; /** * Creates an instance of the GetTopicResult class. * * @param value - * A {@link Topic} object assigned as the value of the result. + * A {@link TopicInfo} object assigned as the value of the result. */ - public GetTopicResult(Topic value) { + public GetTopicResult(TopicInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public GetTopicResult(Topic value) { * Specfies the value of the result. * * @param value - * A {@link Topic} object assigned as the value of the result. + * A {@link TopicInfo} object assigned as the value of the result. */ - public void setValue(Topic value) { + public void setValue(TopicInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Topic} object that represents the value of the result. + * @return A {@link TopicInfo} object that represents the value of the result. */ - public Topic getValue() { + public TopicInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index 4a1fe1a04fea6..b8eddf1960185 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -7,15 +7,15 @@ */ public class ListTopicsResult { - private List items; + private List items; /** * Returns the items in the result list. * - * @return A List of {@link Topic} objects that represent the + * @return A List of {@link TopicInfo} objects that represent the * items in the result list. */ - public List getItems() { + public List getItems() { return items; } @@ -23,10 +23,10 @@ public List getItems() { * Specfies the items in the result list. * * @param value - * A List object that contains the {@link Topic} + * A List object that contains the {@link TopicInfo} * objects assigned as the value of the result. */ - public void setItems(List items) { + public void setItems(List items) { this.items = items; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index d01cb0bf5413d..27b7cbd659a4a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Topic.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -11,11 +11,11 @@ /** * Represents a topic. */ -public class Topic extends EntryModel { +public class TopicInfo extends EntryModel { /** * Creates an instance of the Topic class. */ - public Topic() { + public TopicInfo() { super(new Entry(), new TopicDescription()); getEntry().setContent(new Content()); getEntry().getContent().setType(MediaType.APPLICATION_XML); @@ -28,7 +28,7 @@ public Topic() { * @param entry * An Entry object that represents the entry for the topic. */ - public Topic(Entry entry) { + public TopicInfo(Entry entry) { super(entry, entry.getContent().getTopicDescription()); } @@ -38,7 +38,7 @@ public Topic(Entry entry) { * @param name * A String object that represents the name for the topic. */ - public Topic(String name) { + public TopicInfo(String name) { this(); setName(name); } @@ -60,7 +60,7 @@ public String getName() { * * @return A Topic object that represents the updated topic. */ - public Topic setName(String value) { + public TopicInfo setName(String value) { getEntry().setTitle(value); return this; } @@ -82,7 +82,7 @@ public Duration getDefaultMessageTimeToLive() { * * @return A Topic object that represents the updated topic. */ - public Topic setDefaultMessageTimeToLive(Duration value) { + public TopicInfo setDefaultMessageTimeToLive(Duration value) { getModel().setDefaultMessageTimeToLive(value); return this; } @@ -104,7 +104,7 @@ public Long getMaxSizeInMegabytes() { * * @return A Topic object that represents the updated topic. */ - public Topic setMaxSizeInMegabytes(Long value) { + public TopicInfo setMaxSizeInMegabytes(Long value) { getModel().setMaxSizeInMegabytes(value); return this; } @@ -126,7 +126,7 @@ public Boolean isRequiresDuplicateDetection() { * * @return A Topic object that represents the updated topic. */ - public Topic setRequiresDuplicateDetection(Boolean value) { + public TopicInfo setRequiresDuplicateDetection(Boolean value) { getModel().setRequiresDuplicateDetection(value); return this; } @@ -149,7 +149,7 @@ public Duration getDuplicateDetectionHistoryTimeWindow() { * * @return A Topic object that represents the updated topic. */ - public Topic setDuplicateDetectionHistoryTimeWindow(Duration value) { + public TopicInfo setDuplicateDetectionHistoryTimeWindow(Duration value) { getModel().setDuplicateDetectionHistoryTimeWindow(value); return this; } @@ -171,7 +171,7 @@ public Boolean isEnableBatchedOperations() { * * @return A Topic object that represents the updated topic. */ - public Topic setEnableBatchedOperations(Boolean value) { + public TopicInfo setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 53926858d8d1d..b6c3d2b70425d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -7,7 +7,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public abstract class IntegrationTestBase { @BeforeClass @@ -42,7 +42,7 @@ public void initialize() throws Exception { } } } - for (Topic topic : iterateTopics(service)) { + for (TopicInfo topic : iterateTopics(service)) { String topicName = topic.getName(); if (topicName.startsWith("Test") || topicName.startsWith("test")) { service.deleteQueue(topicName); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 906e43cbc335a..2769ac8795351 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -24,7 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.Rule; import com.microsoft.windowsazure.services.serviceBus.models.Subscription; -import com.microsoft.windowsazure.services.serviceBus.models.Topic; +import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -208,9 +208,9 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; // Act - Topic created = service.createTopic(new Topic().setName(topicName)).getValue(); + TopicInfo created = service.createTopic(new TopicInfo().setName(topicName)).getValue(); ListTopicsResult listed = service.listTopics(); - Topic fetched = service.getTopic(topicName).getValue(); + TopicInfo fetched = service.getTopic(topicName).getValue(); service.deleteTopic(topicName); ListTopicsResult listed2 = service.listTopics(); @@ -251,7 +251,7 @@ public Response handle(Request request, Next next) throws Exception { public void subscriptionsCanBeCreatedOnTopics() throws Exception { // Arrange String topicName = "TestSubscriptionsCanBeCreatedOnTopics"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); // Act Subscription created = service.createSubscription(topicName, new Subscription("MySubscription")).getValue(); @@ -265,7 +265,7 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { public void subscriptionsCanBeListed() throws Exception { // Arrange String topicName = "TestSubscriptionsCanBeListed"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("MySubscription2")); // Act @@ -281,7 +281,7 @@ public void subscriptionsCanBeListed() throws Exception { public void subscriptionsDetailsMayBeFetched() throws Exception { // Arrange String topicName = "TestSubscriptionsDetailsMayBeFetched"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("MySubscription3")); // Act @@ -296,7 +296,7 @@ public void subscriptionsDetailsMayBeFetched() throws Exception { public void subscriptionsMayBeDeleted() throws Exception { // Arrange String topicName = "TestSubscriptionsMayBeDeleted"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("MySubscription4")); service.createSubscription(topicName, new Subscription("MySubscription5")); @@ -314,7 +314,7 @@ public void subscriptionsMayBeDeleted() throws Exception { public void subscriptionWillReceiveMessage() throws Exception { // Arrange String topicName = "TestSubscriptionWillReceiveMessage"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("sub")); service.sendTopicMessage(topicName, new Message("

Testing subscription

").setContentType("text/html")); @@ -334,7 +334,7 @@ public void subscriptionWillReceiveMessage() throws Exception { public void rulesCanBeCreatedOnSubscriptions() throws Exception { // Arrange String topicName = "TestrulesCanBeCreatedOnSubscriptions"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("sub")); // Act @@ -349,7 +349,7 @@ public void rulesCanBeCreatedOnSubscriptions() throws Exception { public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { // Arrange String topicName = "TestrulesCanBeListedAndDefaultRuleIsPrecreated"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("sub")); service.createRule(topicName, "sub", new Rule("MyRule2")); @@ -376,7 +376,7 @@ public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { public void ruleDetailsMayBeFetched() throws Exception { // Arrange String topicName = "TestruleDetailsMayBeFetched"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("sub")); // Act @@ -391,7 +391,7 @@ public void ruleDetailsMayBeFetched() throws Exception { public void rulesMayBeDeleted() throws Exception { // Arrange String topicName = "TestRulesMayBeDeleted"; - service.createTopic(new Topic(topicName)); + service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new Subscription("sub")); service.createRule(topicName, "sub", new Rule("MyRule4")); service.createRule(topicName, "sub", new Rule("MyRule5")); From de0fba4d1d45a7993bb7cff6ab5d88df117a6074 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:37:24 -0800 Subject: [PATCH 233/664] Renaming Subscription domain data object to SubscriptionInfo SB API review --- .../serviceBus/ServiceBusContract.java | 4 +-- .../serviceBus/ServiceBusService.java | 4 +-- .../ServiceBusExceptionProcessor.java | 4 +-- .../implementation/ServiceBusRestProxy.java | 12 ++++----- .../models/CreateSubscriptionResult.java | 14 +++++----- .../models/GetSubscriptionResult.java | 14 +++++----- .../models/ListSubscriptionsResult.java | 10 +++---- ...ubscription.java => SubscriptionInfo.java} | 26 +++++++++---------- .../serviceBus/ServiceBusIntegrationTest.java | 24 ++++++++--------- 9 files changed, 56 insertions(+), 56 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/{Subscription.java => SubscriptionInfo.java} (90%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 394a25873c685..9dd6079abb0fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -24,7 +24,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; -import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; /** @@ -262,7 +262,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) throws ServiceException; + CreateSubscriptionResult createSubscription(String topicName, SubscriptionInfo subscription) throws ServiceException; /** * Deletes a subscription. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index b8f8cd7bee41d..a76956daa7696 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -27,7 +27,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; -import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; /** @@ -363,7 +363,7 @@ public ListTopicsResult listTopics() throws ServiceException { * @exception ServiceException * If a service exception is encountered. */ - public CreateSubscriptionResult createSubscription(String topicName, Subscription subscription) + public CreateSubscriptionResult createSubscription(String topicName, SubscriptionInfo subscription) throws ServiceException { return next.createSubscription(topicName, subscription); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index cec7c56cc1b03..52ffc756e4075 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -30,7 +30,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; -import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; @@ -254,7 +254,7 @@ public ListTopicsResult listTopics() throws ServiceException { } } - public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) + public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) throws ServiceException { try { return next.createSubscription(topicPath, subscription); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 4818734fe7121..79df2b154535f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -36,7 +36,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.Rule; -import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; @@ -285,13 +285,13 @@ public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceExce return result; } - public CreateSubscriptionResult createSubscription(String topicPath, Subscription subscription) { + public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { return new CreateSubscriptionResult(getResource() .path(topicPath) .path("subscriptions") .path(subscription.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Subscription.class, subscription)); + .put(SubscriptionInfo.class, subscription)); } public void deleteSubscription(String topicPath, String subscriptionName) { @@ -307,7 +307,7 @@ public GetSubscriptionResult getSubscription(String topicPath, String subscripti .path(topicPath) .path("subscriptions") .path(subscriptionName) - .get(Subscription.class)); + .get(SubscriptionInfo.class)); } public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) { @@ -315,9 +315,9 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript .path(topicPath) .path("subscriptions")) .get(Feed.class); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { - list.add(new Subscription(entry)); + list.add(new SubscriptionInfo(entry)); } ListSubscriptionsResult result = new ListSubscriptionsResult(); result.setItems(list); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 668d696d80657..87b495c4aaebe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -5,15 +5,15 @@ */ public class CreateSubscriptionResult { - private Subscription value; + private SubscriptionInfo value; /** * Creates an instance of the CreateSubscriptionResult class. * * @param value - * A {@link Subscription} object assigned as the value of the result. + * A {@link SubscriptionInfo} object assigned as the value of the result. */ - public CreateSubscriptionResult(Subscription value) { + public CreateSubscriptionResult(SubscriptionInfo value) { this.setValue(value); } @@ -21,19 +21,19 @@ public CreateSubscriptionResult(Subscription value) { * Specfies the value of the result. * * @param value - * A {@link Subscription} object assigned as the value of the + * A {@link SubscriptionInfo} object assigned as the value of the * result. */ - public void setValue(Subscription value) { + public void setValue(SubscriptionInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Subscription} object that represents the value of the result. + * @return A {@link SubscriptionInfo} object that represents the value of the result. */ - public Subscription getValue() { + public SubscriptionInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index adb72db33bfaa..b8519fd8150ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -5,16 +5,16 @@ */ public class GetSubscriptionResult { - private Subscription value; + private SubscriptionInfo value; /** * Creates an instance of the GetSubscriptionResult class. * * @param value - * A {@link Subscription} object assigned as the value of the + * A {@link SubscriptionInfo} object assigned as the value of the * result. */ - public GetSubscriptionResult(Subscription value) { + public GetSubscriptionResult(SubscriptionInfo value) { this.setValue(value); } @@ -22,20 +22,20 @@ public GetSubscriptionResult(Subscription value) { * Specfies the value of the result. * * @param value - * A {@link Subscription} object assigned as the value of the + * A {@link SubscriptionInfo} object assigned as the value of the * result. */ - public void setValue(Subscription value) { + public void setValue(SubscriptionInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Subscription} object that represents the value of the + * @return A {@link SubscriptionInfo} object that represents the value of the * result. */ - public Subscription getValue() { + public SubscriptionInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 9bfcd91abec14..574bb74fa826e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -7,15 +7,15 @@ */ public class ListSubscriptionsResult { - private List items; + private List items; /** * Returns the items in the result list. * - * @return A List of {@link Subscription} objects that represent the + * @return A List of {@link SubscriptionInfo} objects that represent the * items in the result list. */ - public List getItems() { + public List getItems() { return items; } @@ -23,10 +23,10 @@ public List getItems() { * Specfies the items in the result list. * * @param value - * A List object that contains the {@link Subscription} + * A List object that contains the {@link SubscriptionInfo} * objects assigned as the value of the result. */ - public void setItems(List items) { + public void setItems(List items) { this.items = items; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 1af7f72d7f07e..3c9aec8974c3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Subscription.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -12,12 +12,12 @@ /** * Represents a subscription. */ -public class Subscription extends EntryModel { +public class SubscriptionInfo extends EntryModel { /** * Creates an instance of the Subscription class. */ - public Subscription() { + public SubscriptionInfo() { super(new Entry(), new SubscriptionDescription()); getEntry().setContent(new Content()); getEntry().getContent().setType(MediaType.APPLICATION_XML); @@ -30,7 +30,7 @@ public Subscription() { * @param entry * An Entry object. */ - public Subscription(Entry entry) { + public SubscriptionInfo(Entry entry) { super(entry, entry.getContent().getSubscriptionDescription()); } @@ -40,7 +40,7 @@ public Subscription(Entry entry) { * @param name * A String object that represents the name of the subscription. */ - public Subscription(String name) { + public SubscriptionInfo(String name) { this(); setName(name); } @@ -62,7 +62,7 @@ public String getName() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setName(String value) { + public SubscriptionInfo setName(String value) { getEntry().setTitle(value); return this; } @@ -84,7 +84,7 @@ public Duration getLockDuration() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setLockDuration(Duration value) { + public SubscriptionInfo setLockDuration(Duration value) { getModel().setLockDuration(value); return this; } @@ -106,7 +106,7 @@ public Boolean isRequiresSession() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setRequiresSession(Boolean value) { + public SubscriptionInfo setRequiresSession(Boolean value) { getModel().setRequiresSession(value); return this; } @@ -129,7 +129,7 @@ public Duration getDefaultMessageTimeToLive() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setDefaultMessageTimeToLive(Duration value) { + public SubscriptionInfo setDefaultMessageTimeToLive(Duration value) { getModel().setDefaultMessageTimeToLive(value); return this; } @@ -151,7 +151,7 @@ public Boolean isDeadLetteringOnMessageExpiration() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setDeadLetteringOnMessageExpiration(Boolean value) { + public SubscriptionInfo setDeadLetteringOnMessageExpiration(Boolean value) { getModel().setDeadLetteringOnMessageExpiration(value); return this; } @@ -173,7 +173,7 @@ public Boolean isDeadLetteringOnFilterEvaluationExceptions() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setDeadLetteringOnFilterEvaluationExceptions(Boolean value) { + public SubscriptionInfo setDeadLetteringOnFilterEvaluationExceptions(Boolean value) { getModel().setDeadLetteringOnFilterEvaluationExceptions(value); return this; } @@ -195,7 +195,7 @@ public RuleDescription getDefaultRuleDescription() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setDefaultRuleDescription(RuleDescription value) { + public SubscriptionInfo setDefaultRuleDescription(RuleDescription value) { getModel().setDefaultRuleDescription(value); return this; } @@ -227,7 +227,7 @@ public Integer getMaxDeliveryCount() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setMaxDeliveryCount(Integer value) { + public SubscriptionInfo setMaxDeliveryCount(Integer value) { getModel().setMaxDeliveryCount(value); return this; } @@ -249,7 +249,7 @@ public Boolean isEnableBatchedOperations() { * * @return A Subscription object that represents the updated subscription. */ - public Subscription setEnableBatchedOperations(Boolean value) { + public SubscriptionInfo setEnableBatchedOperations(Boolean value) { getModel().setEnableBatchedOperations(value); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 2769ac8795351..04fe9a6165608 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -23,7 +23,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.Rule; -import com.microsoft.windowsazure.services.serviceBus.models.Subscription; +import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -254,7 +254,7 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { service.createTopic(new TopicInfo(topicName)); // Act - Subscription created = service.createSubscription(topicName, new Subscription("MySubscription")).getValue(); + SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription")).getValue(); // Assert assertNotNull(created); @@ -266,7 +266,7 @@ public void subscriptionsCanBeListed() throws Exception { // Arrange String topicName = "TestSubscriptionsCanBeListed"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("MySubscription2")); + service.createSubscription(topicName, new SubscriptionInfo("MySubscription2")); // Act ListSubscriptionsResult result = service.listSubscriptions(topicName); @@ -282,10 +282,10 @@ public void subscriptionsDetailsMayBeFetched() throws Exception { // Arrange String topicName = "TestSubscriptionsDetailsMayBeFetched"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("MySubscription3")); + service.createSubscription(topicName, new SubscriptionInfo("MySubscription3")); // Act - Subscription result = service.getSubscription(topicName, "MySubscription3").getValue(); + SubscriptionInfo result = service.getSubscription(topicName, "MySubscription3").getValue(); // Assert assertNotNull(result); @@ -297,8 +297,8 @@ public void subscriptionsMayBeDeleted() throws Exception { // Arrange String topicName = "TestSubscriptionsMayBeDeleted"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("MySubscription4")); - service.createSubscription(topicName, new Subscription("MySubscription5")); + service.createSubscription(topicName, new SubscriptionInfo("MySubscription4")); + service.createSubscription(topicName, new SubscriptionInfo("MySubscription5")); // Act service.deleteSubscription(topicName, "MySubscription4"); @@ -315,7 +315,7 @@ public void subscriptionWillReceiveMessage() throws Exception { // Arrange String topicName = "TestSubscriptionWillReceiveMessage"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("sub")); + service.createSubscription(topicName, new SubscriptionInfo("sub")); service.sendTopicMessage(topicName, new Message("

Testing subscription

").setContentType("text/html")); // Act @@ -335,7 +335,7 @@ public void rulesCanBeCreatedOnSubscriptions() throws Exception { // Arrange String topicName = "TestrulesCanBeCreatedOnSubscriptions"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("sub")); + service.createSubscription(topicName, new SubscriptionInfo("sub")); // Act Rule created = service.createRule(topicName, "sub", new Rule("MyRule1")).getValue(); @@ -350,7 +350,7 @@ public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { // Arrange String topicName = "TestrulesCanBeListedAndDefaultRuleIsPrecreated"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("sub")); + service.createSubscription(topicName, new SubscriptionInfo("sub")); service.createRule(topicName, "sub", new Rule("MyRule2")); // Act @@ -377,7 +377,7 @@ public void ruleDetailsMayBeFetched() throws Exception { // Arrange String topicName = "TestruleDetailsMayBeFetched"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("sub")); + service.createSubscription(topicName, new SubscriptionInfo("sub")); // Act Rule result = service.getRule(topicName, "sub", "$Default").getValue(); @@ -392,7 +392,7 @@ public void rulesMayBeDeleted() throws Exception { // Arrange String topicName = "TestRulesMayBeDeleted"; service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new Subscription("sub")); + service.createSubscription(topicName, new SubscriptionInfo("sub")); service.createRule(topicName, "sub", new Rule("MyRule4")); service.createRule(topicName, "sub", new Rule("MyRule5")); From 1642d7a930f99d615a86c7f7c2700c0556b1af85 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:38:31 -0800 Subject: [PATCH 234/664] Renaming Rule domain data object to RuleInfo. fixes #95 SB API review --- .../serviceBus/ServiceBusContract.java | 4 ++-- .../services/serviceBus/ServiceBusService.java | 4 ++-- .../ServiceBusExceptionProcessor.java | 4 ++-- .../implementation/ServiceBusRestProxy.java | 12 ++++++------ .../serviceBus/models/CreateRuleResult.java | 14 +++++++------- .../serviceBus/models/GetRuleResult.java | 14 +++++++------- .../serviceBus/models/ListRulesResult.java | 10 +++++----- .../models/{Rule.java => RuleInfo.java} | 14 +++++++------- .../serviceBus/ServiceBusIntegrationTest.java | 18 +++++++++--------- 9 files changed, 47 insertions(+), 47 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/{Rule.java => RuleInfo.java} (91%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 9dd6079abb0fa..063af322bc021 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -23,7 +23,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.Rule; +import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; @@ -326,7 +326,7 @@ ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOpt * @exception ServiceException * If a service exception is encountered. */ - CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException; + CreateRuleResult createRule(String topicName, String subscriptionName, RuleInfo rule) throws ServiceException; /** * Deletes a rule. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index a76956daa7696..24f988250c0e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -26,7 +26,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.Rule; +import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; @@ -433,7 +433,7 @@ public ListSubscriptionsResult listSubscriptions(String topicName) throws Servic * @exception ServiceException * If a service exception is encountered. */ - public CreateRuleResult createRule(String topicName, String subscriptionName, Rule rule) throws ServiceException { + public CreateRuleResult createRule(String topicName, String subscriptionName, RuleInfo rule) throws ServiceException { return next.createRule(topicName, subscriptionName, rule); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 52ffc756e4075..9b4efbbd67faf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -29,7 +29,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.Rule; +import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; @@ -303,7 +303,7 @@ public ListSubscriptionsResult listSubscriptions(String topicPath) throws Servic } } - public CreateRuleResult createRule(String topicPath, String subscriptionName, Rule rule) throws ServiceException { + public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) throws ServiceException { try { return next.createRule(topicPath, subscriptionName, rule); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 79df2b154535f..3d40ae29ce2aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -35,7 +35,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.Rule; +import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; import com.microsoft.windowsazure.common.ServiceException; @@ -325,7 +325,7 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript } public CreateRuleResult createRule(String topicPath, String subscriptionName, - Rule rule) { + RuleInfo rule) { return new CreateRuleResult(getResource() .path(topicPath) .path("subscriptions") @@ -333,7 +333,7 @@ public CreateRuleResult createRule(String topicPath, String subscriptionName, .path("rules") .path(rule.getName()) .type("application/atom+xml;type=entry;charset=utf-8") - .put(Rule.class, rule)); + .put(RuleInfo.class, rule)); } public void deleteRule(String topicPath, String subscriptionName, @@ -355,7 +355,7 @@ public GetRuleResult getRule(String topicPath, String subscriptionName, .path(subscriptionName) .path("rules") .path(ruleName) - .get(Rule.class)); + .get(RuleInfo.class)); } public ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) { @@ -365,9 +365,9 @@ public ListRulesResult listRules(String topicPath, String subscriptionName, List .path(subscriptionName) .path("rules")) .get(Feed.class); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { - list.add(new Rule(entry)); + list.add(new RuleInfo(entry)); } ListRulesResult result = new ListRulesResult(); result.setItems(list); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index e9de6d7a26fce..26811f17116b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -5,15 +5,15 @@ */ public class CreateRuleResult { - private Rule value; + private RuleInfo value; /** * Creates an instance of the CreateRuleResult class. * * @param value - * A {@link Rule} object assigned as the value of the result. + * A {@link RuleInfo} object assigned as the value of the result. */ - public CreateRuleResult(Rule value) { + public CreateRuleResult(RuleInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public CreateRuleResult(Rule value) { * Specfies the value of the result. * * @param value - * A {@link Rule} object assigned as the value of the result. + * A {@link RuleInfo} object assigned as the value of the result. */ - public void setValue(Rule value) { + public void setValue(RuleInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Rule} object that represents the value of the result. + * @return A {@link RuleInfo} object that represents the value of the result. */ - public Rule getValue() { + public RuleInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java index b366687050154..b45b4f4c5722b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -5,15 +5,15 @@ */ public class GetRuleResult { - private Rule value; + private RuleInfo value; /** * Creates an instance of the GetRuleResult class. * * @param value - * A {@link Rule} object assigned as the value of the result. + * A {@link RuleInfo} object assigned as the value of the result. */ - public GetRuleResult(Rule value) { + public GetRuleResult(RuleInfo value) { this.setValue(value); } @@ -21,18 +21,18 @@ public GetRuleResult(Rule value) { * Specfies the value of the result. * * @param value - * A {@link Rule} object assigned as the value of the result. + * A {@link RuleInfo} object assigned as the value of the result. */ - public void setValue(Rule value) { + public void setValue(RuleInfo value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Rule} object that represents the value of the result. + * @return A {@link RuleInfo} object that represents the value of the result. */ - public Rule getValue() { + public RuleInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java index b35f96252c23a..61db6d2fea0a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -7,15 +7,15 @@ */ public class ListRulesResult { - private List items; + private List items; /** * Returns the items in the result list. * - * @return A List of {@link Rule} objects that represent the + * @return A List of {@link RuleInfo} objects that represent the * items in the result list. */ - public List getItems() { + public List getItems() { return items; } @@ -23,10 +23,10 @@ public List getItems() { * Specfies the items in the result list. * * @param value - * A List object that contains the {@link Rule} + * A List object that contains the {@link RuleInfo} * objects assigned as the value of the result. */ - public void setItems(List items) { + public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java index 8d0bcca44b820..5af2e81a77a66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/Rule.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java @@ -12,12 +12,12 @@ /** * Represents a rule. */ -public class Rule extends EntryModel { +public class RuleInfo extends EntryModel { /** * Creates an instance of the Rule class. */ - public Rule() { + public RuleInfo() { super(new Entry(), new RuleDescription()); getEntry().setContent(new Content()); getEntry().getContent().setType(MediaType.APPLICATION_XML); @@ -31,7 +31,7 @@ public Rule() { * An Entry object. * */ - public Rule(Entry entry) { + public RuleInfo(Entry entry) { super(entry, entry.getContent().getRuleDescription()); } @@ -42,7 +42,7 @@ public Rule(Entry entry) { * A String object that represents the name of the rule. * */ - public Rule(String name) { + public RuleInfo(String name) { this(); setName(name); } @@ -64,7 +64,7 @@ public String getName() { * * @return A Rule object that represents the updated rule. */ - public Rule setName(String value) { + public RuleInfo setName(String value) { getEntry().setTitle(value); return this; } @@ -86,7 +86,7 @@ public Filter getFilter() { * * @return A Rule object that represents the updated rule. */ - public Rule setFilter(Filter value) { + public RuleInfo setFilter(Filter value) { getModel().setFilter(value); return this; } @@ -108,7 +108,7 @@ public RuleAction getAction() { * * @return A Rule object that represents the updated rule. */ - public Rule setAction(RuleAction value) { + public RuleInfo setAction(RuleAction value) { getModel().setAction(value); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 04fe9a6165608..4104d8925d853 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -22,7 +22,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.Message; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.Rule; +import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; @@ -338,7 +338,7 @@ public void rulesCanBeCreatedOnSubscriptions() throws Exception { service.createSubscription(topicName, new SubscriptionInfo("sub")); // Act - Rule created = service.createRule(topicName, "sub", new Rule("MyRule1")).getValue(); + RuleInfo created = service.createRule(topicName, "sub", new RuleInfo("MyRule1")).getValue(); // Assert assertNotNull(created); @@ -351,7 +351,7 @@ public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { String topicName = "TestrulesCanBeListedAndDefaultRuleIsPrecreated"; service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.createRule(topicName, "sub", new Rule("MyRule2")); + service.createRule(topicName, "sub", new RuleInfo("MyRule2")); // Act ListRulesResult result = service.listRules(topicName, "sub"); @@ -359,10 +359,10 @@ public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { // Assert assertNotNull(result); assertEquals(2, result.getItems().size()); - Rule rule0 = result.getItems().get(0); - Rule rule1 = result.getItems().get(1); + RuleInfo rule0 = result.getItems().get(0); + RuleInfo rule1 = result.getItems().get(1); if (rule0.getName() == "MyRule2") { - Rule swap = rule1; + RuleInfo swap = rule1; rule1 = rule0; rule0 = swap; } @@ -380,7 +380,7 @@ public void ruleDetailsMayBeFetched() throws Exception { service.createSubscription(topicName, new SubscriptionInfo("sub")); // Act - Rule result = service.getRule(topicName, "sub", "$Default").getValue(); + RuleInfo result = service.getRule(topicName, "sub", "$Default").getValue(); // Assert assertNotNull(result); @@ -393,8 +393,8 @@ public void rulesMayBeDeleted() throws Exception { String topicName = "TestRulesMayBeDeleted"; service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.createRule(topicName, "sub", new Rule("MyRule4")); - service.createRule(topicName, "sub", new Rule("MyRule5")); + service.createRule(topicName, "sub", new RuleInfo("MyRule4")); + service.createRule(topicName, "sub", new RuleInfo("MyRule5")); // Act service.deleteRule(topicName, "sub", "MyRule5"); From ae0ef6ed6c4c623eb45ab5ff8e5ec60a00ee4fec Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:41:29 -0800 Subject: [PATCH 235/664] Renaming Message domain data object to BrokeredMessage. fixes #108 SB API review --- .../serviceBus/ServiceBusContract.java | 10 ++--- .../serviceBus/ServiceBusService.java | 10 ++--- .../ServiceBusExceptionProcessor.java | 10 ++--- .../implementation/ServiceBusRestProxy.java | 20 +++++----- .../{Message.java => BrokeredMessage.java} | 38 +++++++++---------- .../models/ReceiveQueueMessageResult.java | 14 +++---- .../ReceiveSubscriptionMessageResult.java | 14 +++---- .../serviceBus/ServiceBusIntegrationTest.java | 36 +++++++++--------- 8 files changed, 76 insertions(+), 76 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/{Message.java => BrokeredMessage.java} (90%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 063af322bc021..c5b4a7a7441ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -18,7 +18,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; @@ -45,7 +45,7 @@ public interface ServiceBusContract extends FilterableServiceMessage class. */ - public Message() { + public BrokeredMessage() { this.properties = new BrokerProperties(); } @@ -28,7 +28,7 @@ public Message() { * @param body * An InputStream object that represents the body of the message. */ - public Message(InputStream body) { + public BrokeredMessage(InputStream body) { this.properties = new BrokerProperties(); this.body = body; } @@ -39,7 +39,7 @@ public Message(InputStream body) { * @param body * A byte array that represents the body of the message. */ - public Message(byte[] body) { + public BrokeredMessage(byte[] body) { this.properties = new BrokerProperties(); this.body = (body == null) ? null : new ByteArrayInputStream(body); } @@ -51,12 +51,12 @@ public Message(byte[] body) { * @param body * A String object that represents the body of the message. */ - public Message(String body) { + public BrokeredMessage(String body) { this.properties = new BrokerProperties(); this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); } - Message(BrokerProperties properties, InputStream body) { + BrokeredMessage(BrokerProperties properties, InputStream body) { this.properties = properties; this.body = body; } @@ -76,7 +76,7 @@ public BrokerProperties getProperties() { * @param properties * A {@link BrokerProperties} object that represents the properties of the message. */ - public Message setProperties(BrokerProperties properties) { + public BrokeredMessage setProperties(BrokerProperties properties) { this.properties = properties; return this; } @@ -98,7 +98,7 @@ public InputStream getBody() { * * @return A Message object that represents the updated message. */ - public Message setBody(InputStream body) { + public BrokeredMessage setBody(InputStream body) { this.body = body; return this; } @@ -120,7 +120,7 @@ public String getContentType() { * * @return A Message object that represents the updated message. */ - public Message setContentType(String contentType) { + public BrokeredMessage setContentType(String contentType) { this.contentType = contentType; return this; } @@ -142,7 +142,7 @@ public Date getDate() { * * @return A Message object that represents the updated message. */ - public Message setDate(Date date) { + public BrokeredMessage setDate(Date date) { this.date = date; return this; } @@ -173,7 +173,7 @@ public String getMessageId() { * * @return A Message object that represents the updated message. */ - public Message setMessageId(String messageId) { + public BrokeredMessage setMessageId(String messageId) { properties.setMessageId(messageId); return this; } @@ -205,7 +205,7 @@ public Double getTimeToLive() { * * @return A Message object that represents the updated message. */ - public Message setTimeToLive(Double timeToLive) { + public BrokeredMessage setTimeToLive(Double timeToLive) { properties.setTimeToLive(timeToLive); return this; } @@ -246,7 +246,7 @@ public String getCorrelationId() { * * @return A Message object that represents the updated message. */ - public Message setCorrelationId(String correlationId) { + public BrokeredMessage setCorrelationId(String correlationId) { properties.setCorrelationId(correlationId); return this; } @@ -269,7 +269,7 @@ public String getSessionId() { * * @return A Message object that represents the updated message. */ - public Message setSessionId(String sessionId) { + public BrokeredMessage setSessionId(String sessionId) { properties.setSessionId(sessionId); return this; } @@ -291,7 +291,7 @@ public String getLabel() { * * @return A Message object that represents the updated message. */ - public Message setLabel(String label) { + public BrokeredMessage setLabel(String label) { properties.setLabel(label); return this; } @@ -313,7 +313,7 @@ public String getReplyTo() { * * @return A Message object that represents the updated message. */ - public Message setReplyTo(String replyTo) { + public BrokeredMessage setReplyTo(String replyTo) { properties.setReplyTo(replyTo); return this; } @@ -335,7 +335,7 @@ public String getTo() { * * @return A Message object that represents the updated message. */ - public Message setTo(String to) { + public BrokeredMessage setTo(String to) { properties.setTo(to); return this; } @@ -357,7 +357,7 @@ public Date getScheduledEnqueueTimeUtc() { * * @return A Message object that represents the updated message. */ - public Message setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { + public BrokeredMessage setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); return this; } @@ -379,7 +379,7 @@ public String getReplyToSessionId() { * * @return A Message object that represents the updated message. */ - public Message setReplyToSessionId(String replyToSessionId) { + public BrokeredMessage setReplyToSessionId(String replyToSessionId) { properties.setReplyToSessionId(replyToSessionId); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java index 1357f740ab2ef..14752de848adc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -5,15 +5,15 @@ */ public class ReceiveQueueMessageResult { - private Message value; + private BrokeredMessage value; /** * Creates an instance of the ReceiveQueueMessageResult class. * * @param value - * A {@link Message} object assigned as the value of the result. + * A {@link BrokeredMessage} object assigned as the value of the result. */ - public ReceiveQueueMessageResult(Message value) { + public ReceiveQueueMessageResult(BrokeredMessage value) { this.setValue(value); } @@ -21,18 +21,18 @@ public ReceiveQueueMessageResult(Message value) { * Specifies the value of the result. * * @param value - * A {@link Message} object assigned as the value of the result. + * A {@link BrokeredMessage} object assigned as the value of the result. */ - public void setValue(Message value) { + public void setValue(BrokeredMessage value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Message} object that represents the value of the result. + * @return A {@link BrokeredMessage} object that represents the value of the result. */ - public Message getValue() { + public BrokeredMessage getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java index dcef5ecdc3da6..6db761ffcfd35 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -5,15 +5,15 @@ */ public class ReceiveSubscriptionMessageResult { - private Message value; + private BrokeredMessage value; /** * Creates an instance of the ReceiveSubscriptionMessageResult class. * * @param value - * A {@link Message} object assigned as the value of the result. + * A {@link BrokeredMessage} object assigned as the value of the result. */ - public ReceiveSubscriptionMessageResult(Message value) { + public ReceiveSubscriptionMessageResult(BrokeredMessage value) { this.setValue(value); } @@ -21,18 +21,18 @@ public ReceiveSubscriptionMessageResult(Message value) { * Specifies the value of the result. * * @param value - * A {@link Message} object assigned as the value of the result. + * A {@link BrokeredMessage} object assigned as the value of the result. */ - public void setValue(Message value) { + public void setValue(BrokeredMessage value) { this.value = value; } /** * Returns the value of the result. * - * @return A {@link Message} object that represents the value of the result. + * @return A {@link BrokeredMessage} object that represents the value of the result. */ - public Message getValue() { + public BrokeredMessage getValue() { return value; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 4104d8925d853..b9d37074461f8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -19,7 +19,7 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.Message; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; @@ -79,7 +79,7 @@ public void deleteQueueWorks() throws Exception { @Test public void sendMessageWorks() throws Exception { // Arrange - Message message = new Message("sendMessageWorks"); + BrokeredMessage message = new BrokeredMessage("sendMessageWorks"); // Act service.sendQueueMessage("TestAlpha", message); @@ -92,10 +92,10 @@ public void receiveMessageWorks() throws Exception { // Arrange String queueName = "TestReceiveMessageWorks"; service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new Message("Hello World")); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); // Act - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); byte[] data = new byte[100]; int size = message.getBody().read(data); @@ -109,10 +109,10 @@ public void peekLockMessageWorks() throws Exception { // Arrange String queueName = "TestPeekLockMessageWorks"; service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); // Act - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); + BrokeredMessage message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Assert byte[] data = new byte[100]; @@ -126,8 +126,8 @@ public void peekLockedMessageCanBeCompleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeCompleted"; service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); + BrokeredMessage message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = message.getLockToken(); @@ -147,15 +147,15 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeUnlocked"; service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); + BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.unlockMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(lockToken); @@ -169,15 +169,15 @@ public void peekLockedMessageCanBeDeleted() throws Exception { // Arrange String queueName = "TestPeekLockedMessageCanBeDeleted"; service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new Message("Hello Again")); - Message peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); + BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); // Act String lockToken = peekedMessage.getLockToken(); Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.deleteMessage(peekedMessage); - Message receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(lockToken); @@ -193,9 +193,9 @@ public void contentTypePassesThrough() throws Exception { service.createQueue(new QueueInfo(queueName)); // Act - service.sendQueueMessage(queueName, new Message("Hello Again").setContentType("text/xml")); + service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again").setContentType("text/xml")); - Message message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(message); @@ -316,10 +316,10 @@ public void subscriptionWillReceiveMessage() throws Exception { String topicName = "TestSubscriptionWillReceiveMessage"; service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.sendTopicMessage(topicName, new Message("

Testing subscription

").setContentType("text/html")); + service.sendTopicMessage(topicName, new BrokeredMessage("

Testing subscription

").setContentType("text/html")); // Act - Message message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS).getValue(); // Assert assertNotNull(message); From a5edbf305cd4327775225ce3f6cdf24a922e4ba2 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 13:59:18 -0800 Subject: [PATCH 236/664] Change some string parameters from 'name' to 'path'. fixes #96 SB API Review String queueName becomes String queuePath. String queueName becomes String queuePath. QueueInfo.get/setName becomes QueueInfo.get/setPath TopicInfo.get/setName becomes TopicInfo.get/setPath --- .../serviceBus/ServiceBusContract.java | 76 +++++++++---------- .../implementation/ServiceBusRestProxy.java | 4 +- .../services/serviceBus/models/QueueInfo.java | 10 +-- .../services/serviceBus/models/TopicInfo.java | 10 +-- .../serviceBus/IntegrationTestBase.java | 4 +- .../serviceBus/ServiceBusIntegrationTest.java | 4 +- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index c5b4a7a7441ed..6c52fafc82cf2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -37,7 +37,7 @@ public interface ServiceBusContract extends FilterableServiceString object that represents the name of the queue to which the message will be sent. * @param message * A Message object that represents the message to send. @@ -45,12 +45,12 @@ public interface ServiceBusContract extends FilterableServiceString object that represents the name of the queue from which to receive the message. * * @return A ReceiveQueueMessageResult object that represents the result. @@ -59,12 +59,12 @@ public interface ServiceBusContract extends FilterableServiceString object that represents the name of the queue from which to receive the message. * * @param options @@ -75,13 +75,13 @@ public interface ServiceBusContract extends FilterableServiceString object that represents the name of the topic to which the message will be sent. * @param message * A Message object that represents the message to send. @@ -89,13 +89,13 @@ ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOp * @exception ServiceException * If a service exception is encountered. */ - void sendTopicMessage(String topicName, BrokeredMessage message) throws ServiceException; + void sendTopicMessage(String topicPath, BrokeredMessage message) throws ServiceException; /** * Receives a subscription message. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic to receive. * @param subscriptionName * A String object that represents the name of the subscription from the message will be @@ -106,13 +106,13 @@ ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOp * @exception ServiceException * If a service exception is encountered. */ - ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) + ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, String subscriptionName) throws ServiceException; /** * Receives a subscription message using the specified receive message options. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic to receive. * @param subscriptionName * A String object that represents the name of the subscription from the message will be @@ -126,7 +126,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * If a service exception is encountered. * */ - ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, + ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, String subscriptionName, ReceiveMessageOptions options) throws ServiceException; /** @@ -167,18 +167,18 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St /** * Deletes a queue. * - * @param queueName + * @param queuePath * A String object that represents the name of the queue to delete. * * @exception ServiceException * If a service exception is encountered. */ - void deleteQueue(String queueName) throws ServiceException; + void deleteQueue(String queuePath) throws ServiceException; /** * Retrieves a queue. * - * @param queueName + * @param queuePath * A String object that represents the name of the queue to retrieve. * * @return A GetQueueResult object that represents the result. @@ -186,7 +186,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - GetQueueResult getQueue(String queueName) throws ServiceException; + GetQueueResult getQueue(String queuePath) throws ServiceException; /** * Returns a list of queues. @@ -216,18 +216,18 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St /** * Deletes a topic. * - * @param topicName + * @param topicPath * A String object that represents the name of the queue to delete. * * @exception ServiceException * If a service exception is encountered. */ - void deleteTopic(String topicName) throws ServiceException; + void deleteTopic(String topicPath) throws ServiceException; /** * Retrieves a topic. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic to retrieve. * * @return A GetTopicResult object that represents the result. @@ -235,7 +235,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - GetTopicResult getTopic(String topicName) throws ServiceException; + GetTopicResult getTopic(String topicPath) throws ServiceException; /** * Returns a list of topics. @@ -252,7 +252,7 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St /** * Creates a subscription. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscription * A Subscription object that represents the subscription to create. @@ -262,12 +262,12 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - CreateSubscriptionResult createSubscription(String topicName, SubscriptionInfo subscription) throws ServiceException; + CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) throws ServiceException; /** * Deletes a subscription. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * * @param subscriptionName @@ -276,12 +276,12 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - void deleteSubscription(String topicName, String subscriptionName) throws ServiceException; + void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException; /** * Retrieves a subscription. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscriptionName * A String object that represents the name of the subscription to retrieve. @@ -292,12 +292,12 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException; + GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException; /** * Returns a list of subscriptions. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscriptions to retrieve. * * @return A ListSubscriptionsResult object that represents the result. @@ -305,15 +305,15 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, St * @exception ServiceException * If a service exception is encountered. */ - ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException; + ListSubscriptionsResult listSubscriptions(String topicPath) throws ServiceException; - ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) + ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) throws ServiceException; /** * Creates a rule. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscriptionName * A String object that represents the name of the subscription for which the rule will be @@ -326,12 +326,12 @@ ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOpt * @exception ServiceException * If a service exception is encountered. */ - CreateRuleResult createRule(String topicName, String subscriptionName, RuleInfo rule) throws ServiceException; + CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) throws ServiceException; /** * Deletes a rule. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscriptionName * A String object that represents the name of the subscription for which the rule will be @@ -342,12 +342,12 @@ ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOpt * @exception ServiceException * If a service exception is encountered. */ - void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; /** * Retrieves a rule. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscriptionName * A String object that represents the name of the subscription for which the rule will be @@ -360,12 +360,12 @@ ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOpt * @exception ServiceException * If a service exception is encountered. */ - GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException; + GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; /** * Returns a list of rules. * - * @param topicName + * @param topicPath * A String object that represents the name of the topic for the subscription. * @param subscriptionName * A String object that represents the name of the subscription whose rules are being @@ -376,8 +376,8 @@ ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOpt * @exception ServiceException * If a service exception is encountered. */ - ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException; + ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException; - ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) + ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 6ccc3b7df2ec8..2008215a3587a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -213,7 +213,7 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { return new CreateQueueResult(getResource() - .path(entry.getName()) + .path(entry.getPath()) .type("application/atom+xml;type=entry;charset=utf-8") .put(QueueInfo.class, entry)); } @@ -255,7 +255,7 @@ private WebResource listOptions(AbstractListOptions options, WebResource path public CreateTopicResult createTopic(TopicInfo entry) throws ServiceException { return new CreateTopicResult(getResource() - .path(entry.getName()) + .path(entry.getPath()) .type("application/atom+xml;type=entry;charset=utf-8") .put(TopicInfo.class, entry)); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 67d7db2bf4407..60d3df9359859 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -36,12 +36,12 @@ public QueueInfo(Entry entry) { /** * Creates an instance of the Queue class using the specified name. * - * @param name + * @param path * A String object that represents the name of the queue. */ - public QueueInfo(String name) { + public QueueInfo(String path) { this(); - setName(name); + setPath(path); } /** @@ -49,7 +49,7 @@ public QueueInfo(String name) { * * @return A String object that represents the name of the queue. */ - public String getName() { + public String getPath() { return getEntry().getTitle(); } @@ -61,7 +61,7 @@ public String getName() { * * @return A Queue object that represents the updated queue. */ - public QueueInfo setName(String value) { + public QueueInfo setPath(String value) { getEntry().setTitle(value); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 27b7cbd659a4a..332c0a0906d13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -35,12 +35,12 @@ public TopicInfo(Entry entry) { /** * Creates an instance of the Topic class using the specified name. * - * @param name + * @param path * A String object that represents the name for the topic. */ - public TopicInfo(String name) { + public TopicInfo(String path) { this(); - setName(name); + setPath(path); } /** @@ -48,7 +48,7 @@ public TopicInfo(String name) { * * @return A String object that represents the name of the topic. */ - public String getName() { + public String getPath() { return getEntry().getTitle(); } @@ -60,7 +60,7 @@ public String getName() { * * @return A Topic object that represents the updated topic. */ - public TopicInfo setName(String value) { + public TopicInfo setPath(String value) { getEntry().setTitle(value); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index b6c3d2b70425d..f9a5dd11c0c22 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -28,7 +28,7 @@ public void initialize() throws Exception { boolean testAlphaExists = false; ServiceBusContract service = new ServiceBusService(); for (QueueInfo queue : iterateQueues(service)) { - String queueName = queue.getName(); + String queueName = queue.getPath(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { if (queueName.equalsIgnoreCase("TestAlpha")) { testAlphaExists = true; @@ -43,7 +43,7 @@ public void initialize() throws Exception { } } for (TopicInfo topic : iterateTopics(service)) { - String topicName = topic.getName(); + String topicName = topic.getPath(); if (topicName.startsWith("Test") || topicName.startsWith("test")) { service.deleteQueue(topicName); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index b9d37074461f8..9fdbb2e41b64d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -62,7 +62,7 @@ public void createQueueWorks() throws Exception { // Assert assertNotNull(saved); assertNotSame(queue, saved); - assertEquals("TestCreateQueueWorks", saved.getName()); + assertEquals("TestCreateQueueWorks", saved.getPath()); } @Test @@ -208,7 +208,7 @@ public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; // Act - TopicInfo created = service.createTopic(new TopicInfo().setName(topicName)).getValue(); + TopicInfo created = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); ListTopicsResult listed = service.listTopics(); TopicInfo fetched = service.getTopic(topicName).getValue(); service.deleteTopic(topicName); From 5749571c72fa6a97737c36bcf76b35c5aff7502d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 14:12:04 -0800 Subject: [PATCH 237/664] Utilize factory method pattern instead of class. fixes #99 class XxxService should have two methods: static XxxContract create(); static XxxContract create(Configuration config); As a class it will not implement the XxxContract interface. As a class it will not have public constructors. To avoid confusion it will have a private default constructor (this is the Java way of doing "static class") --- .../serviceBus/ServiceBusService.java | 498 +----------------- .../serviceBus/IntegrationTestBase.java | 2 +- .../serviceBus/ServiceBusCreationTest.java | 9 +- .../serviceBus/ServiceBusIntegrationTest.java | 35 +- 4 files changed, 35 insertions(+), 509 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index dfe0ae33517df..a9e1b76630033 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -1,513 +1,35 @@ package com.microsoft.windowsazure.services.serviceBus; -import javax.inject.Inject; - import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; -import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; -import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; /** * - * Provides service bus functionality. + * Access service bus functionality. * */ -public class ServiceBusService implements ServiceBusContract { - final ServiceBusContract next; - - /** - * Creates an instance of the ServiceBusService class. - * - * @exception Exception - * If an exception is encountered. - */ - public ServiceBusService() throws Exception { - this(null, Configuration.getInstance()); - } +public class ServiceBusService { - /** - * Creates an instance of the ServiceBusService class using the specified configuration. - * - * @param config - * A Configuration object that represents the configuration for the service bus service. - * - * @exception Exception - * If an exception is encountered. - */ - public ServiceBusService(Configuration config) throws Exception { - this(null, config); + private ServiceBusService() { + // class is not instantiated } /** - * Creates an instance of the ServiceBusService class using the specified profile. + * Creates an instance of the ServiceBusContract API. * - * @param profile - * A String object that represents the profile for the service bus service. - * - * @exception Exception - * If an exception is encountered. */ - public ServiceBusService(String profile) throws Exception { - this(profile, Configuration.getInstance()); + public static ServiceBusContract create() { + return Configuration.getInstance().create(ServiceBusContract.class); } /** - * Creates an instance of the ServiceBusService class using the specified profile and configuration. - * - * @param profile - * A String object that represents the profile for the service bus service. + * Creates an instance of the ServiceBusContract API using the specified configuration. * * @param config * A Configuration object that represents the configuration for the service bus service. * - * @exception Exception - * If an exception is encountered. - */ - public ServiceBusService(String profile, Configuration config) throws Exception { - next = config.create(profile, ServiceBusService.class); - } - - @Inject - public ServiceBusService(ServiceBusContract next) throws Exception { - this.next = next; - } - - /** - * Returns a service bus contract with the specified filter. - * - * @param filter - * A ServiceFilter object that represents the filter to use. - * - * @return A ServiceBusContract object that represents the service bus contract with the - * specified filter applied. - */ - public ServiceBusContract withFilter(ServiceFilter filter) { - return next.withFilter(filter); - } - - /** - * Sends a queue message. - * - * @param queueName - * A String object that represents the name of the queue to which the message will be sent. - * @param message - * A Message object that represents the message to send. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void sendQueueMessage(String queueName, BrokeredMessage message) throws ServiceException { - next.sendQueueMessage(queueName, message); - } - - /** - * Receives a queue message. - * - * @param queueName - * A String object that represents the name of the queue from which to receive the message. - * - * @return A ReceiveQueueMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { - return next.receiveQueueMessage(queueName); - } - - /** - * Receives a queue message using the specified receive message options. - * - * @param queueName - * A String object that represents the name of the queue from which to receive the message. - * - * @param options - * A ReceiveMessageOptions object that represents the receive message options. - * - * @return A ReceiveQueueMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) - throws ServiceException { - return next.receiveQueueMessage(queueName, options); - } - - /** - * Sends a topic message. - * - * @param topicName - * A String object that represents the name of the topic to which the message will be sent. - * @param message - * A Message object that represents the message to send. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void sendTopicMessage(String topicName, BrokeredMessage message) throws ServiceException { - next.sendTopicMessage(topicName, message); - } - - /** - * Receives a subscription message. - * - * @param topicName - * A String object that represents the name of the topic to receive. - * @param subscriptionName - * A String object that represents the name of the subscription from the message will be - * received. - * - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) - throws ServiceException { - return next.receiveSubscriptionMessage(topicName, subscriptionName); - } - - /** - * Receives a subscription message using the specified receive message options. - * - * @param topicName - * A String object that represents the name of the topic to receive. - * @param subscriptionName - * A String object that represents the name of the subscription from the message will be - * received. - * @param options - * A ReceiveMessageOptions object that represents the receive message options. - * - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, - ReceiveMessageOptions options) throws ServiceException { - return next.receiveSubscriptionMessage(topicName, subscriptionName, options); - } - - /** - * Unlocks a message. - * - * @param message - * A Message object that represents the message to unlock. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void unlockMessage(BrokeredMessage message) throws ServiceException { - next.unlockMessage(message); - } - - /** - * Deletes a message. - * - * @param message - * A Message object that represents the message to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void deleteMessage(BrokeredMessage message) throws ServiceException { - next.deleteMessage(message); - } - - /** - * Creates a queue. - * - * @param queue - * A Queue object that represents the queue to create. - * - * @return A CreateQueueResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. */ - public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { - return next.createQueue(queue); + public static ServiceBusContract create(Configuration config) { + return config.create(ServiceBusContract.class); } - /** - * Deletes a queue. - * - * @param queueName - * A String object that represents the name of the queue to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void deleteQueue(String queueName) throws ServiceException { - next.deleteQueue(queueName); - } - - /** - * Retrieves a queue. - * - * @param queueName - * A String object that represents the name of the queue to retrieve. - * - * @return A GetQueueResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public GetQueueResult getQueue(String queueName) throws ServiceException { - return next.getQueue(queueName); - } - - /** - * Returns a list of queues. - * - * @return A ListQueuesResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ListQueuesResult listQueues() throws ServiceException { - return next.listQueues(); - } - - /** - * Creates a topic. - * - * @param topic - * A Topic object that represents the topic to create. - * - * @return A CreateTopicResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { - return next.createTopic(topic); - } - - /** - * Deletes a topic. - * - * @param topicName - * A String object that represents the name of the queue to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void deleteTopic(String topicName) throws ServiceException { - next.deleteTopic(topicName); - } - - /** - * Retrieves a topic. - * - * @param topicName - * A String object that represents the name of the topic to retrieve. - * - * @return A GetTopicResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public GetTopicResult getTopic(String topicName) throws ServiceException { - return next.getTopic(topicName); - } - - /** - * Returns a list of topics. - * - * @return A ListTopicsResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ListTopicsResult listTopics() throws ServiceException { - return next.listTopics(); - } - - /** - * Creates a subscription. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscription - * A Subscription object that represents the subscription to create. - * - * @return A CreateSubscriptionResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public CreateSubscriptionResult createSubscription(String topicName, SubscriptionInfo subscription) - throws ServiceException { - return next.createSubscription(topicName, subscription); - } - - /** - * Deletes a subscription. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * - * @param subscriptionName - * A String object that represents the name of the subscription to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void deleteSubscription(String topicName, String subscriptionName) throws ServiceException { - next.deleteSubscription(topicName, subscriptionName); - } - - /** - * Retrieves a subscription. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription to retrieve. - * - * @return A GetSubscriptionResult object that represents the result. - * A String object that represents the name of the subscription to retrieve. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public GetSubscriptionResult getSubscription(String topicName, String subscriptionName) throws ServiceException { - return next.getSubscription(topicName, subscriptionName); - } - - /** - * Returns a list of subscriptions. - * - * @param topicName - * A String object that represents the name of the topic for the subscriptions to retrieve. - * - * @return A ListSubscriptionsResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { - return next.listSubscriptions(topicName); - } - - /** - * Creates a rule. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * created. - * @param rule - * A Rule object that represents the rule to create. - * - * @return A CreateRuleResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public CreateRuleResult createRule(String topicName, String subscriptionName, RuleInfo rule) throws ServiceException { - return next.createRule(topicName, subscriptionName, rule); - } - - /** - * Deletes a rule. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * deleted. - * @param ruleName - * A String object that represents the name of the rule to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public void deleteRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { - next.deleteRule(topicName, subscriptionName, ruleName); - } - - /** - * Retrieves a rule. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * retrieved. - * @param ruleName - * A String object that represents the name of the rule to retrieve. - * - * @return A GetRuleResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public GetRuleResult getRule(String topicName, String subscriptionName, String ruleName) throws ServiceException { - return next.getRule(topicName, subscriptionName, ruleName); - } - - /** - * Returns a list of rules. - * - * @param topicName - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription whose rules are being - * retrieved. - * - * @return A ListRulesResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { - return next.listRules(topicName, subscriptionName); - } - - public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - return next.listQueues(options); - } - - public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { - return next.listTopics(options); - } - - public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) - throws ServiceException { - return next.listSubscriptions(topicName, options); - } - - public ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) - throws ServiceException { - return next.listRules(topicName, subscriptionName, options); - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index f9a5dd11c0c22..05b575742fe2b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -26,7 +26,7 @@ public void initialize() throws Exception { System.setProperty("http.keepAlive", "false"); boolean testAlphaExists = false; - ServiceBusContract service = new ServiceBusService(); + ServiceBusContract service = ServiceBusService.create(); for (QueueInfo queue : iterateQueues(service)) { String queueName = queue.getPath(); if (queueName.startsWith("Test") || queueName.startsWith("test")) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index 9f826c11d6f09..05fe729f3e1a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -5,15 +5,12 @@ import org.junit.Test; import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusService; public class ServiceBusCreationTest { @Test public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { ServiceBusConfiguration.configure("my-namespace", "my-identity", "my-shared-secret"); - ServiceBusService service = new ServiceBusService(); + ServiceBusContract service = ServiceBusService.create(); assertNotNull(service); assertEquals(ServiceBusService.class, service.getClass()); @@ -28,7 +25,7 @@ public Configuration newConfiguration() { @Test public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { Configuration config = newConfiguration(); - ServiceBusContract service = new ServiceBusService(config); + ServiceBusContract service = ServiceBusService.create(config); assertNotNull(service); assertEquals(ServiceBusService.class, service.getClass()); @@ -37,7 +34,7 @@ public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { @Test public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { Configuration config = newConfiguration(); - ServiceBusContract service = config.create(ServiceBusService.class); + ServiceBusContract service = config.create(ServiceBusContract.class); assertNotNull(service); assertEquals(ServiceBusService.class, service.getClass()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 9fdbb2e41b64d..2d1b232bb9b2f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -10,16 +10,15 @@ import org.junit.Before; import org.junit.Test; - import com.microsoft.windowsazure.common.Configuration; - import com.microsoft.windowsazure.common.ServiceException; - import com.microsoft.windowsazure.common.ServiceFilter; - import com.microsoft.windowsazure.common.ServiceFilter.Request; - import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.common.ServiceFilter.Request; +import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; @@ -30,12 +29,13 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { private ServiceBusContract service; - static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete().setTimeout(5); + static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete() + .setTimeout(5); static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); @Before public void createService() throws Exception { - service = new ServiceBusService(); + service = ServiceBusService.create(); } @Test @@ -155,7 +155,8 @@ public void peekLockedMessageCanBeUnlocked() throws Exception { Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.unlockMessage(peekedMessage); - BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS) + .getValue(); // Assert assertNotNull(lockToken); @@ -177,7 +178,8 @@ public void peekLockedMessageCanBeDeleted() throws Exception { Date lockedUntil = peekedMessage.getLockedUntilUtc(); service.deleteMessage(peekedMessage); - BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS) + .getValue(); // Assert assertNotNull(lockToken); @@ -230,6 +232,7 @@ public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { final List responses = new ArrayList(); ServiceBusContract filtered = service.withFilter(new ServiceFilter() { + @Override public Response handle(Request request, Next next) throws Exception { requests.add(request); Response response = next.handle(request); @@ -239,7 +242,8 @@ public Response handle(Request request, Next next) throws Exception { }); // Act - QueueInfo created = filtered.createQueue(new QueueInfo("TestFilterCanSeeAndChangeRequestOrResponse")).getValue(); + QueueInfo created = filtered.createQueue(new QueueInfo("TestFilterCanSeeAndChangeRequestOrResponse")) + .getValue(); // Assert assertNotNull(created); @@ -254,7 +258,8 @@ public void subscriptionsCanBeCreatedOnTopics() throws Exception { service.createTopic(new TopicInfo(topicName)); // Act - SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription")).getValue(); + SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription")) + .getValue(); // Assert assertNotNull(created); @@ -316,10 +321,12 @@ public void subscriptionWillReceiveMessage() throws Exception { String topicName = "TestSubscriptionWillReceiveMessage"; service.createTopic(new TopicInfo(topicName)); service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.sendTopicMessage(topicName, new BrokeredMessage("

Testing subscription

").setContentType("text/html")); + service.sendTopicMessage(topicName, + new BrokeredMessage("

Testing subscription

").setContentType("text/html")); // Act - BrokeredMessage message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS).getValue(); + BrokeredMessage message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS) + .getValue(); // Assert assertNotNull(message); From c3fbdfdbaae0ef50b5b53e133a010e8a1e7b77a0 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 14:25:39 -0800 Subject: [PATCH 238/664] add fundamental sendMessage and receiveMessage operations. fixes #97 These fundamental operations take a string path argument, rather than queuePath, topicPath, subscriptionName component parts. They behave in every other way like their counterparts. --- .../serviceBus/ServiceBusContract.java | 13 +- .../ServiceBusExceptionProcessor.java | 74 +++++- .../implementation/ServiceBusRestProxy.java | 215 ++++++++---------- .../models/ReceiveMessageResult.java | 39 ++++ 4 files changed, 213 insertions(+), 128 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 6c52fafc82cf2..ceccdd9f37d8e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -2,6 +2,7 @@ import com.microsoft.windowsazure.common.FilterableService; import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -18,9 +19,9 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; @@ -91,7 +92,6 @@ ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOp */ void sendTopicMessage(String topicPath, BrokeredMessage message) throws ServiceException; - /** * Receives a subscription message. * @@ -140,6 +140,12 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St */ void unlockMessage(BrokeredMessage message) throws ServiceException; + void sendMessage(String path, BrokeredMessage message) throws ServiceException; + + ReceiveMessageResult receiveMessage(String path) throws ServiceException; + + ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException; + /** * Deletes a message. * @@ -262,7 +268,8 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St * @exception ServiceException * If a service exception is encountered. */ - CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) throws ServiceException; + CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) + throws ServiceException; /** * Deletes a subscription. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index e83367dbdf130..e3938f664a108 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -8,6 +8,7 @@ import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -24,9 +25,9 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; @@ -50,6 +51,7 @@ public ServiceBusExceptionProcessor(ServiceBusRestProxy next) { this.next = next; } + @Override public ServiceBusContract withFilter(ServiceFilter filter) { return new ServiceBusExceptionProcessor(next.withFilter(filter)); } @@ -59,6 +61,7 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("serviceBus", e); } + @Override public void sendQueueMessage(String path, BrokeredMessage message) throws ServiceException { try { next.sendQueueMessage(path, message); @@ -71,6 +74,7 @@ public void sendQueueMessage(String path, BrokeredMessage message) throws Servic } } + @Override public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { try { return next.receiveQueueMessage(queueName); @@ -83,6 +87,7 @@ public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws Se } } + @Override public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) throws ServiceException { try { @@ -96,6 +101,7 @@ public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMe } } + @Override public void sendTopicMessage(String path, BrokeredMessage message) throws ServiceException { try { next.sendTopicMessage(path, message); @@ -108,6 +114,7 @@ public void sendTopicMessage(String path, BrokeredMessage message) throws Servic } } + @Override public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) throws ServiceException { try { @@ -121,6 +128,7 @@ public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicN } } + @Override public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, ReceiveMessageOptions options) throws ServiceException { try { @@ -134,6 +142,7 @@ public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicN } } + @Override public void unlockMessage(BrokeredMessage message) throws ServiceException { try { next.unlockMessage(message); @@ -146,6 +155,7 @@ public void unlockMessage(BrokeredMessage message) throws ServiceException { } } + @Override public void deleteMessage(BrokeredMessage message) throws ServiceException { try { next.deleteMessage(message); @@ -158,6 +168,7 @@ public void deleteMessage(BrokeredMessage message) throws ServiceException { } } + @Override public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { try { return next.createQueue(queue); @@ -170,6 +181,7 @@ public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { } } + @Override public void deleteQueue(String queuePath) throws ServiceException { try { next.deleteQueue(queuePath); @@ -182,6 +194,7 @@ public void deleteQueue(String queuePath) throws ServiceException { } } + @Override public GetQueueResult getQueue(String queuePath) throws ServiceException { try { return next.getQueue(queuePath); @@ -194,6 +207,7 @@ public GetQueueResult getQueue(String queuePath) throws ServiceException { } } + @Override public ListQueuesResult listQueues() throws ServiceException { try { return next.listQueues(); @@ -206,6 +220,7 @@ public ListQueuesResult listQueues() throws ServiceException { } } + @Override public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { try { return next.createTopic(topic); @@ -218,6 +233,7 @@ public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { } } + @Override public void deleteTopic(String topicPath) throws ServiceException { try { next.deleteTopic(topicPath); @@ -230,6 +246,7 @@ public void deleteTopic(String topicPath) throws ServiceException { } } + @Override public GetTopicResult getTopic(String topicPath) throws ServiceException { try { return next.getTopic(topicPath); @@ -242,6 +259,7 @@ public GetTopicResult getTopic(String topicPath) throws ServiceException { } } + @Override public ListTopicsResult listTopics() throws ServiceException { try { return next.listTopics(); @@ -254,6 +272,7 @@ public ListTopicsResult listTopics() throws ServiceException { } } + @Override public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) throws ServiceException { try { @@ -267,6 +286,7 @@ public CreateSubscriptionResult createSubscription(String topicPath, Subscriptio } } + @Override public void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException { try { next.deleteSubscription(topicPath, subscriptionName); @@ -279,6 +299,7 @@ public void deleteSubscription(String topicPath, String subscriptionName) throws } } + @Override public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException { try { return next.getSubscription(topicPath, subscriptionName); @@ -291,6 +312,7 @@ public GetSubscriptionResult getSubscription(String topicPath, String subscripti } } + @Override public ListSubscriptionsResult listSubscriptions(String topicPath) throws ServiceException { try { return next.listSubscriptions(topicPath); @@ -303,7 +325,9 @@ public ListSubscriptionsResult listSubscriptions(String topicPath) throws Servic } } - public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) throws ServiceException { + @Override + public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) + throws ServiceException { try { return next.createRule(topicPath, subscriptionName, rule); } @@ -315,6 +339,7 @@ public CreateRuleResult createRule(String topicPath, String subscriptionName, Ru } } + @Override public void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { next.deleteRule(topicPath, subscriptionName, ruleName); @@ -327,6 +352,7 @@ public void deleteRule(String topicPath, String subscriptionName, String ruleNam } } + @Override public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { try { return next.getRule(topicPath, subscriptionName, ruleName); @@ -339,6 +365,7 @@ public GetRuleResult getRule(String topicPath, String subscriptionName, String r } } + @Override public ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException { try { return next.listRules(topicPath, subscriptionName); @@ -351,6 +378,7 @@ public ListRulesResult listRules(String topicPath, String subscriptionName) thro } } + @Override public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { try { return next.listQueues(options); @@ -363,6 +391,7 @@ public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceExce } } + @Override public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { try { return next.listTopics(options); @@ -375,6 +404,7 @@ public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceExce } } + @Override public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) throws ServiceException { try { @@ -388,6 +418,7 @@ public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscript } } + @Override public ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) throws ServiceException { try { @@ -401,4 +432,43 @@ public ListRulesResult listRules(String topicName, String subscriptionName, List } } + @Override + public void sendMessage(String path, BrokeredMessage message) throws ServiceException { + try { + next.sendMessage(path, message); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ReceiveMessageResult receiveMessage(String path) throws ServiceException { + try { + return next.receiveMessage(path); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException { + try { + return next.receiveMessage(path, 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/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 2008215a3587a..717bd8611c32a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -11,9 +11,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - +import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.AbstractListOptions; +import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; @@ -30,19 +32,15 @@ import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; +import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; - - import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; @@ -58,11 +56,8 @@ public class ServiceBusRestProxy implements ServiceBusContract { ServiceFilter[] filters; @Inject - public ServiceBusRestProxy( - Client channel, - @Named("serviceBus") WrapFilter authFilter, - @Named("serviceBus.uri") String uri, - BrokerPropertiesMapper mapper) { + public ServiceBusRestProxy(Client channel, @Named("serviceBus") WrapFilter authFilter, + @Named("serviceBus.uri") String uri, BrokerPropertiesMapper mapper) { this.channel = channel; this.filters = new ServiceFilter[0]; @@ -71,17 +66,14 @@ public ServiceBusRestProxy( channel.addFilter(authFilter); } - public ServiceBusRestProxy( - Client channel, - ServiceFilter[] filters, - String uri, - BrokerPropertiesMapper mapper) { + public ServiceBusRestProxy(Client channel, ServiceFilter[] filters, String uri, BrokerPropertiesMapper mapper) { this.channel = channel; this.filters = filters; this.uri = uri; this.mapper = mapper; } + @Override public ServiceBusContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; @@ -97,19 +89,16 @@ public void setChannel(Client channel) { } private WebResource getResource() { - WebResource resource = getChannel() - .resource(uri); + WebResource resource = getChannel().resource(uri); for (ServiceFilter filter : filters) { resource.addFilter(new ClientFilterAdapter(filter)); } return resource; } - void sendMessage(String path, BrokeredMessage message) { - Builder request = getResource() - .path(path) - .path("messages") - .getRequestBuilder(); + @Override + public void sendMessage(String path, BrokeredMessage message) { + Builder request = getResource().path(path).path("messages").getRequestBuilder(); if (message.getContentType() != null) request = request.type(message.getContentType()); @@ -120,26 +109,40 @@ void sendMessage(String path, BrokeredMessage message) { request.post(message.getBody()); } + @Override public void sendQueueMessage(String path, BrokeredMessage message) throws ServiceException { sendMessage(path, message); } - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) - throws ServiceException { + @Override + public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); } - public ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOptions options) throws ServiceException { + @Override + public ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOptions options) + throws ServiceException { - WebResource resource = getResource() - .path(queuePath) - .path("messages") - .path("head"); + WebResource resource = getResource().path(queuePath).path("messages").path("head"); BrokeredMessage message = receiveMessage(options, resource); return new ReceiveQueueMessageResult(message); } + @Override + public ReceiveMessageResult receiveMessage(String path) throws ServiceException { + return receiveMessage(path, ReceiveMessageOptions.DEFAULT); + } + + @Override + public ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException { + + WebResource resource = getResource().path(path).path("messages").path("head"); + + BrokeredMessage message = receiveMessage(options, resource); + return new ReceiveMessageResult(message); + } + private BrokeredMessage receiveMessage(ReceiveMessageOptions options, WebResource resource) { if (options.getTimeout() != null) { resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); @@ -176,64 +179,56 @@ else if (options.isPeekLock()) { return message; } + @Override public void sendTopicMessage(String topicName, BrokeredMessage message) throws ServiceException { sendMessage(topicName, message); } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName) throws ServiceException { + @Override + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) + throws ServiceException { return receiveSubscriptionMessage(topicName, subscriptionName, ReceiveMessageOptions.DEFAULT); } - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, - String subscriptionName, ReceiveMessageOptions options) - throws ServiceException { - WebResource resource = getResource() - .path(topicName) - .path("subscriptions") - .path(subscriptionName) - .path("messages") - .path("head"); + @Override + public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, + ReceiveMessageOptions options) throws ServiceException { + WebResource resource = getResource().path(topicName).path("subscriptions").path(subscriptionName) + .path("messages").path("head"); BrokeredMessage message = receiveMessage(options, resource); return new ReceiveSubscriptionMessageResult(message); } + @Override public void unlockMessage(BrokeredMessage message) throws ServiceException { - getChannel() - .resource(message.getLockLocation()) - .put(""); + getChannel().resource(message.getLockLocation()).put(""); } + @Override public void deleteMessage(BrokeredMessage message) throws ServiceException { - getChannel() - .resource(message.getLockLocation()) - .delete(); + getChannel().resource(message.getLockLocation()).delete(); } + @Override public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - return new CreateQueueResult(getResource() - .path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8") - .put(QueueInfo.class, entry)); + return new CreateQueueResult(getResource().path(entry.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").put(QueueInfo.class, entry)); } + @Override public void deleteQueue(String queuePath) throws ServiceException { - getResource() - .path(queuePath) - .delete(); + getResource().path(queuePath).delete(); } + @Override public GetQueueResult getQueue(String queuePath) throws ServiceException { - return new GetQueueResult(getResource() - .path(queuePath) - .get(QueueInfo.class)); + return new GetQueueResult(getResource().path(queuePath).get(QueueInfo.class)); } + @Override public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - Feed feed = listOptions(options, getResource() - .path("$Resources/Queues")) - .get(Feed.class); + Feed feed = listOptions(options, getResource().path("$Resources/Queues")).get(Feed.class); ArrayList queues = new ArrayList(); for (Entry entry : feed.getEntries()) { queues.add(new QueueInfo(entry)); @@ -253,29 +248,25 @@ private WebResource listOptions(AbstractListOptions options, WebResource path return path; } + @Override public CreateTopicResult createTopic(TopicInfo entry) throws ServiceException { - return new CreateTopicResult(getResource() - .path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8") - .put(TopicInfo.class, entry)); + return new CreateTopicResult(getResource().path(entry.getPath()) + .type("application/atom+xml;type=entry;charset=utf-8").put(TopicInfo.class, entry)); } + @Override public void deleteTopic(String TopicPath) throws ServiceException { - getResource() - .path(TopicPath) - .delete(); + getResource().path(TopicPath).delete(); } + @Override public GetTopicResult getTopic(String TopicPath) throws ServiceException { - return new GetTopicResult(getResource() - .path(TopicPath) - .get(TopicInfo.class)); + return new GetTopicResult(getResource().path(TopicPath).get(TopicInfo.class)); } + @Override public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { - Feed feed = listOptions(options, getResource() - .path("$Resources/Topics")) - .get(Feed.class); + Feed feed = listOptions(options, getResource().path("$Resources/Topics")).get(Feed.class); ArrayList Topics = new ArrayList(); for (Entry entry : feed.getEntries()) { Topics.add(new TopicInfo(entry)); @@ -285,36 +276,27 @@ public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceExce return result; } + @Override public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - return new CreateSubscriptionResult(getResource() - .path(topicPath) - .path("subscriptions") - .path(subscription.getName()) - .type("application/atom+xml;type=entry;charset=utf-8") + return new CreateSubscriptionResult(getResource().path(topicPath).path("subscriptions") + .path(subscription.getName()).type("application/atom+xml;type=entry;charset=utf-8") .put(SubscriptionInfo.class, subscription)); } + @Override public void deleteSubscription(String topicPath, String subscriptionName) { - getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) - .delete(); + getResource().path(topicPath).path("subscriptions").path(subscriptionName).delete(); } + @Override public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) { - return new GetSubscriptionResult(getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) + return new GetSubscriptionResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) .get(SubscriptionInfo.class)); } + @Override public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) { - Feed feed = listOptions(options, getResource() - .path(topicPath) - .path("subscriptions")) - .get(Feed.class); + Feed feed = listOptions(options, getResource().path(topicPath).path("subscriptions")).get(Feed.class); ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { list.add(new SubscriptionInfo(entry)); @@ -324,47 +306,30 @@ public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscript return result; } - public CreateRuleResult createRule(String topicPath, String subscriptionName, - RuleInfo rule) { - return new CreateRuleResult(getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) - .path("rules") - .path(rule.getName()) - .type("application/atom+xml;type=entry;charset=utf-8") + @Override + public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) { + return new CreateRuleResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) + .path("rules").path(rule.getName()).type("application/atom+xml;type=entry;charset=utf-8") .put(RuleInfo.class, rule)); } - public void deleteRule(String topicPath, String subscriptionName, - String ruleName) { - getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) - .path("rules") - .path(ruleName) + @Override + public void deleteRule(String topicPath, String subscriptionName, String ruleName) { + getResource().path(topicPath).path("subscriptions").path(subscriptionName).path("rules").path(ruleName) .delete(); } - public GetRuleResult getRule(String topicPath, String subscriptionName, - String ruleName) { - return new GetRuleResult(getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) - .path("rules") - .path(ruleName) - .get(RuleInfo.class)); + @Override + public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) { + return new GetRuleResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) + .path("rules").path(ruleName).get(RuleInfo.class)); } + @Override public ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) { - Feed feed = listOptions(options, getResource() - .path(topicPath) - .path("subscriptions") - .path(subscriptionName) - .path("rules")) - .get(Feed.class); + Feed feed = listOptions(options, + getResource().path(topicPath).path("subscriptions").path(subscriptionName).path("rules")).get( + Feed.class); ArrayList list = new ArrayList(); for (Entry entry : feed.getEntries()) { list.add(new RuleInfo(entry)); @@ -374,18 +339,22 @@ public ListRulesResult listRules(String topicPath, String subscriptionName, List return result; } + @Override public ListQueuesResult listQueues() throws ServiceException { return listQueues(ListQueuesOptions.DEFAULT); } + @Override public ListTopicsResult listTopics() throws ServiceException { return listTopics(ListTopicsOptions.DEFAULT); } + @Override public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { return listSubscriptions(topicName, ListSubscriptionsOptions.DEFAULT); } + @Override public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { return listRules(topicName, subscriptionName, ListRulesOptions.DEFAULT); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java new file mode 100644 index 0000000000000..50e80016042b0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java @@ -0,0 +1,39 @@ +package com.microsoft.windowsazure.services.serviceBus.models; + +/** + * Represents the result of a receiveMessage operation. + */ +public class ReceiveMessageResult { + + private BrokeredMessage value; + + /** + * Creates an instance of the ReceiveQueueMessageResult class. + * + * @param value + * A {@link BrokeredMessage} object assigned as the value of the result. + */ + public ReceiveMessageResult(BrokeredMessage value) { + this.setValue(value); + } + + /** + * Specifies the value of the result. + * + * @param value + * A {@link BrokeredMessage} object assigned as the value of the result. + */ + public void setValue(BrokeredMessage value) { + this.value = value; + } + + /** + * Returns the value of the result. + * + * @return A {@link BrokeredMessage} object that represents the value of the result. + */ + public BrokeredMessage getValue() { + return value; + } + +} From 8f61e253d89fe9ca63b0c4e02e00d72101db127a Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 14:33:37 -0800 Subject: [PATCH 239/664] Adding String profile parameter to factory methods --- .../services/serviceBus/ServiceBusService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index a9e1b76630033..3569050fc3e0d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -32,4 +32,22 @@ public static ServiceBusContract create(Configuration config) { return config.create(ServiceBusContract.class); } + /** + * Creates an instance of the ServiceBusContract API. + * + */ + public static ServiceBusContract create(String profile) { + return Configuration.getInstance().create(profile, ServiceBusContract.class); + } + + /** + * Creates an instance of the ServiceBusContract API using the specified configuration. + * + * @param config + * A Configuration object that represents the configuration for the service bus service. + * + */ + public static ServiceBusContract create(String profile, Configuration config) { + return config.create(profile, ServiceBusContract.class); + } } From dbf0a9e38d693f92aa58180d563aff37955ecb8c Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 22 Nov 2011 16:34:03 -0800 Subject: [PATCH 240/664] Adding javadoc comments for new methods --- .../serviceBus/ServiceBusContract.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index ceccdd9f37d8e..24dd540529b64 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -140,10 +140,46 @@ ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, St */ void unlockMessage(BrokeredMessage message) throws ServiceException; + /** + * Sends a message. + * + * @param path + * A String object that represents the path to which the message will be sent. + * This may be the value of a queuePath or a topicPath. + * @param message + * A Message object that represents the message to send. + * + * @throws ServiceException + * If a service exception is encountered. + */ void sendMessage(String path, BrokeredMessage message) throws ServiceException; + /** + * Receives a message. + * + * @param path + * A String object that represents the path from which a message will be received. + * This may either be the value of queuePath or a combination of + * the topicPath + "/subscriptions/" + subscriptionName. + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * @throws ServiceException + * If a service exception is encountered. + */ ReceiveMessageResult receiveMessage(String path) throws ServiceException; + /** + * Receives a message using the specified receive message options. + * + * @param path + * A String object that represents the path from which a message will be received. + * This may either be the value of queuePath or a combination of + * the topicPath + "/subscriptions/" + subscriptionName. + * @param options + * A ReceiveMessageOptions object that represents the receive message options. + * @return A ReceiveSubscriptionMessageResult object that represents the result. + * @throws ServiceException + * If a service exception is encountered. + */ ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException; /** From e6ad07ba1122ef42ccab993f7ae3f4886cf7be2b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 11:27:10 -0800 Subject: [PATCH 241/664] Restructuring how BrokeredMessage is created Preparation for adding user-defined properties --- .../implementation/ServiceBusRestProxy.java | 36 +++++++++++++------ .../serviceBus/models/BrokeredMessage.java | 8 +++-- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 717bd8611c32a..a8a18d2205d1f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,5 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -159,23 +160,36 @@ else if (options.isPeekLock()) { throw new RuntimeException("Unknown ReceiveMode"); } - String brokerProperties = clientResult.getHeaders().getFirst("BrokerProperties"); - String location = clientResult.getHeaders().getFirst("Location"); - MediaType contentType = clientResult.getType(); - Date date = clientResult.getResponseDate(); + BrokerProperties brokerProperties; + if (clientResult.getHeaders().containsKey("BrokerProperties")) { + brokerProperties = mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties")); + } + else { + brokerProperties = new BrokerProperties(); + } - BrokeredMessage message = new BrokeredMessage(); - if (brokerProperties != null) { - message.setProperties(mapper.fromString(brokerProperties)); + String location = clientResult.getHeaders().getFirst("Location"); + if (location != null) { + brokerProperties.setLockLocation(location); } + + BrokeredMessage message = new BrokeredMessage(brokerProperties); + + MediaType contentType = clientResult.getType(); if (contentType != null) { message.setContentType(contentType.toString()); } - if (location != null) { - message.getProperties().setLockLocation(location); + + Date date = clientResult.getResponseDate(); + if (date != null) { + message.setDate(date); + } + + InputStream body = clientResult.getEntityInputStream(); + if (body != null) { + message.setBody(body); } - message.setDate(date); - message.setBody(clientResult.getEntityInputStream()); + return message; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index 3d18474fc13f2..3dae545571702 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -56,9 +56,13 @@ public BrokeredMessage(String body) { this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); } - BrokeredMessage(BrokerProperties properties, InputStream body) { + /** + * Internal + * + * @param properties + */ + public BrokeredMessage(BrokerProperties properties) { this.properties = properties; - this.body = body; } /** From c6639204070d72a1a7412948e42c41740639c104 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 11:29:32 -0800 Subject: [PATCH 242/664] Renaming getProperties to getBrokerProperties More specific name intended to avoid confusion with user-defined properties --- .../implementation/ServiceBusRestProxy.java | 4 +- .../serviceBus/models/BrokeredMessage.java | 75 ++++++++----------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index a8a18d2205d1f..bfb8ab3826fa4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -104,8 +104,8 @@ public void sendMessage(String path, BrokeredMessage message) { if (message.getContentType() != null) request = request.type(message.getContentType()); - if (message.getProperties() != null) - request = request.header("BrokerProperties", mapper.toString(message.getProperties())); + if (message.getBrokerProperties() != null) + request = request.header("BrokerProperties", mapper.toString(message.getBrokerProperties())); request.post(message.getBody()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index 3dae545571702..5655335e83481 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -10,7 +10,7 @@ * Represents a service bus message. */ public class BrokeredMessage { - BrokerProperties properties; + BrokerProperties brokerProperties; InputStream body; String contentType; Date date; @@ -19,7 +19,7 @@ public class BrokeredMessage { * Creates an instance of the Message class. */ public BrokeredMessage() { - this.properties = new BrokerProperties(); + this.brokerProperties = new BrokerProperties(); } /** @@ -29,7 +29,7 @@ public BrokeredMessage() { * An InputStream object that represents the body of the message. */ public BrokeredMessage(InputStream body) { - this.properties = new BrokerProperties(); + this.brokerProperties = new BrokerProperties(); this.body = body; } @@ -40,7 +40,7 @@ public BrokeredMessage(InputStream body) { * A byte array that represents the body of the message. */ public BrokeredMessage(byte[] body) { - this.properties = new BrokerProperties(); + this.brokerProperties = new BrokerProperties(); this.body = (body == null) ? null : new ByteArrayInputStream(body); } @@ -52,7 +52,7 @@ public BrokeredMessage(byte[] body) { * A String object that represents the body of the message. */ public BrokeredMessage(String body) { - this.properties = new BrokerProperties(); + this.brokerProperties = new BrokerProperties(); this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); } @@ -62,7 +62,7 @@ public BrokeredMessage(String body) { * @param properties */ public BrokeredMessage(BrokerProperties properties) { - this.properties = properties; + this.brokerProperties = properties; } /** @@ -70,19 +70,8 @@ public BrokeredMessage(BrokerProperties properties) { * * @return A {@link BrokerProperties} object that represents the properties of the message. */ - public BrokerProperties getProperties() { - return properties; - } - - /** - * Sets the properties of the message. - * - * @param properties - * A {@link BrokerProperties} object that represents the properties of the message. - */ - public BrokeredMessage setProperties(BrokerProperties properties) { - this.properties = properties; - return this; + public BrokerProperties getBrokerProperties() { + return brokerProperties; } /** @@ -157,7 +146,7 @@ public BrokeredMessage setDate(Date date) { * @return The delivery count. */ public Integer getDeliveryCount() { - return properties.getDeliveryCount(); + return brokerProperties.getDeliveryCount(); } /** @@ -166,7 +155,7 @@ public Integer getDeliveryCount() { * @return A String object that represents the message ID. */ public String getMessageId() { - return properties.getMessageId(); + return brokerProperties.getMessageId(); } /** @@ -178,7 +167,7 @@ public String getMessageId() { * @return A Message object that represents the updated message. */ public BrokeredMessage setMessageId(String messageId) { - properties.setMessageId(messageId); + brokerProperties.setMessageId(messageId); return this; } @@ -189,7 +178,7 @@ public BrokeredMessage setMessageId(String messageId) { * */ public Long getSequenceNumber() { - return properties.getSequenceNumber(); + return brokerProperties.getSequenceNumber(); } /** @@ -198,7 +187,7 @@ public Long getSequenceNumber() { * @return The time, in seconds, for the message to live. */ public Double getTimeToLive() { - return properties.getTimeToLive(); + return brokerProperties.getTimeToLive(); } /** @@ -210,7 +199,7 @@ public Double getTimeToLive() { * @return A Message object that represents the updated message. */ public BrokeredMessage setTimeToLive(Double timeToLive) { - properties.setTimeToLive(timeToLive); + brokerProperties.setTimeToLive(timeToLive); return this; } @@ -220,7 +209,7 @@ public BrokeredMessage setTimeToLive(Double timeToLive) { * @return A String object that represents the lock token. */ public String getLockToken() { - return properties.getLockToken(); + return brokerProperties.getLockToken(); } /** @@ -229,7 +218,7 @@ public String getLockToken() { * @return A Date object that represents the locked-until date/time, in UTC format. */ public Date getLockedUntilUtc() { - return properties.getLockedUntilUtc(); + return brokerProperties.getLockedUntilUtc(); } /** @@ -239,7 +228,7 @@ public Date getLockedUntilUtc() { * */ public String getCorrelationId() { - return properties.getCorrelationId(); + return brokerProperties.getCorrelationId(); } /** @@ -251,7 +240,7 @@ public String getCorrelationId() { * @return A Message object that represents the updated message. */ public BrokeredMessage setCorrelationId(String correlationId) { - properties.setCorrelationId(correlationId); + brokerProperties.setCorrelationId(correlationId); return this; } @@ -262,7 +251,7 @@ public BrokeredMessage setCorrelationId(String correlationId) { * */ public String getSessionId() { - return properties.getSessionId(); + return brokerProperties.getSessionId(); } /** @@ -274,7 +263,7 @@ public String getSessionId() { * @return A Message object that represents the updated message. */ public BrokeredMessage setSessionId(String sessionId) { - properties.setSessionId(sessionId); + brokerProperties.setSessionId(sessionId); return this; } @@ -284,7 +273,7 @@ public BrokeredMessage setSessionId(String sessionId) { * @return A String object that represents the label. */ public String getLabel() { - return properties.getLabel(); + return brokerProperties.getLabel(); } /** @@ -296,7 +285,7 @@ public String getLabel() { * @return A Message object that represents the updated message. */ public BrokeredMessage setLabel(String label) { - properties.setLabel(label); + brokerProperties.setLabel(label); return this; } @@ -306,7 +295,7 @@ public BrokeredMessage setLabel(String label) { * @return A String object that represents the Reply-To recipient. */ public String getReplyTo() { - return properties.getReplyTo(); + return brokerProperties.getReplyTo(); } /** @@ -318,7 +307,7 @@ public String getReplyTo() { * @return A Message object that represents the updated message. */ public BrokeredMessage setReplyTo(String replyTo) { - properties.setReplyTo(replyTo); + brokerProperties.setReplyTo(replyTo); return this; } @@ -328,7 +317,7 @@ public BrokeredMessage setReplyTo(String replyTo) { * @return A String object that represents the To recipient. */ public String getTo() { - return properties.getTo(); + return brokerProperties.getTo(); } /** @@ -340,7 +329,7 @@ public String getTo() { * @return A Message object that represents the updated message. */ public BrokeredMessage setTo(String to) { - properties.setTo(to); + brokerProperties.setTo(to); return this; } @@ -350,7 +339,7 @@ public BrokeredMessage setTo(String to) { * @return A Date object that represents the date/time of the message in UTC format. */ public Date getScheduledEnqueueTimeUtc() { - return properties.getScheduledEnqueueTimeUtc(); + return brokerProperties.getScheduledEnqueueTimeUtc(); } /** @@ -362,7 +351,7 @@ public Date getScheduledEnqueueTimeUtc() { * @return A Message object that represents the updated message. */ public BrokeredMessage setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { - properties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); + brokerProperties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); return this; } @@ -372,7 +361,7 @@ public BrokeredMessage setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) * @return A String object that represents the session ID of the Reply To recipient. */ public String getReplyToSessionId() { - return properties.getReplyToSessionId(); + return brokerProperties.getReplyToSessionId(); } /** @@ -384,7 +373,7 @@ public String getReplyToSessionId() { * @return A Message object that represents the updated message. */ public BrokeredMessage setReplyToSessionId(String replyToSessionId) { - properties.setReplyToSessionId(replyToSessionId); + brokerProperties.setReplyToSessionId(replyToSessionId); return this; } @@ -394,7 +383,7 @@ public BrokeredMessage setReplyToSessionId(String replyToSessionId) { * @return A String object that represents the message location. */ public String getMessageLocation() { - return properties.getMessageLocation(); + return brokerProperties.getMessageLocation(); } /** @@ -403,6 +392,6 @@ public String getMessageLocation() { * @return A String object that represents the lock location. */ public String getLockLocation() { - return properties.getLockLocation(); + return brokerProperties.getLockLocation(); } } From bcb00526dfd2d85ce930174dbf4b681e890bd822 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 11:54:37 -0800 Subject: [PATCH 243/664] Adding custom properties collection to BrokeredMessage --- .../serviceBus/models/BrokeredMessage.java | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index 5655335e83481..6d327cfbed8e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -3,6 +3,8 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; @@ -14,12 +16,13 @@ public class BrokeredMessage { InputStream body; String contentType; Date date; + Map customProperties; /** * Creates an instance of the Message class. */ public BrokeredMessage() { - this.brokerProperties = new BrokerProperties(); + this(new BrokerProperties()); } /** @@ -29,7 +32,7 @@ public BrokeredMessage() { * An InputStream object that represents the body of the message. */ public BrokeredMessage(InputStream body) { - this.brokerProperties = new BrokerProperties(); + this(new BrokerProperties()); this.body = body; } @@ -40,7 +43,7 @@ public BrokeredMessage(InputStream body) { * A byte array that represents the body of the message. */ public BrokeredMessage(byte[] body) { - this.brokerProperties = new BrokerProperties(); + this(new BrokerProperties()); this.body = (body == null) ? null : new ByteArrayInputStream(body); } @@ -52,7 +55,7 @@ public BrokeredMessage(byte[] body) { * A String object that represents the body of the message. */ public BrokeredMessage(String body) { - this.brokerProperties = new BrokerProperties(); + this(new BrokerProperties()); this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); } @@ -63,6 +66,7 @@ public BrokeredMessage(String body) { */ public BrokeredMessage(BrokerProperties properties) { this.brokerProperties = properties; + this.customProperties = new HashMap(); } /** @@ -140,6 +144,31 @@ public BrokeredMessage setDate(Date date) { return this; } + /** + * Returns a user defined property of the message. + * + * @param name + * A String object that represents the name of the property. + * @return An Object object that represents the value of the property. + */ + public Object getProperty(String name) { + return customProperties.get(name); + } + + /** + * Sets a user defined property of the message. + * + * @param name + * A String object that represents the name of the property. + * @param value + * An Object object that represents the value of the property. + * @return A Message object that represents the updated message. + */ + public BrokeredMessage setProperty(String name, Object value) { + customProperties.put(name, value); + return this; + } + /** * Returns the delivery count of the message. * From f66bdddb336f5256865ceb54818a7059575410a7 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 14:04:46 -0800 Subject: [PATCH 244/664] Implementing the mapping to string form of custom properties --- .../CustomPropertiesMapper.java | 67 +++++++++++++++++ .../CustomPropertiesMapperTest.java | 71 +++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java new file mode 100644 index 0000000000000..953cd4003163e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -0,0 +1,67 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; + +public class CustomPropertiesMapper { + // Fri, 04 Mar 2011 08:49:37 GMT + private static final String RFC_1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; + + public BrokerProperties fromString(String value) { + throw new RuntimeException(); + } + + public String toString(Object value) { + if (value == null) + return null; + + Class type = value.getClass(); + if (type == Byte.class) { + return value.toString() + ";byte"; + } + else if (type == Character.class) { + return value.toString() + ";char"; + } + else if (type == Short.class) { + return value.toString() + ";short"; + } + else if (type == Integer.class) { + return value.toString() + ";int"; + } + else if (type == Long.class) { + return value.toString() + ";long"; + } + else if (type == Float.class) { + return value.toString() + ";float"; + } + else if (type == Double.class) { + return value.toString() + ";double"; + } + else if (type == Boolean.class) { + return value.toString() + ";bool"; + } + else if (type == UUID.class) { + return value.toString() + ";uuid"; + } + else if (Calendar.class.isAssignableFrom(type)) { + DateFormat format = new SimpleDateFormat(RFC_1123); + Calendar calendar = (Calendar) value; + format.setTimeZone(calendar.getTimeZone()); + String formatted = format.format(calendar.getTime()); + return formatted + ";date"; + } + else if (Date.class.isAssignableFrom(type)) { + DateFormat format = new SimpleDateFormat(RFC_1123); + format.setTimeZone(TimeZone.getTimeZone("GMT")); + String formatted = format.format((Date) value); + return formatted + ";date"; + } + else { + return value.toString(); + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java new file mode 100644 index 0000000000000..7d7c691bc934c --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -0,0 +1,71 @@ +package com.microsoft.windowsazure.services.serviceBus.implementation; + +import static org.junit.Assert.*; + +import java.util.Calendar; +import java.util.TimeZone; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Test; + +public class CustomPropertiesMapperTest { + private CustomPropertiesMapper mapper; + + @Before + public void init() { + mapper = new CustomPropertiesMapper(); + } + + @Test + public void stringValuesShouldComeThroughUnmodified() { + // Arrange + + // Act + String text = mapper.toString("This is a string"); + + // Assert + assertEquals("This is a string", text); + } + + @Test + public void nonStringValuesShouldHaveTypeSuffix() { + // Arrange + + // Act + String text = mapper.toString(78); + + // Assert + assertEquals("78;int", text); + } + + @Test + public void supportedJavaTypesHaveExpectedTypeSuffix() { + // Arrange + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); + + // Act + + // Assert + // assertEquals("78;byte", mapper.toString((byte) 78)); + assertEquals("78;byte", mapper.toString((byte) 78)); + assertEquals("a;char", mapper.toString('a')); + assertEquals("-78;short", mapper.toString((short) -78)); + // assertEquals("78;ushort", mapper.toString((unsigned short)78); + assertEquals("-78;int", mapper.toString(-78)); + // assertEquals("78;uint", mapper.toString(78)); + assertEquals("-78;long", mapper.toString((long) -78)); + // assertEquals("78;ulong", mapper.toString(78)); + assertEquals("78.5;float", mapper.toString((float) 78.5)); + assertEquals("78.5;double", mapper.toString(78.5)); + //assertEquals("78;decimal", mapper.toString(78)); + assertEquals("true;bool", mapper.toString(true)); + assertEquals("false;bool", mapper.toString(false)); + assertEquals("12345678-9abc-def0-9abc-def012345678;uuid", + mapper.toString(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L))); + assertEquals("Thu, 14 Oct 1971 12:34:56 GMT;date", mapper.toString(cal)); + assertEquals("Thu, 14 Oct 1971 12:34:56 GMT;date", mapper.toString(cal.getTime())); + //assertEquals("78;date-seconds", mapper.toString(78)); + } +} From cdb9e1f17ea11f4c8437dff7b76dcc2b59c8619e Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 14:31:47 -0800 Subject: [PATCH 245/664] Implementing conversion from supported string notations to value --- .../CustomPropertiesMapper.java | 49 +++++++++++-- .../CustomPropertiesMapperTest.java | 69 +++++++++++++++++++ 2 files changed, 113 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index 953cd4003163e..7f1e4c406e456 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -1,6 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -11,13 +12,10 @@ public class CustomPropertiesMapper { // Fri, 04 Mar 2011 08:49:37 GMT private static final String RFC_1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; - public BrokerProperties fromString(String value) { - throw new RuntimeException(); - } - public String toString(Object value) { - if (value == null) + if (value == null) { return null; + } Class type = value.getClass(); if (type == Byte.class) { @@ -64,4 +62,45 @@ else if (Date.class.isAssignableFrom(type)) { return value.toString(); } } + + public Object fromString(String value) throws ParseException { + if (value == null) { + return null; + } + + if (value.endsWith(";byte")) { + return Byte.parseByte(value.substring(0, value.length() - ";byte".length())); + } + else if (value.endsWith(";char") && value.length() == "X;char".length()) { + return new Character(value.charAt(0)); + } + else if (value.endsWith(";short")) { + return Short.parseShort(value.substring(0, value.length() - ";short".length())); + } + else if (value.endsWith(";int")) { + return Integer.parseInt(value.substring(0, value.length() - ";int".length())); + } + else if (value.endsWith(";long")) { + return Long.parseLong(value.substring(0, value.length() - ";long".length())); + } + else if (value.endsWith(";float")) { + return Float.parseFloat(value.substring(0, value.length() - ";float".length())); + } + else if (value.endsWith(";double")) { + return Double.parseDouble(value.substring(0, value.length() - ";double".length())); + } + else if (value.endsWith(";bool")) { + return Boolean.parseBoolean(value.substring(0, value.length() - ";bool".length())); + } + else if (value.endsWith(";uuid")) { + return UUID.fromString(value.substring(0, value.length() - ";uuid".length())); + } + else if (value.endsWith(";date")) { + SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + return format.parse(value.substring(0, value.length() - ";date".length())); + } + else { + return value; + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index 7d7c691bc934c..bba51c2f0b530 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -2,7 +2,9 @@ import static org.junit.Assert.*; +import java.text.ParseException; import java.util.Calendar; +import java.util.Date; import java.util.TimeZone; import java.util.UUID; @@ -68,4 +70,71 @@ public void supportedJavaTypesHaveExpectedTypeSuffix() { assertEquals("Thu, 14 Oct 1971 12:34:56 GMT;date", mapper.toString(cal.getTime())); //assertEquals("78;date-seconds", mapper.toString(78)); } + + @Test + public void valuesComeBackAsStringsByDefault() throws ParseException { + // Arrange + + // Act + Object value = mapper.fromString("Hello world"); + + // Assert + assertEquals("Hello world", value); + assertEquals(String.class, value.getClass()); + } + + @Test + public void nonStringTypesWillBeParsedBySuffix() throws ParseException { + // Arrange + + // Act + Object value = mapper.fromString("5;int"); + + // Assert + assertEquals(5, value); + assertEquals(Integer.class, value.getClass()); + } + + @Test + public void unknownSuffixWillPassThroughAsString() throws ParseException { + // Arrange + + // Act + Object value = mapper.fromString("Hello;world"); + + // Assert + assertEquals("Hello;world", value); + assertEquals(String.class, value.getClass()); + } + + @Test + public void supportedTypeSuffixesHaveExpectedJavaTypes() throws ParseException { + // Arrange + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); + + // Act + Date dt = (Date) mapper.fromString("Thu, 14 Oct 1971 12:34:56 GMT;date"); + + // Assert + // assertEquals("78;byte", mapper.toString((byte) 78)); + assertEquals((byte) 78, mapper.fromString("78;byte")); + assertEquals('a', mapper.fromString("a;char")); + assertEquals((short) -78, mapper.fromString("-78;short")); + // assertEquals("78;ushort", mapper.toString((unsigned short)78); + assertEquals(-78, mapper.fromString("-78;int")); + // assertEquals("78;uint", mapper.toString(78)); + assertEquals((long) -78, mapper.fromString("-78;long")); + // assertEquals("78;ulong", mapper.toString(78)); + assertEquals((float) 78.5, mapper.fromString("78.5;float")); + assertEquals(78.5, mapper.fromString("78.5;double")); + //assertEquals("78;decimal", mapper.toString(78)); + assertEquals(true, mapper.fromString("true;bool")); + assertEquals(false, mapper.fromString("false;bool")); + assertEquals(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L), + mapper.fromString("12345678-9abc-def0-9abc-def012345678;uuid")); + + assertEquals(cal.getTime().getTime(), dt.getTime(), 1000); + //assertEquals("78;date-seconds", mapper.toString(78)); + } } From 489cc1aed907ebfa100d2fced7e3b2fc9c549793 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 14:38:39 -0800 Subject: [PATCH 246/664] Removing non-creatable class from Exports. Fixes #119 --- .../microsoft/windowsazure/services/serviceBus/Exports.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index c94c8f68af704..375f565c6e030 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -12,17 +12,18 @@ import com.sun.jersey.api.json.JSONConfiguration; public class Exports implements Builder.Exports { + @Override public void register(Builder.Registry registry) { // provide contract implementation registry.add(ServiceBusContract.class, ServiceBusExceptionProcessor.class); - registry.add(ServiceBusService.class); registry.add(ServiceBusExceptionProcessor.class); registry.add(ServiceBusRestProxy.class); // alter jersey client config for serviceBus registry.alter(ClientConfig.class, new Builder.Alteration() { + @Override public ClientConfig alter(ClientConfig instance, Builder builder, Map properties) { // enable this feature for unattributed json object serialization From 81641bed473783a94abd61498bf3d627d61eefd8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 14:50:26 -0800 Subject: [PATCH 247/664] Updating serviceBus to map custom properties. Fixes #72 --- .../implementation/ServiceBusRestProxy.java | 12 ++++++++++++ .../services/serviceBus/models/BrokeredMessage.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index bfb8ab3826fa4..30a8a0390997e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -52,6 +52,7 @@ public class ServiceBusRestProxy implements ServiceBusContract { private Client channel; private final String uri; private final BrokerPropertiesMapper mapper; + private final CustomPropertiesMapper customPropertiesMapper; static Log log = LogFactory.getLog(ServiceBusContract.class); ServiceFilter[] filters; @@ -64,6 +65,7 @@ public ServiceBusRestProxy(Client channel, @Named("serviceBus") WrapFilter authF this.filters = new ServiceFilter[0]; this.uri = uri; this.mapper = mapper; + this.customPropertiesMapper = new CustomPropertiesMapper(); channel.addFilter(authFilter); } @@ -72,6 +74,7 @@ public ServiceBusRestProxy(Client channel, ServiceFilter[] filters, String uri, this.filters = filters; this.uri = uri; this.mapper = mapper; + this.customPropertiesMapper = new CustomPropertiesMapper(); } @Override @@ -107,6 +110,10 @@ public void sendMessage(String path, BrokeredMessage message) { if (message.getBrokerProperties() != null) request = request.header("BrokerProperties", mapper.toString(message.getBrokerProperties())); + for (java.util.Map.Entry entry : message.getProperties().entrySet()) { + request.header(entry.getKey(), customPropertiesMapper.toString(entry.getValue())); + } + request.post(message.getBody()); } @@ -190,6 +197,11 @@ else if (options.isPeekLock()) { message.setBody(body); } + for (String key : clientResult.getHeaders().keySet()) { + Object value = clientResult.getHeaders().getFirst(key); + message.setProperty(key, value); + } + return message; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index 6d327cfbed8e0..ef2bfbdd34efc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -169,6 +169,15 @@ public BrokeredMessage setProperty(String name, Object value) { return this; } + /** + * Returns the user defined properties of the message. + * + * @return A Map object that represents the user defined properties. + */ + public Map getProperties() { + return customProperties; + } + /** * Returns the delivery count of the message. * From 6efefe802fbac2d3f78594f62978f5a2179067da Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 15:27:05 -0800 Subject: [PATCH 248/664] Removing proxy settings. Fixes #89 --- .../services/serviceBus/IntegrationTestBase.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 05b575742fe2b..3b016bd566c21 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -12,18 +12,10 @@ public abstract class IntegrationTestBase { @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"); boolean testAlphaExists = false; ServiceBusContract service = ServiceBusService.create(); From a4318877b9429aec344ad5b6d0c368cb3ad26e5b Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 15:34:00 -0800 Subject: [PATCH 249/664] Formatting pom.xml whitespace --- microsoft-azure-api/pom.xml | 159 ++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 79 deletions(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b2ac399aa4924..9449a3cba93fb 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -1,10 +1,11 @@ - + 4.0.0 com.microsoft.azure microsoft-azure-api 0.0.1-SNAPSHOT jar - + Microsoft Azure Client API API for Microsoft Azure Clients https://github.com/WindowsAzure/azure-sdk-for-java @@ -20,59 +21,59 @@ scm:git:https://github.com/WindowsAzure/azure-sdk-for-java scm:git:git://github.com/WindowsAzure/azure-sdk-for-java.git - + UTF-8 - - com.sun.jersey - jersey-client - 1.10-b02 - - javax.xml.bind - jaxb-api - 2.1 - provided + com.sun.jersey + jersey-client + 1.10-b02 + + + javax.xml.bind + jaxb-api + 2.1 + provided + + + junit + junit + 4.8 + test + + + org.hamcrest + hamcrest-all + 1.1 + test + + + org.mockito + mockito-all + test + 1.9.0-rc1 + + + javax.inject + javax.inject + 1 + + + com.sun.jersey + jersey-json + 1.10-b02 - - junit - junit - 4.8 - test - - org.hamcrest - hamcrest-all - 1.1 - test - - - org.mockito - mockito-all - test - 1.9.0-rc1 - - - javax.inject - javax.inject - 1 - - - com.sun.jersey - jersey-json - 1.10-b02 - - - commons-logging - commons-logging - 1.1.1 - + commons-logging + commons-logging + 1.1.1 + - + @@ -83,47 +84,47 @@ generate-sources - generate + generate - true - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.6.0 - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 0.6.0 - - - + true + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.6.0 + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 0.6.0 + + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.3.2 + + true + true + true - - - org.codehaus.mojo - findbugs-maven-plugin - 2.3.2 - - true - true - true - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.8 - - src/config/checkstyle.xml - - + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.8 + + src/config/checkstyle.xml + + From 2626a95f1e6c40bca24cbdcc361fe5982f7d99e3 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 23 Nov 2011 15:54:29 -0800 Subject: [PATCH 250/664] Inform javadoc which packages are implementation details. fixes #115 This will avoid producing documentation html output for material that is an internal implementation detail of the api --- microsoft-azure-api/pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 9449a3cba93fb..29cefdc5b0b4a 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -106,6 +106,15 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization + + + org.codehaus.mojo findbugs-maven-plugin @@ -125,6 +134,8 @@ src/config/checkstyle.xml + + From 44fe4ef6ef22a1910d459af7d11bdf3cd46ded47 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 23 Nov 2011 18:27:46 -0800 Subject: [PATCH 251/664] Merge javadoc and formatting changes --- .../blob/client/AccessPolicyResponse.java | 28 +- .../services/blob/client/BlobConstants.java | 64 +- .../client/BlobDeserializationHelper.java | 158 +- .../services/blob/client/BlobInputStream.java | 58 +- .../blob/client/BlobOutputStream.java | 72 +- .../services/blob/client/BlobRequest.java | 206 ++- .../services/blob/client/BlobResponse.java | 11 +- .../services/blob/client/BlobType.java | 9 +- .../services/blob/client/CloudBlob.java | 1317 ++++++++--------- .../services/blob/client/CloudBlobClient.java | 118 +- .../blob/client/CloudBlobContainer.java | 709 ++++----- .../blob/client/CloudBlobDirectory.java | 58 +- .../services/blob/client/CloudBlockBlob.java | 274 ++-- .../services/blob/client/CloudPageBlob.java | 204 ++- .../blob/client/ContainerRequest.java | 46 +- .../blob/client/ContainerResponse.java | 8 +- .../blob/client/GetBlockListResponse.java | 9 +- .../blob/client/GetPageRangesResponse.java | 6 +- .../blob/client/ListBlobsResponse.java | 24 +- .../blob/client/ListContainersResponse.java | 26 +- .../client/SharedAccessSignatureHelper.java | 55 +- .../core/storage/AccessCondition.java | 9 +- .../core/storage/CloudStorageAccount.java | 77 +- .../services/core/storage/LeaseStatus.java | 9 +- .../core/storage/OperationContext.java | 16 +- .../core/storage/RetryExponentialRetry.java | 13 +- .../core/storage/RetryLinearRetry.java | 8 +- .../services/core/storage/RetryNoRetry.java | 3 +- .../services/core/storage/RetryPolicy.java | 4 +- .../services/core/storage/RetryResult.java | 3 +- .../services/core/storage/ServiceClient.java | 96 +- .../core/storage/ServiceProperties.java | 103 +- .../core/storage/StorageCredentials.java | 34 +- .../StorageCredentialsAccountAndKey.java | 18 +- .../storage/StorageCredentialsAnonymous.java | 8 +- ...orageCredentialsSharedAccessSignature.java | 12 +- .../core/storage/StorageException.java | 24 +- .../StorageExtendedErrorInformation.java | 2 +- .../services/core/storage/StorageKey.java | 12 +- .../services/core/storage/utils/Base64.java | 39 +- .../core/storage/utils/PathUtility.java | 77 +- .../core/storage/utils/UriQueryBuilder.java | 12 +- .../services/core/storage/utils/Utility.java | 101 +- .../utils/implementation/BaseRequest.java | 87 +- .../utils/implementation/BaseResponse.java | 7 +- .../BlobQueueFullCanonicalizer.java | 14 +- .../BlobQueueLiteCanonicalizer.java | 14 +- .../utils/implementation/Canonicalizer.java | 21 +- .../implementation/CanonicalizerFactory.java | 16 +- .../implementation/DeserializationHelper.java | 6 +- .../utils/implementation/ExecutionEngine.java | 86 +- .../implementation/LazySegmentedIterator.java | 16 +- .../implementation/StorageErrorResponse.java | 23 +- .../implementation/StorageOperation.java | 4 +- .../TableLiteCanonicalizer.java | 3 +- .../services/queue/client/CloudQueue.java | 1262 ++++++++-------- .../queue/client/CloudQueueClient.java | 287 ++-- .../queue/client/CloudQueueMessage.java | 107 +- .../queue/client/ListQueuesResponse.java | 120 +- .../queue/client/MessageUpdateFields.java | 14 +- .../services/queue/client/QueueConstants.java | 25 +- .../client/QueueDeserializationHelper.java | 131 +- .../queue/client/QueueListingDetails.java | 10 +- .../queue/client/QueueMessageType.java | 12 +- .../services/queue/client/QueueRequest.java | 436 ++++-- .../queue/client/QueueRequestOptions.java | 21 +- .../services/queue/client/QueueResponse.java | 15 +- 67 files changed, 3582 insertions(+), 3295 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java index bb1e82a04ab15..b94caa98dbfc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java @@ -84,11 +84,13 @@ public void parseResponse() throws XMLStreamException, ParseException { if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { this.readPolicies(xmlr); - } else if (eventType == XMLStreamConstants.END_ELEMENT + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { break; } - } else if (eventType == XMLStreamConstants.END_DOCUMENT) { + } + else if (eventType == XMLStreamConstants.END_DOCUMENT) { break; } } @@ -120,7 +122,8 @@ private void readPolicies(final XMLStreamReader xmlr) throws XMLStreamException, if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { this.readSignedIdentifier(xmlr); - } else if (eventType == XMLStreamConstants.END_ELEMENT + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { break; } @@ -153,15 +156,18 @@ private SharedAccessPolicy readPolicyFromXML(final XMLStreamReader xmlr) throws final String name = xmlr.getName().toString(); if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.PERMISSION)) { - retPolicy.setPermissions(SharedAccessPolicy.permissionsFromString(Utility - .readElementFromXMLReader(xmlr, BlobConstants.PERMISSION))); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.START)) { + retPolicy.setPermissions(SharedAccessPolicy.permissionsFromString(Utility.readElementFromXMLReader( + xmlr, BlobConstants.PERMISSION))); + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.START)) { final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START); retPolicy.setSharedAccessStartTime(Utility.parseISO8061LongDateFromString(tempString)); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.EXPIRY)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.EXPIRY)) { final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.EXPIRY); retPolicy.setSharedAccessExpiryTime(Utility.parseISO8061LongDateFromString(tempString)); - } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { break; } } @@ -195,9 +201,11 @@ private void readSignedIdentifier(final XMLStreamReader xmlr) throws XMLStreamEx if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ID)) { id = Utility.readElementFromXMLReader(xmlr, Constants.ID); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { policy = this.readPolicyFromXML(xmlr); - } else if (eventType == XMLStreamConstants.END_ELEMENT + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { this.policies.put(id, policy); break; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java index 81329e0725e36..09533de03d77b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java @@ -62,8 +62,8 @@ public static class QueryConstants { /** * The header that specifies blob content MD5. */ - public static final String BLOB_CONTENT_MD5_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-content-md5"; + public static final String BLOB_CONTENT_MD5_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-md5"; /** * XML element for a blob. @@ -78,8 +78,8 @@ public static class QueryConstants { /** * The header that specifies public access to blobs. */ - public static final String BLOB_PUBLIC_ACCESS_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-public-access"; + public static final String BLOB_PUBLIC_ACCESS_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-public-access"; /** * XML element for a blob type. @@ -88,8 +88,8 @@ public static class QueryConstants { /** * The header for the blob type. */ - public static final String BLOB_TYPE_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-type"; + public static final String BLOB_TYPE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-type"; /** * XML element for blobs. @@ -139,29 +139,26 @@ public static class QueryConstants { /** * The header that specifies blob content encoding. */ - public static final String CONTENT_ENCODING_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-encoding"; + public static final String CONTENT_ENCODING_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-encoding"; /** * The header that specifies blob content language. */ - public static final String CONTENT_LANGUAGE_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-language"; + public static final String CONTENT_LANGUAGE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-language"; /** * The header that specifies blob content length. */ - public static final String CONTENT_LENGTH_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-length"; + public static final String CONTENT_LENGTH_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-length"; /** * The header that specifies blob content type. */ - public static final String CONTENT_TYPE_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "blob-content-type"; + public static final String CONTENT_TYPE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-type"; /** * The number of default concurrent requests for parallel operation. @@ -176,26 +173,22 @@ public static class QueryConstants { /** * The default write pages size, in bytes, used by blob stream for page blobs. */ - public static final int DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES = - 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + public static final int DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; /** * The default minimum read size, in bytes, for streams. */ - public static final int DEFAULT_MINIMUM_READ_SIZE_IN_BYTES = - 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + public static final int DEFAULT_MINIMUM_READ_SIZE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; /** * The default maximum size, in bytes, of a blob before it must be separated into blocks. */ - public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = - 32 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = 32 * com.microsoft.windowsazure.services.core.storage.Constants.MB; /** * The default write block size, in bytes, used by blob streams. */ - public static final int DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES = - 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + public static final int DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; /** * XML element for the end time of an access policy. @@ -220,8 +213,7 @@ public static class QueryConstants { /** * The maximum size, in bytes, of a blob before it must be separated into blocks. */ - public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = - 64 * com.microsoft.windowsazure.services.core.storage.Constants.MB; + public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = 64 * com.microsoft.windowsazure.services.core.storage.Constants.MB; /** * Specifies the page blob type. @@ -251,8 +243,8 @@ public static class QueryConstants { /** * The header that specifies page write mode. */ - public static final String PAGE_WRITE = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "page-write"; + public static final String PAGE_WRITE = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "page-write"; /** * XML element for the permission of an access policy. @@ -267,9 +259,8 @@ public static class QueryConstants { /** * The header for specifying the sequence number. */ - public static final String SEQUENCE_NUMBER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-sequence-number"; + public static final String SEQUENCE_NUMBER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-sequence-number"; /** * XML element for a signed identifier. @@ -284,9 +275,8 @@ public static class QueryConstants { /** * The header for the blob content length. */ - public static final String SIZE = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-length"; + public static final String SIZE = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "blob-content-length"; /** * XML element for the block length. @@ -306,8 +296,8 @@ public static class QueryConstants { /** * The header for snapshots. */ - public static final String SNAPSHOT_HEADER = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + "snapshot"; + public static final String SNAPSHOT_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "snapshot"; /** * Specifies only snapshots are to be included. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java index 2f0f7fb68dfe4..a803c37405bae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java @@ -36,9 +36,9 @@ final class BlobDeserializationHelper { * if the uri is invalid * @throws StorageException */ - protected static CloudBlob readBlob( - final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { + protected static CloudBlob readBlob(final XMLStreamReader xmlr, final CloudBlobClient serviceClient, + final CloudBlobContainer container) throws XMLStreamException, ParseException, URISyntaxException, + StorageException { xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_ELEMENT); String blobName = Constants.EMPTY_STRING; @@ -57,18 +57,23 @@ protected static CloudBlob readBlob( if (eventType == XMLStreamConstants.START_ELEMENT) { if (name.equals(Constants.URL_ELEMENT)) { urlString = Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT); - } else if (name.equals(BlobConstants.SNAPSHOT_ELEMENT)) { + } + else if (name.equals(BlobConstants.SNAPSHOT_ELEMENT)) { snapshotID = Utility.readElementFromXMLReader(xmlr, BlobConstants.SNAPSHOT_ELEMENT); - } else if (name.equals(Constants.NAME_ELEMENT)) { + } + else if (name.equals(Constants.NAME_ELEMENT)) { blobName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } else if (name.equals(BlobConstants.PROPERTIES)) { + } + else if (name.equals(BlobConstants.PROPERTIES)) { properties = BlobDeserializationHelper.readBlobProperties(xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - } else if (name.equals(Constants.METADATA_ELEMENT)) { + } + else if (name.equals(Constants.METADATA_ELEMENT)) { metadata = DeserializationHelper.parseMetadateFromXML(xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); } - } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.BLOB_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.BLOB_ELEMENT)) { break; } } @@ -87,15 +92,16 @@ protected static CloudBlob readBlob( query = urlString.substring(blobNameSectionIndex + blobName.length() + 1); } - final URI blobURI = - new URI(baseUri.getScheme(), baseUri.getAuthority(), baseUri.getRawPath().concat(blobName), query, - null); + final URI blobURI = new URI(baseUri.getScheme(), baseUri.getAuthority(), baseUri.getRawPath().concat( + blobName), query, null); if (properties.getBlobType() == BlobType.BLOCK_BLOB) { retBlob = new CloudBlockBlob(blobURI, serviceClient, container); - } else if (properties.getBlobType() == BlobType.PAGE_BLOB) { + } + else if (properties.getBlobType() == BlobType.PAGE_BLOB) { retBlob = new CloudPageBlob(blobURI, serviceClient, container); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); @@ -106,7 +112,8 @@ protected static CloudBlob readBlob( retBlob.properties = properties; retBlob.metadata = metadata; return retBlob; - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); @@ -149,15 +156,18 @@ public static ArrayList readBlobBlocks(final XMLStreamReader xmlr, f if (eventType == XMLStreamConstants.START_ELEMENT) { if (name.equals(Constants.NAME_ELEMENT)) { blockName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } else if (name.equals(BlobConstants.SIZE_ELEMENT)) { + } + else if (name.equals(BlobConstants.SIZE_ELEMENT)) { final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.SIZE_ELEMENT); blockSize = Long.parseLong(sizeString); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else if (eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT) { final BlockEntry newBlock = new BlockEntry(blockName, searchMode); newBlock.setSize(blockSize); retBlocks.add(newBlock); @@ -196,16 +206,20 @@ protected static BlobContainerAttributes readBlobContainerAttributes(final XMLSt if (name.equals(BlobConstants.PROPERTIES)) { attributes.setProperties(BlobDeserializationHelper.readBlobContainerProperties(xmlr)); xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - } else if (name.equals(Constants.URL_ELEMENT)) { + } + else if (name.equals(Constants.URL_ELEMENT)) { attributes.setUri(new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT))); - } else if (name.equals(Constants.NAME_ELEMENT)) { + } + else if (name.equals(Constants.NAME_ELEMENT)) { attributes.setName(Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT)); - } else if (name.equals(Constants.METADATA_ELEMENT)) { + } + else if (name.equals(Constants.METADATA_ELEMENT)) { // parse metadata attributes.setMetadata(DeserializationHelper.parseMetadateFromXML(xmlr)); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); } - } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.CONTAINER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.CONTAINER_ELEMENT)) { break; } } @@ -236,10 +250,12 @@ protected static BlobContainerProperties readBlobContainerProperties(final XMLSt if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); - } else if (name.equals(Constants.ETAG_ELEMENT)) { + } + else if (name.equals(Constants.ETAG_ELEMENT)) { properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); } - } else { + } + else { // expect end of properties xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); break; @@ -267,9 +283,9 @@ protected static BlobContainerProperties readBlobContainerProperties(final XMLSt * if the uri is invalid * @throws StorageException */ - public static ArrayList readBlobItems( - final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { + public static ArrayList readBlobItems(final XMLStreamReader xmlr, + final CloudBlobClient serviceClient, final CloudBlobContainer container) throws XMLStreamException, + ParseException, URISyntaxException, StorageException { int eventType = xmlr.getEventType(); final ArrayList retBlobs = new ArrayList(); @@ -283,14 +299,17 @@ public static ArrayList readBlobItems( if (eventType == XMLStreamConstants.START_ELEMENT) { if (name.equals(BlobConstants.BLOB_ELEMENT)) { retBlobs.add(BlobDeserializationHelper.readBlob(xmlr, serviceClient, container)); - } else if (name.equals(BlobConstants.BLOB_PREFIX_ELEMENT)) { + } + else if (name.equals(BlobConstants.BLOB_PREFIX_ELEMENT)) { retBlobs.add(BlobDeserializationHelper.readDirectory(xmlr, serviceClient, container)); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else { + } + else { break; } } @@ -311,8 +330,8 @@ public static ArrayList readBlobItems( * if a date value is not correctly encoded * @throws StorageException */ - protected static BlobProperties readBlobProperties(final XMLStreamReader xmlr) - throws XMLStreamException, ParseException, StorageException { + protected static BlobProperties readBlobProperties(final XMLStreamReader xmlr) throws XMLStreamException, + ParseException, StorageException { xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PROPERTIES); int eventType = xmlr.getEventType(); final BlobProperties properties = new BlobProperties(); @@ -325,57 +344,73 @@ protected static BlobProperties readBlobProperties(final XMLStreamReader xmlr) if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); - } else if (name.equals(Constants.ETAG_ELEMENT)) { + } + else if (name.equals(Constants.ETAG_ELEMENT)) { properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); - } else if (name.equals(Constants.HeaderConstants.CONTENT_LENGTH)) { - final String tempString = - Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_LENGTH); + } + else if (name.equals(Constants.HeaderConstants.CONTENT_LENGTH)) { + final String tempString = Utility.readElementFromXMLReader(xmlr, + Constants.HeaderConstants.CONTENT_LENGTH); properties.setLength(Long.parseLong(tempString)); - } else if (name.equals(Constants.HeaderConstants.CONTENT_TYPE)) { + } + else if (name.equals(Constants.HeaderConstants.CONTENT_TYPE)) { properties.setContentType(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_TYPE)); - } else if (name.equals(Constants.HeaderConstants.CONTENT_ENCODING)) { + } + else if (name.equals(Constants.HeaderConstants.CONTENT_ENCODING)) { properties.setContentEncoding(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_ENCODING)); - } else if (name.equals(Constants.HeaderConstants.CONTENT_LANGUAGE)) { + } + else if (name.equals(Constants.HeaderConstants.CONTENT_LANGUAGE)) { properties.setContentLanguage(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_LANGUAGE)); - } else if (name.equals(Constants.HeaderConstants.CONTENT_MD5)) { + } + else if (name.equals(Constants.HeaderConstants.CONTENT_MD5)) { properties.setContentMD5(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CONTENT_MD5)); - } else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { + } + else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CACHE_CONTROL)); - } else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { + } + else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, Constants.HeaderConstants.CACHE_CONTROL)); - } else if (name.equals(BlobConstants.SEQUENCE_NUMBER)) { + } + else if (name.equals(BlobConstants.SEQUENCE_NUMBER)) { // TODO what do we do with this? Utility.readElementFromXMLReader(xmlr, BlobConstants.SEQUENCE_NUMBER); - } else if (name.equals(BlobConstants.BLOB_TYPE_ELEMENT)) { + } + else if (name.equals(BlobConstants.BLOB_TYPE_ELEMENT)) { final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.BLOB_TYPE_ELEMENT); if (tempString.equals(BlobConstants.BLOCK_BLOB_VALUE)) { properties.setBlobType(BlobType.BLOCK_BLOB); - } else if (tempString.equals(BlobConstants.PAGE_BLOB_VALUE)) { + } + else if (tempString.equals(BlobConstants.PAGE_BLOB_VALUE)) { properties.setBlobType(BlobType.PAGE_BLOB); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else if (name.equals(Constants.LEASE_STATUS_ELEMENT)) { + } + else if (name.equals(Constants.LEASE_STATUS_ELEMENT)) { final String tempString = Utility.readElementFromXMLReader(xmlr, Constants.LEASE_STATUS_ELEMENT); if (tempString.equals(Constants.LOCKED_VALUE.toLowerCase())) { properties.setLeaseStatus(LeaseStatus.LOCKED); - } else if (tempString.equals(Constants.UNLOCKED_VALUE.toLowerCase())) { + } + else if (tempString.equals(Constants.UNLOCKED_VALUE.toLowerCase())) { properties.setLeaseStatus(LeaseStatus.UNLOCKED); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } } - } else if (eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT) { // expect end of properties xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); break; @@ -431,9 +466,9 @@ protected static CloudBlobContainer readContainer(final XMLStreamReader xmlr, fi * @throws URISyntaxException * @throws StorageException */ - public static ArrayList readContainers( - final XMLStreamReader xmlr, final CloudBlobClient serviceClient) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { + public static ArrayList readContainers(final XMLStreamReader xmlr, + final CloudBlobClient serviceClient) throws XMLStreamException, ParseException, URISyntaxException, + StorageException { int eventType = xmlr.getEventType(); xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); @@ -468,9 +503,9 @@ public static ArrayList readContainers( * if the uri is invalid * @throws StorageException */ - protected static CloudBlobDirectory readDirectory( - final XMLStreamReader xmlr, final CloudBlobClient serviceClient, final CloudBlobContainer container) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { + protected static CloudBlobDirectory readDirectory(final XMLStreamReader xmlr, final CloudBlobClient serviceClient, + final CloudBlobContainer container) throws XMLStreamException, ParseException, URISyntaxException, + StorageException { xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_PREFIX_ELEMENT); // Move to Name element @@ -500,8 +535,8 @@ protected static CloudBlobDirectory readDirectory( * if the uri is invalid * @throws StorageException */ - public static ArrayList readPageRanges(final XMLStreamReader xmlr) - throws XMLStreamException, StorageException { + public static ArrayList readPageRanges(final XMLStreamReader xmlr) throws XMLStreamException, + StorageException { int eventType = xmlr.getEventType(); final ArrayList retRanges = new ArrayList(); @@ -521,15 +556,18 @@ public static ArrayList readPageRanges(final XMLStreamReader xmlr) if (name.equals(BlobConstants.START_ELEMENT)) { final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START_ELEMENT); startOffset = Long.parseLong(sizeString); - } else if (name.equals(Constants.END_ELEMENT)) { + } + else if (name.equals(Constants.END_ELEMENT)) { final String sizeString = Utility.readElementFromXMLReader(xmlr, Constants.END_ELEMENT); endOffset = Long.parseLong(sizeString); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else if (eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT) { if (startOffset == -1 || endOffset == -1) { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java index fe35950b96612..e43ed84c2ca18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -152,8 +152,8 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); // Will validate it if it was returned - this.validateBlobMd5 = - !options.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(retrievedContentMD5Value); + this.validateBlobMd5 = !options.getDisableContentMD5Validation() + && !Utility.isNullOrEmpty(retrievedContentMD5Value); // Validates the first option, and sets future requests to use if match // request option. @@ -163,7 +163,7 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce String previousLeaseId = null; if (accessCondition != null) { previousLeaseId = accessCondition.getLeaseID(); - + if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef .getProperties().getLastModified())) { throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), @@ -180,7 +180,8 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce if (this.validateBlobMd5) { try { this.md5Digest = MessageDigest.getInstance("MD5"); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { // This wont happen, throw fatal. throw Utility.generateNewUnexpectedStorageException(e); } @@ -188,9 +189,10 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce if (this.parentBlobRef.getProperties().getBlobType() == BlobType.PAGE_BLOB && this.options.getUseSparsePageBlob()) { - this.pageBlobRanges = - ((CloudPageBlob) parentBlob).downloadPageRanges(this.accessCondition, options, opContext); - } else if (this.parentBlobRef.getProperties().getBlobType() == BlobType.BLOCK_BLOB) { + this.pageBlobRanges = ((CloudPageBlob) parentBlob).downloadPageRanges(this.accessCondition, options, + opContext); + } + else if (this.parentBlobRef.getProperties().getBlobType() == BlobType.BLOCK_BLOB) { if (this.options.getUseSparsePageBlob()) { throw new IllegalArgumentException( "The UseSparsePageBlob option is not applicable of Block Blob streams."); @@ -270,7 +272,8 @@ private synchronized void dispatchRead(final int readLength) throws IOException if (startRange != null) { resolvedReadStart = startRange.getStartOffset(); resolvedReadEnd = startRange.getEndOffset() + 1; - } else { + } + else { break; } } @@ -291,38 +294,30 @@ private synchronized void dispatchRead(final int readLength) throws IOException resolvedReadEnd = Math.min(resolvedReadEnd, this.currentAbsoluteReadPosition + readLength); final int bufferOffset = (int) (resolvedReadStart - this.currentAbsoluteReadPosition); - final int opReadLength = - (int) Math.min(readLength - bufferOffset, resolvedReadEnd - resolvedReadStart); + final int opReadLength = (int) Math.min(readLength - bufferOffset, resolvedReadEnd + - resolvedReadStart); // Do read if (opReadLength > 0) { - this.parentBlobRef.downloadRangeInternal(resolvedReadStart, - opReadLength, - byteBuffer, - bufferOffset, - this.accessCondition, - this.options, - this.opContext); + this.parentBlobRef.downloadRangeInternal(resolvedReadStart, opReadLength, byteBuffer, + bufferOffset, this.accessCondition, this.options, this.opContext); } } // ELSE=> no op, buffer already contains zeros. - } else { + } + else { // Non sparse read, do entire read length - this.parentBlobRef.downloadRangeInternal(this.currentAbsoluteReadPosition, - readLength, - byteBuffer, - 0, - this.accessCondition, - this.options, - this.opContext); + this.parentBlobRef.downloadRangeInternal(this.currentAbsoluteReadPosition, readLength, byteBuffer, 0, + this.accessCondition, this.options, this.opContext); } this.currentBuffer = new ByteArrayInputStream(byteBuffer); this.bufferSize = readLength; this.bufferStartOffset = this.currentAbsoluteReadPosition; - } catch (final StorageException e) { + } + catch (final StorageException e) { this.streamFaulted = true; this.lastError = Utility.initIOException(e); throw this.lastError; @@ -513,12 +508,13 @@ private synchronized int readInternal(final byte[] b, final int off, int len) th // Reached end of stream, validate md5. final String calculatedMd5 = Base64.encode(this.md5Digest.digest()); if (!calculatedMd5.equals(this.parentBlobRef.getProperties().getContentMD5())) { - this.lastError = - Utility.initIOException(new StorageException( + this.lastError = Utility + .initIOException(new StorageException( StorageErrorCodeStrings.INVALID_MD5, - String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - this.parentBlobRef.getProperties().getContentMD5(), - calculatedMd5), Constants.HeaderConstants.HTTP_UNUSED_306, null, null)); + String.format( + "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + this.parentBlobRef.getProperties().getContentMD5(), calculatedMd5), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null)); this.streamFaulted = true; throw this.lastError; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java index 33f743087a507..87890fa33ac8a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -167,7 +167,8 @@ protected BlobOutputStream(final CloudBlob parentBlob, final AccessCondition acc if (this.options.getStoreBlobContentMD5()) { try { this.md5Digest = MessageDigest.getInstance("MD5"); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { // This wont happen, throw fatal. throw Utility.generateNewUnexpectedStorageException(e); } @@ -195,9 +196,8 @@ protected BlobOutputStream(final CloudBlob parentBlob, final AccessCondition acc protected BlobOutputStream(final CloudBlockBlob parentBlob, final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) throws StorageException { this((CloudBlob) parentBlob, accessCondition, options, opContext); - this.blockIdSequenceNumber = - (long) (blockSequenceGenerator.nextInt(Integer.MAX_VALUE)) - + blockSequenceGenerator.nextInt(Integer.MAX_VALUE - 100000); + this.blockIdSequenceNumber = (long) (blockSequenceGenerator.nextInt(Integer.MAX_VALUE)) + + blockSequenceGenerator.nextInt(Integer.MAX_VALUE - 100000); this.blockList = new ArrayList(); this.streamType = BlobType.BLOCK_BLOB; @@ -226,8 +226,8 @@ protected BlobOutputStream(final CloudPageBlob parentBlob, final long length, throws StorageException { this(parentBlob, accessCondition, options, opContext); this.streamType = BlobType.PAGE_BLOB; - this.internalWriteThreshold = - (int) Math.min(this.parentBlobRef.blobServiceClient.getPageBlobStreamWriteSizeInBytes(), length); + this.internalWriteThreshold = (int) Math.min( + this.parentBlobRef.blobServiceClient.getPageBlobStreamWriteSizeInBytes(), length); if (length % BlobConstants.PAGE_SIZE != 0) { throw new IllegalArgumentException("Page blob length must be multiple of 512."); @@ -286,7 +286,8 @@ public void close() throws IOException { try { this.commit(); - } catch (final StorageException e) { + } + catch (final StorageException e) { throw Utility.initIOException(e); } } @@ -311,7 +312,8 @@ private void commit() throws StorageException, IOException { final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; blobRef.commitBlockList(this.blockList, this.accessCondition, this.options, this.opContext); - } else if (this.streamType == BlobType.PAGE_BLOB) { + } + else if (this.streamType == BlobType.PAGE_BLOB) { this.parentBlobRef.uploadProperties(this.accessCondition, this.options, this.opContext); } } @@ -344,21 +346,19 @@ private synchronized void dispatchWrite(final int writeLength) throws IOExceptio final String blockID = Base64.encode(Utility.getBytesFromLong(this.blockIdSequenceNumber++)); this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED)); - worker = new Callable() { + worker = new Callable() { public Void call() { try { - blobRef.uploadBlock(blockID, - bufferRef, - writeLength, - BlobOutputStream.this.accessCondition, - BlobOutputStream.this.options, - BlobOutputStream.this.opContext); - } catch (final IOException e) { + blobRef.uploadBlock(blockID, bufferRef, writeLength, BlobOutputStream.this.accessCondition, + BlobOutputStream.this.options, BlobOutputStream.this.opContext); + } + catch (final IOException e) { synchronized (BlobOutputStream.this.lastErrorLock) { BlobOutputStream.this.streamFaulted = true; BlobOutputStream.this.lastError = e; } - } catch (final StorageException e) { + } + catch (final StorageException e) { synchronized (BlobOutputStream.this.lastErrorLock) { BlobOutputStream.this.streamFaulted = true; BlobOutputStream.this.lastError = Utility.initIOException(e); @@ -367,7 +367,8 @@ public Void call() { return null; } }; - } else if (this.streamType == BlobType.PAGE_BLOB) { + } + else if (this.streamType == BlobType.PAGE_BLOB) { final CloudPageBlob blobRef = (CloudPageBlob) this.parentBlobRef; long tempOffset = this.currentPageOffset; long tempLength = writeLength; @@ -384,17 +385,16 @@ public Void call() { } // Offset is currentOffset - extra data to page align write - final long bufferOffset = - this.firstNonZeroBufferedByte - this.firstNonZeroBufferedByte % BlobConstants.PAGE_SIZE; + final long bufferOffset = this.firstNonZeroBufferedByte - this.firstNonZeroBufferedByte + % BlobConstants.PAGE_SIZE; tempOffset = this.currentPageOffset + bufferOffset; // Find end of last full page - to do this Calculate the end of // last full page of non zero // data and subtract the bufferStarting offset calculated above - tempLength = - (this.lastNonZeroBufferedByte - bufferOffset) - + (BlobConstants.PAGE_SIZE - (this.lastNonZeroBufferedByte % BlobConstants.PAGE_SIZE)); + tempLength = (this.lastNonZeroBufferedByte - bufferOffset) + + (BlobConstants.PAGE_SIZE - (this.lastNonZeroBufferedByte % BlobConstants.PAGE_SIZE)); // Reset buffer markers. this.firstNonZeroBufferedByte = -1; @@ -418,18 +418,16 @@ public Void call() { worker = new Callable() { public Void call() { try { - blobRef.uploadPages(bufferRef, - opOffset, - opWriteLength, - BlobOutputStream.this.accessCondition, - BlobOutputStream.this.options, - BlobOutputStream.this.opContext); - } catch (final IOException e) { + blobRef.uploadPages(bufferRef, opOffset, opWriteLength, BlobOutputStream.this.accessCondition, + BlobOutputStream.this.options, BlobOutputStream.this.opContext); + } + catch (final IOException e) { synchronized (BlobOutputStream.this.lastErrorLock) { BlobOutputStream.this.streamFaulted = true; BlobOutputStream.this.lastError = e; } - } catch (final StorageException e) { + } + catch (final StorageException e) { synchronized (BlobOutputStream.this.lastErrorLock) { BlobOutputStream.this.streamFaulted = true; BlobOutputStream.this.lastError = Utility.initIOException(e); @@ -458,9 +456,9 @@ public synchronized void flush() throws IOException { if (this.streamType == BlobType.PAGE_BLOB && this.currentBufferedBytes > 0 && (this.currentBufferedBytes % BlobConstants.PAGE_SIZE != 0)) { - throw new IOException( - String.format("Page data must be a multiple of 512 bytes, buffer currently contains %d bytes.", - this.currentBufferedBytes)); + throw new IOException(String.format( + "Page data must be a multiple of 512 bytes, buffer currently contains %d bytes.", + this.currentBufferedBytes)); // Non 512 byte remainder, uncomment to pad with bytes and commit. /* @@ -483,9 +481,11 @@ private void waitForTaskToComplete() throws IOException { try { final Future future = this.completionService.take(); future.get(); - } catch (final InterruptedException e) { + } + catch (final InterruptedException e) { throw Utility.initIOException(e); - } catch (final ExecutionException e) { + } + catch (final ExecutionException e) { throw Utility.initIOException(e); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java index b8092d104d292..b1d4b9b28a739 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java @@ -35,8 +35,8 @@ final class BlobRequest { * @param metadata * The metadata. */ - public static void addMetadata( - final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final HashMap metadata, + final OperationContext opContext) { BaseRequest.addMetadata(request, metadata, opContext); } @@ -50,8 +50,8 @@ public static void addMetadata( * @param value * The metadata value. */ - public static void addMetadata( - final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final String name, final String value, + final OperationContext opContext) { BaseRequest.addMetadata(request, name, value, opContext); } @@ -81,11 +81,10 @@ public static void addMetadata( * @throws IOException * @throws URISyntaxException */ - public static HttpURLConnection copyFrom( - final URI uri, final int timeout, String source, final String sourceSnapshotID, - final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws StorageException, IOException, URISyntaxException { + public static HttpURLConnection copyFrom(final URI uri, final int timeout, String source, + final String sourceSnapshotID, final AccessCondition sourceAccessCondition, + final AccessCondition destinationAccessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws StorageException, IOException, URISyntaxException { if (sourceSnapshotID != null) { source = source.concat("?snapshot="); @@ -129,9 +128,9 @@ public static HttpURLConnection copyFrom( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - private static HttpURLConnection createURLConnection( - final URI uri, final int timeout, final UriQueryBuilder query, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + private static HttpURLConnection createURLConnection(final URI uri, final int timeout, final UriQueryBuilder query, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { return BaseRequest.createURLConnection(uri, timeout, query, opContext); } @@ -161,17 +160,15 @@ private static HttpURLConnection createURLConnection( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection delete( - final URI uri, final int timeout, final String snapshotVersion, + public static HttpURLConnection delete(final URI uri, final int timeout, final String snapshotVersion, final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) { - throw new IllegalArgumentException( - String.format("The option '%s' must be 'None' to delete a specific snapshot specified by '%s'", - "deleteSnapshotsOption", - "snapshot")); + throw new IllegalArgumentException(String.format( + "The option '%s' must be 'None' to delete a specific snapshot specified by '%s'", + "deleteSnapshotsOption", "snapshot")); } final UriQueryBuilder builder = new UriQueryBuilder(); @@ -229,15 +226,14 @@ public static HttpURLConnection delete( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection get( - final URI uri, final int timeout, final String snapshotVersion, final long offset, final long count, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection get(final URI uri, final int timeout, final String snapshotVersion, + final long offset, final long count, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { final HttpURLConnection request = get(uri, timeout, snapshotVersion, accessCondition, blobOptions, opContext); - final String rangeHeaderValue = - String.format(Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, offset, offset + count - - 1); + final String rangeHeaderValue = String.format(Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, + offset, offset + count - 1); request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, rangeHeaderValue); @@ -268,10 +264,9 @@ public static HttpURLConnection get( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection get( - final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection get(final URI uri, final int timeout, final String snapshotVersion, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); BaseRequest.addSnapshot(builder, snapshotVersion); @@ -311,10 +306,10 @@ public static HttpURLConnection get( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection getBlockList( - final URI uri, final int timeout, final String snapshotVersion, final BlockListingFilter blockFilter, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws StorageException, IOException, URISyntaxException { + public static HttpURLConnection getBlockList(final URI uri, final int timeout, final String snapshotVersion, + final BlockListingFilter blockFilter, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws StorageException, + IOException, URISyntaxException { final UriQueryBuilder builder = new UriQueryBuilder(); @@ -356,17 +351,16 @@ public static HttpURLConnection getBlockList( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection getPageRanges( - final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws StorageException, IOException, URISyntaxException { + public static HttpURLConnection getPageRanges(final URI uri, final int timeout, final String snapshotVersion, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws StorageException, IOException, URISyntaxException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "pagelist"); BaseRequest.addSnapshot(builder, snapshotVersion); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setRequestMethod("GET"); if (accessCondition != null) { @@ -401,10 +395,9 @@ public static HttpURLConnection getPageRanges( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection getProperties( - final URI uri, final int timeout, final String snapshotVersion, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws StorageException, IOException, URISyntaxException { + public static HttpURLConnection getProperties(final URI uri, final int timeout, final String snapshotVersion, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws StorageException, IOException, URISyntaxException { final UriQueryBuilder builder = new UriQueryBuilder(); BaseRequest.addSnapshot(builder, snapshotVersion); @@ -441,16 +434,15 @@ public static HttpURLConnection getProperties( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection lease( - final URI uri, final int timeout, final LeaseAction action, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection lease(final URI uri, final int timeout, final LeaseAction action, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "lease"); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setDoOutput(true); request.setRequestMethod("PUT"); @@ -485,10 +477,9 @@ public static HttpURLConnection lease( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException * */ - public static HttpURLConnection list( - final URI uri, final int timeout, final BlobListingContext listingContext, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection list(final URI uri, final int timeout, final BlobListingContext listingContext, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws URISyntaxException, + IOException, StorageException { final UriQueryBuilder builder = ContainerRequest.getContainerUriQueryBuilder(); builder.add("comp", "list"); @@ -518,7 +509,8 @@ public static HttpURLConnection list( if (listingContext.getListingDetails().contains(BlobListingDetails.SNAPSHOTS)) { if (!started) { started = true; - } else { + } + else { sb.append(","); } @@ -528,7 +520,8 @@ public static HttpURLConnection list( if (listingContext.getListingDetails().contains(BlobListingDetails.UNCOMMITTED_BLOBS)) { if (!started) { started = true; - } else { + } + else { sb.append(","); } @@ -538,7 +531,8 @@ public static HttpURLConnection list( if (listingContext.getListingDetails().contains(BlobListingDetails.METADATA)) { if (!started) { started = true; - } else { + } + else { sb.append(","); } @@ -549,8 +543,8 @@ public static HttpURLConnection list( } } - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setRequestMethod("GET"); @@ -585,10 +579,10 @@ public static HttpURLConnection list( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection put( - final URI uri, final int timeout, final BlobProperties properties, final BlobType blobType, - final long pageBlobSize, final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection put(final URI uri, final int timeout, final BlobProperties properties, + final BlobType blobType, final long pageBlobSize, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { if (blobType == BlobType.UNSPECIFIED) { throw new IllegalArgumentException("The blob type cannot be undefined."); } @@ -603,11 +597,9 @@ public static HttpURLConnection put( BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL, properties.getCacheControl()); BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_TYPE, properties.getContentType()); BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_MD5, properties.getContentMD5()); - BaseRequest.addOptionalHeader(request, - Constants.HeaderConstants.CONTENT_LANGUAGE, + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_LANGUAGE, properties.getContentLanguage()); - BaseRequest.addOptionalHeader(request, - Constants.HeaderConstants.CONTENT_ENCODING, + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_ENCODING, properties.getContentEncoding()); if (blobType == BlobType.PAGE_BLOB) { @@ -618,7 +610,8 @@ public static HttpURLConnection put( request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize)); properties.setLength(pageBlobSize); - } else { + } + else { request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB); } @@ -653,16 +646,15 @@ public static HttpURLConnection put( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection putBlock( - final URI uri, final int timeout, final String blockId, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection putBlock(final URI uri, final int timeout, final String blockId, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "block"); builder.add("blockid", blockId); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setDoOutput(true); request.setRequestMethod("PUT"); @@ -696,16 +688,15 @@ public static HttpURLConnection putBlock( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection putBlockList( - final URI uri, final int timeout, final BlobProperties properties, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection putBlockList(final URI uri, final int timeout, final BlobProperties properties, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "blocklist"); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setDoOutput(true); request.setRequestMethod("PUT"); @@ -714,8 +705,7 @@ public static HttpURLConnection putBlockList( accessCondition.applyConditionToRequest(request); } - BaseRequest.addOptionalHeader(request, - Constants.HeaderConstants.CACHE_CONTROL_HEADER, + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL_HEADER, properties.getCacheControl()); BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); @@ -749,15 +739,14 @@ public static HttpURLConnection putBlockList( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection putPage( - final URI uri, final int timeout, final PageProperties properties, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection putPage(final URI uri, final int timeout, final PageProperties properties, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "page"); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setDoOutput(true); request.setRequestMethod("PUT"); @@ -799,10 +788,9 @@ public static HttpURLConnection putPage( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection setMetadata( - final URI uri, final int timeout, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection setMetadata(final URI uri, final int timeout, + final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final HttpURLConnection request = BaseRequest.setMetadata(uri, timeout, null, opContext); if (accessCondition != null) { @@ -837,15 +825,14 @@ public static HttpURLConnection setMetadata( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection setProperties( - final URI uri, final int timeout, final BlobProperties properties, final Long newBlobSize, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, + public static HttpURLConnection setProperties(final URI uri, final int timeout, final BlobProperties properties, + final Long newBlobSize, final AccessCondition accessCondition, final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "properties"); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setFixedLengthStreamingMode(0); request.setDoOutput(true); @@ -860,8 +847,7 @@ public static HttpURLConnection setProperties( properties.setLength(newBlobSize); } - BaseRequest.addOptionalHeader(request, - Constants.HeaderConstants.CACHE_CONTROL_HEADER, + BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL_HEADER, properties.getCacheControl()); BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); @@ -893,14 +879,13 @@ public static HttpURLConnection setProperties( * an exception representing any error which occurred during the operation. * @throws IllegalArgumentException */ - public static HttpURLConnection snapshot( - final URI uri, final int timeout, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection snapshot(final URI uri, final int timeout, final AccessCondition accessCondition, + final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add(Constants.HeaderConstants.COMP, BlobConstants.SNAPSHOT); - final HttpURLConnection request = - BlobRequest.createURLConnection(uri, timeout, builder, blobOptions, opContext); + final HttpURLConnection request = BlobRequest + .createURLConnection(uri, timeout, builder, blobOptions, opContext); request.setFixedLengthStreamingMode(0); request.setDoOutput(true); @@ -939,9 +924,11 @@ public static byte[] writeBlockListToStream(final Iterable blockList for (final BlockEntry block : blockList) { if (block.searchMode == BlockSearchMode.COMMITTED) { xmlw.writeStartElement(BlobConstants.COMMITTED_ELEMENT); - } else if (block.searchMode == BlockSearchMode.UNCOMMITTED) { + } + else if (block.searchMode == BlockSearchMode.UNCOMMITTED) { xmlw.writeStartElement(BlobConstants.UNCOMMITTED_ELEMENT); - } else if (block.searchMode == BlockSearchMode.LATEST) { + } + else if (block.searchMode == BlockSearchMode.LATEST) { xmlw.writeStartElement(BlobConstants.LATEST_ELEMENT); } @@ -956,7 +943,8 @@ public static byte[] writeBlockListToStream(final Iterable blockList xmlw.writeEndDocument(); try { return outWriter.toString().getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java index 34c8bd5c42e15..f4f0e6fac11e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java @@ -30,9 +30,8 @@ final class BlobResponse extends BaseResponse { * a tracking object for the request * @return the BlobAttributes from the given request */ - public static BlobAttributes getAttributes( - final HttpURLConnection request, final URI resourceURI, final String snapshotID, - final OperationContext opContext) { + public static BlobAttributes getAttributes(final HttpURLConnection request, final URI resourceURI, + final String snapshotID, final OperationContext opContext) { final String blobType = request.getHeaderField(BlobConstants.BLOB_TYPE_HEADER); final BlobAttributes attributes = new BlobAttributes(BlobType.parse(blobType)); @@ -60,9 +59,11 @@ public static BlobAttributes getAttributes( if (!Utility.isNullOrEmpty(rangeHeader)) { properties.setLength(Long.parseLong(rangeHeader)); - } else if (!Utility.isNullOrEmpty(xContentLengthHeader)) { + } + else if (!Utility.isNullOrEmpty(xContentLengthHeader)) { properties.setLength(Long.parseLong(xContentLengthHeader)); - } else { + } + else { // using this instead of the request property since the request // property only returns an int. final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java index 1b77be9e4b419..e5559596908f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java @@ -39,11 +39,14 @@ public enum BlobType { public static BlobType parse(final String typeString) { if (Utility.isNullOrEmpty(typeString)) { return UNSPECIFIED; - } else if ("blockblob".equals(typeString.toLowerCase(Locale.US))) { + } + else if ("blockblob".equals(typeString.toLowerCase(Locale.US))) { return BLOCK_BLOB; - } else if ("pageblob".equals(typeString.toLowerCase(Locale.US))) { + } + else if ("pageblob".equals(typeString.toLowerCase(Locale.US))) { return PAGE_BLOB; - } else { + } + else { return UNSPECIFIED; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 39c250c36754e..c65f1631a2fb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -164,7 +164,8 @@ protected CloudBlob(final BlobType type, final URI uri, final String snapshotID, if (this.snapshotID != null) { throw new IllegalArgumentException( "Snapshot query parameter is already defined in the blobUri. Either pass in a snapshotTime parameter or use a full URL with a snapshot query parameter."); - } else { + } + else { this.snapshotID = snapshotID; } } @@ -228,9 +229,8 @@ public final String acquireLease() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final String acquireLease( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final String acquireLease(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -242,42 +242,34 @@ public final String acquireLease( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public String execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.lease(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - LeaseAction.ACQUIRE, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public String execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); - blob.properties.setLeaseStatus(LeaseStatus.LOCKED); + final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.ACQUIRE, accessCondition, + blobOptions, opContext); - return BlobResponse.getLeaseID(request, opContext); - } - }; + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + blob.properties.setLeaseStatus(LeaseStatus.LOCKED); + + return BlobResponse.getLeaseID(request, opContext); + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -291,16 +283,18 @@ protected final void assertCorrectBlobType() throws StorageException { if (this instanceof CloudBlockBlob && this.properties.getBlobType() != BlobType.BLOCK_BLOB) { throw new StorageException( StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - BlobType.BLOCK_BLOB, - this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + String.format( + "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + BlobType.BLOCK_BLOB, this.properties.getBlobType()), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } if (this instanceof CloudPageBlob && this.properties.getBlobType() != BlobType.PAGE_BLOB) { throw new StorageException( StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - BlobType.PAGE_BLOB, - this.properties.getBlobType()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + String.format( + "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + BlobType.PAGE_BLOB, this.properties.getBlobType()), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } } @@ -340,9 +334,8 @@ public final long breakLease() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final long breakLease( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final long breakLease(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -354,43 +347,35 @@ public final long breakLease( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Long execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.lease(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - LeaseAction.BREAK, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return -1L; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Long execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); - final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, accessCondition, blobOptions, + opContext); - blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); - return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); - } - }; + client.getCredentials().signRequest(request, 0L); - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return -1L; + } + + blob.updatePropertiesFromResponse(request); + final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + + blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); + return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -433,8 +418,7 @@ public final void copyFromBlob(final CloudBlob sourceBlob) throws StorageExcepti * */ @DoesServiceRequest - public final void copyFromBlob( - final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, + public final void copyFromBlob(final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { @@ -448,39 +432,32 @@ public final void copyFromBlob( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.copyFrom(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - sourceBlob.getCanonicalName(false), - blob.snapshotID, - sourceAccessCondition, - destinationAccessCondition, - blobOptions, - opContext); - - BlobRequest.addMetadata(request, sourceBlob.metadata, opContext); - client.getCredentials().signRequest(request, 0); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); + final HttpURLConnection request = BlobRequest.copyFrom(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), sourceBlob.getCanonicalName(false), blob.snapshotID, + sourceAccessCondition, destinationAccessCondition, blobOptions, opContext); - return null; - } - }; + BlobRequest.addMetadata(request, sourceBlob.metadata, opContext); + client.getCredentials().signRequest(request, 0); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -519,9 +496,8 @@ public final CloudBlob createSnapshot() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final CloudBlob createSnapshot( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final CloudBlob createSnapshot(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -533,43 +509,39 @@ public final CloudBlob createSnapshot( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public CloudBlob execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + final StorageOperation impl = new StorageOperation( + options) { + @Override + public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, + final OperationContext opContext) throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.snapshot(blob.getTransformedAddress(opContext), this.getRequestOptions() - .getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + final HttpURLConnection request = BlobRequest.snapshot(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); - client.getCredentials().signRequest(request, 0L); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - CloudBlob snapshot = null; - final String snapshotTime = BlobResponse.getSnapshotTime(request, opContext); - if (blob instanceof CloudBlockBlob) { - snapshot = new CloudBlockBlob(blob.getUri(), snapshotTime, client); - } else if (blob instanceof CloudPageBlob) { - snapshot = new CloudPageBlob(blob.getUri(), snapshotTime, client); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + CloudBlob snapshot = null; + final String snapshotTime = BlobResponse.getSnapshotTime(request, opContext); + if (blob instanceof CloudBlockBlob) { + snapshot = new CloudBlockBlob(blob.getUri(), snapshotTime, client); + } + else if (blob instanceof CloudPageBlob) { + snapshot = new CloudPageBlob(blob.getUri(), snapshotTime, client); + } - blob.updatePropertiesFromResponse(request); - return snapshot; - } - }; + blob.updatePropertiesFromResponse(request); + return snapshot; + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -610,8 +582,7 @@ public final void delete() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final void delete( - final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, + public final void delete(final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); @@ -626,35 +597,29 @@ public final void delete( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.delete(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.snapshotID, - deleteSnapshotsOption, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - return null; - } - }; + final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, + accessCondition, blobOptions, opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -707,9 +672,9 @@ public final Boolean deleteIfExists() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final Boolean deleteIfExists( - final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException { + public final Boolean deleteIfExists(final DeleteSnapshotsOption deleteSnapshotsOption, + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); if (opContext == null) { @@ -723,45 +688,38 @@ public final Boolean deleteIfExists( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Boolean execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.delete(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.snapshotID, - deleteSnapshotsOption, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - blob.updatePropertiesFromResponse(request); - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } else { - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - } - }; + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, + accessCondition, blobOptions, opContext); - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + blob.updatePropertiesFromResponse(request); + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } + else { + this.setNonExceptionedRetryableFailure(true); + + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -803,9 +761,8 @@ public final void download(final OutputStream outStream) throws StorageException * If a storage service error occurred. */ @DoesServiceRequest - public final void download( - final OutputStream outStream, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException, IOException { + public final void download(final OutputStream outStream, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { if (opContext == null) { opContext = new OperationContext(); } @@ -817,81 +774,66 @@ public final void download( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.get(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blob.snapshotID, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); - - final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - final Boolean validateMD5 = - !blobOptions.getDisableContentMD5Validation() && !Utility.isNullOrEmpty(contentMD5); - - final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - final long expectedLength = Long.parseLong(contentLength); - - final StreamDescriptor descriptor = - Utility.writeToOutputStream(streamRef, - outStream, - -1, - false, - validateMD5, - this.getResult(), - opContext); - - ExecutionEngine.getResponseCode(this.getResult(), request, opContext); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); + final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); - if (descriptor.getLength() != expectedLength) { - throw new StorageException( - StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect number of bytes was read from the connection. The connection may have been closed", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } + client.getCredentials().signRequest(request, -1L); + final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); + this.setResult(opContext.getLastResult()); - if (validateMD5 && !contentMD5.equals(descriptor.getMd5())) { - throw new StorageException( - StorageErrorCodeStrings.INVALID_MD5, - String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - contentMD5, - descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } + final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + final Boolean validateMD5 = !blobOptions.getDisableContentMD5Validation() + && !Utility.isNullOrEmpty(contentMD5); - return null; - } - }; + final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + final long expectedLength = Long.parseLong(contentLength); + + final StreamDescriptor descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, + validateMD5, this.getResult(), opContext); + + ExecutionEngine.getResponseCode(this.getResult(), request, opContext); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + + if (descriptor.getLength() != expectedLength) { + throw new StorageException( + StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect number of bytes was read from the connection. The connection may have been closed", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + if (validateMD5 && !contentMD5.equals(descriptor.getMd5())) { + throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( + "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + contentMD5, descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + return null; + } + }; try { // Executed with no retries so that the first failure will move out // to the read Stream. ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, RetryNoRetry.getInstance(), opContext); opContext.setIntermediateMD5(null); - } catch (final StorageException ex) { + } + catch (final StorageException ex) { // Check if users has any retries specified. final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext); - if (!dummyPolicy.shouldRetry(0, - opContext.getLastResult().getStatusCode(), - (Exception) ex.getCause(), + if (!dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), (Exception) ex.getCause(), opContext).isShouldRetry()) { opContext.setIntermediateMD5(null); throw ex; @@ -923,21 +865,22 @@ public Void execute( } // 3. Continue copying - final StreamDescriptor descriptor = - Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMd5, null, opContext); + final StreamDescriptor descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, + validateMd5, null, opContext); if (validateMd5 && !this.properties.getContentMD5().equals(descriptor.getMd5())) { - throw new StorageException( - StorageErrorCodeStrings.INVALID_MD5, - String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - this.properties.getContentMD5(), - descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( + "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + this.properties.getContentMD5(), descriptor.getMd5()), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } catch (final IOException secondEx) { + } + catch (final IOException secondEx) { opContext.setIntermediateMD5(null); if (secondEx.getCause() != null && secondEx.getCause() instanceof StorageException) { throw (StorageException) secondEx.getCause(); - } else { + } + else { throw secondEx; } } @@ -981,9 +924,8 @@ public final void downloadAttributes() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final void downloadAttributes( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final void downloadAttributes(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -994,51 +936,46 @@ public final void downloadAttributes( options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.getProperties(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.snapshotID, - accessCondition, - blobOptions, - opContext); + final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, + opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - // Set attributes - final BlobAttributes retrievedAttributes = - BlobResponse.getAttributes(request, blob.getUri(), blob.snapshotID, opContext); + // Set attributes + final BlobAttributes retrievedAttributes = BlobResponse.getAttributes(request, blob.getUri(), + blob.snapshotID, opContext); - if (retrievedAttributes.getProperties().getBlobType() != blob.properties.getBlobType()) { - throw new StorageException( - StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format("Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - blob.properties.getBlobType(), - retrievedAttributes.getProperties().getBlobType()), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } + if (retrievedAttributes.getProperties().getBlobType() != blob.properties.getBlobType()) { + throw new StorageException( + StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, + String.format( + "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", + blob.properties.getBlobType(), retrievedAttributes.getProperties().getBlobType()), + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } - blob.properties = retrievedAttributes.getProperties(); - blob.metadata = retrievedAttributes.getMetadata(); + blob.properties = retrievedAttributes.getProperties(); + blob.metadata = retrievedAttributes.getMetadata(); - return null; - } - }; + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -1092,8 +1029,7 @@ public final void downloadRange(final long offset, final int length, final byte[ * If a storage service error occurred. */ @DoesServiceRequest - public final void downloadRange( - final long offset, final int length, final byte[] buffer, final int bufferOffet, + public final void downloadRange(final long offset, final int length, final byte[] buffer, final int bufferOffet, final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) throws StorageException { if (offset < 0 || length <= 0) { @@ -1131,10 +1067,9 @@ public final void downloadRange( * an exception representing any error which occurred during the operation. */ @DoesServiceRequest - protected final void downloadRangeInternal( - final long blobOffset, final int length, final byte[] buffer, final int bufferOffset, - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + protected final void downloadRangeInternal(final long blobOffset, final int length, final byte[] buffer, + final int bufferOffset, final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (blobOffset < 0 || length <= 0) { throw new IndexOutOfBoundsException(); } @@ -1154,94 +1089,85 @@ protected final void downloadRangeInternal( "Cannot specify x-ms-range-get-content-md5 header on ranges larger than 4 MB. Either use a BlobReadStream via openRead, or disable TransactionalMD5 checking via the BlobRequestOptions."); } - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.get(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blob.snapshotID, - blobOffset, - length, - accessCondition, - blobOptions, - opContext); - - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - client.getCredentials().signRequest(request, -1L); - - final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); - - int totalRead = 0; - int nextRead = buffer.length - bufferOffset; - int count = sourceStream.read(buffer, bufferOffset, nextRead); - - while (count > 0) { - totalRead += count; - nextRead = buffer.length - (bufferOffset + totalRead); - - if (nextRead == 0) { - // check for case where more data is returned - if (sourceStream.read(new byte[1], 0, 1) != -1) { - throw new StorageException( - StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect number of bytes was read from the connection. The connection may have been closed", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - count = sourceStream.read(buffer, bufferOffset + totalRead, nextRead); - } + final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blobOffset, length, accessCondition, + blobOptions, opContext); - ExecutionEngine.getResponseCode(this.getResult(), request, opContext); + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); + } - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_PARTIAL) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + client.getCredentials().signRequest(request, -1L); + + final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext); + this.setResult(opContext.getLastResult()); - blob.updatePropertiesFromResponse(request); - final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - final long expectedLength = Long.parseLong(contentLength); - if (totalRead != expectedLength) { + int totalRead = 0; + int nextRead = buffer.length - bufferOffset; + int count = sourceStream.read(buffer, bufferOffset, nextRead); + + while (count > 0) { + totalRead += count; + nextRead = buffer.length - (bufferOffset + totalRead); + + if (nextRead == 0) { + // check for case where more data is returned + if (sourceStream.read(new byte[1], 0, 1) != -1) { throw new StorageException( StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, "An incorrect number of bytes was read from the connection. The connection may have been closed", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } + } + count = sourceStream.read(buffer, bufferOffset + totalRead, nextRead); + } - if (blobOptions.getUseTransactionalContentMD5()) { - final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - - try { - final MessageDigest digest = MessageDigest.getInstance("MD5"); - digest.update(buffer, bufferOffset, length); - final String calculatedMD5 = Base64.encode(digest.digest()); - if (!contentMD5.equals(calculatedMD5)) { - throw new StorageException( - StorageErrorCodeStrings.INVALID_MD5, - String.format("Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - contentMD5, - calculatedMD5), Constants.HeaderConstants.HTTP_UNUSED_306, null, - null); - } - } catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } + ExecutionEngine.getResponseCode(this.getResult(), request, opContext); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_PARTIAL) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return null; + blob.updatePropertiesFromResponse(request); + final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); + final long expectedLength = Long.parseLong(contentLength); + if (totalRead != expectedLength) { + throw new StorageException( + StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, + "An incorrect number of bytes was read from the connection. The connection may have been closed", + Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } + + if (blobOptions.getUseTransactionalContentMD5()) { + final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); + + try { + final MessageDigest digest = MessageDigest.getInstance("MD5"); + digest.update(buffer, bufferOffset, length); + final String calculatedMD5 = Base64.encode(digest.digest()); + if (!contentMD5.equals(calculatedMD5)) { + throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( + "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", + contentMD5, calculatedMD5), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); + } } - }; + catch (final NoSuchAlgorithmException e) { + // This wont happen, throw fatal. + throw Utility.generateNewUnexpectedStorageException(e); + } + } + + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -1280,9 +1206,8 @@ public final boolean exists() throws StorageException { * f a storage service error occurred. */ @DoesServiceRequest - public final boolean exists( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final boolean exists(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -1294,45 +1219,39 @@ public final boolean exists( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.getProperties(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.snapshotID, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - blob.updatePropertiesFromResponse(request); - return Boolean.valueOf(true); - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } else { - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + blob.updatePropertiesFromResponse(request); + return Boolean.valueOf(true); + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } + else { + this.setNonExceptionedRetryableFailure(true); - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1352,8 +1271,8 @@ public Boolean execute( * @throws StorageException * If a storage service error occurred. */ - public final String generateSharedAccessSignature(final SharedAccessPolicy policy) - throws InvalidKeyException, StorageException { + public final String generateSharedAccessSignature(final SharedAccessPolicy policy) throws InvalidKeyException, + StorageException { return this.generateSharedAccessSignature(policy, null); } @@ -1403,8 +1322,8 @@ public final String generateSharedAccessSignature(final SharedAccessPolicy polic * @throws StorageException * If a storage service error occurred. */ - public final String generateSharedAccessSignature(final String groupPolicyIdentifier) - throws InvalidKeyException, StorageException { + public final String generateSharedAccessSignature(final String groupPolicyIdentifier) throws InvalidKeyException, + StorageException { return this.generateSharedAccessSignature(groupPolicyIdentifier, null); } @@ -1460,9 +1379,9 @@ public final String generateSharedAccessSignature(final String groupPolicyIdenti * @throws StorageException * If a storage service error occurred. */ - private String generateSharedAccessSignatureCore( - final SharedAccessPolicy policy, final String groupPolicyIdentifier, OperationContext opContext) - throws InvalidKeyException, StorageException { + private String generateSharedAccessSignatureCore(final SharedAccessPolicy policy, + final String groupPolicyIdentifier, OperationContext opContext) throws InvalidKeyException, + StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -1479,16 +1398,11 @@ private String generateSharedAccessSignatureCore( final String resourceName = this.getCanonicalName(true); - final String signature = - SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, - groupPolicyIdentifier, - resourceName, - this.blobServiceClient, - opContext); + final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, + groupPolicyIdentifier, resourceName, this.blobServiceClient, opContext); - final UriQueryBuilder builder = - SharedAccessSignatureHelper - .generateSharedAccessSignature(policy, groupPolicyIdentifier, "b", signature); + final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignature(policy, + groupPolicyIdentifier, "b", signature); return builder.toString(); } @@ -1509,10 +1423,10 @@ String getCanonicalName(final boolean ignoreSnapshotTime) { String canonicalName; if (this.blobServiceClient.isUsePathStyleUris()) { canonicalName = this.getUri().getRawPath(); - } else { - canonicalName = - PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this.getUri() - .getRawPath()); + } + else { + canonicalName = PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this + .getUri().getRawPath()); } if (!ignoreSnapshotTime && this.snapshotID != null) { @@ -1534,8 +1448,8 @@ String getCanonicalName(final boolean ignoreSnapshotTime) { */ public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { if (this.container == null) { - final URI containerURI = - PathUtility.getContainerURI(this.getUri(), this.blobServiceClient.isUsePathStyleUris()); + final URI containerURI = PathUtility.getContainerURI(this.getUri(), + this.blobServiceClient.isUsePathStyleUris()); this.container = new CloudBlobContainer(containerURI, this.blobServiceClient); } @@ -1578,10 +1492,8 @@ public final String getName() throws URISyntaxException { */ public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { - final URI parentURI = - PathUtility.getParentAddress(this.getUri(), - this.blobServiceClient.getDirectoryDelimiter(), - this.blobServiceClient.isUsePathStyleUris()); + final URI parentURI = PathUtility.getParentAddress(this.getUri(), + this.blobServiceClient.getDirectoryDelimiter(), this.blobServiceClient.isUsePathStyleUris()); this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); } return this.parent; @@ -1609,9 +1521,11 @@ public final BlobProperties getProperties() { public final URI getQualifiedUri() throws URISyntaxException, StorageException { if (this.isSnapshot()) { return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); - } else if (this.blobServiceClient.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { + } + else if (this.blobServiceClient.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { return this.blobServiceClient.getCredentials().transformUri(this.getUri()); - } else { + } + else { return this.getUri(); } } @@ -1651,17 +1565,19 @@ public final String getSnapshotID() { * @throws URISyntaxException * If the resource URI is invalid. */ - protected final URI getTransformedAddress(final OperationContext opContext) - throws URISyntaxException, StorageException { + protected final URI getTransformedAddress(final OperationContext opContext) throws URISyntaxException, + StorageException { if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { if (this.getUri().isAbsolute()) { return this.blobServiceClient.getCredentials().transformUri(this.getUri(), opContext); - } else { + } + else { final StorageException ex = Utility.generateNewUnexpectedStorageException(null); ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); throw ex; } - } else { + } + else { return this.getUri(); } } @@ -1723,9 +1639,8 @@ public final BlobInputStream openInputStream() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final BlobInputStream openInputStream( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final BlobInputStream openInputStream(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -1755,15 +1670,14 @@ public final BlobInputStream openInputStream( * @throws StorageException * If a storage service error occurred. * */ - private void parseURIQueryStringAndVerify( - final URI completeUri, final CloudBlobClient existingClient, final boolean usePathStyleUris) - throws StorageException { + private void parseURIQueryStringAndVerify(final URI completeUri, final CloudBlobClient existingClient, + final boolean usePathStyleUris) throws StorageException { Utility.assertNotNull("resourceUri", completeUri); if (!completeUri.isAbsolute()) { - final String errorMessage = - String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", - completeUri.toString()); + final String errorMessage = String.format( + "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", + completeUri.toString()); throw new IllegalArgumentException(errorMessage); } @@ -1771,8 +1685,8 @@ private void parseURIQueryStringAndVerify( final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); - final StorageCredentialsSharedAccessSignature sasCreds = - SharedAccessSignatureHelper.parseQuery(queryParameters); + final StorageCredentialsSharedAccessSignature sasCreds = SharedAccessSignatureHelper + .parseQuery(queryParameters); final String[] snapshotIDs = queryParameters.get(BlobConstants.SNAPSHOT); if (snapshotIDs != null && snapshotIDs.length > 0) { @@ -1783,15 +1697,15 @@ private void parseURIQueryStringAndVerify( return; } - final Boolean sameCredentials = - existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, existingClient.getCredentials()); + final Boolean sameCredentials = existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, + existingClient.getCredentials()); if (existingClient == null || !sameCredentials) { try { - this.blobServiceClient = - new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress(this.getUri(), - usePathStyleUris)), sasCreds); - } catch (final URISyntaxException e) { + this.blobServiceClient = new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress( + this.getUri(), usePathStyleUris)), sasCreds); + } + catch (final URISyntaxException e) { throw Utility.generateNewUnexpectedStorageException(e); } } @@ -1813,15 +1727,17 @@ void updatePropertiesFromResponse(HttpURLConnection request) { String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); // ETag - if (Utility.isNullOrEmpty(tempStr)) { + if (!Utility.isNullOrEmpty(tempStr)) { this.getProperties().setEtag(tempStr); } // Last Modified - final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); - lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); - lastModifiedCalendar.setTime(new Date(request.getLastModified())); - this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + if (0 != request.getLastModified()) { + final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); + lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); + lastModifiedCalendar.setTime(new Date(request.getLastModified())); + this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + } // using this instead of the request property since the request // property only returns an int. @@ -1866,9 +1782,8 @@ public final void releaseLease(final AccessCondition accessCondition) throws Sto * If a storage service error occurred. */ @DoesServiceRequest - public final void releaseLease( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final void releaseLease(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { Utility.assertNotNull("accessCondition", accessCondition); Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); @@ -1883,36 +1798,31 @@ public final void releaseLease( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.lease(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - LeaseAction.RELEASE, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); - blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); - return null; - } - }; + final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RELEASE, accessCondition, + blobOptions, opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -1952,9 +1862,8 @@ public final void renewLease(final AccessCondition accessCondition) throws Stora * If a storage service error occurred. */ @DoesServiceRequest - public final void renewLease( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final void renewLease(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { Utility.assertNotNull("accessCondition", accessCondition); Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); @@ -1969,35 +1878,30 @@ public final void renewLease( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.lease(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - LeaseAction.RENEW, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); - return null; - } - }; + final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RENEW, accessCondition, blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -2078,9 +1982,8 @@ public final long tryBreakLease() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final long tryBreakLease( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final long tryBreakLease(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -2092,55 +1995,47 @@ public final long tryBreakLease( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Long execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.lease(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - LeaseAction.BREAK, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = - StorageException.translateException(request, null, opContext); - - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - } - - return -1L; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Long execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return -1L; - } + final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, accessCondition, blobOptions, + opContext); + + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); - blob.updatePropertiesFromResponse(request); - final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = StorageException.translateException(request, + null, opContext); - return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); } - }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return -1L; + } + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return -1L; + } + + blob.updatePropertiesFromResponse(request); + final String leaseTime = BlobResponse.getLeaseTime(request, opContext); + + return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -2189,9 +2084,8 @@ public Long execute( * If a storage service error occurred. */ @DoesServiceRequest - public abstract void upload( - InputStream sourceStream, long length, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException, IOException; + public abstract void upload(InputStream sourceStream, long length, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException; /** * Uploads a blob in a single operation. @@ -2217,9 +2111,9 @@ public abstract void upload( * If a storage service error occurred. */ @DoesServiceRequest - protected final void uploadFullBlob( - final InputStream sourceStream, final long length, final AccessCondition accessCondition, - final BlobRequestOptions options, final OperationContext opContext) throws StorageException, IOException { + protected final void uploadFullBlob(final InputStream sourceStream, final long length, + final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) + throws StorageException, IOException { // Mark sourceStream for current position. sourceStream.mark(Integer.MAX_VALUE); @@ -2227,56 +2121,43 @@ protected final void uploadFullBlob( throw new IllegalArgumentException("Invalid stream length, specify a positive number of bytes"); } - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.put(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.properties, - blob.properties.getBlobType(), - 0, - accessCondition, - blobOptions, - opContext); + final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, blob.properties.getBlobType(), + 0, accessCondition, blobOptions, opContext); - BlobRequest.addMetadata(request, blob.metadata, opContext); + BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, length); + client.getCredentials().signRequest(request, length); - final StreamDescriptor descriptor = - Utility.writeToOutputStream(sourceStream, - request.getOutputStream(), - length, - true, - false, - null, - opContext); + final StreamDescriptor descriptor = Utility.writeToOutputStream(sourceStream, + request.getOutputStream(), length, true, false, null, opContext); - if (length != descriptor.getLength()) { - throw new StorageException( - StorageErrorCodeStrings.INVALID_INPUT, - "An incorrect stream length was specified, resulting in an authentication failure. Please specify correct length, or -1.", - HttpURLConnection.HTTP_FORBIDDEN, null, null); - } + if (length != descriptor.getLength()) { + throw new StorageException( + StorageErrorCodeStrings.INVALID_INPUT, + "An incorrect stream length was specified, resulting in an authentication failure. Please specify correct length, or -1.", + HttpURLConnection.HTTP_FORBIDDEN, null, null); + } - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - blob.updatePropertiesFromResponse(request); - return null; - } - }; + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -2312,9 +2193,8 @@ public final void uploadMetadata() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final void uploadMetadata( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final void uploadMetadata(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -2326,32 +2206,30 @@ public final void uploadMetadata( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.setMetadata(blob.getTransformedAddress(opContext), this.getRequestOptions() - .getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); + final HttpURLConnection request = BlobRequest.setMetadata(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); - BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + BlobRequest.addMetadata(request, blob.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - blob.updatePropertiesFromResponse(request); - return null; - } - }; + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -2386,9 +2264,8 @@ public final void uploadProperties() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final void uploadProperties( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public final void uploadProperties(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -2400,37 +2277,31 @@ public final void uploadProperties( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.setProperties(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.properties, - null, - accessCondition, - blobOptions, - opContext); - - BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - blob.updatePropertiesFromResponse(request); - return null; - } - }; + final HttpURLConnection request = BlobRequest.setProperties(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, null, accessCondition, + blobOptions, opContext); + + BlobRequest.addMetadata(request, blob.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index f49ca4bcf1ed3..b3f99b5a233f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -112,8 +112,8 @@ public CloudBlobClient(final URI baseUri, StorageCredentials credentials) { * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) - throws URISyntaxException, StorageException { + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, + StorageException { return this.getBlockBlobReference(blobAddressUri, null); } @@ -164,8 +164,8 @@ public int getConcurrentRequestCount() { * @throws StorageException * If a storage service error occurred. */ - public CloudBlobContainer getContainerReference(final String containerAddress) - throws URISyntaxException, StorageException { + public CloudBlobContainer getContainerReference(final String containerAddress) throws URISyntaxException, + StorageException { Utility.assertNotNullOrEmpty("containerAddress", containerAddress); return new CloudBlobContainer(containerAddress, this); } @@ -197,8 +197,8 @@ public String getDirectoryDelimiter() { * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlobDirectory getDirectoryReference(final String relativeAddress) - throws URISyntaxException, StorageException { + public CloudBlobDirectory getDirectoryReference(final String relativeAddress) throws URISyntaxException, + StorageException { Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); return new CloudBlobDirectory(relativeAddress, this); @@ -333,8 +333,8 @@ public Iterable listContainers(final String prefix) { * client. */ @DoesServiceRequest - public Iterable listContainers( - final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, + public Iterable listContainers(final String prefix, + final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, final OperationContext opContext) { return this.listContainersWithPrefix(prefix, detailsIncluded, options, opContext); } @@ -364,24 +364,20 @@ public Iterable listContainers( * @throws StorageException */ @DoesServiceRequest - ResultSegment listContainersCore( - final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + ResultSegment listContainersCore(final String prefix, + final ContainerListingDetails detailsIncluded, final int maxResults, final ResultContinuation continuationToken, final RequestOptions options, final StorageOperation> taskReference, - final OperationContext opContext) - throws IOException, URISyntaxException, XMLStreamException, InvalidKeyException, StorageException { + final OperationContext opContext) throws IOException, URISyntaxException, XMLStreamException, + InvalidKeyException, StorageException { Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); final ListingContext listingContext = new ListingContext(prefix, maxResults); listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - final HttpURLConnection listContainerRequest = - ContainerRequest.list(this.getEndpoint(), - options.getTimeoutIntervalInMs(), - listingContext, - detailsIncluded, - opContext); + final HttpURLConnection listContainerRequest = ContainerRequest.list(this.getEndpoint(), + options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); this.getCredentials().signRequest(listContainerRequest, -1L); @@ -403,8 +399,8 @@ ResultSegment listContainersCore( newToken.setContinuationType(ResultContinuationType.CONTAINER); } - final ResultSegment resSegment = - new ResultSegment(response.getContainers(this), maxResults, newToken); + final ResultSegment resSegment = new ResultSegment( + response.getContainers(this), maxResults, newToken); return resSegment; } @@ -471,16 +467,12 @@ public ResultSegment listContainersSegmented(final String pr * If a storage service error occurred. */ @DoesServiceRequest - public ResultSegment listContainersSegmented( - final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + public ResultSegment listContainersSegmented(final String prefix, + final ContainerListingDetails detailsIncluded, final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, final OperationContext opContext) throws StorageException { - return this.listContainersWithPrefixSegmented(prefix, - detailsIncluded, - maxResults, - continuationToken, - options, + return this.listContainersWithPrefixSegmented(prefix, detailsIncluded, maxResults, continuationToken, options, opContext); } @@ -505,9 +497,8 @@ public ResultSegment listContainersSegmented( * begin with the specified prefix. */ @DoesServiceRequest - protected Iterable listContainersWithPrefix( - final String prefix, final ContainerListingDetails detailsIncluded, BlobRequestOptions options, - OperationContext opContext) { + protected Iterable listContainersWithPrefix(final String prefix, + final ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext opContext) { if (opContext == null) { opContext = new OperationContext(); } @@ -519,29 +510,22 @@ protected Iterable listContainersWithPrefix( opContext.initialize(); options.applyDefaults(this); - final SegmentedStorageOperation> impl = - new SegmentedStorageOperation>(options, null) { - @Override - public ResultSegment execute( - final CloudBlobClient client, final Void dontCare, final OperationContext opContext) - throws Exception { - - final ResultSegment result = - CloudBlobClient.this.listContainersCore(prefix, - detailsIncluded, - -1, - this.getToken(), - this.getRequestOptions(), - this, - opContext); - - // Note, setting the token on the SegmentedStorageOperation is - // key, this is how the iterator - // will share the token across executions - this.setToken(result.getContinuationToken()); - return result; - } - }; + final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( + options, null) { + @Override + public ResultSegment execute(final CloudBlobClient client, final Void dontCare, + final OperationContext opContext) throws Exception { + + final ResultSegment result = CloudBlobClient.this.listContainersCore(prefix, + detailsIncluded, -1, this.getToken(), this.getRequestOptions(), this, opContext); + + // Note, setting the token on the SegmentedStorageOperation is + // key, this is how the iterator + // will share the token across executions + this.setToken(result.getContinuationToken()); + return result; + } + }; return new LazySegmentedIterator(impl, this, null, options.getRetryPolicyFactory(), opContext); @@ -576,8 +560,8 @@ public ResultSegment execute( * If a storage service error occurred. */ @DoesServiceRequest - protected ResultSegment listContainersWithPrefixSegmented( - final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + protected ResultSegment listContainersWithPrefixSegmented(final String prefix, + final ContainerListingDetails detailsIncluded, final int maxResults, final ResultContinuation continuationToken, BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { @@ -593,21 +577,15 @@ protected ResultSegment listContainersWithPrefixSegmented( Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); - final StorageOperation> impl = - new StorageOperation>(options) { - @Override - public ResultSegment execute( - final CloudBlobClient client, final Void dontCare, final OperationContext opContext) - throws Exception { - return CloudBlobClient.this.listContainersCore(prefix, - detailsIncluded, - maxResults, - continuationToken, - this.getRequestOptions(), - this, - opContext); - } - }; + final StorageOperation> impl = new StorageOperation>( + options) { + @Override + public ResultSegment execute(final CloudBlobClient client, final Void dontCare, + final OperationContext opContext) throws Exception { + return CloudBlobClient.this.listContainersCore(prefix, detailsIncluded, maxResults, continuationToken, + this.getRequestOptions(), this, opContext); + } + }; return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 83071b7b749b8..1fe9359de2d5b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -55,12 +55,13 @@ static BlobContainerPermissions getContainerAcl(final String aclString) { final String lowerAclString = aclString.toLowerCase(); if ("container".equals(lowerAclString)) { accessType = BlobContainerPublicAccessType.CONTAINER; - } else if ("blob".equals(lowerAclString)) { + } + else if ("blob".equals(lowerAclString)) { accessType = BlobContainerPublicAccessType.BLOB; - } else { - throw new IllegalArgumentException( - String.format("Invalid acl public access type returned '%s'. Expected blob or container.", - aclString)); + } + else { + throw new IllegalArgumentException(String.format( + "Invalid acl public access type returned '%s'. Expected blob or container.", aclString)); } } @@ -195,36 +196,34 @@ public void create(BlobRequestOptions options, OperationContext opContext) throw opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.create(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - // Set attributes - final BlobContainerAttributes attributes = - ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); - container.setMetadata(attributes.getMetadata()); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return null; - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + // Set attributes + final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, + client.isUsePathStyleUris()); + container.setMetadata(attributes.getMetadata()); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -273,54 +272,51 @@ public Boolean createIfNotExist(BlobRequestOptions options, OperationContext opC opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Boolean execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.create(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - // Validate response code here - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - // Set attributes - final BlobContainerAttributes attributes = - ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); - container.metadata = attributes.getMetadata(); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = - StorageException.translateException(request, null, opContext); - - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - - return false; - } else { - throw StorageException.translateException(request, null, opContext); - } + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + // Validate response code here + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + // Set attributes + final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, + client.isUsePathStyleUris()); + container.metadata = attributes.getMetadata(); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = StorageException.translateException(request, + null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + + // return false instead of null to avoid SCA issues + return false; } - }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return false; + } + else { + throw StorageException.translateException(request, null, opContext); + } + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -363,28 +359,26 @@ public void delete(BlobRequestOptions options, OperationContext opContext) throw opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.delete(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -434,40 +428,37 @@ public Boolean deleteIfExists(BlobRequestOptions options, OperationContext opCon opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Boolean execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { + @Override + public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.delete(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { - container.updatePropertiesFromResponse(request); - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { + container.updatePropertiesFromResponse(request); + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } + else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } - } - }; + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -511,35 +502,33 @@ public void downloadAttributes(BlobRequestOptions options, OperationContext opCo opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.getProperties(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - // Set attributes - final BlobContainerAttributes attributes = - ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); - container.metadata = attributes.getMetadata(); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return null; - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this + .getRequestOptions().getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + // Set attributes + final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, + client.isUsePathStyleUris()); + container.metadata = attributes.getMetadata(); + container.properties = attributes.getProperties(); + container.name = attributes.getName(); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -589,44 +578,39 @@ public BlobContainerPermissions downloadPermissions(BlobRequestOptions options, opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public BlobContainerPermissions execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { + @Override + public BlobContainerPermissions execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.getAcl(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = ContainerRequest.getAcl(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } - container.updatePropertiesFromResponse(request); - final String aclString = ContainerResponse.getAcl(request); - final BlobContainerPermissions containerAcl = getContainerAcl(aclString); + container.updatePropertiesFromResponse(request); + final String aclString = ContainerResponse.getAcl(request); + final BlobContainerPermissions containerAcl = getContainerAcl(aclString); - final AccessPolicyResponse response = new AccessPolicyResponse(request.getInputStream()); + final AccessPolicyResponse response = new AccessPolicyResponse(request.getInputStream()); - for (final String key : response.getAccessIdentifiers().keySet()) { - containerAcl.getSharedAccessPolicies().put(key, response.getAccessIdentifiers().get(key)); - } + for (final String key : response.getAccessIdentifiers().keySet()) { + containerAcl.getSharedAccessPolicies().put(key, response.getAccessIdentifiers().get(key)); + } - return containerAcl; - } - }; + return containerAcl; + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -674,38 +658,35 @@ public boolean exists(BlobRequestOptions options, OperationContext opContext) th opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.getProperties(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - container.updatePropertiesFromResponse(request); - return Boolean.valueOf(true); - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this + .getRequestOptions().getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + container.updatePropertiesFromResponse(request); + return Boolean.valueOf(true); + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } + else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -757,8 +738,8 @@ public Boolean execute( * @throws StorageException * If a storage service error occurred. */ - public String generateSharedAccessSignature(final SharedAccessPolicy policy) - throws InvalidKeyException, StorageException { + public String generateSharedAccessSignature(final SharedAccessPolicy policy) throws InvalidKeyException, + StorageException { return this.generateSharedAccessSignature(policy, null); } @@ -870,8 +851,8 @@ public String generateSharedAccessSignature(final SharedAccessPolicy policy, Ope * @throws StorageException * If a storage service error occurred. */ - public String generateSharedAccessSignature(final String groupPolicyIdentifier) - throws InvalidKeyException, StorageException { + public String generateSharedAccessSignature(final String groupPolicyIdentifier) throws InvalidKeyException, + StorageException { return this.generateSharedAccessSignature(groupPolicyIdentifier, null); } @@ -947,31 +928,25 @@ public String generateSharedAccessSignature(final String groupPolicyIdentifier, * @throws StorageException * @throws IllegalArgumentException */ - private String generateSharedAccessSignatureCore( - final SharedAccessPolicy policy, final String groupPolicyIdentifier, OperationContext opContext) - throws InvalidKeyException, StorageException { + private String generateSharedAccessSignatureCore(final SharedAccessPolicy policy, + final String groupPolicyIdentifier, OperationContext opContext) throws InvalidKeyException, + StorageException { if (opContext == null) { opContext = new OperationContext(); } if (!this.blobServiceClient.getCredentials().canCredentialsSignRequest()) { - final String errorMessage = - "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."; + final String errorMessage = "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."; throw new IllegalArgumentException(errorMessage); } final String resourceName = this.getSharedAccessCanonicalName(); - final String signature = - SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, - groupPolicyIdentifier, - resourceName, - this.blobServiceClient, - opContext); + final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, + groupPolicyIdentifier, resourceName, this.blobServiceClient, opContext); - final UriQueryBuilder builder = - SharedAccessSignatureHelper - .generateSharedAccessSignature(policy, groupPolicyIdentifier, "c", signature); + final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignature(policy, + groupPolicyIdentifier, "c", signature); return builder.toString(); } @@ -989,8 +964,8 @@ private String generateSharedAccessSignatureCore( * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) - throws URISyntaxException, StorageException { + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, + StorageException { Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); @@ -1040,8 +1015,8 @@ public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final S * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlobDirectory getDirectoryReference(final String relativeAddress) - throws URISyntaxException, StorageException { + public CloudBlobDirectory getDirectoryReference(final String relativeAddress) throws URISyntaxException, + StorageException { Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); final URI address = PathUtility.appendPathToUri(this.uri, relativeAddress); @@ -1140,7 +1115,8 @@ public CloudBlobClient getServiceClient() { private String getSharedAccessCanonicalName() { if (this.blobServiceClient.isUsePathStyleUris()) { return this.getUri().getPath(); - } else { + } + else { return PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this.getUri() .getPath()); } @@ -1163,12 +1139,14 @@ protected URI getTransformedAddress() throws URISyntaxException, StorageExceptio if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { if (this.uri.isAbsolute()) { return this.blobServiceClient.getCredentials().transformUri(this.uri); - } else { + } + else { final StorageException ex = Utility.generateNewUnexpectedStorageException(null); ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); throw ex; } - } else { + } + else { return this.uri; } } @@ -1239,9 +1217,8 @@ public Iterable listBlobs(final String prefix) { * If the resource URI is invalid. */ @DoesServiceRequest - public Iterable listBlobs( - final String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, - BlobRequestOptions options, OperationContext opContext) { + public Iterable listBlobs(final String prefix, final boolean useFlatBlobListing, + final EnumSet listingDetails, BlobRequestOptions options, OperationContext opContext) { if (opContext == null) { opContext = new OperationContext(); } @@ -1258,34 +1235,26 @@ public Iterable listBlobs( "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); } - final SegmentedStorageOperation> impl = - new SegmentedStorageOperation>( - options, null) { - - @Override - public ResultSegment execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final ResultSegment result = - CloudBlobContainer.this.listBlobsCore(prefix, - useFlatBlobListing, - listingDetails, - -1, - this.getToken(), - (BlobRequestOptions) this.getRequestOptions(), - this, - opContext); - - // Note, setting the token on the SegmentedStorageOperation is - // key, this is how the iterator - // will share the token across executions - if (result != null) { - this.setToken(result.getContinuationToken()); - } - return result; - } - }; + final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( + options, null) { + + @Override + public ResultSegment execute(final CloudBlobClient client, + final CloudBlobContainer container, final OperationContext opContext) throws Exception { + + final ResultSegment result = CloudBlobContainer.this.listBlobsCore(prefix, + useFlatBlobListing, listingDetails, -1, this.getToken(), + (BlobRequestOptions) this.getRequestOptions(), this, opContext); + + // Note, setting the token on the SegmentedStorageOperation is + // key, this is how the iterator + // will share the token across executions + if (result != null) { + this.setToken(result.getContinuationToken()); + } + return result; + } + }; return new LazySegmentedIterator(impl, this.blobServiceClient, this, options.getRetryPolicyFactory(), opContext); @@ -1321,12 +1290,12 @@ public ResultSegment execute( * @throws XMLStreamException */ @DoesServiceRequest - ResultSegment listBlobsCore( - final String prefix, final boolean useFlatBlobListing, EnumSet listingDetails, - final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, + ResultSegment listBlobsCore(final String prefix, final boolean useFlatBlobListing, + EnumSet listingDetails, final int maxResults, + final ResultContinuation continuationToken, final BlobRequestOptions options, final StorageOperation> taskReference, - final OperationContext opContext) - throws URISyntaxException, IOException, StorageException, InvalidKeyException, XMLStreamException { + final OperationContext opContext) throws URISyntaxException, IOException, StorageException, + InvalidKeyException, XMLStreamException { Utility.assertContinuationType(continuationToken, ResultContinuationType.BLOB); Utility.assertNotNull("options", options); @@ -1344,12 +1313,8 @@ ResultSegment listBlobsCore( final BlobListingContext listingContext = new BlobListingContext(prefix, maxResults, delimiter, listingDetails); listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - final HttpURLConnection listBlobsRequest = - BlobRequest.list(this.getTransformedAddress(), - options.getTimeoutIntervalInMs(), - listingContext, - options, - opContext); + final HttpURLConnection listBlobsRequest = BlobRequest.list(this.getTransformedAddress(), + options.getTimeoutIntervalInMs(), listingContext, options, opContext); this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); @@ -1371,8 +1336,8 @@ ResultSegment listBlobsCore( newToken.setContinuationType(ResultContinuationType.BLOB); } - final ResultSegment resSegment = - new ResultSegment(response.getBlobs(this.blobServiceClient, this), maxResults, newToken); + final ResultSegment resSegment = new ResultSegment(response.getBlobs( + this.blobServiceClient, this), maxResults, newToken); return resSegment; } @@ -1444,10 +1409,10 @@ public ResultSegment listBlobsSegmented(final String prefix) throw * If a storage service error occurred. */ @DoesServiceRequest - public ResultSegment listBlobsSegmented( - final String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, - final int maxResults, final ResultContinuation continuationToken, BlobRequestOptions options, - OperationContext opContext) throws StorageException { + public ResultSegment listBlobsSegmented(final String prefix, final boolean useFlatBlobListing, + final EnumSet listingDetails, final int maxResults, + final ResultContinuation continuationToken, BlobRequestOptions options, OperationContext opContext) + throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -1466,29 +1431,19 @@ public ResultSegment listBlobsSegmented( "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); } - final StorageOperation> impl = - new StorageOperation>(options) { - - @Override - public ResultSegment execute( - final CloudBlobClient client, final CloudBlobContainer parent, - final OperationContext opContext) throws Exception { - - return CloudBlobContainer.this.listBlobsCore(prefix, - useFlatBlobListing, - listingDetails, - maxResults, - continuationToken, - (BlobRequestOptions) this.getRequestOptions(), - this, - opContext); - } - }; + final StorageOperation> impl = new StorageOperation>( + options) { + + @Override + public ResultSegment execute(final CloudBlobClient client, final CloudBlobContainer parent, + final OperationContext opContext) throws Exception { - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return CloudBlobContainer.this.listBlobsCore(prefix, useFlatBlobListing, listingDetails, maxResults, + continuationToken, (BlobRequestOptions) this.getRequestOptions(), this, opContext); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1539,8 +1494,8 @@ public Iterable listContainers(final String prefix) { * service client associated with this container. */ @DoesServiceRequest - public Iterable listContainers( - final String prefix, final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, + public Iterable listContainers(final String prefix, + final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, final OperationContext opContext) { return this.blobServiceClient.listContainers(prefix, detailsIncluded, options, opContext); } @@ -1612,16 +1567,12 @@ public ResultSegment listContainersSegmented(final String pr * */ @DoesServiceRequest - public ResultSegment listContainersSegmented( - final String prefix, final ContainerListingDetails detailsIncluded, final int maxResults, + public ResultSegment listContainersSegmented(final String prefix, + final ContainerListingDetails detailsIncluded, final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, final OperationContext opContext) throws StorageException { - return this.blobServiceClient.listContainersSegmented(prefix, - detailsIncluded, - maxResults, - continuationToken, - options, - opContext); + return this.blobServiceClient.listContainersSegmented(prefix, detailsIncluded, maxResults, continuationToken, + options, opContext); } /** @@ -1640,35 +1591,33 @@ public ResultSegment listContainersSegmented( * @throws URISyntaxException * @throws StorageException */ - private void parseQueryAndVerify( - final URI completeUri, final CloudBlobClient existingClient, final boolean usePathStyleUris) - throws URISyntaxException, StorageException { + private void parseQueryAndVerify(final URI completeUri, final CloudBlobClient existingClient, + final boolean usePathStyleUris) throws URISyntaxException, StorageException { Utility.assertNotNull("completeUri", completeUri); if (!completeUri.isAbsolute()) { - final String errorMessage = - String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", - completeUri.toString()); + final String errorMessage = String.format( + "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", + completeUri.toString()); throw new IllegalArgumentException(errorMessage); } this.uri = PathUtility.stripURIQueryAndFragment(completeUri); final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); - final StorageCredentialsSharedAccessSignature sasCreds = - SharedAccessSignatureHelper.parseQuery(queryParameters); + final StorageCredentialsSharedAccessSignature sasCreds = SharedAccessSignatureHelper + .parseQuery(queryParameters); if (sasCreds == null) { return; } - final Boolean sameCredentials = - existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, existingClient.getCredentials()); + final Boolean sameCredentials = existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, + existingClient.getCredentials()); if (existingClient == null || !sameCredentials) { - this.blobServiceClient = - new CloudBlobClient(new URI( - PathUtility.getServiceClientBaseAddress(this.getUri(), usePathStyleUris)), sasCreds); + this.blobServiceClient = new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress(this.getUri(), + usePathStyleUris)), sasCreds); } if (existingClient != null && !sameCredentials) { @@ -1688,15 +1637,17 @@ void updatePropertiesFromResponse(HttpURLConnection request) { String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); // ETag - if (Utility.isNullOrEmpty(tempStr)) { + if (!Utility.isNullOrEmpty(tempStr)) { this.getProperties().setEtag(tempStr); } // Last Modified - final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); - lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); - lastModifiedCalendar.setTime(new Date(request.getLastModified())); - this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + if (0 != request.getLastModified()) { + final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); + lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); + lastModifiedCalendar.setTime(new Date(request.getLastModified())); + this.getProperties().setLastModified(lastModifiedCalendar.getTime()); + } } /** @@ -1779,31 +1730,29 @@ public void uploadMetadata(BlobRequestOptions options, OperationContext opContex opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { + @Override + public Void execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.setMetadata(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = ContainerRequest.setMetadata(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + ContainerRequest.addMetadata(request, container.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } - container.updatePropertiesFromResponse(request); - return null; - } - }; + container.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -1842,9 +1791,8 @@ public void uploadPermissions(final BlobContainerPermissions permissions) throws * If a storage service error occurred. */ @DoesServiceRequest - public void uploadPermissions( - final BlobContainerPermissions permissions, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public void uploadPermissions(final BlobContainerPermissions permissions, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -1856,38 +1804,35 @@ public void uploadPermissions( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { + @Override + public Void execute(final CloudBlobClient client, final CloudBlobContainer container, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - ContainerRequest.setAcl(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), permissions.getPublicAccess(), opContext); + final HttpURLConnection request = ContainerRequest.setAcl(container.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), permissions.getPublicAccess(), opContext); - final StringWriter outBuffer = new StringWriter(); + final StringWriter outBuffer = new StringWriter(); - ContainerRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), - outBuffer); + ContainerRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), outBuffer); - final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); - client.getCredentials().signRequest(request, aclBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(aclBytes); + final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); + client.getCredentials().signRequest(request, aclBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(aclBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + } - container.updatePropertiesFromResponse(request); - return null; - } - }; + container.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java index 5e0ad33b8d56e..4f7e8ce3d4ca6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java @@ -109,8 +109,8 @@ protected CloudBlobDirectory(final URI uri, final CloudBlobDirectory parent, fin * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) - throws URISyntaxException, StorageException { + public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, + StorageException { return this.getBlockBlobReference(blobAddressUri, null); } @@ -134,8 +134,8 @@ public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final S throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - final URI address = - PathUtility.appendPathToUri(this.uri, blobAddressUri, this.blobServiceClient.getDirectoryDelimiter()); + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri, + this.blobServiceClient.getDirectoryDelimiter()); final CloudBlockBlob retBlob = new CloudBlockBlob(address, snapshotID, this.blobServiceClient); retBlob.setContainer(this.container); @@ -198,8 +198,8 @@ public CloudPageBlob getPageBlobReference(final String blobAddressUri, final Str throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - final URI address = - PathUtility.appendPathToUri(this.uri, blobAddressUri, this.blobServiceClient.getDirectoryDelimiter()); + final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri, + this.blobServiceClient.getDirectoryDelimiter()); final CloudPageBlob retBlob = new CloudPageBlob(address, snapshotID, this.blobServiceClient); retBlob.setContainer(this.container); @@ -219,10 +219,8 @@ public CloudPageBlob getPageBlobReference(final String blobAddressUri, final Str */ public CloudBlobDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { - final URI parentURI = - PathUtility.getParentAddress(this.uri, - this.blobServiceClient.getDirectoryDelimiter(), - this.blobServiceClient.isUsePathStyleUris()); + final URI parentURI = PathUtility.getParentAddress(this.uri, + this.blobServiceClient.getDirectoryDelimiter(), this.blobServiceClient.isUsePathStyleUris()); this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); } return this.parent; @@ -241,7 +239,8 @@ protected String getPrefix() throws StorageException { try { final String containerUri = this.getContainer().getUri().toString().concat("/"); this.prefix = Utility.safeRelativize(new URI(containerUri), this.uri); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } @@ -273,12 +272,12 @@ public CloudBlobClient getServiceClient() { * @throws URISyntaxException * If the resource URI is invalid. */ - public CloudBlobDirectory getSubDirectoryReference(final String relativeAddress) - throws StorageException, URISyntaxException { + public CloudBlobDirectory getSubDirectoryReference(final String relativeAddress) throws StorageException, + URISyntaxException { Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); - final URI address = - PathUtility.appendPathToUri(this.uri, relativeAddress, this.blobServiceClient.getDirectoryDelimiter()); + final URI address = PathUtility.appendPathToUri(this.uri, relativeAddress, + this.blobServiceClient.getDirectoryDelimiter()); return new CloudBlobDirectory(address, this, this.blobServiceClient); } @@ -359,16 +358,12 @@ public Iterable listBlobs(String prefix) throws URISyntaxException * If the resource URI is invalid. */ @DoesServiceRequest - public Iterable listBlobs( - String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, - final BlobRequestOptions options, final OperationContext opContext) - throws URISyntaxException, StorageException { + public Iterable listBlobs(String prefix, final boolean useFlatBlobListing, + final EnumSet listingDetails, final BlobRequestOptions options, + final OperationContext opContext) throws URISyntaxException, StorageException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobs(this.getPrefix().concat(prefix), - useFlatBlobListing, - listingDetails, - options, - opContext); + return this.getContainer().listBlobs(this.getPrefix().concat(prefix), useFlatBlobListing, listingDetails, + options, opContext); } /** @@ -445,17 +440,12 @@ public ResultSegment listBlobsSegmented(String prefix) throws Stor * If the resource URI is invalid. */ @DoesServiceRequest - public ResultSegment listBlobsSegmented( - String prefix, final boolean useFlatBlobListing, final EnumSet listingDetails, - final int maxResults, final ResultContinuation continuationToken, final BlobRequestOptions options, + public ResultSegment listBlobsSegmented(String prefix, final boolean useFlatBlobListing, + final EnumSet listingDetails, final int maxResults, + final ResultContinuation continuationToken, final BlobRequestOptions options, final OperationContext opContext) throws StorageException, URISyntaxException { prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix), - useFlatBlobListing, - listingDetails, - maxResults, - continuationToken, - options, - opContext); + return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix), useFlatBlobListing, + listingDetails, maxResults, continuationToken, options, opContext); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 53fecee4947b2..015f8167ff321 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -130,9 +130,8 @@ public void commitBlockList(final Iterable blockList) throws Storage * If a storage service error occurred. */ @DoesServiceRequest - public void commitBlockList( - final Iterable blockList, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { + public void commitBlockList(final Iterable blockList, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -143,58 +142,46 @@ public void commitBlockList( options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.putBlockList(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blob.properties, - accessCondition, - blobOptions, - opContext); - BlobRequest.addMetadata(request, blob.metadata, opContext); + final HttpURLConnection request = BlobRequest.putBlockList(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blob.properties, accessCondition, blobOptions, opContext); + BlobRequest.addMetadata(request, blob.metadata, opContext); - // Potential optimization, we can write this stream outside of - // the StorageOperation, so it wont need to be rewritten for each retry. Because it would - // need to be a final member this would require refactoring into an internal method which - // receives the block list bytestream as a final param. + // Potential optimization, we can write this stream outside of + // the StorageOperation, so it wont need to be rewritten for each retry. Because it would + // need to be a final member this would require refactoring into an internal method which + // receives the block list bytestream as a final param. - final byte[] blockListBytes = BlobRequest.writeBlockListToStream(blockList, opContext); + final byte[] blockListBytes = BlobRequest.writeBlockListToStream(blockList, opContext); - final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(blockListBytes); + final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(blockListBytes); - final StreamDescriptor descriptor = - Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + final StreamDescriptor descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - client.getCredentials().signRequest(request, descriptor.getLength()); - Utility.writeToOutputStream(blockListInputStream, - request.getOutputStream(), - descriptor.getLength(), - false, - false, - null, - opContext); + client.getCredentials().signRequest(request, descriptor.getLength()); + Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), + false, false, null, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - blob.updatePropertiesFromResponse(request); - return null; - } - }; + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -243,9 +230,9 @@ public ArrayList downloadBlockList() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public ArrayList downloadBlockList( - final BlockListingFilter blockListingFilter, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException { + public ArrayList downloadBlockList(final BlockListingFilter blockListingFilter, + final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) + throws StorageException { Utility.assertNotNull("blockListingFilter", blockListingFilter); if (opContext == null) { @@ -259,43 +246,34 @@ public ArrayList downloadBlockList( opContext.initialize(); options.applyDefaults(this.blobServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { - - @Override - public ArrayList execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.getBlockList(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blob.snapshotID, - blockListingFilter, - accessCondition, - blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - final GetBlockListResponse response = new GetBlockListResponse(request.getInputStream()); - return response.getBlocks(); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final StorageOperation> impl = new StorageOperation>( + options) { + + @Override + public ArrayList execute(final CloudBlobClient client, final CloudBlob blob, + final OperationContext opContext) throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = BlobRequest.getBlockList(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blockListingFilter, accessCondition, + blobOptions, opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + final GetBlockListResponse response = new GetBlockListResponse(request.getInputStream()); + return response.getBlocks(); + } + }; + + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -331,9 +309,8 @@ public BlobOutputStream openOutputStream() throws StorageException { * @throws StorageException * If a storage service error occurred. */ - public BlobOutputStream openOutputStream( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public BlobOutputStream openOutputStream(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -391,8 +368,7 @@ public void upload(final InputStream sourceStream, final long length) throws Sto */ @Override @DoesServiceRequest - public void upload( - final InputStream sourceStream, final long length, final AccessCondition accessCondition, + public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { if (length < -1) { throw new IllegalArgumentException( @@ -425,12 +401,8 @@ public void upload( // If the stream is of unknown length or we need to calculate // the MD5, then we we need to read the stream contents first - descriptor = - Utility.analyzeStream(sourceStream, - length, - this.blobServiceClient.getSingleBlobPutThresholdInBytes(), - true, - options.getStoreBlobContentMD5()); + descriptor = Utility.analyzeStream(sourceStream, length, + this.blobServiceClient.getSingleBlobPutThresholdInBytes(), true, options.getStoreBlobContentMD5()); if (descriptor.getMd5() != null && options.getStoreBlobContentMD5()) { this.properties.setContentMD5(descriptor.getMd5()); @@ -442,7 +414,8 @@ public void upload( if (sourceStream.markSupported() && descriptor.getLength() != -1 && descriptor.getLength() < this.blobServiceClient.getSingleBlobPutThresholdInBytes()) { this.uploadFullBlob(sourceStream, descriptor.getLength(), accessCondition, options, opContext); - } else { + } + else { final BlobOutputStream writeStream = this.openOutputStream(accessCondition, options, opContext); writeStream.write(sourceStream, length); writeStream.close(); @@ -499,8 +472,7 @@ public void uploadBlock(final String blockId, final InputStream sourceStream, fi * If a storage service error occurred. */ @DoesServiceRequest - public void uploadBlock( - final String blockId, final InputStream sourceStream, final long length, + public void uploadBlock(final String blockId, final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { if (length < -1) { @@ -538,23 +510,18 @@ public void uploadBlock( if (!sourceStream.markSupported()) { // needs buffering final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - descriptor = - Utility.writeToOutputStream(sourceStream, - byteStream, - length, - false, - options.getUseTransactionalContentMD5(), - null, - opContext); + descriptor = Utility.writeToOutputStream(sourceStream, byteStream, length, false, + options.getUseTransactionalContentMD5(), null, opContext); bufferedStreamReference = new ByteArrayInputStream(byteStream.toByteArray()); - } else if (length < 0 || options.getUseTransactionalContentMD5()) { + } + else if (length < 0 || options.getUseTransactionalContentMD5()) { // If the stream is of unknown length or we need to calculate the // MD5, then we we need to read // the stream contents first - descriptor = - Utility.analyzeStream(sourceStream, length, -1L, true, options.getUseTransactionalContentMD5()); + descriptor = Utility + .analyzeStream(sourceStream, length, -1L, true, options.getUseTransactionalContentMD5()); } if (descriptor.getLength() > 4 * Constants.MB) { @@ -562,13 +529,8 @@ public void uploadBlock( "Invalid stream length, length must be less than or equal to 4 MB in size."); } - this.uploadBlockInternal(blockId, - descriptor.getMd5(), - bufferedStreamReference, - descriptor.getLength(), - accessCondition, - options, - opContext); + this.uploadBlockInternal(blockId, descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), + accessCondition, options, opContext); } /** @@ -593,53 +555,41 @@ public void uploadBlock( * @throws IOException */ @DoesServiceRequest - private void uploadBlockInternal( - final String blockId, final String md5, final InputStream sourceStream, final long length, - final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) - throws StorageException, IOException { + private void uploadBlockInternal(final String blockId, final String md5, final InputStream sourceStream, + final long length, final AccessCondition accessCondition, final BlobRequestOptions options, + final OperationContext opContext) throws StorageException, IOException { + + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.putBlock(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blockId, - accessCondition, - blobOptions, - opContext); - - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); - } - - client.getCredentials().signRequest(request, length); - - Utility.writeToOutputStream(sourceStream, - request.getOutputStream(), - length, - true, - false, - null, - opContext); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; + final HttpURLConnection request = BlobRequest.putBlock(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blockId, accessCondition, blobOptions, opContext); + + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); + } + + client.getCredentials().signRequest(request, length); + + Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true, false, null, + opContext); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index ac252a5f7ce6e..1145cfa32c1a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -142,9 +142,8 @@ public void clearPages(final long offset, final long length) throws StorageExcep * If a storage service error occurred. */ @DoesServiceRequest - public void clearPages( - final long offset, final long length, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException, IOException { + public void clearPages(final long offset, final long length, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { if (offset % BlobConstants.PAGE_SIZE != 0) { throw new IllegalArgumentException("Page start offset must be multiple of 512!"); } @@ -209,8 +208,7 @@ public void create(final long length) throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public void create( - final long length, final AccessCondition accessCondition, BlobRequestOptions options, + public void create(final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException { if (length % BlobConstants.PAGE_SIZE != 0) { throw new IllegalArgumentException("Page blob length must be multiple of 512."); @@ -226,40 +224,33 @@ public void create( options.applyDefaults(this.blobServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.put(blob.getTransformedAddress(opContext), - this.getRequestOptions().getTimeoutIntervalInMs(), - blob.properties, - BlobType.PAGE_BLOB, - length, - accessCondition, - blobOptions, - opContext); + final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this + .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, BlobType.PAGE_BLOB, length, + accessCondition, blobOptions, opContext); - BlobRequest.addMetadata(request, blob.metadata, opContext); + BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - blob.updatePropertiesFromResponse(request); - return null; - } - }; + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -303,9 +294,8 @@ public ArrayList downloadPageRanges() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public ArrayList downloadPageRanges( - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { + public ArrayList downloadPageRanges(final AccessCondition accessCondition, BlobRequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); @@ -317,42 +307,33 @@ public ArrayList downloadPageRanges( options.applyDefaults(this.blobServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { + final StorageOperation> impl = new StorageOperation>( + options) { - @Override - public ArrayList execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + @Override + public ArrayList execute(final CloudBlobClient client, final CloudBlob blob, + final OperationContext opContext) throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - final HttpURLConnection request = - BlobRequest.getPageRanges(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - blob.snapshotID, - accessCondition, - blobOptions, - opContext); + final HttpURLConnection request = BlobRequest.getPageRanges(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - blob.updatePropertiesFromResponse(request); - final GetPageRangesResponse response = new GetPageRangesResponse(request.getInputStream()); - return response.getPageRanges(); - } - }; + blob.updatePropertiesFromResponse(request); + final GetPageRangesResponse response = new GetPageRangesResponse(request.getInputStream()); + return response.getPageRanges(); + } + }; - return ExecutionEngine.executeWithRetry(this.blobServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -395,9 +376,8 @@ public BlobOutputStream openOutputStream(final long length) throws StorageExcept * If a storage service error occurred. */ @DoesServiceRequest - public BlobOutputStream openOutputStream( - final long length, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { + public BlobOutputStream openOutputStream(final long length, final AccessCondition accessCondition, + BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -441,50 +421,44 @@ public BlobOutputStream openOutputStream( * If a storage service error occurred. */ @DoesServiceRequest - private void putPagesInternal( - final PageProperties pageProperties, final byte[] data, final long length, final String md5, - final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) - throws StorageException { + private void putPagesInternal(final PageProperties pageProperties, final byte[] data, final long length, + final String md5, final AccessCondition accessCondition, final BlobRequestOptions options, + final OperationContext opContext) throws StorageException { - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = - BlobRequest.putPage(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), - pageProperties, - accessCondition, - blobOptions, - opContext); - - if (pageProperties.getPageOperation() == PageOperationType.UPDATE) { - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); - } - - client.getCredentials().signRequest(request, length); - request.getOutputStream().write(data); - } else { - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) + throws Exception { + final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); + + final HttpURLConnection request = BlobRequest.putPage(blob.getTransformedAddress(opContext), + blobOptions.getTimeoutIntervalInMs(), pageProperties, accessCondition, blobOptions, opContext); + + if (pageProperties.getPageOperation() == PageOperationType.UPDATE) { + if (blobOptions.getUseTransactionalContentMD5()) { + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); } - }; + + client.getCredentials().signRequest(request, length); + request.getOutputStream().write(data); + } + else { + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + blob.updatePropertiesFromResponse(request); + return null; + } + }; ExecutionEngine .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); @@ -535,8 +509,7 @@ public void upload(final InputStream sourceStream, final long length) throws Sto */ @Override @DoesServiceRequest - public void upload( - final InputStream sourceStream, final long length, final AccessCondition accessCondition, + public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { if (opContext == null) { opContext = new OperationContext(); @@ -561,7 +534,8 @@ public void upload( if (length <= 4 * Constants.MB) { this.create(length, accessCondition, options, opContext); this.uploadPages(sourceStream, 0, length, accessCondition, options, opContext); - } else { + } + else { final OutputStream streamRef = this.openOutputStream(length, accessCondition, options, opContext); Utility.writeToOutputStream(sourceStream, streamRef, length, false, false, null, opContext); streamRef.close(); @@ -622,8 +596,7 @@ public void uploadPages(final InputStream sourceStream, final long offset, final * If a storage service error occurred. */ @DoesServiceRequest - public void uploadPages( - final InputStream sourceStream, final long offset, final long length, + public void uploadPages(final InputStream sourceStream, final long offset, final long length, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { @@ -668,7 +641,8 @@ public void uploadPages( final MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(data, 0, data.length); md5 = Base64.encode(digest.digest()); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { // This wont happen, throw fatal. throw Utility.generateNewUnexpectedStorageException(e); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java index 1fc3ade1af858..0f496dc2dce14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java @@ -36,8 +36,8 @@ final class ContainerRequest { * @param metadata * The user-defined metadata. * */ - public static void addMetadata( - final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final HashMap metadata, + final OperationContext opContext) { BaseRequest.addMetadata(request, metadata, opContext); } @@ -51,8 +51,8 @@ public static void addMetadata( * @param value * The metadata value. * */ - public static void addMetadata( - final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final String name, final String value, + final OperationContext opContext) { BaseRequest.addMetadata(request, name, value, opContext); } @@ -86,9 +86,8 @@ public static HttpURLConnection create(final URI uri, final int timeout, final O * @throws StorageException * @throws IllegalArgumentException */ - private static HttpURLConnection createURLConnection( - final URI uri, final int timeout, final UriQueryBuilder query, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + private static HttpURLConnection createURLConnection(final URI uri, final int timeout, final UriQueryBuilder query, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { return BaseRequest.createURLConnection(uri, timeout, query, opContext); } @@ -142,7 +141,8 @@ protected static UriQueryBuilder getContainerUriQueryBuilder() throws StorageExc final UriQueryBuilder uriBuilder = new UriQueryBuilder(); try { uriBuilder.add("restype", "container"); - } catch (final IllegalArgumentException e) { + } + catch (final IllegalArgumentException e) { throw Utility.generateNewUnexpectedStorageException(e); } return uriBuilder; @@ -200,10 +200,9 @@ public static HttpURLConnection getProperties(final URI uri, final int timeout, * @throws StorageException * @throws IllegalArgumentException */ - public static HttpURLConnection list( - final URI uri, final int timeout, final ListingContext listingContext, - final ContainerListingDetails detailsIncluded, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection list(final URI uri, final int timeout, final ListingContext listingContext, + final ContainerListingDetails detailsIncluded, final OperationContext opContext) throws URISyntaxException, + IOException, StorageException { final UriQueryBuilder builder = getContainerUriQueryBuilder(); builder.add("comp", "list"); @@ -245,9 +244,9 @@ public static HttpURLConnection list( * @return a HttpURLConnection configured for the operation. * @throws StorageException * */ - public static HttpURLConnection setAcl( - final URI uri, final int timeout, final BlobContainerPublicAccessType publicAccess, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection setAcl(final URI uri, final int timeout, + final BlobContainerPublicAccessType publicAccess, final OperationContext opContext) throws IOException, + URISyntaxException, StorageException { final UriQueryBuilder builder = getContainerUriQueryBuilder(); builder.add("comp", "acl"); @@ -289,9 +288,8 @@ public static HttpURLConnection setMetadata(final URI uri, final int timeout, fi * The account credentials. * @throws StorageException * */ - public static void signRequest( - final HttpURLConnection request, final Credentials credentials, final Long contentLength, - final OperationContext opContext) throws InvalidKeyException, StorageException { + public static void signRequest(final HttpURLConnection request, final Credentials credentials, + final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { BaseRequest.signRequestForBlobAndQueue(request, credentials, contentLength, opContext); } @@ -305,9 +303,8 @@ public static void signRequest( * @throws StorageException * @throws InvalidKeyException * */ - public static void signRequestForSharedKeyLite( - final HttpURLConnection request, final Credentials credentials, final Long contentLength, - final OperationContext opContext) throws InvalidKeyException, StorageException { + public static void signRequestForSharedKeyLite(final HttpURLConnection request, final Credentials credentials, + final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { BaseRequest.signRequestForBlobAndQueueSharedKeyLite(request, credentials, contentLength, opContext); } @@ -330,10 +327,9 @@ public static void writeSharedAccessIdentifiersToStream( final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); if (sharedAccessPolicies.keySet().size() > BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS) { - final String errorMessage = - String.format("Too many %d shared access policy identifiers provided. Server does not support setting more than %d on a single container.", - sharedAccessPolicies.keySet().size(), - BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS); + final String errorMessage = String + .format("Too many %d shared access policy identifiers provided. Server does not support setting more than %d on a single container.", + sharedAccessPolicies.keySet().size(), BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS); throw new IllegalArgumentException(errorMessage); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java index 4d37a999a5b89..6292055b55f1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java @@ -38,14 +38,14 @@ public static String getAcl(final HttpURLConnection request) { * @return the BlobContainerAttributes from the given request. * @throws StorageException */ - public static - BlobContainerAttributes getAttributes(final HttpURLConnection request, final boolean usePathStyleUris) - throws StorageException { + public static BlobContainerAttributes getAttributes(final HttpURLConnection request, final boolean usePathStyleUris) + throws StorageException { final BlobContainerAttributes containerAttributes = new BlobContainerAttributes(); URI tempURI; try { tempURI = PathUtility.stripURIQueryAndFragment(request.getURL().toURI()); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); throw wrappedUnexpectedException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java index 5b10f08a3b5d5..21091147b7401 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java @@ -88,7 +88,8 @@ public void parseResponse() throws XMLStreamException, StorageException { this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.COMMITTED)); xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.COMMITTED_BLOCKS_ELEMENT); } - } else if (name.equals(BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT)) { + } + else if (name.equals(BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT)) { // Move to block element eventType = xmlr.next(); if (eventType == XMLStreamConstants.START_ELEMENT @@ -96,9 +97,11 @@ public void parseResponse() throws XMLStreamException, StorageException { this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.UNCOMMITTED)); xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT); } - } else if (name.equals(BlobConstants.BLOCK_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (name.equals(BlobConstants.BLOCK_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { break; - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java index ac09e9e70561f..81f8a4c236220 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java @@ -83,9 +83,11 @@ public void parseResponse() throws XMLStreamException, StorageException { if (name.equals(BlobConstants.PAGE_RANGE_ELEMENT)) { this.pageRanges = BlobDeserializationHelper.readPageRanges(xmlr); - } else if (name.equals(BlobConstants.PAGE_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (name.equals(BlobConstants.PAGE_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { break; - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java index b8623900cc665..b5324ec8ff8db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java @@ -115,25 +115,33 @@ public void parseResponse(final CloudBlobClient serviceClient, final CloudBlobCo if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); this.maxResults = Integer.parseInt(tempParseString); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.DELIMITER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.DELIMITER_ELEMENT)) { this.delimiter = Utility.readElementFromXMLReader(xmlr, Constants.DELIMITER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.BLOBS_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.BLOBS_ELEMENT)) { try { this.blobs = BlobDeserializationHelper.readBlobItems(xmlr, serviceClient, container); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { throw new XMLStreamException(e); - } catch (final ParseException e) { + } + catch (final ParseException e) { throw new XMLStreamException(e); } xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); - } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { break; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java index 9e100b01ebe20..0dbd1fb6dcfa8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java @@ -68,8 +68,8 @@ public ListContainersResponse(final InputStream stream) { * @throws XMLStreamException * @throws StorageException */ - public ArrayList getContainers(final CloudBlobClient serviceClient) - throws XMLStreamException, StorageException { + public ArrayList getContainers(final CloudBlobClient serviceClient) throws XMLStreamException, + StorageException { if (!this.isParsed) { this.parseResponse(serviceClient); } @@ -122,25 +122,31 @@ public void parseResponse(final CloudBlobClient serviceClient) throws XMLStreamE if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); this.maxResults = Integer.parseInt(tempParseString); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT - && name.equals(BlobConstants.CONTAINERS_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.CONTAINERS_ELEMENT)) { try { this.containers = BlobDeserializationHelper.readContainers(xmlr, serviceClient); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { throw new XMLStreamException(e); - } catch (final ParseException e) { + } + catch (final ParseException e) { throw new XMLStreamException(e); } xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); // eventType = xmlr.next(); - } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { break; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java index 09df6f0020295..f43c59cfb22d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java @@ -32,9 +32,9 @@ final class SharedAccessSignatureHelper { * @throws IllegalArgumentException * @throws StorageException */ - protected static UriQueryBuilder generateSharedAccessSignature( - final SharedAccessPolicy policy, final String groupPolicyIdentifier, final String resourceType, - final String signature) throws StorageException { + protected static UriQueryBuilder generateSharedAccessSignature(final SharedAccessPolicy policy, + final String groupPolicyIdentifier, final String resourceType, final String signature) + throws StorageException { Utility.assertNotNullOrEmpty("resourceType", resourceType); Utility.assertNotNull("signature", signature); @@ -91,10 +91,9 @@ protected static UriQueryBuilder generateSharedAccessSignature( * @throws InvalidKeyException * @throws StorageException */ - protected static String generateSharedAccessSignatureHash( - final SharedAccessPolicy policy, final String groupPolicyIdentifier, final String resourceName, - final CloudBlobClient client, final OperationContext opContext) - throws InvalidKeyException, StorageException { + protected static String generateSharedAccessSignatureHash(final SharedAccessPolicy policy, + final String groupPolicyIdentifier, final String resourceName, final CloudBlobClient client, + final OperationContext opContext) throws InvalidKeyException, StorageException { Utility.assertNotNullOrEmpty("resourceName", resourceName); Utility.assertNotNull("client", client); @@ -103,14 +102,10 @@ protected static String generateSharedAccessSignatureHash( if (policy == null) { // Revokable access Utility.assertNotNullOrEmpty("groupPolicyIdentifier", groupPolicyIdentifier); - stringToSign = - String.format("%s\n%s\n%s\n%s\n%s", - Constants.EMPTY_STRING, - Constants.EMPTY_STRING, - Constants.EMPTY_STRING, - resourceName, - groupPolicyIdentifier); - } else { + stringToSign = String.format("%s\n%s\n%s\n%s\n%s", Constants.EMPTY_STRING, Constants.EMPTY_STRING, + Constants.EMPTY_STRING, resourceName, groupPolicyIdentifier); + } + else { // Non Revokable access if (policy.getSharedAccessExpiryTime() == null) { throw new IllegalArgumentException("Policy Expiry time is mandatory and cannot be null"); @@ -120,13 +115,11 @@ protected static String generateSharedAccessSignatureHash( throw new IllegalArgumentException("Policy permissions are mandatory and cannot be null"); } - stringToSign = - String.format("%s\n%s\n%s\n%s\n%s", - SharedAccessPolicy.permissionsToString(policy.getPermissions()), - Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()), - Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()), - resourceName, - groupPolicyIdentifier == null ? Constants.EMPTY_STRING : groupPolicyIdentifier); + stringToSign = String.format("%s\n%s\n%s\n%s\n%s", + SharedAccessPolicy.permissionsToString(policy.getPermissions()), + Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()), + Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()), resourceName, + groupPolicyIdentifier == null ? Constants.EMPTY_STRING : groupPolicyIdentifier); } stringToSign = Utility.safeDecode(stringToSign); @@ -166,22 +159,28 @@ protected static StorageCredentialsSharedAccessSignature parseQuery(final HashMa if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_START)) { signedStart = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_EXPIRY)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_EXPIRY)) { signedExpiry = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_PERMISSIONS)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_PERMISSIONS)) { sigendPermissions = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_RESOURCE)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_RESOURCE)) { signedResource = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_IDENTIFIER)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_IDENTIFIER)) { signedIdentifier = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNATURE)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNATURE)) { signature = entry.getValue()[0]; sasParameterFound = true; - } else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_VERSION)) { + } + else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_VERSION)) { signedVersion = entry.getValue()[0]; sasParameterFound = true; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java index 1bbc17d3394e2..3ab39f3675c0a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -207,11 +207,13 @@ public void applyConditionToRequest(final HttpURLConnection request, boolean use if (!Utility.isNullOrEmpty(this.etag)) { if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH)) { request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_MATCH_HEADER, this.etag); - } else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { + } + else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, this.etag); } } - } else { + } + else { if (!Utility.isNullOrEmpty(this.leaseID)) { BaseRequest.addLeaseId(request, this.leaseID); } @@ -341,7 +343,8 @@ public boolean verifyConditional(final String etag, final Date lastModified) { if (!this.etag.equals(etag) && !this.etag.equals("*")) { return false; } - } else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { + } + else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { if (this.etag.equals(etag)) { return false; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java index 12aff46bea89d..6fbc8769c19e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -49,8 +49,7 @@ public final class CloudStorageAccount { /** * The default account key for the development storage. */ - private static final String DEVSTORE_ACCOUNT_KEY = - "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; + private static final String DEVSTORE_ACCOUNT_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; /** * The default account name for the development storage. @@ -107,12 +106,10 @@ public final class CloudStorageAccount { * @return The default blob endpoint. */ private static String getDefaultBlobEndpoint(final HashMap settings) { - final String scheme = - settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - final String accountName = - settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; return getDefaultBlobEndpoint(scheme, accountName); } @@ -138,13 +135,11 @@ private static String getDefaultBlobEndpoint(final String scheme, final String a * @return The default queue endpoint. */ private static String getDefaultQueueEndpoint(final HashMap settings) { - final String scheme = - settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - final String accountName = - settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; return getDefaultQueueEndpoint(scheme, accountName); } @@ -170,12 +165,10 @@ private static String getDefaultQueueEndpoint(final String scheme, final String * @return The default table endpoint. */ private static String getDefaultTableEndpoint(final HashMap settings) { - final String scheme = - settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - final String accountName = - settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; + final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; return getDefaultTableEndpoint(scheme, accountName); } @@ -202,7 +195,8 @@ public static CloudStorageAccount getDevelopmentStorageAccount() { if (devStoreAccount == null) { try { devStoreAccount = getDevelopmentStorageAccount(new URI("http://127.0.0.1")); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { // this wont happen since we know the uri above. } } @@ -253,8 +247,8 @@ public static CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUr * @throws URISyntaxException * If the connection string specifies an invalid URI. */ - public static CloudStorageAccount parse(final String connectionString) - throws URISyntaxException, InvalidKeyException { + public static CloudStorageAccount parse(final String connectionString) throws URISyntaxException, + InvalidKeyException { if (connectionString == null || connectionString.length() == 0) { throw new IllegalArgumentException("Invalid Connection String"); } @@ -311,7 +305,8 @@ private static CloudStorageAccount tryConfigureDevStore(final HashMap settings) throws URISyntaxException, InvalidKeyException { - final String defaultEndpointSetting = - settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME).toLowerCase() : null; + final String defaultEndpointSetting = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings + .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME).toLowerCase() : null; if (defaultEndpointSetting != null && !defaultEndpointSetting.equals(Constants.HTTP) && !defaultEndpointSetting.equals(Constants.HTTPS)) { @@ -340,15 +334,12 @@ private static CloudStorageAccount tryConfigureServiceAccount(final HashMap retVals = new ArrayList(); if (this == devStoreAccount) { retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); - } else if (this.credentials != null && DEVSTORE_ACCOUNT_NAME.equals(this.credentials.getAccountName()) + } + else if (this.credentials != null && DEVSTORE_ACCOUNT_NAME.equals(this.credentials.getAccountName()) && this.credentials.toString(true).equals(CloudStorageAccount.DEVSTORE_CREDENTIALS_IN_STRING) && this.blobEndpoint != null && this.getBlobEndpoint().getHost().equals(this.getQueueEndpoint().getHost()) @@ -643,7 +634,8 @@ public String toString(final Boolean exportSecrets) { retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); retVals.add(String.format("%s=%s://%s", DEVELOPMENT_STORAGE_PROXY_URI_NAME, this.getBlobEndpoint() .getScheme(), this.getBlobEndpoint().getHost())); - } else if (this.getBlobEndpoint().getHost().endsWith(BLOB_BASE_DNS_NAME) + } + else if (this.getBlobEndpoint().getHost().endsWith(BLOB_BASE_DNS_NAME) && this.getQueueEndpoint().getHost().endsWith(QUEUE_BASE_DNS_NAME) && this.getTableEndpoint().getHost().endsWith(TABLE_BASE_DNS_NAME) && this.getBlobEndpoint().getScheme().equals(this.getQueueEndpoint().getScheme()) @@ -652,7 +644,8 @@ public String toString(final Boolean exportSecrets) { if (this.getCredentials() != null) { retVals.add(this.getCredentials().toString(exportSecrets)); } - } else { + } + else { if (this.getBlobEndpoint() != null) { retVals.add(String.format("%s=%s", BLOB_ENDPOINT_NAME, this.getBlobEndpoint())); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java index 9ed740ee765de..df31917581a95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java @@ -42,11 +42,14 @@ public enum LeaseStatus { public static LeaseStatus parse(final String typeString) { if (Utility.isNullOrEmpty(typeString)) { return UNSPECIFIED; - } else if ("unlocked".equals(typeString.toLowerCase(Locale.US))) { + } + else if ("unlocked".equals(typeString.toLowerCase(Locale.US))) { return UNLOCKED; - } else if ("locked".equals(typeString.toLowerCase(Locale.US))) { + } + else if ("locked".equals(typeString.toLowerCase(Locale.US))) { return LOCKED; - } else { + } + else { return UNSPECIFIED; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 0627a2c847ced..8e6e675af02fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -49,8 +49,7 @@ public final class OperationContext { * @see EventListenerMultiCaster * @see ResponseReceivedEvent */ - private EventListenerMultiCaster> responseReceivedEventHandler = - new EventListenerMultiCaster>(); + private EventListenerMultiCaster> responseReceivedEventHandler = new EventListenerMultiCaster>(); /** * Reserved for internal use. @@ -118,7 +117,8 @@ public MessageDigest getIntermediateMD5() { public RequestResult getLastResult() { if (this.requestResults == null || this.requestResults.size() == 0) { return null; - } else { + } + else { return this.requestResults.get(this.requestResults.size() - 1); } } @@ -147,9 +147,7 @@ public ArrayList getRequestResults() { /** * @return the responseReceivedEventHandler */ - public - EventListenerMultiCaster> - getResponseReceivedEventHandler() { + public EventListenerMultiCaster> getResponseReceivedEventHandler() { return this.responseReceivedEventHandler; } @@ -212,10 +210,8 @@ private void setLogger(final Logger logger) { * @param responseReceivedEventHandler * the responseReceivedEventHandler to set */ - public - void - setResponseReceivedEventHandler( - final EventListenerMultiCaster> responseReceivedEventHandler) { + public void setResponseReceivedEventHandler( + final EventListenerMultiCaster> responseReceivedEventHandler) { this.responseReceivedEventHandler = responseReceivedEventHandler; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java index 542bec26aea72..63f1263e29f4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java @@ -102,8 +102,7 @@ public RetryPolicy createInstance(final OperationContext opContext) { * retried and how long to backoff. */ @Override - public RetryResult shouldRetry( - final int currentRetryCount, final int statusCode, final Exception lastException, + public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, final OperationContext opContext) { if (statusCode >= 400 && statusCode < 500) { @@ -116,15 +115,15 @@ public RetryResult shouldRetry( // backoff, multiply by 2^n -1 for // exponential int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); - final int boundedRandDelta = - (int) (this.deltaBackoffIntervalInMs * 0.8) - + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - - (int) (this.deltaBackoffIntervalInMs * 0.8)); + final int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) + + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) + - (int) (this.deltaBackoffIntervalInMs * 0.8)); incrementDelta *= boundedRandDelta; // Enforce max / min backoffs return new RetryResult(Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff), true); - } else { + } + else { return new RetryResult(-1, false); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java index f93159d9efbb4..a31e2dd437f8a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java @@ -63,16 +63,14 @@ public RetryPolicy createInstance(final OperationContext opContext) { * retried and how long to backoff. */ @Override - public RetryResult shouldRetry( - final int currentRetryCount, final int statusCode, final Exception lastException, + public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, final OperationContext opContext) { if (statusCode >= 400 && statusCode < 500) { return new RetryResult(0, false); } - final int backoff = - Math.max(Math.min(this.deltaBackoffIntervalInMs, RetryPolicy.DEFAULT_MAX_BACKOFF), - RetryPolicy.DEFAULT_MIN_BACKOFF); + final int backoff = Math.max(Math.min(this.deltaBackoffIntervalInMs, RetryPolicy.DEFAULT_MAX_BACKOFF), + RetryPolicy.DEFAULT_MIN_BACKOFF); return new RetryResult(backoff, currentRetryCount < this.maximumAttempts); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java index db54ea1cda4e4..cf78fc40bd19e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java @@ -58,8 +58,7 @@ public RetryPolicy createInstance(final OperationContext opContext) { * */ @Override - public RetryResult shouldRetry( - final int currentRetryCount, final int statusCode, final Exception lastException, + public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, final OperationContext opContext) { return new RetryResult(0, false); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java index 26da7d9047b57..210989e314997 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java @@ -79,6 +79,6 @@ public RetryPolicy(final int deltaBackoff, final int maxAttempts) { * @return A {@link RetryResult} object that indicates whether the operation should be retried and how long to * backoff. */ - public abstract RetryResult shouldRetry( - int currentRetryCount, int statusCode, Exception lastException, OperationContext opContext); + public abstract RetryResult shouldRetry(int currentRetryCount, int statusCode, Exception lastException, + OperationContext opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java index dfd4c1c709b3c..1cce16a49fb76 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java @@ -41,7 +41,8 @@ public void doSleep() { if (this.isShouldRetry()) { try { Thread.sleep(this.backOffIntervalInMs); - } catch (final InterruptedException e) { + } + catch (final InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index 15c8535879de1..e9ead21962585 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -69,9 +69,8 @@ public ServiceClient(final URI baseUri, final StorageCredentials credentials) { Utility.assertNotNull("baseUri", baseUri); if (!baseUri.isAbsolute()) { - throw new IllegalArgumentException( - String.format("Address '%s' is not an absolute address. Relative addresses are not permitted in here.", - baseUri)); + throw new IllegalArgumentException(String.format( + "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", baseUri)); } this.retryPolicyFactory = new RetryExponentialRetry(); @@ -124,28 +123,26 @@ public final ServiceProperties downloadServiceProperties(RequestOptions options, opContext.initialize(); options.applyBaseDefaults(this); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public ServiceProperties execute( - final ServiceClient client, final Void v, final OperationContext opContext) - throws Exception { + final StorageOperation impl = new StorageOperation( + options) { + @Override + public ServiceProperties execute(final ServiceClient client, final Void v, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - BaseRequest.getServiceProperties(client.getEndpoint(), this.getRequestOptions() - .getTimeoutIntervalInMs(), null, opContext); + final HttpURLConnection request = BaseRequest.getServiceProperties(client.getEndpoint(), this + .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); - client.getCredentials().signRequest(request, -1); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + client.getCredentials().signRequest(request, -1); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return BaseResponse.readServicePropertiesFromStream(request.getInputStream(), opContext); - } - }; + return BaseResponse.readServicePropertiesFromStream(request.getInputStream(), opContext); + } + }; return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); } @@ -282,9 +279,8 @@ public void uploadServiceProperties(final ServiceProperties properties) throws S * If a storage service error occurred. */ @DoesServiceRequest - public void uploadServiceProperties( - final ServiceProperties properties, RequestOptions options, OperationContext opContext) - throws StorageException { + public void uploadServiceProperties(final ServiceProperties properties, RequestOptions options, + OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -302,44 +298,36 @@ public void uploadServiceProperties( Utility.assertNotNull("properties.Merics", properties.getMetrics()); Utility.assertNotNull("properties.Merics.Configuration", properties.getMetrics().getMetricsLevel()); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute(final ServiceClient client, final Void v, final OperationContext opContext) - throws Exception { + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final ServiceClient client, final Void v, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - BaseRequest.setServiceProperties(client.getEndpoint(), this.getRequestOptions() - .getTimeoutIntervalInMs(), null, opContext); + final HttpURLConnection request = BaseRequest.setServiceProperties(client.getEndpoint(), this + .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); - final byte[] propertiesBytes = - BaseRequest.serializeServicePropertiesToByteArray(properties, opContext); + final byte[] propertiesBytes = BaseRequest.serializeServicePropertiesToByteArray(properties, opContext); - final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(propertiesBytes); + final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(propertiesBytes); - final StreamDescriptor descriptor = - Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); + final StreamDescriptor descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - client.getCredentials().signRequest(request, descriptor.getLength()); - Utility.writeToOutputStream(blockListInputStream, - request.getOutputStream(), - descriptor.getLength(), - false, - false, - null, - opContext); + client.getCredentials().signRequest(request, descriptor.getLength()); + Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), + false, false, null, opContext); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return null; - } - }; + return null; + } + }; ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java index 9b1f18397b28f..ecba39f2067f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java @@ -43,33 +43,39 @@ private static void readLoggingProperties(final ServiceProperties retProps, fina if (eventType == XMLStreamConstants.START_ELEMENT) { final String name = xmlr.getName().toString(); if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { - retProps.getLogging().setVersion(Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.VERSION_ELEMENT)); - } else if (name.equals(Constants.AnalyticsConstants.DELETE_ELEMENT)) { - tempParseString = - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.DELETE_ELEMENT); + retProps.getLogging().setVersion( + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.VERSION_ELEMENT)); + } + else if (name.equals(Constants.AnalyticsConstants.DELETE_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.DELETE_ELEMENT); if (Boolean.parseBoolean(tempParseString)) { retProps.getLogging().getLogOperationTypes().add(LoggingOperations.DELETE); } - } else if (name.equals(Constants.AnalyticsConstants.READ_ELEMENT)) { + } + else if (name.equals(Constants.AnalyticsConstants.READ_ELEMENT)) { tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.READ_ELEMENT); if (Boolean.parseBoolean(tempParseString)) { retProps.getLogging().getLogOperationTypes().add(LoggingOperations.READ); } - } else if (name.equals(Constants.AnalyticsConstants.WRITE_ELEMENT)) { - tempParseString = - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.WRITE_ELEMENT); + } + else if (name.equals(Constants.AnalyticsConstants.WRITE_ELEMENT)) { + tempParseString = Utility + .readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.WRITE_ELEMENT); if (Boolean.parseBoolean(tempParseString)) { retProps.getLogging().getLogOperationTypes().add(LoggingOperations.WRITE); } - } else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { + } + else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { retProps.getLogging().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else { + } + else { xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); break; } @@ -102,34 +108,41 @@ private static void readMetricsProperties(final ServiceProperties retProps, fina if (eventType == XMLStreamConstants.START_ELEMENT) { final String name = xmlr.getName().toString(); if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { - retProps.getMetrics().setVersion(Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.VERSION_ELEMENT)); - } else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { - tempParseString = - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.ENABLED_ELEMENT); + retProps.getMetrics().setVersion( + Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.VERSION_ELEMENT)); + } + else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.ENABLED_ELEMENT); if (Boolean.parseBoolean(tempParseString)) { retProps.getMetrics() - .setMetricsLevel(retProps.getMetrics().getMetricsLevel() != MetricsLevel.SERVICE_AND_API ? MetricsLevel.SERVICE - : MetricsLevel.SERVICE_AND_API); - } else { + .setMetricsLevel( + retProps.getMetrics().getMetricsLevel() != MetricsLevel.SERVICE_AND_API ? MetricsLevel.SERVICE + : MetricsLevel.SERVICE_AND_API); + } + else { retProps.getMetrics().setMetricsLevel(MetricsLevel.DISABLED); } - } else if (name.equals(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT)) { - tempParseString = - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); + } + else if (name.equals(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); if (Boolean.parseBoolean(tempParseString) && retProps.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED) { retProps.getMetrics().setMetricsLevel(MetricsLevel.SERVICE_AND_API); } - } else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { + } + else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { retProps.getMetrics().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else { + } + else { xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); break; } @@ -167,21 +180,23 @@ private static Integer readRetentionPolicy(final XMLStreamReader xmlr) throws XM if (retVal != null) { retVal = Integer.parseInt(tempParseString); } - } else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { - tempParseString = - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.ENABLED_ELEMENT); + } + else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { + tempParseString = Utility.readElementFromXMLReader(xmlr, + Constants.AnalyticsConstants.ENABLED_ELEMENT); if (!Boolean.parseBoolean(tempParseString)) { retVal = null; } - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else { - xmlr.require(XMLStreamConstants.END_ELEMENT, - null, + } + else { + xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); break; } @@ -203,8 +218,8 @@ private static Integer readRetentionPolicy(final XMLStreamReader xmlr) throws XM * @throws StorageException * if unexpected xml is found. */ - public static ServiceProperties readServicePropertiesFromStream( - final InputStream inStream, final OperationContext opContext) throws XMLStreamException, StorageException { + public static ServiceProperties readServicePropertiesFromStream(final InputStream inStream, + final OperationContext opContext) throws XMLStreamException, StorageException { final ServiceProperties retProps = new ServiceProperties(); final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); @@ -215,8 +230,7 @@ public static ServiceProperties readServicePropertiesFromStream( // 1. get StorageServiceProperties Header eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, - null, + xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT); // check if there are more events in the input stream @@ -227,18 +241,22 @@ public static ServiceProperties readServicePropertiesFromStream( if (name.equals(Constants.AnalyticsConstants.LOGGING_ELEMENT)) { readLoggingProperties(retProps, xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); - } else if (name.equals(Constants.AnalyticsConstants.METRICS_ELEMENT)) { + } + else if (name.equals(Constants.AnalyticsConstants.METRICS_ELEMENT)) { readMetricsProperties(retProps, xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); - } else if (name.equals(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)) { + } + else if (name.equals(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)) { retProps.setDefaultServiceVersion(Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)); - } else { + } + else { throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, "The response recieved is invalid or improperly formatted.", Constants.HeaderConstants.HTTP_UNUSED_306, null, null); } - } else if (eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT) { if (xmlr.getName().toString().equals(Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT)) { break; } @@ -417,7 +435,8 @@ public byte[] serializeToByteArray(final OperationContext opContext) throws XMLS try { return outWriter.toString().getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index e58c646b271e5..6f648bb7f70e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -42,22 +42,20 @@ public abstract class StorageCredentials { */ protected static StorageCredentials tryParseCredentials(final HashMap settings) throws InvalidKeyException { - final String accountName = - settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; + final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; - final String accountKey = - settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null; + final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ? settings + .get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null; - final String sasSignature = - settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ? settings - .get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null; + final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ? settings + .get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null; if (accountName != null && accountKey != null && sasSignature == null) { if (Base64.validateIsBase64String(accountKey)) { return new StorageCredentialsAccountAndKey(accountName, accountKey); - } else { + } + else { throw new InvalidKeyException("Storage Key is not a valid base64 encoded string."); } } @@ -85,8 +83,8 @@ protected static StorageCredentials tryParseCredentials(final HashMapStorageException object that represents translated exception. */ - public static StorageException translateException( - final HttpURLConnection request, final Exception cause, final OperationContext opContext) { + public static StorageException translateException(final HttpURLConnection request, final Exception cause, + final OperationContext opContext) { if (request == null) { return new StorageException("Client error", "A Client side exception occurred, please check the inner exception for details", @@ -77,7 +78,8 @@ public static StorageException translateException( try { responseCode = request.getResponseCode(); responseMessage = request.getResponseMessage(); - } catch (final IOException e) { + } + catch (final IOException e) { // ignore errors } @@ -87,9 +89,8 @@ public static StorageException translateException( // 1. If extended information is available use it if (extendedError != null) { - translatedException = - new StorageException(extendedError.getErrorCode(), responseMessage, responseCode, extendedError, - cause); + translatedException = new StorageException(extendedError.getErrorCode(), responseMessage, responseCode, + extendedError, cause); if (translatedException != null) { return translatedException; @@ -124,9 +125,8 @@ public static StorageException translateException( * * @return A StorageException object that represents translated exception. **/ - protected static StorageException translateFromHttpStatus( - final int statusCode, final String statusDescription, final StorageExtendedErrorInformation details, - final Exception inner) { + protected static StorageException translateFromHttpStatus(final int statusCode, final String statusDescription, + final StorageExtendedErrorInformation details, final Exception inner) { switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: return new StorageException(StorageErrorCode.ACCESS_DENIED.toString(), statusDescription, statusCode, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java index d768cfbb74601..d9107d897ba5b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java @@ -53,7 +53,7 @@ public String getErrorCode() { /** * @return the errorMessage */ - protected String getErrorMessage() { + public String getErrorMessage() { return this.errorMessage; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java index 17ca96d3941dd..0f5d888f92a6c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java @@ -44,7 +44,8 @@ public static synchronized String computeMacSha256(final StorageKey storageKey, byte[] utf8Bytes = null; try { utf8Bytes = stringToSign.getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } @@ -75,7 +76,8 @@ public static synchronized String computeMacSha512(final StorageKey storageKey, byte[] utf8Bytes = null; try { utf8Bytes = stringToSign.getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } @@ -146,7 +148,8 @@ private void initHmacSha256() throws InvalidKeyException { this.key256 = new SecretKeySpec(this.key, "HmacSHA256"); try { this.hmacSha256 = Mac.getInstance("HmacSHA256"); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException(); } this.hmacSha256.init(this.key256); @@ -162,7 +165,8 @@ private void initHmacSha512() throws InvalidKeyException { this.key512 = new SecretKeySpec(this.key, "HmacSHA512"); try { this.hmacSha512 = Mac.getInstance("HmacSHA512"); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { throw new IllegalArgumentException(); } this.hmacSha512.init(this.key512); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java index 86bed726877ed..d1d57f6fefc5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -51,7 +51,8 @@ public static byte[] decode(final String data) { if (data.endsWith("==")) { byteArrayLength -= 2; - } else if (data.endsWith("=")) { + } + else if (data.endsWith("=")) { byteArrayLength -= 1; } @@ -80,13 +81,15 @@ public static byte[] decode(final String data) { // two "==" pad chars, check bits 12-24 tVal &= 0x00FFF000; retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - } else if (char4 == -2) { + } + else if (char4 == -2) { // one pad char "=" , check bits 6-24. tVal &= 0x00FFFFC0; retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - } else { + } + else { // No pads take all 3 bytes, bits 0-24 retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); @@ -111,7 +114,8 @@ public static Byte[] decodeAsByteObjectArray(final String data) { if (data.endsWith("==")) { byteArrayLength -= 2; - } else if (data.endsWith("=")) { + } + else if (data.endsWith("=")) { byteArrayLength -= 1; } @@ -140,13 +144,15 @@ public static Byte[] decodeAsByteObjectArray(final String data) { // two "==" pad chars, check bits 12-24 tVal &= 0x00FFF000; retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - } else if (char4 == -2) { + } + else if (char4 == -2) { // one pad char "=" , check bits 6-24. tVal &= 0x00FFFFC0; retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - } else { + } + else { // No pads take all 3 bytes, bits 0-24 retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); @@ -173,10 +179,12 @@ public static String encode(final byte[] data) { if (j < data.length - dataRemainder) { n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); - } else { + } + else { if (dataRemainder == 1) { n = (data[j] & 0xFF) << 16; - } else if (dataRemainder == 2) { + } + else if (dataRemainder == 2) { n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); } } @@ -197,7 +205,8 @@ public static String encode(final byte[] data) { // append '=' to pad if (data.length % 3 == 1) { builder.replace(bLength - 2, bLength, "=="); - } else if (data.length % 3 == 2) { + } + else if (data.length % 3 == 2) { builder.replace(bLength - 1, bLength, "="); } @@ -221,10 +230,12 @@ public static String encode(final Byte[] data) { if (j < data.length - dataRemainder) { n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); - } else { + } + else { if (dataRemainder == 1) { n = (data[j] & 0xFF) << 16; - } else if (dataRemainder == 2) { + } + else if (dataRemainder == 2) { n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); } } @@ -245,7 +256,8 @@ public static String encode(final Byte[] data) { // append '=' to pad if (data.length % 3 == 1) { builder.replace(bLength - 2, bLength, "=="); - } else if (data.length % 3 == 2) { + } + else if (data.length % 3 == 2) { builder.replace(bLength - 1, bLength, "="); } @@ -272,7 +284,8 @@ public static Boolean validateIsBase64String(final String data) { if (DECODE_64[charByte] == -2) { if (m < data.length() - 2) { return false; - } else if (m == data.length() - 2 && DECODE_64[(byte) data.charAt(m + 1)] != -2) { + } + else if (m == data.length() - 2 && DECODE_64[(byte) data.charAt(m + 1)] != -2) { return false; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java index 508b8c2f5efbe..d3e5b329b2297 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -53,8 +53,8 @@ public static URI addToQuery(final URI resourceURI, final HashMap 0) { final int authorityLength = relativeOrAbsoluteUri.substring(hostNameBeginIndex).indexOf(separator); - final String authorityName = - relativeOrAbsoluteUri.substring(hostNameBeginIndex, hostNameBeginIndex + authorityLength); + final String authorityName = relativeOrAbsoluteUri.substring(hostNameBeginIndex, hostNameBeginIndex + + authorityLength); final URI absoluteUri = new URI(relativeOrAbsoluteUri); if (uri.getAuthority().equals(authorityName)) { return absoluteUri; - } else { + } + else { // Happens when using fiddler, DNS aliases, or potentially NATs return new URI(uri.getScheme(), uri.getAuthority(), absoluteUri.getPath(), absoluteUri.getRawQuery(), absoluteUri.getRawFragment()); } - } else { + } + else { // relative URI // used by directory if (uri.getPath().length() == 0 && relativeOrAbsoluteUri.startsWith(separator)) { @@ -123,7 +126,8 @@ public static URI appendPathToUri(final URI uri, final String relativeOrAbsolute if (uri.getPath().endsWith(separator)) { pathString.append(relativeOrAbsoluteUri); - } else { + } + else { pathString.append(separator); pathString.append(relativeOrAbsoluteUri); } @@ -156,13 +160,11 @@ public static String getBlobNameFromURI(final URI inURI, final boolean usePathSt * the Absolute path of the object. * @return the canonical path for an object from the credentials */ - public static - String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath) { + public static String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath) { final String account = credentials.getAccountName(); if (account == null) { - final String errorMessage = - "Cannot create Shared Access Signature as the credentials does not have account name information. Please check that the credentials used support creating Shared Access Signature."; + final String errorMessage = "Cannot create Shared Access Signature as the credentials does not have account name information. Please check that the credentials used support creating Shared Access Signature."; throw new IllegalArgumentException(errorMessage); } final StringBuilder builder = new StringBuilder("/"); @@ -182,8 +184,7 @@ String getCanonicalPathFromCredentials(final StorageCredentials credentials, fin * @throws IllegalArgumentException */ public static String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { - return getContainerOrQueueNameFromUri(resourceAddress, - usePathStyleUris, + return getContainerOrQueueNameFromUri(resourceAddress, usePathStyleUris, String.format("Invalid blob address '%s', missing container information", resourceAddress)); } @@ -197,8 +198,8 @@ public static String getContainerNameFromUri(final URI resourceAddress, final bo * @return container name from address from the URI. * @throws IllegalArgumentException */ - private static String getContainerOrQueueNameFromUri( - final URI resourceAddress, final boolean usePathStyleUris, final String error) { + private static String getContainerOrQueueNameFromUri(final URI resourceAddress, final boolean usePathStyleUris, + final String error) { Utility.assertNotNull("resourceAddress", resourceAddress); final String[] pathSegments = resourceAddress.getRawPath().split("/"); @@ -227,8 +228,8 @@ private static String getContainerOrQueueNameFromUri( public static URI getContainerURI(final URI blobAddress, final boolean usePathStyleUris) throws URISyntaxException { final String containerName = getContainerNameFromUri(blobAddress, usePathStyleUris); - final URI containerUri = - appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), containerName); + final URI containerUri = appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), + containerName); return containerUri; } @@ -249,8 +250,8 @@ public static URI getParentAddress(final URI blobAddress, final String delimiter throws URISyntaxException, StorageException { final String parentName = getParentNameFromURI(blobAddress, delimiter, usePathStyleUris); - final URI parentUri = - appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), parentName); + final URI parentUri = appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), + parentName); return parentUri; } @@ -267,9 +268,8 @@ public static URI getParentAddress(final URI blobAddress, final String delimiter * @throws URISyntaxException * @throws StorageException */ - public static String getParentNameFromURI( - final URI resourceAddress, final String delimiter, final boolean usePathStyleUris) - throws URISyntaxException, StorageException { + public static String getParentNameFromURI(final URI resourceAddress, final String delimiter, + final boolean usePathStyleUris) throws URISyntaxException, StorageException { Utility.assertNotNull("resourceAddress", resourceAddress); Utility.assertNotNullOrEmpty("delimiter", delimiter); @@ -281,9 +281,8 @@ public static String getParentNameFromURI( */ URI baseURI = new URI(getServiceClientBaseAddress(resourceAddress, usePathStyleUris)); if (usePathStyleUris && !baseURI.getRawPath().endsWith("/")) { - baseURI = - new URI(baseURI.getScheme(), baseURI.getRawAuthority(), baseURI.getRawPath().concat("/"), null, - null); + baseURI = new URI(baseURI.getScheme(), baseURI.getRawAuthority(), baseURI.getRawPath().concat("/"), null, + null); } final URI relativeURI = new URI(Utility.safeRelativize(baseURI, resourceAddress)); @@ -300,14 +299,16 @@ public static String getParentNameFromURI( // Case 1 /[Delimiter]*? => / // Parent of container is container itself parentName = containerName.concat(delimiter); - } else { + } + else { final int lastDelimiterDex = relativeURIString.lastIndexOf(delimiter); if (lastDelimiterDex <= 0) { // Case 2 // // Parent of a folder is container parentName = containerName.concat(delimiter); - } else { + } + else { // Case 3 ///[/]* // Parent of blob is folder parentName = relativeURIString.substring(0, lastDelimiterDex + delimiter.length()); @@ -328,8 +329,7 @@ public static String getParentNameFromURI( * @throws IllegalArgumentException */ public static String getQueueNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { - return getContainerOrQueueNameFromUri(resourceAddress, - usePathStyleUris, + return getContainerOrQueueNameFromUri(resourceAddress, usePathStyleUris, String.format("Invalid queue URI '%s'.", resourceAddress)); } @@ -349,18 +349,19 @@ public static String getServiceClientBaseAddress(final URI address, final boolea final String[] pathSegments = address.getRawPath().split("/"); if (pathSegments.length < 2) { - final String error = - String.format("Missing account name information inside path style uri. Path style uris should be of the form http:///"); + final String error = String + .format("Missing account name information inside path style uri. Path style uris should be of the form http:///"); throw new IllegalArgumentException(error); } - final StringBuilder completeAddress = - new StringBuilder(new URI(address.getScheme(), address.getAuthority(), null, null, null).toString()); + final StringBuilder completeAddress = new StringBuilder(new URI(address.getScheme(), + address.getAuthority(), null, null, null).toString()); completeAddress.append("/"); completeAddress.append(Utility.trimEnd(pathSegments[1], '/')); return completeAddress.toString(); - } else { + } + else { return new URI(address.getScheme(), address.getAuthority(), null, null, null).toString(); } } @@ -411,7 +412,8 @@ public static HashMap parseQueryString(String parseString) thr if (!value.equals(Constants.EMPTY_STRING)) { retVals.put(key, values); } - } else if (!value.equals(Constants.EMPTY_STRING)) { + } + else if (!value.equals(Constants.EMPTY_STRING)) { final String[] newValues = new String[values.length + 1]; for (int j = 0; j < values.length; j++) { newValues[j] = values[j]; @@ -435,7 +437,8 @@ public static HashMap parseQueryString(String parseString) thr public static URI stripURIQueryAndFragment(final URI inUri) throws StorageException { try { return new URI(inUri.getScheme(), inUri.getAuthority(), inUri.getPath(), null, null); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { throw Utility.generateNewUnexpectedStorageException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java index b436bcb84f32b..a16e08e98e10f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java @@ -67,11 +67,13 @@ public URI addToURI(final URI uri) throws URISyntaxException, StorageException { if (Utility.isNullOrEmpty(origRawQuery) && !Utility.isNullOrEmpty(rawFragment)) { final int bangDex = uriString.indexOf('#'); retBuilder.append(uriString.substring(0, bangDex)); - } else if (!Utility.isNullOrEmpty(origRawQuery)) { + } + else if (!Utility.isNullOrEmpty(origRawQuery)) { // has a query final int queryDex = uriString.indexOf('?'); retBuilder.append(uriString.substring(0, queryDex)); - } else { + } + else { // no fragment or query retBuilder.append(uriString); if (uri.getRawPath().length() <= 0) { @@ -116,7 +118,8 @@ private void insertKeyValue(String key, String value) throws StorageException { list = new ArrayList(); list.add(value); this.parameters.put(key, list); - } else { + } + else { if (!list.contains(value)) { list.add(value); } @@ -138,7 +141,8 @@ public String toString() { for (final String val : this.parameters.get(key)) { if (isFirstPair) { isFirstPair = false; - } else { + } + else { outString.append("&"); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index 05d5170e8d5a0..4f7642617c2a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -97,9 +97,8 @@ public final class Utility { * @throws StorageException * If a storage service error occurred. */ - public static StreamDescriptor analyzeStream( - final InputStream sourceStream, long writeLength, long abandonLength, final boolean rewindSourceStream, - final boolean calculateMD5) throws IOException, StorageException { + public static StreamDescriptor analyzeStream(final InputStream sourceStream, long writeLength, long abandonLength, + final boolean rewindSourceStream, final boolean calculateMD5) throws IOException, StorageException { if (abandonLength < 0) { abandonLength = Long.MAX_VALUE; } @@ -115,7 +114,8 @@ public static StreamDescriptor analyzeStream( if (calculateMD5) { try { digest = MessageDigest.getInstance("MD5"); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { // This wont happen, throw fatal. throw Utility.generateNewUnexpectedStorageException(e); } @@ -187,12 +187,14 @@ public static boolean areCredentialsEqual(final StorageCredentials thisCred, fin } if (thisCred instanceof StorageCredentialsAccountAndKey) { - return ((StorageCredentialsAccountAndKey) thisCred).toString(true) - .equals(((StorageCredentialsAccountAndKey) thatCred).toString(true)); - } else if (thisCred instanceof StorageCredentialsSharedAccessSignature) { - return ((StorageCredentialsSharedAccessSignature) thisCred).getToken() - .equals(((StorageCredentialsSharedAccessSignature) thatCred).getToken()); - } else if (thisCred instanceof StorageCredentialsAnonymous) { + return ((StorageCredentialsAccountAndKey) thisCred).toString(true).equals( + ((StorageCredentialsAccountAndKey) thatCred).toString(true)); + } + else if (thisCred instanceof StorageCredentialsSharedAccessSignature) { + return ((StorageCredentialsSharedAccessSignature) thisCred).getToken().equals( + ((StorageCredentialsSharedAccessSignature) thatCred).getToken()); + } + else if (thisCred instanceof StorageCredentialsAnonymous) { return true; } @@ -209,16 +211,15 @@ public static boolean areCredentialsEqual(final StorageCredentials thisCred, fin * A {@link ResultContinuationType} value that represents the continuation token type being asserted with * the specified continuation token. */ - public static void assertContinuationType( - final ResultContinuation continuationToken, final ResultContinuationType continuationType) { + public static void assertContinuationType(final ResultContinuation continuationToken, + final ResultContinuationType continuationType) { if (continuationToken != null) { if (!(continuationToken.getContinuationType() == ResultContinuationType.NONE || continuationToken .getContinuationType() == continuationType)) { - final String errorMessage = - String.format(Utility.LOCALE_US, + final String errorMessage = String + .format(Utility.LOCALE_US, "The continuation type passed in is unexpected. Please verify that the correct continuation type is passed in. Expected {%s}, found {%s}", - continuationToken.getContinuationType(), - continuationType); + continuationToken.getContinuationType(), continuationType); throw new IllegalArgumentException(errorMessage); } } @@ -258,6 +259,26 @@ public static void assertNotNullOrEmpty(final String param, final String value) } } + /** + * Asserts that the specified integer is in the valid range. + * + * @param param + * A String that represents the name of the parameter, which becomes the exception message + * text if the value parameter is out of bounds. + * @param value + * The value of the specified parameter. + * @param min + * The minimum value for the specified parameter. + * @param max + * The maximum value for the specified parameter. + */ + public static void assertInBounds(final String param, final int value, final int min, final int max) { + if (value < min || value > max) { + throw new IllegalArgumentException(String.format( + "The value of the parameter %s should be between %s and %s.", param, min, max)); + } + } + /** * Creates an XML stream reader from the specified input stream. * @@ -307,7 +328,8 @@ public static boolean determinePathStyleFromUri(final URI baseURI, final String if (Utility.isNullOrEmpty(path) || baseURI.getHost().startsWith(knownAccountName)) { return false; - } else if (!Utility.isNullOrEmpty(path) && path.startsWith(knownAccountName)) { + } + else if (!Utility.isNullOrEmpty(path) && path.startsWith(knownAccountName)) { return true; } @@ -324,10 +346,9 @@ public static boolean determinePathStyleFromUri(final URI baseURI, final String * @return A {@link StorageException} object that represents the unexpected storage exception being thrown. */ public static StorageException generateNewUnexpectedStorageException(final Exception cause) { - final StorageException exceptionRef = - new StorageException(StorageErrorCode.NONE.toString(), "Unexpected internal storage client error.", - 306, // unused - null, null); + final StorageException exceptionRef = new StorageException(StorageErrorCode.NONE.toString(), + "Unexpected internal storage client error.", 306, // unused + null, null); exceptionRef.initCause(cause); return exceptionRef; } @@ -363,15 +384,16 @@ public static byte[] getBytesFromLong(final long value) { * @return A {@link StorageExtendedErrorInformation} object that represents the extended error information from the * request. */ - protected static StorageExtendedErrorInformation getErrorDetailsFromRequest( - final HttpURLConnection request, final OperationContext opContext) { + protected static StorageExtendedErrorInformation getErrorDetailsFromRequest(final HttpURLConnection request, + final OperationContext opContext) { if (request == null) { return null; } try { final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream()); return response.getExtendedErrorInformation(); - } catch (final XMLStreamException e) { + } + catch (final XMLStreamException e) { return null; } } @@ -656,10 +678,12 @@ public static String safeDecode(final String stringToDecode) throws StorageExcep } return outBuilder.toString(); - } else { + } + else { return URLDecoder.decode(stringToDecode, "UTF-8"); } - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } @@ -708,11 +732,13 @@ public static String safeEncode(final String stringToEncode) throws StorageExcep } return outBuilder.toString(); - } else { + } + else { return tString; } - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } @@ -760,10 +786,12 @@ public static String safeRelativize(final URI baseURI, final URI toUri) throws U if (basePath.charAt(m) == '/') { ellipsesCount++; } - } else { + } + else { if (basePath.charAt(m) != toPath.charAt(m)) { break; - } else if (basePath.charAt(m) == '/') { + } + else if (basePath.charAt(m) == '/') { truncatePtr = m + 1; } } @@ -772,7 +800,8 @@ public static String safeRelativize(final URI baseURI, final URI toUri) throws U if (m == toPath.length()) { // No path difference, return query + fragment return new URI(null, null, null, toUri.getQuery(), toUri.getFragment()).toString(); - } else { + } + else { toPath = toPath.substring(truncatePtr); final StringBuilder sb = new StringBuilder(); while (ellipsesCount > 0) { @@ -862,10 +891,9 @@ public static String trimStart(final String value) { * @throws StorageException * If a storage service error occurred. */ - public static StreamDescriptor writeToOutputStream( - final InputStream sourceStream, final OutputStream outStream, long writeLength, - final boolean rewindSourceStream, final boolean calculateMD5, final RequestResult currentResult, - final OperationContext opContext) throws IOException, StorageException { + public static StreamDescriptor writeToOutputStream(final InputStream sourceStream, final OutputStream outStream, + long writeLength, final boolean rewindSourceStream, final boolean calculateMD5, + final RequestResult currentResult, final OperationContext opContext) throws IOException, StorageException { if (opContext != null) { opContext.setCurrentOperationByteCount(0); } @@ -878,7 +906,8 @@ public static StreamDescriptor writeToOutputStream( if (calculateMD5 && opContext.getIntermediateMD5() == null) { try { opContext.setIntermediateMD5(MessageDigest.getInstance("MD5")); - } catch (final NoSuchAlgorithmException e) { + } + catch (final NoSuchAlgorithmException e) { // This wont happen, throw fatal. throw Utility.generateNewUnexpectedStorageException(e); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index 10ecfe8c3cbb6..3062fcb0fcdb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -53,8 +53,8 @@ public static void addLeaseId(final HttpURLConnection request, final String leas * @param metadata * The metadata. */ - public static void addMetadata( - final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final HashMap metadata, + final OperationContext opContext) { if (metadata != null) { for (final Entry entry : metadata.entrySet()) { addMetadata(request, entry.getKey(), entry.getValue(), opContext); @@ -74,8 +74,8 @@ public static void addMetadata( * @param value * The metadata value. */ - public static void addMetadata( - final HttpURLConnection request, final String name, final String value, final OperationContext opContext) { + public static void addMetadata(final HttpURLConnection request, final String name, final String value, + final OperationContext opContext) { Utility.assertNotNullOrEmpty("value", value); request.setRequestProperty(Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA + name, value); @@ -131,9 +131,8 @@ public static void addSnapshot(final UriQueryBuilder builder, final String snaps * @throws StorageException * @throws IllegalArgumentException */ - public static HttpURLConnection create( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection create(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -164,9 +163,8 @@ public static HttpURLConnection create( * if there is an improperly formated URI * @throws StorageException */ - public static HttpURLConnection createURLConnection( - final URI uri, final int timeoutInMs, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection createURLConnection(final URI uri, final int timeoutInMs, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -215,9 +213,8 @@ public static HttpURLConnection createURLConnection( * if there is an improperly formated URI * @throws StorageException */ - public static HttpURLConnection delete( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection delete(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -246,9 +243,8 @@ public static HttpURLConnection delete( * @throws URISyntaxException * @throws IOException * */ - public static HttpURLConnection getMetadata( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws StorageException, IOException, URISyntaxException { + public static HttpURLConnection getMetadata(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws StorageException, IOException, URISyntaxException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -278,9 +274,8 @@ public static HttpURLConnection getMetadata( * @throws URISyntaxException * @throws IOException * */ - public static HttpURLConnection getProperties( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection getProperties(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -309,9 +304,8 @@ public static HttpURLConnection getProperties( * @throws URISyntaxException * @throws StorageException */ - public static HttpURLConnection getServiceProperties( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection getServiceProperties(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -334,10 +328,8 @@ public static HttpURLConnection getServiceProperties( */ public static String getUserAgent() { if (userAgent == null) { - userAgent = - String.format("%s/%s", - Constants.HeaderConstants.USER_AGENT_PREFIX, - Constants.HeaderConstants.USER_AGENT_VERSION); + userAgent = String.format("%s/%s", Constants.HeaderConstants.USER_AGENT_PREFIX, + Constants.HeaderConstants.USER_AGENT_VERSION); } return userAgent; } @@ -354,9 +346,8 @@ public static String getUserAgent() { * if there is an error writing the content to the stream. * @throws StorageException */ - public static byte[] serializeServicePropertiesToByteArray( - final ServiceProperties properties, final OperationContext opContext) - throws XMLStreamException, StorageException { + public static byte[] serializeServicePropertiesToByteArray(final ServiceProperties properties, + final OperationContext opContext) throws XMLStreamException, StorageException { return properties.serializeToByteArray(opContext); } @@ -376,9 +367,8 @@ public static byte[] serializeServicePropertiesToByteArray( * @throws URISyntaxException * @throws IOException * */ - public static HttpURLConnection setMetadata( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection setMetadata(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); @@ -410,9 +400,8 @@ public static HttpURLConnection setMetadata( * @throws URISyntaxException * @throws StorageException */ - public static HttpURLConnection setServiceProperties( - final URI uri, final int timeout, UriQueryBuilder builder, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection setServiceProperties(final URI uri, final int timeout, UriQueryBuilder builder, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { if (builder == null) { builder = new UriQueryBuilder(); } @@ -443,14 +432,13 @@ public static HttpURLConnection setServiceProperties( * if the credentials key is invalid. * @throws StorageException */ - public static void signRequestForBlobAndQueue( - final HttpURLConnection request, final Credentials credentials, final Long contentLength, - final OperationContext opContext) throws InvalidKeyException, StorageException { + public static void signRequestForBlobAndQueue(final HttpURLConnection request, final Credentials credentials, + final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueFullCanonicalizer(request); - final String stringToSign = - canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, + opContext); final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); @@ -476,15 +464,15 @@ public static void signRequestForBlobAndQueue( * if the credentials key is invalid. * @throws StorageException */ - public static void signRequestForBlobAndQueueSharedKeyLite( - final HttpURLConnection request, final Credentials credentials, final Long contentLength, - final OperationContext opContext) throws InvalidKeyException, StorageException { + public static void signRequestForBlobAndQueueSharedKeyLite(final HttpURLConnection request, + final Credentials credentials, final Long contentLength, final OperationContext opContext) + throws InvalidKeyException, StorageException { request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueLiteCanonicalizer(request); - final String stringToSign = - canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, + opContext); final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); @@ -511,15 +499,14 @@ public static void signRequestForBlobAndQueueSharedKeyLite( * if the credentials key is invalid. * @throws StorageException */ - public static void signRequestForTableSharedKeyLite( - final HttpURLConnection request, final Credentials credentials, final Long contentLength, - final OperationContext opContext) throws InvalidKeyException, StorageException { + public static void signRequestForTableSharedKeyLite(final HttpURLConnection request, final Credentials credentials, + final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); final Canonicalizer canonicalizer = CanonicalizerFactory.getTableLiteCanonicalizer(request); - final String stringToSign = - canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, opContext); + final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, + opContext); final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java index 3ee401673de00..b45a8a353729a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java @@ -83,8 +83,7 @@ public static String getRequestId(final HttpURLConnection request) { * the prefix for headers to be returned. * @return all the header/value pairs with the given prefix. */ - private static - HashMap getValuesByHeaderPrefix(final HttpURLConnection request, final String prefix) { + private static HashMap getValuesByHeaderPrefix(final HttpURLConnection request, final String prefix) { final HashMap retVals = new HashMap(); final Map> headerMap = request.getHeaderFields(); final int prefixLength = prefix.length(); @@ -112,8 +111,8 @@ HashMap getValuesByHeaderPrefix(final HttpURLConnection request, * @throws StorageException * if unexpected xml is found. */ - public static ServiceProperties readServicePropertiesFromStream( - final InputStream inStream, final OperationContext opContext) throws XMLStreamException, StorageException { + public static ServiceProperties readServicePropertiesFromStream(final InputStream inStream, + final OperationContext opContext) throws XMLStreamException, StorageException { return ServiceProperties.readServicePropertiesFromStream(inStream, opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java index 2bf783e461c06..dc1a61c40704d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java @@ -34,21 +34,15 @@ final class BlobQueueFullCanonicalizer extends Canonicalizer { * @throws StorageException */ @Override - protected String canonicalize( - final HttpURLConnection conn, final String accountName, final Long contentLength, + protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, final OperationContext opContext) throws StorageException { if (contentLength < -1) { throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); } - return canonicalizeHttpRequest(conn.getURL(), - accountName, - conn.getRequestMethod(), - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), - contentLength, - null, - conn, - opContext); + return canonicalizeHttpRequest(conn.getURL(), accountName, conn.getRequestMethod(), + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), contentLength, null, + conn, opContext); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java index afa14aca2ad87..aefe6b9e50e50 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java @@ -31,20 +31,14 @@ final class BlobQueueLiteCanonicalizer extends Canonicalizer { * @throws StorageException */ @Override - protected String canonicalize( - final HttpURLConnection conn, final String accountName, final Long contentLength, + protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, final OperationContext opContext) throws StorageException { if (contentLength < -1) { throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); } - return canonicalizeHttpRequestLite(conn.getURL(), - accountName, - conn.getRequestMethod(), - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), - contentLength, - null, - conn, - opContext); + return canonicalizeHttpRequestLite(conn.getURL(), accountName, conn.getRequestMethod(), + Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), contentLength, null, + conn, opContext); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java index 19c03b7643a7e..04d6d1d68fd16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -112,11 +112,9 @@ protected static void appendCanonicalizedElement(final StringBuilder builder, fi * @return A canonicalized string. * @throws StorageException */ - protected static - String canonicalizeHttpRequest( - final java.net.URL address, final String accountName, final String method, - final String contentType, final long contentLength, final String date, - final HttpURLConnection conn, final OperationContext opContext) throws StorageException { + protected static String canonicalizeHttpRequest(final java.net.URL address, final String accountName, + final String method, final String contentType, final long contentLength, final String date, + final HttpURLConnection conn, final OperationContext opContext) throws StorageException { // The first element should be the Method of the request. // I.e. GET, POST, PUT, or HEAD. @@ -184,11 +182,9 @@ String canonicalizeHttpRequest( * @return A canonicalized string. * @throws StorageException */ - protected static - String canonicalizeHttpRequestLite( - final java.net.URL address, final String accountName, final String method, - final String contentType, final long contentLength, final String date, - final HttpURLConnection conn, final OperationContext opContext) throws StorageException { + protected static String canonicalizeHttpRequestLite(final java.net.URL address, final String accountName, + final String method, final String contentType, final long contentLength, final String date, + final HttpURLConnection conn, final OperationContext opContext) throws StorageException { // The first element should be the Method of the request. // I.e. GET, POST, PUT, or HEAD. final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); @@ -372,7 +368,6 @@ private static ArrayList getHeaderValues(final Map> * the OperationContext for the given request * @return a canonicalized string. */ - protected abstract String canonicalize( - HttpURLConnection conn, String accountName, Long contentLength, OperationContext opContext) - throws StorageException; + protected abstract String canonicalize(HttpURLConnection conn, String accountName, Long contentLength, + OperationContext opContext) throws StorageException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java index 798a16f5c6a20..d47cdd28a13f6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -45,7 +45,8 @@ final class CanonicalizerFactory { protected static Canonicalizer getBlobQueueFullCanonicalizer(final HttpURLConnection conn) { if (validateVersionIsSupported(conn)) { return BLOB_QUEUE_FULL_V2_INSTANCE; - } else { + } + else { throw new UnsupportedOperationException("Storage protocol version prior to 2009-09-19 are not supported."); } } @@ -60,7 +61,8 @@ protected static Canonicalizer getBlobQueueFullCanonicalizer(final HttpURLConnec protected static Canonicalizer getBlobQueueLiteCanonicalizer(final HttpURLConnection conn) { if (validateVersionIsSupported(conn)) { return BLOB_QUEUE_LITE_INSTANCE; - } else { + } + else { throw new UnsupportedOperationException( "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); } @@ -76,7 +78,8 @@ protected static Canonicalizer getBlobQueueLiteCanonicalizer(final HttpURLConnec protected static Canonicalizer getTableLiteCanonicalizer(final HttpURLConnection conn) { if (validateVersionIsSupported(conn)) { return TABLE_LITE_INSTANCE; - } else { + } + else { throw new UnsupportedOperationException( "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); } @@ -90,8 +93,8 @@ protected static Canonicalizer getTableLiteCanonicalizer(final HttpURLConnection * @return true if is greater or equal PDC 09'; otherwise, false. */ private static Boolean validateVersionIsSupported(final HttpURLConnection conn) { - final String versionString = - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.STORAGE_VERSION_HEADER); + final String versionString = Utility.getStandardHeaderValue(conn, + Constants.HeaderConstants.STORAGE_VERSION_HEADER); if (versionString.length() == 0 || versionString.length() == 0) { return true; @@ -113,7 +116,8 @@ private static Boolean validateVersionIsSupported(final HttpURLConnection conn) return requestVersionCalendar.compareTo(versionThresholdCalendar) >= 0; - } catch (final ParseException e) { + } + catch (final ParseException e) { return false; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java index d3bf310926292..ff2688ad95e9d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java @@ -36,9 +36,11 @@ public static HashMap parseMetadateFromXML(final XMLStreamReader if (eventType == XMLStreamConstants.END_ELEMENT && Constants.METADATA_ELEMENT.equals(name)) { break; - } else if (Constants.INVALID_METADATA_NAME.equals(name)) { + } + else if (Constants.INVALID_METADATA_NAME.equals(name)) { // no op , skip - } else if (eventType == XMLStreamConstants.START_ELEMENT) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT) { final String tValue = Utility.readElementFromXMLReader(xmlr, name); if (!Utility.isNullOrEmpty(tValue)) { retVals.put(name, tValue); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 0ed8b385404bf..1bf0339fa495e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -49,10 +49,9 @@ public final class ExecutionEngine { * @throws StorageException * an exception representing any error which occurred during the operation. */ - protected static RESULT_TYPE execute( - final CLIENT_TYPE client, final PARENT_TYPE parentObject, - final StorageOperation task, final OperationContext opContext) - throws StorageException { + protected static RESULT_TYPE execute(final CLIENT_TYPE client, + final PARENT_TYPE parentObject, final StorageOperation task, + final OperationContext opContext) throws StorageException { return executeWithRetry(client, parentObject, task, RetryNoRetry.getInstance(), opContext); } @@ -79,10 +78,9 @@ protected static RESULT_TYPE execute( * @throws StorageException * an exception representing any error which occurred during the operation. */ - public static RESULT_TYPE executeWithRetry( - final CLIENT_TYPE client, final PARENT_TYPE parentObject, - final StorageOperation task, final RetryPolicyFactory policyFactory, - final OperationContext opContext) throws StorageException { + public static RESULT_TYPE executeWithRetry(final CLIENT_TYPE client, + final PARENT_TYPE parentObject, final StorageOperation task, + final RetryPolicyFactory policyFactory, final OperationContext opContext) throws StorageException { final RetryPolicy policy = policyFactory.createInstance(opContext); RetryResult retryRes; @@ -102,7 +100,8 @@ public static RESULT_TYPE executeWithRet if (!task.isNonExceptionedRetryableFailure()) { // Success return result, the rest of the return paths throw. return result; - } else { + } + else { // The task may have already parsed an exception. translatedException = task.materializeException(getLastRequestObject(opContext), opContext); setLastException(opContext, translatedException); @@ -115,61 +114,68 @@ public static RESULT_TYPE executeWithRet throw translatedException; } } - } catch (final TimeoutException e) { + } + catch (final TimeoutException e) { // Retryable - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); - } catch (final SocketTimeoutException e) { + } + catch (final SocketTimeoutException e) { // Retryable - translatedException = - new StorageException(StorageErrorCodeStrings.OPERATION_TIMED_OUT, - "The operation did not complete in the specified time.", -1, null, e); + translatedException = new StorageException(StorageErrorCodeStrings.OPERATION_TIMED_OUT, + "The operation did not complete in the specified time.", -1, null, e); setLastException(opContext, translatedException); - } catch (final IOException e) { + } + catch (final IOException e) { // Retryable - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); - } catch (final XMLStreamException e) { + } + catch (final XMLStreamException e) { // Retryable - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); - } catch (final InvalidKeyException e) { + } + catch (final InvalidKeyException e) { // Non Retryable, just throw - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); throw translatedException; - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { // Non Retryable, just throw - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); throw translatedException; - } catch (final StorageException e) { + } + catch (final StorageException e) { // Non Retryable, just throw // do not translate StorageException setLastException(opContext, e); throw e; - } catch (final Exception e) { + } + catch (final Exception e) { // Non Retryable, just throw // TODO Should this be retried? - translatedException = - StorageException.translateException(getLastRequestObject(opContext), e, opContext); + translatedException = StorageException + .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); throw translatedException; } // Evaluate Retry Policy - retryRes = - policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), opContext.getLastResult() - .getException(), opContext); + retryRes = policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), opContext + .getLastResult().getException(), opContext); if (!retryRes.isShouldRetry()) { throw translatedException; - } else { + } + else { retryRes.doSleep(); currentRetryCount++; } @@ -195,7 +201,8 @@ public static InputStream getInputStream(final HttpURLConnection request, final opContext.getRequestResults().add(currResult); try { return request.getInputStream(); - } catch (final IOException ex) { + } + catch (final IOException ex) { getResponseCode(currResult, request, opContext); throw ex; } @@ -228,9 +235,8 @@ private static HttpURLConnection getLastRequestObject(final OperationContext opC * @throws IOException * if there is an error making the connection */ - public static void getResponseCode( - final RequestResult currResult, final HttpURLConnection request, final OperationContext opContext) - throws IOException { + public static void getResponseCode(final RequestResult currResult, final HttpURLConnection request, + final OperationContext opContext) throws IOException { // Send the request currResult.setStatusCode(request.getResponseCode()); currResult.setStatusMessage(request.getResponseMessage()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java index 59d9f87dedcad..02e0cc52db677 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java @@ -94,16 +94,12 @@ public boolean hasNext() { || (!this.currentSegmentIterator.hasNext() && this.currentSegment != null && this.currentSegment .getHasMoreResults())) { try { - this.currentSegment = - ExecutionEngine.executeWithRetry(this.client, - this.parentObject, - this.segmentGenerator, - this.policyFactory, - this.opContext); - } catch (final StorageException e) { - final NoSuchElementException ex = - new NoSuchElementException( - "An error occurred while enumerating the result, check the original exception for details."); + this.currentSegment = ExecutionEngine.executeWithRetry(this.client, this.parentObject, + this.segmentGenerator, this.policyFactory, this.opContext); + } + catch (final StorageException e) { + final NoSuchElementException ex = new NoSuchElementException( + "An error occurred while enumerating the result, check the original exception for details."); ex.initCause(e); throw ex; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java index c2e63a55d4c2c..9e17f012d77c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java @@ -75,18 +75,20 @@ private void parseErrorException(final XMLStreamReader xmlr) throws XMLStreamExc final String name = xmlr.getName().toString(); if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION_MESSAGE)) { - final String errorExceptionMessage = - Utility.readElementFromXMLReader(xmlr, Constants.ERROR_EXCEPTION_MESSAGE); + final String errorExceptionMessage = Utility.readElementFromXMLReader(xmlr, + Constants.ERROR_EXCEPTION_MESSAGE); this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_MESSAGE, new String[] { errorExceptionMessage }); - } else if (eventType == XMLStreamConstants.START_ELEMENT + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION_STACK_TRACE)) { - final String errorExceptionStack = - Utility.readElementFromXMLReader(xmlr, Constants.ERROR_EXCEPTION_STACK_TRACE); + final String errorExceptionStack = Utility.readElementFromXMLReader(xmlr, + Constants.ERROR_EXCEPTION_STACK_TRACE); this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_STACK_TRACE, new String[] { errorExceptionStack }); - } else if (eventType == XMLStreamConstants.END_ELEMENT) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT) { break; } } @@ -122,13 +124,16 @@ private void parseResponse() throws XMLStreamException { if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_CODE)) { this.errorInfo.setErrorCode(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_CODE)); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_MESSAGE)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_MESSAGE)) { this.errorInfo.setErrorMessage(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_MESSAGE)); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION)) { // get error exception this.parseErrorException(xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ERROR_EXCEPTION); - } else if (eventType == XMLStreamConstants.START_ELEMENT) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT) { // get additional details tempParseString = Utility.readElementFromXMLReader(xmlr, name); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index 337c0cd5b854b..c166e00de56d3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -119,8 +119,8 @@ public final boolean isNonExceptionedRetryableFailure() { * an object used to track the execution of the operation * @return the exception to throw. */ - protected final StorageException materializeException( - final HttpURLConnection request, final OperationContext opContext) { + protected final StorageException materializeException(final HttpURLConnection request, + final OperationContext opContext) { if (this.getException() != null) { return this.getException(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java index f83b936ffa9c9..a03d60e17fbe4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -33,8 +33,7 @@ class TableLiteCanonicalizer extends Canonicalizer { * @throws StorageException */ @Override - protected String canonicalize( - final HttpURLConnection conn, final String accountName, final Long contentLength, + protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, final OperationContext opContext) throws StorageException { if (contentLength < -1) { throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 027ac7b66e0f0..aa808f3b4cde2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -1,3 +1,8 @@ +/* + * CloudQueue.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.OutputStream; @@ -13,17 +18,26 @@ import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; +import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; /** - * Represents a queue in the Windows Azure Queue service. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * This class represents a queue in the Windows Azure Queue service. */ public final class CloudQueue { + /** + * Gets the first message from a list of queue messages, if any. + * + * @param messages + * The Iterable collection of {@link CloudQueueMessage} objects to get the first message + * from. + * + * @return The first {@link CloudQueueMessage} from the list of queue + * messages, or null if the list is empty. + */ static CloudQueueMessage getFirstOrNull(final Iterable messages) { for (final CloudQueueMessage m : messages) { return m; @@ -33,48 +47,52 @@ static CloudQueueMessage getFirstOrNull(final Iterable messag } /** - * Holds the Name of the queue + * The name of the queue. */ private String name; /** - * Holds the URI of the queue + * The absolute URI of the queue. */ URI uri; /** - * Holds a reference to the associated service client. + * A reference to the queue's associated service client. */ private CloudQueueClient queueServiceClient; /** - * Holds the Queue Metadata + * The queue's Metadata collection. */ HashMap metadata; /** - * Holds the Queue ApproximateMessageCount + * The queue's approximate message count, as reported by the server. */ long approximateMessageCount; /** - * Uri for the messages. + * The CloudQueue class using the specified address and client. + * Creates an instance of the CloudQueue class using the + * specified address and client. * * @param queueAddress - * A String that represents either the absolute URI to the queue, or the queue name. + * A String that represents either the absolute URI + * to the queue, or the queue name. * @param client - * A {@link CloudQueueClient} object that represents the associated service client, and that specifies - * the endpoint for the Queue service. + * A {@link CloudQueueClient} object that represents the + * associated service client, and that specifies the endpoint for + * the Queue service. * * @throws URISyntaxException * If the resource URI is invalid. @@ -84,13 +102,16 @@ public CloudQueue(final String queueAddress, final CloudQueueClient client) thro } /** - * Creates an instance of the CloudQueue class using the specified address and client. + * Creates an instance of the CloudQueue class using the + * specified queue URI and client. * * @param uri - * A java.net.URI object that represents the URI of the queue. + * A java.net.URI object that represents the + * absolute URI of the queue. * @param client - * A {@link CloudQueueClient} object that represents the associated service client, and that specifies - * the endpoint for the Queue service. + * A {@link CloudQueueClient} object that represents the + * associated service client, and that specifies the endpoint for + * the Queue service. */ public CloudQueue(final URI uri, final CloudQueueClient client) { this.uri = uri; @@ -100,13 +121,14 @@ public CloudQueue(final URI uri, final CloudQueueClient client) { } /** - * Adds a message to the queue. + * Adds a message to the back of the queue with the default options. * * @param message - * A {@link CloudQueueMessage} object that specifies the message to add. + * A {@link CloudQueueMessage} object that specifies the message + * to add. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void addMessage(final CloudQueueMessage message) throws StorageException { @@ -114,36 +136,55 @@ public void addMessage(final CloudQueueMessage message) throws StorageException } /** - * Adds a message to the queue. + * Adds a message to the back of the queue with the specified options. * * @param message - * A {@link CloudQueueMessage} object that specifies the message to add. + * A {@link CloudQueueMessage} object that specifies the message + * to add. * * @param timeToLiveInSeconds - * The maximum time to allow the message to be in the queue, or null if the service default time is to be - * used. + * The maximum time to allow the message to be in the queue. A + * value of zero will set the time-to-live to the service default + * value of seven days. * * @param initialVisibilityDelayInSeconds - * The length of time from now during which the message will be invisible, or null if the message is to - * be visible immediately. This must be greater than or equal to zero and less than the value of - * timeToLive (if not null). + * The length of time during which the message will be invisible, + * starting when it is added to the queue, or 0 to make the + * message visible immediately. This value must be greater than + * or equal to zero and less than or equal to the time-to-live + * value. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). + * * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void addMessage( - final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, - QueueRequestOptions options, OperationContext opContext) throws StorageException { + public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, + final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext) + throws StorageException { + Utility.assertNotNull("message", message); + Utility.assertNotNull("messageContent", message.getMessageContentAsByte()); + Utility.assertInBounds("timeToLiveInSeconds", timeToLiveInSeconds, 0, + QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); + + final int realTimeToLiveInSeconds = timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS + : timeToLiveInSeconds; + Utility.assertInBounds("initialVisibilityDelayInSeconds", initialVisibilityDelayInSeconds, 0, + realTimeToLiveInSeconds - 1); + + final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); + if (opContext == null) { opContext = new OperationContext(); } @@ -155,52 +196,43 @@ public void addMessage( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.putMessage(queue.getMessageRequestAddress(), - this.getRequestOptions().getTimeoutIntervalInMs(), - initialVisibilityDelayInSeconds, - timeToLiveInSeconds, - opContext); + final HttpURLConnection request = QueueRequest.putMessage(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), initialVisibilityDelayInSeconds, + timeToLiveInSeconds, opContext); - final byte[] messageBytes = - QueueRequest.generateMessageRequestBody(message - .getMessageContentForTransfer(queue.shouldEncodeMessage)); + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Clears all messages from the queue. + * Clears all messages from the queue, using the default request options. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void clear() throws StorageException { @@ -208,19 +240,22 @@ public void clear() throws StorageException { } /** - * Clears all messages from the queue, using the specified request options and operation context. + * Clears all messages from the queue, using the specified request options + * and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void clear(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -235,42 +270,37 @@ public void clear(QueueRequestOptions options, OperationContext opContext) throw opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.clearMessages(queue.getMessageRequestAddress(), this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = QueueRequest.clearMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Creates the queue. + * Creates the queue in the storage service with default request options. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void create() throws StorageException { @@ -278,19 +308,22 @@ public void create() throws StorageException { } /** - * Creates the queue. + * Creates the queue in the storage service using the specified request + * options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void create(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -305,44 +338,42 @@ public void create(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.create(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED - && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED + && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Creates the queue if it does not exist. + * Creates the queue in the storage service using default request options if + * it does not already exist. + * + * @return A value of true if the queue is created in the + * storage service, otherwise false. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean createIfNotExist() throws StorageException { @@ -350,19 +381,25 @@ public Boolean createIfNotExist() throws StorageException { } /** - * Creates the queue if it does not exist. + * Creates the queue in the storage service with the specified request + * options and operation context if it does not already exist. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return A value of true if the queue is created in the + * storage service, otherwise false. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean createIfNotExist(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -377,53 +414,48 @@ public Boolean createIfNotExist(QueueRequestOptions options, OperationContext op opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.create(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = - StorageException.translateException(request, null, opContext); - - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - } - } - - return false; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = StorageException.translateException(request, + null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); } - }; + } - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return false; + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Deletes the queue. + * Deletes the queue from the storage service. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void delete() throws StorageException { @@ -431,19 +463,22 @@ public void delete() throws StorageException { } /** - * Deletes the queue. + * Deletes the queue from the storage service, using the specified request + * options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void delete(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -458,42 +493,39 @@ public void delete(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.delete(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Deletes the queue if it exists. + * Deletes the queue from the storage service if it exists. + * + * @return A value of true if the queue existed in the storage + * service and has been deleted, otherwise false. * * @throws StorageException - * an exception representing any error which occurred during the operation. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean deleteIfExists() throws StorageException { @@ -501,21 +533,25 @@ public Boolean deleteIfExists() throws StorageException { } /** - * Deletes the queue if it exists using the specified request options and operation context. + * Deletes the queue from the storage service using the specified request + * options and operation context, if it exists. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return true if the queue did not already exist and was created; otherwise, false. + * @return A value of true if the queue existed in the storage + * service and has been deleted, otherwise false. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -530,48 +566,45 @@ public Boolean deleteIfExists(QueueRequestOptions options, OperationContext opCo opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.delete(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } else { - this.setNonExceptionedRetryableFailure(true); - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } + else { + this.setNonExceptionedRetryableFailure(true); + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Deletes a message in a queue. + * Deletes the specified message from the queue. * * @param message - * A {@link CloudQueueMessage} object that specifies the message to delete. + * A {@link CloudQueueMessage} object that specifies the message + * to delete. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void deleteMessage(final CloudQueueMessage message) throws StorageException { @@ -579,22 +612,27 @@ public void deleteMessage(final CloudQueueMessage message) throws StorageExcepti } /** - * Deletes a message in a queue, using the specified request options and operation context. + * Deletes the specified message from the queue, using the specified request + * options and operation context. * * @param message - * A {@link CloudQueueMessage} object that specifies the message to delete. + * A {@link CloudQueueMessage} object that specifies the message + * to delete. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). + * * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext) @@ -613,42 +651,38 @@ public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions o final String messageId = message.getId(); final String messagePopReceipt = message.getPopReceipt(); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.deleteMessage(queue.getIndividualMessageAddress(messageId), this - .getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); + final HttpURLConnection request = QueueRequest.deleteMessage( + queue.getIndividualMessageAddress(messageId), + this.getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Downloads the queue's metadata and ApproximateMessageCount. + * Downloads the queue's metadata and approximate message count value. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void downloadAttributes() throws StorageException { @@ -656,20 +690,22 @@ public void downloadAttributes() throws StorageException { } /** - * Downloads the queue's metadata and ApproximateMessageCount, using the specified request options and operation - * context. + * Downloads the queue's metadata and approximate message count value, using + * the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueue}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueue}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void downloadAttributes(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -684,46 +720,43 @@ public void downloadAttributes(QueueRequestOptions options, OperationContext opC opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - queue.metadata = BaseResponse.getMetadata(request); - queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); - return null; - } - }; + queue.metadata = BaseResponse.getMetadata(request); + queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Returns a value that indicates whether the queue exists. + * Returns a value that indicates whether the queue exists in the storage + * service. * - * @return true if the queue exists, otherwise false. + * @return true if the queue exists in the storage service, + * otherwise false. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean exist() throws StorageException { @@ -731,22 +764,25 @@ public Boolean exist() throws StorageException { } /** - * Returns a value that indicates whether the queue exists, using the specified request options and operation - * context. + * Returns a value that indicates whether the queue exists in the storage + * service, using the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return true if the queue exists, otherwise false. + * @return true if the queue exists in the storage service, + * otherwise false. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Boolean exist(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -761,53 +797,53 @@ public Boolean exist(QueueRequestOptions options, OperationContext opContext) th opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - return Boolean.valueOf(true); - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + return Boolean.valueOf(true); + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } + else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Gets the approximate messages count of the queue. + * Gets the approximate messages count of the queue. This value is + * initialized by a request to {@link #downloadAttributes} and represents + * the approximate message count when that request completed. * - * @return A Long object that represents the approximate messages count of the queue. + * @return A Long object that represents the approximate + * messages count of the queue. */ public long getApproximateMessageCount() { return this.approximateMessageCount; } /** - * Get a single message request(Used internally only). + * Get a single message request (Used internally only). * - * @return the single message request. + * @return The URI for a single message request. * * @throws URISyntaxException * If the resource URI is invalid. @@ -817,9 +853,9 @@ URI getIndividualMessageAddress(final String messageId) throws URISyntaxExceptio } /** - * Get the message request base address(Used internally only). + * Get the message request base address (Used internally only). * - * @return the message request. + * @return The message request URI. * * @throws URISyntaxException * If the resource URI is invalid. @@ -833,57 +869,67 @@ URI getMessageRequestAddress() throws URISyntaxException { } /** - * Returns the metadata for the queue. + * Gets the metadata collection for the queue as stored in this CloudQueue object. This value is + * initialized with the + * metadata from the queue by a call to {@link #downloadAttributes}, and is + * set on the queue with a call to {@link #uploadMetadata}. * - * @return A java.util.HashMap object that represents the metadata for the queue. + * @return A java.util.HashMap object that represents the + * metadata for the queue. */ public HashMap getMetadata() { return this.metadata; } /** - * Gets the name of the queue + * Gets the name of the queue. * - * @return A String object that represents the name of the queue. + * @return A String object that represents the name of the + * queue. */ public String getName() { return this.name; } /** - * Returns the queue service client associated with this queue. + * Gets the queue service client associated with this queue. * - * @return A {@link CloudQueueClient} object that represents the service client associated with this queue. + * @return A {@link CloudQueueClient} object that represents the service + * client associated with this queue. */ public CloudQueueClient getServiceClient() { return this.queueServiceClient; } /** - * Gets the value indicating whether the message should be encoded. + * Gets the value indicating whether the message should be base-64 encoded. * - * @return A Boolean that represents whether the message should be encoded. + * @return A Boolean that represents whether the message should + * be base-64 encoded. */ public Boolean getShouldEncodeMessage() { return this.shouldEncodeMessage; } /** - * Gets the uri for this queue. + * Gets the absolute URI for this queue. * - * @return A URI object that represents the uri for this queue. + * @return A java.net.URI object that represents the URI for + * this queue. */ public URI getUri() { return this.uri; } /** - * Peeks a message from the queue. + * Peeks a message from the queue. A peek request retrieves a message from + * the front of the queue without changing its visibility. * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * @return An {@link CloudQueueMessage} object that represents a message in + * this queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public CloudQueueMessage peekMessage() throws StorageException { @@ -891,21 +937,26 @@ public CloudQueueMessage peekMessage() throws StorageException { } /** - * Peeks a message from the queue, using the specified request options and operation context. + * Peeks a message from the queue, using the specified request options and + * operation context. A peek request retrieves a message from the front of + * the queue without changing its visibility. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * @return An {@link CloudQueueMessage} object that represents the requested + * message from the queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public CloudQueueMessage peekMessage(final QueueRequestOptions options, final OperationContext opContext) @@ -914,15 +965,18 @@ public CloudQueueMessage peekMessage(final QueueRequestOptions options, final Op } /** - * Peeks a set of messages from the queue. + * Peeks a specified number of messages from the queue. A peek request + * retrieves messages from the front of the queue without changing their + * visibility. * * @param numberOfMessages - * The number of messages. + * The number of messages to retrieve. * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects + * that represents the requested messages from the queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Iterable peekMessages(final int numberOfMessages) throws StorageException { @@ -930,29 +984,35 @@ public Iterable peekMessages(final int numberOfMessages) thro } /** - * Peeks a set of messages from the queue, using the specified request options and operation context. + * Peeks a set of messages from the queue, using the specified request + * options and operation context. A peek request retrieves messages from the + * front of the queue without changing their visibility. * * @param numberOfMessages - * The number of messages. + * The number of messages to retrieve. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects + * that represents the requested messages from the queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable peekMessages( - final int numberOfMessages, QueueRequestOptions options, OperationContext opContext) - throws StorageException { + public Iterable peekMessages(final int numberOfMessages, QueueRequestOptions options, + OperationContext opContext) throws StorageException { + Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); + if (opContext == null) { opContext = new OperationContext(); } @@ -964,46 +1024,44 @@ public Iterable peekMessages( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { + final StorageOperation> impl = new StorageOperation>( + options) { - @Override - public ArrayList execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - QueueRequest.peekMessages(queue.getMessageRequestAddress(), this.getRequestOptions() - .getTimeoutIntervalInMs(), numberOfMessages, opContext); + final HttpURLConnection request = QueueRequest.peekMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), - queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Retrieves a message from the queue. + * Retrieves a message from the front of the queue using the default request + * options. This operation marks the retrieved message as invisible in the + * queue for the default visibility timeout period. * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * @return An {@link CloudQueueMessage} object that represents a message in + * this queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public CloudQueueMessage retrieveMessage() throws StorageException { @@ -1011,42 +1069,51 @@ public CloudQueueMessage retrieveMessage() throws StorageException { } /** - * Retrieves a message from the queue, using the specified request options and operation context. + * Retrieves a message from the front of the queue, using the specified + * request options and operation context. This operation marks the retrieved + * message as invisible in the queue for the specified visibility timeout + * period. * * @param visibilityTimeoutInSeconds * Specifies the visibility timeout for the message, in seconds. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. + * @return An {@link CloudQueueMessage} object that represents a message in + * this queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public CloudQueueMessage retrieveMessage( - final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext) - throws StorageException { + public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, + final OperationContext opContext) throws StorageException { return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, null, null)); } /** - * Retrieves a list of messages from the queue. + * Retrieves the specified number of messages from the front of the queue + * using the default request options. This operation marks the retrieved + * messages as invisible in the queue for the default visibility timeout + * period. * * @param numberOfMessages - * The number of messages. + * The number of messages to retrieve. * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects + * that represents the retrieved messages from the queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { @@ -1054,32 +1121,41 @@ public Iterable retrieveMessages(final int numberOfMessages) } /** - * Retrieves a list of messages from the queue, using the specified request options and operation context. + * Retrieves the specified number of messages from the front of the queue + * using the specified request options and operation context. This operation + * marks the retrieved messages as invisible in the queue for the default + * visibility timeout period. * * @param numberOfMessages - * The number of messages. + * The number of messages to retrieve. * * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout for the message, in seconds. + * Specifies the visibility timeout for the retrieved messages, + * in seconds. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages in this queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects + * that represents the messages retrieved from the queue. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable retrieveMessages( - final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, - OperationContext opContext) throws StorageException { + public Iterable retrieveMessages(final int numberOfMessages, + final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) + throws StorageException { + Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); + if (opContext == null) { opContext = new OperationContext(); } @@ -1091,47 +1167,44 @@ public Iterable retrieveMessages( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { + final StorageOperation> impl = new StorageOperation>( + options) { - @Override - public ArrayList execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), - this.getRequestOptions().getTimeoutIntervalInMs(), - numberOfMessages, - visibilityTimeoutInSeconds, - opContext); + final HttpURLConnection request = QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, visibilityTimeoutInSeconds, + opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), - queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Sets the metadata for the queue. + * Sets the metadata collection of name-value pairs to be set on the queue + * with an {@link #uploadMetadata} call. This collection will overwrite any + * existing queue metadata. If this is set to an empty collection, the queue + * metadata will be cleared on an {@link #uploadMetadata} call. * * @param metadata - * A java.util.HashMap object that represents the metadata being assigned to the queue. + * A java.util.HashMap object that represents the + * metadata being assigned to the queue. */ public void setMetadata(final HashMap metadata) { this.metadata = metadata; @@ -1141,17 +1214,26 @@ public void setMetadata(final HashMap metadata) { * Sets the name of the queue. * * @param name - * A String that represents the name being assigned to the queue. + * A String that represents the name being assigned + * to the queue. */ void setName(final String name) { this.name = name; } /** - * Updates a message in the queue. + * Updates the specified message in the queue with a new visibility timeout + * value in seconds. + * + * @param message + * The {@link CloudQueueMessage} to update in the queue. + * + * @param visibilityTimeoutInSeconds + * Specifies the new visibility timeout for the message, in + * seconds. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds) throws StorageException { @@ -1159,31 +1241,48 @@ public void updateMessage(final CloudQueueMessage message, final int visibilityT } /** - * Updates a message in the queue, using the specified request options and operation context. + * Updates a message in the queue, using the specified request options and + * operation context. + * + * @param message + * The {@link CloudQueueMessage} to update in the queue. * * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout for the message, in seconds. + * Specifies the new visibility timeout for the message, in + * seconds. * * @param messageUpdateFields - * Specifies which parts of the message are to be updated. + * An EnumSet of {@link MessageUpdateFields} values + * that specifies which parts of the message are to be updated. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). + * * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void updateMessage( - final CloudQueueMessage message, final int visibilityTimeoutInSeconds, + public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, final EnumSet messageUpdateFields, QueueRequestOptions options, OperationContext opContext) throws StorageException { + Utility.assertNotNull("message", message); + Utility.assertNotNullOrEmpty("messageId", message.id); + Utility.assertNotNullOrEmpty("popReceipt", message.popReceipt); + + Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, + QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); + + final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); + if (opContext == null) { opContext = new OperationContext(); } @@ -1195,57 +1294,50 @@ public void updateMessage( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = - QueueRequest.updateMessage(queue.getIndividualMessageAddress(message.getId()), - this.getRequestOptions().getTimeoutIntervalInMs(), - message.getPopReceipt(), - visibilityTimeoutInSeconds, - opContext); - - if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { - final byte[] messageBytes = - QueueRequest.generateMessageRequestBody(message - .getMessageContentForTransfer(queue.shouldEncodeMessage)); - - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); - } else { - request.setFixedLengthStreamingMode(0); - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - return null; - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = QueueRequest.updateMessage(queue.getIndividualMessageAddress(message + .getId()), this.getRequestOptions().getTimeoutIntervalInMs(), message.getPopReceipt(), + visibilityTimeoutInSeconds, opContext); - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); + + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); + } + else { + request.setFixedLengthStreamingMode(0); + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } /** - * Uploads the queue's metadata. + * Uploads the metadata in the CloudQueue object to the queue, + * using the default request options. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void uploadMetadata() throws StorageException { @@ -1253,19 +1345,23 @@ public void uploadMetadata() throws StorageException { } /** - * Uploads the queue's metadata using the specified request options and operation context. + * Uploads the metadata in the CloudQueue object to the queue, + * using the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueueClient}). + * * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public void uploadMetadata(QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -1280,36 +1376,30 @@ public void uploadMetadata(QueueRequestOptions options, OperationContext opConte opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.setMetadata(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + final HttpURLConnection request = QueueRequest.setMetadata(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 3cdb0201923de..373448521245b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -1,3 +1,8 @@ +/* + * CloudQueueClient.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; @@ -27,15 +32,13 @@ import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; /** - * Provides a client for accessing the Windows Azure Queue service. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * Provides a service client for accessing the Windows Azure Queue service. */ public final class CloudQueueClient extends ServiceClient { /** - * Initializes a new instance of the CloudQueueClient class using the specified Queue service endpoint and account - * credentials. + * Initializes a new instance of the CloudQueueClient class + * using the specified Queue service endpoint and account credentials. * * @param baseUri * The Queue service endpoint to use to create the client @@ -52,16 +55,20 @@ public CloudQueueClient(final URI baseUri, final StorageCredentials credentials) } /** - * Returns a reference to a {@link CloudQueue} object that represents the cloud queue for the specified address. + * Gets a {@link CloudQueue} object that represents the storage service + * queue for the specified address. * * @param queueAddress - * A String that represents the name of the queue, or the absolute URI to the queue. - * @return A {@link CloudQueue} object that represents a reference to the cloud queue. + * A String that represents the name of the queue, + * or the absolute URI to the queue. + * + * @return A {@link CloudQueue} object that represents a reference to the + * queue. * * @throws URISyntaxException * If the resource URI is invalid. * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ public CloudQueue getQueueReference(final String queueAddress) throws URISyntaxException, StorageException { Utility.assertNotNullOrEmpty("queueAddress", queueAddress); @@ -69,9 +76,10 @@ public CloudQueue getQueueReference(final String queueAddress) throws URISyntaxE } /** - * Returns an enumerable collection of queues for this queue service client. + * Gets an iterable collection of queues for this queue service client. * - * @return An enumerable collection of {@link CloudQueue} objects that represent the queues for this client. + * @return An iterable collection of {@link CloudQueue} objects that + * represent the queues in this client. */ @DoesServiceRequest public Iterable listQueues() { @@ -79,14 +87,15 @@ public Iterable listQueues() { } /** - * Returns an enumerable collection of queues whose names begin with the specified prefix for this Queue service - * client. + * Returns an iterable collection of queues whose names begin with the + * specified prefix in this Queue service client. * * @param prefix * A String that represents the queue name prefix. * - * @return An enumerable collection of {@link CloudQueue} objects that represent the queues for this client whose - * names begin with the specified prefix. + * @return An iterable collection of {@link CloudQueue} objects that + * represent the queues in this client whose names begin with the + * specified prefix. */ @DoesServiceRequest public Iterable listQueues(final String prefix) { @@ -94,28 +103,32 @@ public Iterable listQueues(final String prefix) { } /** - * Returns an enumerable collection of queues whose names begin with the specified prefix for this Queue service - * client, using the specified details setting, request options, and operation context. + * Returns an iterable collection of queues whose names begin with the + * specified prefix for this Queue service client, using the specified + * details setting, request options, and operation context. * * @param prefix * A String that represents the queue name prefix. * @param detailsIncluded - * A {@link QueueListingDetails} value that indicates whether queue metadata will be returned. + * A {@link QueueListingDetails} value that indicates whether + * queue metadata will be returned. * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueue}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueue}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return An enumerable collection of {@link CloudQueue} objects that represents the queues for this client. + * @return An iterable collection of {@link CloudQueue} objects that + * represents the specified queues for this client. */ @DoesServiceRequest - public Iterable listQueues( - final String prefix, final QueueListingDetails detailsIncluded, QueueRequestOptions options, - OperationContext opContext) { + public Iterable listQueues(final String prefix, final QueueListingDetails detailsIncluded, + QueueRequestOptions options, OperationContext opContext) { if (opContext == null) { opContext = new OperationContext(); } @@ -127,75 +140,80 @@ public Iterable listQueues( opContext.initialize(); options.applyDefaults(this); - final SegmentedStorageOperation> impl = - new SegmentedStorageOperation>(options, null) { - @Override - public ResultSegment execute( - final CloudQueueClient client, final Void dontCare, final OperationContext opContext) - throws Exception { - - final ResultSegment result = - CloudQueueClient.this.listQueuesCore(prefix, - detailsIncluded, - -1, - this.getToken(), - this.getRequestOptions(), - this, - opContext); - - this.setToken(result.getContinuationToken()); - return result; - } - }; + final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( + options, null) { + @Override + public ResultSegment execute(final CloudQueueClient client, final Void dontCare, + final OperationContext opContext) throws Exception { + + final ResultSegment result = CloudQueueClient.this.listQueuesCore(prefix, detailsIncluded, + -1, this.getToken(), this.getRequestOptions(), this, opContext); + + this.setToken(result.getContinuationToken()); + return result; + } + }; return new LazySegmentedIterator(impl, this, null, options.getRetryPolicyFactory(), opContext); } /** - * Returns a result segment containing a collection of queues. + * Gets a result segment containing a collection of queues from the storage + * service with the specified parameters. * * @param prefix - * A String that represents the queue name prefix. + * A String containing the queue name prefix to + * filter the results with. * @param detailsIncluded - * A value that indicates whether to return queue metadata with the listing. + * A {@link QueueListingDetails} value that indicates whether + * queue metadata will be returned. * @param maxResults - * the maximum results to retrieve. + * The maximum number of queue results to retrieve. * @param continuationToken - * A continuation token returned by a previous listing operation. + * A {@link ResultContinuation} object that represents a + * continuation token returned by a previous listing operation. * @param options - * the request options to use for the operation + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueue}). * @param taskReference - * a reference to the encapsulating task + * A {@link StorageOperation} reference to the encapsulating + * task. * @param opContext - * a tracking object for the operation - * @return a result segment containing a collection of queues whose names begin with the specified prefix. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return A {@link ResultSegment} of {@link CloudQueue} objects that + * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested + * queues in + * the storage service. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws XMLStreamException * @throws InvalidKeyException * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - ResultSegment listQueuesCore( - final String prefix, final QueueListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, final RequestOptions options, + ResultSegment listQueuesCore(final String prefix, final QueueListingDetails detailsIncluded, + final int maxResults, final ResultContinuation continuationToken, final RequestOptions options, final StorageOperation> taskReference, - final OperationContext opContext) - throws IOException, URISyntaxException, XMLStreamException, InvalidKeyException, StorageException { + final OperationContext opContext) throws IOException, URISyntaxException, XMLStreamException, + InvalidKeyException, StorageException { Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); final ListingContext listingContext = new ListingContext(prefix, maxResults); listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - final HttpURLConnection listQueueRequest = - QueueRequest.list(this.getEndpoint(), - options.getTimeoutIntervalInMs(), - listingContext, - detailsIncluded, - opContext); + final HttpURLConnection listQueueRequest = QueueRequest.list(this.getEndpoint(), + options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); this.getCredentials().signRequest(listQueueRequest, -1L); @@ -217,20 +235,23 @@ ResultSegment listQueuesCore( newToken.setContinuationType(ResultContinuationType.QUEUE); } - final ResultSegment resSegment = - new ResultSegment(response.getQueues(this), maxResults, newToken); + final ResultSegment resSegment = new ResultSegment(response.getQueues(this), + maxResults, newToken); return resSegment; } /** - * Returns a result segment of an enumerable collection of queues for this Queue service client. + * Gets a result segment of an iterable collection of queues for this Queue + * service client. * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} - * objects that represent the queues in this collection. + * @return A {@link ResultSegment} of {@link CloudQueue} objects that + * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested + * queues in + * the storage service. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public ResultSegment listQueuesSegmented() throws StorageException { @@ -238,14 +259,16 @@ public ResultSegment listQueuesSegmented() throws StorageException { } /** - * Returns a result segment of an enumerable collection of queues whose names begin with the specified prefix for - * this Queue service client. + * Gets a result segment of an iterable collection of queues whose names + * begin with the specified prefix for this Queue service client. * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} - * objects that represent the queues in this collection. + * @return A {@link ResultSegment} of {@link CloudQueue} objects that + * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested + * queues in + * the storage service. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest public ResultSegment listQueuesSegmented(final String prefix) throws StorageException { @@ -253,36 +276,43 @@ public ResultSegment listQueuesSegmented(final String prefix) throws } /** - * Returns a result segment of an enumerable collection of queues whose names begin with the specified prefix for - * this queue, using the specified listing details options, request options, and operation context. + * Gets a result segment of an iterable collection of queues whose names + * begin with the specified prefix for this queue, using the specified + * listing details options, request options, and operation context. * * @param prefix - * A String that represents the prefix of the queue name. + * A String that represents the prefix of the queue + * name to match. * @param detailsIncluded - * A {@link QueueListingDetails} value that indicates whether queue metadata will be returned. + * A {@link QueueListingDetails} value that indicates whether + * queue metadata will be returned. * @param maxResults - * The maximum number of results to retrieve. + * The maximum number of queue results to retrieve. * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. + * A {@link ResultContinuation} object that represents a + * continuation token returned by a previous listing operation. * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueue}). + * A {@link QueueRequestOptions} object that specifies any + * additional options for the request. Specifying null will use the default request options + * from + * the associated service client ( {@link CloudQueue}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of {@link CloudQueue} - * objects that represent the containers in this container. + * @return A {@link ResultSegment} of {@link CloudQueue} objects that + * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested + * queues in + * the storage service. * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest - public ResultSegment listQueuesSegmented( - final String prefix, final QueueListingDetails detailsIncluded, final int maxResults, + public ResultSegment listQueuesSegmented(final String prefix, + final QueueListingDetails detailsIncluded, final int maxResults, final ResultContinuation continuationToken, QueueRequestOptions options, OperationContext opContext) throws StorageException { @@ -299,32 +329,29 @@ public ResultSegment listQueuesSegmented( Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); - final StorageOperation> impl = - new StorageOperation>(options) { - @Override - public ResultSegment execute( - final CloudQueueClient client, final Void dontCare, final OperationContext opContext) - throws Exception { - return CloudQueueClient.this.listQueuesCore(prefix, - detailsIncluded, - maxResults, - continuationToken, - this.getRequestOptions(), - this, - opContext); - } - }; + final StorageOperation> impl = new StorageOperation>( + options) { + @Override + public ResultSegment execute(final CloudQueueClient client, final Void dontCare, + final OperationContext opContext) throws Exception { + return CloudQueueClient.this.listQueuesCore(prefix, detailsIncluded, maxResults, continuationToken, + this.getRequestOptions(), this, opContext); + } + }; return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); } /** - * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * Uploads a new configuration of service properties to the storage service, + * using the default request options. This includes Metrics and Logging + * Configuration. * * @param properties - * The ServiceProperties to upload. + * The {@link ServiceProperties} to upload. + * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest @Override @@ -333,26 +360,30 @@ public void uploadServiceProperties(final ServiceProperties properties) throws S } /** - * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. + * Uploads a new configuration of service properties to the storage service, + * using the specified request options and operation context. This includes + * Metrics and Logging Configuration. * * @param properties - * The ServiceProperties to upload. + * The {@link ServiceProperties} to upload. * @param options - * A {@link RequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}{@link CloudQueueClient}). + * A {@link RequestOptions} object that specifies any additional + * options for the request. Specifying null will use + * the default request options from the associated service client + * ( {@link CloudBlobClient}{@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * * @throws StorageException - * If a storage service error occurred. + * If a storage service error occurred during the operation. */ @DoesServiceRequest @Override - public void uploadServiceProperties( - final ServiceProperties properties, final RequestOptions options, final OperationContext opContext) - throws StorageException { + public void uploadServiceProperties(final ServiceProperties properties, final RequestOptions options, + final OperationContext opContext) throws StorageException { if (!Utility.isNullOrEmpty(properties.getDefaultServiceVersion())) { throw new IllegalArgumentException( "DefaultServiceVersion can only be set for the Blob service and the request must be made using the 2011-08-18 version"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java index 35885dc787cd2..6944e036f3e54 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java @@ -1,3 +1,8 @@ +/* + * CloudQueueMessage.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.UnsupportedEncodingException; @@ -9,8 +14,6 @@ /** * Represents a message in the Windows Azure Queue service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public class CloudQueueMessage { @@ -55,38 +58,39 @@ public class CloudQueueMessage { protected QueueMessageType messageType; /** - * Initializes a new instance of the CloudQueueMessage class(used internaly). + * Initializes a new instance of the CloudQueueMessage class (used + * internally). */ CloudQueueMessage() { // no op } /** - * Initializes a new instance of the CloudQueueMessage class. + * Initializes a new instance of the CloudQueueMessage class with an array + * of byte containing the message. * * @param content - * The content of the message. + * The array of byte that contains the message. */ public CloudQueueMessage(final byte[] content) { - this.messageContent = Base64.encode(content); - this.messageType = QueueMessageType.BASE_64_ENCODED; + this.setMessageContent(content); } /** - * Initializes a new instance of the CloudQueueMessage class. + * Initializes a new instance of the CloudQueueMessage class with a string + * containing the message. * * @param content - * The content of the message. + * The String that contains the message. */ public CloudQueueMessage(final String content) { - this.messageContent = content; - this.messageType = QueueMessageType.RAW_STRING; + this.setMessageContent(content); } /** * Gets the dequeue count. * - * @return the dequeue count. + * @return The dequeue count. */ public final int getDequeueCount() { return this.dequeueCount; @@ -95,7 +99,7 @@ public final int getDequeueCount() { /** * Gets the time that the message expires. * - * @return the time that the message expires. + * @return The time that the message expires. */ public final Date getExpirationTime() { return this.expirationTime; @@ -104,7 +108,7 @@ public final Date getExpirationTime() { /** * Gets the message ID. * - * @return the message ID. + * @return A String that contains the message ID. */ public final String getId() { return this.id; @@ -113,79 +117,94 @@ public final String getId() { /** * Gets the time that the message was added to the queue. * - * @return the time that the message was added to the queue. + * @return The time that the message was added to the queue. */ public final Date getInsertionTime() { return this.insertionTime; } /** - * Gets the content of the message, as a byte array. + * Gets the content of the message as a byte array. * - * @return the content of the message. + * @return An array of byte with the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final byte[] getMessageContentAsByte() throws StorageException { if (Utility.isNullOrEmpty(this.messageContent)) { - return null; + return new byte[0]; } if (this.messageType == QueueMessageType.RAW_STRING) { try { return this.messageContent.getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } - } else { + } + else { return Base64.decode(this.messageContent); } } /** - * Gets the content of the message, as a string. + * Gets the content of the message as a string. * - * @return the content of the message. + * @return A String with the content of the message. * * @throws StorageException * If a storage service error occurred. */ public final String getMessageContentAsString() throws StorageException { - if (Utility.isNullOrEmpty(this.messageContent)) { - return null; - } - if (this.messageType == QueueMessageType.RAW_STRING) { return this.messageContent; - } else { + } + else { + if (Utility.isNullOrEmpty(this.messageContent)) { + return null; + } + try { return new String(Base64.decode(this.messageContent), "UTF-8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } } /** - * Gets the content of the message for transfer(internal use only). + * Gets the content of the message for transfer (internal use only). + * + * @return A String with the content of the message. * * @throws StorageException */ protected final String getMessageContentForTransfer(final boolean shouldEncodeMessage) throws StorageException { - if (this.messageType == QueueMessageType.RAW_STRING) { - if (shouldEncodeMessage) { - return Base64.encode(this.getMessageContentAsByte()); - } + String result = null; + if (this.messageType == QueueMessageType.RAW_STRING && shouldEncodeMessage) { + result = Base64.encode(this.getMessageContentAsByte()); + + } + else { + result = this.messageContent; + } + + if (result != null && result.length() > QueueConstants.MAX_MESSAGE_SIZE) { + throw new IllegalArgumentException(String.format("The message size can't be larger than %s bytes. ", + QueueConstants.MAX_MESSAGE_SIZE)); } - return this.messageContent; + return result; } /** * Gets the time that the message will next be visible. * - * @return the time that the message will next be visible. + * @return A java.util.Date with the time that the message will + * next be visible. */ public final Date getNextVisibleTime() { return this.nextVisibleTime; @@ -194,33 +213,38 @@ public final Date getNextVisibleTime() { /** * Gets the message's pop receipt. * - * @return the message's pop receipt. + * @return A String containing the message's pop receipt. */ public final String getPopReceipt() { return this.popReceipt; } /** + * Sets the expiration time for the message. + * * @param expirationTime - * the expirationTime to set + * The java.util.Date representing the expiration + * time to set on the message. */ public final void setExpirationTime(final Date expirationTime) { this.expirationTime = expirationTime; } /** - * Sets the content of the message. + * Sets the content of the message as an array of byte. * * @param content * The content of the message. */ public final void setMessageContent(final byte[] content) { + Utility.assertNotNull("content", content); + this.messageContent = Base64.encode(content); this.messageType = QueueMessageType.BASE_64_ENCODED; } /** - * Sets the content of the message. + * Sets the content of the message as a String. * * @param content * The content of the message. @@ -231,8 +255,11 @@ public final void setMessageContent(final String content) { } /** + * Sets the time for the message to become visible in the queue. + * * @param nextVisibleTime - * the nextVisibleTime to set + * The java.util.Date representing the time to set + * for the message to be visible. */ public final void setNextVisibleTime(final Date nextVisibleTime) { this.nextVisibleTime = nextVisibleTime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java index 9fa73aa07cf98..37a6df34fe49e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java @@ -1,3 +1,8 @@ +/* + * ListQueuesResponse.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; @@ -14,78 +19,133 @@ import com.microsoft.windowsazure.services.core.storage.utils.Utility; /** - * RESERVED FOR INTERNAL USE. A class for parsing a list queues response stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * RESERVED FOR INTERNAL USE. Provides methods for parsing the response stream + * from a queue listing operation. */ final class ListQueuesResponse { /** - * Holds the list of queues. + * The list of queues from the response to a list queues operation. */ private ArrayList queues = new ArrayList(); /** - * Stores the value indicating if the response has been fully parsed. + * A value indicating if the response has been fully parsed. */ private boolean isParsed; /** - * Stores the marker. + * The marker value from the response. */ private String marker; /** - * Stores the max results. + * The max results value from the response. */ private int maxResults; /** - * Stores the next marker. + * The next marker value from the response, to be passed as the marker value + * in the next queue listing request. */ private String nextMarker; /** - * Stores the container prefix. + * The container prefix value from the response. */ private String prefix; /** - * Stores the InputStream to read from. + * The InputStream containing the response body from a queue + * listing operation. */ private final InputStream streamRef; + /** + * Class constructor specifying an input stream created from the response + * body to a list queues operation. + * + * @param stream + * An InputStream to parse for the results of a list + * queues operation. + */ public ListQueuesResponse(final InputStream stream) { this.streamRef = stream; } + /** + * Gets the value of the Marker element in the response to a list queues + * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or + * {@link #parseResponse(CloudQueueClient)} has been called, and is only + * present if the list queues request specified the marker. + * + * @return A String containing the value of the Marker element + * in the response. + */ public String getMarker() { return this.marker; } + /** + * Gets the value of the MaxResults element in the response to a list queues + * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or + * {@link #parseResponse(CloudQueueClient)} has been called, and is only + * present if the request specified a maxresults value. + * + * @return An int containing the value of the MaxResults + * element in the response. + */ public int getMaxResults() { return this.maxResults; } + /** + * Gets the value of the NextMarker element in the response to a list queues + * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or + * {@link #parseResponse(CloudQueueClient)} has been called, and is only + * present when maxresults was specified in the request, and more results + * are available that have not yet been returned. This value may be sent as + * the marker value in a list queues request to retrieve the next set of + * queues. + * + * @return A String containing the value of the NextMarker + * element in the response. + */ public String getNextMarker() { return this.nextMarker; } + /** + * Gets the value of the Prefix element in the response to a list queues + * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or + * {@link #parseResponse(CloudQueueClient)} has been called, and is only + * present if the request specified a prefix value. The list queues result + * is filtered to return only queues with names that begin with the + * specified prefix. + * + * @return A String containing the value of the Prefix element + * in the response. + */ public String getPrefix() { return this.prefix; } /** - * Returns an ArrayList of CloudQueue + * Gets the list of queues returned by the list queues request as an ArrayList of (@link CloudQueue} + * objects. * * @param serviceClient - * a reference to the client object associated with this object. - * @return an ArrayList of CloudQueue + * A {@link CloudQueueClient} object associated with the storage + * service. + * + * @return an ArrayList of {@link CloudQueue} objects returned + * by the list queues operation. + * * @throws XMLStreamException * @throws StorageException */ - public ArrayList getQueues(final CloudQueueClient serviceClient) - throws XMLStreamException, StorageException { + public ArrayList getQueues(final CloudQueueClient serviceClient) throws XMLStreamException, + StorageException { if (!this.isParsed) { this.parseResponse(serviceClient); } @@ -94,11 +154,16 @@ public ArrayList getQueues(final CloudQueueClient serviceClient) } /** - * Parses the XML stream. + * Parses the input stream containing the response body of the list queues + * request result and populates the class data. * * @param serviceClient - * a reference to the client object associated with this object. + * A {@link CloudQueueClient} object associated with the storage + * service. + * * @throws XMLStreamException + * If the input stream cannot be read or parsed as a list queues + * response. * @throws StorageException */ public void parseResponse(final CloudQueueClient serviceClient) throws XMLStreamException, StorageException { @@ -122,24 +187,31 @@ public void parseResponse(final CloudQueueClient serviceClient) throws XMLStream if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); this.maxResults = Integer.parseInt(tempParseString); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(QueueConstants.QUEUES_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(QueueConstants.QUEUES_ELEMENT)) { try { this.queues = QueueDeserializationHelper.readQueues(xmlr, serviceClient); - } catch (final URISyntaxException e) { + } + catch (final URISyntaxException e) { throw new XMLStreamException(e); - } catch (final ParseException e) { + } + catch (final ParseException e) { throw new XMLStreamException(e); } xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); // eventType = xmlr.next(); - } else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { break; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java index 3dd45b80c1e15..473379aa9cfdd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java @@ -1,19 +1,21 @@ +/* + * MessageUpdateFields.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; /** - * - * Represents a set of flags for updating messages. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * Flags for the values to set when updating messages. */ public enum MessageUpdateFields { /** - * Update the message visibility timeout. + * Set to update the message visibility timeout. */ VISIBILITY(1), /** - * Update the message content. + * Set to update the message content. */ CONTENT(2); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index 1a66760f9055c..c578953fbd0e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -1,3 +1,8 @@ +/* + * QueueConstants.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; /** @@ -9,6 +14,21 @@ final class QueueConstants { */ public static final int DEFAULT_QUEUE_CLIENT_TIMEOUT_IN_MS = 30 * 1000; + /** + * The maximum message size in bytes. + */ + public static final long MAX_MESSAGE_SIZE = 64 * com.microsoft.windowsazure.services.core.storage.Constants.KB; + + /** + * The maximum number of messages that can be peeked or retrieved at a time. + */ + public static final int MAX_NUMBER_OF_MESSAGES_TO_PEEK = 32; + + /** + * The maximum amount of time a message is kept inside the queue, in seconds. + */ + public static final int MAX_TIME_TO_LIVE_IN_SECONDS = 7 * 24 * 60 * 60; + /** * XML element for a queue. */ @@ -72,9 +92,8 @@ final class QueueConstants { /** * The header that specifies the approximate message count of a queue. */ - public static final String APPROXIMATE_MESSAGES_COUNT = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "approximate-messages-count"; + public static final String APPROXIMATE_MESSAGES_COUNT = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "approximate-messages-count"; /** * Private Default Ctor. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java index 0292aaad2fdb6..71c823a289100 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java @@ -1,3 +1,8 @@ +/* + * QueueDeserializationHelper.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; @@ -17,14 +22,20 @@ import com.microsoft.windowsazure.services.core.storage.utils.implementation.DeserializationHelper; /** - * RESERVED FOR INTERNAL USE. Class to provide object deserialization for queues. + * RESERVED FOR INTERNAL USE. Class to provide object deserialization for + * queues. */ final class QueueDeserializationHelper { /** * Populates the message from an XMLStreamReader. * * @param xmlr - * the XMLStreamReader to read from + * The XMLStreamReader to read from. + * @param shouldEncodeMessage + * A flag indicating whether messages should be base-64 encoded. + * + * @return A {@link CloudQueueMessage} from the stream. + * * @throws XMLStreamException * if there is an error parsing the stream * @throws ParseException @@ -32,6 +43,7 @@ final class QueueDeserializationHelper { * @throws URISyntaxException * if the uri is invalid * @throws StorageException + * If a storage service error occurred during the operation. */ protected static CloudQueueMessage readMessage(final XMLStreamReader xmlr, final boolean shouldEncodeMessage) throws XMLStreamException, ParseException, URISyntaxException, StorageException { @@ -49,30 +61,33 @@ protected static CloudQueueMessage readMessage(final XMLStreamReader xmlr, final if (eventType == XMLStreamConstants.START_ELEMENT) { if (name.equals(QueueConstants.MESSAGE_ID_ELEMENT)) { message.id = Utility.readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_ID_ELEMENT); - } else if (name.equals(QueueConstants.INSERTION_TIME_ELEMENT)) { - message.insertionTime = - Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, - QueueConstants.INSERTION_TIME_ELEMENT)); - } else if (name.equals(QueueConstants.EXPIRATION_TIME_ELEMENT)) { - message.expirationTime = - Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, - QueueConstants.EXPIRATION_TIME_ELEMENT)); - } else if (name.equals(QueueConstants.POP_RECEIPT_ELEMENT)) { + } + else if (name.equals(QueueConstants.INSERTION_TIME_ELEMENT)) { + message.insertionTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( + xmlr, QueueConstants.INSERTION_TIME_ELEMENT)); + } + else if (name.equals(QueueConstants.EXPIRATION_TIME_ELEMENT)) { + message.expirationTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( + xmlr, QueueConstants.EXPIRATION_TIME_ELEMENT)); + } + else if (name.equals(QueueConstants.POP_RECEIPT_ELEMENT)) { message.popReceipt = Utility.readElementFromXMLReader(xmlr, QueueConstants.POP_RECEIPT_ELEMENT); - } else if (name.equals(QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)) { - message.nextVisibleTime = - Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader(xmlr, - QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)); - } else if (name.equals(QueueConstants.DEQUEUE_COUNT_ELEMENT)) { - message.dequeueCount = - Integer.parseInt(Utility.readElementFromXMLReader(xmlr, - QueueConstants.DEQUEUE_COUNT_ELEMENT)); - } else if (name.equals(QueueConstants.MESSAGE_TEXT_ELEMENT)) { - message.messageContent = - Utility.readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_TEXT_ELEMENT); + } + else if (name.equals(QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)) { + message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( + xmlr, QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)); + } + else if (name.equals(QueueConstants.DEQUEUE_COUNT_ELEMENT)) { + message.dequeueCount = Integer.parseInt(Utility.readElementFromXMLReader(xmlr, + QueueConstants.DEQUEUE_COUNT_ELEMENT)); + } + else if (name.equals(QueueConstants.MESSAGE_TEXT_ELEMENT)) { + message.messageContent = Utility + .readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_TEXT_ELEMENT); } - } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_MESSAGE_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_MESSAGE_ELEMENT)) { break; } } @@ -82,24 +97,28 @@ protected static CloudQueueMessage readMessage(final XMLStreamReader xmlr, final } /** - * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of - * ContainersElement. + * Populates CloudQueueMessage objects from the XMLStreamReader; the reader + * must be at the Start element of QueuesElement. + * + * @param stream + * The InputStream object to deserialize from. + * @param shouldEncodeMessage + * A flag indicating whether messages should be base-64 encoded. + * + * @return An ArrayList of {@link CloudQueueMessage} from the + * stream. * - * @param xmlr - * the XMLStreamReader object - * @param serviceClient - * the CloudBlobClient associated with the objects. - * @return an ArrayList of CloudBlobContainer from the stream. * @throws XMLStreamException - * if there is a parsing exception + * If there is a parsing exception. * @throws ParseException - * if a date value is not correctly encoded + * If a date value is not correctly encoded. * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException + * If a storage service error occurred during the operation. */ - public static - ArrayList readMessages(final InputStream stream, final boolean shouldEncodeMessage) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { + public static ArrayList readMessages(final InputStream stream, final boolean shouldEncodeMessage) + throws XMLStreamException, ParseException, URISyntaxException, StorageException { final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(stream); // Start document @@ -128,14 +147,20 @@ ArrayList readMessages(final InputStream stream, final boolea * Populates the queue from an XMLStreamReader * * @param xmlr - * the XMLStreamReader to read from + * The XMLStreamReader to read from. + * @param serviceClient + * The {@link CloudQueueClient} to create the return value with. + * + * @return A {@link CloudQueue} populated with the deserialized data. + * * @throws XMLStreamException - * if there is an error parsing the stream + * If there is a parsing exception. * @throws ParseException - * if there is an error in parsing a date + * If a date value is not correctly encoded. * @throws URISyntaxException - * if the uri is invalid + * If the URI is not valid. * @throws StorageException + * If a storage service error occurred during the operation. */ protected static CloudQueue readQueue(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) throws XMLStreamException, ParseException, URISyntaxException, StorageException { @@ -154,14 +179,17 @@ protected static CloudQueue readQueue(final XMLStreamReader xmlr, final CloudQue if (eventType == XMLStreamConstants.START_ELEMENT) { if (name.equals(Constants.URL_ELEMENT)) { queueUri = new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT)); - } else if (name.equals(Constants.NAME_ELEMENT)) { + } + else if (name.equals(Constants.NAME_ELEMENT)) { queueName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } else if (name.equals(Constants.METADATA_ELEMENT)) { + } + else if (name.equals(Constants.METADATA_ELEMENT)) { // parse metadata queueMetadata = DeserializationHelper.parseMetadateFromXML(xmlr); xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); } - } else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_ELEMENT)) { + } + else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_ELEMENT)) { break; } } @@ -175,20 +203,25 @@ protected static CloudQueue readQueue(final XMLStreamReader xmlr, final CloudQue } /** - * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of - * ContainersElement. + * Populates CloudQueue objects from the XMLStreamReader; the reader must be + * at the Start element of QueuesElement. * * @param xmlr - * the XMLStreamReader object + * The XMLStreamReader to read from. * @param serviceClient - * the CloudBlobClient associated with the objects. - * @return an ArrayList of CloudBlobContainer from the stream. + * The {@link CloudQueueClient} to create the return value with. + * + * @return An ArrayList of{@link CloudQueue} populated with the + * deserialized data. + * * @throws XMLStreamException - * if there is a parsing exception + * If there is a parsing exception. * @throws ParseException - * if a date value is not correctly encoded + * If a date value is not correctly encoded. * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException + * If a storage service error occurred during the operation. */ public static ArrayList readQueues(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) throws XMLStreamException, ParseException, URISyntaxException, StorageException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java index 8349e47c07eb0..de3ad05a0f816 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java @@ -1,9 +1,13 @@ +/* + * QueueListingDetails.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; /** - * Specifies which details to include when listing the queues in this storage account. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * Specifies which details to include when listing the queues in this storage + * account. */ public enum QueueListingDetails { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java index 75d5bae540de5..b7ec1c964876a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java @@ -1,9 +1,12 @@ +/* + * QueueMessageType.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; /** - * Reserved for internal use. Specifies queue message type. Used internally. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * Reserved for internal use. Specifies queue message type. */ public enum QueueMessageType { /** @@ -12,7 +15,8 @@ public enum QueueMessageType { RAW_STRING, /** - * Indicates the message object stores the Base64-Encoded representation of the raw data. + * Indicates the message object stores the Base64-Encoded representation of + * the raw data. */ BASE_64_ENCODED } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index 1fd1c34efd8a0..12c83d58385d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -1,3 +1,8 @@ +/* + * QueueRequest.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; @@ -21,36 +26,57 @@ import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; /** - * RESERVED FOR INTERNAL USE. A class used to generate requests for queue objects. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing web + * requests for queue operations. */ final class QueueRequest { /** - * Adds user-defined metadata to the request as one or more name-value pairs. + * Adds user-defined metadata to the web request as one or more name-value + * pairs. * * @param request - * The web request. + * The HttpURLConnection web request to add the + * metadata to. * @param metadata - * The user-defined metadata. - * */ - public static void addMetadata( - final HttpURLConnection request, final HashMap metadata, final OperationContext opContext) { + * A HashMap containing the user-defined metadata to + * add. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + */ + public static void addMetadata(final HttpURLConnection request, final HashMap metadata, + final OperationContext opContext) { BaseRequest.addMetadata(request, metadata, opContext); } /** - * Constructs a request to clear messages. + * Constructs a web request to clear all the messages in the queue. Sign the + * web request with a length of -1L. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ public static HttpURLConnection clearMessages(final URI uri, final int timeout, final OperationContext opContext) throws URISyntaxException, IOException, StorageException { @@ -63,15 +89,31 @@ public static HttpURLConnection clearMessages(final URI uri, final int timeout, } /** - * Constructs a web request to create a new queue. Sign with 0 length. + * Constructs a web request to create a new queue. Sign the web request with + * a length of 0. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * + * @throws IOException + * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ public static HttpURLConnection create(final URI uri, final int timeout, final OperationContext opContext) throws IOException, URISyntaxException, StorageException { @@ -79,15 +121,31 @@ public static HttpURLConnection create(final URI uri, final int timeout, final O } /** - * Constructs a web request to delete the queue. Sign with no length specified. + * Constructs a web request to delete the queue. Sign the web request with a + * length of -1L. * * @param uri - * The absolute URI to the container. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * + * @throws IOException + * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ public static HttpURLConnection delete(final URI uri, final int timeout, final OperationContext opContext) throws IOException, URISyntaxException, StorageException { @@ -95,21 +153,38 @@ public static HttpURLConnection delete(final URI uri, final int timeout, final O } /** - * Constructs a request to delete a message. + * Constructs a web request to delete a message from the queue. Sign the web + * request with a length of -1L. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws IOException + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param popReceipt + * A String that contains the pop receipt value + * returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to + * delete. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws URISyntaxException + * If the URI is not valid. + * @throws IOException * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection deleteMessage( - final URI uri, final int timeout, final String popReceipt, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection deleteMessage(final URI uri, final int timeout, final String popReceipt, + final OperationContext opContext) throws URISyntaxException, IOException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("popreceipt", popReceipt); @@ -122,41 +197,53 @@ public static HttpURLConnection deleteMessage( } /** - * Constructs a web request to download user-defined metadata and ApproximateMessageCount for the queue. + * Constructs a web request to download user-defined metadata and the + * approximate message count for the queue. Sign the web request with a + * length of -1L. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * */ - public static HttpURLConnection downloadAttributes( - final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - return BaseRequest.getMetadata(uri, timeout, null, opContext); - } - - /** - * Constructs a web request to delete the queue. Sign with no length specified. + * @return An HttpURLConnection configured for the specified + * operation. * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * @throws IOException + * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection exist(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - return BaseRequest.delete(uri, timeout, null, opContext); + public static HttpURLConnection downloadAttributes(final URI uri, final int timeout, + final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + return BaseRequest.getMetadata(uri, timeout, null, opContext); } /** - * Parse message request body. + * Generates the message request body from a string containing the message. + * The message must be encodable as UTF-8. To be included in a web request, + * this message request body must be written to the output stream of the web + * request. + * + * @param message + * A String containing the message to wrap in a message request body. * + * @return An array of byte containing the message request body + * encoded as UTF-8. + * + * @throws XMLStreamException + * @throws StorageException + * If the message cannot be encoded as UTF-8. */ public static byte[] generateMessageRequestBody(final String message) throws XMLStreamException, StorageException { final StringWriter outWriter = new StringWriter(); @@ -178,34 +265,48 @@ public static byte[] generateMessageRequestBody(final String message) throws XML xmlw.writeEndDocument(); try { return outWriter.toString().getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { + } + catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } /** - * Constructs a request to return a listing of all queues in this storage account. Sign with no length specified. + * Constructs a web request to return a listing of all queues in this + * storage account. Sign the web request with a length of -1L. * * @param uri - * The absolute URI for the account. + * A URI object that specifies the absolute URI to + * the storage account. * @param timeout - * The absolute URI for the account. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. * @param listingContext - * A set of parameters for the listing operation. + * A {@link ListingContext} object that specifies parameters for + * the listing operation, if any. May be null. * @param detailsIncluded - * Additional details to return with the listing. + * A {@link QueueListingDetails} object that specifies additional + * details to return with the listing, if any. May be null. * @param opContext - * a tracking object for the request - * @return a HttpURLConnection configured for the operation. + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection list( - final URI uri, final int timeout, final ListingContext listingContext, - final QueueListingDetails detailsIncluded, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection list(final URI uri, final int timeout, final ListingContext listingContext, + final QueueListingDetails detailsIncluded, final OperationContext opContext) throws URISyntaxException, + IOException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("comp", "list"); @@ -236,21 +337,38 @@ public static HttpURLConnection list( } /** - * Constructs a request to peek messages. + * Constructs a web request to retrieve a specified number of messages from + * the front of the queue without changing their visibility. Sign the web + * request with a length of -1L. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param numberOfMessages + * A nonzero value that specifies the number of messages to + * retrieve from the queue, up to a maximum of 32. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection peekMessages( - final URI uri, final int timeout, final int numberOfMessages, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection peekMessages(final URI uri, final int timeout, final int numberOfMessages, + final OperationContext opContext) throws URISyntaxException, IOException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); builder.add("peekonly", "true"); @@ -267,19 +385,49 @@ public static HttpURLConnection peekMessages( } /** - * Constructs a web request to create a new message. Sign with 0 length. + * Constructs a web request to add a message to the back of the queue. Write + * the encoded message request body generated with a call to {@link #generateMessageRequestBody(String)} to the + * output stream of the + * request. Sign the web request with the length of the encoded message + * request body. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param visibilityTimeoutInSeconds + * Specifies the length of time for the message to be invisible + * in seconds, starting when it is added to the queue. A value of + * 0 will make the message visible immediately. The value must be + * greater than or equal to 0, and cannot be larger than 7 days. + * The visibility timeout of a message cannot be set to a value + * greater than the time-to-live time. + * @param timeToLiveInSeconds + * Specifies the time-to-live interval for the message, in + * seconds. The maximum time-to-live allowed is 7 days. If this + * parameter is 0, the default time-to-live of 7 days is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * + * @throws IOException + * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection putMessage( - final URI uri, final int timeout, final int visibilityTimeoutInSeconds, final int timeToLiveInSeconds, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { + public static HttpURLConnection putMessage(final URI uri, final int timeout, final int visibilityTimeoutInSeconds, + final int timeToLiveInSeconds, final OperationContext opContext) throws IOException, URISyntaxException, + StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); @@ -300,21 +448,46 @@ public static HttpURLConnection putMessage( } /** - * Constructs a request to retrieve messages. + * Constructs a web request to retrieve messages from the front of the + * queue. Sign the web request with a length of -1L. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param numberOfMessages + * A nonzero value that specifies the number of messages to + * retrieve from the queue, up to a maximum of 32. + * @param visibilityTimeoutInSeconds + * Specifies the visibility timeout value in seconds, relative to + * server time, to make the retrieved messages invisible until + * the visibility timeout expires. The value must be larger than + * or equal to 0, and cannot be larger than 7 days. The + * visibility timeout of a message can be set to a value later + * than the expiry time, which will prevent the message from + * being retrieved again whether it is processed or not. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection retrieveMessages( - final URI uri, final int timeout, final int numberOfMessages, final int visibilityTimeoutInSeconds, - final OperationContext opContext) throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection retrieveMessages(final URI uri, final int timeout, final int numberOfMessages, + final int visibilityTimeoutInSeconds, final OperationContext opContext) throws URISyntaxException, + IOException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); @@ -334,37 +507,86 @@ public static HttpURLConnection retrieveMessages( } /** - * Constructs a web request to set user-defined metadata for the queue, Sign with 0 Length. + * Constructs a web request to set user-defined metadata for the queue. Each + * call to this operation replaces all existing metadata attached to the + * queue. Use the {@link #addMetadata} method to specify the metadata to set + * on the queue. To remove all metadata from the queue, call this web + * request with no metadata added. Sign the web request with a length of 0. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. * - * @return a HttpURLConnection configured for the operation. + * @return An HttpURLConnection configured for the specified + * operation. + * + * @throws IOException + * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * */ + * If a storage service error occurred during the operation. + */ public static HttpURLConnection setMetadata(final URI uri, final int timeout, final OperationContext opContext) throws IOException, URISyntaxException, StorageException { return BaseRequest.setMetadata(uri, timeout, null, opContext); } /** - * Constructs a request to update message. + * Constructs a web request to update the visibility timeout of a message in + * the queue. Optionally updates the message content if a message request + * body is written to the output stream of the web request. The web request + * should be signed with the length of the encoded message request body if + * one is included, or a length of 0 if no message request body is included. * * @param uri - * The absolute URI to the queue. + * A URI object that specifies the absolute URI to + * the queue. * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. + * The server response timeout interval in milliseconds. If the + * operation does not complete within the specified timeout + * interval, a timeout error is returned by the server. If the + * timeout value is 0, the maximum timeout of 30 seconds is used. + * @param popReceipt + * A String that contains the pop receipt value + * returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to + * update. + * @param visibilityTimeoutInSeconds + * Specifies the new visibility timeout value in seconds, + * relative to server time, to make the retrieved messages + * invisible until the visibility timeout expires. The value must + * be larger than or equal to 0, and cannot be larger than 7 + * days. The visibility timeout of a message can be set to a + * value later than the expiry time, which will prevent the + * message from being retrieved again whether it is processed or + * not. + * @param opContext + * An {@link OperationContext} object that represents the context + * for the current operation. This object is used to track + * requests to the storage service, and to provide additional + * runtime information about the operation. + * + * @return An HttpURLConnection configured for the specified + * operation. + * * @throws IOException * @throws URISyntaxException + * If the URI is not valid. * @throws StorageException - * @throws IllegalArgumentException + * If a storage service error occurred during the operation. */ - public static HttpURLConnection updateMessage( - final URI uri, final int timeout, final String popReceipt, final int visibilityTimeoutInSeconds, - final OperationContext opContext) throws URISyntaxException, IOException, StorageException { + public static HttpURLConnection updateMessage(final URI uri, final int timeout, final String popReceipt, + final int visibilityTimeoutInSeconds, final OperationContext opContext) throws URISyntaxException, + IOException, StorageException { final UriQueryBuilder builder = new UriQueryBuilder(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java index 9d9611b5b4f60..012dee7f7522c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java @@ -1,14 +1,14 @@ -/** +/* + * QueueRequestOptions.java * + * Copyright (c) 2011 Microsoft. All rights reserved. */ package com.microsoft.windowsazure.services.queue.client; import com.microsoft.windowsazure.services.core.storage.RequestOptions; /** - * Represents a set of options that may be specified on a request. - * - * Copyright (c)2011 Microsoft. All rights reserved. + * Represents a set of options that may be specified on a queue request. */ public final class QueueRequestOptions extends RequestOptions { /** @@ -19,17 +19,24 @@ public QueueRequestOptions() { } /** - * Initializes a new instance of the QueueRequestOptions class. + * Initializes a new instance of the QueueRequestOptions class as a copy of + * another QueueRequestOptions instance. + * + * @param other + * The {@link QueueRequestOptions} object to copy the values + * from. */ public QueueRequestOptions(final QueueRequestOptions other) { super(other); } /** - * Populates the default timeout and retry policy from client if they are null. + * Populates the default timeout and retry policy from client if they are + * not set. * * @param client - * the service client to populate from + * The {@link CloudQueueClient} service client to populate the + * default values from. */ protected void applyDefaults(final CloudQueueClient client) { super.applyBaseDefaults(client); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java index d9630b48af929..17fb18eb66d71 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java @@ -1,3 +1,8 @@ +/* + * QueueResponse.java + * + * Copyright (c) 2011 Microsoft. All rights reserved. + */ package com.microsoft.windowsazure.services.queue.client; import java.net.HttpURLConnection; @@ -5,18 +10,16 @@ import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; /** - * RESERVED FOR INTERNAL USE. A class for parsing various responses from the queue service - * - * Copyright (c)2011 Microsoft. All rights reserved. + * RESERVED FOR INTERNAL USE. A class for parsing various responses from the queue service. */ final class QueueResponse extends BaseResponse { /** - * Gets the approximate messages count from the request header. + * Gets the approximate messages count from the headers of a server response to a get metadata request. * * @param request - * The response from server. - * @return the lease id from the request header. + * The HttpURLConnection containing a web request with a response from the server. + * @return The long value of the approximate messages count header field. */ public static long getApproximateMessageCount(final HttpURLConnection request) { return Long.parseLong(request.getHeaderField("x-ms-approximate-messages-count")); From bbcc073e2ee62562806dc61bf0b148df0428321b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 11:54:56 -0800 Subject: [PATCH 252/664] Changing maven config to target version 1.6 --- microsoft-azure-api/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 29cefdc5b0b4a..39842eb617425 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -76,6 +76,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + + org.jvnet.jaxb2.maven2 maven-jaxb2-plugin From 851fa093c037fdf0bc6e4b7221473e07deb952b0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 11:58:29 -0800 Subject: [PATCH 253/664] Rename ".common" to ".services.core" --- .../windowsazure/services/blob/BlobContract.java | 4 ++-- .../windowsazure/services/blob/BlobService.java | 6 +++--- .../microsoft/windowsazure/services/blob/Exports.java | 2 +- .../blob/implementation/BlobExceptionProcessor.java | 4 ++-- .../services/blob/implementation/BlobRestProxy.java | 4 ++-- .../{common => services/core}/Builder.java | 2 +- .../{common => services/core}/Configuration.java | 2 +- .../core}/ConfigurationException.java | 2 +- .../{common => services/core}/DefaultBuilder.java | 2 +- .../core}/ExponentialRetryPolicy.java | 4 ++-- .../{common => services/core}/FilterableService.java | 2 +- .../{common => services/core}/RetryPolicy.java | 4 ++-- .../{common => services/core}/RetryPolicyFilter.java | 2 +- .../{common => services/core}/ServiceException.java | 2 +- .../{common => services/core}/ServiceFilter.java | 2 +- .../microsoft/windowsazure/services/queue/Exports.java | 2 +- .../windowsazure/services/queue/QueueContract.java | 4 ++-- .../windowsazure/services/queue/QueueService.java | 6 +++--- .../queue/implementation/QueueExceptionProcessor.java | 4 ++-- .../services/queue/implementation/QueueRestProxy.java | 4 ++-- .../windowsazure/services/serviceBus/Exports.java | 2 +- .../services/serviceBus/ServiceBusConfiguration.java | 2 +- .../services/serviceBus/ServiceBusContract.java | 4 ++-- .../services/serviceBus/ServiceBusService.java | 2 +- .../windowsazure/services/serviceBus/Util.java | 2 +- .../services/serviceBus/implementation/Exports.java | 2 +- .../implementation/ServiceBusExceptionProcessor.java | 4 ++-- .../serviceBus/implementation/ServiceBusRestProxy.java | 4 ++-- .../serviceBus/implementation/WrapContract.java | 2 +- .../services/serviceBus/implementation/WrapFilter.java | 2 +- .../serviceBus/implementation/WrapRestProxy.java | 2 +- .../serviceBus/implementation/WrapTokenManager.java | 2 +- .../java/com/microsoft/windowsazure/utils/Exports.java | 2 +- .../windowsazure/utils/ServiceExceptionFactory.java | 2 +- .../windowsazure/utils/jersey/ClientFilterAdapter.java | 6 +++--- .../microsoft/windowsazure/utils/jersey/Exports.java | 4 ++-- .../builder/AlterClassWithProperties.java | 2 +- .../configuration/builder/DefaultBuilderTest.java | 2 +- .../services/blob/BlobServiceIntegrationTest.java | 10 +++++----- .../services/blob/IntegrationTestBase.java | 2 +- .../services/queue/IntegrationTestBase.java | 2 +- .../services/queue/QueueServiceIntegrationTest.java | 2 +- .../serviceBus/ServiceBusConfigurationTest.java | 2 +- .../services/serviceBus/ServiceBusCreationTest.java | 2 +- .../services/serviceBus/ServiceBusIntegrationTest.java | 8 ++++---- .../implementation/WrapRestProxyIntegrationTest.java | 2 +- .../WrapTokenManagerIntegrationTest.java | 2 +- .../implementation/WrapTokenManagerTest.java | 2 +- .../utils/ServiceExceptionFactoryTest.java | 2 +- 49 files changed, 74 insertions(+), 74 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/Builder.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/Configuration.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/ConfigurationException.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/DefaultBuilder.java (99%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/ExponentialRetryPolicy.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/FilterableService.java (62%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/RetryPolicy.java (79%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/RetryPolicyFilter.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/ServiceException.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{common => services/core}/ServiceFilter.java (95%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index e34ad58ce00ec..9aead4567bc7f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -3,8 +3,6 @@ import java.io.InputStream; import java.util.HashMap; -import com.microsoft.windowsazure.common.FilterableService; -import com.microsoft.windowsazure.common.ServiceException; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; @@ -45,6 +43,8 @@ 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.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; public interface BlobContract extends FilterableService { GetServicePropertiesResult getServiceProperties() throws ServiceException; 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/BlobService.java index b5b68aa4f2715..76ca645dbcb3e 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/BlobService.java @@ -5,9 +5,6 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; import com.microsoft.windowsazure.services.blob.models.BlobServiceOptions; @@ -48,6 +45,9 @@ 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.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; public class BlobService implements BlobContract { final BlobContract next; 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 8238988aedb25..0012e70497d92 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 @@ -1,10 +1,10 @@ package com.microsoft.windowsazure.services.blob; -import com.microsoft.windowsazure.common.Builder; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; +import com.microsoft.windowsazure.services.core.Builder; 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/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index b0f630844a79e..9d93d37138f01 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -8,8 +8,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobContract; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; import com.microsoft.windowsazure.services.blob.models.AcquireLeaseResult; @@ -51,6 +49,8 @@ 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.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index bc522234f974a..93f010524c7e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -8,8 +8,6 @@ import javax.inject.Inject; import javax.inject.Named; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.BlobContract; import com.microsoft.windowsazure.services.blob.models.AccessCondition; @@ -55,6 +53,8 @@ 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.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; import com.microsoft.windowsazure.utils.jersey.HttpURLConnectionClient; import com.microsoft.windowsazure.utils.jersey.JerseyHelpers; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java index 4fe8de2011e5c..487efc61dca4a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java index 323a0c6f44d8a..5080e89484308 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.io.IOException; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java index b21d4b5147ad6..b97325d27d0e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ConfigurationException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; public class ConfigurationException extends RuntimeException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java index 5d65f4f8170a3..3cbc1e340bf01 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java index ba6f5722efd8a..56aa4c59fb7c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ExponentialRetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java @@ -1,9 +1,9 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.util.Arrays; import java.util.Random; -import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.services.core.ServiceFilter.Response; public class ExponentialRetryPolicy extends RetryPolicy { private final int deltaBackoffIntervalInMs; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java similarity index 62% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/FilterableService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java index d60ce20225bf0..673139986edb1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/FilterableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; public interface FilterableService { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java similarity index 79% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java index c8d1fdee04742..4731f6700bea2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java @@ -1,6 +1,6 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; -import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.services.core.ServiceFilter.Response; public abstract class RetryPolicy { public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java index a4f63de45e533..0824852e2d0c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/RetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java index ed0518534fbc0..487e73fe6bd55 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.util.HashMap; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java index 5538d7be6ddba..5b5de010eb791 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/common/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.common; +package com.microsoft.windowsazure.services.core; import java.io.InputStream; import java.net.URI; 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 a86d091f21aa9..c460c56b12d7d 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,6 +1,6 @@ package com.microsoft.windowsazure.services.queue; -import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; import com.microsoft.windowsazure.services.queue.implementation.SharedKeyFilter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index 6ac72ebc2ff9b..615245ac6075f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java @@ -2,8 +2,8 @@ import java.util.HashMap; -import com.microsoft.windowsazure.common.FilterableService; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; 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/QueueService.java index 8767bd9c03716..fb2b697b207d6 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/QueueService.java @@ -4,9 +4,9 @@ import javax.inject.Inject; -import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; import com.microsoft.windowsazure.services.queue.models.GetQueueMetadataResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index a81a34e76296e..c0bfa50890d5a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -7,8 +7,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 76c004da179d7..3b34b99e44bea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -7,9 +7,9 @@ import javax.inject.Inject; import javax.inject.Named; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.queue.QueueConfiguration; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index 375f565c6e030..532fcedffb177 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -2,7 +2,7 @@ import java.util.Map; -import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModelProvider; import com.microsoft.windowsazure.services.serviceBus.implementation.MarshallerProvider; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index cf1f3877a26bd..f714875cf78cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; /** * Provides functionality to create a service bus configuration. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 24dd540529b64..a432480f413c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,7 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.common.FilterableService; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 3569050fc3e0d..1ae1e8437b3a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; /** * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 321e5948cc31f..9183a3d84e8b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java index 00ae004267fe5..170d0832825a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.core.Builder; public class Exports implements Builder.Exports { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index e3938f664a108..2705ed461614a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -5,8 +5,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 30a8a0390997e..c06336160a0aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -12,8 +12,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.AbstractListOptions; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java index 8b46999949f2a..ba57840a73474 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; public interface WrapContract { WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index cc6054c021d93..00683e93f2307 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index c4a5262c43585..462c1b409ee34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -6,7 +6,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 2e0ad35343a45..28bd3f78b4c69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -6,7 +6,7 @@ import javax.inject.Named; import javax.management.timer.Timer; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.utils.DateFactory; public class WrapTokenManager { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java index a18deb52bd4ae..7face53bfb103 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.utils; -import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.core.Builder; public class Exports implements Builder.Exports { public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java index 51b8eec3a23a7..840182f440f2b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java @@ -1,6 +1,6 @@ package com.microsoft.windowsazure.utils; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java index 60706db8a584b..b27261b10835d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java @@ -6,9 +6,9 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.common.ServiceFilter; -import com.microsoft.windowsazure.common.ServiceFilter.Request; -import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.ServiceFilter.Request; +import com.microsoft.windowsazure.services.core.ServiceFilter.Response; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java index 004a9dde17e8f..85d231989caf6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java @@ -3,8 +3,8 @@ import java.util.Map; import java.util.Map.Entry; -import com.microsoft.windowsazure.common.Builder; -import com.microsoft.windowsazure.common.Builder.Registry; +import com.microsoft.windowsazure.services.core.Builder; +import com.microsoft.windowsazure.services.core.Builder.Registry; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index 5a85851c8308d..cf4e3e4bac6d6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -2,7 +2,7 @@ import java.util.Map; -import com.microsoft.windowsazure.common.Builder; +import com.microsoft.windowsazure.services.core.Builder; public class AlterClassWithProperties implements Builder.Alteration { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java index ec629888f0713..dda2c4ca45e04 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import com.microsoft.windowsazure.common.DefaultBuilder; +import com.microsoft.windowsazure.services.core.DefaultBuilder; public class DefaultBuilderTest { 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 89288c84eb78f..02d2b0389093f 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 @@ -23,11 +23,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; -import com.microsoft.windowsazure.common.ExponentialRetryPolicy; -import com.microsoft.windowsazure.common.RetryPolicyFilter; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.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; @@ -57,6 +52,11 @@ 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.core.Configuration; +import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; +import com.microsoft.windowsazure.services.core.RetryPolicyFilter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; public class BlobServiceIntegrationTest extends IntegrationTestBase { private static final String testContainersPrefix = "sdktest-"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 7d552254ecde7..39dc038410a31 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { 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 0154fda420244..7f055859a616d 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 @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { 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 447acf7bafe30..8301ddab56e43 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 @@ -13,7 +13,7 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.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; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 32546aeb201ad..3be67b31ece10 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class ServiceBusConfigurationTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index 05fe729f3e1a4..e31cf1db576ab 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; public class ServiceBusCreationTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 2d1b232bb9b2f..7a09bcc66bb56 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -10,10 +10,10 @@ import org.junit.Before; import org.junit.Test; -import com.microsoft.windowsazure.common.ServiceException; -import com.microsoft.windowsazure.common.ServiceFilter; -import com.microsoft.windowsazure.common.ServiceFilter.Request; -import com.microsoft.windowsazure.common.ServiceFilter.Response; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.ServiceFilter.Request; +import com.microsoft.windowsazure.services.core.ServiceFilter.Response; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 3248d743e147c..03efe51854d76 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; import com.sun.jersey.api.client.Client; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 8c2420b8cc9f5..f5ade3677e5cb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -4,7 +4,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.common.Configuration; +import com.microsoft.windowsazure.services.core.Configuration; public class WrapTokenManagerIntegrationTest { @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index c7c30e602bef4..0864f7ac64180 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -12,7 +12,7 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.utils.DateFactory; public class WrapTokenManagerTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index f561b553362fb..97a7f2645dc15 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -6,7 +6,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.common.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; From 0704189b261ecb24cfcd0726d784dd1f8dfa2ba0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 12:00:04 -0800 Subject: [PATCH 254/664] Rename ".utils" to ".services.core.utils" --- .../services/blob/implementation/BlobExceptionProcessor.java | 2 +- .../windowsazure/{ => services/core}/utils/DateFactory.java | 2 +- .../{ => services/core}/utils/DefaultDateFactory.java | 2 +- .../windowsazure/{ => services/core}/utils/Exports.java | 2 +- .../{ => services/core}/utils/ServiceExceptionFactory.java | 2 +- .../queue/implementation/QueueExceptionProcessor.java | 2 +- .../implementation/ServiceBusExceptionProcessor.java | 2 +- .../services/serviceBus/implementation/WrapRestProxy.java | 2 +- .../services/serviceBus/implementation/WrapTokenManager.java | 2 +- .../com.microsoft.windowsazure.common.Builder$Exports | 4 ++-- .../serviceBus/implementation/WrapTokenManagerTest.java | 2 +- .../windowsazure/utils/ServiceExceptionFactoryTest.java | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{ => services/core}/utils/DateFactory.java (58%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{ => services/core}/utils/DefaultDateFactory.java (72%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{ => services/core}/utils/Exports.java (80%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{ => services/core}/utils/ServiceExceptionFactory.java (98%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 9d93d37138f01..4688c3394ea3d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -51,7 +51,7 @@ import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java similarity index 58% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java index 9998578fc5809..02af75c7fe6c0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils; +package com.microsoft.windowsazure.services.core.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java similarity index 72% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java index 4677c6291f366..d98d63ff1c16c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/DefaultDateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils; +package com.microsoft.windowsazure.services.core.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java similarity index 80% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java index 7face53bfb103..af68b89242d18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils; +package com.microsoft.windowsazure.services.core.utils; import com.microsoft.windowsazure.services.core.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 840182f440f2b..56fa8b8bd4869 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils; +package com.microsoft.windowsazure.services.core.utils; import com.microsoft.windowsazure.services.core.ServiceException; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index c0bfa50890d5a..e2708da0dfc17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -9,6 +9,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; import com.microsoft.windowsazure.services.queue.models.CreateQueueOptions; @@ -23,7 +24,6 @@ import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; 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; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 2705ed461614a..5138a0ad23ff9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -7,6 +7,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; @@ -33,7 +34,6 @@ import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -import com.microsoft.windowsazure.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index 462c1b409ee34..824f00e230ab4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -7,7 +7,7 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 28bd3f78b4c69..1ae1cf8fac7d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -7,7 +7,7 @@ import javax.management.timer.Timer; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.utils.DateFactory; +import com.microsoft.windowsazure.services.core.utils.DateFactory; public class WrapTokenManager { diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports index ee6898cc76eec..bbe057ada1b5b 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports @@ -2,5 +2,5 @@ com.microsoft.windowsazure.services.blob.Exports com.microsoft.windowsazure.services.queue.Exports com.microsoft.windowsazure.services.serviceBus.Exports com.microsoft.windowsazure.services.serviceBus.implementation.Exports -com.microsoft.windowsazure.utils.Exports -com.microsoft.windowsazure.utils.jersey.Exports +com.microsoft.windowsazure.services.core.utils.Exports +com.microsoft.windowsazure.services.core.utils.jersey.Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 0864f7ac64180..7119b7acd88df 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -13,7 +13,7 @@ import org.mockito.stubbing.Answer; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.utils.DateFactory; +import com.microsoft.windowsazure.services.core.utils.DateFactory; public class WrapTokenManagerTest { private WrapContract contract; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index 97a7f2645dc15..24a54a91dd516 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; From bb3001ce66e155fe10585ed55be34abdf7921cd1 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 12:01:20 -0800 Subject: [PATCH 255/664] Rename ".utils" to ".services.core.utils" --- .../services/blob/implementation/BlobRestProxy.java | 8 ++++---- .../services/blob/implementation/SharedKeyFilter.java | 2 +- .../services/blob/implementation/SharedKeyLiteFilter.java | 2 +- .../windowsazure/services/blob/models/BlockList.java | 2 +- .../services/blob/models/ListBlobBlocksResult.java | 2 +- .../core/utils/pipeline}/Base64StringAdapter.java | 2 +- .../core/utils/pipeline}/ClientFilterAdapter.java | 2 +- .../core/utils/pipeline}/EntityStreamingListener.java | 2 +- .../jersey => services/core/utils/pipeline}/Exports.java | 2 +- .../core/utils/pipeline}/HttpURLConnectionClient.java | 2 +- .../utils/pipeline}/HttpURLConnectionClientHandler.java | 4 ++-- .../core/utils/pipeline}/JerseyHelpers.java | 2 +- .../services/queue/implementation/QueueRestProxy.java | 6 +++--- .../serviceBus/implementation/ServiceBusRestProxy.java | 2 +- .../com.microsoft.windowsazure.common.Builder$Exports | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/Base64StringAdapter.java (88%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/ClientFilterAdapter.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/EntityStreamingListener.java (87%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/Exports.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/HttpURLConnectionClient.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/HttpURLConnectionClientHandler.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/{utils/jersey => services/core/utils/pipeline}/JerseyHelpers.java (98%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 93f010524c7e4..6b6d70f073ddb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -55,10 +55,10 @@ import com.microsoft.windowsazure.services.blob.models.SetContainerMetadataOptions; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; -import com.microsoft.windowsazure.utils.jersey.HttpURLConnectionClient; -import com.microsoft.windowsazure.utils.jersey.JerseyHelpers; -import com.microsoft.windowsazure.utils.jersey.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; +import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers; +import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java index e2879ee5976c4..5b8cc02551b46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -12,7 +12,7 @@ import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; -import com.microsoft.windowsazure.utils.jersey.EntityStreamingListener; +import com.microsoft.windowsazure.services.core.utils.pipeline.EntityStreamingListener; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; 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 4173055e93aa8..3671f51877455 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 @@ -10,7 +10,7 @@ import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; -import com.microsoft.windowsazure.utils.jersey.EntityStreamingListener; +import com.microsoft.windowsazure.services.core.utils.pipeline.EntityStreamingListener; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index e3da496648545..39ae94c6da571 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -10,7 +10,7 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.windowsazure.utils.jersey.Base64StringAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class BlockList { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java index 1181bb108b69b..c15b6a2b8ac22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java @@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import com.microsoft.windowsazure.utils.jersey.Base64StringAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.Base64StringAdapter; @XmlRootElement(name = "BlockList") public class ListBlobBlocksResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java similarity index 88% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index f9386afe00add..1d45b330e3438 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java index b27261b10835d..d7e147d1cd59d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import java.io.InputStream; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java index 64e37e7cf87bb..8ab28a121804d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/EntityStreamingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import com.sun.jersey.api.client.ClientRequest; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index 85d231989caf6..27349a7775f0d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import java.util.Map; import java.util.Map.Entry; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java index ee8c27cf541e6..2b02799f75c13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java index 75d89e257aebf..450f917e4c375 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -13,7 +13,7 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.utils.jersey.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/JerseyHelpers.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java index 9b66713ce92b2..712640f16fbf8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/utils/jersey/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.utils.jersey; +package com.microsoft.windowsazure.services.core.utils.pipeline; import java.util.HashMap; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 3b34b99e44bea..c130bb605cfcf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -10,6 +10,9 @@ import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; +import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers; import com.microsoft.windowsazure.services.queue.QueueConfiguration; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; @@ -25,9 +28,6 @@ import com.microsoft.windowsazure.services.queue.models.QueueServiceOptions; import com.microsoft.windowsazure.services.queue.models.ServiceProperties; import com.microsoft.windowsazure.services.queue.models.UpdateMessageResult; -import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; -import com.microsoft.windowsazure.utils.jersey.HttpURLConnectionClient; -import com.microsoft.windowsazure.utils.jersey.JerseyHelpers; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index c06336160a0aa..ec63bde251f69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -14,6 +14,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; import com.microsoft.windowsazure.services.serviceBus.models.AbstractListOptions; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; @@ -41,7 +42,6 @@ import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -import com.microsoft.windowsazure.utils.jersey.ClientFilterAdapter; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports index bbe057ada1b5b..cc7087393981f 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports @@ -3,4 +3,4 @@ com.microsoft.windowsazure.services.queue.Exports com.microsoft.windowsazure.services.serviceBus.Exports com.microsoft.windowsazure.services.serviceBus.implementation.Exports com.microsoft.windowsazure.services.core.utils.Exports -com.microsoft.windowsazure.services.core.utils.jersey.Exports +com.microsoft.windowsazure.services.core.utils.pipeline.Exports From d93a12470d580ce2d80743f61326b8712d2b61bb Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 12:16:34 -0800 Subject: [PATCH 256/664] Apply code cleanup and formatting settings --- .../services/blob/BlobContract.java | 71 ++++++++++------ .../services/blob/BlobService.java | 83 ++++++++++++------- .../BlobExceptionProcessor.java | 83 ++++++++++++------- .../services/blob/models/AccessCondition.java | 6 +- .../services/blob/models/BlockList.java | 3 +- .../blob/models/GetBlobMetadataOptions.java | 1 - .../services/blob/models/GetBlobOptions.java | 1 - .../blob/models/GetBlobPropertiesOptions.java | 1 - .../blob/models/ListBlobRegionsOptions.java | 1 - .../services/blob/models/ListBlobsResult.java | 3 +- .../blob/models/ListContainersOptions.java | 1 - .../blob/models/SetBlobMetadataOptions.java | 1 - .../models/SetContainerMetadataOptions.java | 1 - .../services/core/ExponentialRetryPolicy.java | 3 +- .../services/core/FilterableService.java | 1 - .../services/core/RetryPolicyFilter.java | 3 +- .../services/queue/QueueContract.java | 14 ++-- .../services/queue/QueueService.java | 17 ++-- .../QueueExceptionProcessor.java | 20 +++-- .../services/serviceBus/Util.java | 6 +- .../BrokerPropertiesMapper.java | 3 +- .../implementation/EntryModelProvider.java | 33 +++----- .../serviceBus/implementation/WrapFilter.java | 6 +- .../implementation/WrapRestProxy.java | 10 ++- .../implementation/WrapTokenManager.java | 4 +- .../serviceBus/models/CreateQueueResult.java | 54 ++++++------ .../serviceBus/models/CreateRuleResult.java | 54 ++++++------ .../models/CreateSubscriptionResult.java | 36 ++++---- .../serviceBus/models/CreateTopicResult.java | 54 ++++++------ .../serviceBus/models/GetQueueResult.java | 54 ++++++------ .../serviceBus/models/GetRuleResult.java | 54 ++++++------ .../models/GetSubscriptionResult.java | 60 +++++++------- .../serviceBus/models/GetTopicResult.java | 54 ++++++------ .../serviceBus/models/ListQueuesResult.java | 40 ++++----- .../serviceBus/models/ListRulesResult.java | 26 +++--- .../models/ListSubscriptionsResult.java | 26 +++--- .../serviceBus/models/ListTopicsResult.java | 28 +++---- .../serviceBus/models/SubscriptionInfo.java | 1 - 38 files changed, 487 insertions(+), 430 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index 9aead4567bc7f..4e7a4104bbe5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -15,6 +15,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; @@ -24,7 +25,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.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; @@ -69,11 +69,13 @@ public interface BlobContract extends FilterableService { GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException; - GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException; + GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) + throws ServiceException; GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException; - GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException; + GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) + throws ServiceException; GetContainerACLResult getContainerACL(String container) throws ServiceException; @@ -85,7 +87,8 @@ public interface BlobContract extends FilterableService { void setContainerMetadata(String container, HashMap metadata) throws ServiceException; - void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException; + void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) + throws ServiceException; ListBlobsResult listBlobs(String container) throws ServiceException; @@ -97,50 +100,62 @@ public interface BlobContract extends FilterableService { void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException; - void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; + void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException; CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException; - CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException; + CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) + throws ServiceException; - CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, 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, PageRange range, 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; + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) + throws ServiceException; - void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException; + void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, + CreateBlobBlockOptions options) throws ServiceException; void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException; - void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; + void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException; ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException; - ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException; + ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) + throws ServiceException; GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException; - GetBlobPropertiesResult 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; - GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException; + GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) + throws ServiceException; ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException; - ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException; + ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) + throws ServiceException; SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException; - SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException; - - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException; + SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) + throws ServiceException; - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException; + SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, + SetBlobMetadataOptions options) throws ServiceException; + GetBlobResult getBlob(String container, String blob) throws ServiceException; GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException; @@ -151,24 +166,28 @@ SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metad next.setContainerMetadata(container, metadata); } - public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { + public void setContainerMetadata(String container, HashMap metadata, + SetContainerMetadataOptions options) throws ServiceException { next.setContainerMetadata(container, metadata, options); } @@ -169,7 +173,8 @@ public void createPageBlob(String container, String blob, int length) throws Ser next.createPageBlob(container, blob, length); } - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) + throws ServiceException { next.createPageBlob(container, blob, length, options); } @@ -177,7 +182,8 @@ public void createBlockBlob(String container, String blob, InputStream contentSt next.createBlockBlob(container, blob, contentStream); } - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException { next.createBlockBlob(container, blob, contentStream, options); } @@ -185,26 +191,28 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR return next.clearBlobPages(container, blob, range); } - 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 next.clearBlobPages(container, blob, range, options); } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) - throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream) throws ServiceException { return next.createBlobPages(container, blob, range, length, contentStream); } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, - CreateBlobPagesOptions options) throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { return next.createBlobPages(container, blob, range, length, contentStream, options); } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) + throws ServiceException { next.createBlobBlock(container, blob, blockId, contentStream); } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) - throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, + CreateBlobBlockOptions options) throws ServiceException { next.createBlobBlock(container, blob, blockId, contentStream, options); } @@ -212,7 +220,8 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) next.commitBlobBlocks(container, blob, blockList); } - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException { next.commitBlobBlocks(container, blob, blockList, options); } @@ -220,7 +229,8 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws return next.listBlobBlocks(container, blob); } - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) + throws ServiceException { return next.listBlobBlocks(container, blob, options); } @@ -228,7 +238,8 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob) return next.getBlobProperties(container, blob); } - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) + throws ServiceException { return next.getBlobProperties(container, blob, options); } @@ -236,7 +247,8 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro return next.getBlobMetadata(container, blob); } - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) + throws ServiceException { return next.getBlobMetadata(container, blob, options); } @@ -244,7 +256,8 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro return next.listBlobRegions(container, blob); } - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) + throws ServiceException { return next.listBlobRegions(container, blob, options); } @@ -252,16 +265,18 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob) return next.setBlobProperties(container, blob); } - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) + throws ServiceException { return next.setBlobProperties(container, blob, options); } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) + throws ServiceException { return next.setBlobMetadata(container, blob, metadata); } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) - throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, + SetBlobMetadataOptions options) throws ServiceException { return next.setBlobMetadata(container, blob, metadata, options); } @@ -285,16 +300,18 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob return next.createBlobSnapshot(container, blob); } - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) + throws ServiceException { return next.createBlobSnapshot(container, blob, options); } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) + throws ServiceException { next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) - throws ServiceException { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, + String sourceBlob, CopyBlobOptions options) throws ServiceException { next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); } @@ -302,7 +319,8 @@ public AcquireLeaseResult acquireLease(String container, String blob) throws Ser return next.acquireLease(container, blob); } - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) + throws ServiceException { return next.acquireLease(container, blob, options); } @@ -310,7 +328,8 @@ public AcquireLeaseResult renewLease(String container, String blob, String lease return next.renewLease(container, blob, leaseId); } - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { return next.renewLease(container, blob, leaseId, options); } @@ -318,7 +337,8 @@ public void releaseLease(String container, String blob, String leaseId) throws S next.releaseLease(container, blob, leaseId); } - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { next.releaseLease(container, blob, leaseId, options); } @@ -326,7 +346,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser next.breakLease(container, blob, leaseId); } - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { next.breakLease(container, blob, leaseId, options); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 4688c3394ea3d..297ba2e8db758 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -101,7 +101,8 @@ public GetServicePropertiesResult getServiceProperties(BlobServiceOptions option } } - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) + throws ServiceException { try { service.setServiceProperties(serviceProperties, options); } @@ -209,7 +210,8 @@ public GetContainerPropertiesResult getContainerProperties(String container) thr } } - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException { + public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) + throws ServiceException { try { return service.getContainerProperties(container, options); } @@ -233,7 +235,8 @@ public GetContainerPropertiesResult getContainerMetadata(String container) throw } } - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException { + public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) + throws ServiceException { try { return service.getContainerMetadata(container, options); } @@ -305,7 +308,8 @@ public void setContainerMetadata(String container, HashMap metad } } - public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { + public void setContainerMetadata(String container, HashMap metadata, + SetContainerMetadataOptions options) throws ServiceException { try { service.setContainerMetadata(container, metadata, options); } @@ -353,7 +357,8 @@ public void createPageBlob(String container, String blob, int length) throws Ser } } - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { + public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) + throws ServiceException { try { service.createPageBlob(container, blob, length, options); } @@ -377,7 +382,8 @@ public void createBlockBlob(String container, String blob, InputStream contentSt } } - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { + public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException { try { service.createBlockBlob(container, blob, contentStream, options); } @@ -401,7 +407,8 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR } } - 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 { try { return service.clearBlobPages(container, blob, range, options); } @@ -413,8 +420,8 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR } } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) - throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream) throws ServiceException { try { return service.createBlobPages(container, blob, range, length, contentStream); } @@ -426,8 +433,8 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, Page } } - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, - CreateBlobPagesOptions options) throws ServiceException { + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { try { return service.createBlobPages(container, blob, range, length, contentStream, options); } @@ -439,7 +446,8 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, Page } } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) + throws ServiceException { try { service.createBlobBlock(container, blob, blockId, contentStream); } @@ -451,8 +459,8 @@ public void createBlobBlock(String container, String blob, String blockId, Input } } - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) - throws ServiceException { + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, + CreateBlobBlockOptions options) throws ServiceException { try { service.createBlobBlock(container, blob, blockId, contentStream, options); } @@ -476,7 +484,8 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) } } - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException { try { service.commitBlobBlocks(container, blob, blockList, options); } @@ -500,7 +509,8 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws } } - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) + throws ServiceException { try { return service.listBlobBlocks(container, blob, options); } @@ -524,7 +534,8 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob) } } - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { + public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) + throws ServiceException { try { return service.getBlobProperties(container, blob, options); } @@ -548,7 +559,8 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro } } - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) + throws ServiceException { try { return service.getBlobMetadata(container, blob, options); } @@ -572,7 +584,8 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro } } - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) + throws ServiceException { try { return service.listBlobRegions(container, blob, options); } @@ -584,7 +597,8 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List } } - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) + throws ServiceException { try { return service.setBlobProperties(container, blob, options); } @@ -608,7 +622,8 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob) } } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) + throws ServiceException { try { return service.setBlobMetadata(container, blob, metadata); } @@ -620,8 +635,8 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash } } - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) - throws ServiceException { + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, + SetBlobMetadataOptions options) throws ServiceException { try { return service.setBlobMetadata(container, blob, metadata, options); } @@ -693,7 +708,8 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob } } - public CreateBlobSnapshotResult 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); } @@ -705,7 +721,8 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob } } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) + throws ServiceException { try { service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); } @@ -717,8 +734,8 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } } - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) - throws ServiceException { + public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, + String sourceBlob, CopyBlobOptions options) throws ServiceException { try { service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); } @@ -742,7 +759,8 @@ public AcquireLeaseResult acquireLease(String container, String blob) throws Ser } } - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { + public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) + throws ServiceException { try { return service.acquireLease(container, blob, options); } @@ -766,7 +784,8 @@ public AcquireLeaseResult renewLease(String container, String blob, String lease } } - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { try { return service.renewLease(container, blob, leaseId, options); } @@ -790,7 +809,8 @@ public void releaseLease(String container, String blob, String leaseId) throws S } } - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { try { service.releaseLease(container, blob, leaseId, options); } @@ -814,7 +834,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser } } - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { try { service.breakLease(container, blob, leaseId, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java index c53b2e6fdf792..31879b4dfd622 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java @@ -53,7 +53,8 @@ public static AccessCondition ifMatch(String etag) { * @return An AccessCondition object that represents the If-Modified-Since condition. */ public static AccessCondition ifModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); + return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, + new RFC1123DateConverter().format(lastMotified)); } /** @@ -93,7 +94,8 @@ public static AccessCondition ifNoneMatch(String etag) { * @return An AccessCondition object that represents the If-Unmodified-Since condition. */ public static AccessCondition ifNotModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, new RFC1123DateConverter().format(lastMotified)); + return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, + new RFC1123DateConverter().format(lastMotified)); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index 39ae94c6da571..06e49f74c0d58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -37,7 +37,8 @@ public BlockList addLatestEntry(String blockId) { return this; } - @XmlElementRefs({ @XmlElementRef(name = "Committed", type = CommittedEntry.class), @XmlElementRef(name = "Uncommitted", type = UncommittedEntry.class), + @XmlElementRefs({ @XmlElementRef(name = "Committed", type = CommittedEntry.class), + @XmlElementRef(name = "Uncommitted", type = UncommittedEntry.class), @XmlElementRef(name = "Latest", type = LatestEntry.class) }) @XmlMixed public List getEntries() { 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 1adf62fffc0ba..14044ffaec541 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class GetBlobMetadataOptions extends BlobServiceOptions { private String snapshot; private String leaseId; 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 b7d87465cb422..56a55fe6a6001 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class GetBlobOptions extends BlobServiceOptions { private String snapshot; private String leaseId; 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 b4a4181b3c07f..7e70cf5192320 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class GetBlobPropertiesOptions extends BlobServiceOptions { private String snapshot; private String leaseId; 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 263f1a3266020..dfb99b5158d93 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class ListBlobRegionsOptions extends BlobServiceOptions { private String leaseId; private String snapshot; 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 4e038f16154eb..ff7edfbce5d14 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 @@ -26,7 +26,8 @@ public class ListBlobsResult { private int maxResults; @XmlElementWrapper(name = "Blobs") - @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefixEntry.class), @XmlElementRef(name = "Blob", type = BlobEntry.class) }) + @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefixEntry.class), + @XmlElementRef(name = "Blob", type = BlobEntry.class) }) public List getEntries() { ArrayList result = new ArrayList(); result.addAll(this.blobPrefixes); 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 6b3bf57b9eef2..0b4f74d686a9c 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class ListContainersOptions extends BlobServiceOptions { private String prefix; private String marker; 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 b09ae1027d9d9..9fe24273ae53f 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - 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/SetContainerMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java index 9d856e97c88ea..237f3991c7aed 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,6 +1,5 @@ package com.microsoft.windowsazure.services.blob.models; - public class SetContainerMetadataOptions extends BlobServiceOptions { private AccessCondition accessCondition; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java index 56aa4c59fb7c3..821b59118c811 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java @@ -46,7 +46,8 @@ public int calculateBackoff(int currentRetryCount, Response response, Exception // exponential int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) - + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - (int) (this.deltaBackoffIntervalInMs * 0.8)); + + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) + - (int) (this.deltaBackoffIntervalInMs * 0.8)); incrementDelta *= boundedRandDelta; // Enforce max / min backoffs diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java index 673139986edb1..0cdc06d020e17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.core; - public interface FilterableService { T withFilter(ServiceFilter filter); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java index 0824852e2d0c8..1ecce3a22a210 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java @@ -36,7 +36,8 @@ public Response handle(Request request, Next next) throws Exception { } int backoffTime = retryPolicy.calculateBackoff(retryCount, response, error); - log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", backoffTime, retryCount)); + log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", + backoffTime, retryCount)); backoff(backoffTime); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index 615245ac6075f..0a43084629d3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java @@ -45,21 +45,23 @@ public interface QueueContract extends FilterableService { void setQueueMetadata(String queue, HashMap metadata) throws ServiceException; - void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException; + void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) + throws ServiceException; void createMessage(String queue, String messageText) throws ServiceException; 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) throws ServiceException; + 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; + void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) + throws ServiceException; ListMessagesResult listMessages(String queue) throws ServiceException; 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/QueueService.java index fb2b697b207d6..119ae12615eb9 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/QueueService.java @@ -61,7 +61,8 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser next.setServiceProperties(serviceProperties); } - public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) + throws ServiceException { next.setServiceProperties(serviceProperties, options); } @@ -101,7 +102,8 @@ public void setQueueMetadata(String queue, HashMap metadata) thr next.setQueueMetadata(queue, metadata); } - public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) + throws ServiceException { next.setQueueMetadata(queue, metadata, options); } @@ -113,13 +115,13 @@ public void createMessage(String queue, String messageText, CreateMessageOptions next.createMessage(queue, messageText, options); } - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) - throws ServiceException { + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds) throws ServiceException { return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); } - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, - QueueServiceOptions options) throws ServiceException { + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); } @@ -127,7 +129,8 @@ public void deleteMessage(String queue, String messageId, String popReceipt) thr next.deleteMessage(queue, messageId, popReceipt); } - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) + throws ServiceException { next.deleteMessage(queue, messageId, popReceipt, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index e2708da0dfc17..a113b4f29a51b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -85,7 +85,8 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser } } - public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) throws ServiceException { + public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) + throws ServiceException { try { service.setServiceProperties(serviceProperties, options); } @@ -205,7 +206,8 @@ public void setQueueMetadata(String queue, HashMap metadata) thr } } - public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) throws ServiceException { + public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) + throws ServiceException { try { service.setQueueMetadata(queue, metadata, options); } @@ -241,8 +243,8 @@ public void createMessage(String queue, String messageText, CreateMessageOptions } } - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds) - throws ServiceException { + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds) throws ServiceException { try { return service.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); } @@ -254,10 +256,11 @@ public UpdateMessageResult updateMessage(String queue, String messageId, String } } - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, int visibilityTimeoutInSeconds, - QueueServiceOptions options) throws ServiceException { + public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, + int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { try { - return service.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); + return service + .updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -327,7 +330,8 @@ public void deleteMessage(String queue, String messageId, String popReceipt) thr } } - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) throws ServiceException { + public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) + throws ServiceException { try { service.deleteMessage(queue, messageId, popReceipt, options); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 9183a3d84e8b5..2409039ebee3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -5,14 +5,12 @@ import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; public class Util { - public static Iterable iterateQueues(ServiceBusContract service) - throws ServiceException { + public static Iterable iterateQueues(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listQueues().getItems(); } - public static Iterable iterateTopics(ServiceBusContract service) - throws ServiceException { + public static Iterable iterateTopics(ServiceBusContract service) throws ServiceException { // TODO: iterate over link rel=next pagination return service.listTopics().getItems(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index d443289f1a164..fe3d5b5e7c3d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -11,8 +11,7 @@ public class BrokerPropertiesMapper { - public BrokerProperties fromString(String value) - throws IllegalArgumentException { + public BrokerProperties fromString(String value) throws IllegalArgumentException { ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(value.getBytes(), BrokerProperties.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java index 17569830549b3..4053a779a8c9a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java @@ -17,8 +17,7 @@ import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; import com.sun.jersey.spi.MessageBodyWorkers; -public class EntryModelProvider extends - AbstractMessageReaderWriterProvider> { +public class EntryModelProvider extends AbstractMessageReaderWriterProvider> { MessageBodyWorkers workers; @@ -26,21 +25,18 @@ public EntryModelProvider(@Context MessageBodyWorkers workers) { this.workers = workers; } - public boolean isReadable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { + public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { return EntryModel.class.isAssignableFrom(type); } - public EntryModel readFrom(Class> type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, InputStream entityStream) + public EntryModel readFrom(Class> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { - MessageBodyReader reader = workers.getMessageBodyReader( - Entry.class, Entry.class, annotations, mediaType); + MessageBodyReader reader = workers + .getMessageBodyReader(Entry.class, Entry.class, annotations, mediaType); - Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, - mediaType, httpHeaders, entityStream); + Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, mediaType, httpHeaders, entityStream); // these exceptions are masked as a RuntimeException because they cannot // be thrown by this override @@ -61,21 +57,18 @@ public EntryModel readFrom(Class> type, Type genericType, } } - public boolean isWriteable(Class type, Type genericType, - Annotation[] annotations, MediaType mediaType) { + public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { return EntryModel.class.isAssignableFrom(type); } - public void writeTo(EntryModel t, Class type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, - OutputStream entityStream) throws IOException, - WebApplicationException { + public void writeTo(EntryModel t, Class type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { Entry entry = t.getEntry(); - MessageBodyWriter writer = workers.getMessageBodyWriter( - Entry.class, Entry.class, annotations, mediaType); + MessageBodyWriter writer = workers + .getMessageBodyWriter(Entry.class, Entry.class, annotations, mediaType); writer.writeTo(entry, Entry.class, genericType, annotations, mediaType, httpHeaders, entityStream); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 00683e93f2307..5a2356990c638 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -14,8 +14,7 @@ public WrapFilter(WrapTokenManager tokenManager) { } @Override - public ClientResponse handle(ClientRequest cr) - throws ClientHandlerException { + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { String accessToken; try { @@ -26,8 +25,7 @@ public ClientResponse handle(ClientRequest cr) throw new ClientHandlerException(e); } - cr.getHeaders().add("Authorization", - "WRAP access_token=\"" + accessToken + "\""); + cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); return this.getNext().handle(cr); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index 824f00e230ab4..51180a8aa23c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -22,7 +22,8 @@ public WrapRestProxy(Client channel) { this.channel = channel; } - public WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) throws ServiceException { + public WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) + throws ServiceException { Form requestForm = new Form(); requestForm.add("wrap_name", name); requestForm.add("wrap_password", password); @@ -30,12 +31,13 @@ public WrapAccessTokenResult wrapAccessToken(String uri, String name, String pas Form responseForm; try { - responseForm = channel.resource(uri).accept(MediaType.APPLICATION_FORM_URLENCODED).type(MediaType.APPLICATION_FORM_URLENCODED) - .post(Form.class, requestForm); + responseForm = channel.resource(uri).accept(MediaType.APPLICATION_FORM_URLENCODED) + .type(MediaType.APPLICATION_FORM_URLENCODED).post(Form.class, requestForm); } catch (UniformInterfaceException e) { log.warn("WRAP server returned error acquiring access_token", e); - throw ServiceExceptionFactory.process("WRAP", new ServiceException("WRAP server returned error acquiring access_token", e)); + throw ServiceExceptionFactory.process("WRAP", new ServiceException( + "WRAP server returned error acquiring access_token", e)); } WrapAccessTokenResult response = new WrapAccessTokenResult(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 1ae1cf8fac7d2..4789c26c3a641 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -21,8 +21,8 @@ public class WrapTokenManager { private ActiveToken activeToken; @Inject - public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, @Named("wrap.scope") String scope, - @Named("wrap.name") String name, @Named("wrap.password") String password) { + public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, + @Named("wrap.scope") String scope, @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; this.dateFactory = dateFactory; this.uri = uri; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index 71a2f7b2ddc90..e7f29c15a0d09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -5,35 +5,35 @@ */ public class CreateQueueResult { - private QueueInfo value; + private QueueInfo value; - /** - * Creates an instance of the CreateQueueResult class. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public CreateQueueResult(QueueInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the CreateQueueResult class. + * + * @param value + * A {@link QueueInfo} object assigned as the value of the result. + */ + public CreateQueueResult(QueueInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public void setValue(QueueInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link QueueInfo} object assigned as the value of the result. + */ + public void setValue(QueueInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link QueueInfo} object that represents the value of the result. - */ - public QueueInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link QueueInfo} object that represents the value of the result. + */ + public QueueInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index 26811f17116b3..3e7bac017081b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -5,35 +5,35 @@ */ public class CreateRuleResult { - private RuleInfo value; + private RuleInfo value; - /** - * Creates an instance of the CreateRuleResult class. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public CreateRuleResult(RuleInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the CreateRuleResult class. + * + * @param value + * A {@link RuleInfo} object assigned as the value of the result. + */ + public CreateRuleResult(RuleInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public void setValue(RuleInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link RuleInfo} object assigned as the value of the result. + */ + public void setValue(RuleInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link RuleInfo} object that represents the value of the result. - */ - public RuleInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link RuleInfo} object that represents the value of the result. + */ + public RuleInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 87b495c4aaebe..7dd0df52e7140 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -7,32 +7,32 @@ public class CreateSubscriptionResult { private SubscriptionInfo value; - /** - * Creates an instance of the CreateSubscriptionResult class. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the result. - */ + /** + * Creates an instance of the CreateSubscriptionResult class. + * + * @param value + * A {@link SubscriptionInfo} object assigned as the value of the result. + */ public CreateSubscriptionResult(SubscriptionInfo value) { this.setValue(value); } - /** - * Specfies the value of the result. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ + /** + * Specfies the value of the result. + * + * @param value + * A {@link SubscriptionInfo} object assigned as the value of the + * result. + */ public void setValue(SubscriptionInfo value) { this.value = value; } - /** - * Returns the value of the result. - * - * @return A {@link SubscriptionInfo} object that represents the value of the result. - */ + /** + * Returns the value of the result. + * + * @return A {@link SubscriptionInfo} object that represents the value of the result. + */ public SubscriptionInfo getValue() { return value; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 263eb7b3e0d1d..11e1dfa0b9022 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -5,35 +5,35 @@ */ public class CreateTopicResult { - private TopicInfo value; + private TopicInfo value; - /** - * Creates an instance of the CreateTopicResult class. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public CreateTopicResult(TopicInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the CreateTopicResult class. + * + * @param value + * A {@link TopicInfo} object assigned as the value of the result. + */ + public CreateTopicResult(TopicInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public void setValue(TopicInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link TopicInfo} object assigned as the value of the result. + */ + public void setValue(TopicInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link TopicInfo} object that represents the value of the result. - */ - public TopicInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link TopicInfo} object that represents the value of the result. + */ + public TopicInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index ddb5da06d5a11..c625bb7e7d9eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -5,35 +5,35 @@ */ public class GetQueueResult { - private QueueInfo value; + private QueueInfo value; - /** - * Creates an instance of the GetQueueResult class. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public GetQueueResult(QueueInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the GetQueueResult class. + * + * @param value + * A {@link QueueInfo} object assigned as the value of the result. + */ + public GetQueueResult(QueueInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public void setValue(QueueInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link QueueInfo} object assigned as the value of the result. + */ + public void setValue(QueueInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link QueueInfo} object that represents the value of the result. - */ - public QueueInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link QueueInfo} object that represents the value of the result. + */ + public QueueInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java index b45b4f4c5722b..2a9217f7137fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -5,35 +5,35 @@ */ public class GetRuleResult { - private RuleInfo value; + private RuleInfo value; - /** - * Creates an instance of the GetRuleResult class. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public GetRuleResult(RuleInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the GetRuleResult class. + * + * @param value + * A {@link RuleInfo} object assigned as the value of the result. + */ + public GetRuleResult(RuleInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public void setValue(RuleInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link RuleInfo} object assigned as the value of the result. + */ + public void setValue(RuleInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link RuleInfo} object that represents the value of the result. - */ - public RuleInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link RuleInfo} object that represents the value of the result. + */ + public RuleInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index b8519fd8150ca..15a897f07e8f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -5,38 +5,38 @@ */ public class GetSubscriptionResult { - private SubscriptionInfo value; + private SubscriptionInfo value; - /** - * Creates an instance of the GetSubscriptionResult class. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ - public GetSubscriptionResult(SubscriptionInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the GetSubscriptionResult class. + * + * @param value + * A {@link SubscriptionInfo} object assigned as the value of the + * result. + */ + public GetSubscriptionResult(SubscriptionInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ - public void setValue(SubscriptionInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link SubscriptionInfo} object assigned as the value of the + * result. + */ + public void setValue(SubscriptionInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link SubscriptionInfo} object that represents the value of the - * result. - */ - public SubscriptionInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link SubscriptionInfo} object that represents the value of the + * result. + */ + public SubscriptionInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index bce289b148853..8a8fbeaeb9be5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -5,35 +5,35 @@ */ public class GetTopicResult { - private TopicInfo value; + private TopicInfo value; - /** - * Creates an instance of the GetTopicResult class. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public GetTopicResult(TopicInfo value) { - this.setValue(value); - } + /** + * Creates an instance of the GetTopicResult class. + * + * @param value + * A {@link TopicInfo} object assigned as the value of the result. + */ + public GetTopicResult(TopicInfo value) { + this.setValue(value); + } - /** - * Specfies the value of the result. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public void setValue(TopicInfo value) { - this.value = value; - } + /** + * Specfies the value of the result. + * + * @param value + * A {@link TopicInfo} object assigned as the value of the result. + */ + public void setValue(TopicInfo value) { + this.value = value; + } - /** - * Returns the value of the result. - * - * @return A {@link TopicInfo} object that represents the value of the result. - */ - public TopicInfo getValue() { - return value; - } + /** + * Returns the value of the result. + * + * @return A {@link TopicInfo} object that represents the value of the result. + */ + public TopicInfo getValue() { + return value; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index 877e0f105bae5..e7ee67a9f3a45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -7,26 +7,26 @@ */ public class ListQueuesResult { - private List items; + private List items; - /** - * Returns the items in the result list. - * - * @return A List of {@link QueueInfo} objects that represent the - * items in the result list. - */ - public List getItems() { - return items; - } + /** + * Returns the items in the result list. + * + * @return A List of {@link QueueInfo} objects that represent the + * items in the result list. + */ + public List getItems() { + return items; + } - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link QueueInfo} - * objects assigned as the value of the result. - */ - public void setItems(List items) { - this.items = items; - } + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link QueueInfo} objects assigned as the value of the + * result. + */ + public void setItems(List items) { + this.items = items; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java index 61db6d2fea0a1..0766e3896d78a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -9,23 +9,23 @@ public class ListRulesResult { private List items; - /** - * Returns the items in the result list. - * - * @return A List of {@link RuleInfo} objects that represent the - * items in the result list. - */ + /** + * Returns the items in the result list. + * + * @return A List of {@link RuleInfo} objects that represent the + * items in the result list. + */ public List getItems() { return items; } - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link RuleInfo} - * objects assigned as the value of the result. - */ + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link RuleInfo} objects assigned as the value of the + * result. + */ public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 574bb74fa826e..9ea13c690bd6c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -9,23 +9,23 @@ public class ListSubscriptionsResult { private List items; - /** - * Returns the items in the result list. - * - * @return A List of {@link SubscriptionInfo} objects that represent the - * items in the result list. - */ + /** + * Returns the items in the result list. + * + * @return A List of {@link SubscriptionInfo} objects that represent the + * items in the result list. + */ public List getItems() { return items; } - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link SubscriptionInfo} - * objects assigned as the value of the result. - */ + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link SubscriptionInfo} objects assigned as the value of + * the result. + */ public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index b8eddf1960185..efe91c422362b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -9,23 +9,23 @@ public class ListTopicsResult { private List items; - /** - * Returns the items in the result list. - * - * @return A List of {@link TopicInfo} objects that represent the - * items in the result list. - */ + /** + * Returns the items in the result list. + * + * @return A List of {@link TopicInfo} objects that represent the + * items in the result list. + */ public List getItems() { return items; } - - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link TopicInfo} - * objects assigned as the value of the result. - */ + + /** + * Specfies the items in the result list. + * + * @param value + * A List object that contains the {@link TopicInfo} objects assigned as the value of the + * result. + */ public void setItems(List items) { this.items = items; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 3c9aec8974c3a..7dea0733c7857 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -209,7 +209,6 @@ public Long getMessageCount() { return getModel().getMessageCount(); } - /** * Returns the maximum delivery count for the subscription. * From 74dc06a4d266b5d0ba74b4bc85d5dfe552cff2ea Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 14:05:30 -0800 Subject: [PATCH 257/664] Use ascii apostrophe --- .../com/microsoft/windowsazure/serviceruntime/RoleInstance.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java index bee72e428486b..2201e1a597ea4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java @@ -44,7 +44,7 @@ public int getFaultDomain() { /** * Returns the ID of this instance. *

- * The returned ID is unique to the application domain of the role�s instance. If an instance is terminated and has + * The returned ID is unique to the application domain of the role's instance. If an instance is terminated and has * been configured to restart automatically, the restarted instance will have the same ID as the terminated * instance. * From a4d666e2136773b4f5935823aacb39f9d059ea3e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 14:52:30 -0800 Subject: [PATCH 258/664] Update Blob to follow new configuration/instantiation pattern Conflicts: microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java --- .../services/blob/BlobService.java | 351 +----------------- .../blob/BlobServiceIntegrationTest.java | 95 ++--- .../services/blob/IntegrationTestBase.java | 38 +- .../com.microsoft.windowsazure.properties | 3 + 4 files changed, 63 insertions(+), 424 deletions(-) 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/BlobService.java index 8964d84ad4a59..912a026babf07 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/BlobService.java @@ -1,353 +1,24 @@ package com.microsoft.windowsazure.services.blob; -import java.io.InputStream; -import java.util.HashMap; - -import javax.inject.Inject; - -import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; -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.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.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; -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.GetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -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; -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.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; -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.services.core.Configuration; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; - -public class BlobService implements BlobContract { - final BlobContract next; - - public BlobService() throws Exception { - this(null, Configuration.getInstance()); - } - - public BlobService(Configuration config) throws Exception { - this(null, config); - } - - public BlobService(String profile) throws Exception { - this(profile, Configuration.getInstance()); - } - - public BlobService(String profile, Configuration config) throws Exception { - next = config.create(profile, BlobContract.class); - } - - @Inject - public BlobService(BlobContract next) throws Exception { - this.next = next; - } - - public BlobContract withFilter(ServiceFilter filter) { - return next.withFilter(filter); - } - - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - return next.getServiceProperties(); - } - - public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { - return next.getServiceProperties(options); - } - - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - next.setServiceProperties(serviceProperties); - } - - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) - throws ServiceException { - next.setServiceProperties(serviceProperties, options); - } - - public ListContainersResult listContainers() throws ServiceException { - return next.listContainers(); - } - - public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { - return next.listContainers(options); - } - - public void createContainer(String container) throws ServiceException { - next.createContainer(container); - } - - public void createContainer(String container, CreateContainerOptions options) throws ServiceException { - next.createContainer(container, options); - } - - public void deleteContainer(String container) throws ServiceException { - next.deleteContainer(container); - } - - public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { - next.deleteContainer(container, options); - } - - public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { - return next.getContainerProperties(container); - } - - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) - throws ServiceException { - return next.getContainerProperties(container, options); - } - - public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { - return next.getContainerMetadata(container); - } - - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) - throws ServiceException { - return next.getContainerMetadata(container, options); - } - - public GetContainerACLResult getContainerACL(String container) throws ServiceException { - return next.getContainerACL(container); - } - - public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { - return next.getContainerACL(container, options); - } - - public void setContainerACL(String container, ContainerACL acl) throws ServiceException { - next.setContainerACL(container, acl); - } - - public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { - next.setContainerACL(container, acl, options); - } - - public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { - next.setContainerMetadata(container, metadata); - } - - public void setContainerMetadata(String container, HashMap metadata, - SetContainerMetadataOptions options) throws ServiceException { - next.setContainerMetadata(container, metadata, options); - } - - public ListBlobsResult listBlobs(String container) throws ServiceException { - return next.listBlobs(container); - } - - public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - return next.listBlobs(container, options); - } - - public void createPageBlob(String container, String blob, int length) throws ServiceException { - next.createPageBlob(container, blob, length); - } - - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) - throws ServiceException { - next.createPageBlob(container, blob, length, options); - } - - public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { - next.createBlockBlob(container, blob, contentStream); - } - - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) - throws ServiceException { - next.createBlockBlob(container, blob, contentStream, options); - } - - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { - return next.clearBlobPages(container, blob, range); - } - - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, - CreateBlobPagesOptions options) throws ServiceException { - return next.clearBlobPages(container, blob, range, options); - } - - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream) throws ServiceException { - return next.createBlobPages(container, blob, range, length, contentStream); - } - - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - return next.createBlobPages(container, blob, range, length, contentStream, options); - } - - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) - throws ServiceException { - next.createBlobBlock(container, blob, blockId, contentStream); - } - - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, - CreateBlobBlockOptions options) throws ServiceException { - next.createBlobBlock(container, blob, blockId, contentStream, options); - } - - public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { - next.commitBlobBlocks(container, blob, blockList); - } - - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) - throws ServiceException { - next.commitBlobBlocks(container, blob, blockList, options); - } - - public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { - return next.listBlobBlocks(container, blob); - } - - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) - throws ServiceException { - return next.listBlobBlocks(container, blob, options); - } - - public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { - return next.getBlobProperties(container, blob); - } - - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) - throws ServiceException { - return next.getBlobProperties(container, blob, options); - } - - public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { - return next.getBlobMetadata(container, blob); - } - - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) - throws ServiceException { - return next.getBlobMetadata(container, blob, options); - } - - public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { - return next.listBlobRegions(container, blob); - } - - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) - throws ServiceException { - return next.listBlobRegions(container, blob, options); - } - - public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { - return next.setBlobProperties(container, blob); - } - - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) - throws ServiceException { - return next.setBlobProperties(container, blob, options); - } - - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) - throws ServiceException { - return next.setBlobMetadata(container, blob, metadata); - } - - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, - SetBlobMetadataOptions options) throws ServiceException { - return next.setBlobMetadata(container, blob, metadata, options); - } - - public GetBlobResult getBlob(String container, String blob) throws ServiceException { - return next.getBlob(container, blob); - } - - public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { - return next.getBlob(container, blob, options); - } - - public void deleteBlob(String container, String blob) throws ServiceException { - next.deleteBlob(container, blob); - } - - public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { - next.deleteBlob(container, blob, options); - } - - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { - return next.createBlobSnapshot(container, blob); - } - - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) - throws ServiceException { - return next.createBlobSnapshot(container, blob, options); - } - - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) - throws ServiceException { - next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); - } - - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, - String sourceBlob, CopyBlobOptions options) throws ServiceException { - next.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); - } - - public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { - return next.acquireLease(container, blob); - } - - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) - throws ServiceException { - return next.acquireLease(container, blob, options); - } - - public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { - return next.renewLease(container, blob, leaseId); - } - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - return next.renewLease(container, blob, leaseId, options); +public class BlobService { + private BlobService() { } - public void releaseLease(String container, String blob, String leaseId) throws ServiceException { - next.releaseLease(container, blob, leaseId); + public static BlobContract create() { + return create(null, Configuration.getInstance()); } - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - next.releaseLease(container, blob, leaseId, options); + public static BlobContract create(Configuration config) { + return create(null, config); } - public void breakLease(String container, String blob, String leaseId) throws ServiceException { - next.breakLease(container, blob, leaseId); + public static BlobContract create(String profile) { + return create(profile, Configuration.getInstance()); } - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - next.breakLease(container, blob, leaseId, options); + public static BlobContract create(String profile, Configuration config) { + return config.create(profile, BlobContract.class); } -} +} \ 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 02d2b0389093f..78708846ea23b 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 @@ -97,7 +97,7 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); createContainers(service, testContainersPrefix, testContainers); } @@ -105,7 +105,7 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); deleteContainers(service, testContainersPrefix, testContainers); deleteContainers(service, createableContainersPrefix, creatableContainers); @@ -142,7 +142,7 @@ private static Set listContainers(BlobContract service, String prefix) t public void getServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobService service = new BlobService(config); + BlobContract service = BlobService.create(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -160,7 +160,7 @@ public void getServiceProppertiesWorks() throws Exception { public void setServiceProppertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -186,7 +186,7 @@ public void setServiceProppertiesWorks() throws Exception { public void createContainerWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createContainer(CREATEABLE_CONTAINER_1); @@ -198,7 +198,7 @@ public void createContainerWorks() throws Exception { public void createContainerWithMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createContainer(CREATEABLE_CONTAINER_2, new CreateContainerOptions().setPublicAccess("blob") @@ -249,7 +249,7 @@ public void createContainerWithMetadataWorks() throws Exception { public void setContainerMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createContainer(CREATEABLE_CONTAINER_3); @@ -276,7 +276,7 @@ public void setContainerMetadataWorks() throws Exception { public void setContainerACLWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); String container = CREATEABLE_CONTAINER_4; Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); @@ -310,7 +310,7 @@ public void setContainerACLWorks() throws Exception { public void listContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act ListContainersResult results = service.listContainers(); @@ -330,7 +330,7 @@ public void listContainersWorks() throws Exception { public void listContainersWithPaginationWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); @@ -353,7 +353,7 @@ public void listContainersWithPaginationWorks() throws Exception { public void listContainersWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix( @@ -379,7 +379,7 @@ public void listContainersWithPrefixWorks() throws Exception { public void workingWithRootContainersWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // // Ensure root container exists @@ -446,7 +446,7 @@ public void workingWithRootContainersWorks() throws Exception { public void listBlobsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); String[] blobNames = { "myblob1", "myblob2", "other-blob1", "other-blob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -468,7 +468,7 @@ public void listBlobsWorks() throws Exception { public void listBlobsWithPrefixWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -499,7 +499,7 @@ public void listBlobsWithPrefixWorks() throws Exception { public void listBlobsWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); String[] blobNames = { "myblob1", "myblob2", "otherblob1", "otherblob2" }; for (String blob : blobNames) { service.createPageBlob(TEST_CONTAINER_FOR_LISTING, blob, 512); @@ -522,7 +522,7 @@ public void listBlobsWithOptionsWorks() throws Exception { public void listBlobsWithDelimiterWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); 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); @@ -571,7 +571,7 @@ public void listBlobsWithDelimiterWorks() throws Exception { public void createPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512); @@ -583,7 +583,7 @@ public void createPageBlobWorks() throws Exception { public void createPageBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, @@ -620,7 +620,7 @@ public void createPageBlobWithOptionsWorks() throws Exception { public void clearBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -641,7 +641,7 @@ public void clearBlobPagesWorks() throws Exception { public void createBlobPagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -664,7 +664,7 @@ public void createBlobPagesWorks() throws Exception { public void listBlobRegionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -704,7 +704,7 @@ public void listBlobRegionsWorks() throws Exception { public void listBlobBlocksOnEmptyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -729,7 +729,7 @@ public void listBlobBlocksOnEmptyBlobWorks() throws Exception { public void listBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -763,7 +763,7 @@ public void listBlobBlocksWorks() throws Exception { public void listBlobBlocksWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -800,7 +800,7 @@ public void listBlobBlocksWithOptionsWorks() throws Exception { public void commitBlobBlocksWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -841,7 +841,7 @@ public void commitBlobBlocksWorks() throws Exception { public void createBlobBlockWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -858,7 +858,7 @@ public void createBlobBlockWorks() throws Exception { public void createBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream("some content".getBytes())); @@ -870,7 +870,7 @@ public void createBlockBlobWorks() throws Exception { public void createBlockBlobWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content"; @@ -908,7 +908,7 @@ public void createBlockBlobWithOptionsWorks() throws Exception { public void createBlobSnapshotWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -927,7 +927,7 @@ public void createBlobSnapshotWorks() throws Exception { public void createBlobSnapshotWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -953,7 +953,7 @@ public void createBlobSnapshotWithOptionsWorks() throws Exception { public void getBlockBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content"; @@ -992,7 +992,7 @@ public void getBlockBlobWorks() throws Exception { public void getPageBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, @@ -1029,7 +1029,7 @@ public void getPageBlobWorks() throws Exception { public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -1048,7 +1048,7 @@ public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -1068,7 +1068,7 @@ public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); @@ -1088,7 +1088,7 @@ public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1125,7 +1125,7 @@ public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception public void getBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1158,7 +1158,7 @@ public void getBlobPropertiesWorks() throws Exception { public void getBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1183,7 +1183,7 @@ public void getBlobMetadataWorks() throws Exception { public void setBlobPropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1225,7 +1225,7 @@ public void setBlobPropertiesWorks() throws Exception { public void setBlobMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String container = TEST_CONTAINER_FOR_BLOBS; @@ -1256,7 +1256,7 @@ public void setBlobMetadataWorks() throws Exception { public void deleteBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content"; @@ -1271,7 +1271,7 @@ public void deleteBlobWorks() throws Exception { public void copyBlobWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content2"; @@ -1302,7 +1302,7 @@ public void copyBlobWorks() throws Exception { public void acquireLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content2"; @@ -1318,7 +1318,7 @@ public void acquireLeaseWorks() throws Exception { public void renewLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content2"; @@ -1336,7 +1336,7 @@ public void renewLeaseWorks() throws Exception { public void breakLeaseWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); // Act String content = "some content2"; @@ -1352,6 +1352,7 @@ public void breakLeaseWorks() throws Exception { class RetryPolicyObserver implements ServiceFilter { public int requestCount; + @Override public Response handle(Request request, Next next) throws Exception { requestCount++; return next.handle(request); @@ -1362,7 +1363,7 @@ public Response handle(Request request, Next next) throws Exception { public void retryPolicyWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); @@ -1388,7 +1389,7 @@ public void retryPolicyWorks() throws Exception { public void retryPolicyCompositionWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - BlobContract service = config.create(BlobContract.class); + BlobContract service = BlobService.create(config); RetryPolicyObserver observer = new RetryPolicyObserver(); service = service.withFilter(observer); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 39dc038410a31..a1cae61b98525 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -1,45 +1,9 @@ package com.microsoft.windowsazure.services.blob; -import java.util.Map; - -import org.junit.Before; -import org.junit.BeforeClass; - import com.microsoft.windowsazure.services.core.Configuration; public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { - Configuration config = new Configuration(); - Map env = System.getenv(); - - // Storage emulator support - //setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "devstoreaccount1"); - //setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="); - //setConfigValue(config, env, BlobConfiguration.URL, "http://127.0.0.1:10000/devstoreaccount1"); - - // Storage account support - setConfigValue(config, env, BlobConfiguration.ACCOUNT_NAME, "xxx"); - setConfigValue(config, env, BlobConfiguration.ACCOUNT_KEY, "xxx"); - setConfigValue(config, env, BlobConfiguration.URL, "http://xxx.blob.core.windows.net"); - - 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"); - } - - @Before - public void initialize() throws Exception { - //System.out.println("initialize"); + return Configuration.getInstance(); } } diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index 5cb494f2985eb..5e9ea1140be4c 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -3,3 +3,6 @@ serviceBus.wrap.uri=https://%SERVICEBUS_NAMESPACE%-sb.accesscontrol.windows.net/ serviceBus.wrap.scope=http://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ serviceBus.wrap.name=%SERVICEBUS_SERVICEIDENTITY% serviceBus.wrap.password=%SERVICEBUS_SHAREDSECRET% +blob.accountName=%BLOB_ACCOUNTNAME% +blob.accountKey=%BLOB_ACCOUNTKEY% +blob.uri=http://%BLOB_ACCOUNTNAME%.blob.core.windows.net \ No newline at end of file From 0112357b8260571e44f031d7a82b313c73d6d5bf Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 22 Nov 2011 16:16:37 -0800 Subject: [PATCH 259/664] Fix unit tests --- .../microsoft/windowsazure/services/blob/BlobConfiguration.java | 2 +- .../java/com/microsoft/windowsazure/services/blob/Exports.java | 2 +- .../services/blob/implementation/BlobRestProxy.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java index 6e95bcc286b03..6ed6499297b9b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java @@ -3,5 +3,5 @@ public class BlobConfiguration { public final static String ACCOUNT_NAME = "blob.accountName"; public final static String ACCOUNT_KEY = "blob.accountKey"; - public final static String URL = "blob.url"; + public final static String URI = "blob.uri"; } 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 0012e70497d92..dfe339003643f 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,9 +7,9 @@ import com.microsoft.windowsazure.services.core.Builder; public class Exports implements Builder.Exports { + @Override public void register(Builder.Registry registry) { registry.add(BlobContract.class, BlobExceptionProcessor.class); - registry.add(BlobService.class); registry.add(BlobExceptionProcessor.class); registry.add(BlobRestProxy.class); registry.add(SharedKeyLiteFilter.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 6b6d70f073ddb..a555550a34d65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -75,7 +75,7 @@ public class BlobRestProxy implements BlobContract { @Inject public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, - @Named(BlobConfiguration.URL) String url, SharedKeyFilter filter) { + @Named(BlobConfiguration.URI) String url, SharedKeyFilter filter) { this.channel = channel; this.accountName = accountName; From 329280551614d2ab9372313c52b1c2ce77b705cf Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 22 Nov 2011 16:32:27 -0800 Subject: [PATCH 260/664] Update queue to new configuration/instantiation pattern Conflicts: microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java --- .../windowsazure/services/queue/Exports.java | 2 +- .../services/queue/QueueConfiguration.java | 2 +- .../services/queue/QueueService.java | 156 ++---------------- .../queue/implementation/QueueRestProxy.java | 2 +- .../services/queue/IntegrationTestBase.java | 37 +---- .../queue/QueueServiceIntegrationTest.java | 34 ++-- .../com.microsoft.windowsazure.properties | 5 +- 7 files changed, 35 insertions(+), 203 deletions(-) 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 c460c56b12d7d..ed6d83fbcaac4 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 @@ -7,9 +7,9 @@ import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; public class Exports implements Builder.Exports { + @Override public void register(Builder.Registry registry) { registry.add(QueueContract.class, QueueExceptionProcessor.class); - registry.add(QueueService.class); registry.add(QueueExceptionProcessor.class); registry.add(QueueRestProxy.class); registry.add(SharedKeyLiteFilter.class); 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 index 416de1f33adac..0cdf198caecda 100644 --- 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 @@ -3,5 +3,5 @@ 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"; + public final static String URI = "queue.uri"; } 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/QueueService.java index 119ae12615eb9..8c28a3fd9ab26 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/QueueService.java @@ -1,160 +1,24 @@ package com.microsoft.windowsazure.services.queue; -import java.util.HashMap; - -import javax.inject.Inject; - import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -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; -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 class QueueService implements QueueContract { - final QueueContract next; - - public QueueService() throws Exception { - this(null, Configuration.getInstance()); - } - - public QueueService(Configuration config) throws Exception { - this(null, config); - } - - public QueueService(String profile) throws Exception { - this(profile, Configuration.getInstance()); - } - - public QueueService(String profile, Configuration config) throws Exception { - next = config.create(profile, QueueContract.class); - } - - @Inject - public QueueService(QueueContract next) throws Exception { - this.next = next; - } - - public QueueContract withFilter(ServiceFilter filter) { - return next.withFilter(filter); - } - - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - return next.getServiceProperties(); - } - - public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { - return next.getServiceProperties(options); - } - - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - next.setServiceProperties(serviceProperties); - } - - public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) - throws ServiceException { - next.setServiceProperties(serviceProperties, options); - } - - public void createQueue(String queue) throws ServiceException { - next.createQueue(queue); - } - - public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { - next.createQueue(queue, options); - } - - public void deleteQueue(String queue) throws ServiceException { - next.deleteQueue(queue); - } - - public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { - next.deleteQueue(queue, options); - } - - public ListQueuesResult listQueues() throws ServiceException { - return next.listQueues(); - } - - public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - return next.listQueues(options); - } - - public GetQueueMetadataResult getQueueMetadata(String queue) throws ServiceException { - return next.getQueueMetadata(queue); - } - - public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { - return next.getQueueMetadata(queue, options); - } - - public void setQueueMetadata(String queue, HashMap metadata) throws ServiceException { - next.setQueueMetadata(queue, metadata); - } - - public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) - throws ServiceException { - next.setQueueMetadata(queue, metadata, options); - } - - public void createMessage(String queue, String messageText) throws ServiceException { - next.createMessage(queue, messageText); - } - - public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { - next.createMessage(queue, messageText, options); - } - - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, - int visibilityTimeoutInSeconds) throws ServiceException { - return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); - } - - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, - int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { - return next.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds, options); - } - - public void deleteMessage(String queue, String messageId, String popReceipt) throws ServiceException { - next.deleteMessage(queue, messageId, popReceipt); - } - - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) - throws ServiceException { - next.deleteMessage(queue, messageId, popReceipt, options); - } - - public ListMessagesResult listMessages(String queue) throws ServiceException { - return next.listMessages(queue); - } - public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { - return next.listMessages(queue, options); +public class QueueService { + private QueueService() { } - public PeekMessagesResult peekMessages(String queue) throws ServiceException { - return next.peekMessages(queue); + public static QueueContract create() { + return create(null, Configuration.getInstance()); } - public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { - return next.peekMessages(queue, options); + public static QueueContract create(Configuration config) { + return create(null, config); } - public void clearMessages(String queue) throws ServiceException { - next.clearMessages(queue); + public static QueueContract create(String profile) { + return create(profile, Configuration.getInstance()); } - public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { - next.clearMessages(queue, options); + public static QueueContract create(String profile, Configuration config) { + return config.create(profile, QueueContract.class); } } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index c130bb605cfcf..b1fab27845fcb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -45,7 +45,7 @@ public class QueueRestProxy implements QueueContract { @Inject public QueueRestProxy(HttpURLConnectionClient channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, - @Named(QueueConfiguration.URL) String url, SharedKeyFilter filter) { + @Named(QueueConfiguration.URI) String url, SharedKeyFilter filter) { this.channel = channel; this.accountName = accountName; 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 7f055859a616d..74c86164d4028 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 @@ -1,45 +1,10 @@ package com.microsoft.windowsazure.services.queue; -import java.util.Map; - -import org.junit.Before; -import org.junit.BeforeClass; - import com.microsoft.windowsazure.services.core.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"); - + Configuration config = Configuration.getInstance(); 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"); - } - - @Before - public void initialize() throws Exception { - System.out.println("initialize"); - } } 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 8301ddab56e43..52cf4ae5e00d0 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 @@ -73,7 +73,7 @@ public static void setup() throws Exception { // Create all test containers and their content Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); createQueues(service, testQueuesPrefix, testQueues); } @@ -81,7 +81,7 @@ public static void setup() throws Exception { @AfterClass public static void cleanup() throws Exception { Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); deleteQueues(service, testQueuesPrefix, testQueues); deleteQueues(service, createableQueuesPrefix, creatableQueues); @@ -118,7 +118,7 @@ private static Set listQueues(QueueContract service, String prefix) thro public void getServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueService service = new QueueService(config); + QueueContract service = QueueService.create(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -136,7 +136,7 @@ public void getServicePropertiesWorks() throws Exception { public void setServicePropertiesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -160,7 +160,7 @@ public void setServicePropertiesWorks() throws Exception { public void createQueueWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createQueue(CREATABLE_QUEUE_1); @@ -178,7 +178,7 @@ public void createQueueWorks() throws Exception { public void createQueueWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createQueue(CREATABLE_QUEUE_2, @@ -199,7 +199,7 @@ public void createQueueWithOptionsWorks() throws Exception { public void listQueuesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act ListQueuesResult result = service.listQueues(); @@ -217,7 +217,7 @@ public void listQueuesWorks() throws Exception { public void listQueuesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act ListQueuesResult result = service.listQueues(new ListQueuesOptions().setMaxResults(3).setPrefix( @@ -253,7 +253,7 @@ public void listQueuesWithOptionsWorks() throws Exception { public void setQueueMetadataWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createQueue(CREATABLE_QUEUE_3); @@ -280,7 +280,7 @@ public void setQueueMetadataWorks() throws Exception { public void createMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES, "message1"); @@ -295,7 +295,7 @@ public void createMessageWorks() throws Exception { public void listMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -333,7 +333,7 @@ public void listMessagesWorks() throws Exception { public void listMessagesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -373,7 +373,7 @@ public void listMessagesWithOptionsWorks() throws Exception { public void peekMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -408,7 +408,7 @@ public void peekMessagesWorks() throws Exception { public void peekMessagesWithOptionsWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); @@ -445,7 +445,7 @@ public void peekMessagesWithOptionsWorks() throws Exception { public void clearMessagesWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES_6, "message1"); @@ -465,7 +465,7 @@ public void clearMessagesWorks() throws Exception { public void deleteMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); // Act service.createMessage(TEST_QUEUE_FOR_MESSAGES_7, "message1"); @@ -488,7 +488,7 @@ public void deleteMessageWorks() throws Exception { public void updateMessageWorks() throws Exception { // Arrange Configuration config = createConfiguration(); - QueueContract service = config.create(QueueContract.class); + QueueContract service = QueueService.create(config); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2010, 01, 01); diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index 5e9ea1140be4c..b50e1d15ff441 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -5,4 +5,7 @@ serviceBus.wrap.name=%SERVICEBUS_SERVICEIDENTITY% serviceBus.wrap.password=%SERVICEBUS_SHAREDSECRET% blob.accountName=%BLOB_ACCOUNTNAME% blob.accountKey=%BLOB_ACCOUNTKEY% -blob.uri=http://%BLOB_ACCOUNTNAME%.blob.core.windows.net \ No newline at end of file +blob.uri=http://%BLOB_ACCOUNTNAME%.blob.core.windows.net +queue.accountName=%QUEUE_ACCOUNTNAME% +queue.accountKey=%QUEUE_ACCOUNTKEY% +queue.uri=http://%QUEUE_ACCOUNTNAME%.queue.core.windows.net \ No newline at end of file From 62ecf490e60f19319d4fdf4900e8af24de592564 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 14:35:20 -0800 Subject: [PATCH 261/664] Dynamically disable tests for features not supported by emulator --- .../services/blob/BlobServiceIntegrationTest.java | 10 ++++++++++ .../services/blob/IntegrationTestBase.java | 8 ++++++++ .../services/queue/IntegrationTestBase.java | 8 ++++++++ .../services/queue/QueueServiceIntegrationTest.java | 10 ++++++++++ 4 files changed, 36 insertions(+) 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 78708846ea23b..7f3e6026242a4 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 @@ -144,6 +144,11 @@ public void getServiceProppertiesWorks() throws Exception { Configuration config = createConfiguration(); BlobContract service = BlobService.create(config); + // Don't run this test with emulator, as v1.6 doesn't support this method + if (isRunningWithEmulator(config)) { + return; + } + // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -162,6 +167,11 @@ public void setServiceProppertiesWorks() throws Exception { Configuration config = createConfiguration(); BlobContract service = BlobService.create(config); + // Don't run this test with emulator, as v1.6 doesn't support this method + if (isRunningWithEmulator(config)) { + return; + } + // Act ServiceProperties props = service.getServiceProperties().getValue(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index a1cae61b98525..96a24e1cdf1b5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -6,4 +6,12 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { return Configuration.getInstance(); } + + protected static boolean isRunningWithEmulator(Configuration config) { + String accountName = "devstoreaccount1"; + String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; + + return accountName.equals(config.getProperty(BlobConfiguration.ACCOUNT_NAME)) + && accountKey.equals(config.getProperty(BlobConfiguration.ACCOUNT_NAME)); + } } 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 74c86164d4028..d2bc4885bd9c8 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 @@ -7,4 +7,12 @@ protected static Configuration createConfiguration() { Configuration config = Configuration.getInstance(); return config; } + + protected static boolean isRunningWithEmulator(Configuration config) { + String accountName = "devstoreaccount1"; + String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; + + return accountName.equals(config.getProperty(QueueConfiguration.ACCOUNT_NAME)) + && accountKey.equals(config.getProperty(QueueConfiguration.ACCOUNT_NAME)); + } } 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 52cf4ae5e00d0..8d57edd746115 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 @@ -120,6 +120,11 @@ public void getServicePropertiesWorks() throws Exception { Configuration config = createConfiguration(); QueueContract service = QueueService.create(config); + // Don't run this test with emulator, as v1.6 doesn't support this method + if (isRunningWithEmulator(config)) { + return; + } + // Act ServiceProperties props = service.getServiceProperties().getValue(); @@ -138,6 +143,11 @@ public void setServicePropertiesWorks() throws Exception { Configuration config = createConfiguration(); QueueContract service = QueueService.create(config); + // Don't run this test with emulator, as v1.6 doesn't support this method + if (isRunningWithEmulator(config)) { + return; + } + // Act ServiceProperties props = service.getServiceProperties().getValue(); From 7f4fd0cb4dd4522c1effaf8631cd4b01a8f15202 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 28 Nov 2011 15:46:24 -0800 Subject: [PATCH 262/664] Updating name of services file. Fixes #129 Also updating the unit tests' expectations because the SBS class is no longer returned as a SBC implementation. --- ...m.microsoft.windowsazure.services.core.Builder$Exports} | 0 .../services/serviceBus/ServiceBusCreationTest.java | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) rename microsoft-azure-api/src/main/resources/META-INF/services/{com.microsoft.windowsazure.common.Builder$Exports => com.microsoft.windowsazure.services.core.Builder$Exports} (100%) diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports similarity index 100% rename from microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.common.Builder$Exports rename to microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index e31cf1db576ab..c88c694d5d8f3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor; public class ServiceBusCreationTest { @Test @@ -13,7 +14,7 @@ public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Excep ServiceBusContract service = ServiceBusService.create(); assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); + assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); } public Configuration newConfiguration() { @@ -28,7 +29,7 @@ public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { ServiceBusContract service = ServiceBusService.create(config); assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); + assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); } @Test @@ -37,7 +38,7 @@ public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { ServiceBusContract service = config.create(ServiceBusContract.class); assertNotNull(service); - assertEquals(ServiceBusService.class, service.getClass()); + assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); } @Test From b2e55bbb5e22b31f8586b41ee19e180d841918d0 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 17:13:16 -0800 Subject: [PATCH 263/664] Fix typo to fix integration tests running on emulator. --- .../windowsazure/services/blob/IntegrationTestBase.java | 2 +- .../windowsazure/services/queue/IntegrationTestBase.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 96a24e1cdf1b5..27d923a6d1ca4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -12,6 +12,6 @@ protected static boolean isRunningWithEmulator(Configuration config) { String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; return accountName.equals(config.getProperty(BlobConfiguration.ACCOUNT_NAME)) - && accountKey.equals(config.getProperty(BlobConfiguration.ACCOUNT_NAME)); + && accountKey.equals(config.getProperty(BlobConfiguration.ACCOUNT_KEY)); } } 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 d2bc4885bd9c8..0427ce0af9672 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 @@ -4,8 +4,7 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { - Configuration config = Configuration.getInstance(); - return config; + return Configuration.getInstance(); } protected static boolean isRunningWithEmulator(Configuration config) { @@ -13,6 +12,6 @@ protected static boolean isRunningWithEmulator(Configuration config) { String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; return accountName.equals(config.getProperty(QueueConfiguration.ACCOUNT_NAME)) - && accountKey.equals(config.getProperty(QueueConfiguration.ACCOUNT_NAME)); + && accountKey.equals(config.getProperty(QueueConfiguration.ACCOUNT_KEY)); } } From 3ecdc12fefd993716a4b029cf7ecdc6e0f5e6a9d Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 17:37:13 -0800 Subject: [PATCH 264/664] Enable integration tests to be configured via environment variables --- .../services/blob/IntegrationTestBase.java | 14 +++++++++++++- .../services/queue/IntegrationTestBase.java | 14 +++++++++++++- .../serviceBus/ServiceBusIntegrationTest.java | 17 ++++++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 27d923a6d1ca4..38a8bbb53a9ef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -4,7 +4,19 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { - return Configuration.getInstance(); + Configuration config = Configuration.getInstance(); + OverrideWithEnv(config, BlobConfiguration.ACCOUNT_NAME); + OverrideWithEnv(config, BlobConfiguration.ACCOUNT_KEY); + OverrideWithEnv(config, BlobConfiguration.URI); + return config; + } + + private static void OverrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); } protected static boolean isRunningWithEmulator(Configuration config) { 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 0427ce0af9672..c2625f30896ab 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 @@ -4,7 +4,19 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { - return Configuration.getInstance(); + Configuration config = Configuration.getInstance(); + OverrideWithEnv(config, QueueConfiguration.ACCOUNT_NAME); + OverrideWithEnv(config, QueueConfiguration.ACCOUNT_KEY); + OverrideWithEnv(config, QueueConfiguration.URI); + return config; + } + + private static void OverrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); } protected static boolean isRunningWithEmulator(Configuration config) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 7a09bcc66bb56..cf48e4febf3b5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -10,6 +10,7 @@ import org.junit.Before; import org.junit.Test; +import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.ServiceFilter.Request; @@ -35,7 +36,21 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { @Before public void createService() throws Exception { - service = ServiceBusService.create(); + Configuration config = Configuration.getInstance(); + OverrideWithEnv(config, ServiceBusConfiguration.URI); + OverrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); + OverrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); + OverrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); + OverrideWithEnv(config, ServiceBusConfiguration.WRAP_SCOPE); + service = ServiceBusService.create(config); + } + + private static void OverrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); } @Test From a17bcb6b2c60e0757bec473810a58eb06079c6e1 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 17:51:03 -0800 Subject: [PATCH 265/664] Make interface fluent. Fixes #130 --- .../services/blob/models/CreateBlobBlockOptions.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 8db0409f202dd..266b6ac154188 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 @@ -8,15 +8,17 @@ public String getLeaseId() { return leaseId; } - public void setLeaseId(String leaseId) { + public CreateBlobBlockOptions setLeaseId(String leaseId) { this.leaseId = leaseId; + return this; } public String getContentMD5() { return contentMD5; } - public void setContentMD5(String contentMD5) { + public CreateBlobBlockOptions setContentMD5(String contentMD5) { this.contentMD5 = contentMD5; + return this; } } From 082d36173a9a7e70614c90fe4895fa73dcf043a2 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 18:41:39 -0800 Subject: [PATCH 266/664] Override "SetTimeout" method in all derived classes Fixes #100 --- .../services/blob/models/AcquireLeaseOptions.java | 7 +++++++ .../services/blob/models/CommitBlobBlocksOptions.java | 6 ++++++ .../windowsazure/services/blob/models/CopyBlobOptions.java | 6 ++++++ .../services/blob/models/CreateBlobBlockOptions.java | 6 ++++++ .../services/blob/models/CreateBlobOptions.java | 6 ++++++ .../services/blob/models/CreateBlobPagesOptions.java | 6 ++++++ .../services/blob/models/CreateBlobSnapshotOptions.java | 6 ++++++ .../services/blob/models/CreateContainerOptions.java | 6 ++++++ .../services/blob/models/DeleteBlobOptions.java | 6 ++++++ .../services/blob/models/DeleteContainerOptions.java | 6 ++++++ .../services/blob/models/GetBlobMetadataOptions.java | 6 ++++++ .../windowsazure/services/blob/models/GetBlobOptions.java | 6 ++++++ .../services/blob/models/GetBlobPropertiesOptions.java | 6 ++++++ .../services/blob/models/ListBlobBlocksOptions.java | 6 ++++++ .../services/blob/models/ListBlobRegionsOptions.java | 6 ++++++ .../services/blob/models/ListBlobsOptions.java | 6 ++++++ .../services/blob/models/ListContainersOptions.java | 6 ++++++ .../services/blob/models/SetBlobMetadataOptions.java | 6 ++++++ .../services/blob/models/SetBlobPropertiesOptions.java | 6 ++++++ .../services/blob/models/SetContainerMetadataOptions.java | 6 ++++++ .../services/queue/models/CreateMessageOptions.java | 6 ++++++ .../services/queue/models/CreateQueueOptions.java | 6 ++++++ .../services/queue/models/ListMessagesOptions.java | 6 ++++++ .../services/queue/models/ListQueuesOptions.java | 6 ++++++ .../services/queue/models/PeekMessagesOptions.java | 6 ++++++ 25 files changed, 151 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java index 8277f48ad66f7..3dbdac8b24071 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java @@ -1,8 +1,15 @@ package com.microsoft.windowsazure.services.blob.models; + public class AcquireLeaseOptions extends BlobServiceOptions { private AccessCondition accessCondition; + @Override + public AcquireLeaseOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public AccessCondition getAccessCondition() { return accessCondition; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java index aee99e1660591..2b4cf162a052e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java @@ -12,6 +12,12 @@ public class CommitBlobBlocksOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; + @Override + public CommitBlobBlocksOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getBlobContentType() { return blobContentType; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java index 39353082ad29d..80f4b9181b1f2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java @@ -10,6 +10,12 @@ public class CopyBlobOptions extends BlobServiceOptions { private HashMap metadata = new HashMap(); private AccessCondition sourceAccessCondition; + @Override + public CopyBlobOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getSourceSnapshot() { return sourceSnapshot; } 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 8db0409f202dd..16f1141ec1931 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 @@ -4,6 +4,12 @@ public class CreateBlobBlockOptions extends BlobServiceOptions { private String leaseId; private String contentMD5; + @Override + public CreateBlobBlockOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getLeaseId() { return leaseId; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java index e8fda3f7a0fd6..1ab6a08a219b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java @@ -18,6 +18,12 @@ public class CreateBlobOptions extends BlobServiceOptions { private Long sequenceNumber; private AccessCondition accessCondition; + @Override + public CreateBlobOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getContentType() { return contentType; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java index 3418ae2bc76c8..ec75899e6aff2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java @@ -5,6 +5,12 @@ public class CreateBlobPagesOptions extends BlobServiceOptions { private String contentMD5; private AccessCondition accessCondition; + @Override + public CreateBlobPagesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getLeaseId() { return leaseId; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java index faf82305c6194..0294ae990645e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java @@ -7,6 +7,12 @@ public class CreateBlobSnapshotOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; + @Override + public CreateBlobSnapshotOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public HashMap getMetadata() { return metadata; } 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 7f7ceee8c31f1..779768fee545b 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 @@ -6,6 +6,12 @@ public class CreateContainerOptions extends BlobServiceOptions { private String publicAccess; private HashMap metadata = new HashMap(); + @Override + public CreateContainerOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public HashMap getMetadata() { return metadata; } 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 100c1704bea70..4bf3193a285fb 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 @@ -6,6 +6,12 @@ public class DeleteBlobOptions extends BlobServiceOptions { private boolean deleteSnaphotsOnly; private AccessCondition accessCondition; + @Override + public DeleteBlobOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getSnapshot() { return snapshot; } 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 ced65b0ce1f36..8cac4596758fc 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 @@ -3,6 +3,12 @@ public class DeleteContainerOptions extends BlobServiceOptions { private AccessCondition accessCondition; + @Override + public DeleteContainerOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public AccessCondition getAccessCondition() { return accessCondition; } 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 14044ffaec541..17b9ce55fa6e3 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 @@ -5,6 +5,12 @@ public class GetBlobMetadataOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; + @Override + public GetBlobMetadataOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getSnapshot() { return snapshot; } 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 56a55fe6a6001..525fec627591f 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 @@ -8,6 +8,12 @@ public class GetBlobOptions extends BlobServiceOptions { private Long rangeEnd; private AccessCondition accessCondition; + @Override + public GetBlobOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getSnapshot() { return snapshot; } 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 7e70cf5192320..4ff1b44978203 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 @@ -5,6 +5,12 @@ public class GetBlobPropertiesOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; + @Override + public GetBlobPropertiesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getSnapshot() { return snapshot; } 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 4c26fd7d34cf4..cb4dcbd0b2701 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 @@ -6,6 +6,12 @@ public class ListBlobBlocksOptions extends BlobServiceOptions { private boolean committedList; private boolean uncommittedList; + @Override + public ListBlobBlocksOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getLeaseId() { return leaseId; } 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 dfb99b5158d93..e4c979ce2f2c7 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 @@ -7,6 +7,12 @@ public class ListBlobRegionsOptions extends BlobServiceOptions { private Long rangeEnd; private AccessCondition accessCondition; + @Override + public ListBlobRegionsOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getLeaseId() { return leaseId; } 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 f28765a27172f..6c8f9e8b485ac 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 @@ -9,6 +9,12 @@ public class ListBlobsOptions extends BlobServiceOptions { private boolean includeSnapshots; private boolean includeUncommittedBlobs; + @Override + public ListBlobsOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getPrefix() { return prefix; } 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 0b4f74d686a9c..8901655e81be2 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 @@ -6,6 +6,12 @@ public class ListContainersOptions extends BlobServiceOptions { private int maxResults; private boolean includeMetadata; + @Override + public ListContainersOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getPrefix() { return prefix; } 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 9fe24273ae53f..7f2f7894ece51 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 @@ -4,6 +4,12 @@ public class SetBlobMetadataOptions extends BlobServiceOptions { private String leaseId; private AccessCondition accessCondition; + @Override + public SetBlobMetadataOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getLeaseId() { return leaseId; } 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 3171956874bbf..669de8429d6c6 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 @@ -12,6 +12,12 @@ public class SetBlobPropertiesOptions extends BlobServiceOptions { private Long sequenceNumber; private AccessCondition accessCondition; + @Override + public SetBlobPropertiesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getContentType() { return contentType; } 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 237f3991c7aed..cb6ec42d067e3 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 @@ -3,6 +3,12 @@ public class SetContainerMetadataOptions extends BlobServiceOptions { private AccessCondition accessCondition; + @Override + public SetContainerMetadataOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public AccessCondition getAccessCondition() { return accessCondition; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java index b68ae53dc8530..fea533738f4ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java @@ -4,6 +4,12 @@ public class CreateMessageOptions extends QueueServiceOptions { private Integer visibilityTimeoutInSeconds; private Integer timeToLiveInSeconds; + @Override + public CreateMessageOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public Integer getVisibilityTimeoutInSeconds() { return visibilityTimeoutInSeconds; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java index 6decb3b2be33a..630677006b1fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java @@ -5,6 +5,12 @@ public class CreateQueueOptions extends QueueServiceOptions { private HashMap metadata = new HashMap(); + @Override + public CreateQueueOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public HashMap getMetadata() { return metadata; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java index e7bbd55fc3d39..b4a7e92e8d640 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java @@ -4,6 +4,12 @@ public class ListMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; private Integer visibilityTimeoutInSeconds; + @Override + public ListMessagesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public Integer getNumberOfMessages() { return numberOfMessages; } 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 0d44721c235fc..c4b7d93726a15 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 @@ -6,6 +6,12 @@ public class ListQueuesOptions extends QueueServiceOptions { private int maxResults; private boolean includeMetadata; + @Override + public ListQueuesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public String getPrefix() { return prefix; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java index 5bdde6fcbd5cd..46809815dd1b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java @@ -3,6 +3,12 @@ public class PeekMessagesOptions extends QueueServiceOptions { private Integer numberOfMessages; + @Override + public PeekMessagesOptions setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } + public Integer getNumberOfMessages() { return numberOfMessages; } From 6532d3f3fe491872ac3d47c42f8e9595cb5d8d98 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 18:56:59 -0800 Subject: [PATCH 267/664] Fix method casing --- .../services/blob/IntegrationTestBase.java | 8 ++++---- .../services/queue/IntegrationTestBase.java | 8 ++++---- .../serviceBus/ServiceBusIntegrationTest.java | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 38a8bbb53a9ef..883b252a65d43 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -5,13 +5,13 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { Configuration config = Configuration.getInstance(); - OverrideWithEnv(config, BlobConfiguration.ACCOUNT_NAME); - OverrideWithEnv(config, BlobConfiguration.ACCOUNT_KEY); - OverrideWithEnv(config, BlobConfiguration.URI); + overrideWithEnv(config, BlobConfiguration.ACCOUNT_NAME); + overrideWithEnv(config, BlobConfiguration.ACCOUNT_KEY); + overrideWithEnv(config, BlobConfiguration.URI); return config; } - private static void OverrideWithEnv(Configuration config, String key) { + private static void overrideWithEnv(Configuration config, String key) { String value = System.getenv(key); if (value == null) return; 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 c2625f30896ab..ac7948d856139 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 @@ -5,13 +5,13 @@ public abstract class IntegrationTestBase { protected static Configuration createConfiguration() { Configuration config = Configuration.getInstance(); - OverrideWithEnv(config, QueueConfiguration.ACCOUNT_NAME); - OverrideWithEnv(config, QueueConfiguration.ACCOUNT_KEY); - OverrideWithEnv(config, QueueConfiguration.URI); + overrideWithEnv(config, QueueConfiguration.ACCOUNT_NAME); + overrideWithEnv(config, QueueConfiguration.ACCOUNT_KEY); + overrideWithEnv(config, QueueConfiguration.URI); return config; } - private static void OverrideWithEnv(Configuration config, String key) { + private static void overrideWithEnv(Configuration config, String key) { String value = System.getenv(key); if (value == null) return; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index cf48e4febf3b5..52722d3de4fcb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -37,15 +37,15 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { @Before public void createService() throws Exception { Configuration config = Configuration.getInstance(); - OverrideWithEnv(config, ServiceBusConfiguration.URI); - OverrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); - OverrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); - OverrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); - OverrideWithEnv(config, ServiceBusConfiguration.WRAP_SCOPE); + overrideWithEnv(config, ServiceBusConfiguration.URI); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_SCOPE); service = ServiceBusService.create(config); } - private static void OverrideWithEnv(Configuration config, String key) { + private static void overrideWithEnv(Configuration config, String key) { String value = System.getenv(key); if (value == null) return; From a201fa3dae6f046c5d20f0ae60a90dc69dc4b2cf Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 28 Nov 2011 20:55:50 -0800 Subject: [PATCH 268/664] Remove "empty" overload of setBlobProperties The method is technically correct, but sort of meaningless, as the overload with the "Options" parameters always makes more sense. Fixes #76 --- .../services/blob/BlobContract.java | 2 - .../BlobExceptionProcessor.java | 76 +++++++++++++++---- .../blob/implementation/BlobRestProxy.java | 66 +++++++++++++++- 3 files changed, 125 insertions(+), 19 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index 4e7a4104bbe5c..c471fa9cf6648 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -145,8 +145,6 @@ GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMeta ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException; - SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException; - SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 297ba2e8db758..8b64fcd7fddf9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -21,6 +21,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; @@ -30,7 +31,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.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; @@ -68,6 +68,7 @@ public BlobExceptionProcessor(BlobContract service) { this.service = service; } + @Override public BlobContract withFilter(ServiceFilter filter) { return new BlobExceptionProcessor(service.withFilter(filter)); } @@ -77,6 +78,7 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("blob", e); } + @Override public GetServicePropertiesResult getServiceProperties() throws ServiceException { try { return service.getServiceProperties(); @@ -89,6 +91,7 @@ public GetServicePropertiesResult getServiceProperties() throws ServiceException } } + @Override public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { try { return service.getServiceProperties(options); @@ -101,6 +104,7 @@ public GetServicePropertiesResult getServiceProperties(BlobServiceOptions option } } + @Override public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException { try { @@ -114,6 +118,7 @@ public void setServiceProperties(ServiceProperties serviceProperties, BlobServic } } + @Override public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { try { service.setServiceProperties(serviceProperties); @@ -126,6 +131,7 @@ public void setServiceProperties(ServiceProperties serviceProperties) throws Ser } } + @Override public ListContainersResult listContainers() throws ServiceException { try { return service.listContainers(); @@ -138,6 +144,7 @@ public ListContainersResult listContainers() throws ServiceException { } } + @Override public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { try { return service.listContainers(options); @@ -150,6 +157,7 @@ public ListContainersResult listContainers(ListContainersOptions options) throws } } + @Override public void createContainer(String container) throws ServiceException { try { service.createContainer(container); @@ -162,6 +170,7 @@ public void createContainer(String container) throws ServiceException { } } + @Override public void createContainer(String container, CreateContainerOptions options) throws ServiceException { try { service.createContainer(container, options); @@ -174,6 +183,7 @@ public void createContainer(String container, CreateContainerOptions options) th } } + @Override public void deleteContainer(String container) throws ServiceException { try { service.deleteContainer(container); @@ -186,6 +196,7 @@ public void deleteContainer(String container) throws ServiceException { } } + @Override public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { try { service.deleteContainer(container, options); @@ -198,6 +209,7 @@ public void deleteContainer(String container, DeleteContainerOptions options) th } } + @Override public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { try { return service.getContainerProperties(container); @@ -210,6 +222,7 @@ public GetContainerPropertiesResult getContainerProperties(String container) thr } } + @Override public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException { try { @@ -223,6 +236,7 @@ public GetContainerPropertiesResult getContainerProperties(String container, Blo } } + @Override public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { try { return service.getContainerMetadata(container); @@ -235,6 +249,7 @@ public GetContainerPropertiesResult getContainerMetadata(String container) throw } } + @Override public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException { try { @@ -248,6 +263,7 @@ public GetContainerPropertiesResult getContainerMetadata(String container, BlobS } } + @Override public GetContainerACLResult getContainerACL(String container) throws ServiceException { try { return service.getContainerACL(container); @@ -260,6 +276,7 @@ public GetContainerACLResult getContainerACL(String container) throws ServiceExc } } + @Override public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { try { return service.getContainerACL(container, options); @@ -272,6 +289,7 @@ public GetContainerACLResult getContainerACL(String container, BlobServiceOption } } + @Override public void setContainerACL(String container, ContainerACL acl) throws ServiceException { try { service.setContainerACL(container, acl); @@ -284,6 +302,7 @@ public void setContainerACL(String container, ContainerACL acl) throws ServiceEx } } + @Override public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { try { service.setContainerACL(container, acl, options); @@ -296,6 +315,7 @@ public void setContainerACL(String container, ContainerACL acl, BlobServiceOptio } } + @Override public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { try { service.setContainerMetadata(container, metadata); @@ -308,6 +328,7 @@ public void setContainerMetadata(String container, HashMap metad } } + @Override public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { try { @@ -321,6 +342,7 @@ public void setContainerMetadata(String container, HashMap metad } } + @Override public ListBlobsResult listBlobs(String container) throws ServiceException { try { return service.listBlobs(container); @@ -333,6 +355,7 @@ public ListBlobsResult listBlobs(String container) throws ServiceException { } } + @Override public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { try { return service.listBlobs(container, options); @@ -345,6 +368,7 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) thr } } + @Override public void createPageBlob(String container, String blob, int length) throws ServiceException { try { service.createPageBlob(container, blob, length); @@ -357,6 +381,7 @@ public void createPageBlob(String container, String blob, int length) throws Ser } } + @Override public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { try { @@ -370,6 +395,7 @@ public void createPageBlob(String container, String blob, int length, CreateBlob } } + @Override public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { try { service.createBlockBlob(container, blob, contentStream); @@ -382,6 +408,7 @@ public void createBlockBlob(String container, String blob, InputStream contentSt } } + @Override public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { try { @@ -395,6 +422,7 @@ public void createBlockBlob(String container, String blob, InputStream contentSt } } + @Override public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { try { return service.clearBlobPages(container, blob, range); @@ -407,6 +435,7 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR } } + @Override public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { try { @@ -420,6 +449,7 @@ public CreateBlobPagesResult clearBlobPages(String container, String blob, PageR } } + @Override public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) throws ServiceException { try { @@ -433,6 +463,7 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, Page } } + @Override public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { try { @@ -446,6 +477,7 @@ public CreateBlobPagesResult createBlobPages(String container, String blob, Page } } + @Override public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { try { @@ -459,6 +491,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input } } + @Override public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException { try { @@ -472,6 +505,7 @@ public void createBlobBlock(String container, String blob, String blockId, Input } } + @Override public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { try { service.commitBlobBlocks(container, blob, blockList); @@ -484,6 +518,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList) } } + @Override public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { try { @@ -497,6 +532,7 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList, } } + @Override public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { try { return service.listBlobBlocks(container, blob); @@ -509,6 +545,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws } } + @Override public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { try { @@ -522,6 +559,7 @@ public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBl } } + @Override public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { try { return service.getBlobProperties(container, blob); @@ -534,6 +572,7 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob) } } + @Override public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { try { @@ -547,6 +586,7 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob, } } + @Override public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { try { return service.getBlobMetadata(container, blob); @@ -559,6 +599,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob) thro } } + @Override public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { try { @@ -572,6 +613,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetB } } + @Override public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { try { return service.listBlobRegions(container, blob); @@ -584,6 +626,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob) thro } } + @Override public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { try { @@ -597,6 +640,7 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List } } + @Override public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { try { @@ -610,18 +654,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, } } - public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { - try { - return service.setBlobProperties(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - + @Override public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { try { @@ -635,6 +668,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash } } + @Override public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) throws ServiceException { try { @@ -648,6 +682,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash } } + @Override public GetBlobResult getBlob(String container, String blob) throws ServiceException { try { return service.getBlob(container, blob); @@ -660,6 +695,7 @@ public GetBlobResult getBlob(String container, String blob) throws ServiceExcept } } + @Override public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { try { return service.getBlob(container, blob, options); @@ -672,6 +708,7 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio } } + @Override public void deleteBlob(String container, String blob) throws ServiceException { try { service.deleteBlob(container, blob); @@ -684,6 +721,7 @@ public void deleteBlob(String container, String blob) throws ServiceException { } } + @Override public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { try { service.deleteBlob(container, blob, options); @@ -696,6 +734,7 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) } } + @Override public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { try { return service.createBlobSnapshot(container, blob); @@ -708,6 +747,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob } } + @Override public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { try { @@ -721,6 +761,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob } } + @Override public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { try { @@ -734,6 +775,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } } + @Override public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) throws ServiceException { try { @@ -747,6 +789,7 @@ public void copyBlob(String destinationContainer, String destinationBlob, String } } + @Override public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { try { return service.acquireLease(container, blob); @@ -759,6 +802,7 @@ public AcquireLeaseResult acquireLease(String container, String blob) throws Ser } } + @Override public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { try { @@ -772,6 +816,7 @@ public AcquireLeaseResult acquireLease(String container, String blob, AcquireLea } } + @Override public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { try { return service.renewLease(container, blob, leaseId); @@ -784,6 +829,7 @@ public AcquireLeaseResult renewLease(String container, String blob, String lease } } + @Override public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { try { @@ -797,6 +843,7 @@ public AcquireLeaseResult renewLease(String container, String blob, String lease } } + @Override public void releaseLease(String container, String blob, String leaseId) throws ServiceException { try { service.releaseLease(container, blob, leaseId); @@ -809,6 +856,7 @@ public void releaseLease(String container, String blob, String leaseId) throws S } } + @Override public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { try { @@ -822,6 +870,7 @@ public void releaseLease(String container, String blob, String leaseId, BlobServ } } + @Override public void breakLease(String container, String blob, String leaseId) throws ServiceException { try { service.breakLease(container, blob, leaseId); @@ -834,6 +883,7 @@ public void breakLease(String container, String blob, String leaseId) throws Ser } } + @Override public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { try { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index a555550a34d65..446a98ebfb7a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -97,6 +97,7 @@ public BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, St this.dateMapper = dateMapper; } + @Override public BlobContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; @@ -238,10 +239,12 @@ private String getCopyBlobSourceName(String sourceContainer, String sourceBlob, return sourceName; } + @Override public GetServicePropertiesResult getServiceProperties() throws ServiceException { return getServiceProperties(new BlobServiceOptions()); } + @Override public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service") .queryParam("comp", "properties"); @@ -253,10 +256,12 @@ public GetServicePropertiesResult getServiceProperties(BlobServiceOptions option return result; } + @Override public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { setServiceProperties(serviceProperties, new BlobServiceOptions()); } + @Override public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("resType", "service") @@ -267,10 +272,12 @@ public void setServiceProperties(ServiceProperties serviceProperties, BlobServic builder.put(serviceProperties); } + @Override public void createContainer(String container) throws ServiceException { createContainer(container, new CreateContainerOptions()); } + @Override public void createContainer(String container, CreateContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); @@ -281,10 +288,12 @@ public void createContainer(String container, CreateContainerOptions options) th builder.put(); } + @Override public void deleteContainer(String container) throws ServiceException { deleteContainer(container, new DeleteContainerOptions()); } + @Override public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); @@ -294,19 +303,23 @@ public void deleteContainer(String container, DeleteContainerOptions options) th builder.delete(); } + @Override public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { return getContainerProperties(container, new BlobServiceOptions()); } + @Override public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) throws ServiceException { return getContainerPropertiesImpl(container, options, null); } + @Override public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { return getContainerMetadata(container, new BlobServiceOptions()); } + @Override public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) throws ServiceException { return getContainerPropertiesImpl(container, options, "metadata"); @@ -330,10 +343,12 @@ private GetContainerPropertiesResult getContainerPropertiesImpl(String container return properties; } + @Override public GetContainerACLResult getContainerACL(String container) throws ServiceException { return getContainerACL(container, new BlobServiceOptions()); } + @Override public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container") .queryParam("comp", "acl"); @@ -363,10 +378,12 @@ else if ("blob".equals(response.getHeaders().getFirst("x-ms-blob-public-access") return result; } + @Override public void setContainerACL(String container, ContainerACL acl) throws ServiceException { setContainerACL(container, acl, new BlobServiceOptions()); } + @Override public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container") .queryParam("comp", "acl"); @@ -385,10 +402,12 @@ else if (acl.getPublicAccess() == PublicAccessType.CONTAINER_AND_BLOBS) { builder.put(si); } + @Override public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); } + @Override public void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("resType", "container") @@ -401,10 +420,12 @@ public void setContainerMetadata(String container, HashMap metad builder.put(); } + @Override public ListContainersResult listContainers() throws ServiceException { return listContainers(new ListContainersOptions()); } + @Override public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); @@ -417,10 +438,12 @@ public ListContainersResult listContainers(ListContainersOptions options) throws return builder.get(ListContainersResult.class); } + @Override public ListBlobsResult listBlobs(String container) throws ServiceException { return listBlobs(container, new ListBlobsOptions()); } + @Override public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).queryParam("comp", "list") .queryParam("resType", "container"); @@ -435,10 +458,12 @@ public ListBlobsResult listBlobs(String container, ListBlobsOptions options) thr return builder.get(ListBlobsResult.class); } + @Override public void createPageBlob(String container, String blob, int length) throws ServiceException { createPageBlob(container, blob, length, new CreateBlobOptions()); } + @Override public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); @@ -453,10 +478,12 @@ public void createPageBlob(String container, String blob, int length, CreateBlob builder.put(); } + @Override public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); } + @Override public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); @@ -470,10 +497,12 @@ public void createBlockBlob(String container, String blob, InputStream contentSt builder.put(contentObject); } + @Override public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); } + @Override public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); @@ -489,10 +518,12 @@ public GetBlobPropertiesResult getBlobProperties(String container, String blob, return getBlobPropertiesResultFromResponse(response); } + @Override public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); } + @Override public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); @@ -513,10 +544,7 @@ public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetB return properties; } - public SetBlobPropertiesResult setBlobProperties(String container, String blob) throws ServiceException { - return setBlobProperties(container, blob, new SetBlobPropertiesOptions()); - } - + @Override public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "properties"); @@ -547,11 +575,13 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, return result; } + @Override public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) throws ServiceException { return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); } + @Override public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, SetBlobMetadataOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); @@ -570,10 +600,12 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash return result; } + @Override public GetBlobResult getBlob(String container, String blob) throws ServiceException { return getBlob(container, blob, new GetBlobOptions()); } + @Override public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); @@ -594,10 +626,12 @@ public GetBlobResult getBlob(String container, String blob, GetBlobOptions optio return blobResult; } + @Override public void deleteBlob(String container, String blob) throws ServiceException { deleteBlob(container, blob, new DeleteBlobOptions()); } + @Override public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob); webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); @@ -611,10 +645,12 @@ public void deleteBlob(String container, String blob, DeleteBlobOptions options) builder.delete(); } + @Override public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); } + @Override public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container + "/" + blob).queryParam("comp", "snapshot"); @@ -635,11 +671,13 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob return blobSnapshot; } + @Override public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) throws ServiceException { copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); } + @Override public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, CopyBlobOptions options) { WebResource webResource = getResource(options).path(destinationContainer).path(destinationBlob); @@ -656,37 +694,45 @@ public void copyBlob(String destinationContainer, String destinationBlob, String builder.put(); } + @Override public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { return acquireLease(container, blob, new AcquireLeaseOptions()); } + @Override public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException { return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); } + @Override public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { return renewLease(container, blob, leaseId, new BlobServiceOptions()); } + @Override public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); } + @Override public void releaseLease(String container, String blob, String leaseId) throws ServiceException { releaseLease(container, blob, leaseId, new BlobServiceOptions()); } + @Override public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); } + @Override public void breakLease(String container, String blob, String leaseId) throws ServiceException { breakLease(container, blob, leaseId, new BlobServiceOptions()); } + @Override public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); @@ -710,20 +756,24 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St return result; } + @Override public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); } + @Override public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) throws ServiceException { return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); } + @Override public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream) throws ServiceException { return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); } + @Override public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); @@ -754,10 +804,12 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont return result; } + @Override public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { return listBlobRegions(container, blob, new ListBlobRegionsOptions()); } + @Override public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "pagelist"); @@ -778,11 +830,13 @@ public ListBlobRegionsResult listBlobRegions(String container, String blob, List return result; } + @Override public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) throws ServiceException { createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); } + @Override public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "block"); @@ -795,10 +849,12 @@ public void createBlobBlock(String container, String blob, String blockId, Input builder.put(contentStream); } + @Override public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); } + @Override public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); @@ -816,10 +872,12 @@ public void commitBlobBlocks(String container, String blob, BlockList blockList, builder.put(blockList); } + @Override public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); } + @Override public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) throws ServiceException { WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); From 73ec37ed277d1993b61969e323e43104eb4bb96b Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Mon, 28 Nov 2011 17:53:20 -0800 Subject: [PATCH 269/664] TODO comment cleanup, Quoted Etag fix, and Anonymous client fix --- .../client/BlobDeserializationHelper.java | 1 - .../services/blob/client/BlobProperties.java | 3 ++- .../services/blob/client/CloudBlobClient.java | 7 +----- .../core/storage/AccessCondition.java | 23 +++++++++++++++++-- .../core/storage/MetricsProperties.java | 2 +- .../services/core/storage/ServiceClient.java | 7 +++--- .../core/storage/utils/PathUtility.java | 1 - .../utils/implementation/BaseRequest.java | 11 +++++---- .../utils/implementation/ExecutionEngine.java | 1 - 9 files changed, 34 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java index a803c37405bae..47815e883ce49 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java @@ -378,7 +378,6 @@ else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { Constants.HeaderConstants.CACHE_CONTROL)); } else if (name.equals(BlobConstants.SEQUENCE_NUMBER)) { - // TODO what do we do with this? Utility.readElementFromXMLReader(xmlr, BlobConstants.SEQUENCE_NUMBER); } else if (name.equals(BlobConstants.BLOB_TYPE_ELEMENT)) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java index 97684f64a8ea2..2c69d0f090ab7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -94,7 +94,8 @@ public BlobProperties(final BlobProperties other) { this.leaseStatus = other.leaseStatus; this.length = other.length; this.lastModified = other.lastModified; - // TODO why not copy cachecontrol, contentmd5? + this.contentMD5 = other.contentMD5; + this.cacheControl = other.cacheControl; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index b3f99b5a233f9..5dd3ccb8c2228 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -75,7 +75,7 @@ public final class CloudBlobClient extends ServiceClient { * client. */ public CloudBlobClient(final URI baseUri) { - this(baseUri, null); + this(baseUri, StorageCredentialsAnonymous.ANONYMOUS); } /** @@ -90,11 +90,6 @@ public CloudBlobClient(final URI baseUri) { */ public CloudBlobClient(final URI baseUri, StorageCredentials credentials) { super(baseUri, credentials); - - if (credentials == null) { - credentials = StorageCredentialsAnonymous.ANONYMOUS; - } - this.directoryDelimiter = BlobConstants.DEFAULT_DELIMITER; this.streamMinimumReadSizeInBytes = BlobConstants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java index 3ab39f3675c0a..dbc5653bb25ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -275,7 +275,7 @@ public String getLeaseID() { * the etag to set */ public void setIfMatch(String etag) { - this.etag = etag; + this.etag = normalizeEtag(etag); this.ifMatchHeaderType = Constants.HeaderConstants.IF_MATCH; } @@ -292,7 +292,7 @@ public void setIfModifiedSinceDate(Date ifModifiedSinceDate) { * the etag to set */ public void setIfNoneMatch(String etag) { - this.etag = etag; + this.etag = normalizeEtag(etag); this.ifMatchHeaderType = Constants.HeaderConstants.IF_NONE_MATCH; } @@ -353,4 +353,23 @@ else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) return true; } + + /** + * Normalizes an Etag to be quoted, unless it is * + * + * @param inTag + * the etag to normalize + * @return the quoted etag + */ + private static String normalizeEtag(String inTag) { + if (Utility.isNullOrEmpty(inTag) || inTag.equals("*")) { + return inTag; + } + else if (inTag.startsWith("\"") && inTag.endsWith("\"")) { + return inTag; + } + else { + return String.format("\"%s\"", inTag); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java index 39193f46b5fbd..b784ac8bdeace 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java @@ -12,7 +12,7 @@ public final class MetricsProperties { private String version = "1.0"; /** - * A used to enable Metric and API logging // todo do xref see to enum values. + * A {@link MetricsLevel} level used to enable Metric and API logging */ private MetricsLevel metricsLevel = com.microsoft.windowsazure.services.core.storage.MetricsLevel.DISABLED; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index e9ead21962585..5ae4eae908fa7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -67,19 +67,18 @@ public ServiceClient(final URI baseUri) { */ public ServiceClient(final URI baseUri, final StorageCredentials credentials) { Utility.assertNotNull("baseUri", baseUri); - if (!baseUri.isAbsolute()) { throw new IllegalArgumentException(String.format( "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", baseUri)); } + this.credentials = credentials == null ? StorageCredentialsAnonymous.ANONYMOUS : credentials; + this.retryPolicyFactory = new RetryExponentialRetry(); this.timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; - this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, credentials.getAccountName()); + this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, this.credentials.getAccountName()); this.endpoint = baseUri; - - this.credentials = credentials; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java index d3e5b329b2297..1c640908cb0bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -394,7 +394,6 @@ public static HashMap parseQueryString(String parseString) thr final int equalDex = valuePairs[m].indexOf("="); if (equalDex < 0 || equalDex == valuePairs[m].length() - 1) { - // TODO should throw here? continue; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index 3062fcb0fcdb3..6caccb6d4b0d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -178,10 +178,11 @@ public static HttpURLConnection createURLConnection(final URI uri, final int tim final HttpURLConnection retConnection = (HttpURLConnection) resourceUrl.openConnection(); retConnection.setReadTimeout(timeoutInMs); + // Note : accept behavior, java by default sends Accept behavior - // as text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 + // as text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 This will need to be set for table requests. // - // to override set retConnection.setRequestProperty("Accept", + // To override set retConnection.setRequestProperty("Accept", // "application/atom+xml"); retConnection.setRequestProperty(Constants.HeaderConstants.STORAGE_VERSION_HEADER, @@ -476,7 +477,7 @@ public static void signRequestForBlobAndQueueSharedKeyLite(final HttpURLConnecti final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); - // V2 add logging + // VNext add logging // System.out.println(String.format("Signing %s\r\n%s\r\n", // stringToSign, computedBase64Signature)); request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, @@ -510,8 +511,8 @@ public static void signRequestForTableSharedKeyLite(final HttpURLConnection requ final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); - // TODO V2 add logging - System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); + // TODO Vnext add logging + // System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, String.format("%s %s:%s", "SharedKeyLite", credentials.getAccountName(), computedBase64Signature)); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 1bf0339fa495e..1ff0f2bf92a0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -161,7 +161,6 @@ public static RESULT_TYPE executeWithRet } catch (final Exception e) { // Non Retryable, just throw - // TODO Should this be retried? translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); From 3bc0585d6f98061d75e0233d8fbb16b9d6d3f6d0 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 29 Nov 2011 13:59:47 -0800 Subject: [PATCH 270/664] Including methods model data modifiers to hide serialization types Various Filter and Action types can be created directly, but are in the xsd-generated "implementation" package and are not as discoverable. --- .../services/serviceBus/models/RuleInfo.java | 36 ++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 56 ++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java index 5af2e81a77a66..c417d60592f43 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java @@ -3,11 +3,16 @@ import javax.ws.rs.core.MediaType; import com.microsoft.windowsazure.services.serviceBus.implementation.Content; +import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; +import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.Filter; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; +import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; /** * Represents a rule. @@ -113,4 +118,35 @@ public RuleInfo setAction(RuleAction value) { return this; } + public RuleInfo withCorrelationIdFilter(String correlationId) { + CorrelationFilter filter = new CorrelationFilter(); + filter.setCorrelationId(correlationId); + return setFilter(filter); + } + + public RuleInfo withTrueSqlExpressionFilter(String sqlExpression) { + TrueFilter filter = new TrueFilter(); + filter.setSqlExpression(sqlExpression); + filter.setCompatibilityLevel(20); + return setFilter(filter); + } + + public RuleInfo withFalseSqlExpressionFilter(String sqlExpression) { + FalseFilter filter = new FalseFilter(); + filter.setSqlExpression(sqlExpression); + filter.setCompatibilityLevel(20); + return setFilter(filter); + } + + public RuleInfo withEmptyRuleAction() { + EmptyRuleAction action = new EmptyRuleAction(); + return setAction(action); + } + + public RuleInfo withSqlRuleAction(String sqlExpression) { + SqlRuleAction action = new SqlRuleAction(); + action.setSqlExpression(sqlExpression); + action.setCompatibilityLevel(20); + return setAction(action); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 52722d3de4fcb..ec138e774db94 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -6,15 +6,24 @@ import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import com.microsoft.windowsazure.services.core.Builder; +import com.microsoft.windowsazure.services.core.Builder.Alteration; +import com.microsoft.windowsazure.services.core.Builder.Registry; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.ServiceFilter.Request; import com.microsoft.windowsazure.services.core.ServiceFilter.Response; +import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; +import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; +import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; @@ -25,6 +34,8 @@ import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.filter.LoggingFilter; public class ServiceBusIntegrationTest extends IntegrationTestBase { @@ -36,13 +47,27 @@ public class ServiceBusIntegrationTest extends IntegrationTestBase { @Before public void createService() throws Exception { - Configuration config = Configuration.getInstance(); + // reinitialize configuration from known state + Configuration config = Configuration.load(); overrideWithEnv(config, ServiceBusConfiguration.URI); overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); overrideWithEnv(config, ServiceBusConfiguration.WRAP_SCOPE); - service = ServiceBusService.create(config); + + // add LoggingFilter to any pipeline that is created + Registry builder = (Registry) config.getBuilder(); + builder.alter(Client.class, new Alteration() { + @Override + public Client alter(Client instance, Builder builder, Map properties) { + instance.addFilter(new LoggingFilter()); + return instance; + } + }); + + // applied as default configuration + Configuration.setInstance(config); + service = ServiceBusService.create(); } private static void overrideWithEnv(Configuration config, String key) { @@ -428,4 +453,31 @@ public void rulesMayBeDeleted() throws Exception { assertEquals(1, result.getItems().size()); assertEquals("MyRule4", result.getItems().get(0).getName()); } + + @Test + public void rulesMayHaveActionAndFilter() throws ServiceException { + // Arrange + String topicName = "TestRulesMayHaveAnActionAndFilter"; + service.createTopic(new TopicInfo(topicName)); + service.createSubscription(topicName, new SubscriptionInfo("sub")); + + // Act + RuleInfo ruleOne = service.createRule(topicName, "sub", new RuleInfo("One").withCorrelationIdFilter("my-id")) + .getValue(); + RuleInfo ruleTwo = service.createRule(topicName, "sub", + new RuleInfo("Two").withTrueSqlExpressionFilter("my-true-expression")).getValue(); + RuleInfo ruleThree = service.createRule(topicName, "sub", + new RuleInfo("Three").withFalseSqlExpressionFilter("my-false-expression")).getValue(); + RuleInfo ruleFour = service.createRule(topicName, "sub", new RuleInfo("Four").withEmptyRuleAction()).getValue(); + RuleInfo ruleFive = service.createRule(topicName, "sub", new RuleInfo("Five").withSqlRuleAction("SET x = 5")) + .getValue(); + + // Assert + assertEquals(CorrelationFilter.class, ruleOne.getFilter().getClass()); + assertEquals(TrueFilter.class, ruleTwo.getFilter().getClass()); + assertEquals(FalseFilter.class, ruleThree.getFilter().getClass()); + assertEquals(EmptyRuleAction.class, ruleFour.getAction().getClass()); + assertEquals(SqlRuleAction.class, ruleFive.getAction().getClass()); + + } } From 2c5c7bbe1eaa0e800cf382c55dea909264108b38 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 29 Nov 2011 14:50:53 -0800 Subject: [PATCH 271/664] Special case retry policy and input stream entities If a retry policy is activated, throw an error if the input stream for the entity doesn't support "mark" and "reset". Fixes #132 --- .../services/core/RetryPolicyFilter.java | 35 +++++++++++++++++ .../blob/BlobServiceIntegrationTest.java | 39 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java index 1ecce3a22a210..3c3dd9fda233b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java @@ -1,5 +1,7 @@ package com.microsoft.windowsazure.services.core; +import java.io.InputStream; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -11,6 +13,7 @@ public RetryPolicyFilter(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; } + @Override public Response handle(Request request, Next next) throws Exception { // Only the last added retry policy should be active if (request.getProperties().containsKey("RetryPolicy")) @@ -19,6 +22,12 @@ public Response handle(Request request, Next next) throws Exception { // Retry the operation as long as retry policy tells us to do so for (int retryCount = 0;; ++retryCount) { + // Mark the stream before passing the request through + if (getEntityStream(request) != null) { + getEntityStream(request).mark(Integer.MAX_VALUE); + } + + // Pass the request to the next handler Response response = null; Exception error = null; try { @@ -28,6 +37,7 @@ public Response handle(Request request, Next next) throws Exception { error = e; } + // Determine if we should retry according to retry policy boolean shouldRetry = retryPolicy.shouldRetry(retryCount, response, error); if (!shouldRetry) { if (error != null) @@ -35,6 +45,12 @@ public Response handle(Request request, Next next) throws Exception { return response; } + // Reset the stream before retrying + if (getEntityStream(request) != null) { + getEntityStream(request).reset(); + } + + // Backoff for some time according to retry policy int backoffTime = retryPolicy.calculateBackoff(retryCount, response, error); log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", backoffTime, retryCount)); @@ -42,6 +58,25 @@ public Response handle(Request request, Next next) throws Exception { } } + private InputStream getEntityStream(Request request) { + if (request.getEntity() == null) + return null; + + if (!(request.getEntity() instanceof InputStream)) + return null; + + InputStream entityStream = (InputStream) request.getEntity(); + + // If the entity is an InputStream that doesn't support "mark/reset", we can't + // implement a retry logic, so we simply throw. + if (!entityStream.markSupported()) { + throw new IllegalArgumentException("The input stream for the request entity must support 'mark' and " + + "'reset' to be compatible with a retry policy filter."); + } + + return entityStream; + } + private void backoff(int milliseconds) { try { Thread.sleep(milliseconds); 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 7f3e6026242a4..7caa46abe446c 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 @@ -5,6 +5,7 @@ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -1423,6 +1424,44 @@ public void retryPolicyCompositionWorks() throws Exception { assertEquals(3, observer.requestCount); } + private class NonResetableInputStream extends FilterInputStream { + + protected NonResetableInputStream(InputStream in) { + super(in); + } + + @Override + public boolean markSupported() { + return false; + } + } + + @Test + public void retryPolicyThrowsOnInvalidInputStream() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract service = BlobService.create(config); + + // Act + service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, + 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); + + Exception error = null; + try { + String content = "foo"; + InputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); + InputStream stream = new NonResetableInputStream(contentStream); + + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "testretry", stream); + } + catch (Exception e) { + error = e; + } + + // Assert + assertNotNull(error); + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From aca1a10643ab2502394f822dc689649c6fe76675 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 29 Nov 2011 16:46:27 -0800 Subject: [PATCH 272/664] Change the pom xml id references from azure->windowsazure fixes #126 The groupID is currently com.microsoft.azure, and the artifactID is microsoft-azure-api. Both should have azure changed to microsoft azure. --- microsoft-azure-api/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 39842eb617425..9925ca4731ae8 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -1,13 +1,13 @@ 4.0.0 - com.microsoft.azure - microsoft-azure-api + com.microsoft.windowsazure + microsoft-windowsazure-api 0.0.1-SNAPSHOT jar - Microsoft Azure Client API - API for Microsoft Azure Clients + Microsoft Windows Azure Client API + API for Microsoft Windows Azure Clients https://github.com/WindowsAzure/azure-sdk-for-java From e63ea5bbf08c73e449206f4d778647b64b4618b5 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 29 Nov 2011 17:30:04 -0800 Subject: [PATCH 273/664] Adding integration test to check stream reset is handled properly --- .../blob/BlobServiceIntegrationTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) 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 7caa46abe446c..94fc44dfdf86a 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 @@ -1462,6 +1462,58 @@ public void retryPolicyThrowsOnInvalidInputStream() throws Exception { assertNotNull(error); } + private class ResetableInputStream extends FilterInputStream { + private boolean resetCalled; + + protected ResetableInputStream(InputStream in) { + super(in); + } + + @Override + public void reset() throws IOException { + super.reset(); + setResetCalled(true); + } + + public boolean isResetCalled() { + return resetCalled; + } + + public void setResetCalled(boolean resetCalled) { + this.resetCalled = resetCalled; + } + } + + @Test + public void retryPolicyCallsResetOnValidInputStream() throws Exception { + // Arrange + Configuration config = createConfiguration(); + BlobContract service = BlobService.create(config); + + // Act + service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, + 3/*maximumAttempts*/, new int[] { 403 }))); + + ServiceException error = null; + ResetableInputStream stream = null; + try { + String content = "foo"; + InputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); + stream = new ResetableInputStream(contentStream); + + service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "invalidblobname @#$#@$@", stream); + } + catch (ServiceException e) { + error = e; + } + + // Assert + assertNotNull(error); + assertEquals(403, error.getHttpStatusCode()); + assertNotNull(stream); + assertTrue(stream.isResetCalled()); + } + private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From 576c7f2c375ebcc51ba11cc6773af179a8b725d7 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Wed, 30 Nov 2011 10:47:40 -0800 Subject: [PATCH 274/664] ASK MODE: Queue createIfNotExist() bug, returns incorrect value and retries on already crated. DOC fix for Blob.BreakLease --- .../services/blob/client/CloudBlob.java | 4 +- .../services/queue/client/CloudQueue.java | 463 ++++++++---------- 2 files changed, 195 insertions(+), 272 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index c65f1631a2fb4..d29643ff5ea62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -303,7 +303,7 @@ protected final void assertCorrectBlobType() throws StorageException { * Breaks the lease but ensures that another client cannot acquire a new lease until the current lease period has * expired. * - * @return The time, in seconds, remaining in the lease period, or -1 if the lease has already been broken. + * @return The time, in seconds, remaining in the lease period. * * @throws StorageException * If a storage service error occurred. @@ -328,7 +328,7 @@ public final long breakLease() throws StorageException { * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * - * @return The time, in seconds, remaining in the lease period, or -1 if the lease has already been broken. + * @return The time, in seconds, remaining in the lease period. * * @throws StorageException * If a storage service error occurred. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index aa808f3b4cde2..f60eee9dea153 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -35,8 +35,8 @@ public final class CloudQueue { * The Iterable collection of {@link CloudQueueMessage} objects to get the first message * from. * - * @return The first {@link CloudQueueMessage} from the list of queue - * messages, or null if the list is empty. + * @return The first {@link CloudQueueMessage} from the list of queue messages, or null if the list is + * empty. */ static CloudQueueMessage getFirstOrNull(final Iterable messages) { for (final CloudQueueMessage m : messages) { @@ -59,7 +59,7 @@ static CloudQueueMessage getFirstOrNull(final Iterable messag /** * A reference to the queue's associated service client. */ - private CloudQueueClient queueServiceClient; + private final CloudQueueClient queueServiceClient; /** * The queue's Metadata collection. @@ -77,22 +77,18 @@ static CloudQueueMessage getFirstOrNull(final Iterable messag private URI messageRequestAddress; /** - * A flag indicating whether or not the message should be encoded in - * base-64. + * A flag indicating whether or not the message should be encoded in base-64. */ Boolean shouldEncodeMessage; /** - * Creates an instance of the CloudQueue class using the - * specified address and client. + * Creates an instance of the CloudQueue class using the specified address and client. * * @param queueAddress - * A String that represents either the absolute URI - * to the queue, or the queue name. + * A String that represents either the absolute URI to the queue, or the queue name. * @param client - * A {@link CloudQueueClient} object that represents the - * associated service client, and that specifies the endpoint for - * the Queue service. + * A {@link CloudQueueClient} object that represents the associated service client, and that specifies + * the endpoint for the Queue service. * * @throws URISyntaxException * If the resource URI is invalid. @@ -102,16 +98,13 @@ public CloudQueue(final String queueAddress, final CloudQueueClient client) thro } /** - * Creates an instance of the CloudQueue class using the - * specified queue URI and client. + * Creates an instance of the CloudQueue class using the specified queue URI and client. * * @param uri - * A java.net.URI object that represents the - * absolute URI of the queue. + * A java.net.URI object that represents the absolute URI of the queue. * @param client - * A {@link CloudQueueClient} object that represents the - * associated service client, and that specifies the endpoint for - * the Queue service. + * A {@link CloudQueueClient} object that represents the associated service client, and that specifies + * the endpoint for the Queue service. */ public CloudQueue(final URI uri, final CloudQueueClient client) { this.uri = uri; @@ -124,8 +117,7 @@ public CloudQueue(final URI uri, final CloudQueueClient client) { * Adds a message to the back of the queue with the default options. * * @param message - * A {@link CloudQueueMessage} object that specifies the message - * to add. + * A {@link CloudQueueMessage} object that specifies the message to add. * * @throws StorageException * If a storage service error occurred during the operation. @@ -139,32 +131,26 @@ public void addMessage(final CloudQueueMessage message) throws StorageException * Adds a message to the back of the queue with the specified options. * * @param message - * A {@link CloudQueueMessage} object that specifies the message - * to add. + * A {@link CloudQueueMessage} object that specifies the message to add. * * @param timeToLiveInSeconds - * The maximum time to allow the message to be in the queue. A - * value of zero will set the time-to-live to the service default - * value of seven days. + * The maximum time to allow the message to be in the queue. A value of zero will set the time-to-live to + * the service default value of seven days. * * @param initialVisibilityDelayInSeconds - * The length of time during which the message will be invisible, - * starting when it is added to the queue, or 0 to make the - * message visible immediately. This value must be greater than - * or equal to zero and less than or equal to the time-to-live - * value. + * The length of time during which the message will be invisible, starting when it is added to the queue, + * or 0 to make the message visible immediately. This value must be greater than or equal to zero and + * less than or equal to the time-to-live value. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -240,19 +226,16 @@ public void clear() throws StorageException { } /** - * Clears all messages from the queue, using the specified request options - * and operation context. + * Clears all messages from the queue, using the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -308,19 +291,16 @@ public void create() throws StorageException { } /** - * Creates the queue in the storage service using the specified request - * options and operation context. + * Creates the queue in the storage service using the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -366,11 +346,10 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final } /** - * Creates the queue in the storage service using default request options if - * it does not already exist. + * Creates the queue in the storage service using default request options if it does not already exist. * - * @return A value of true if the queue is created in the - * storage service, otherwise false. + * @return A value of true if the queue is created in the storage service, otherwise false + * . * * @throws StorageException * If a storage service error occurred during the operation. @@ -381,22 +360,20 @@ public Boolean createIfNotExist() throws StorageException { } /** - * Creates the queue in the storage service with the specified request - * options and operation context if it does not already exist. + * Creates the queue in the storage service with the specified request options and operation context if it does not + * already exist. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return A value of true if the queue is created in the - * storage service, otherwise false. + * @return A value of true if the queue is created in the storage service, otherwise false + * . * * @throws StorageException * If a storage service error occurred during the operation. @@ -429,9 +406,11 @@ public Boolean execute(final CloudQueueClient client, final CloudQueue queue, this.setResult(ExecutionEngine.processRequest(request, opContext)); if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); return true; } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return false; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { final StorageException potentialConflictException = StorageException.translateException(request, null, opContext); @@ -442,6 +421,9 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { this.setNonExceptionedRetryableFailure(true); } } + else { + this.setNonExceptionedRetryableFailure(true); + } return false; } @@ -463,19 +445,16 @@ public void delete() throws StorageException { } /** - * Deletes the queue from the storage service, using the specified request - * options and operation context. + * Deletes the queue from the storage service, using the specified request options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -521,8 +500,8 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final /** * Deletes the queue from the storage service if it exists. * - * @return A value of true if the queue existed in the storage - * service and has been deleted, otherwise false. + * @return A value of true if the queue existed in the storage service and has been deleted, otherwise + * false. * * @throws StorageException * If a storage service error occurred during the operation. @@ -533,22 +512,20 @@ public Boolean deleteIfExists() throws StorageException { } /** - * Deletes the queue from the storage service using the specified request - * options and operation context, if it exists. + * Deletes the queue from the storage service using the specified request options and operation context, if it + * exists. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return A value of true if the queue existed in the storage - * service and has been deleted, otherwise false. + * @return A value of true if the queue existed in the storage service and has been deleted, otherwise + * false. * * @throws StorageException * If a storage service error occurred during the operation. @@ -600,8 +577,7 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { * Deletes the specified message from the queue. * * @param message - * A {@link CloudQueueMessage} object that specifies the message - * to delete. + * A {@link CloudQueueMessage} object that specifies the message to delete. * * @throws StorageException * If a storage service error occurred during the operation. @@ -612,24 +588,20 @@ public void deleteMessage(final CloudQueueMessage message) throws StorageExcepti } /** - * Deletes the specified message from the queue, using the specified request - * options and operation context. + * Deletes the specified message from the queue, using the specified request options and operation context. * * @param message - * A {@link CloudQueueMessage} object that specifies the message - * to delete. + * A {@link CloudQueueMessage} object that specifies the message to delete. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -690,19 +662,17 @@ public void downloadAttributes() throws StorageException { } /** - * Downloads the queue's metadata and approximate message count value, using - * the specified request options and operation context. + * Downloads the queue's metadata and approximate message count value, using the specified request options and + * operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueue}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueue}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -749,11 +719,9 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final } /** - * Returns a value that indicates whether the queue exists in the storage - * service. + * Returns a value that indicates whether the queue exists in the storage service. * - * @return true if the queue exists in the storage service, - * otherwise false. + * @return true if the queue exists in the storage service, otherwise false. * * @throws StorageException * If a storage service error occurred during the operation. @@ -764,22 +732,19 @@ public Boolean exist() throws StorageException { } /** - * Returns a value that indicates whether the queue exists in the storage - * service, using the specified request options and operation context. + * Returns a value that indicates whether the queue exists in the storage service, using the specified request + * options and operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return true if the queue exists in the storage service, - * otherwise false. + * @return true if the queue exists in the storage service, otherwise false. * * @throws StorageException * If a storage service error occurred during the operation. @@ -829,12 +794,10 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { } /** - * Gets the approximate messages count of the queue. This value is - * initialized by a request to {@link #downloadAttributes} and represents - * the approximate message count when that request completed. + * Gets the approximate messages count of the queue. This value is initialized by a request to + * {@link #downloadAttributes} and represents the approximate message count when that request completed. * - * @return A Long object that represents the approximate - * messages count of the queue. + * @return A Long object that represents the approximate messages count of the queue. */ public long getApproximateMessageCount() { return this.approximateMessageCount; @@ -870,12 +833,10 @@ URI getMessageRequestAddress() throws URISyntaxException { /** * Gets the metadata collection for the queue as stored in this CloudQueue object. This value is - * initialized with the - * metadata from the queue by a call to {@link #downloadAttributes}, and is - * set on the queue with a call to {@link #uploadMetadata}. + * initialized with the metadata from the queue by a call to {@link #downloadAttributes}, and is set on the queue + * with a call to {@link #uploadMetadata}. * - * @return A java.util.HashMap object that represents the - * metadata for the queue. + * @return A java.util.HashMap object that represents the metadata for the queue. */ public HashMap getMetadata() { return this.metadata; @@ -884,8 +845,7 @@ public HashMap getMetadata() { /** * Gets the name of the queue. * - * @return A String object that represents the name of the - * queue. + * @return A String object that represents the name of the queue. */ public String getName() { return this.name; @@ -894,8 +854,7 @@ public String getName() { /** * Gets the queue service client associated with this queue. * - * @return A {@link CloudQueueClient} object that represents the service - * client associated with this queue. + * @return A {@link CloudQueueClient} object that represents the service client associated with this queue. */ public CloudQueueClient getServiceClient() { return this.queueServiceClient; @@ -904,8 +863,7 @@ public CloudQueueClient getServiceClient() { /** * Gets the value indicating whether the message should be base-64 encoded. * - * @return A Boolean that represents whether the message should - * be base-64 encoded. + * @return A Boolean that represents whether the message should be base-64 encoded. */ public Boolean getShouldEncodeMessage() { return this.shouldEncodeMessage; @@ -914,19 +872,17 @@ public Boolean getShouldEncodeMessage() { /** * Gets the absolute URI for this queue. * - * @return A java.net.URI object that represents the URI for - * this queue. + * @return A java.net.URI object that represents the URI for this queue. */ public URI getUri() { return this.uri; } /** - * Peeks a message from the queue. A peek request retrieves a message from - * the front of the queue without changing its visibility. + * Peeks a message from the queue. A peek request retrieves a message from the front of the queue without changing + * its visibility. * - * @return An {@link CloudQueueMessage} object that represents a message in - * this queue. + * @return An {@link CloudQueueMessage} object that represents a message in this queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -937,23 +893,19 @@ public CloudQueueMessage peekMessage() throws StorageException { } /** - * Peeks a message from the queue, using the specified request options and - * operation context. A peek request retrieves a message from the front of - * the queue without changing its visibility. + * Peeks a message from the queue, using the specified request options and operation context. A peek request + * retrieves a message from the front of the queue without changing its visibility. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return An {@link CloudQueueMessage} object that represents the requested - * message from the queue. + * @return An {@link CloudQueueMessage} object that represents the requested message from the queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -965,15 +917,14 @@ public CloudQueueMessage peekMessage(final QueueRequestOptions options, final Op } /** - * Peeks a specified number of messages from the queue. A peek request - * retrieves messages from the front of the queue without changing their - * visibility. + * Peeks a specified number of messages from the queue. A peek request retrieves messages from the front of the + * queue without changing their visibility. * * @param numberOfMessages * The number of messages to retrieve. * - * @return An enumerable collection of {@link CloudQueueMessage} objects - * that represents the requested messages from the queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the requested messages from + * the queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -984,26 +935,23 @@ public Iterable peekMessages(final int numberOfMessages) thro } /** - * Peeks a set of messages from the queue, using the specified request - * options and operation context. A peek request retrieves messages from the - * front of the queue without changing their visibility. + * Peeks a set of messages from the queue, using the specified request options and operation context. A peek request + * retrieves messages from the front of the queue without changing their visibility. * * @param numberOfMessages * The number of messages to retrieve. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return An enumerable collection of {@link CloudQueueMessage} objects - * that represents the requested messages from the queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the requested messages from + * the queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1053,12 +1001,10 @@ public ArrayList execute(final CloudQueueClient client, final } /** - * Retrieves a message from the front of the queue using the default request - * options. This operation marks the retrieved message as invisible in the - * queue for the default visibility timeout period. + * Retrieves a message from the front of the queue using the default request options. This operation marks the + * retrieved message as invisible in the queue for the default visibility timeout period. * - * @return An {@link CloudQueueMessage} object that represents a message in - * this queue. + * @return An {@link CloudQueueMessage} object that represents a message in this queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1069,27 +1015,22 @@ public CloudQueueMessage retrieveMessage() throws StorageException { } /** - * Retrieves a message from the front of the queue, using the specified - * request options and operation context. This operation marks the retrieved - * message as invisible in the queue for the specified visibility timeout - * period. + * Retrieves a message from the front of the queue, using the specified request options and operation context. This + * operation marks the retrieved message as invisible in the queue for the specified visibility timeout period. * * @param visibilityTimeoutInSeconds * Specifies the visibility timeout for the message, in seconds. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return An {@link CloudQueueMessage} object that represents a message in - * this queue. + * @return An {@link CloudQueueMessage} object that represents a message in this queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1101,16 +1042,14 @@ public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, f } /** - * Retrieves the specified number of messages from the front of the queue - * using the default request options. This operation marks the retrieved - * messages as invisible in the queue for the default visibility timeout - * period. + * Retrieves the specified number of messages from the front of the queue using the default request options. This + * operation marks the retrieved messages as invisible in the queue for the default visibility timeout period. * * @param numberOfMessages * The number of messages to retrieve. * - * @return An enumerable collection of {@link CloudQueueMessage} objects - * that represents the retrieved messages from the queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the retrieved messages from + * the queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1121,31 +1060,27 @@ public Iterable retrieveMessages(final int numberOfMessages) } /** - * Retrieves the specified number of messages from the front of the queue - * using the specified request options and operation context. This operation - * marks the retrieved messages as invisible in the queue for the default + * Retrieves the specified number of messages from the front of the queue using the specified request options and + * operation context. This operation marks the retrieved messages as invisible in the queue for the default * visibility timeout period. * * @param numberOfMessages * The number of messages to retrieve. * * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout for the retrieved messages, - * in seconds. + * Specifies the visibility timeout for the retrieved messages, in seconds. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * - * @return An enumerable collection of {@link CloudQueueMessage} objects - * that represents the messages retrieved from the queue. + * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages retrieved from + * the queue. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1197,14 +1132,12 @@ public ArrayList execute(final CloudQueueClient client, final } /** - * Sets the metadata collection of name-value pairs to be set on the queue - * with an {@link #uploadMetadata} call. This collection will overwrite any - * existing queue metadata. If this is set to an empty collection, the queue + * Sets the metadata collection of name-value pairs to be set on the queue with an {@link #uploadMetadata} call. + * This collection will overwrite any existing queue metadata. If this is set to an empty collection, the queue * metadata will be cleared on an {@link #uploadMetadata} call. * * @param metadata - * A java.util.HashMap object that represents the - * metadata being assigned to the queue. + * A java.util.HashMap object that represents the metadata being assigned to the queue. */ public void setMetadata(final HashMap metadata) { this.metadata = metadata; @@ -1214,23 +1147,20 @@ public void setMetadata(final HashMap metadata) { * Sets the name of the queue. * * @param name - * A String that represents the name being assigned - * to the queue. + * A String that represents the name being assigned to the queue. */ void setName(final String name) { this.name = name; } /** - * Updates the specified message in the queue with a new visibility timeout - * value in seconds. + * Updates the specified message in the queue with a new visibility timeout value in seconds. * * @param message * The {@link CloudQueueMessage} to update in the queue. * * @param visibilityTimeoutInSeconds - * Specifies the new visibility timeout for the message, in - * seconds. + * Specifies the new visibility timeout for the message, in seconds. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1241,31 +1171,27 @@ public void updateMessage(final CloudQueueMessage message, final int visibilityT } /** - * Updates a message in the queue, using the specified request options and - * operation context. + * Updates a message in the queue, using the specified request options and operation context. * * @param message * The {@link CloudQueueMessage} to update in the queue. * * @param visibilityTimeoutInSeconds - * Specifies the new visibility timeout for the message, in - * seconds. + * Specifies the new visibility timeout for the message, in seconds. * * @param messageUpdateFields - * An EnumSet of {@link MessageUpdateFields} values - * that specifies which parts of the message are to be updated. + * An EnumSet of {@link MessageUpdateFields} values that specifies which parts of the + * message are to be updated. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1333,8 +1259,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final } /** - * Uploads the metadata in the CloudQueue object to the queue, - * using the default request options. + * Uploads the metadata in the CloudQueue object to the queue, using the default request options. * * @throws StorageException * If a storage service error occurred during the operation. @@ -1345,20 +1270,18 @@ public void uploadMetadata() throws StorageException { } /** - * Uploads the metadata in the CloudQueue object to the queue, - * using the specified request options and operation context. + * Uploads the metadata in the CloudQueue object to the queue, using the specified request options and + * operation context. * * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueueClient}). + * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying + * null will use the default request options from the associated service client ( + * {@link CloudQueueClient}). * * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. * * @throws StorageException * If a storage service error occurred during the operation. From 8a865c80cc59801f214c3f49f1513749b049a1f4 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 30 Nov 2011 13:40:43 -0800 Subject: [PATCH 275/664] Remove all copyrights (will add final one in next change) --- .../services/blob/client/AccessPolicyResponse.java | 2 -- .../windowsazure/services/blob/client/BlobAttributes.java | 2 -- .../services/blob/client/BlobContainerAttributes.java | 2 -- .../services/blob/client/BlobContainerPermissions.java | 2 -- .../services/blob/client/BlobContainerProperties.java | 2 -- .../blob/client/BlobContainerPublicAccessType.java | 2 -- .../windowsazure/services/blob/client/BlobInputStream.java | 2 -- .../services/blob/client/BlobListingContext.java | 2 -- .../services/blob/client/BlobListingDetails.java | 1 - .../services/blob/client/BlobOutputStream.java | 4 ++-- .../windowsazure/services/blob/client/BlobProperties.java | 2 -- .../windowsazure/services/blob/client/BlobRequest.java | 2 -- .../services/blob/client/BlobRequestOptions.java | 2 -- .../windowsazure/services/blob/client/BlobResponse.java | 2 -- .../windowsazure/services/blob/client/BlobType.java | 2 -- .../windowsazure/services/blob/client/BlockEntry.java | 2 -- .../services/blob/client/BlockListingFilter.java | 2 -- .../windowsazure/services/blob/client/BlockSearchMode.java | 2 -- .../windowsazure/services/blob/client/CloudBlob.java | 5 +++-- .../windowsazure/services/blob/client/CloudBlobClient.java | 2 -- .../services/blob/client/CloudBlobContainer.java | 2 -- .../services/blob/client/CloudBlobDirectory.java | 5 +++-- .../windowsazure/services/blob/client/CloudBlockBlob.java | 2 -- .../windowsazure/services/blob/client/CloudPageBlob.java | 1 - .../services/blob/client/ContainerListingDetails.java | 1 - .../services/blob/client/ContainerRequest.java | 1 - .../services/blob/client/ContainerResponse.java | 2 -- .../services/blob/client/DeleteSnapshotsOption.java | 2 -- .../services/blob/client/GetBlockListResponse.java | 2 -- .../services/blob/client/GetPageRangesResponse.java | 2 -- .../windowsazure/services/blob/client/ListBlobItem.java | 2 -- .../services/blob/client/ListBlobsResponse.java | 2 -- .../services/blob/client/ListContainersResponse.java | 2 -- .../services/blob/client/PageOperationType.java | 2 -- .../windowsazure/services/blob/client/PageProperties.java | 2 -- .../windowsazure/services/blob/client/PageRange.java | 2 -- .../services/blob/client/SharedAccessPermissions.java | 2 -- .../services/blob/client/SharedAccessPolicy.java | 2 -- .../services/blob/client/SharedAccessSignatureHelper.java | 2 -- .../windowsazure/services/blob/models/AccessCondition.java | 2 -- .../services/blob/models/AccessConditionHeaderType.java | 2 -- .../services/core/storage/AccessCondition.java | 2 -- .../services/core/storage/CloudStorageAccount.java | 2 -- .../windowsazure/services/core/storage/Constants.java | 2 -- .../windowsazure/services/core/storage/Credentials.java | 2 -- .../services/core/storage/DoesServiceRequest.java | 2 -- .../windowsazure/services/core/storage/EventListener.java | 2 -- .../services/core/storage/EventListenerMultiCaster.java | 2 -- .../windowsazure/services/core/storage/LeaseStatus.java | 2 -- .../services/core/storage/LoggingOperations.java | 2 -- .../services/core/storage/LoggingProperties.java | 2 -- .../windowsazure/services/core/storage/MetricsLevel.java | 2 -- .../services/core/storage/MetricsProperties.java | 2 -- .../services/core/storage/OperationContext.java | 4 +--- .../windowsazure/services/core/storage/RequestOptions.java | 2 -- .../windowsazure/services/core/storage/RequestResult.java | 2 -- .../services/core/storage/ResponseReceivedEvent.java | 6 ++---- .../services/core/storage/ResultContinuation.java | 2 -- .../windowsazure/services/core/storage/ResultSegment.java | 2 -- .../services/core/storage/RetryExponentialRetry.java | 3 +-- .../services/core/storage/RetryLinearRetry.java | 3 +-- .../windowsazure/services/core/storage/RetryNoRetry.java | 3 +-- .../windowsazure/services/core/storage/RetryPolicy.java | 2 -- .../services/core/storage/RetryPolicyFactory.java | 2 -- .../windowsazure/services/core/storage/RetryResult.java | 7 +------ .../windowsazure/services/core/storage/ServiceClient.java | 2 -- .../services/core/storage/ServiceProperties.java | 2 -- .../services/core/storage/StorageCredentials.java | 2 -- .../core/storage/StorageCredentialsAccountAndKey.java | 2 -- .../services/core/storage/StorageCredentialsAnonymous.java | 3 --- .../storage/StorageCredentialsSharedAccessSignature.java | 2 -- .../services/core/storage/StorageErrorCode.java | 2 -- .../services/core/storage/StorageErrorCodeStrings.java | 2 -- .../services/core/storage/StorageException.java | 2 -- .../core/storage/StorageExtendedErrorInformation.java | 2 -- .../windowsazure/services/core/storage/StorageKey.java | 2 -- .../windowsazure/services/core/storage/utils/Base64.java | 2 -- .../services/core/storage/utils/PathUtility.java | 2 -- .../services/core/storage/utils/StreamDescriptor.java | 2 -- .../services/core/storage/utils/UriQueryBuilder.java | 2 -- .../windowsazure/services/core/storage/utils/Utility.java | 2 -- .../core/storage/utils/implementation/BaseRequest.java | 2 -- .../core/storage/utils/implementation/BaseResponse.java | 2 -- .../utils/implementation/BlobQueueFullCanonicalizer.java | 2 -- .../utils/implementation/BlobQueueLiteCanonicalizer.java | 2 -- .../core/storage/utils/implementation/Canonicalizer.java | 2 -- .../storage/utils/implementation/CanonicalizerFactory.java | 2 -- .../utils/implementation/DeserializationHelper.java | 2 -- .../core/storage/utils/implementation/ExecutionEngine.java | 2 -- .../utils/implementation/LazySegmentedIterator.java | 6 ++++-- .../core/storage/utils/implementation/LeaseAction.java | 2 -- .../core/storage/utils/implementation/ListingContext.java | 2 -- .../utils/implementation/SegmentedStorageOperation.java | 2 -- .../storage/utils/implementation/StorageErrorResponse.java | 2 -- .../storage/utils/implementation/StorageOperation.java | 2 -- .../utils/implementation/TableLiteCanonicalizer.java | 2 -- .../windowsazure/services/queue/client/CloudQueue.java | 5 ----- .../services/queue/client/CloudQueueClient.java | 5 ----- .../services/queue/client/CloudQueueMessage.java | 5 ----- .../services/queue/client/ListQueuesResponse.java | 5 ----- .../services/queue/client/MessageUpdateFields.java | 5 ----- .../windowsazure/services/queue/client/QueueConstants.java | 5 ----- .../services/queue/client/QueueDeserializationHelper.java | 5 ----- .../services/queue/client/QueueListingDetails.java | 5 ----- .../services/queue/client/QueueMessageType.java | 5 ----- .../windowsazure/services/queue/client/QueueRequest.java | 5 ----- .../services/queue/client/QueueRequestOptions.java | 5 ----- .../windowsazure/services/queue/client/QueueResponse.java | 5 ----- 108 files changed, 19 insertions(+), 256 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java index b94caa98dbfc1..caa37c0415719 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java @@ -13,8 +13,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to parse SharedAccessPolicies from an input stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class AccessPolicyResponse { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java index ae4f4fa2415d5..80183b0bd08cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java @@ -5,8 +5,6 @@ /** * RESERVED FOR INTERNAL USE. Represents a blob's attributes. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobAttributes { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java index 138a83e81d988..6b9aae0c5aee7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java @@ -5,8 +5,6 @@ /** * RESERVED FOR INTERNAL USE. Represents a container's attributes, including its properties and metadata. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobContainerAttributes { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java index d067cfdc5e332..f37787f34b723 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java @@ -16,8 +16,6 @@ * * For more information on managing container permissions, see Managing Access to Containers and Blobs. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobContainerPermissions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java index b7f66f6e4d4f0..40438432cff02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java @@ -6,8 +6,6 @@ /** * Represents the system properties for a container. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobContainerProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java index 4b521d246def0..9e3ce6fe610ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java @@ -3,8 +3,6 @@ /** * Specifies the level of public access that is allowed on the container. * - * Copyright (c)2011 Microsoft. All rights reserved. - * */ public enum BlobContainerPublicAccessType { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java index e43ed84c2ca18..b6a7557f98a17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -21,8 +21,6 @@ /** * Provides an input stream to read a given blob resource. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobInputStream extends InputStream { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java index c34ad91bbd43c..742eca52a8691 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java @@ -6,8 +6,6 @@ /** * RESERVED FOR INTERNAL USE. Provides the listing context for blobs including the delimiter and listingdetails - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobListingContext extends ListingContext { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java index dbe33cbfce54a..1077e6bb9240d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java @@ -6,7 +6,6 @@ * 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 { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java index 87890fa33ac8a..5ede30d385f24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -26,8 +26,6 @@ /** * The class is an append-only stream for writing into storage. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobOutputStream extends OutputStream { /** @@ -347,6 +345,7 @@ private synchronized void dispatchWrite(final int writeLength) throws IOExceptio this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED)); worker = new Callable() { + @Override public Void call() { try { blobRef.uploadBlock(blockID, bufferRef, writeLength, BlobOutputStream.this.accessCondition, @@ -416,6 +415,7 @@ else if (this.streamType == BlobType.PAGE_BLOB) { this.currentPageOffset += writeLength; worker = new Callable() { + @Override public Void call() { try { blobRef.uploadPages(bufferRef, opOffset, opWriteLength, BlobOutputStream.this.accessCondition, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java index 2c69d0f090ab7..419f050ce033f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -7,8 +7,6 @@ /** * Represents the system properties for a blob. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java index b1d4b9b28a739..eb434a39717f2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java @@ -23,8 +23,6 @@ /** * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing requests for blob operations. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobRequest { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java index 7b5d453e768fc..ce1db0ff9bace 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java @@ -7,8 +7,6 @@ /** * Represents a set of options that may be specified on a request. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlobRequestOptions extends RequestOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java index f4f0e6fac11e4..5fcec51155e32 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java @@ -12,8 +12,6 @@ /** * RESERVED FOR INTERNAL USE. A class for parsing various responses from the blob service - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobResponse extends BaseResponse { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java index e5559596908f3..a82a23c79af1f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java @@ -9,8 +9,6 @@ /** * Specifies the type of a blob. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum BlobType { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java index 713fd924d200f..c1a2536b94988 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java @@ -2,8 +2,6 @@ /** * A class which is used to list and commit blocks of a {@link CloudBlockBlob}. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BlockEntry { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java index 860ce3e905f32..38faac0a04358 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java @@ -2,8 +2,6 @@ /** * Specifies whether to list only committed blocks, only uncommitted blocks, or all blocks. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum BlockListingFilter { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java index 26df47e7a5164..776759880e047 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java @@ -2,8 +2,6 @@ /** * Specifies which block lists should be searched to find a specified block. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum BlockSearchMode { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index d29643ff5ea62..7d930a9ceb149 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -36,8 +36,6 @@ * * Represents a Windows Azure blob. This is the base class for the {@link CloudBlockBlob} and {@link CloudPageBlob} * classes. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class CloudBlob implements ListBlobItem { /** @@ -1446,6 +1444,7 @@ String getCanonicalName(final boolean ignoreSnapshotTime) { * @throws URISyntaxException * If the resource URI is invalid. */ + @Override public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { if (this.container == null) { final URI containerURI = PathUtility.getContainerURI(this.getUri(), @@ -1490,6 +1489,7 @@ public final String getName() throws URISyntaxException { * @throws URISyntaxException * If the resource URI is invalid. */ + @Override public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { final URI parentURI = PathUtility.getParentAddress(this.getUri(), @@ -1587,6 +1587,7 @@ protected final URI getTransformedAddress(final OperationContext opContext) thro * * @return A java.net.URI object that represents the URI for the blob. */ + @Override public final URI getUri() { return this.uri; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index 5dd3ccb8c2228..db01505ef0263 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -33,8 +33,6 @@ * This class provides a point of access to the Blob service. The service client encapsulates the base URI for the Blob * service. If the service client will be used for authenticated access, it also encapsulates the credentials for * accessing the storage account. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudBlobClient extends ServiceClient { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 1fe9359de2d5b..3cdbf2acb6182 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -36,8 +36,6 @@ *

* Containers hold directories, which are encapsulated as {@link CloudBlobDirectory} objects, and directories hold block * blobs and page blobs. Directories can also contain sub-directories. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudBlobContainer { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java index 4f7e8ce3d4ca6..7c372f91eede5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java @@ -18,8 +18,6 @@ *

* Containers, which are encapsulated as {@link CloudBlobContainer} objects, hold directories, and directories hold * block blobs and page blobs. Directories can also contain sub-directories. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudBlobDirectory implements ListBlobItem { @@ -152,6 +150,7 @@ public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final S * @throws URISyntaxException * If the resource URI is invalid. */ + @Override public CloudBlobContainer getContainer() throws StorageException, URISyntaxException { if (this.container == null) { final URI containerURI = PathUtility.getContainerURI(this.uri, this.blobServiceClient.isUsePathStyleUris()); @@ -217,6 +216,7 @@ public CloudPageBlob getPageBlobReference(final String blobAddressUri, final Str * @throws URISyntaxException * If the resource URI is invalid. */ + @Override public CloudBlobDirectory getParent() throws URISyntaxException, StorageException { if (this.parent == null) { final URI parentURI = PathUtility.getParentAddress(this.uri, @@ -287,6 +287,7 @@ public CloudBlobDirectory getSubDirectoryReference(final String relativeAddress) * * @return A java.net.URI object that represents the URI for this directory. */ + @Override public URI getUri() { return this.uri; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 015f8167ff321..3e2c34236b741 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -22,8 +22,6 @@ /** * Represents a blob that is uploaded as a set of blocks. * - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudBlockBlob extends CloudBlob { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index 1145cfa32c1a9..838b2ed34d32a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -22,7 +22,6 @@ /** * Represents a Windows Azure page blob. * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudPageBlob extends CloudBlob { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java index 1187fdf7e6552..81bb92b77f03e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java @@ -3,7 +3,6 @@ /** * Specifies which details to include when listing the containers in this storage account. * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum ContainerListingDetails { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java index 0f496dc2dce14..b860d8508d9de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java @@ -25,7 +25,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to generate requests for contianer objects. * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class ContainerRequest { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java index 6292055b55f1b..2abc6b4978f8a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java @@ -12,8 +12,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to parse the response from container operations - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class ContainerResponse extends BaseResponse { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java index ea772491a7380..f55e29381e23f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java @@ -5,8 +5,6 @@ /** * Specifies options when calling delete operations. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum DeleteSnapshotsOption { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java index 21091147b7401..89a7b17d3e16d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java @@ -14,8 +14,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to parse a get block list response stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class GetBlockListResponse { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java index 81f8a4c236220..5bd2b7dbec02d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java @@ -14,8 +14,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to parse a get page ranges response stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class GetPageRangesResponse { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java index 28243830d39fd..ff48585038bc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java @@ -7,8 +7,6 @@ /** * Represents an item that may be returned by a blob listing operation. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public interface ListBlobItem { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java index b5324ec8ff8db..24f3cf8b79b11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java @@ -15,8 +15,6 @@ /** * RESERVED FOR INTERNAL USE. A class used to parse a list blobs response stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class ListBlobsResponse { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java index 0dbd1fb6dcfa8..cffc95cf5c420 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java @@ -15,8 +15,6 @@ /** * RESERVED FOR INTERNAL USE. A class for parsing a list containers response stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class ListContainersResponse { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java index 9fd233de11486..3a3ec8c2dfcc7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java @@ -2,8 +2,6 @@ /** * RESERVED FOR INTERNAL USE. Describes actions that may be used for writing to a page blob or clearing a set of pages. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ enum PageOperationType { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java index 61baa16d685c1..3452ea7590e12 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java @@ -2,8 +2,6 @@ /** * RESERVED FOR INTERNAL USE. Represents properties for writing to a page blob. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class PageProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java index a02ee9d5c6229..f19e1b93e172f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java @@ -2,8 +2,6 @@ /** * Represents a range of pages in a page blob. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class PageRange { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java index 119039d451d9a..6cda5bd9eb9c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java @@ -4,8 +4,6 @@ /** * Specifies the set of possible permissions for a shared access policy. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum SharedAccessPermissions { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java index b86a4c149f731..43f8f0a66d07a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java @@ -8,8 +8,6 @@ /** * Represents a shared access policy, which specifies the start time, expiry time, and permissions for a shared access * signature. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class SharedAccessPolicy { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java index f43c59cfb22d0..a2a52d437a8af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java @@ -13,8 +13,6 @@ /** * RESERVED FOR INTERNAL USE. Contains helper methods for implementing shared access signatures. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class SharedAccessSignatureHelper { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java index 31879b4dfd622..f8c112ef5282c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java @@ -6,8 +6,6 @@ /** * Represents a set of access conditions to be used for operations against the storage services. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class AccessCondition { 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 1479e9c862fd9..f9ea8a11584b3 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 @@ -2,8 +2,6 @@ /** * Specifies the kinds of conditional headers that may be set for a request. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum AccessConditionHeaderType { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java index dbc5653bb25ae..a1223a506e899 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -8,8 +8,6 @@ /** * Represents a set of access conditions to be used for operations against the storage services. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class AccessCondition { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java index 6fbc8769c19e3..bb625f32a27ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -13,8 +13,6 @@ /** * Represents a Windows Azure storage account. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class CloudStorageAccount { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java index 0295b12044846..2bbdaa3260c69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -2,8 +2,6 @@ /** * Defines constants for use with blob operations, HTTP headers, and query strings. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class Constants { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java index eb3fd1c792cdb..109ff94b49d5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java @@ -7,8 +7,6 @@ /** * Represents the credentials used to sign a request against the storage services. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class Credentials { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java index b7268b5bc0277..0cd4ab5d394b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java @@ -9,8 +9,6 @@ /** * An attribute used to describe a method that will make a request to the storage service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ @Retention(RetentionPolicy.RUNTIME) @Documented diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java index 9aeae0c0e7212..cd6b2ff734e94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java @@ -6,8 +6,6 @@ * * @param * The type of the event to be received. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class EventListener { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java index 574566050b16b..9a564e4ee471d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java @@ -9,8 +9,6 @@ * An object that represents the type of the event. * @param * An object that represents the type of the event listener. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class EventListenerMultiCaster> { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java index df31917581a95..0a09e13532dbb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java @@ -12,8 +12,6 @@ *

* You can check the lease status of a blob to determine whether it currently has an active lease (locked for * exclusive-write access), or whether it is available for exclusive-write access. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum LeaseStatus { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java index 3c6eecff13ddf..69d4accb91db1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java @@ -3,8 +3,6 @@ /** * * Specifies which types of operations the service should log. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum LoggingOperations { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java index 0df26372b07e5..be0f6cf346ce4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java @@ -4,8 +4,6 @@ /** * Represents the logging properties for the analytics service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class LoggingProperties { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java index 593e2e889f9a5..c6a3a4c5ed9a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java @@ -2,8 +2,6 @@ /** * Enumeration representing the state of metrics collection in a service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum MetricsLevel { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java index b784ac8bdeace..a0d20944d346e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java @@ -2,8 +2,6 @@ /** * Represents the metrics properties for the analytics service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class MetricsProperties { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 8e6e675af02fb..a1b07b61f0d39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -12,8 +12,6 @@ /** * Represents the current logical operation. A logical operation has potentially a one-to-many relationship with * individual physical requests. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class OperationContext { @@ -39,7 +37,7 @@ public final class OperationContext { * Represents request results, in the form of an ArrayList object that contains the * {@link RequestResult} objects, for each physical request that is made. */ - private ArrayList requestResults; + private final ArrayList requestResults; /** * Represents an event that is triggered when a response is received from the storage service while processing a diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java index 48eab58ba69a3..27dabab78c6aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java @@ -5,8 +5,6 @@ /** * Represents the options to use while processing a given request. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public class RequestOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java index 18c739479917e..3cbb8fc98497f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java @@ -7,8 +7,6 @@ /** * Represents the result of a physical request. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class RequestResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java index b026d0dd2462a..fcbb5d55f54b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -2,8 +2,6 @@ /** * Represents an event that is fired when a response is received. - * - * Copyright (c)2011 Microsoft */ public final class ResponseReceivedEvent { @@ -11,13 +9,13 @@ public final class ResponseReceivedEvent { * Represents a connection object. Currently only java.net.HttpURLConnection is supported as a * connection object. */ - private Object connectionObject; + private final Object connectionObject; /** * Represents a context for the current operation. This object is used to track requests to the storage service, and * to provide additional runtime information about the operation. */ - private OperationContext opContext; + private final OperationContext opContext; /** * Creates an instance of the ResponseReceivedEvent class. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java index 85357a99936d1..20eca49c5bcb2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java @@ -5,8 +5,6 @@ /** * Represents a continuation token for listing operations. Continuation tokens are used in methods that return a * {@link ResultSegment} object, such as {@link CloudBlobDirectory#listBlobsSegmented}. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class ResultContinuation { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java index f99001107c5d7..0a1dfb2441f43 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java @@ -7,8 +7,6 @@ * * @param * The type of the result that the segment contains. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public class ResultSegment { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java index 63f1263e29f4e..62cf48406af65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java @@ -8,8 +8,6 @@ * * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class RetryExponentialRetry extends RetryPolicy implements RetryPolicyFactory { @@ -78,6 +76,7 @@ public RetryExponentialRetry(final int minBackoff, final int deltaBackoff, final * * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. */ + @Override public RetryPolicy createInstance(final OperationContext opContext) { return new RetryExponentialRetry(this.resolvedMinBackoff, this.deltaBackoffIntervalInMs, this.resolvedMaxBackoff, this.maximumAttempts); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java index a31e2dd437f8a..6e84d54096721 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java @@ -5,8 +5,6 @@ * retries. * * This class extends the {@link RetryPolicy} class and implements the {@link RetryPolicyFactory} interface. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class RetryLinearRetry extends RetryPolicy implements RetryPolicyFactory { @@ -40,6 +38,7 @@ public RetryLinearRetry(final int deltaBackoff, final int maxAttempts) { * * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. */ + @Override public RetryPolicy createInstance(final OperationContext opContext) { return new RetryLinearRetry(this.deltaBackoffIntervalInMs, this.maximumAttempts); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java index cf78fc40bd19e..e08a1edb435fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java @@ -5,8 +5,6 @@ * * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class RetryNoRetry extends RetryPolicy implements RetryPolicyFactory { @@ -34,6 +32,7 @@ public static RetryNoRetry getInstance() { * * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. */ + @Override public RetryPolicy createInstance(final OperationContext opContext) { return getInstance(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java index 210989e314997..229e3c500a4a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java @@ -5,8 +5,6 @@ /** * Abstract class that represents a retry policy. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class RetryPolicy { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java index e7656a7c68a34..772193b559b5b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java @@ -5,8 +5,6 @@ /** * Represents a retry policy factory that creates a new {@link RetryPolicy} object per transaction. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public interface RetryPolicyFactory { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java index 1cce16a49fb76..3bdcd67d74b7c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java @@ -1,18 +1,13 @@ -/** - * - */ package com.microsoft.windowsazure.services.core.storage; /** * Represents the result of a retry policy evaluation. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class RetryResult { /** * Represents the backoff interval in milliseconds. */ - private int backOffIntervalInMs; + private final int backOffIntervalInMs; /** * Indicates whether to retry the operation. Set to true to retry; otherwise, false. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index 5ae4eae908fa7..e7cf32e1ccc92 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -15,8 +15,6 @@ /** * Reserved for internal use. Provides a client for accessing the Windows Azure Storage service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class ServiceClient { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java index ecba39f2067f4..d3fbc1a8ed46e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java @@ -14,8 +14,6 @@ /** * Represents the analytics properties for the service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class ServiceProperties { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index 6f648bb7f70e0..dd8e20823a699 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -15,8 +15,6 @@ /** * Represents a set of credentials used to authenticate access to a Windows Azure storage account. This is the base * class for the {@link StorageCredentialsAccountAndKey} and {@link StorageCredentialsSharedAccessSignature} classes. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class StorageCredentials { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index c8a7b9698aa7f..cca983419d2ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -13,8 +13,6 @@ /** * Represents storage account credentials, based on storage account and access key, for accessing the Windows Azure * storage services. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageCredentialsAccountAndKey extends StorageCredentials { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index 3d1d1c4c6f165..093e17cad06f8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -8,9 +8,6 @@ /** * *RESERVED FOR INTERNAL USE* Represents credentials for anonymous access. This class is used by the internal * implementation (not a public class, so its comments are not built into the Javadoc output). - * - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageCredentialsAnonymous extends StorageCredentials { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index f5590b4e4dc59..c6b1a2d5ad11a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -7,8 +7,6 @@ /** * Represents storage credentials for delegated access to Blob service resources via a shared access signature. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageCredentialsSharedAccessSignature extends StorageCredentials { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java index 3eae71b7668d2..04e6a23c8b037 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java @@ -3,8 +3,6 @@ /** * * Represents error codes that may be returned by the Windows Azure storage services or the storage client library. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum StorageErrorCode { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java index 60f0b09615f4c..0d9aac609d5aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java @@ -2,8 +2,6 @@ /** * Represents error code strings that are common to all storage services. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageErrorCodeStrings { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java index 5f4479594546d..d9b5f4c73a298 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java @@ -9,8 +9,6 @@ /** * Represents an exception for the Windows Azure storage service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageException extends Exception { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java index d9107d897ba5b..22f8a5d712a92 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java @@ -5,8 +5,6 @@ /** * Represents extended error information returned by the Windows Azure storage service. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageExtendedErrorInformation implements Serializable { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java index 0f5d888f92a6c..ab0d1eb3594ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java @@ -16,8 +16,6 @@ /** * Represents a container for a storage key. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageKey { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java index d1d57f6fefc5f..4e695925dd8d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -2,8 +2,6 @@ /** * RESERVED FOR INTERNAL USE. Provides Base64 encoding, decoding, and validation functionality. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class Base64 { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java index 1c640908cb0bb..397ea95e0c01c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -11,8 +11,6 @@ /** * RESERVED FOR INTERNAL USE. A class to help modify paths - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class PathUtility { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java index 09d1e68656ddc..3568dc07355dc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java @@ -2,8 +2,6 @@ /** * RESERVED FOR INTERNAL USE. Represents a stream descriptor that contains the stream size and MD5 hash. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StreamDescriptor { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java index a16e08e98e10f..5b584ac865c5e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java @@ -10,8 +10,6 @@ /** * RESERVED FOR INTERNAL USE. A helper class to help modify the query string of a URI - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class UriQueryBuilder { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index 4f7642617c2a6..1df1901bc14d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -40,8 +40,6 @@ /** * RESERVED FOR INTERNAL USE. A class which provides utility methods. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class Utility { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index 6caccb6d4b0d7..a456d48cad8c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -22,8 +22,6 @@ /** * RESERVED FOR INTERNAL USE. The Base Request class for the protocol layer. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class BaseRequest { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java index b45a8a353729a..0f6ae1beb57bf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java @@ -16,8 +16,6 @@ /** * RESERVED FOR INTERNAL USE. The base response class for the protocol layer - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public class BaseResponse { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java index dc1a61c40704d..286eab5b0b743 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java @@ -14,8 +14,6 @@ /** * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue * Service under the Shared Key authentication scheme. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobQueueFullCanonicalizer extends Canonicalizer { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java index aefe6b9e50e50..6335e8548ad84 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java @@ -11,8 +11,6 @@ /** * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue * Service under the Shared Key authentication scheme. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class BlobQueueLiteCanonicalizer extends Canonicalizer { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java index 04d6d1d68fd16..a0e8b3774cce8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -22,8 +22,6 @@ /** * RESERVED FOR INTERNAL USE. This is a Version 2 Canoncicalization strategy conforming to the PDC 2009-09-19 * specification - * - * Copyright (c)2011 Microsoft. All rights reserved. */ abstract class Canonicalizer { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java index d47cdd28a13f6..00ec6b5a6bcf7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -16,8 +16,6 @@ /** * RESERVED FOR INTERNAL USE. Retrieve appropriate version of CanonicalizationStrategy based on the webrequest for Blob * and Queue. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ final class CanonicalizerFactory { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java index ff2688ad95e9d..1293aadd29115 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java @@ -11,8 +11,6 @@ /** * RESERVED FOR INTERNAL USE. An internal helper class used to parse objects from responses. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class DeserializationHelper { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 1ff0f2bf92a0e..ca0519617f220 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -23,8 +23,6 @@ /** * RESERVED FOR INTERNAL USE. A class that handles execution of StorageOperations and enforces retry policies. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class ExecutionEngine { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java index 02e0cc52db677..a60cdb4517e67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java @@ -19,8 +19,6 @@ * The type of the parent object, i.e. CloudBlobClient for ListContainers etc. * @param * The type of the objects the resulting iterable objects - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class LazySegmentedIterator implements Iterator, Iterable { @@ -88,6 +86,7 @@ public LazySegmentedIterator( /** * Indicates if the iterator has another element. */ + @Override @DoesServiceRequest public boolean hasNext() { while (this.currentSegment == null @@ -116,6 +115,7 @@ public boolean hasNext() { /** * Gets a reference to the iterator. */ + @Override public Iterator iterator() { return this; } @@ -123,6 +123,7 @@ public Iterator iterator() { /** * Returns the next element. */ + @Override public ENTITY_TYPE next() { return this.currentSegmentIterator.next(); } @@ -130,6 +131,7 @@ public ENTITY_TYPE next() { /** * Removes an element, not supported */ + @Override public void remove() { // read only, no-op throw new UnsupportedOperationException(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java index 6c346e67f7165..753a579e301d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java @@ -4,8 +4,6 @@ /** * RESERVED FOR INTERNAL USE. Describes actions that can be performed on a lease. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public enum LeaseAction { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java index 384fb72f9d2fd..250716773473c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java @@ -2,8 +2,6 @@ /** * RESERVED FOR INTERNAL USE. A class which holds the current context of a listing - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public class ListingContext { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java index c6e3ce77c7b6b..23d63130b7f3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java @@ -12,8 +12,6 @@ * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. * @param * The type of the expected result - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class SegmentedStorageOperation extends StorageOperation { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java index 9e17f012d77c4..443bd0af394bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java @@ -12,8 +12,6 @@ /*** * RESERVED FOR INTERNAL USE. A class to help parse the Error details from an input stream. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public final class StorageErrorResponse { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index c166e00de56d3..b53291bb26731 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -16,8 +16,6 @@ * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. * @param * The type of the expected result - * - * Copyright (c)2011 Microsoft. All rights reserved. */ public abstract class StorageOperation { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java index a03d60e17fbe4..9b26f4e808cac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -14,8 +14,6 @@ /** * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Table Service * under the Shared Key Lite authentication scheme. - * - * Copyright (c)2011 Microsoft. All rights reserved. */ class TableLiteCanonicalizer extends Canonicalizer { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index f60eee9dea153..cdd8a8534e593 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -1,8 +1,3 @@ -/* - * CloudQueue.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.OutputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 373448521245b..e4b0b579a2c0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -1,8 +1,3 @@ -/* - * CloudQueueClient.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java index 6944e036f3e54..5ba586314597d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java @@ -1,8 +1,3 @@ -/* - * CloudQueueMessage.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.UnsupportedEncodingException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java index 37a6df34fe49e..999deddd3b839 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java @@ -1,8 +1,3 @@ -/* - * ListQueuesResponse.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java index 473379aa9cfdd..c6b898b98ac38 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java @@ -1,8 +1,3 @@ -/* - * MessageUpdateFields.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index c578953fbd0e3..4bdcf69b600e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -1,8 +1,3 @@ -/* - * QueueConstants.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java index 71c823a289100..401d917f3b5a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java @@ -1,8 +1,3 @@ -/* - * QueueDeserializationHelper.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java index de3ad05a0f816..bd62a1ec61e18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java @@ -1,8 +1,3 @@ -/* - * QueueListingDetails.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java index b7ec1c964876a..05444c986df3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java @@ -1,8 +1,3 @@ -/* - * QueueMessageType.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index 12c83d58385d8..ca6aa3a24bd5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -1,8 +1,3 @@ -/* - * QueueRequest.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java index 012dee7f7522c..61cb94c2c4e39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java @@ -1,8 +1,3 @@ -/* - * QueueRequestOptions.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import com.microsoft.windowsazure.services.core.storage.RequestOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java index 17fb18eb66d71..6c58074eeafd9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java @@ -1,8 +1,3 @@ -/* - * QueueResponse.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ package com.microsoft.windowsazure.services.queue.client; import java.net.HttpURLConnection; From aa5b48f8083eb4adaea67d3ddaaee3bde5e74a1e Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 30 Nov 2011 13:56:06 -0800 Subject: [PATCH 276/664] Add final license/copyright header --- .../serviceruntime/AcquireCurrentState.java | 14 ++++++++++++++ .../serviceruntime/AcquireLeaseInfo.java | 14 ++++++++++++++ .../windowsazure/serviceruntime/Adapter1.java | 14 ++++++++++++++ .../ChunkedGoalStateDeserializer.java | 14 ++++++++++++++ .../serviceruntime/ConfigurationSettingInfo.java | 14 ++++++++++++++ .../ConfigurationSettingsInfo.java | 14 ++++++++++++++ .../serviceruntime/CurrentRoleInstanceInfo.java | 14 ++++++++++++++ .../serviceruntime/CurrentState.java | 11 +++++++++++ .../serviceruntime/CurrentStateInfo.java | 14 ++++++++++++++ .../serviceruntime/CurrentStateSerializer.java | 11 +++++++++++ .../serviceruntime/CurrentStatus.java | 14 ++++++++++++++ .../serviceruntime/CurrentStatusEnum.java | 14 ++++++++++++++ .../serviceruntime/DeploymentInfo.java | 14 ++++++++++++++ .../serviceruntime/EndpointInfo.java | 14 ++++++++++++++ .../serviceruntime/EndpointsInfo.java | 14 ++++++++++++++ .../serviceruntime/ExpectedState.java | 11 +++++++++++ .../serviceruntime/ExpectedStateEnum.java | 14 ++++++++++++++ .../serviceruntime/FileInputChannel.java | 11 +++++++++++ .../serviceruntime/FileOutputChannel.java | 11 +++++++++++ .../windowsazure/serviceruntime/GoalState.java | 11 +++++++++++ .../serviceruntime/GoalStateChangedListener.java | 11 +++++++++++ .../serviceruntime/GoalStateDeserializer.java | 11 +++++++++++ .../serviceruntime/GoalStateInfo.java | 14 ++++++++++++++ .../serviceruntime/InputChannel.java | 11 +++++++++++ .../serviceruntime/LocalResource.java | 16 +++++++++++++++- .../serviceruntime/LocalResourceInfo.java | 14 ++++++++++++++ .../serviceruntime/LocalResourcesInfo.java | 14 ++++++++++++++ .../serviceruntime/ObjectFactory.java | 14 ++++++++++++++ .../serviceruntime/OutputChannel.java | 11 +++++++++++ .../serviceruntime/Protocol1RuntimeClient.java | 13 ++++++++++++- .../Protocol1RuntimeCurrentStateClient.java | 11 +++++++++++ .../Protocol1RuntimeGoalStateClient.java | 11 +++++++++++ .../serviceruntime/ProtocolEnum.java | 14 ++++++++++++++ .../serviceruntime/ReleaseCurrentState.java | 14 ++++++++++++++ .../windowsazure/serviceruntime/Role.java | 16 +++++++++++++++- .../serviceruntime/RoleEnvironment.java | 16 +++++++++++++++- .../serviceruntime/RoleEnvironmentChange.java | 14 ++++++++++++++ .../RoleEnvironmentChangedEvent.java | 14 ++++++++++++++ .../RoleEnvironmentChangedListener.java | 16 +++++++++++++++- .../RoleEnvironmentChangingEvent.java | 16 +++++++++++++++- .../RoleEnvironmentChangingListener.java | 14 ++++++++++++++ ...oleEnvironmentConfigurationSettingChange.java | 16 +++++++++++++++- .../serviceruntime/RoleEnvironmentData.java | 11 +++++++++++ .../RoleEnvironmentDataDeserializer.java | 11 +++++++++++ .../serviceruntime/RoleEnvironmentInfo.java | 14 ++++++++++++++ .../RoleEnvironmentNotAvailableException.java | 11 +++++++++++ .../RoleEnvironmentStoppingListener.java | 16 +++++++++++++++- .../RoleEnvironmentTopologyChange.java | 14 ++++++++++++++ .../windowsazure/serviceruntime/RoleInfo.java | 14 ++++++++++++++ .../serviceruntime/RoleInstance.java | 16 +++++++++++++++- .../serviceruntime/RoleInstanceEndpoint.java | 16 +++++++++++++++- .../serviceruntime/RoleInstanceInfo.java | 14 ++++++++++++++ .../serviceruntime/RoleInstanceStatus.java | 16 +++++++++++++++- .../serviceruntime/RoleInstancesInfo.java | 14 ++++++++++++++ .../windowsazure/serviceruntime/RolesInfo.java | 14 ++++++++++++++ .../serviceruntime/RuntimeClient.java | 11 +++++++++++ .../serviceruntime/RuntimeClientFactory.java | 11 +++++++++++ .../RuntimeCurrentStateClient.java | 11 +++++++++++ .../serviceruntime/RuntimeGoalStateClient.java | 11 +++++++++++ .../serviceruntime/RuntimeKernel.java | 11 +++++++++++ .../RuntimeServerDiscoveryInfo.java | 14 ++++++++++++++ .../RuntimeServerEndpointInfo.java | 14 ++++++++++++++ .../RuntimeServerEndpointsInfo.java | 14 ++++++++++++++ .../serviceruntime/RuntimeVersionManager.java | 11 +++++++++++ .../RuntimeVersionProtocolClient.java | 11 +++++++++++ .../serviceruntime/StatusLeaseInfo.java | 14 ++++++++++++++ .../XmlCurrentStateSerializer.java | 11 +++++++++++ .../serviceruntime/XmlGoalStateDeserializer.java | 11 +++++++++++ .../XmlRoleEnvironmentDataDeserializer.java | 11 +++++++++++ .../services/blob/BlobConfiguration.java | 14 ++++++++++++++ .../windowsazure/services/blob/BlobContract.java | 14 ++++++++++++++ .../windowsazure/services/blob/BlobService.java | 16 +++++++++++++++- .../windowsazure/services/blob/Exports.java | 14 ++++++++++++++ .../blob/client/AccessPolicyResponse.java | 14 ++++++++++++++ .../services/blob/client/BlobAttributes.java | 14 ++++++++++++++ .../services/blob/client/BlobConstants.java | 14 ++++++++++++++ .../blob/client/BlobContainerAttributes.java | 14 ++++++++++++++ .../blob/client/BlobContainerPermissions.java | 14 ++++++++++++++ .../blob/client/BlobContainerProperties.java | 14 ++++++++++++++ .../client/BlobContainerPublicAccessType.java | 14 ++++++++++++++ .../blob/client/BlobDeserializationHelper.java | 14 ++++++++++++++ .../services/blob/client/BlobInputStream.java | 14 ++++++++++++++ .../services/blob/client/BlobListingContext.java | 14 ++++++++++++++ .../services/blob/client/BlobListingDetails.java | 14 ++++++++++++++ .../services/blob/client/BlobOutputStream.java | 14 ++++++++++++++ .../services/blob/client/BlobProperties.java | 14 ++++++++++++++ .../services/blob/client/BlobRequest.java | 14 ++++++++++++++ .../services/blob/client/BlobRequestOptions.java | 11 +++++++++++ .../services/blob/client/BlobResponse.java | 14 ++++++++++++++ .../services/blob/client/BlobType.java | 11 +++++++++++ .../services/blob/client/BlockEntry.java | 14 ++++++++++++++ .../services/blob/client/BlockListingFilter.java | 14 ++++++++++++++ .../services/blob/client/BlockSearchMode.java | 14 ++++++++++++++ .../services/blob/client/CloudBlob.java | 14 ++++++++++++++ .../services/blob/client/CloudBlobClient.java | 14 ++++++++++++++ .../services/blob/client/CloudBlobContainer.java | 14 ++++++++++++++ .../services/blob/client/CloudBlobDirectory.java | 14 ++++++++++++++ .../services/blob/client/CloudBlockBlob.java | 14 ++++++++++++++ .../services/blob/client/CloudPageBlob.java | 14 ++++++++++++++ .../blob/client/ContainerListingDetails.java | 14 ++++++++++++++ .../services/blob/client/ContainerRequest.java | 14 ++++++++++++++ .../services/blob/client/ContainerResponse.java | 14 ++++++++++++++ .../blob/client/DeleteSnapshotsOption.java | 11 +++++++++++ .../blob/client/GetBlockListResponse.java | 14 ++++++++++++++ .../blob/client/GetPageRangesResponse.java | 14 ++++++++++++++ .../services/blob/client/ListBlobItem.java | 14 ++++++++++++++ .../services/blob/client/ListBlobsResponse.java | 14 ++++++++++++++ .../blob/client/ListContainersResponse.java | 14 ++++++++++++++ .../services/blob/client/PageOperationType.java | 14 ++++++++++++++ .../services/blob/client/PageProperties.java | 14 ++++++++++++++ .../services/blob/client/PageRange.java | 14 ++++++++++++++ .../blob/client/SharedAccessPermissions.java | 14 ++++++++++++++ .../services/blob/client/SharedAccessPolicy.java | 14 ++++++++++++++ .../blob/client/SharedAccessSignatureHelper.java | 14 ++++++++++++++ .../implementation/BlobExceptionProcessor.java | 14 ++++++++++++++ .../blob/implementation/BlobRestProxy.java | 14 ++++++++++++++ .../implementation/ContainerACLDateAdapter.java | 14 ++++++++++++++ .../ContainerACLDateConverter.java | 14 ++++++++++++++ .../blob/implementation/HmacSHA256Sign.java | 14 ++++++++++++++ .../blob/implementation/MetadataAdapter.java | 14 ++++++++++++++ .../blob/implementation/RFC1123DateAdapter.java | 14 ++++++++++++++ .../implementation/RFC1123DateConverter.java | 14 ++++++++++++++ .../blob/implementation/SharedKeyFilter.java | 14 ++++++++++++++ .../blob/implementation/SharedKeyLiteFilter.java | 14 ++++++++++++++ .../blob/implementation/SharedKeyUtils.java | 14 ++++++++++++++ .../services/blob/models/AccessCondition.java | 14 ++++++++++++++ .../blob/models/AccessConditionHeaderType.java | 14 ++++++++++++++ .../blob/models/AcquireLeaseOptions.java | 14 ++++++++++++++ .../services/blob/models/AcquireLeaseResult.java | 14 ++++++++++++++ .../services/blob/models/BlobProperties.java | 16 +++++++++++++++- .../services/blob/models/BlobServiceOptions.java | 14 ++++++++++++++ .../services/blob/models/BlockList.java | 14 ++++++++++++++ .../blob/models/CommitBlobBlocksOptions.java | 14 ++++++++++++++ .../services/blob/models/ContainerACL.java | 14 ++++++++++++++ .../services/blob/models/CopyBlobOptions.java | 14 ++++++++++++++ .../blob/models/CreateBlobBlockOptions.java | 14 ++++++++++++++ .../services/blob/models/CreateBlobOptions.java | 14 ++++++++++++++ .../blob/models/CreateBlobPagesOptions.java | 14 ++++++++++++++ .../blob/models/CreateBlobPagesResult.java | 14 ++++++++++++++ .../blob/models/CreateBlobSnapshotOptions.java | 14 ++++++++++++++ .../blob/models/CreateBlobSnapshotResult.java | 14 ++++++++++++++ .../blob/models/CreateContainerOptions.java | 14 ++++++++++++++ .../services/blob/models/DeleteBlobOptions.java | 14 ++++++++++++++ .../blob/models/DeleteContainerOptions.java | 14 ++++++++++++++ .../blob/models/GetBlobMetadataOptions.java | 14 ++++++++++++++ .../blob/models/GetBlobMetadataResult.java | 14 ++++++++++++++ .../services/blob/models/GetBlobOptions.java | 14 ++++++++++++++ .../blob/models/GetBlobPropertiesOptions.java | 14 ++++++++++++++ .../blob/models/GetBlobPropertiesResult.java | 14 ++++++++++++++ .../services/blob/models/GetBlobResult.java | 14 ++++++++++++++ .../blob/models/GetContainerACLResult.java | 14 ++++++++++++++ .../models/GetContainerPropertiesResult.java | 14 ++++++++++++++ .../blob/models/GetServicePropertiesResult.java | 14 ++++++++++++++ .../blob/models/ListBlobBlocksOptions.java | 14 ++++++++++++++ .../blob/models/ListBlobBlocksResult.java | 14 ++++++++++++++ .../blob/models/ListBlobRegionsOptions.java | 14 ++++++++++++++ .../blob/models/ListBlobRegionsResult.java | 14 ++++++++++++++ .../services/blob/models/ListBlobsOptions.java | 14 ++++++++++++++ .../services/blob/models/ListBlobsResult.java | 14 ++++++++++++++ .../blob/models/ListContainersOptions.java | 16 +++++++++++++++- .../blob/models/ListContainersResult.java | 14 ++++++++++++++ .../services/blob/models/PageRange.java | 16 +++++++++++++++- .../services/blob/models/ServiceProperties.java | 14 ++++++++++++++ .../blob/models/SetBlobMetadataOptions.java | 14 ++++++++++++++ .../blob/models/SetBlobMetadataResult.java | 14 ++++++++++++++ .../blob/models/SetBlobPropertiesOptions.java | 14 ++++++++++++++ .../blob/models/SetBlobPropertiesResult.java | 14 ++++++++++++++ .../blob/models/SetContainerMetadataOptions.java | 14 ++++++++++++++ .../windowsazure/services/core/Builder.java | 14 ++++++++++++++ .../services/core/Configuration.java | 14 ++++++++++++++ .../services/core/ConfigurationException.java | 14 ++++++++++++++ .../services/core/DefaultBuilder.java | 14 ++++++++++++++ .../services/core/ExponentialRetryPolicy.java | 14 ++++++++++++++ .../services/core/FilterableService.java | 14 ++++++++++++++ .../windowsazure/services/core/RetryPolicy.java | 14 ++++++++++++++ .../services/core/RetryPolicyFilter.java | 14 ++++++++++++++ .../services/core/ServiceException.java | 14 ++++++++++++++ .../services/core/ServiceFilter.java | 14 ++++++++++++++ .../services/core/storage/AccessCondition.java | 14 ++++++++++++++ .../core/storage/CloudStorageAccount.java | 14 ++++++++++++++ .../services/core/storage/Constants.java | 14 ++++++++++++++ .../services/core/storage/Credentials.java | 11 +++++++++++ .../core/storage/DoesServiceRequest.java | 11 +++++++++++ .../services/core/storage/EventListener.java | 14 ++++++++++++++ .../core/storage/EventListenerMultiCaster.java | 14 ++++++++++++++ .../services/core/storage/LeaseStatus.java | 11 +++++++++++ .../services/core/storage/LoggingOperations.java | 14 ++++++++++++++ .../services/core/storage/LoggingProperties.java | 14 ++++++++++++++ .../services/core/storage/MetricsLevel.java | 14 ++++++++++++++ .../services/core/storage/MetricsProperties.java | 14 ++++++++++++++ .../services/core/storage/OperationContext.java | 11 +++++++++++ .../services/core/storage/RequestOptions.java | 11 +++++++++++ .../services/core/storage/RequestResult.java | 11 +++++++++++ .../core/storage/ResponseReceivedEvent.java | 14 ++++++++++++++ .../core/storage/ResultContinuation.java | 14 ++++++++++++++ .../core/storage/ResultContinuationType.java | 14 ++++++++++++++ .../services/core/storage/ResultSegment.java | 14 ++++++++++++++ .../core/storage/RetryExponentialRetry.java | 14 ++++++++++++++ .../services/core/storage/RetryLinearRetry.java | 14 ++++++++++++++ .../services/core/storage/RetryNoRetry.java | 14 ++++++++++++++ .../services/core/storage/RetryPolicy.java | 11 +++++++++++ .../core/storage/RetryPolicyFactory.java | 11 +++++++++++ .../services/core/storage/RetryResult.java | 14 ++++++++++++++ .../services/core/storage/ServiceClient.java | 14 ++++++++++++++ .../services/core/storage/ServiceProperties.java | 14 ++++++++++++++ .../core/storage/StorageCredentials.java | 11 +++++++++++ .../storage/StorageCredentialsAccountAndKey.java | 11 +++++++++++ .../storage/StorageCredentialsAnonymous.java | 11 +++++++++++ .../StorageCredentialsSharedAccessSignature.java | 14 ++++++++++++++ .../services/core/storage/StorageErrorCode.java | 14 ++++++++++++++ .../core/storage/StorageErrorCodeStrings.java | 14 ++++++++++++++ .../services/core/storage/StorageException.java | 14 ++++++++++++++ .../storage/StorageExtendedErrorInformation.java | 14 ++++++++++++++ .../services/core/storage/StorageKey.java | 11 +++++++++++ .../services/core/storage/utils/Base64.java | 14 ++++++++++++++ .../services/core/storage/utils/PathUtility.java | 14 ++++++++++++++ .../core/storage/utils/StreamDescriptor.java | 14 ++++++++++++++ .../core/storage/utils/UriQueryBuilder.java | 14 ++++++++++++++ .../services/core/storage/utils/Utility.java | 14 ++++++++++++++ .../utils/implementation/BaseRequest.java | 14 ++++++++++++++ .../utils/implementation/BaseResponse.java | 14 ++++++++++++++ .../BlobQueueFullCanonicalizer.java | 11 +++++++++++ .../BlobQueueLiteCanonicalizer.java | 14 ++++++++++++++ .../utils/implementation/Canonicalizer.java | 11 +++++++++++ .../implementation/CanonicalizerFactory.java | 11 +++++++++++ .../implementation/DeserializationHelper.java | 14 ++++++++++++++ .../utils/implementation/ExecutionEngine.java | 14 ++++++++++++++ .../implementation/LazySegmentedIterator.java | 14 ++++++++++++++ .../utils/implementation/LeaseAction.java | 14 ++++++++++++++ .../utils/implementation/ListingContext.java | 14 ++++++++++++++ .../SegmentedStorageOperation.java | 14 ++++++++++++++ .../implementation/StorageErrorResponse.java | 14 ++++++++++++++ .../utils/implementation/StorageOperation.java | 14 ++++++++++++++ .../implementation/TableLiteCanonicalizer.java | 11 +++++++++++ .../services/core/utils/DateFactory.java | 14 ++++++++++++++ .../services/core/utils/DefaultDateFactory.java | 14 ++++++++++++++ .../services/core/utils/Exports.java | 14 ++++++++++++++ .../core/utils/ServiceExceptionFactory.java | 14 ++++++++++++++ .../core/utils/pipeline/Base64StringAdapter.java | 14 ++++++++++++++ .../core/utils/pipeline/ClientFilterAdapter.java | 16 +++++++++++++++- .../utils/pipeline/EntityStreamingListener.java | 14 ++++++++++++++ .../services/core/utils/pipeline/Exports.java | 14 ++++++++++++++ .../utils/pipeline/HttpURLConnectionClient.java | 14 ++++++++++++++ .../pipeline/HttpURLConnectionClientHandler.java | 14 ++++++++++++++ .../core/utils/pipeline/JerseyHelpers.java | 14 ++++++++++++++ .../windowsazure/services/queue/Exports.java | 14 ++++++++++++++ .../services/queue/QueueConfiguration.java | 14 ++++++++++++++ .../services/queue/QueueContract.java | 14 ++++++++++++++ .../services/queue/QueueService.java | 16 +++++++++++++++- .../services/queue/client/CloudQueue.java | 14 ++++++++++++++ .../services/queue/client/CloudQueueClient.java | 14 ++++++++++++++ .../services/queue/client/CloudQueueMessage.java | 14 ++++++++++++++ .../queue/client/ListQueuesResponse.java | 14 ++++++++++++++ .../queue/client/MessageUpdateFields.java | 14 ++++++++++++++ .../services/queue/client/QueueConstants.java | 14 ++++++++++++++ .../queue/client/QueueDeserializationHelper.java | 14 ++++++++++++++ .../queue/client/QueueListingDetails.java | 14 ++++++++++++++ .../services/queue/client/QueueMessageType.java | 14 ++++++++++++++ .../services/queue/client/QueueRequest.java | 14 ++++++++++++++ .../queue/client/QueueRequestOptions.java | 14 ++++++++++++++ .../services/queue/client/QueueResponse.java | 14 ++++++++++++++ .../implementation/QueueExceptionProcessor.java | 14 ++++++++++++++ .../queue/implementation/QueueMessage.java | 14 ++++++++++++++ .../queue/implementation/QueueRestProxy.java | 14 ++++++++++++++ .../queue/implementation/SharedKeyFilter.java | 14 ++++++++++++++ .../implementation/SharedKeyLiteFilter.java | 14 ++++++++++++++ .../queue/models/CreateMessageOptions.java | 14 ++++++++++++++ .../queue/models/CreateQueueOptions.java | 14 ++++++++++++++ .../queue/models/GetQueueMetadataResult.java | 14 ++++++++++++++ .../queue/models/GetServicePropertiesResult.java | 14 ++++++++++++++ .../queue/models/ListMessagesOptions.java | 14 ++++++++++++++ .../queue/models/ListMessagesResult.java | 14 ++++++++++++++ .../services/queue/models/ListQueuesOptions.java | 16 +++++++++++++++- .../services/queue/models/ListQueuesResult.java | 14 ++++++++++++++ .../queue/models/PeekMessagesOptions.java | 14 ++++++++++++++ .../queue/models/PeekMessagesResult.java | 14 ++++++++++++++ .../queue/models/QueueServiceOptions.java | 14 ++++++++++++++ .../services/queue/models/ServiceProperties.java | 14 ++++++++++++++ .../queue/models/UpdateMessageResult.java | 14 ++++++++++++++ .../services/serviceBus/Exports.java | 14 ++++++++++++++ .../serviceBus/ServiceBusConfiguration.java | 14 ++++++++++++++ .../services/serviceBus/ServiceBusContract.java | 14 ++++++++++++++ .../services/serviceBus/ServiceBusService.java | 14 ++++++++++++++ .../windowsazure/services/serviceBus/Util.java | 14 ++++++++++++++ .../implementation/BrokerProperties.java | 14 ++++++++++++++ .../implementation/BrokerPropertiesMapper.java | 14 ++++++++++++++ .../implementation/CustomPropertiesMapper.java | 14 ++++++++++++++ .../serviceBus/implementation/EntryModel.java | 14 ++++++++++++++ .../implementation/EntryModelProvider.java | 14 ++++++++++++++ .../serviceBus/implementation/Exports.java | 14 ++++++++++++++ .../implementation/MarshallerProvider.java | 14 ++++++++++++++ .../NamespacePrefixMapperImpl.java | 14 ++++++++++++++ .../ServiceBusExceptionProcessor.java | 14 ++++++++++++++ .../implementation/ServiceBusRestProxy.java | 14 ++++++++++++++ .../implementation/WrapAccessTokenResult.java | 14 ++++++++++++++ .../serviceBus/implementation/WrapContract.java | 14 ++++++++++++++ .../serviceBus/implementation/WrapFilter.java | 14 ++++++++++++++ .../serviceBus/implementation/WrapRestProxy.java | 14 ++++++++++++++ .../implementation/WrapTokenManager.java | 14 ++++++++++++++ .../serviceBus/models/AbstractListOptions.java | 14 ++++++++++++++ .../serviceBus/models/BrokeredMessage.java | 14 ++++++++++++++ .../serviceBus/models/CreateQueueResult.java | 14 ++++++++++++++ .../serviceBus/models/CreateRuleResult.java | 14 ++++++++++++++ .../models/CreateSubscriptionResult.java | 14 ++++++++++++++ .../serviceBus/models/CreateTopicResult.java | 14 ++++++++++++++ .../serviceBus/models/GetQueueResult.java | 14 ++++++++++++++ .../serviceBus/models/GetRuleResult.java | 14 ++++++++++++++ .../serviceBus/models/GetSubscriptionResult.java | 14 ++++++++++++++ .../serviceBus/models/GetTopicResult.java | 14 ++++++++++++++ .../serviceBus/models/ListQueuesOptions.java | 14 ++++++++++++++ .../serviceBus/models/ListQueuesResult.java | 14 ++++++++++++++ .../serviceBus/models/ListRulesOptions.java | 14 ++++++++++++++ .../serviceBus/models/ListRulesResult.java | 14 ++++++++++++++ .../models/ListSubscriptionsOptions.java | 14 ++++++++++++++ .../models/ListSubscriptionsResult.java | 14 ++++++++++++++ .../serviceBus/models/ListTopicsOptions.java | 14 ++++++++++++++ .../serviceBus/models/ListTopicsResult.java | 14 ++++++++++++++ .../services/serviceBus/models/QueueInfo.java | 14 ++++++++++++++ .../serviceBus/models/ReceiveMessageOptions.java | 14 ++++++++++++++ .../serviceBus/models/ReceiveMessageResult.java | 14 ++++++++++++++ .../services/serviceBus/models/ReceiveMode.java | 14 ++++++++++++++ .../models/ReceiveQueueMessageResult.java | 14 ++++++++++++++ .../models/ReceiveSubscriptionMessageResult.java | 14 ++++++++++++++ .../services/serviceBus/models/RuleInfo.java | 14 ++++++++++++++ .../serviceBus/models/SubscriptionInfo.java | 14 ++++++++++++++ .../services/serviceBus/models/TopicInfo.java | 14 ++++++++++++++ .../builder/AlterClassWithProperties.java | 14 ++++++++++++++ .../ClassWithMultipleCtorMultipleInject.java | 14 ++++++++++++++ .../builder/ClassWithMultipleCtorNoInject.java | 14 ++++++++++++++ .../builder/ClassWithNamedParameter.java | 14 ++++++++++++++ .../builder/ClassWithProperties.java | 14 ++++++++++++++ .../builder/ClassWithSingleCtorNoInject.java | 14 ++++++++++++++ .../builder/DefaultBuilderTest.java | 16 +++++++++++++++- .../serviceruntime/FileInputChannelTests.java | 11 +++++++++++ .../serviceruntime/MockInputChannel.java | 11 +++++++++++ .../Protocol1RuntimeCurrentStateClientTests.java | 11 +++++++++++ .../Protocol1RuntimeGoalStateClientTests.java | 11 +++++++++++ .../serviceruntime/RoleEnvironmentTests.java | 11 +++++++++++ .../RuntimeVersionManagerTests.java | 11 +++++++++++ .../XmlGoalStateDeserializerTests.java | 11 +++++++++++ .../blob/BlobServiceIntegrationTest.java | 14 ++++++++++++++ .../services/blob/IntegrationTestBase.java | 14 ++++++++++++++ .../services/queue/IntegrationTestBase.java | 14 ++++++++++++++ .../queue/QueueServiceIntegrationTest.java | 14 ++++++++++++++ .../serviceBus/BrokerPropertiesMapperTest.java | 14 ++++++++++++++ .../services/serviceBus/IntegrationTestBase.java | 14 ++++++++++++++ .../serviceBus/ServiceBusConfigurationTest.java | 14 ++++++++++++++ .../serviceBus/ServiceBusCreationTest.java | 14 ++++++++++++++ .../serviceBus/ServiceBusIntegrationTest.java | 14 ++++++++++++++ .../CustomPropertiesMapperTest.java | 14 ++++++++++++++ .../WrapRestProxyIntegrationTest.java | 14 ++++++++++++++ .../WrapTokenManagerIntegrationTest.java | 14 ++++++++++++++ .../implementation/WrapTokenManagerTest.java | 14 ++++++++++++++ .../utils/ServiceExceptionFactoryTest.java | 14 ++++++++++++++ 354 files changed, 4819 insertions(+), 19 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java index 6b8c9b5fb11c0..2dd6e66b18581 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.math.BigInteger; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java index fdf1c8a0eab34..7030db4332b2b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java index 7277282500f23..3b35f8d0463e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java index f672cc4b7129a..4d5d2f468fe44 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.io.BufferedReader; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java index 9ea4fc74eaa7d..3c52c56eb5688 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java index b5ac3b805f9b3..152228cced1bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java index aa502627d4b84..78ae4283605f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java index 6b2408f889e75..a297210f77e46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java index dbcd006fd451b..e9ae55b96a160 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java index dff84856d6012..b972bc6c4f516 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java index 0b5b76960c7a1..4117871ddac56 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; enum CurrentStatus { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java index 0e7c4657d3356..01ce61f3ae834 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java index 92bbd0f1f9b77..90b28659fa77a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java index 50401a623c15b..38a846701d74c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java index daed15178a87d..208070113082d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java index 230f498af838b..c341d8630e501 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java index 18125994e9a8e..9f07267449bb1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java index 8a48aa5d3907a..75c85fb7e05b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java index 84c3d054c7b8b..a377a8f42b729 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java index bbe808ddd784f..963b1e88abaf8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java index 440ff116fac8d..68af2418ea7c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java index 8e51706589ca9..c255037d4393b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java index 0293f16adaaf8..fa26a21d40464 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java index a45bee2e0751a..9623dfd83541f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java index a52c64f5568ca..c62ff4aaf8667 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** @@ -77,4 +91,4 @@ public String getRootPath() { public String toString() { return name + " max:" + maximumSizeInMegabytes + "MB path:" + rootPath; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java index 643c5ca6e75eb..524a072ca85a3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java index 3a8ba4a4bb21f..e4c1f724e57c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java index bf4d4e423f770..043b15c7dc373 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java index 2e9ed8f2fa162..02588c1bbd76f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java index 8576109559799..145fd690c46ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; @@ -42,4 +53,4 @@ public void removeGoalStateChangedListener(GoalStateChangedListener listener) { public void setCurrentState(CurrentState state) { currentStateClient.setCurrentState(state); } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java index fb196429a1b9f..5629f11bcf2c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java index 333304ba268b1..5ad4692c4352f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java index 2b3e92aab6215..db453e64c4fc6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java index 8aa2fb7d992c2..a1f55f0c57e14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; class ReleaseCurrentState extends CurrentState { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java index 85c4148b4fba1..aacdb7393c327 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.util.Map; @@ -46,4 +60,4 @@ public Map getInstances() { public String getName() { return name; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index 033003d7e1941..f0bc096b8a1e8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.util.Calendar; @@ -586,4 +600,4 @@ public static synchronized void removeRoleEnvironmentStoppingListener(RoleEnviro stoppingListeners.remove(listener); } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java index 6e5c5646518ea..25f1471358ef3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java index 8627ac2768f82..9dceff6aaa21e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.util.Collection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java index ce3badacf8e3d..f97f3254bf799 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** @@ -19,4 +33,4 @@ public interface RoleEnvironmentChangedListener { */ public void roleEnvironmentChanged(RoleEnvironmentChangedEvent event); -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java index 9159a890944f6..165c01ae04453 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.util.Collection; @@ -59,4 +73,4 @@ boolean isCancelled() { public Collection getChanges() { return changes; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java index 4b2ab7adf15b4..d23826c7636d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java index caf509e49f9b3..8cacec8f39369 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** @@ -23,4 +37,4 @@ public String getConfigurationSettingName() { return settingName; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java index 8b82dcefec028..28d7583ec2dd1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java index 8a16a9e7b8e60..acb58d29d2139 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java index 0cbd9fe328b89..d12e8be57331b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java index 327a19a2b651c..5d677fc39c4b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java index 7f3e17e756922..e226db05b84b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** @@ -14,4 +28,4 @@ public interface RoleEnvironmentStoppingListener { public void roleEnvironmentStopping(); -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java index 95bc92626c9cb..b6e93c6f2defd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java index 5b77b6b7d7473..a658b35195ef7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java index 2201e1a597ea4..e43948abd8b3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.util.Map; @@ -84,4 +98,4 @@ public Role getRole() { public Map getInstanceEndpoints() { return endpoints; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java index 014fa406b61de..2e13e5fb7b09c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; import java.net.InetSocketAddress; @@ -68,4 +82,4 @@ public String getProtocol() { public InetSocketAddress getIpEndPoint() { return ipEndPoint; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java index d259a68e4b34b..16f5d51cdd256 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java index 75aaa8e1ee625..f1dd9d12e3d92 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.serviceruntime; /** @@ -14,4 +28,4 @@ public enum RoleInstanceStatus { * The role instance is ready to accept requests. */ Ready -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java index 316ac5938d03b..128754996001b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java index 20adb3c45bcfe..75c91dd919307 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java index 3f16ff44cd359..8e628daccffb1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java index fec652da83fde..5e08d97c63291 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java index a79e145fce053..253dbe5432640 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java index a73d5d8c9cba7..74f1166990e69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java index c14604888799d..58bc3927ad723 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java index d0297c64f02a8..df4dac6e76ed1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java index b6e6b3b87ca6b..071da2b2710d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java index 9942e972becb1..13dfdd6359893 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java index 0f674cde0ba13..272cc36f59a26 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java index 24cd372481525..4bea2131f367c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java index e5aee0292d421..3d4b1e55bc71f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java index 28ebf42a3747e..b947685e5c855 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java index d8e1a4a001ca2..8499f43b7dd0b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java index 28bc89f60d4d0..4924bc65439b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java index 6ed6499297b9b..d561bcb73a87e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; public class BlobConfiguration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index c471fa9cf6648..e334771a68819 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; import java.io.InputStream; 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/BlobService.java index 912a026babf07..6a35854124a0e 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/BlobService.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; import com.microsoft.windowsazure.services.core.Configuration; @@ -21,4 +35,4 @@ public static BlobContract create(String profile) { public static BlobContract create(String profile, Configuration config) { return config.create(profile, BlobContract.class); } -} \ No newline at end of file +} 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 dfe339003643f..197537a9db826 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java index caa37c0415719..3354bbc7c2ba4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java index 80183b0bd08cc..2b54ba8578bd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java index 09533de03d77b..2180e0f452f05 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java index 6b9aae0c5aee7..e895bc323f75a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java index f37787f34b723..c68f845b18e65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java index 40438432cff02..0c4bcb89db9d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java index 9e3ce6fe610ef..5bec62642940d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java index 47815e883ce49..c04b3123bad66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java index b6a7557f98a17..9b75c6d216eb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java index 742eca52a8691..77c61deb98f30 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java index 1077e6bb9240d..c1e569d0fdebb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java index 5ede30d385f24..50de3fca38c0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java index 419f050ce033f..03ed5236b9741 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java index eb434a39717f2..b958fe925f7b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java index ce1db0ff9bace..9584c4964b490 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.client; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java index 5fcec51155e32..2f08d6ee5f1f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java index a82a23c79af1f..4ef9b4278e972 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.client; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java index c1a2536b94988..aa736238f1e67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java index 38faac0a04358..f792bb272e081 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java index 776759880e047..709f620c33817 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 7d930a9ceb149..0557d92c755ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index db01505ef0263..5c721220734c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 3cdbf2acb6182..124f2b64b38e9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java index 7c372f91eede5..10e90f9193d26 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 3e2c34236b741..e8d20e5705ced 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index 838b2ed34d32a..145bc4a30a9b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java index 81bb92b77f03e..4b5740909ef91 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java index b860d8508d9de..1615cebeac00c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java index 2abc6b4978f8a..7c78dd518927a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java index f55e29381e23f..254f7dfaa953b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.client; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java index 89a7b17d3e16d..fbc8c3b69c958 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java index 5bd2b7dbec02d..d6ea710ad400b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java index ff48585038bc1..d096e92e001ce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java index 24f3cf8b79b11..9e658d4f54c09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java index cffc95cf5c420..cb565025d436d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java index 3a3ec8c2dfcc7..e9c010f4d0772 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java index 3452ea7590e12..e01609e967cb9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java index f19e1b93e172f..9196b0e9deb79 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java index 6cda5bd9eb9c9..79be8d8d25ad9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java index 43f8f0a66d07a..7509c8bcee0c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java index a2a52d437a8af..896c47b5c339a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.client; import java.security.InvalidKeyException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 8b64fcd7fddf9..167add68535be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 446a98ebfb7a4..3c462a01b857e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; 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 26315d2f2f40c..39e67d931a384 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.Date; 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 05cc5fb9b4c0f..209a345d26a0a 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.text.DateFormat; 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 3a41ac996ed19..395d7d9cd393a 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import javax.crypto.Mac; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java index 5f9f3a3775d05..fb07884c72a3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.ArrayList; 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 811042bb2cf63..79387438534b3 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.Date; 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 f8dc6fc29c31c..67d1738a3889d 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.text.DateFormat; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java index 5b8cc02551b46..6481932c7cde0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.Collections; 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 3671f51877455..0134195d5c3aa 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java index b0ca62d7aa767..b3cfcecbf5451 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.implementation; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java index f8c112ef5282c..24018221dc132 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 f9ea8a11584b3..30045ee84b981 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java index 3dbdac8b24071..af9ea1931ee2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java index e7192422b3d74..1565c42585004 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class AcquireLeaseResult { 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 index 4bf3039443394..73d968d1153f6 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/BlobProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; @@ -119,4 +133,4 @@ public long getSequenceNumber() { 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/BlobServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java index b81564284fdd5..879986c2640c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index 06e49f74c0d58..7fcdfe314651b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java index 2b4cf162a052e..b502f18929df1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java index ce247cd084a8c..628d08d95cab6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java index 80f4b9181b1f2..dcecf99c157f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; 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 9f7ba80971f8e..65b3d4b40855f 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class CreateBlobBlockOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java index 1ab6a08a219b5..41fef87ff0cbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java index ec75899e6aff2..cbbde22e0f99b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class CreateBlobPagesOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java index 62501762488ab..b7eb8e83f56df 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java index 0294ae990645e..35ffd6419f97a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java index c7732292a56fa..eeaf0fb61b377 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 779768fee545b..2ad569ba45423 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.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 4bf3193a285fb..729a68c9e99f9 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class DeleteBlobOptions extends BlobServiceOptions { 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 8cac4596758fc..1916ecb70320c 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class DeleteContainerOptions extends BlobServiceOptions { 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 17b9ce55fa6e3..9b1e055d8ae8f 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class GetBlobMetadataOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java index 85c0be6125871..93348f23cdba6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 525fec627591f..e35db2b0c05f6 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class GetBlobOptions extends BlobServiceOptions { 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 4ff1b44978203..8c252723fc180 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class GetBlobPropertiesOptions extends BlobServiceOptions { 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 fca6449392624..9d20e5221e945 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.HashMap; 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 3c65e0cfd8e71..b29a99fee7a27 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.io.InputStream; 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 index a768b51344057..b0277c1b0bac0 100644 --- 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class GetContainerACLResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java index e899bfc7a8621..24c6d318e4995 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 46285ac71fd62..0a5a0e0f16f8b 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class GetServicePropertiesResult { 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 cb4dcbd0b2701..624474ea57f74 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class ListBlobBlocksOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java index c15b6a2b8ac22..125c5cb6934e9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; 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 e4c979ce2f2c7..916981de10f51 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class ListBlobRegionsOptions extends BlobServiceOptions { 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 3887ca6c30cd9..da1ea2e16854b 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 6c8f9e8b485ac..d437f99b8ae7d 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class ListBlobsOptions extends BlobServiceOptions { 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 ff7edfbce5d14..35acf17541c56 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.ArrayList; 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 8901655e81be2..4d795d2410c08 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class ListContainersOptions extends BlobServiceOptions { @@ -47,4 +61,4 @@ public ListContainersOptions 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/blob/models/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java index d55c9fde184e6..36ca841ed734d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 index 0491e45806822..afef6edd6096b 100644 --- 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import javax.xml.bind.annotation.XmlElement; @@ -42,4 +56,4 @@ 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/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 187a272bdccb8..4171ef288f4a7 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import javax.xml.bind.annotation.XmlElement; 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 7f2f7894ece51..c30ec2b0d1f04 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class SetBlobMetadataOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java index 0bde3e5734eb0..abda2abdfdb60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 669de8429d6c6..ed1e9c631cd7d 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class SetBlobPropertiesOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java index 49e2d7eaee7ce..f505058f1890c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; import java.util.Date; 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 cb6ec42d067e3..f27304a09b755 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob.models; public class SetContainerMetadataOptions extends BlobServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java index 487efc61dca4a..5b7459507322c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java index 5080e89484308..1664dec987818 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java index b97325d27d0e2..90fae9f80a1b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; public class ConfigurationException extends RuntimeException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java index 3cbc1e340bf01..9db58f6417612 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.lang.annotation.Annotation; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java index 821b59118c811..a5ff7c5bbae4a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.util.Arrays; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java index 0cdc06d020e17..0e9563b0131ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; public interface FilterableService { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java index 4731f6700bea2..26c6fbd0ca507 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import com.microsoft.windowsazure.services.core.ServiceFilter.Response; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java index 3c3dd9fda233b..72686dcb2e200 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java index 487e73fe6bd55..e9f292f180f94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java index 5b5de010eb791..552202540bc36 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java index a1223a506e899..354f61604b872 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java index bb625f32a27ab..fed6411552840 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java index 2bbdaa3260c69..b9cbfe3c43105 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java index 109ff94b49d5d..d3b03adc72461 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java index 0cd4ab5d394b5..405ccf2fa56d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java index cd6b2ff734e94..f8fc84e323d89 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java index 9a564e4ee471d..c58f493fb7bc4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java index 0a09e13532dbb..d7707825b5419 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java index 69d4accb91db1..b17398e168013 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java index be0f6cf346ce4..490b081a57955 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.util.EnumSet; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java index c6a3a4c5ed9a4..94cf8ba67c346 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java index a0d20944d346e..d1f2acca61bfa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index a1b07b61f0d39..e53c1e208132c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java index 27dabab78c6aa..af0a5c5a07daf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java index 3cbb8fc98497f..050dfcbdb7eea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java index fcbb5d55f54b9..a4cc29204915d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java index 20eca49c5bcb2..c8450867aa9ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import com.microsoft.windowsazure.services.blob.client.CloudBlobDirectory; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java index 9607279122f15..a36eb2ef722ce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java index 0a1dfb2441f43..63afc5805f6b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java index 62cf48406af65..5dc967bcbbeb6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.util.Random; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java index 6e84d54096721..d74d0595bf695 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java index e08a1edb435fb..4818851a2e396 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java index 229e3c500a4a4..7be148342cf2d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java index 772193b559b5b..3345063f2785c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java index 3bdcd67d74b7c..80d74744c470f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index e7cf32e1ccc92..fd747572c5434 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java index d3fbc1a8ed46e..b88fb17e75215 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index dd8e20823a699..d9ec68968a7d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index cca983419d2ee..453bbb6407d12 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index 093e17cad06f8..64d9b8be35ad9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index c6b1a2d5ad11a..16156b07abe74 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java index 04e6a23c8b037..222cd22f87507 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java index 0d9aac609d5aa..feed66f4f8ef0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java index d9b5f4c73a298..06d97fad7e720 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java index 22f8a5d712a92..4d4e65a8f3856 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage; import java.io.Serializable; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java index ab0d1eb3594ac..0c1dd93068b39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java index 4e695925dd8d5..fdbd80f7371d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java index 397ea95e0c01c..34cb97fc8a814 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java index 3568dc07355dc..0163a751b6a2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java index 5b584ac865c5e..0459c94d7b496 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index 1df1901bc14d1..0ed1c0db7a2d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index a456d48cad8c2..e8c595045e618 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java index 0f6ae1beb57bf..e6acc444a7c06 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java index 286eab5b0b743..0b7e2e4d43680 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java index 6335e8548ad84..cf6949cdfcc33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java index a0e8b3774cce8..cd2af8a81c3d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java index 00ec6b5a6bcf7..05b3607322cb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java index 1293aadd29115..7d85bcb3e5941 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index ca0519617f220..c0d3e929d23d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java index a60cdb4517e67..3cada7d30b23a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.util.Iterator; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java index 753a579e301d8..6206d2ef9dda4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import com.microsoft.windowsazure.services.core.storage.Constants; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java index 250716773473c..167b7cfaf0d73 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java index 23d63130b7f3b..91bdfda5e19c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import com.microsoft.windowsazure.services.core.storage.RequestOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java index 443bd0af394bc..7779324a8c8e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index b53291bb26731..2da55c04def5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java index 9b26f4e808cac..8c76b38cd2614 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.storage.utils.implementation; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java index 02af75c7fe6c0..10db79d098ce8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java index d98d63ff1c16c..77e779fcf10b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java index af68b89242d18..c9960912fb974 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils; import com.microsoft.windowsazure.services.core.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index 56fa8b8bd4869..90210ac0e6254 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index 1d45b330e3438..7a28be44bed93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import javax.xml.bind.annotation.adapters.XmlAdapter; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java index d7e147d1cd59d..f486cbbf14015 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import java.io.InputStream; @@ -119,4 +133,4 @@ public InputStream getEntityInputStream() { public void setEntityInputStream(InputStream entity) { clientResponse.setEntityInputStream(entity); } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java index 8ab28a121804d..c3366788b5de7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import com.sun.jersey.api.client.ClientRequest; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index 27349a7775f0d..a562b7c2122e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java index 2b02799f75c13..9b7ca1dd32482 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import com.sun.jersey.api.client.Client; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java index 450f917e4c375..e8eba599def27 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java index 712640f16fbf8..909daeacc3580 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.core.utils.pipeline; import java.util.HashMap; 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 ed6d83fbcaac4..14850f379862e 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.services.core.Builder; 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 index 0cdf198caecda..165df11b234b0 100644 --- 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; public class QueueConfiguration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index 0a43084629d3e..62a6e2b5fb801 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; import java.util.HashMap; 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/QueueService.java index 8c28a3fd9ab26..c457b6b34d39f 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/QueueService.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.services.core.Configuration; @@ -21,4 +35,4 @@ public static QueueContract create(String profile) { public static QueueContract create(String profile, Configuration config) { return config.create(profile, QueueContract.class); } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index cdd8a8534e593..8d511588906a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.OutputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index e4b0b579a2c0e..71fc78af065bf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java index 5ba586314597d..6e116da0c7633 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.UnsupportedEncodingException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java index 999deddd3b839..328a39e3aa7d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java index c6b898b98ac38..1e10b72e8b01b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index 4bdcf69b600e6..7fedb9f268951 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java index 401d917f3b5a0..d2077cb2d5ac0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java index bd62a1ec61e18..dafb259c05e67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java index 05444c986df3e..cbd3ba362450d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index ca6aa3a24bd5f..da78f9d5313c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java index 61cb94c2c4e39..f945aab8d3e65 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import com.microsoft.windowsazure.services.core.storage.RequestOptions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java index 6c58074eeafd9..c3817ad822261 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.client; import java.net.HttpURLConnection; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index a113b4f29a51b..6f68d1f8ec958 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.implementation; import java.util.HashMap; 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 index d19228e959420..cffc724549ac4 100644 --- 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.implementation; import javax.xml.bind.annotation.XmlElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index b1fab27845fcb..fa115bf4c86ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.implementation; import java.util.Arrays; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java index e251bb2b834a3..3707a3f119118 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.implementation; import javax.inject.Named; 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 4bbe297f4ee51..351d6ed8f62f6 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.implementation; import javax.inject.Named; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java index fea533738f4ae..f227771970f49 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class CreateMessageOptions extends QueueServiceOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java index 630677006b1fd..cb79876571241 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.HashMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java index 7d44c071192d1..e412e00ece63a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.HashMap; 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 index 0d80af3228c6c..2a7e788205659 100644 --- 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class GetServicePropertiesResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java index b4a7e92e8d640..2aa19b6409441 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class ListMessagesOptions extends QueueServiceOptions { 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 a6c15fa584b11..af7c53f87ff18 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.ArrayList; 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 c4b7d93726a15..6b62c7cacd2a7 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class ListQueuesOptions extends QueueServiceOptions { @@ -47,4 +61,4 @@ 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/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java index b550126aec2a6..6dc3a704a930d 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java index 46809815dd1b6..9339f83eb958b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class PeekMessagesOptions extends QueueServiceOptions { 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 6a4a49b760975..79990e4391d69 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,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.ArrayList; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java index e75c243729f17..ff574f82e1790 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; public class QueueServiceOptions { 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 78fd4cf5d5151..f676d600b63b7 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import javax.xml.bind.annotation.XmlElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java index fbf13dd87dd89..a57f8be013ffe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue.models; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index 532fcedffb177..053d3b7fcff51 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import java.util.Map; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index f714875cf78cf..824b6c3e83706 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.services.core.Configuration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index a432480f413c6..4459ba1308d82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.services.core.FilterableService; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index 1ae1e8437b3a6..e7d12cf2dd06b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.services.core.Configuration; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index 2409039ebee3b..f2d6ce0404bec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index 549efae90c5d2..0ccbc406d66ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index fe3d5b5e7c3d5..e7892b7116f83 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index 7f1e4c406e456..f377b5c18c294 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.text.DateFormat; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java index 71d618e533851..2edab43e9419d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; public class EntryModel { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java index 4053a779a8c9a..57fe3cd996fc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java index 170d0832825a1..728e70dc4273c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import com.microsoft.windowsazure.services.core.Builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index 719ba346946bf..7654604e20fd1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.ws.rs.Produces; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java index 11b954e7acdb4..5af2ccf6f6df1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import com.sun.xml.bind.marshaller.NamespacePrefixMapper; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index 5138a0ad23ff9..da556270bf0e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.inject.Inject; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index ec63bde251f69..07e6505662738 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.InputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java index da241b3ad9cfb..9732c0741c571 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; public class WrapAccessTokenResult { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java index ba57840a73474..8514686db4329 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 5a2356990c638..a93932dc7b642 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index 51180a8aa23c6..d73638329561d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import javax.inject.Inject; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 4789c26c3a641..e72aac951583d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java index 285d60bcc89c9..b7695de3aa72c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; public abstract class AbstractListOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index ef2bfbdd34efc..e149f01872e70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import java.io.ByteArrayInputStream; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index e7f29c15a0d09..bf617d161f245 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index 3e7bac017081b..4477a1a242d27 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 7dd0df52e7140..477e1abb50e31 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 11e1dfa0b9022..91c5f30d20e84 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index c625bb7e7d9eb..9e3e5da19a070 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java index 2a9217f7137fe..222ae08d8463b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index 15a897f07e8f0..4649f6f2e4b03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index 8a8fbeaeb9be5..d546630c39b52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java index ae44c1e3e74ce..db1d3a1d41c13 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; public class ListQueuesOptions extends AbstractListOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index e7ee67a9f3a45..df68d6fd58608 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java index 1720a3051145b..5ba5ed561814e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; public class ListRulesOptions extends AbstractListOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java index 0766e3896d78a..22cc18bb0d5fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java index 57532efcb586e..472b25a35e6e9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; public class ListSubscriptionsOptions extends AbstractListOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 9ea13c690bd6c..d77f40bfb519a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java index 3a65872bd67ef..54ffa6f364d55 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; public class ListTopicsOptions extends AbstractListOptions { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index efe91c422362b..0aa49b51d9cf9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import java.util.List; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 60d3df9359859..65e08b395acd8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java index 96be7360a7c6e..4e7ffcd2328d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java index 50e80016042b0..e9ca05b07570d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java index 7dfd2cffe1f16..99c7e3e02d394 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java index 14752de848adc..46a0c4a1ac5ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java index 6db761ffcfd35..0436a5a873f16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java index c417d60592f43..a004cf9802018 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index 7dea0733c7857..e8490870583c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 332c0a0906d13..76ac97d68196f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.models; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index cf4e3e4bac6d6..2fa253cd5fc8c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; import java.util.Map; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java index 1eb511b7b5a0e..bab655d1c9a74 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; import javax.inject.Inject; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java index bfb5e28955d6b..9522d97ad251f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; public class ClassWithMultipleCtorNoInject { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java index e9f08cad2e950..cef547f4078c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; import javax.inject.Inject; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java index f0b1e1b49ef62..2c2005676163f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; public class ClassWithProperties { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java index 13a763a60f799..19ed61a0a021a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; public class ClassWithSingleCtorNoInject { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java index dda2c4ca45e04..dc57798032bfc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.configuration.builder; import java.util.HashMap; @@ -162,4 +176,4 @@ public void namedParamatersFallBackFromLeftToRight() throws Exception { Assert.assertEquals("custom.Foo value", result2.getHello()); Assert.assertEquals("testing.custom.Foo value", result3.getHello()); } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java index 8b25ce274ba67..12f9656c17550 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java index 112fd2fab69f1..804022b81da6f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java index 3f9832c3dd986..b18feab92e441 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index ce62a7475b800..c460f04cc62bb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java index 88d11db6ef29a..3ebd677771ca0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java index f6551843d0469..2e8c72b0beda1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java index d70697ee7901a..4222faf05b1fd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java @@ -1,5 +1,16 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.serviceruntime; 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 94fc44dfdf86a..2e5d4b4d2d0e4 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 883b252a65d43..4275e212fb8c0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.blob; import com.microsoft.windowsazure.services.core.Configuration; 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 ac7948d856139..a854804bde36d 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; import com.microsoft.windowsazure.services.core.Configuration; 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 8d57edd746115..db8ca0f130c1e 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 @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.queue; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java index 2f2f8d52be6c8..849fd72e606a8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 3b016bd566c21..9d007ca95458e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import static com.microsoft.windowsazure.services.serviceBus.Util.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 3be67b31ece10..d17f41cf0c7ff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index c88c694d5d8f3..682e56504f3f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ec138e774db94..e1553a7d761ba 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index bba51c2f0b530..7e36a37f13695 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 03efe51854d76..26bb036a1da61 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index f5ade3677e5cb..adc41c9a8fb08 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import junit.framework.Assert; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 7119b7acd88df..1495c7277280c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.services.serviceBus.implementation; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index 24a54a91dd516..3cc8639eb849c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -1,3 +1,17 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.microsoft.windowsazure.utils; import static org.junit.Assert.*; From 4e244d32f7456bdd4a2e380dead1623632d38543 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 30 Nov 2011 14:01:51 -0800 Subject: [PATCH 277/664] Updating custom message properties based on clarifications fixes #152 custom message properties seems to be not sent correctly for service to understand --- .../CustomPropertiesMapper.java | 86 ++++++++++--------- .../implementation/ServiceBusRestProxy.java | 12 ++- .../serviceBus/ServiceBusIntegrationTest.java | 16 ++++ .../CustomPropertiesMapperTest.java | 80 ++++++++--------- 4 files changed, 106 insertions(+), 88 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index 7f1e4c406e456..3fca6ce58f989 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -6,7 +6,6 @@ import java.util.Calendar; import java.util.Date; import java.util.TimeZone; -import java.util.UUID; public class CustomPropertiesMapper { // Fri, 04 Mar 2011 08:49:37 GMT @@ -19,47 +18,41 @@ public String toString(Object value) { Class type = value.getClass(); if (type == Byte.class) { - return value.toString() + ";byte"; - } - else if (type == Character.class) { - return value.toString() + ";char"; + return value.toString(); } else if (type == Short.class) { - return value.toString() + ";short"; + return value.toString(); } else if (type == Integer.class) { - return value.toString() + ";int"; + return value.toString(); } else if (type == Long.class) { - return value.toString() + ";long"; + return value.toString(); } else if (type == Float.class) { - return value.toString() + ";float"; + return value.toString(); } else if (type == Double.class) { - return value.toString() + ";double"; + return value.toString(); } else if (type == Boolean.class) { - return value.toString() + ";bool"; - } - else if (type == UUID.class) { - return value.toString() + ";uuid"; + return value.toString(); } else if (Calendar.class.isAssignableFrom(type)) { DateFormat format = new SimpleDateFormat(RFC_1123); Calendar calendar = (Calendar) value; format.setTimeZone(calendar.getTimeZone()); String formatted = format.format(calendar.getTime()); - return formatted + ";date"; + return "\"" + formatted + "\""; } else if (Date.class.isAssignableFrom(type)) { DateFormat format = new SimpleDateFormat(RFC_1123); format.setTimeZone(TimeZone.getTimeZone("GMT")); String formatted = format.format((Date) value); - return formatted + ";date"; + return "\"" + formatted + "\""; } else { - return value.toString(); + return "\"" + value.toString() + "\""; } } @@ -68,39 +61,50 @@ public Object fromString(String value) throws ParseException { return null; } - if (value.endsWith(";byte")) { - return Byte.parseByte(value.substring(0, value.length() - ";byte".length())); - } - else if (value.endsWith(";char") && value.length() == "X;char".length()) { - return new Character(value.charAt(0)); + if (value.startsWith("\"") && value.endsWith("\"")) { + String text = value.substring(1, value.length() - 1); + if (isRFC1123(text)) { + SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + return format.parse(text); + } + + return text; } - else if (value.endsWith(";short")) { - return Short.parseShort(value.substring(0, value.length() - ";short".length())); + else if ("true".equals(value)) { + return Boolean.TRUE; } - else if (value.endsWith(";int")) { - return Integer.parseInt(value.substring(0, value.length() - ";int".length())); + else if ("false".equals(value)) { + return Boolean.FALSE; } - else if (value.endsWith(";long")) { - return Long.parseLong(value.substring(0, value.length() - ";long".length())); + else if (isInteger(value)) { + return Integer.parseInt(value); } - else if (value.endsWith(";float")) { - return Float.parseFloat(value.substring(0, value.length() - ";float".length())); + else { + return Double.parseDouble(value); } - else if (value.endsWith(";double")) { - return Double.parseDouble(value.substring(0, value.length() - ";double".length())); + } + + private boolean isRFC1123(String text) { + if (text.length() != RFC_1123.length()) { + return false; } - else if (value.endsWith(";bool")) { - return Boolean.parseBoolean(value.substring(0, value.length() - ";bool".length())); + try { + SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + format.parse(text); + return true; } - else if (value.endsWith(";uuid")) { - return UUID.fromString(value.substring(0, value.length() - ";uuid".length())); + catch (ParseException e) { + return false; } - else if (value.endsWith(";date")) { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); - return format.parse(value.substring(0, value.length() - ";date".length())); + } + + private boolean isInteger(String value) { + try { + Integer.parseInt(value); + return true; } - else { - return value; + catch (NumberFormatException e) { + return false; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index ec63bde251f69..84469b71cc0c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,6 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; import java.io.InputStream; +import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -199,7 +200,16 @@ else if (options.isPeekLock()) { for (String key : clientResult.getHeaders().keySet()) { Object value = clientResult.getHeaders().getFirst(key); - message.setProperty(key, value); + try { + value = customPropertiesMapper.fromString(value.toString()); + message.setProperty(key, value); + } + catch (ParseException e) { + //log.warn("Unable to parse custom header", e); + } + catch (NumberFormatException e) { + //log.warn("Unable to parse custom header", e); + } } return message; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ec138e774db94..0e07b91f0f46e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -480,4 +480,20 @@ public void rulesMayHaveActionAndFilter() throws ServiceException { assertEquals(SqlRuleAction.class, ruleFive.getAction().getClass()); } + + @Test + public void messagesMayHaveCustomProperties() throws ServiceException { + // Arrange + String queueName = "TestMessagesMayHaveCustomProperties"; + service.createQueue(new QueueInfo(queueName)); + + // Act + service.sendQueueMessage(queueName, new BrokeredMessage("").setProperty("hello", "world") + .setProperty("foo", 42)); + BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); + + // Assert + assertEquals("world", message.getProperty("hello")); + assertEquals(42, message.getProperty("foo")); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index bba51c2f0b530..b4a210a231b6b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -20,29 +20,29 @@ public void init() { } @Test - public void stringValuesShouldComeThroughUnmodified() { + public void stringValuesShouldComeThroughInQuotes() { // Arrange // Act String text = mapper.toString("This is a string"); // Assert - assertEquals("This is a string", text); + assertEquals("\"This is a string\"", text); } @Test - public void nonStringValuesShouldHaveTypeSuffix() { + public void nonStringValuesShouldNotHaveQuotes() { // Arrange // Act String text = mapper.toString(78); // Assert - assertEquals("78;int", text); + assertEquals("78", text); } @Test - public void supportedJavaTypesHaveExpectedTypeSuffix() { + public void supportedJavaTypesHaveExpectedRepresentations() { // Arrange Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); @@ -51,32 +51,32 @@ public void supportedJavaTypesHaveExpectedTypeSuffix() { // Assert // assertEquals("78;byte", mapper.toString((byte) 78)); - assertEquals("78;byte", mapper.toString((byte) 78)); - assertEquals("a;char", mapper.toString('a')); - assertEquals("-78;short", mapper.toString((short) -78)); + assertEquals("78", mapper.toString((byte) 78)); + assertEquals("\"a\"", mapper.toString('a')); + assertEquals("-78", mapper.toString((short) -78)); // assertEquals("78;ushort", mapper.toString((unsigned short)78); - assertEquals("-78;int", mapper.toString(-78)); + assertEquals("-78", mapper.toString(-78)); // assertEquals("78;uint", mapper.toString(78)); - assertEquals("-78;long", mapper.toString((long) -78)); + assertEquals("-78", mapper.toString((long) -78)); // assertEquals("78;ulong", mapper.toString(78)); - assertEquals("78.5;float", mapper.toString((float) 78.5)); - assertEquals("78.5;double", mapper.toString(78.5)); + assertEquals("78.5", mapper.toString((float) 78.5)); + assertEquals("78.5", mapper.toString(78.5)); //assertEquals("78;decimal", mapper.toString(78)); - assertEquals("true;bool", mapper.toString(true)); - assertEquals("false;bool", mapper.toString(false)); - assertEquals("12345678-9abc-def0-9abc-def012345678;uuid", + assertEquals("true", mapper.toString(true)); + assertEquals("false", mapper.toString(false)); + assertEquals("\"12345678-9abc-def0-9abc-def012345678\"", mapper.toString(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L))); - assertEquals("Thu, 14 Oct 1971 12:34:56 GMT;date", mapper.toString(cal)); - assertEquals("Thu, 14 Oct 1971 12:34:56 GMT;date", mapper.toString(cal.getTime())); + assertEquals("\"Thu, 14 Oct 1971 12:34:56 GMT\"", mapper.toString(cal)); + assertEquals("\"Thu, 14 Oct 1971 12:34:56 GMT\"", mapper.toString(cal.getTime())); //assertEquals("78;date-seconds", mapper.toString(78)); } @Test - public void valuesComeBackAsStringsByDefault() throws ParseException { + public void valuesComeBackAsStringsWhenInQuotes() throws ParseException { // Arrange // Act - Object value = mapper.fromString("Hello world"); + Object value = mapper.fromString("\"Hello world\""); // Assert assertEquals("Hello world", value); @@ -84,11 +84,11 @@ public void valuesComeBackAsStringsByDefault() throws ParseException { } @Test - public void nonStringTypesWillBeParsedBySuffix() throws ParseException { + public void nonStringTypesWillBeParsedAsNumeric() throws ParseException { // Arrange // Act - Object value = mapper.fromString("5;int"); + Object value = mapper.fromString("5"); // Assert assertEquals(5, value); @@ -96,43 +96,31 @@ public void nonStringTypesWillBeParsedBySuffix() throws ParseException { } @Test - public void unknownSuffixWillPassThroughAsString() throws ParseException { - // Arrange - - // Act - Object value = mapper.fromString("Hello;world"); - - // Assert - assertEquals("Hello;world", value); - assertEquals(String.class, value.getClass()); - } - - @Test - public void supportedTypeSuffixesHaveExpectedJavaTypes() throws ParseException { + public void supportedFormatsHaveExpectedJavaTypes() throws ParseException { // Arrange Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); // Act - Date dt = (Date) mapper.fromString("Thu, 14 Oct 1971 12:34:56 GMT;date"); + Date dt = (Date) mapper.fromString("\"Thu, 14 Oct 1971 12:34:56 GMT\""); // Assert // assertEquals("78;byte", mapper.toString((byte) 78)); - assertEquals((byte) 78, mapper.fromString("78;byte")); - assertEquals('a', mapper.fromString("a;char")); - assertEquals((short) -78, mapper.fromString("-78;short")); + // assertEquals((byte) 78, mapper.fromString("78")); + // assertEquals('a', mapper.fromString("a;char")); + // assertEquals((short) -78, mapper.fromString("-78;short")); // assertEquals("78;ushort", mapper.toString((unsigned short)78); - assertEquals(-78, mapper.fromString("-78;int")); + assertEquals(-78, mapper.fromString("-78")); // assertEquals("78;uint", mapper.toString(78)); - assertEquals((long) -78, mapper.fromString("-78;long")); + // assertEquals((long) -78, mapper.fromString("-78;long")); // assertEquals("78;ulong", mapper.toString(78)); - assertEquals((float) 78.5, mapper.fromString("78.5;float")); - assertEquals(78.5, mapper.fromString("78.5;double")); + // assertEquals((float) 78.5, mapper.fromString("78.5;float")); + assertEquals(78.5, mapper.fromString("78.5")); //assertEquals("78;decimal", mapper.toString(78)); - assertEquals(true, mapper.fromString("true;bool")); - assertEquals(false, mapper.fromString("false;bool")); - assertEquals(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L), - mapper.fromString("12345678-9abc-def0-9abc-def012345678;uuid")); + assertEquals(true, mapper.fromString("true")); + assertEquals(false, mapper.fromString("false")); + // assertEquals(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L), + // mapper.fromString("12345678-9abc-def0-9abc-def012345678;uuid")); assertEquals(cal.getTime().getTime(), dt.getTime(), 1000); //assertEquals("78;date-seconds", mapper.toString(78)); From 7b833fe6344312d98260076c582902c13473b0f2 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 29 Nov 2011 12:33:20 -0800 Subject: [PATCH 278/664] Giving WrapTokenManager knowledge of request URI scope There are cases where you may create permissions for an identity that apply to a specific entity. The working assumption is the convention in serviceBus is that the scope of the authorization matches the URL of the operation, without the querystring, and using the http sheme. --- .../serviceBus/implementation/WrapFilter.java | 10 +- .../implementation/WrapTokenManager.java | 21 ++-- .../serviceBus/IntegrationTestBase.java | 1 + .../WrapTokenManagerIntegrationTest.java | 6 +- .../implementation/WrapTokenManagerTest.java | 112 +++++++++++------- 5 files changed, 100 insertions(+), 50 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 5a2356990c638..93aee9ad5eab1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,5 +1,7 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; +import java.net.URISyntaxException; + import com.microsoft.windowsazure.services.core.ServiceException; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; @@ -7,7 +9,7 @@ import com.sun.jersey.api.client.filter.ClientFilter; public class WrapFilter extends ClientFilter { - private WrapTokenManager tokenManager; + private final WrapTokenManager tokenManager; public WrapFilter(WrapTokenManager tokenManager) { this.tokenManager = tokenManager; @@ -18,12 +20,16 @@ public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { String accessToken; try { - accessToken = tokenManager.getAccessToken(); + accessToken = tokenManager.getAccessToken(cr.getURI()); } catch (ServiceException e) { // must wrap exception because of base class signature throw new ClientHandlerException(e); } + catch (URISyntaxException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 4789c26c3a641..8e99f10940a39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -1,6 +1,10 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Date; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; import javax.inject.Named; @@ -16,19 +20,18 @@ public class WrapTokenManager { private final String uri; private final String name; private final String password; - private final String scope; - private ActiveToken activeToken; + private final Map activeTokens; @Inject public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, - @Named("wrap.scope") String scope, @Named("wrap.name") String name, @Named("wrap.password") String password) { + @Named("wrap.name") String name, @Named("wrap.password") String password) { this.contract = contract; this.dateFactory = dateFactory; this.uri = uri; - this.scope = scope; this.name = name; this.password = password; + activeTokens = new ConcurrentHashMap(); } /** @@ -46,9 +49,13 @@ public void setContract(WrapContract contract) { this.contract = contract; } - public String getAccessToken() throws ServiceException { + public String getAccessToken(URI targetUri) throws ServiceException, URISyntaxException { Date now = dateFactory.getDate(); - ActiveToken active = this.activeToken; + + URI scopeUri = new URI("http", targetUri.getAuthority(), targetUri.getPath(), null, null); + String scope = scopeUri.toString(); + + ActiveToken active = this.activeTokens.get(scope); if (active != null && now.before(active.getExpiresUtc())) { return active.getWrapResponse().getAccessToken(); @@ -60,7 +67,7 @@ public String getAccessToken() throws ServiceException { ActiveToken acquired = new ActiveToken(); acquired.setWrapResponse(wrapResponse); acquired.setExpiresUtc(expiresUtc); - this.activeToken = acquired; + this.activeTokens.put(scope, acquired); return wrapResponse.getAccessToken(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 3b016bd566c21..7ab9e45b60459 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -12,6 +12,7 @@ public abstract class IntegrationTestBase { @BeforeClass public static void initializeSystem() { + System.setProperty("http.keepAlive", "false"); } @Before diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index f5ade3677e5cb..55934d9ee435f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -1,10 +1,13 @@ package com.microsoft.windowsazure.services.serviceBus.implementation; +import java.net.URI; + import junit.framework.Assert; import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class WrapTokenManagerIntegrationTest { @Test @@ -14,7 +17,8 @@ public void wrapClientWillAcquireAccessToken() throws Exception { WrapTokenManager client = config.create("serviceBus", WrapTokenManager.class); // Act - String accessToken = client.getAccessToken(); + String wrapScope = (String) config.getProperty(ServiceBusConfiguration.WRAP_SCOPE); + String accessToken = client.getAccessToken(new URI(wrapScope)); // Assert Assert.assertNotNull(accessToken); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 7119b7acd88df..8b4f3a6f4019b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -3,6 +3,8 @@ import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; @@ -27,83 +29,113 @@ public void init() { dateFactory = mock(DateFactory.class); contract = mock(WrapContract.class); - client = new WrapTokenManager(contract, dateFactory, "testurl", "testscope", "testname", "testpassword"); + client = new WrapTokenManager(contract, dateFactory, "testurl", "testname", "testpassword"); when(dateFactory.getDate()).thenAnswer(new Answer() { + @Override public Date answer(InvocationOnMock invocation) throws Throwable { return calendar.getTime(); } }); + } + + private void doIncrementingTokens() throws ServiceException { + doAnswer(new Answer() { + int count = 0; + + @Override + public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { + ++count; + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); + wrapResponse.setAccessToken("testaccesstoken1-" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); + doAnswer(new Answer() { + int count = 0; + + @Override + public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { + ++count; + WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); + wrapResponse.setAccessToken("testaccesstoken2-" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope2"); } @Test - public void clientUsesContractToGetToken() throws ServiceException { + public void clientUsesContractToGetToken() throws ServiceException, URISyntaxException { // Arrange - WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); - wrapResponse.setAccessToken("testaccesstoken"); - wrapResponse.setExpiresIn(83); - - when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + doIncrementingTokens(); // Act - String accessToken = client.getAccessToken(); + String accessToken = client.getAccessToken(new URI("https://test/scope")); // Assert assertNotNull(accessToken); - assertEquals("testaccesstoken", accessToken); + assertEquals("testaccesstoken1-1", accessToken); } @Test - public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException { + public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException, URISyntaxException { // Arrange - WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); - wrapResponse.setAccessToken("testaccesstoken"); - wrapResponse.setExpiresIn(83); - - when(contract.wrapAccessToken("testurl", "testname", "testpassword", "testscope")).thenReturn(wrapResponse); + doIncrementingTokens(); // Act - String accessToken1 = client.getAccessToken(); - String accessToken2 = client.getAccessToken(); + String accessToken1 = client.getAccessToken(new URI("https://test/scope?arg=1")); + String accessToken2 = client.getAccessToken(new URI("https://test/scope?arg=2")); calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken(); + String accessToken3 = client.getAccessToken(new URI("https://test/scope?arg=3")); // Assert - assertEquals("testaccesstoken", accessToken1); - assertEquals("testaccesstoken", accessToken2); - assertEquals("testaccesstoken", accessToken3); + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken1-1", accessToken2); + assertEquals("testaccesstoken1-1", accessToken3); - verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); } @Test - public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException { + public void callsToDifferentPathsWillResultInDifferentAccessTokens() throws ServiceException, URISyntaxException { // Arrange - doAnswer(new Answer() { - int count = 0; + doIncrementingTokens(); - public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { - ++count; - WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); - wrapResponse.setAccessToken("testaccesstoken" + count); - wrapResponse.setExpiresIn(83); - return wrapResponse; - } - }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); + // Act + String accessToken1 = client.getAccessToken(new URI("https://test/scope?arg=1")); + String accessToken2 = client.getAccessToken(new URI("https://test/scope2?arg=2")); + calendar.add(Calendar.SECOND, 40); + String accessToken3 = client.getAccessToken(new URI("https://test/scope?arg=3")); + + // Assert + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken2-1", accessToken2); + assertEquals("testaccesstoken1-1", accessToken3); + + verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); + verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope2"); + } + + @Test + public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException, URISyntaxException { + // Arrange + doIncrementingTokens(); // Act - String accessToken1 = client.getAccessToken(); - String accessToken2 = client.getAccessToken(); + String accessToken1 = client.getAccessToken(new URI("https://test/scope")); + String accessToken2 = client.getAccessToken(new URI("https://test/scope")); calendar.add(Calendar.SECOND, 45); - String accessToken3 = client.getAccessToken(); + String accessToken3 = client.getAccessToken(new URI("https://test/scope")); // Assert - assertEquals("testaccesstoken1", accessToken1); - assertEquals("testaccesstoken1", accessToken2); - assertEquals("testaccesstoken2", accessToken3); + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken1-1", accessToken2); + assertEquals("testaccesstoken1-2", accessToken3); - verify(contract, times(2)).wrapAccessToken("testurl", "testname", "testpassword", "testscope"); + verify(contract, times(2)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); } } From 6aeab7393aef49a4b953b27e836962bf0a2a99c9 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 29 Nov 2011 13:02:05 -0800 Subject: [PATCH 279/664] Remove WRAP_SCOPE from ServiceBusConfiguration constants The scope is determined by knowledge of the request URI conventions. --- .../serviceBus/ServiceBusConfiguration.java | 7 ----- .../ServiceBusConfigurationTest.java | 26 +++++-------------- .../serviceBus/ServiceBusIntegrationTest.java | 1 - .../WrapRestProxyIntegrationTest.java | 4 ++- .../WrapTokenManagerIntegrationTest.java | 4 +-- .../com.microsoft.windowsazure.properties | 1 - 6 files changed, 12 insertions(+), 31 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index f714875cf78cf..36e0206f6446b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -32,12 +32,6 @@ public class ServiceBusConfiguration { */ public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; - /** - * Defines the configuration wrap scope constant. - * - */ - public final static String WRAP_SCOPE = "serviceBus.wrap.scope"; - /** * Creates a service bus configuration using the specified namespace, name, and password. * @@ -124,7 +118,6 @@ else if (profile.length() != 0 && !profile.endsWith(".")) { configuration.setProperty(profile + WRAP_NAME, authenticationName); configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); - configuration.setProperty(profile + WRAP_SCOPE, "http://" + namespace + ".servicebus.windows.net/"); return configuration; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 3be67b31ece10..d4d0288bdd756 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -5,7 +5,6 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; public class ServiceBusConfigurationTest { @Test @@ -17,16 +16,10 @@ public void ConfigureSetsExpectedProperties() { ServiceBusConfiguration.configure(config, "alpha", "beta", "gamma"); // Assert - assertEquals("https://alpha.servicebus.windows.net/", - config.getProperty("serviceBus.uri")); - assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", - config.getProperty("serviceBus.wrap.uri")); - assertEquals("beta", - config.getProperty("serviceBus.wrap.name")); - assertEquals("gamma", - config.getProperty("serviceBus.wrap.password")); - assertEquals("http://alpha.servicebus.windows.net/", - config.getProperty("serviceBus.wrap.scope")); + assertEquals("https://alpha.servicebus.windows.net/", config.getProperty("serviceBus.uri")); + assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", config.getProperty("serviceBus.wrap.uri")); + assertEquals("beta", config.getProperty("serviceBus.wrap.name")); + assertEquals("gamma", config.getProperty("serviceBus.wrap.password")); } @Test @@ -38,15 +31,10 @@ public void UsingProfileAddsPrefix() { ServiceBusConfiguration.configure("backup", config, "alpha", "beta", "gamma"); // Assert - assertEquals("https://alpha.servicebus.windows.net/", - config.getProperty("backup.serviceBus.uri")); + assertEquals("https://alpha.servicebus.windows.net/", config.getProperty("backup.serviceBus.uri")); assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", config.getProperty("backup.serviceBus.wrap.uri")); - assertEquals("beta", - config.getProperty("backup.serviceBus.wrap.name")); - assertEquals("gamma", - config.getProperty("backup.serviceBus.wrap.password")); - assertEquals("http://alpha.servicebus.windows.net/", - config.getProperty("backup.serviceBus.wrap.scope")); + assertEquals("beta", config.getProperty("backup.serviceBus.wrap.name")); + assertEquals("gamma", config.getProperty("backup.serviceBus.wrap.password")); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ec138e774db94..9c069d2dd1b70 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -53,7 +53,6 @@ public void createService() throws Exception { overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); - overrideWithEnv(config, ServiceBusConfiguration.WRAP_SCOPE); // add LoggingFilter to any pipeline that is created Registry builder = (Registry) config.getBuilder(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 03efe51854d76..cb6b1340244c8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -2,6 +2,8 @@ import static org.junit.Assert.*; +import java.net.URI; + import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; @@ -19,7 +21,7 @@ public void serviceCanBeCalledToCreateAccessToken() throws Exception { String uri = (String) config.getProperty(ServiceBusConfiguration.WRAP_URI); String name = (String) config.getProperty(ServiceBusConfiguration.WRAP_NAME); String password = (String) config.getProperty(ServiceBusConfiguration.WRAP_PASSWORD); - String scope = (String) config.getProperty(ServiceBusConfiguration.WRAP_SCOPE); + String scope = new URI("http", new URI(uri).getAuthority(), new URI(uri).getPath(), null, null).toString(); WrapAccessTokenResult result = contract.wrapAccessToken(uri, name, password, scope); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 55934d9ee435f..8f11704c116f5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -17,8 +17,8 @@ public void wrapClientWillAcquireAccessToken() throws Exception { WrapTokenManager client = config.create("serviceBus", WrapTokenManager.class); // Act - String wrapScope = (String) config.getProperty(ServiceBusConfiguration.WRAP_SCOPE); - String accessToken = client.getAccessToken(new URI(wrapScope)); + URI serviceBusURI = new URI((String) config.getProperty(ServiceBusConfiguration.URI)); + String accessToken = client.getAccessToken(serviceBusURI); // Assert Assert.assertNotNull(accessToken); diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index b50e1d15ff441..e7bf06b034de2 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -1,6 +1,5 @@ serviceBus.uri=https://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ serviceBus.wrap.uri=https://%SERVICEBUS_NAMESPACE%-sb.accesscontrol.windows.net/WRAPv0.9 -serviceBus.wrap.scope=http://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ serviceBus.wrap.name=%SERVICEBUS_SERVICEIDENTITY% serviceBus.wrap.password=%SERVICEBUS_SHAREDSECRET% blob.accountName=%BLOB_ACCOUNTNAME% From 83cdd1d69ce7800220601a93975c3ae3afe6759d Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 29 Nov 2011 13:09:51 -0800 Subject: [PATCH 280/664] Sweeping away expired entries in a thread-safe fashion This prevents a neverending accumulation of access tokens for urls that represent things which could have data in the path. A lock location, for example, could have data in the path depending on how the service is implemented. --- .../serviceBus/implementation/WrapTokenManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 8e99f10940a39..26b83dbf597cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -3,7 +3,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Date; +import java.util.Iterator; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; @@ -61,6 +63,15 @@ public String getAccessToken(URI targetUri) throws ServiceException, URISyntaxEx return active.getWrapResponse().getAccessToken(); } + // sweep expired tokens out of collection + Iterator> iterator = activeTokens.entrySet().iterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); + if (!now.before(entry.getValue().getExpiresUtc())) { + iterator.remove(); + } + } + WrapAccessTokenResult wrapResponse = getContract().wrapAccessToken(uri, name, password, scope); Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); From 6f6fd5bf501fe1a71b2f63bc00561fe46a19c2fa Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 30 Nov 2011 14:21:24 -0800 Subject: [PATCH 281/664] Rename method Fixes #107 --- .../services/serviceBus/ServiceBusConfiguration.java | 10 +++++----- .../serviceBus/ServiceBusConfigurationTest.java | 4 ++-- .../services/serviceBus/ServiceBusCreationTest.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index f714875cf78cf..2552519d47309 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -55,8 +55,8 @@ public class ServiceBusConfiguration { * ServiceBusService class. * */ - public static Configuration configure(String namespace, String authenticationName, String authenticationPassword) { - return configure(null, Configuration.getInstance(), namespace, authenticationName, authenticationPassword); + public static Configuration configureWithWrapAuthentication(String namespace, String authenticationName, String authenticationPassword) { + return configureWithWrapAuthentication(null, Configuration.getInstance(), namespace, authenticationName, authenticationPassword); } /** @@ -79,9 +79,9 @@ public static Configuration configure(String namespace, String authenticationNam * ServiceBusService class. * */ - public static Configuration configure(Configuration configuration, String namespace, String authenticationName, + public static Configuration configureWithWrapAuthentication(Configuration configuration, String namespace, String authenticationName, String authenticationPassword) { - return configure(null, configuration, namespace, authenticationName, authenticationPassword); + return configureWithWrapAuthentication(null, configuration, namespace, authenticationName, authenticationPassword); } /** @@ -107,7 +107,7 @@ public static Configuration configure(Configuration configuration, String namesp * ServiceBusService class. * */ - public static Configuration configure(String profile, Configuration configuration, String namespace, + public static Configuration configureWithWrapAuthentication(String profile, Configuration configuration, String namespace, String authenticationName, String authenticationPassword) { if (profile == null) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 3be67b31ece10..0c9ba721a5de8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -14,7 +14,7 @@ public void ConfigureSetsExpectedProperties() { Configuration config = new Configuration(); // Act - ServiceBusConfiguration.configure(config, "alpha", "beta", "gamma"); + ServiceBusConfiguration.configureWithWrapAuthentication(config, "alpha", "beta", "gamma"); // Assert assertEquals("https://alpha.servicebus.windows.net/", @@ -35,7 +35,7 @@ public void UsingProfileAddsPrefix() { Configuration config = new Configuration(); // Act - ServiceBusConfiguration.configure("backup", config, "alpha", "beta", "gamma"); + ServiceBusConfiguration.configureWithWrapAuthentication("backup", config, "alpha", "beta", "gamma"); // Assert assertEquals("https://alpha.servicebus.windows.net/", diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index c88c694d5d8f3..fdc47941ab3a9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -10,7 +10,7 @@ public class ServiceBusCreationTest { @Test public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { - ServiceBusConfiguration.configure("my-namespace", "my-identity", "my-shared-secret"); + ServiceBusConfiguration.configureWithWrapAuthentication("my-namespace", "my-identity", "my-shared-secret"); ServiceBusContract service = ServiceBusService.create(); assertNotNull(service); @@ -19,7 +19,7 @@ public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Excep public Configuration newConfiguration() { Configuration config = new Configuration(); - ServiceBusConfiguration.configure(config, "my-namespace", "my-identity", "my-shared-secret"); + ServiceBusConfiguration.configureWithWrapAuthentication(config, "my-namespace", "my-identity", "my-shared-secret"); return config; } From 39a001c3a1230f8c49306cfc774550316264d4b5 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 30 Nov 2011 16:32:49 -0800 Subject: [PATCH 282/664] Adding license file --- LICENSE.txt | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000000000..d645695673349 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 4df63865cd3d87c42860e7bb749e0c0260b7a6dc Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Wed, 30 Nov 2011 16:33:11 -0800 Subject: [PATCH 283/664] Adding method to create SqlFilter for RuleInfo Based on clarification of the semantics of the xml data model Fixes #161 --- .../services/serviceBus/models/RuleInfo.java | 14 ++++++++++---- .../serviceBus/ServiceBusIntegrationTest.java | 10 ++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java index c417d60592f43..f5c855c5a7524 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java @@ -11,6 +11,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.Filter; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; +import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; @@ -124,16 +125,21 @@ public RuleInfo withCorrelationIdFilter(String correlationId) { return setFilter(filter); } - public RuleInfo withTrueSqlExpressionFilter(String sqlExpression) { - TrueFilter filter = new TrueFilter(); + public RuleInfo withSqlExpressionFilter(String sqlExpression) { + SqlFilter filter = new SqlFilter(); filter.setSqlExpression(sqlExpression); filter.setCompatibilityLevel(20); return setFilter(filter); } - public RuleInfo withFalseSqlExpressionFilter(String sqlExpression) { + public RuleInfo withTrueFilter() { + TrueFilter filter = new TrueFilter(); + filter.setCompatibilityLevel(20); + return setFilter(filter); + } + + public RuleInfo withFalseFilter() { FalseFilter filter = new FalseFilter(); - filter.setSqlExpression(sqlExpression); filter.setCompatibilityLevel(20); return setFilter(filter); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index ec138e774db94..e39a83965a96b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -22,6 +22,7 @@ import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; +import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; @@ -464,13 +465,13 @@ public void rulesMayHaveActionAndFilter() throws ServiceException { // Act RuleInfo ruleOne = service.createRule(topicName, "sub", new RuleInfo("One").withCorrelationIdFilter("my-id")) .getValue(); - RuleInfo ruleTwo = service.createRule(topicName, "sub", - new RuleInfo("Two").withTrueSqlExpressionFilter("my-true-expression")).getValue(); - RuleInfo ruleThree = service.createRule(topicName, "sub", - new RuleInfo("Three").withFalseSqlExpressionFilter("my-false-expression")).getValue(); + RuleInfo ruleTwo = service.createRule(topicName, "sub", new RuleInfo("Two").withTrueFilter()).getValue(); + RuleInfo ruleThree = service.createRule(topicName, "sub", new RuleInfo("Three").withFalseFilter()).getValue(); RuleInfo ruleFour = service.createRule(topicName, "sub", new RuleInfo("Four").withEmptyRuleAction()).getValue(); RuleInfo ruleFive = service.createRule(topicName, "sub", new RuleInfo("Five").withSqlRuleAction("SET x = 5")) .getValue(); + RuleInfo ruleSix = service.createRule(topicName, "sub", new RuleInfo("Six").withSqlExpressionFilter("x != 5")) + .getValue(); // Assert assertEquals(CorrelationFilter.class, ruleOne.getFilter().getClass()); @@ -478,6 +479,7 @@ public void rulesMayHaveActionAndFilter() throws ServiceException { assertEquals(FalseFilter.class, ruleThree.getFilter().getClass()); assertEquals(EmptyRuleAction.class, ruleFour.getAction().getClass()); assertEquals(SqlRuleAction.class, ruleFive.getAction().getClass()); + assertEquals(SqlFilter.class, ruleSix.getFilter().getClass()); } } From 0a67f57d952097fad8c704a9db130ac47b8899d5 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 2 Dec 2011 12:08:54 -0800 Subject: [PATCH 284/664] Fix unit test --- .../implementation/WrapRestProxyIntegrationTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 8a06824695139..9e58ad475a5ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -32,10 +32,12 @@ public void serviceCanBeCalledToCreateAccessToken() throws Exception { WrapContract contract = new WrapRestProxy(config.create(Client.class)); // Act + String serviceBusUri = (String) config.getProperty(ServiceBusConfiguration.URI); String uri = (String) config.getProperty(ServiceBusConfiguration.WRAP_URI); String name = (String) config.getProperty(ServiceBusConfiguration.WRAP_NAME); String password = (String) config.getProperty(ServiceBusConfiguration.WRAP_PASSWORD); - String scope = new URI("http", new URI(uri).getAuthority(), new URI(uri).getPath(), null, null).toString(); + String scope = new URI("http", new URI(serviceBusUri).getAuthority(), new URI(serviceBusUri).getPath(), null, + null).toString(); WrapAccessTokenResult result = contract.wrapAccessToken(uri, name, password, scope); // Assert From f3501e734d10a4bee25b1790bd7c9a1aea74f289 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Fri, 2 Dec 2011 13:49:53 -0800 Subject: [PATCH 285/664] Change version Fixes #171 --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 9925ca4731ae8..8f7b03af6b5a5 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.0.1-SNAPSHOT + 0.1.0 jar Microsoft Windows Azure Client API From a0ade873152d99efce2fa36035bddd1eda793e63 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 2 Dec 2011 16:46:50 -0800 Subject: [PATCH 286/664] Adding legal text to pom.xml "evaluate" plugin used to echo legal text at build time --- microsoft-azure-api/pom.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 8f7b03af6b5a5..5f52b8d6fcff4 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -25,6 +25,7 @@ UTF-8 + @@ -76,6 +77,23 @@ + + org.apache.maven.plugins + maven-help-plugin + 2.1.1 + + + validate + + evaluate + + + legal + + + + + org.apache.maven.plugins maven-compiler-plugin From ef0aff998b4f1c0ac8a64ee36463aeaef95d43c2 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 2 Dec 2011 16:53:32 -0800 Subject: [PATCH 287/664] Updating legal text --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 5f52b8d6fcff4..dbc701915295c 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -25,7 +25,7 @@ UTF-8 - + From 0ab24419f2c08582674cfe023e61878d6a0b52c0 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Fri, 2 Dec 2011 16:22:28 -0800 Subject: [PATCH 288/664] primitive type consistency, rename exist->exist, --- .../blob/client/BlobRequestOptions.java | 16 +++---- .../services/blob/client/CloudBlob.java | 4 +- .../blob/client/CloudBlobContainer.java | 10 ++-- .../core/storage/CloudStorageAccount.java | 4 +- .../core/storage/StorageCredentials.java | 10 ++-- .../StorageCredentialsAccountAndKey.java | 10 ++-- .../storage/StorageCredentialsAnonymous.java | 10 ++-- ...orageCredentialsSharedAccessSignature.java | 10 ++-- .../services/core/storage/utils/Base64.java | 2 +- .../utils/implementation/ExecutionEngine.java | 3 +- .../services/queue/client/CloudQueue.java | 48 +++++++++++++------ .../services/queue/client/QueueConstants.java | 5 ++ .../services/queue/client/QueueRequest.java | 4 +- 13 files changed, 78 insertions(+), 58 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java index 7b5d453e768fc..25ce5c721b460 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java @@ -97,28 +97,28 @@ public Integer getConcurrentRequestCount() { /** * @return the disableContentMD5Validation */ - protected Boolean getDisableContentMD5Validation() { + protected boolean getDisableContentMD5Validation() { return this.disableContentMD5Validation; } /** * @return the storeBlobContentMD5 */ - public Boolean getStoreBlobContentMD5() { + public boolean getStoreBlobContentMD5() { return this.storeBlobContentMD5; } /** * @return the useSparsePageBlob */ - public Boolean getUseSparsePageBlob() { + public boolean getUseSparsePageBlob() { return this.useSparsePageBlob; } /** * @return the useTransactionalContentMD5 */ - public Boolean getUseTransactionalContentMD5() { + public boolean getUseTransactionalContentMD5() { return this.useTransactionalContentMD5; } @@ -134,7 +134,7 @@ public void setConcurrentRequestCount(final Integer concurrentRequestCount) { * @param disableContentMD5Validation * the disableContentMD5Validation to set */ - public void setDisableContentMD5Validation(final Boolean disableContentMD5Validation) { + public void setDisableContentMD5Validation(final boolean disableContentMD5Validation) { this.disableContentMD5Validation = disableContentMD5Validation; } @@ -142,7 +142,7 @@ public void setDisableContentMD5Validation(final Boolean disableContentMD5Valida * @param storeBlobContentMD5 * the storeBlobContentMD5 to set */ - public void setStoreBlobContentMD5(final Boolean storeBlobContentMD5) { + public void setStoreBlobContentMD5(final boolean storeBlobContentMD5) { this.storeBlobContentMD5 = storeBlobContentMD5; } @@ -150,7 +150,7 @@ public void setStoreBlobContentMD5(final Boolean storeBlobContentMD5) { * @param useSparsePageBlob * the useSparsePageBlob to set */ - public void setUseSparsePageBlob(final Boolean useSparsePageBlob) { + public void setUseSparsePageBlob(final boolean useSparsePageBlob) { this.useSparsePageBlob = useSparsePageBlob; } @@ -158,7 +158,7 @@ public void setUseSparsePageBlob(final Boolean useSparsePageBlob) { * @param useTransactionalContentMD5 * the useTransactionalContentMD5 to set */ - public void setUseTransactionalContentMD5(final Boolean useTransactionalContentMD5) { + public void setUseTransactionalContentMD5(final boolean useTransactionalContentMD5) { this.useTransactionalContentMD5 = useTransactionalContentMD5; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index d29643ff5ea62..7685b7c526110 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -640,7 +640,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op * */ @DoesServiceRequest - public final Boolean deleteIfExists() throws StorageException { + public final boolean deleteIfExists() throws StorageException { return this.deleteIfExists(DeleteSnapshotsOption.NONE, null, null, null); } @@ -672,7 +672,7 @@ public final Boolean deleteIfExists() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public final Boolean deleteIfExists(final DeleteSnapshotsOption deleteSnapshotsOption, + public final boolean deleteIfExists(final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 1fe9359de2d5b..b295dd4317211 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -218,7 +218,6 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta // Set attributes final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); - container.setMetadata(attributes.getMetadata()); container.properties = attributes.getProperties(); container.name = attributes.getName(); return null; @@ -238,7 +237,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta * If a storage service error occurred. */ @DoesServiceRequest - public Boolean createIfNotExist() throws StorageException { + public boolean createIfNotExist() throws StorageException { return this.createIfNotExist(null, null); } @@ -260,7 +259,7 @@ public Boolean createIfNotExist() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public Boolean createIfNotExist(BlobRequestOptions options, OperationContext opContext) throws StorageException { + public boolean createIfNotExist(BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -290,7 +289,6 @@ public Boolean execute(final CloudBlobClient client, final CloudBlobContainer co // Set attributes final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, client.isUsePathStyleUris()); - container.metadata = attributes.getMetadata(); container.properties = attributes.getProperties(); container.name = attributes.getName(); return true; @@ -394,7 +392,7 @@ public Void execute(final CloudBlobClient client, final CloudBlobContainer conta * If a storage service error occurred. */ @DoesServiceRequest - public Boolean deleteIfExists() throws StorageException { + public boolean deleteIfExists() throws StorageException { return this.deleteIfExists(null, null); } @@ -416,7 +414,7 @@ public Boolean deleteIfExists() throws StorageException { * If a storage service error occurred. */ @DoesServiceRequest - public Boolean deleteIfExists(BlobRequestOptions options, OperationContext opContext) throws StorageException { + public boolean deleteIfExists(BlobRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java index 6fbc8769c19e3..c7083a3cba55b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -477,7 +477,7 @@ public CloudStorageAccount(final StorageCredentials storageCredentials, final UR // won't ever really happen. // Also eclipse's auto formatting below is horrible - public CloudStorageAccount(final StorageCredentialsAccountAndKey storageCredentials, final Boolean useHttps) + public CloudStorageAccount(final StorageCredentialsAccountAndKey storageCredentials, final boolean useHttps) throws URISyntaxException { this(storageCredentials, new URI(getDefaultBlobEndpoint(useHttps ? Constants.HTTPS : Constants.HTTP, storageCredentials.getAccountName())), new URI(getDefaultQueueEndpoint(useHttps ? Constants.HTTPS @@ -615,7 +615,7 @@ public String toString() { * @param exportSecrets * true to include sensitive data in the string; otherwise, false. */ - public String toString(final Boolean exportSecrets) { + public String toString(final boolean exportSecrets) { if (this.credentials != null && Utility.isNullOrEmpty(this.credentials.getAccountName())) { return this.credentials.toString(exportSecrets); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index 6f648bb7f70e0..6b91e29793a1e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -97,7 +97,7 @@ public static StorageCredentials tryParseCredentials(final String connectionStri // signature string; otherwise, false // /** Reserved. */ - public abstract Boolean canCredentialsComputeHmac(); + public abstract boolean canCredentialsComputeHmac(); // // RESERVED, for internal use only. Gets a value indicating whether a @@ -108,7 +108,7 @@ public static StorageCredentials tryParseCredentials(final String connectionStri // credentials; otherwise, false // /** Reserved. */ - public abstract Boolean canCredentialsSignRequest(); + public abstract boolean canCredentialsSignRequest(); // // RESERVED, for internal use only. Gets a value indicating whether a @@ -119,7 +119,7 @@ public static StorageCredentials tryParseCredentials(final String connectionStri // credentials; otherwise, false // /** Reserved. */ - public abstract Boolean canCredentialsSignRequestLite(); + public abstract boolean canCredentialsSignRequestLite(); /** * Computes a signature for the specified string using the HMAC-SHA256 algorithm. @@ -193,7 +193,7 @@ public static StorageCredentials tryParseCredentials(final String connectionStri // false // /** Reserved. */ - public abstract Boolean doCredentialsNeedTransformUri(); + public abstract boolean doCredentialsNeedTransformUri(); /** * Returns the associated account name for the credentials. @@ -282,7 +282,7 @@ public abstract void signRequestLite(HttpURLConnection request, long contentLeng * true to include sensitive data in the return string; otherwise, false. * @return A String that represents this object, optionally including sensitive data. */ - public abstract String toString(Boolean exportSecrets); + public abstract String toString(boolean exportSecrets); /** * Transforms a resource URI into a shared access signature URI, by appending a shared access token. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index c8a7b9698aa7f..529e2024facfb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -58,7 +58,7 @@ public StorageCredentialsAccountAndKey(final String accountName, final String ke // /** Reserved. */ @Override - public Boolean canCredentialsComputeHmac() { + public boolean canCredentialsComputeHmac() { return true; } @@ -71,7 +71,7 @@ public Boolean canCredentialsComputeHmac() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequest() { + public boolean canCredentialsSignRequest() { return true; } @@ -84,7 +84,7 @@ public Boolean canCredentialsSignRequest() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequestLite() { + public boolean canCredentialsSignRequestLite() { return true; } @@ -172,7 +172,7 @@ public String computeHmac512(final String value, final OperationContext opContex // /** Reserved. */ @Override - public Boolean doCredentialsNeedTransformUri() { + public boolean doCredentialsNeedTransformUri() { return false; } @@ -311,7 +311,7 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long * @return A String that represents this object, optionally including sensitive data. */ @Override - public String toString(final Boolean exportSecrets) { + public String toString(final boolean exportSecrets) { return String.format("%s=%s;%s=%s", CloudStorageAccount.ACCOUNT_NAME_NAME, this.getAccountName(), CloudStorageAccount.ACCOUNT_KEY_NAME, exportSecrets ? this.credentials.getKey().getBase64EncodedKey() : "[key hidden]"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index 3d1d1c4c6f165..bfc4738935c62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -44,7 +44,7 @@ protected StorageCredentialsAnonymous() { // /** Reserved. */ @Override - public Boolean canCredentialsComputeHmac() { + public boolean canCredentialsComputeHmac() { return false; } @@ -57,7 +57,7 @@ public Boolean canCredentialsComputeHmac() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequest() { + public boolean canCredentialsSignRequest() { return false; } @@ -70,7 +70,7 @@ public Boolean canCredentialsSignRequest() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequestLite() { + public boolean canCredentialsSignRequestLite() { return false; } @@ -146,7 +146,7 @@ public String computeHmac512(final String value, final OperationContext opContex // /** Reserved. */ @Override - public Boolean doCredentialsNeedTransformUri() { + public boolean doCredentialsNeedTransformUri() { return false; } @@ -230,7 +230,7 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long * @return a string representation of the credentials, optionally including sensitive data. */ @Override - public String toString(final Boolean exportSecrets) { + public String toString(final boolean exportSecrets) { return Constants.EMPTY_STRING; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index f5590b4e4dc59..225c4695128ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -37,7 +37,7 @@ public StorageCredentialsSharedAccessSignature(final String token) { // /** Reserved. */ @Override - public Boolean canCredentialsComputeHmac() { + public boolean canCredentialsComputeHmac() { return false; } @@ -50,7 +50,7 @@ public Boolean canCredentialsComputeHmac() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequest() { + public boolean canCredentialsSignRequest() { return false; } @@ -63,7 +63,7 @@ public Boolean canCredentialsSignRequest() { // /** Reserved. */ @Override - public Boolean canCredentialsSignRequestLite() { + public boolean canCredentialsSignRequestLite() { return false; } @@ -145,7 +145,7 @@ public String computeHmac512(final String value, final OperationContext opContex // /** Reserved. */ @Override - public Boolean doCredentialsNeedTransformUri() { + public boolean doCredentialsNeedTransformUri() { return true; } @@ -245,7 +245,7 @@ public void signRequestLite(final java.net.HttpURLConnection request, final long * @return A String that represents this object, optionally including sensitive data. */ @Override - public String toString(final Boolean exportSecrets) { + public String toString(final boolean exportSecrets) { return String.format("%s=%s", CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME, exportSecrets ? this.token : "[signature hidden]"); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java index d1d57f6fefc5f..8b73361dae601 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -271,7 +271,7 @@ else if (data.length % 3 == 2) { * the string, as a String object, to validate * @return true if data is a valid Base64 string, otherwise false */ - public static Boolean validateIsBase64String(final String data) { + public static boolean validateIsBase64String(final String data) { if (data == null || data.length() % 4 != 0) { return false; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index 1ff0f2bf92a0e..7d4f051899a6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -134,10 +134,11 @@ public static RESULT_TYPE executeWithRet setLastException(opContext, translatedException); } catch (final XMLStreamException e) { - // Retryable + // Non Retryable, just throw translatedException = StorageException .translateException(getLastRequestObject(opContext), e, opContext); setLastException(opContext, translatedException); + throw translatedException; } catch (final InvalidKeyException e) { // Non Retryable, just throw diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index f60eee9dea153..f7067a16ffd03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -54,22 +54,22 @@ static CloudQueueMessage getFirstOrNull(final Iterable messag /** * The absolute URI of the queue. */ - URI uri; + private URI uri; /** * A reference to the queue's associated service client. */ - private final CloudQueueClient queueServiceClient; + private CloudQueueClient queueServiceClient; /** * The queue's Metadata collection. */ - HashMap metadata; + private HashMap metadata; /** * The queue's approximate message count, as reported by the server. */ - long approximateMessageCount; + private long approximateMessageCount; /** * The messag /** * A flag indicating whether or not the message should be encoded in base-64. */ - Boolean shouldEncodeMessage; + private boolean shouldEncodeMessage; /** * Creates an instance of the CloudQueue class using the specified address and client. @@ -355,7 +355,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean createIfNotExist() throws StorageException { + public boolean createIfNotExist() throws StorageException { return this.createIfNotExist(null, null); } @@ -379,7 +379,7 @@ public Boolean createIfNotExist() throws StorageException { * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean createIfNotExist(QueueRequestOptions options, OperationContext opContext) throws StorageException { + public boolean createIfNotExist(QueueRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -507,7 +507,7 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean deleteIfExists() throws StorageException { + public boolean deleteIfExists() throws StorageException { return this.deleteIfExists(null, null); } @@ -531,7 +531,7 @@ public Boolean deleteIfExists() throws StorageException { * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException { + public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -609,6 +609,7 @@ public void deleteMessage(final CloudQueueMessage message) throws StorageExcepti @DoesServiceRequest public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext) throws StorageException { + Utility.assertNotNull("message", message); if (opContext == null) { opContext = new OperationContext(); } @@ -727,8 +728,8 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean exist() throws StorageException { - return this.exist(null, null); + public boolean exists() throws StorageException { + return this.exists(null, null); } /** @@ -750,7 +751,7 @@ public Boolean exist() throws StorageException { * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Boolean exist(QueueRequestOptions options, OperationContext opContext) throws StorageException { + public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } @@ -865,7 +866,7 @@ public CloudQueueClient getServiceClient() { * * @return A Boolean that represents whether the message should be base-64 encoded. */ - public Boolean getShouldEncodeMessage() { + public boolean getShouldEncodeMessage() { return this.shouldEncodeMessage; } @@ -1011,7 +1012,7 @@ public ArrayList execute(final CloudQueueClient client, final */ @DoesServiceRequest public CloudQueueMessage retrieveMessage() throws StorageException { - return this.retrieveMessage(0, null, null); + return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); } /** @@ -1056,7 +1057,8 @@ public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, f */ @DoesServiceRequest public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { - return this.retrieveMessages(numberOfMessages, 0, null, null); + return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, + null, null); } /** @@ -1090,6 +1092,8 @@ public Iterable retrieveMessages(final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); + Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, + QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); if (opContext == null) { opContext = new OperationContext(); @@ -1143,6 +1147,16 @@ public void setMetadata(final HashMap metadata) { this.metadata = metadata; } + /** + * Sets the flag indicating whether the message should be base-64 encoded. + * + * @param shouldEncodeMessage + * The value indicates whether the message should be base-64 encoded. + */ + public void setShouldEncodeMessage(final boolean shouldEncodeMessage) { + this.shouldEncodeMessage = shouldEncodeMessage; + } + /** * Sets the name of the queue. * @@ -1250,6 +1264,10 @@ public Void execute(final CloudQueueClient client, final CloudQueue queue, final return null; } + message.popReceipt = request.getHeaderField("x-ms-popreceipt"); + message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request + .getHeaderField("x-ms-time-next-visible")); + return null; } }; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index c578953fbd0e3..cfa161c8c2bcc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -24,6 +24,11 @@ final class QueueConstants { */ public static final int MAX_NUMBER_OF_MESSAGES_TO_PEEK = 32; + /** + * Default visibility time out for the retrieve message operation. + */ + public static final int DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS = 30; + /** * The maximum amount of time a message is kept inside the queue, in seconds. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index 12c83d58385d8..7b9d9333d56dc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -495,9 +495,7 @@ public static HttpURLConnection retrieveMessages(final URI uri, final int timeou builder.add("numofmessages", Integer.toString(numberOfMessages)); } - if (visibilityTimeoutInSeconds != 0) { - builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); - } + builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); From 08f88db86c59b481e29cc29990dcb9b61aed4097 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Fri, 2 Dec 2011 16:24:41 -0800 Subject: [PATCH 289/664] primitive scrub cntd. --- .../services/queue/client/CloudQueue.java | 703 ++++++++++-------- .../services/queue/client/QueueConstants.java | 7 +- .../services/queue/client/QueueRequest.java | 19 +- 3 files changed, 406 insertions(+), 323 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index f7067a16ffd03..d0901842ca90a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -156,17 +156,21 @@ public void addMessage(final CloudQueueMessage message) throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, - final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext) - throws StorageException { + public void addMessage( + final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, + QueueRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("message", message); Utility.assertNotNull("messageContent", message.getMessageContentAsByte()); - Utility.assertInBounds("timeToLiveInSeconds", timeToLiveInSeconds, 0, + Utility.assertInBounds("timeToLiveInSeconds", + timeToLiveInSeconds, + 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); - final int realTimeToLiveInSeconds = timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS - : timeToLiveInSeconds; - Utility.assertInBounds("initialVisibilityDelayInSeconds", initialVisibilityDelayInSeconds, 0, + final int realTimeToLiveInSeconds = + timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS : timeToLiveInSeconds; + Utility.assertInBounds("initialVisibilityDelayInSeconds", + initialVisibilityDelayInSeconds, + 0, realTimeToLiveInSeconds - 1); final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); @@ -182,35 +186,42 @@ public void addMessage(final CloudQueueMessage message, final int timeToLiveInSe opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.putMessage(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), initialVisibilityDelayInSeconds, - timeToLiveInSeconds, opContext); + final HttpURLConnection request = + QueueRequest.putMessage(queue.getMessageRequestAddress(), + this.getRequestOptions().getTimeoutIntervalInMs(), + initialVisibilityDelayInSeconds, + timeToLiveInSeconds, + opContext); - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -253,29 +264,34 @@ public void clear(QueueRequestOptions options, OperationContext opContext) throw opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.clearMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = + QueueRequest.clearMessages(queue.getMessageRequestAddress(), this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -318,30 +334,36 @@ public void create(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.create(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED - && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED + && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -391,45 +413,48 @@ public boolean createIfNotExist(QueueRequestOptions options, OperationContext op opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return false; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = StorageException.translateException(request, - null, opContext); - - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.create(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return false; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = + StorageException.translateException(request, null, opContext); + + if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() + .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + } + } else { + this.setNonExceptionedRetryableFailure(true); + } + + return false; } - } - else { - this.setNonExceptionedRetryableFailure(true); - } + }; - return false; - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -472,27 +497,33 @@ public void delete(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.delete(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -543,32 +574,36 @@ public boolean deleteIfExists(QueueRequestOptions options, OperationContext opCo opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } - else { - this.setNonExceptionedRetryableFailure(true); - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + final StorageOperation impl = + new StorageOperation(options) { + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.delete(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return true; + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } else { + this.setNonExceptionedRetryableFailure(true); + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -624,30 +659,34 @@ public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions o final String messageId = message.getId(); final String messagePopReceipt = message.getPopReceipt(); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.deleteMessage( - queue.getIndividualMessageAddress(messageId), - this.getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); + final HttpURLConnection request = + QueueRequest.deleteMessage(queue.getIndividualMessageAddress(messageId), this + .getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -691,31 +730,36 @@ public void downloadAttributes(QueueRequestOptions options, OperationContext opC opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - queue.metadata = BaseResponse.getMetadata(request); - queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); - return null; - } - }; + queue.metadata = BaseResponse.getMetadata(request); + queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -763,34 +807,37 @@ public boolean exists(QueueRequestOptions options, OperationContext opContext) t opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - return Boolean.valueOf(true); - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } - else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Boolean execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = + QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + return Boolean.valueOf(true); + } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -958,8 +1005,9 @@ public Iterable peekMessages(final int numberOfMessages) thro * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable peekMessages(final int numberOfMessages, QueueRequestOptions options, - OperationContext opContext) throws StorageException { + public Iterable peekMessages( + final int numberOfMessages, QueueRequestOptions options, OperationContext opContext) + throws StorageException { Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); if (opContext == null) { @@ -973,31 +1021,36 @@ public Iterable peekMessages(final int numberOfMessages, Queu opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = new StorageOperation>( - options) { + final StorageOperation> impl = + new StorageOperation>(options) { - @Override - public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { + @Override + public ArrayList execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.peekMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); + final HttpURLConnection request = + QueueRequest.peekMessages(queue.getMessageRequestAddress(), this.getRequestOptions() + .getTimeoutIntervalInMs(), numberOfMessages, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), + queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -1012,7 +1065,8 @@ public ArrayList execute(final CloudQueueClient client, final */ @DoesServiceRequest public CloudQueueMessage retrieveMessage() throws StorageException { - return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); + return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, + null, null); } /** @@ -1037,8 +1091,9 @@ public CloudQueueMessage retrieveMessage() throws StorageException { * If a storage service error occurred during the operation. */ @DoesServiceRequest - public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, - final OperationContext opContext) throws StorageException { + public CloudQueueMessage retrieveMessage( + final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext) + throws StorageException { return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, null, null)); } @@ -1057,7 +1112,7 @@ public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, f */ @DoesServiceRequest public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { - return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, + return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); } @@ -1088,11 +1143,13 @@ public Iterable retrieveMessages(final int numberOfMessages) * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable retrieveMessages(final int numberOfMessages, - final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) - throws StorageException { + public Iterable retrieveMessages( + final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, + OperationContext opContext) throws StorageException { Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); - Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, + Utility.assertInBounds("visibilityTimeoutInSeconds", + visibilityTimeoutInSeconds, + 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); if (opContext == null) { @@ -1106,32 +1163,39 @@ public Iterable retrieveMessages(final int numberOfMessages, opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = new StorageOperation>( - options) { + final StorageOperation> impl = + new StorageOperation>(options) { - @Override - public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { + @Override + public ArrayList execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, visibilityTimeoutInSeconds, - opContext); + final HttpURLConnection request = + QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), + this.getRequestOptions().getTimeoutIntervalInMs(), + numberOfMessages, + visibilityTimeoutInSeconds, + opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), + queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -1146,7 +1210,7 @@ public ArrayList execute(final CloudQueueClient client, final public void setMetadata(final HashMap metadata) { this.metadata = metadata; } - + /** * Sets the flag indicating whether the message should be base-64 encoded. * @@ -1211,14 +1275,17 @@ public void updateMessage(final CloudQueueMessage message, final int visibilityT * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, + public void updateMessage( + final CloudQueueMessage message, final int visibilityTimeoutInSeconds, final EnumSet messageUpdateFields, QueueRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("message", message); Utility.assertNotNullOrEmpty("messageId", message.id); Utility.assertNotNullOrEmpty("popReceipt", message.popReceipt); - Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, + Utility.assertInBounds("visibilityTimeoutInSeconds", + visibilityTimeoutInSeconds, + 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); @@ -1234,45 +1301,51 @@ public void updateMessage(final CloudQueueMessage message, final int visibilityT opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.updateMessage(queue.getIndividualMessageAddress(message - .getId()), this.getRequestOptions().getTimeoutIntervalInMs(), message.getPopReceipt(), - visibilityTimeoutInSeconds, opContext); - - if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); - } - else { - request.setFixedLengthStreamingMode(0); - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - message.popReceipt = request.getHeaderField("x-ms-popreceipt"); - message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request - .getHeaderField("x-ms-time-next-visible")); - - return null; - } - }; + final StorageOperation impl = + new StorageOperation(options) { + + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + + final HttpURLConnection request = + QueueRequest.updateMessage(queue.getIndividualMessageAddress(message.getId()), + this.getRequestOptions().getTimeoutIntervalInMs(), + message.getPopReceipt(), + visibilityTimeoutInSeconds, + opContext); + + if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); + + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); + } else { + request.setFixedLengthStreamingMode(0); + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + message.popReceipt = request.getHeaderField("x-ms-popreceipt"); + message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request + .getHeaderField("x-ms-time-next-visible")); + + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } @@ -1317,30 +1390,36 @@ public void uploadMetadata(QueueRequestOptions options, OperationContext opConte opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = new StorageOperation( - options) { + final StorageOperation impl = + new StorageOperation(options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute( + final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = QueueRequest.setMetadata(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = + QueueRequest.setMetadata(queue.uri, + this.getRequestOptions().getTimeoutIntervalInMs(), + opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, + this, + impl, + options.getRetryPolicyFactory(), opContext); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index cfa161c8c2bcc..2f27f07d0aad9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -23,7 +23,7 @@ final class QueueConstants { * The maximum number of messages that can be peeked or retrieved at a time. */ public static final int MAX_NUMBER_OF_MESSAGES_TO_PEEK = 32; - + /** * Default visibility time out for the retrieve message operation. */ @@ -97,8 +97,9 @@ final class QueueConstants { /** * The header that specifies the approximate message count of a queue. */ - public static final String APPROXIMATE_MESSAGES_COUNT = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "approximate-messages-count"; + public static final String APPROXIMATE_MESSAGES_COUNT = + com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER + + "approximate-messages-count"; /** * Private Default Ctor. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index 7b9d9333d56dc..9469039ba80d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -166,7 +166,8 @@ public static HttpURLConnection delete(final URI uri, final int timeout, final O * timeout value is 0, the maximum timeout of 30 seconds is used. * @param popReceipt * A String that contains the pop receipt value - * returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to + * returned from an earlier call to + * {@link CloudQueueMessage#getPopReceipt} for the message to * delete. * @param opContext * An {@link OperationContext} object that represents the context @@ -236,7 +237,8 @@ public static HttpURLConnection downloadAttributes(final URI uri, final int time * request. * * @param message - * A String containing the message to wrap in a message request body. + * A + * String containing the message to wrap in a message request body. * * @return An array of byte containing the message request body * encoded as UTF-8. @@ -265,8 +267,7 @@ public static byte[] generateMessageRequestBody(final String message) throws XML xmlw.writeEndDocument(); try { return outWriter.toString().getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw Utility.generateNewUnexpectedStorageException(e); } } @@ -288,7 +289,8 @@ public static byte[] generateMessageRequestBody(final String message) throws XML * the listing operation, if any. May be null. * @param detailsIncluded * A {@link QueueListingDetails} object that specifies additional - * details to return with the listing, if any. May be null. + * details to return with the listing, if any. May be + * null. * @param opContext * An {@link OperationContext} object that represents the context * for the current operation. This object is used to track @@ -386,8 +388,8 @@ public static HttpURLConnection peekMessages(final URI uri, final int timeout, f /** * Constructs a web request to add a message to the back of the queue. Write - * the encoded message request body generated with a call to {@link #generateMessageRequestBody(String)} to the - * output stream of the + * the encoded message request body generated with a call to + * {@link #generateMessageRequestBody(String)} to the output stream of the * request. Sign the web request with the length of the encoded message * request body. * @@ -556,7 +558,8 @@ public static HttpURLConnection setMetadata(final URI uri, final int timeout, fi * timeout value is 0, the maximum timeout of 30 seconds is used. * @param popReceipt * A String that contains the pop receipt value - * returned from an earlier call to {@link CloudQueueMessage#getPopReceipt} for the message to + * returned from an earlier call to + * {@link CloudQueueMessage#getPopReceipt} for the message to * update. * @param visibilityTimeoutInSeconds * Specifies the new visibility timeout value in seconds, From 5d0f1b3b340564e5134e03faa5566f54616a1a38 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Mon, 5 Dec 2011 13:41:33 -0800 Subject: [PATCH 290/664] Rename utility class --- .../blob/implementation/BlobRestProxy.java | 22 +++++++++---------- .../HttpURLConnectionClientHandler.java | 2 +- ...erseyHelpers.java => PipelineHelpers.java} | 2 +- .../queue/implementation/QueueRestProxy.java | 12 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/{JerseyHelpers.java => PipelineHelpers.java} (99%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 3c462a01b857e..3907ac20db407 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -71,8 +71,8 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; -import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers; -import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; @@ -119,39 +119,39 @@ public BlobContract withFilter(ServiceFilter filter) { } private void ThrowIfError(ClientResponse r) { - JerseyHelpers.ThrowIfError(r); + PipelineHelpers.ThrowIfError(r); } private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - return JerseyHelpers.addOptionalQueryParam(webResource, key, value); + return PipelineHelpers.addOptionalQueryParam(webResource, key, value); } private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); + return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } private Builder addOptionalHeader(Builder builder, String name, Object value) { - return JerseyHelpers.addOptionalHeader(builder, name, value); + return PipelineHelpers.addOptionalHeader(builder, name, value); } private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - return JerseyHelpers.addOptionalMetadataHeader(builder, metadata); + return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); } private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { - return JerseyHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); + return PipelineHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); } private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - return JerseyHelpers.addOptionalAccessContitionHeader(builder, accessCondition); + return PipelineHelpers.addOptionalAccessContitionHeader(builder, accessCondition); } private Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - return JerseyHelpers.addOptionalSourceAccessContitionHeader(builder, accessCondition); + return PipelineHelpers.addOptionalSourceAccessContitionHeader(builder, accessCondition); } private HashMap getMetadataFromHeaders(ClientResponse response) { - return JerseyHelpers.getMetadataFromHeaders(response); + return PipelineHelpers.getMetadataFromHeaders(response); } private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java index e8eba599def27..0610eb8d7bc94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers.EnumCommaStringBuilder; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers.EnumCommaStringBuilder; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.ClientRequest; import com.sun.jersey.api.client.ClientResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java similarity index 99% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java index 909daeacc3580..95fce9e9dbeb2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/JerseyHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java @@ -26,7 +26,7 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; -public class JerseyHelpers { +public class PipelineHelpers { public static void ThrowIfError(ClientResponse r) { if (r.getStatus() >= 300) { throw new UniformInterfaceException(r); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index fa115bf4c86ba..4677d0431b818 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -26,7 +26,7 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; -import com.microsoft.windowsazure.services.core.utils.pipeline.JerseyHelpers; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.queue.QueueConfiguration; import com.microsoft.windowsazure.services.queue.QueueContract; import com.microsoft.windowsazure.services.queue.models.CreateMessageOptions; @@ -88,23 +88,23 @@ public QueueContract withFilter(ServiceFilter filter) { } private void ThrowIfError(ClientResponse r) { - JerseyHelpers.ThrowIfError(r); + PipelineHelpers.ThrowIfError(r); } private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - return JerseyHelpers.addOptionalQueryParam(webResource, key, value); + return PipelineHelpers.addOptionalQueryParam(webResource, key, value); } private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - return JerseyHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); + return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); } private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - return JerseyHelpers.addOptionalMetadataHeader(builder, metadata); + return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); } private HashMap getMetadataFromHeaders(ClientResponse response) { - return JerseyHelpers.getMetadataFromHeaders(response); + return PipelineHelpers.getMetadataFromHeaders(response); } private WebResource getResource(QueueServiceOptions options) { From 3e1dcd3ea67d71aa06390e975950a0892acd1b02 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Tue, 6 Dec 2011 15:07:51 -0800 Subject: [PATCH 291/664] Rename readme file --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 7599ec3e93c4f0c9c983e94ac8a6bbbe89f0c981 Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 7 Dec 2011 09:27:49 -0800 Subject: [PATCH 292/664] Fix pom.xml for Eclipse usage --- microsoft-azure-api/pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index dbc701915295c..c5b7cf4fc6a60 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -163,5 +163,34 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-help-plugin + [2.1.1,) + + evaluate + + + + + + + + + + + + From ca45760425e05302f4c2c86154cb650c71b18423 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Wed, 7 Dec 2011 15:10:31 -0800 Subject: [PATCH 293/664] ASK MODE: rename eventlistener and StreamDescriptor for LCA bliss --- .../windowsazure/services/blob/client/CloudBlob.java | 8 ++++---- .../services/blob/client/CloudBlockBlob.java | 8 ++++---- .../services/core/storage/OperationContext.java | 10 +++++----- .../services/core/storage/ServiceClient.java | 4 ++-- .../{EventListener.java => StorageEvent.java} | 4 +++- ...MultiCaster.java => StorageEventMultiCaster.java} | 4 ++-- ...StreamDescriptor.java => StreamMd5AndLength.java} | 2 +- .../services/core/storage/utils/Utility.java | 12 ++++++------ 8 files changed, 27 insertions(+), 25 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/{EventListener.java => StorageEvent.java} (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/{EventListenerMultiCaster.java => StorageEventMultiCaster.java} (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/{StreamDescriptor.java => StreamMd5AndLength.java} (97%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index d58b96c0565fa..eef555a84b3bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -39,7 +39,7 @@ import com.microsoft.windowsazure.services.core.storage.StorageException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; @@ -807,7 +807,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); - final StreamDescriptor descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, + final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMD5, this.getResult(), opContext); ExecutionEngine.getResponseCode(this.getResult(), request, opContext); @@ -877,7 +877,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op } // 3. Continue copying - final StreamDescriptor descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, + final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMd5, null, opContext); if (validateMd5 && !this.properties.getContentMD5().equals(descriptor.getMd5())) { @@ -2152,7 +2152,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op client.getCredentials().signRequest(request, length); - final StreamDescriptor descriptor = Utility.writeToOutputStream(sourceStream, + final StreamMd5AndLength descriptor = Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true, false, null, opContext); if (length != descriptor.getLength()) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index e8d20e5705ced..f0b6706e07398 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -28,7 +28,7 @@ import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.StorageException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; @@ -175,7 +175,7 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(blockListBytes); - final StreamDescriptor descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + final StreamMd5AndLength descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); @@ -400,7 +400,7 @@ public void upload(final InputStream sourceStream, final long length, final Acce // Mark sourceStream for current position. sourceStream.mark(Integer.MAX_VALUE); - StreamDescriptor descriptor = new StreamDescriptor(); + StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); // If the stream is rewindable and the length is unknown or we need to @@ -516,7 +516,7 @@ public void uploadBlock(final String blockId, final InputStream sourceStream, fi sourceStream.mark(Integer.MAX_VALUE); InputStream bufferedStreamReference = sourceStream; - StreamDescriptor descriptor = new StreamDescriptor(); + StreamMd5AndLength descriptor = new StreamMd5AndLength(); descriptor.setLength(length); if (!sourceStream.markSupported()) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index e53c1e208132c..ce9f10672f90e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -54,11 +54,11 @@ public final class OperationContext { * Represents an event that is triggered when a response is received from the storage service while processing a * request. * - * @see EventListener - * @see EventListenerMultiCaster + * @see StorageEvent + * @see StorageEventMultiCaster * @see ResponseReceivedEvent */ - private EventListenerMultiCaster> responseReceivedEventHandler = new EventListenerMultiCaster>(); + private StorageEventMultiCaster> responseReceivedEventHandler = new StorageEventMultiCaster>(); /** * Reserved for internal use. @@ -156,7 +156,7 @@ public ArrayList getRequestResults() { /** * @return the responseReceivedEventHandler */ - public EventListenerMultiCaster> getResponseReceivedEventHandler() { + public StorageEventMultiCaster> getResponseReceivedEventHandler() { return this.responseReceivedEventHandler; } @@ -220,7 +220,7 @@ private void setLogger(final Logger logger) { * the responseReceivedEventHandler to set */ public void setResponseReceivedEventHandler( - final EventListenerMultiCaster> responseReceivedEventHandler) { + final StorageEventMultiCaster> responseReceivedEventHandler) { this.responseReceivedEventHandler = responseReceivedEventHandler; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index fd747572c5434..871f95bc36bdc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -19,7 +19,7 @@ import java.net.URI; import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; -import com.microsoft.windowsazure.services.core.storage.utils.StreamDescriptor; +import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; @@ -322,7 +322,7 @@ public Void execute(final ServiceClient client, final Void v, final OperationCon final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(propertiesBytes); - final StreamDescriptor descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); + final StreamMd5AndLength descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); client.getCredentials().signRequest(request, descriptor.getLength()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java index f8fc84e323d89..12e0d0cbf2510 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java @@ -14,6 +14,8 @@ */ package com.microsoft.windowsazure.services.core.storage; +import java.util.EventListener; + /** * * Abstract class that represents a generic event listener. @@ -21,7 +23,7 @@ * @param * The type of the event to be received. */ -public abstract class EventListener { +public abstract class StorageEvent implements EventListener { /** * Represents an event that occurred. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java index c58f493fb7bc4..f89c60ab651e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/EventListenerMultiCaster.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java @@ -24,7 +24,7 @@ * @param * An object that represents the type of the event listener. */ -public final class EventListenerMultiCaster> { +public final class StorageEventMultiCaster> { /** * Holds the list of listeners. @@ -48,7 +48,7 @@ public synchronized void addListener(final EVENT_LISTENTER_TYPE listener) { * An EVENTTYPEobject that represents the event being multi-casted. */ public synchronized void fireEvent(final EVENT_TYPE event) { - for (final EventListener listener : this.listeners) { + for (final StorageEvent listener : this.listeners) { listener.eventOccurred(event); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java index 0163a751b6a2c..dd3c2d2b0bfd1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamDescriptor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java @@ -17,7 +17,7 @@ /** * RESERVED FOR INTERNAL USE. Represents a stream descriptor that contains the stream size and MD5 hash. */ -public final class StreamDescriptor { +public final class StreamMd5AndLength { /** * Contains the MD5 hash for the stream data. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index 0ed1c0db7a2d0..169ff1ebfaeaa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -102,14 +102,14 @@ public final class Utility { * @param calculateMD5 * true if an MD5 hash will be calculated; otherwise, false. * - * @return A {@link StreamDescriptor} object that contains the stream length, and optionally the MD5 hash. + * @return A {@link StreamMd5AndLength} object that contains the stream length, and optionally the MD5 hash. * * @throws IOException * If an I/O error occurs. * @throws StorageException * If a storage service error occurred. */ - public static StreamDescriptor analyzeStream(final InputStream sourceStream, long writeLength, long abandonLength, + public static StreamMd5AndLength analyzeStream(final InputStream sourceStream, long writeLength, long abandonLength, final boolean rewindSourceStream, final boolean calculateMD5) throws IOException, StorageException { if (abandonLength < 0) { abandonLength = Long.MAX_VALUE; @@ -137,7 +137,7 @@ public static StreamDescriptor analyzeStream(final InputStream sourceStream, lon writeLength = Long.MAX_VALUE; } - final StreamDescriptor retVal = new StreamDescriptor(); + final StreamMd5AndLength retVal = new StreamMd5AndLength(); int count = -1; final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; @@ -896,14 +896,14 @@ public static String trimStart(final String value) { * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * - * @return A {@link StreamDescriptor} object that contains the output stream length, and optionally the MD5 hash. + * @return A {@link StreamMd5AndLength} object that contains the output stream length, and optionally the MD5 hash. * * @throws IOException * If an I/O error occurs. * @throws StorageException * If a storage service error occurred. */ - public static StreamDescriptor writeToOutputStream(final InputStream sourceStream, final OutputStream outStream, + public static StreamMd5AndLength writeToOutputStream(final InputStream sourceStream, final OutputStream outStream, long writeLength, final boolean rewindSourceStream, final boolean calculateMD5, final RequestResult currentResult, final OperationContext opContext) throws IOException, StorageException { if (opContext != null) { @@ -925,7 +925,7 @@ public static StreamDescriptor writeToOutputStream(final InputStream sourceStrea } } - final StreamDescriptor retVal = new StreamDescriptor(); + final StreamMd5AndLength retVal = new StreamMd5AndLength(); if (writeLength < 0) { writeLength = Long.MAX_VALUE; From ba9f55cf2dac4dcf2458b7afbae42689aceba2dc Mon Sep 17 00:00:00 2001 From: Toddy Mladenov Date: Thu, 8 Dec 2011 09:58:02 -0800 Subject: [PATCH 294/664] Populated the README.md file with information Populated the README.md file with information for getting started --- README.md | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/README.md b/README.md index e69de29bb2d1d..1bc96bc7bdb37 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,121 @@ +

Windows Azure SDK for Java

+

This SDK allows you to build Windows Azure applications in Java that allow +you to take advantage of Azure scalable cloud computing resources: table and blob +storage, messaging through Service Bus.

+ +

The SDK components available in this respository are:

+
    +
  • Client Libraries for Windows Azure Service Runtime, Storage Services and + Service Bus
  • +
  • Code Samples
  • +
  • Basic Tests
  • +
+

For documentation please see the +Windows Azure Java Developer Center

+ +

Getting Started

+

Download

+

Option 1: Via Git

+

To get the source code of the SDK via git just type:
+

git clone git://github.com/WindowsAzure/azure-sdk-for-java.git
+cd ./azure-sdk-for-java
+ +

Option 2: Via Maven

+

To get the binaries of this library as distributed by Microsoft, ready for use +within your project you can also have them installed by the Java package manager Maven.
+


+  com.microsoft.windowsazure
+  microsoft-windowsazure-api
+  0.1.0
+

+ +

Usage

+

To use this SDK to call Windows Azure services, you need to first create an +account. To host your Java code in Windows Azure, you additionally need to download +the full Windows Azure SDK for Java � which includes packaging, emulation, and +deployment tools.

+ +

Code Samples

+

The following is a quick example on how to set up a Azure blob using the API +and uploading a file to it.
+ +

import com.microsoft.windowsazure.services.core.storage.*;
+import com.microsoft.windowsazure.services.blob.client.*;
+
+public class BlobSample {
+
+    public static final String storageConnectionString = 
+            "DefaultEndpointsProtocol=http;" + 
+               "AccountName=your_account_name;" + 
+               "AccountKey= your_account_name"; 
+
+    public static void main(String[] args) 
+    {
+        try
+        {
+            CloudStorageAccount account;
+            CloudBlobClient serviceClient;
+            CloudBlobContainer container;
+            CloudBlockBlob blob;
+            
+            account = CloudStorageAccount.parse(storageConnectionString);
+            serviceClient = account.createCloudBlobClient();
+            // Container name must be lower case.
+            container = serviceClient.getContainerReference("blobsample");
+            container.createIfNotExist();
+            
+            // Set anonymous access on the container.
+            BlobContainerPermissions containerPermissions;
+            containerPermissions = new BlobContainerPermissions();
+
+            // Upload an image file.
+            blob = container.getBlockBlobReference("image1.jpg");
+            File fileReference = new File ("c:\\myimages\\image1.jpg");
+blob.upload(new FileInputStream(fileReference), fileReference.length());
+        }
+        catch (FileNotFoundException fileNotFoundException)
+        {
+            System.out.print("FileNotFoundException encountered: ");
+            System.out.println(fileNotFoundException.getMessage());
+            System.exit(-1);
+        }
+        catch (StorageException storageException)
+        {
+            System.out.print("StorageException encountered: ");
+            System.out.println(storageException.getMessage());
+            System.exit(-1);
+        }
+        catch (Exception e)
+        {
+            System.out.print("Exception encountered: ");
+            System.out.println(e.getMessage());
+            System.exit(-1);
+        }
+        
+    }
+}
+

+ +

Minimum Requirements

+
    +
  • Java 1.6
  • +
+ +

Need Help?

+

Be sure to check out the Windows Azure +Developer Forums on Stack Overflow if you have trouble with the provided code.

+ +

Feedback

+

For feedback related specificically to this SDK, please use the Issues +section of the repository.

+

For general suggestions about Windows Azure please use our +UserVoice forum.

+ +

Learn More

+ + From d451c0cf986badc254ec87d2eee975554d50f5d4 Mon Sep 17 00:00:00 2001 From: "Toddy Mladenov (Microsoft)" Date: Thu, 8 Dec 2011 10:00:00 -0800 Subject: [PATCH 295/664] Fixed encoding issues in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bc96bc7bdb37..8e35fe397bace 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ within your project you can also have them installed by the Java package manager

Usage

To use this SDK to call Windows Azure services, you need to first create an account. To host your Java code in Windows Azure, you additionally need to download -the full Windows Azure SDK for Java � which includes packaging, emulation, and +the full Windows Azure SDK for Java - which includes packaging, emulation, and deployment tools.

Code Samples

From 08a4a820d445d94a6a63b562d35e734791221dda Mon Sep 17 00:00:00 2001 From: joostdenijs Date: Thu, 8 Dec 2011 12:37:38 -0800 Subject: [PATCH 296/664] Update README.md --- README.md | 58 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 8e35fe397bace..764ab798b3ab1 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,53 @@ you to take advantage of Azure scalable cloud computing resources: table and blob storage, messaging through Service Bus.

-

The SDK components available in this respository are:

-
    -
  • Client Libraries for Windows Azure Service Runtime, Storage Services and - Service Bus
  • -
  • Code Samples
  • -
  • Basic Tests
  • -

For documentation please see the Windows Azure Java Developer Center

+

Features

+
    +
  • Blob +
      +
    • Create/Read/Update/Delete Blobs
    • +
  • +
  • Queue +
      +
    • Create/Delete Queues
    • +
    • Insert/Peek Queue Messages
    • +
    • Advanced Queue Operations
    • +
  • +
  • Service Bus +
      +
    • Use either the Queue or Topic/Subscription Model
    • +
  • +
  • Service Runtime +
      +
    • Retrieve information about the state of your Azure Compute instances
    • +
  • +
+

Getting Started

Download

Option 1: Via Git

To get the source code of the SDK via git just type:

git clone git://github.com/WindowsAzure/azure-sdk-for-java.git
-cd ./azure-sdk-for-java
+cd ./azure-sdk-for-java +mvn compile

Option 2: Via Maven

To get the binaries of this library as distributed by Microsoft, ready for use within your project you can also have them installed by the Java package manager Maven.
-


-  com.microsoft.windowsazure
-  microsoft-windowsazure-api
-  0.1.0
-

+
<dependency>
+  <groupId>com.microsoft.windowsazure</groupId>
+  <artifactId>microsoft-windowsazure-api</artifactId>
+  <version>0.1.0</version>
+</dependency>

+ +

Minimum Requirements

+
    +
  • Java 1.6
  • +
  • (Optional) Maven
  • +

Usage

To use this SDK to call Windows Azure services, you need to first create an @@ -37,7 +59,8 @@ deployment tools.

Code Samples

The following is a quick example on how to set up a Azure blob using the API -and uploading a file to it.
+and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed +here.

import com.microsoft.windowsazure.services.core.storage.*;
 import com.microsoft.windowsazure.services.blob.client.*;
@@ -71,7 +94,7 @@ public class BlobSample {
             // Upload an image file.
             blob = container.getBlockBlobReference("image1.jpg");
             File fileReference = new File ("c:\\myimages\\image1.jpg");
-blob.upload(new FileInputStream(fileReference), fileReference.length());
+            blob.upload(new FileInputStream(fileReference), fileReference.length());
         }
         catch (FileNotFoundException fileNotFoundException)
         {
@@ -96,11 +119,6 @@ blob.upload(new FileInputStream(fileReference), fileReference.length());
 }
 

-

Minimum Requirements

-
    -
  • Java 1.6
  • -
-

Need Help?

Be sure to check out the Windows Azure Developer Forums on Stack Overflow if you have trouble with the provided code.

From b33766ea0b0ef495bfbe8823644cff1825c0077c Mon Sep 17 00:00:00 2001 From: Walter Blaurock Date: Fri, 9 Dec 2011 10:42:25 -0800 Subject: [PATCH 297/664] Fixed string-comparison bug in service runtime. --- .../serviceruntime/XmlRoleEnvironmentDataDeserializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java index 4924bc65439b9..8f27d2a1e3469 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java @@ -85,7 +85,7 @@ private Map translateRoles(RoleEnvironmentInfo environmentInfo, Ro for (RoleInfo roleInfo : environmentInfo.getRoles().getRole()) { Map instances = translateRoleInstances(roleInfo.getInstances()); - if (roleInfo.getName() == currentRole) { + if (roleInfo.getName().equals(currentRole)) { instances.put(currentInstance.getId(), currentInstance); } From fec97ea3b5550e662fd8a55428daec4d0f85175b Mon Sep 17 00:00:00 2001 From: Renaud Paquay Date: Wed, 14 Dec 2011 11:29:13 -0800 Subject: [PATCH 298/664] Update version # --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index c5b7cf4fc6a60..e0685a46028e8 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.1.0 + 0.1.1 jar Microsoft Windows Azure Client API From 09ffd0321330bbf2c0069c0aa92b469a83fb0745 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Mon, 19 Dec 2011 16:04:26 -0800 Subject: [PATCH 299/664] Hotfix: Update CloudBlob.download to lock to etag during a resume. Extended Error null fix. Signed-off-by: Joe Giardino --- .../services/blob/client/CloudBlob.java | 41 +- .../blob/client/CloudBlobContainer.java | 27 +- .../services/queue/client/CloudQueue.java | 730 ++++++++---------- 3 files changed, 374 insertions(+), 424 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index eef555a84b3bd..5c409c6f7c6bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -2,15 +2,15 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.client; @@ -37,6 +37,7 @@ import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; @@ -807,6 +808,8 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); final long expectedLength = Long.parseLong(contentLength); + blob.updatePropertiesFromResponse(request); + final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, validateMD5, this.getResult(), opContext); @@ -817,8 +820,6 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op return null; } - blob.updatePropertiesFromResponse(request); - if (descriptor.getLength() != expectedLength) { throw new StorageException( StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, @@ -855,8 +856,15 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op // be outside the operation above as it would get retried resulting // in a nested retry + // Copy access condition, and update etag. This will potentially replace the if match value, but not on the + // users object. + + AccessCondition etagLockCondition = new AccessCondition(); + etagLockCondition.setIfMatch(this.getProperties().getEtag()); + etagLockCondition.setLeaseID(accessCondition.getLeaseID()); + // 1. Open Read Stream - final BlobInputStream streamRef = this.openInputStream(accessCondition, options, opContext); + final BlobInputStream streamRef = this.openInputStream(etagLockCondition, options, opContext); // Cache value indicating if we need final boolean validateMd5 = streamRef.getValidateBlobMd5(); @@ -2029,8 +2037,15 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op final StorageException potentialConflictException = StorageException.translateException(request, null, opContext); - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { + StorageExtendedErrorInformation extendedInfo = potentialConflictException + .getExtendedErrorInformation(); + + if (extendedInfo == null) { + // If we cant validate the error then the error must be surfaced to the user. + throw potentialConflictException; + } + + if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { this.setException(potentialConflictException); this.setNonExceptionedRetryableFailure(true); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 60aab1eff8728..3d9acd152d6a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -2,15 +2,15 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.client; @@ -37,6 +37,7 @@ import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; import com.microsoft.windowsazure.services.core.storage.utils.Utility; @@ -309,8 +310,14 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { final StorageException potentialConflictException = StorageException.translateException(request, null, opContext); - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { + StorageExtendedErrorInformation extendedInfo = potentialConflictException + .getExtendedErrorInformation(); + if (extendedInfo == null) { + // If we can't validate the error then the error must be surfaced to the user. + throw potentialConflictException; + } + + if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { this.setException(potentialConflictException); this.setNonExceptionedRetryableFailure(true); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index c6fde24aad6dc..17c1d58eae170 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -2,15 +2,15 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.queue.client; @@ -26,6 +26,7 @@ import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; +import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; import com.microsoft.windowsazure.services.core.storage.utils.Utility; import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; @@ -63,12 +64,12 @@ static CloudQueueMessage getFirstOrNull(final Iterable messag /** * The absolute URI of the queue. */ - private URI uri; + private final URI uri; /** * A reference to the queue's associated service client. */ - private CloudQueueClient queueServiceClient; + private final CloudQueueClient queueServiceClient; /** * The queue's Metadata collection. @@ -165,21 +166,17 @@ public void addMessage(final CloudQueueMessage message) throws StorageException * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void addMessage( - final CloudQueueMessage message, final int timeToLiveInSeconds, final int initialVisibilityDelayInSeconds, - QueueRequestOptions options, OperationContext opContext) throws StorageException { + public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, + final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext) + throws StorageException { Utility.assertNotNull("message", message); Utility.assertNotNull("messageContent", message.getMessageContentAsByte()); - Utility.assertInBounds("timeToLiveInSeconds", - timeToLiveInSeconds, - 0, + Utility.assertInBounds("timeToLiveInSeconds", timeToLiveInSeconds, 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); - final int realTimeToLiveInSeconds = - timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS : timeToLiveInSeconds; - Utility.assertInBounds("initialVisibilityDelayInSeconds", - initialVisibilityDelayInSeconds, - 0, + final int realTimeToLiveInSeconds = timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS + : timeToLiveInSeconds; + Utility.assertInBounds("initialVisibilityDelayInSeconds", initialVisibilityDelayInSeconds, 0, realTimeToLiveInSeconds - 1); final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); @@ -195,42 +192,35 @@ public void addMessage( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.putMessage(queue.getMessageRequestAddress(), - this.getRequestOptions().getTimeoutIntervalInMs(), - initialVisibilityDelayInSeconds, - timeToLiveInSeconds, - opContext); + final HttpURLConnection request = QueueRequest.putMessage(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), initialVisibilityDelayInSeconds, + timeToLiveInSeconds, opContext); - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -273,34 +263,29 @@ public void clear(QueueRequestOptions options, OperationContext opContext) throw opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.clearMessages(queue.getMessageRequestAddress(), this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + final HttpURLConnection request = QueueRequest.clearMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -343,36 +328,30 @@ public void create(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.create(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED - && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED + && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -422,48 +401,51 @@ public boolean createIfNotExist(QueueRequestOptions options, OperationContext op opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.create(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return false; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = - StorageException.translateException(request, null, opContext); - - if (!potentialConflictException.getExtendedErrorInformation().getErrorCode() - .equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - } - } else { - this.setNonExceptionedRetryableFailure(true); - } - - return false; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return false; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { + final StorageException potentialConflictException = StorageException.translateException(request, + null, opContext); + + StorageExtendedErrorInformation extendedInfo = potentialConflictException + .getExtendedErrorInformation(); + if (extendedInfo == null) { + // If we cant validate the error then the error must be surfaced to the user. + throw potentialConflictException; } - }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { + this.setException(potentialConflictException); + this.setNonExceptionedRetryableFailure(true); + } + } + else { + this.setNonExceptionedRetryableFailure(true); + } + + return false; + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -506,33 +488,27 @@ public void delete(QueueRequestOptions options, OperationContext opContext) thro opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.delete(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -583,36 +559,32 @@ public boolean deleteIfExists(QueueRequestOptions options, OperationContext opCo opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.delete(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return true; - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } else { - this.setNonExceptionedRetryableFailure(true); - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final StorageOperation impl = new StorageOperation( + options) { + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { + return true; + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return false; + } + else { + this.setNonExceptionedRetryableFailure(true); + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -668,34 +640,30 @@ public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions o final String messageId = message.getId(); final String messagePopReceipt = message.getPopReceipt(); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.deleteMessage(queue.getIndividualMessageAddress(messageId), this - .getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); + final HttpURLConnection request = QueueRequest.deleteMessage( + queue.getIndividualMessageAddress(messageId), + this.getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -739,36 +707,31 @@ public void downloadAttributes(QueueRequestOptions options, OperationContext opC opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { + final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } - queue.metadata = BaseResponse.getMetadata(request); - queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); - return null; - } - }; + queue.metadata = BaseResponse.getMetadata(request); + queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -816,37 +779,34 @@ public boolean exists(QueueRequestOptions options, OperationContext opContext) t opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Boolean execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = - QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - return Boolean.valueOf(true); - } else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Boolean execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { + final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); + + client.getCredentials().signRequest(request, -1L); + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { + return Boolean.valueOf(true); + } + else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { + return Boolean.valueOf(false); + } + else { + this.setNonExceptionedRetryableFailure(true); + // return false instead of null to avoid SCA issues + return false; + } + } + }; + + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1014,9 +974,8 @@ public Iterable peekMessages(final int numberOfMessages) thro * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable peekMessages( - final int numberOfMessages, QueueRequestOptions options, OperationContext opContext) - throws StorageException { + public Iterable peekMessages(final int numberOfMessages, QueueRequestOptions options, + OperationContext opContext) throws StorageException { Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); if (opContext == null) { @@ -1030,36 +989,31 @@ public Iterable peekMessages( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { + final StorageOperation> impl = new StorageOperation>( + options) { - @Override - public ArrayList execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - QueueRequest.peekMessages(queue.getMessageRequestAddress(), this.getRequestOptions() - .getTimeoutIntervalInMs(), numberOfMessages, opContext); + final HttpURLConnection request = QueueRequest.peekMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), - queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1074,8 +1028,7 @@ public ArrayList execute( */ @DoesServiceRequest public CloudQueueMessage retrieveMessage() throws StorageException { - return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, - null, null); + return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); } /** @@ -1100,9 +1053,8 @@ public CloudQueueMessage retrieveMessage() throws StorageException { * If a storage service error occurred during the operation. */ @DoesServiceRequest - public CloudQueueMessage retrieveMessage( - final int visibilityTimeoutInSeconds, final QueueRequestOptions options, final OperationContext opContext) - throws StorageException { + public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, + final OperationContext opContext) throws StorageException { return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, null, null)); } @@ -1121,7 +1073,7 @@ public CloudQueueMessage retrieveMessage( */ @DoesServiceRequest public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { - return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, + return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); } @@ -1152,13 +1104,11 @@ public Iterable retrieveMessages(final int numberOfMessages) * If a storage service error occurred during the operation. */ @DoesServiceRequest - public Iterable retrieveMessages( - final int numberOfMessages, final int visibilityTimeoutInSeconds, QueueRequestOptions options, - OperationContext opContext) throws StorageException { + public Iterable retrieveMessages(final int numberOfMessages, + final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) + throws StorageException { Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); - Utility.assertInBounds("visibilityTimeoutInSeconds", - visibilityTimeoutInSeconds, - 0, + Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); if (opContext == null) { @@ -1172,39 +1122,32 @@ public Iterable retrieveMessages( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation> impl = - new StorageOperation>(options) { + final StorageOperation> impl = new StorageOperation>( + options) { - @Override - public ArrayList execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, + final OperationContext opContext) throws Exception { - final HttpURLConnection request = - QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), - this.getRequestOptions().getTimeoutIntervalInMs(), - numberOfMessages, - visibilityTimeoutInSeconds, - opContext); + final HttpURLConnection request = QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), this + .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, visibilityTimeoutInSeconds, + opContext); - client.getCredentials().signRequest(request, -1L); + client.getCredentials().signRequest(request, -1L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), - queue.shouldEncodeMessage); - } - } - }; + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + else { + return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); + } + } + }; - return ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1219,7 +1162,7 @@ public ArrayList execute( public void setMetadata(final HashMap metadata) { this.metadata = metadata; } - + /** * Sets the flag indicating whether the message should be base-64 encoded. * @@ -1284,17 +1227,14 @@ public void updateMessage(final CloudQueueMessage message, final int visibilityT * If a storage service error occurred during the operation. */ @DoesServiceRequest - public void updateMessage( - final CloudQueueMessage message, final int visibilityTimeoutInSeconds, + public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, final EnumSet messageUpdateFields, QueueRequestOptions options, OperationContext opContext) throws StorageException { Utility.assertNotNull("message", message); Utility.assertNotNullOrEmpty("messageId", message.id); Utility.assertNotNullOrEmpty("popReceipt", message.popReceipt); - Utility.assertInBounds("visibilityTimeoutInSeconds", - visibilityTimeoutInSeconds, - 0, + Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); @@ -1310,51 +1250,45 @@ public void updateMessage( opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { - - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = - QueueRequest.updateMessage(queue.getIndividualMessageAddress(message.getId()), - this.getRequestOptions().getTimeoutIntervalInMs(), - message.getPopReceipt(), - visibilityTimeoutInSeconds, - opContext); - - if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); - } else { - request.setFixedLengthStreamingMode(0); - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - message.popReceipt = request.getHeaderField("x-ms-popreceipt"); - message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request - .getHeaderField("x-ms-time-next-visible")); - - return null; - } - }; + final StorageOperation impl = new StorageOperation( + options) { + + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + final HttpURLConnection request = QueueRequest.updateMessage(queue.getIndividualMessageAddress(message + .getId()), this.getRequestOptions().getTimeoutIntervalInMs(), message.getPopReceipt(), + visibilityTimeoutInSeconds, opContext); + + if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { + final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); + + client.getCredentials().signRequest(request, messageBytes.length); + final OutputStream outStreamRef = request.getOutputStream(); + outStreamRef.write(messageBytes); + } + else { + request.setFixedLengthStreamingMode(0); + client.getCredentials().signRequest(request, 0L); + } + + this.setResult(ExecutionEngine.processRequest(request, opContext)); + + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + return null; + } + + message.popReceipt = request.getHeaderField("x-ms-popreceipt"); + message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request + .getHeaderField("x-ms-time-next-visible")); + + return null; + } + }; + + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } @@ -1399,36 +1333,30 @@ public void uploadMetadata(QueueRequestOptions options, OperationContext opConte opContext.initialize(); options.applyDefaults(this.queueServiceClient); - final StorageOperation impl = - new StorageOperation(options) { + final StorageOperation impl = new StorageOperation( + options) { - @Override - public Void execute( - final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { + @Override + public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) + throws Exception { - final HttpURLConnection request = - QueueRequest.setMetadata(queue.uri, - this.getRequestOptions().getTimeoutIntervalInMs(), - opContext); + final HttpURLConnection request = QueueRequest.setMetadata(queue.uri, this.getRequestOptions() + .getTimeoutIntervalInMs(), opContext); - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); + QueueRequest.addMetadata(request, queue.metadata, opContext); + client.getCredentials().signRequest(request, 0L); - this.setResult(ExecutionEngine.processRequest(request, opContext)); + this.setResult(ExecutionEngine.processRequest(request, opContext)); - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } + if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { + this.setNonExceptionedRetryableFailure(true); + } - return null; - } - }; + return null; + } + }; - ExecutionEngine.executeWithRetry(this.queueServiceClient, - this, - impl, - options.getRetryPolicyFactory(), + ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); } From c9d56725a66eec21eb35ea4d142d578a93ba2d2d Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Mon, 19 Dec 2011 16:07:46 -0800 Subject: [PATCH 300/664] (Hotfix: Update CloudBlob.download to lock to etag during a resume. Extended Error null fix.) --- .../services/queue/client/CloudQueue.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 17c1d58eae170..33b8131623496 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -1,16 +1,7 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 +/* + * CloudQueue.java * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2011 Microsoft. All rights reserved. */ package com.microsoft.windowsazure.services.queue.client; @@ -428,7 +419,7 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { StorageExtendedErrorInformation extendedInfo = potentialConflictException .getExtendedErrorInformation(); if (extendedInfo == null) { - // If we cant validate the error then the error must be surfaced to the user. + // If we can't validate the error then the error must be surfaced to the user. throw potentialConflictException; } From 8b35d93b21e37ea5fb6d9d70360a18c36260dcdd Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Mon, 19 Dec 2011 16:15:04 -0800 Subject: [PATCH 301/664] (Hotfix: Update CloudBlob.download to lock to etag during a resume. Extended Error null fix.) --- .../windowsazure/services/queue/client/CloudQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 17c1d58eae170..ad8e1b7372eaa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -428,7 +428,7 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { StorageExtendedErrorInformation extendedInfo = potentialConflictException .getExtendedErrorInformation(); if (extendedInfo == null) { - // If we cant validate the error then the error must be surfaced to the user. + // If we can't validate the error then the error must be surfaced to the user. throw potentialConflictException; } From dad61673df805fb1de33cc113667d11a7d16f57d Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Tue, 20 Dec 2011 10:55:00 -0800 Subject: [PATCH 302/664] CloudBlob Fix: Ensure Client side exceptions are not resumed --- .../windowsazure/services/blob/client/CloudBlob.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 5c409c6f7c6bb..bcaeaff4735d6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -844,10 +844,11 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op opContext.setIntermediateMD5(null); } catch (final StorageException ex) { - // Check if users has any retries specified. + // Check if users has any retries specified, Or if the exception is retryable final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext); - if (!dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), (Exception) ex.getCause(), - opContext).isShouldRetry()) { + if (ex.getHttpStatusCode() == Constants.HeaderConstants.HTTP_UNUSED_306 + || !dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), + (Exception) ex.getCause(), opContext).isShouldRetry()) { opContext.setIntermediateMD5(null); throw ex; } From db4e58a30cb451682b3d8aead5559f365e4cd2b5 Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Tue, 20 Dec 2011 11:29:28 -0800 Subject: [PATCH 303/664] CloudBlob Fix: Ensure Client side exceptions are not resumed --- .../services/blob/client/CloudBlob.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 5c409c6f7c6bb..4f0ebe6a341c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -809,10 +809,6 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op final long expectedLength = Long.parseLong(contentLength); blob.updatePropertiesFromResponse(request); - - final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, - validateMD5, this.getResult(), opContext); - ExecutionEngine.getResponseCode(this.getResult(), request, opContext); if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { @@ -820,6 +816,9 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op return null; } + final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, + validateMD5, this.getResult(), opContext); + if (descriptor.getLength() != expectedLength) { throw new StorageException( StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, @@ -844,10 +843,12 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op opContext.setIntermediateMD5(null); } catch (final StorageException ex) { - // Check if users has any retries specified. + // Check if users has any retries specified, Or if the exception is retryable final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext); - if (!dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), (Exception) ex.getCause(), - opContext).isShouldRetry()) { + if (ex.getHttpStatusCode() == Constants.HeaderConstants.HTTP_UNUSED_306 + || ex.getHttpStatusCode() == HttpURLConnection.HTTP_PRECON_FAILED + || !dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), + (Exception) ex.getCause(), opContext).isShouldRetry()) { opContext.setIntermediateMD5(null); throw ex; } From 484e6840d263bf9d520605f9f580b79856371abb Mon Sep 17 00:00:00 2001 From: Joe Giardino Date: Tue, 20 Dec 2011 11:51:18 -0800 Subject: [PATCH 304/664] AccessCondition null check --- .../windowsazure/services/blob/client/CloudBlob.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 4f0ebe6a341c9..b669f76f223f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -862,7 +862,9 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op AccessCondition etagLockCondition = new AccessCondition(); etagLockCondition.setIfMatch(this.getProperties().getEtag()); - etagLockCondition.setLeaseID(accessCondition.getLeaseID()); + if (accessCondition != null) { + etagLockCondition.setLeaseID(accessCondition.getLeaseID()); + } // 1. Open Read Stream final BlobInputStream streamRef = this.openInputStream(etagLockCondition, options, opContext); From 97d83b66833bec682e0f06d559b0a5565278e500 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Thu, 22 Dec 2011 14:54:57 -0800 Subject: [PATCH 305/664] Updating version number Also updates javadoc copyright --- microsoft-azure-api/pom.xml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index e0685a46028e8..8273cb6c86456 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.microsoft.windowsazure microsoft-windowsazure-api - 0.1.1 + 0.1.2 jar Microsoft Windows Azure Client API @@ -28,6 +28,13 @@ + + + microsoft + Microsoft + + + com.sun.jersey @@ -138,6 +145,20 @@ 2.8 *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization + /** +
* Copyright 2011 Microsoft Corporation +
* +
* Licensed under the Apache License, Version 2.0 (the "License"); +
* you may not use this file except in compliance with the License. +
* You may obtain a copy of the License at +
* http://www.apache.org/licenses/LICENSE-2.0 +
* +
* Unless required by applicable law or agreed to in writing, software +
* distributed under the License is distributed on an "AS IS" BASIS, +
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +
* See the License for the specific language governing permissions and +
* limitations under the License. +
*/
]]>
From 604ead07e3ccf6dcf513de02b616dd594c29d080 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Tue, 14 Feb 2012 09:22:00 -0800 Subject: [PATCH 306/664] History collapsed from this point. See README.md for more information --- LICENSE.txt | 202 -- README.md | 140 +- .../.settings/org.eclipse.jdt.core.prefs | 289 -- .../.settings/org.eclipse.jdt.ui.prefs | 118 - .../.settings/org.eclipse.m2e.core.prefs | 5 - microsoft-azure-api/pom.xml | 217 -- microsoft-azure-api/src/config/checkstyle.xml | 189 -- .../serviceruntime/AcquireCurrentState.java | 46 - .../serviceruntime/AcquireLeaseInfo.java | 171 -- .../windowsazure/serviceruntime/Adapter1.java | 44 - .../ChunkedGoalStateDeserializer.java | 67 - .../ConfigurationSettingInfo.java | 106 - .../ConfigurationSettingsInfo.java | 90 - .../CurrentRoleInstanceInfo.java | 230 -- .../serviceruntime/CurrentState.java | 30 - .../serviceruntime/CurrentStateInfo.java | 83 - .../CurrentStateSerializer.java | 24 - .../serviceruntime/CurrentStatus.java | 19 - .../serviceruntime/CurrentStatusEnum.java | 78 - .../serviceruntime/DeploymentInfo.java | 98 - .../serviceruntime/EndpointInfo.java | 152 -- .../serviceruntime/EndpointsInfo.java | 90 - .../serviceruntime/ExpectedState.java | 22 - .../serviceruntime/ExpectedStateEnum.java | 72 - .../serviceruntime/FileInputChannel.java | 36 - .../serviceruntime/FileOutputChannel.java | 36 - .../serviceruntime/GoalState.java | 58 - .../GoalStateChangedListener.java | 22 - .../serviceruntime/GoalStateDeserializer.java | 26 - .../serviceruntime/GoalStateInfo.java | 198 -- .../serviceruntime/InputChannel.java | 24 - .../serviceruntime/LocalResource.java | 94 - .../serviceruntime/LocalResourceInfo.java | 125 - .../serviceruntime/LocalResourcesInfo.java | 90 - .../serviceruntime/ObjectFactory.java | 264 -- .../serviceruntime/OutputChannel.java | 24 - .../Protocol1RuntimeClient.java | 56 - .../Protocol1RuntimeCurrentStateClient.java | 52 - .../Protocol1RuntimeGoalStateClient.java | 158 -- .../serviceruntime/ProtocolEnum.java | 102 - .../serviceruntime/ReleaseCurrentState.java | 21 - .../windowsazure/serviceruntime/Role.java | 63 - .../serviceruntime/RoleEnvironment.java | 603 ----- .../serviceruntime/RoleEnvironmentChange.java | 22 - .../RoleEnvironmentChangedEvent.java | 50 - .../RoleEnvironmentChangedListener.java | 36 - .../RoleEnvironmentChangingEvent.java | 76 - .../RoleEnvironmentChangingListener.java | 47 - ...EnvironmentConfigurationSettingChange.java | 40 - .../serviceruntime/RoleEnvironmentData.java | 64 - .../RoleEnvironmentDataDeserializer.java | 24 - .../serviceruntime/RoleEnvironmentInfo.java | 137 - .../RoleEnvironmentNotAvailableException.java | 36 - .../RoleEnvironmentStoppingListener.java | 31 - .../RoleEnvironmentTopologyChange.java | 40 - .../windowsazure/serviceruntime/RoleInfo.java | 111 - .../serviceruntime/RoleInstance.java | 101 - .../serviceruntime/RoleInstanceEndpoint.java | 85 - .../serviceruntime/RoleInstanceInfo.java | 149 -- .../serviceruntime/RoleInstanceStatus.java | 31 - .../serviceruntime/RoleInstancesInfo.java | 90 - .../serviceruntime/RolesInfo.java | 90 - .../serviceruntime/RuntimeClient.java | 22 - .../serviceruntime/RuntimeClientFactory.java | 24 - .../RuntimeCurrentStateClient.java | 22 - .../RuntimeGoalStateClient.java | 28 - .../serviceruntime/RuntimeKernel.java | 90 - .../RuntimeServerDiscoveryInfo.java | 83 - .../RuntimeServerEndpointInfo.java | 106 - .../RuntimeServerEndpointsInfo.java | 90 - .../serviceruntime/RuntimeVersionManager.java | 58 - .../RuntimeVersionProtocolClient.java | 58 - .../serviceruntime/StatusLeaseInfo.java | 170 -- .../XmlCurrentStateSerializer.java | 77 - .../XmlGoalStateDeserializer.java | 51 - .../XmlRoleEnvironmentDataDeserializer.java | 158 -- .../windowsazure/serviceruntime/overview.html | 6 - .../windowsazure/serviceruntime/package.html | 16 - .../services/blob/BlobConfiguration.java | 21 - .../services/blob/BlobContract.java | 207 -- .../services/blob/BlobService.java | 38 - .../windowsazure/services/blob/Exports.java | 32 - .../blob/client/AccessPolicyResponse.java | 230 -- .../services/blob/client/BlobAttributes.java | 68 - .../services/blob/client/BlobConstants.java | 347 --- .../blob/client/BlobContainerAttributes.java | 83 - .../blob/client/BlobContainerPermissions.java | 99 - .../blob/client/BlobContainerProperties.java | 71 - .../client/BlobContainerPublicAccessType.java | 38 - .../client/BlobDeserializationHelper.java | 608 ----- .../services/blob/client/BlobInputStream.java | 635 ----- .../blob/client/BlobListingContext.java | 100 - .../blob/client/BlobListingDetails.java | 54 - .../blob/client/BlobOutputStream.java | 628 ----- .../services/blob/client/BlobProperties.java | 284 -- .../services/blob/client/BlobRequest.java | 970 ------- .../blob/client/BlobRequestOptions.java | 173 -- .../services/blob/client/BlobResponse.java | 133 - .../services/blob/client/BlobType.java | 62 - .../services/blob/client/BlockEntry.java | 78 - .../blob/client/BlockListingFilter.java | 35 - .../services/blob/client/BlockSearchMode.java | 36 - .../services/blob/client/CloudBlob.java | 2342 ----------------- .../services/blob/client/CloudBlobClient.java | 690 ----- .../blob/client/CloudBlobContainer.java | 1857 ------------- .../blob/client/CloudBlobDirectory.java | 466 ---- .../services/blob/client/CloudBlockBlob.java | 610 ----- .../services/blob/client/CloudPageBlob.java | 666 ----- .../blob/client/ContainerListingDetails.java | 51 - .../blob/client/ContainerRequest.java | 401 --- .../blob/client/ContainerResponse.java | 76 - .../blob/client/DeleteSnapshotsOption.java | 35 - .../blob/client/GetBlockListResponse.java | 126 - .../blob/client/GetPageRangesResponse.java | 112 - .../services/blob/client/ListBlobItem.java | 57 - .../blob/client/ListBlobsResponse.java | 164 -- .../blob/client/ListContainersResponse.java | 170 -- .../blob/client/PageOperationType.java | 30 - .../services/blob/client/PageProperties.java | 68 - .../services/blob/client/PageRange.java | 83 - .../blob/client/SharedAccessPermissions.java | 85 - .../blob/client/SharedAccessPolicy.java | 173 -- .../client/SharedAccessSignatureHelper.java | 248 -- .../BlobExceptionProcessor.java | 913 ------- .../blob/implementation/BlobRestProxy.java | 923 ------- .../ContainerACLDateAdapter.java | 35 - .../ContainerACLDateConverter.java | 53 - .../blob/implementation/HmacSHA256Sign.java | 43 - .../blob/implementation/MetadataAdapter.java | 59 - .../implementation/RFC1123DateAdapter.java | 35 - .../implementation/RFC1123DateConverter.java | 49 - .../blob/implementation/SharedKeyFilter.java | 216 -- .../implementation/SharedKeyLiteFilter.java | 150 -- .../blob/implementation/SharedKeyUtils.java | 132 - .../services/blob/models/AccessCondition.java | 158 -- .../models/AccessConditionHeaderType.java | 66 - .../blob/models/AcquireLeaseOptions.java | 35 - .../blob/models/AcquireLeaseResult.java | 27 - .../services/blob/models/BlobProperties.java | 136 - .../blob/models/BlobServiceOptions.java | 29 - .../services/blob/models/BlockList.java | 92 - .../blob/models/CommitBlobBlocksOptions.java | 111 - .../services/blob/models/ContainerACL.java | 153 -- .../services/blob/models/CopyBlobOptions.java | 91 - .../blob/models/CreateBlobBlockOptions.java | 44 - .../blob/models/CreateBlobOptions.java | 171 -- .../blob/models/CreateBlobPagesOptions.java | 54 - .../blob/models/CreateBlobPagesResult.java | 56 - .../models/CreateBlobSnapshotOptions.java | 61 - .../blob/models/CreateBlobSnapshotResult.java | 47 - .../blob/models/CreateContainerOptions.java | 51 - .../blob/models/DeleteBlobOptions.java | 64 - .../blob/models/DeleteContainerOptions.java | 34 - .../blob/models/GetBlobMetadataOptions.java | 54 - .../blob/models/GetBlobMetadataResult.java | 48 - .../services/blob/models/GetBlobOptions.java | 84 - .../blob/models/GetBlobPropertiesOptions.java | 54 - .../blob/models/GetBlobPropertiesResult.java | 38 - .../services/blob/models/GetBlobResult.java | 48 - .../blob/models/GetContainerACLResult.java | 27 - .../models/GetContainerPropertiesResult.java | 48 - .../models/GetServicePropertiesResult.java | 27 - .../blob/models/ListBlobBlocksOptions.java | 64 - .../blob/models/ListBlobBlocksResult.java | 112 - .../blob/models/ListBlobRegionsOptions.java | 74 - .../blob/models/ListBlobRegionsResult.java | 62 - .../blob/models/ListBlobsOptions.java | 94 - .../services/blob/models/ListBlobsResult.java | 201 -- .../blob/models/ListContainersOptions.java | 64 - .../blob/models/ListContainersResult.java | 161 -- .../services/blob/models/PageRange.java | 59 - .../blob/models/ServiceProperties.java | 171 -- .../blob/models/SetBlobMetadataOptions.java | 44 - .../blob/models/SetBlobMetadataResult.java | 38 - .../blob/models/SetBlobPropertiesOptions.java | 124 - .../blob/models/SetBlobPropertiesResult.java | 47 - .../models/SetContainerMetadataOptions.java | 34 - .../windowsazure/services/core/Builder.java | 44 - .../services/core/Configuration.java | 105 - .../services/core/ConfigurationException.java | 36 - .../services/core/DefaultBuilder.java | 195 -- .../services/core/ExponentialRetryPolicy.java | 70 - .../services/core/FilterableService.java | 19 - .../services/core/RetryPolicy.java | 28 - .../services/core/RetryPolicyFilter.java | 103 - .../services/core/ServiceException.java | 127 - .../services/core/ServiceFilter.java | 65 - .../core/storage/AccessCondition.java | 387 --- .../core/storage/CloudStorageAccount.java | 691 ----- .../services/core/storage/Constants.java | 469 ---- .../services/core/storage/Credentials.java | 115 - .../core/storage/DoesServiceRequest.java | 28 - .../services/core/storage/LeaseStatus.java | 65 - .../core/storage/LoggingOperations.java | 36 - .../core/storage/LoggingProperties.java | 83 - .../services/core/storage/MetricsLevel.java | 35 - .../core/storage/MetricsProperties.java | 80 - .../core/storage/OperationContext.java | 226 -- .../services/core/storage/RequestOptions.java | 96 - .../services/core/storage/RequestResult.java | 203 -- .../core/storage/ResponseReceivedEvent.java | 63 - .../core/storage/ResultContinuation.java | 140 - .../core/storage/ResultContinuationType.java | 45 - .../services/core/storage/ResultSegment.java | 125 - .../core/storage/RetryExponentialRetry.java | 143 - .../core/storage/RetryLinearRetry.java | 90 - .../services/core/storage/RetryNoRetry.java | 78 - .../services/core/storage/RetryPolicy.java | 93 - .../core/storage/RetryPolicyFactory.java | 33 - .../services/core/storage/RetryResult.java | 75 - .../services/core/storage/ServiceClient.java | 345 --- .../core/storage/ServiceProperties.java | 479 ---- .../core/storage/StorageCredentials.java | 333 --- .../StorageCredentialsAccountAndKey.java | 371 --- .../storage/StorageCredentialsAnonymous.java | 275 -- ...orageCredentialsSharedAccessSignature.java | 310 --- .../core/storage/StorageErrorCode.java | 136 - .../core/storage/StorageErrorCodeStrings.java | 232 -- .../services/core/storage/StorageEvent.java | 34 - .../core/storage/StorageEventMultiCaster.java | 74 - .../core/storage/StorageException.java | 256 -- .../StorageExtendedErrorInformation.java | 95 - .../services/core/storage/StorageKey.java | 213 -- .../services/core/storage/utils/Base64.java | 319 --- .../core/storage/utils/PathUtility.java | 463 ---- .../storage/utils/StreamMd5AndLength.java | 60 - .../core/storage/utils/UriQueryBuilder.java | 168 -- .../services/core/storage/utils/Utility.java | 970 ------- .../utils/implementation/BaseRequest.java | 538 ---- .../utils/implementation/BaseResponse.java | 137 - .../BlobQueueFullCanonicalizer.java | 57 - .../BlobQueueLiteCanonicalizer.java | 56 - .../utils/implementation/Canonicalizer.java | 382 --- .../implementation/CanonicalizerFactory.java | 140 - .../implementation/DeserializationHelper.java | 72 - .../utils/implementation/ExecutionEngine.java | 324 --- .../implementation/LazySegmentedIterator.java | 153 -- .../utils/implementation/LeaseAction.java | 60 - .../utils/implementation/ListingContext.java | 95 - .../SegmentedStorageOperation.java | 74 - .../implementation/StorageErrorResponse.java | 159 -- .../implementation/StorageOperation.java | 174 -- .../TableLiteCanonicalizer.java | 62 - .../services/core/utils/DateFactory.java | 21 - .../core/utils/DefaultDateFactory.java | 23 - .../services/core/utils/Exports.java | 23 - .../core/utils/ServiceExceptionFactory.java | 86 - .../utils/pipeline/Base64StringAdapter.java | 35 - .../utils/pipeline/ClientFilterAdapter.java | 136 - .../pipeline/EntityStreamingListener.java | 28 - .../services/core/utils/pipeline/Exports.java | 56 - .../pipeline/HttpURLConnectionClient.java | 35 - .../HttpURLConnectionClientHandler.java | 299 --- .../core/utils/pipeline/PipelineHelpers.java | 141 - .../windowsazure/services/queue/Exports.java | 32 - .../services/queue/QueueConfiguration.java | 21 - .../services/queue/QueueContract.java | 92 - .../services/queue/QueueService.java | 38 - .../services/queue/client/CloudQueue.java | 1354 ---------- .../queue/client/CloudQueueClient.java | 402 --- .../queue/client/CloudQueueMessage.java | 276 -- .../queue/client/ListQueuesResponse.java | 232 -- .../queue/client/MessageUpdateFields.java | 45 - .../services/queue/client/QueueConstants.java | 119 - .../client/QueueDeserializationHelper.java | 260 -- .../queue/client/QueueListingDetails.java | 51 - .../queue/client/QueueMessageType.java | 31 - .../services/queue/client/QueueRequest.java | 623 ----- .../queue/client/QueueRequestOptions.java | 53 - .../services/queue/client/QueueResponse.java | 36 - .../QueueExceptionProcessor.java | 383 --- .../queue/implementation/QueueMessage.java | 33 - .../queue/implementation/QueueRestProxy.java | 322 --- .../queue/implementation/SharedKeyFilter.java | 26 - .../implementation/SharedKeyLiteFilter.java | 26 - .../queue/models/CreateMessageOptions.java | 44 - .../queue/models/CreateQueueOptions.java | 41 - .../queue/models/GetQueueMetadataResult.java | 38 - .../models/GetServicePropertiesResult.java | 27 - .../queue/models/ListMessagesOptions.java | 44 - .../queue/models/ListMessagesResult.java | 115 - .../queue/models/ListQueuesOptions.java | 64 - .../queue/models/ListQueuesResult.java | 126 - .../queue/models/PeekMessagesOptions.java | 34 - .../queue/models/PeekMessagesResult.java | 94 - .../queue/models/QueueServiceOptions.java | 29 - .../queue/models/ServiceProperties.java | 161 -- .../queue/models/UpdateMessageResult.java | 38 - .../services/serviceBus/Exports.java | 60 - .../serviceBus/ServiceBusConfiguration.java | 138 - .../serviceBus/ServiceBusContract.java | 440 ---- .../serviceBus/ServiceBusService.java | 67 - .../services/serviceBus/Util.java | 31 - .../implementation/BrokerProperties.java | 213 -- .../BrokerPropertiesMapper.java | 74 - .../CustomPropertiesMapper.java | 124 - .../serviceBus/implementation/EntryModel.java | 41 - .../implementation/EntryModelProvider.java | 90 - .../serviceBus/implementation/Exports.java | 27 - .../implementation/MarshallerProvider.java | 71 - .../NamespacePrefixMapperImpl.java | 32 - .../ServiceBusExceptionProcessor.java | 488 ---- .../implementation/ServiceBusRestProxy.java | 412 --- .../implementation/WrapAccessTokenResult.java | 50 - .../implementation/WrapContract.java | 22 - .../serviceBus/implementation/WrapFilter.java | 52 - .../implementation/WrapRestProxy.java | 66 - .../implementation/WrapTokenManager.java | 135 - .../models/AbstractListOptions.java | 40 - .../serviceBus/models/BrokeredMessage.java | 449 ---- .../serviceBus/models/CreateQueueResult.java | 53 - .../serviceBus/models/CreateRuleResult.java | 53 - .../models/CreateSubscriptionResult.java | 54 - .../serviceBus/models/CreateTopicResult.java | 53 - .../serviceBus/models/GetQueueResult.java | 53 - .../serviceBus/models/GetRuleResult.java | 53 - .../models/GetSubscriptionResult.java | 56 - .../serviceBus/models/GetTopicResult.java | 53 - .../serviceBus/models/ListQueuesOptions.java | 19 - .../serviceBus/models/ListQueuesResult.java | 46 - .../serviceBus/models/ListRulesOptions.java | 19 - .../serviceBus/models/ListRulesResult.java | 47 - .../models/ListSubscriptionsOptions.java | 19 - .../models/ListSubscriptionsResult.java | 46 - .../serviceBus/models/ListTopicsOptions.java | 19 - .../serviceBus/models/ListTopicsResult.java | 46 - .../services/serviceBus/models/QueueInfo.java | 303 --- .../models/ReceiveMessageOptions.java | 113 - .../models/ReceiveMessageResult.java | 53 - .../serviceBus/models/ReceiveMode.java | 30 - .../models/ReceiveQueueMessageResult.java | 53 - .../ReceiveSubscriptionMessageResult.java | 53 - .../services/serviceBus/models/RuleInfo.java | 172 -- .../serviceBus/models/SubscriptionInfo.java | 269 -- .../services/serviceBus/models/TopicInfo.java | 202 -- .../services/serviceBus/models/package.html | 6 - .../services/serviceBus/package.html | 6 - ...windowsazure.services.core.Builder$Exports | 6 - .../src/main/resources/package-names.xjb | 17 - ...as.microsoft.com.2003.10.Serialization.xsd | 42 - ...netservices.2010.10.servicebus.connect.xsd | 303 --- .../src/main/resources/servicebus-atom.xsd | 37 - .../builder/AlterClassWithProperties.java | 28 - .../ClassWithMultipleCtorMultipleInject.java | 27 - .../ClassWithMultipleCtorNoInject.java | 23 - .../builder/ClassWithNamedParameter.java | 35 - .../builder/ClassWithProperties.java | 55 - .../builder/ClassWithSingleCtorNoInject.java | 21 - .../builder/DefaultBuilderTest.java | 179 -- .../serviceruntime/FileInputChannelTests.java | 53 - .../serviceruntime/MockInputChannel.java | 83 - ...otocol1RuntimeCurrentStateClientTests.java | 116 - .../Protocol1RuntimeGoalStateClientTests.java | 253 -- .../serviceruntime/RoleEnvironmentTests.java | 78 - .../RuntimeVersionManagerTests.java | 112 - .../XmlGoalStateDeserializerTests.java | 28 - .../blob/BlobServiceIntegrationTest.java | 1567 ----------- .../services/blob/IntegrationTestBase.java | 43 - .../services/queue/IntegrationTestBase.java | 43 - .../queue/QueueServiceIntegrationTest.java | 554 ---- .../BrokerPropertiesMapperTest.java | 127 - .../serviceBus/IntegrationTestBase.java | 62 - .../ServiceBusConfigurationTest.java | 54 - .../serviceBus/ServiceBusCreationTest.java | 65 - .../serviceBus/ServiceBusIntegrationTest.java | 514 ---- .../CustomPropertiesMapperTest.java | 142 - .../WrapRestProxyIntegrationTest.java | 47 - .../WrapTokenManagerIntegrationTest.java | 40 - .../implementation/WrapTokenManagerTest.java | 155 -- .../utils/ServiceExceptionFactoryTest.java | 79 - .../com.microsoft.windowsazure.properties | 10 - .../src/test/resources/NewFile.xml | 4 - 372 files changed, 3 insertions(+), 54428 deletions(-) delete mode 100644 LICENSE.txt delete mode 100644 microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs delete mode 100644 microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs delete mode 100644 microsoft-azure-api/pom.xml delete mode 100644 microsoft-azure-api/src/config/checkstyle.xml delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java delete 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/implementation/QueueRestProxy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html delete mode 100644 microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports delete mode 100644 microsoft-azure-api/src/main/resources/package-names.xjb delete mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd delete mode 100644 microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd delete mode 100644 microsoft-azure-api/src/main/resources/servicebus-atom.xsd delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java delete mode 100644 microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties delete mode 100644 microsoft-azure-api/src/test/resources/NewFile.xml diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index d645695673349..0000000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index 764ab798b3ab1..896fb06cb7476 100644 --- a/README.md +++ b/README.md @@ -1,139 +1,5 @@ -

Windows Azure SDK for Java

-

This SDK allows you to build Windows Azure applications in Java that allow -you to take advantage of Azure scalable cloud computing resources: table and blob -storage, messaging through Service Bus.

+## Obsolete repository -

For documentation please see the -Windows Azure Java Developer Center

- -

Features

-
    -
  • Blob -
      -
    • Create/Read/Update/Delete Blobs
    • -
  • -
  • Queue -
      -
    • Create/Delete Queues
    • -
    • Insert/Peek Queue Messages
    • -
    • Advanced Queue Operations
    • -
  • -
  • Service Bus -
      -
    • Use either the Queue or Topic/Subscription Model
    • -
  • -
  • Service Runtime -
      -
    • Retrieve information about the state of your Azure Compute instances
    • -
  • -
- -

Getting Started

-

Download

-

Option 1: Via Git

-

To get the source code of the SDK via git just type:
-

git clone git://github.com/WindowsAzure/azure-sdk-for-java.git
-cd ./azure-sdk-for-java
-mvn compile
- -

Option 2: Via Maven

-

To get the binaries of this library as distributed by Microsoft, ready for use -within your project you can also have them installed by the Java package manager Maven.
-

<dependency>
-  <groupId>com.microsoft.windowsazure</groupId>
-  <artifactId>microsoft-windowsazure-api</artifactId>
-  <version>0.1.0</version>
-</dependency>

- -

Minimum Requirements

-
    -
  • Java 1.6
  • -
  • (Optional) Maven
  • -
- -

Usage

-

To use this SDK to call Windows Azure services, you need to first create an -account. To host your Java code in Windows Azure, you additionally need to download -the full Windows Azure SDK for Java - which includes packaging, emulation, and -deployment tools.

- -

Code Samples

-

The following is a quick example on how to set up a Azure blob using the API -and uploading a file to it. For additional information on using the client libraries to access Azure services see the How To guides listed -here.
- -

import com.microsoft.windowsazure.services.core.storage.*;
-import com.microsoft.windowsazure.services.blob.client.*;
-
-public class BlobSample {
-
-    public static final String storageConnectionString = 
-            "DefaultEndpointsProtocol=http;" + 
-               "AccountName=your_account_name;" + 
-               "AccountKey= your_account_name"; 
-
-    public static void main(String[] args) 
-    {
-        try
-        {
-            CloudStorageAccount account;
-            CloudBlobClient serviceClient;
-            CloudBlobContainer container;
-            CloudBlockBlob blob;
-            
-            account = CloudStorageAccount.parse(storageConnectionString);
-            serviceClient = account.createCloudBlobClient();
-            // Container name must be lower case.
-            container = serviceClient.getContainerReference("blobsample");
-            container.createIfNotExist();
-            
-            // Set anonymous access on the container.
-            BlobContainerPermissions containerPermissions;
-            containerPermissions = new BlobContainerPermissions();
-
-            // Upload an image file.
-            blob = container.getBlockBlobReference("image1.jpg");
-            File fileReference = new File ("c:\\myimages\\image1.jpg");
-            blob.upload(new FileInputStream(fileReference), fileReference.length());
-        }
-        catch (FileNotFoundException fileNotFoundException)
-        {
-            System.out.print("FileNotFoundException encountered: ");
-            System.out.println(fileNotFoundException.getMessage());
-            System.exit(-1);
-        }
-        catch (StorageException storageException)
-        {
-            System.out.print("StorageException encountered: ");
-            System.out.println(storageException.getMessage());
-            System.exit(-1);
-        }
-        catch (Exception e)
-        {
-            System.out.print("Exception encountered: ");
-            System.out.println(e.getMessage());
-            System.exit(-1);
-        }
-        
-    }
-}
-

- -

Need Help?

-

Be sure to check out the Windows Azure -Developer Forums on Stack Overflow if you have trouble with the provided code.

- -

Feedback

-

For feedback related specificically to this SDK, please use the Issues -section of the repository.

-

For general suggestions about Windows Azure please use our -UserVoice forum.

- -

Learn More

- +The `WindowsAzure/azure-sdk-for-java-pr` branch `dev` can no longer be used. It is no longer compatible with the real `WindowsAzure/azure-sdk-for-java` repository once the history was collapsed. +Please fork `WindowsAzure/azure-sdk-for-java` and continue development on that `dev` branch. diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3f7604ef3b690..0000000000000 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,289 +0,0 @@ -#Wed Nov 16 15:46:43 PST 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=false -org.eclipse.jdt.core.formatter.comment.format_header=true -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=false -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -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=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 -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=120 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 0f7349dc40641..0000000000000 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,118 +0,0 @@ -#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 -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=false -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=false -cleanup.format_source_code=false -cleanup.format_source_code_changes_only=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=false -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=false -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_blocks=false -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile -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=12 -org.eclipse.jdt.ui.exception.name=e -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=java;javax;org;com; -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=1 -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=true -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=true -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=true -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=false -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=false -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=false -sp_cleanup.use_this_for_non_static_field_access=false -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=false -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs b/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 55679f3b05ac3..0000000000000 --- a/microsoft-azure-api/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Tue Oct 18 09:29:27 PDT 2011 -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml deleted file mode 100644 index 8273cb6c86456..0000000000000 --- a/microsoft-azure-api/pom.xml +++ /dev/null @@ -1,217 +0,0 @@ - - 4.0.0 - com.microsoft.windowsazure - microsoft-windowsazure-api - 0.1.2 - jar - - Microsoft Windows Azure Client API - API for Microsoft Windows Azure Clients - https://github.com/WindowsAzure/azure-sdk-for-java - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - scm:git:https://github.com/WindowsAzure/azure-sdk-for-java - scm:git:git://github.com/WindowsAzure/azure-sdk-for-java.git - - - - UTF-8 - - - - - - microsoft - Microsoft - - - - - - com.sun.jersey - jersey-client - 1.10-b02 - - - javax.xml.bind - jaxb-api - 2.1 - provided - - - junit - junit - 4.8 - test - - - org.hamcrest - hamcrest-all - 1.1 - test - - - org.mockito - mockito-all - test - 1.9.0-rc1 - - - javax.inject - javax.inject - 1 - - - com.sun.jersey - jersey-json - 1.10-b02 - - - commons-logging - commons-logging - 1.1.1 - - - - - - - org.apache.maven.plugins - maven-help-plugin - 2.1.1 - - - validate - - evaluate - - - legal - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - 0.8.0 - - - generate-sources - - generate - - - - - true - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.6.0 - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 0.6.0 - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8 - - *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization - /** -
* Copyright 2011 Microsoft Corporation -
* -
* Licensed under the Apache License, Version 2.0 (the "License"); -
* you may not use this file except in compliance with the License. -
* You may obtain a copy of the License at -
* http://www.apache.org/licenses/LICENSE-2.0 -
* -
* Unless required by applicable law or agreed to in writing, software -
* distributed under the License is distributed on an "AS IS" BASIS, -
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
* See the License for the specific language governing permissions and -
* limitations under the License. -
*/
]]> - - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.3.2 - - true - true - true - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.8 - - src/config/checkstyle.xml - - - - -
- - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-help-plugin - [2.1.1,) - - evaluate - - - - - - - - - - - - -
- diff --git a/microsoft-azure-api/src/config/checkstyle.xml b/microsoft-azure-api/src/config/checkstyle.xml deleted file mode 100644 index 0f628e43c5c52..0000000000000 --- a/microsoft-azure-api/src/config/checkstyle.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java deleted file mode 100644 index 2dd6e66b18581..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.math.BigInteger; -import java.util.Calendar; - -/** - * - */ -class AcquireCurrentState extends CurrentState { - private final BigInteger incarnation; - private final CurrentStatus status; - private final Calendar expiration; - - public AcquireCurrentState(String clientId, BigInteger incarnation, CurrentStatus status, Calendar expiration) { - super(clientId); - this.incarnation = incarnation; - this.status = status; - this.expiration = expiration; - } - - public BigInteger getIncarnation() { - return incarnation; - } - - public CurrentStatus getStatus() { - return status; - } - - public Calendar getExpiration() { - return expiration; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java deleted file mode 100644 index 7030db4332b2b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.math.BigInteger; -import java.util.Calendar; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - - -/** - *

Java class for AcquireLeaseInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="AcquireLeaseInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="Incarnation" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
- *         <element name="Status" type="{}CurrentStatusEnum"/>
- *         <element name="StatusDetail" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="Expiration" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
- *       </all>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "AcquireLeaseInfo", propOrder = { - -}) -class AcquireLeaseInfo { - - @XmlElement(name = "Incarnation", required = true) - @XmlSchemaType(name = "unsignedLong") - protected BigInteger incarnation; - @XmlElement(name = "Status", required = true) - protected CurrentStatusEnum status; - @XmlElement(name = "StatusDetail", required = true) - protected String statusDetail; - @XmlElement(name = "Expiration", required = true, type = String.class) - @XmlJavaTypeAdapter(Adapter1 .class) - @XmlSchemaType(name = "dateTime") - protected Calendar expiration; - - /** - * Gets the value of the incarnation property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getIncarnation() { - return incarnation; - } - - /** - * Sets the value of the incarnation property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setIncarnation(BigInteger value) { - this.incarnation = value; - } - - /** - * Gets the value of the status property. - * - * @return - * possible object is - * {@link CurrentStatusEnum } - * - */ - public CurrentStatusEnum getStatus() { - return status; - } - - /** - * Sets the value of the status property. - * - * @param value - * allowed object is - * {@link CurrentStatusEnum } - * - */ - public void setStatus(CurrentStatusEnum value) { - this.status = value; - } - - /** - * Gets the value of the statusDetail property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStatusDetail() { - return statusDetail; - } - - /** - * Sets the value of the statusDetail property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStatusDetail(String value) { - this.statusDetail = value; - } - - /** - * Gets the value of the expiration property. - * - * @return - * possible object is - * {@link String } - * - */ - public Calendar getExpiration() { - return expiration; - } - - /** - * Sets the value of the expiration property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setExpiration(Calendar value) { - this.expiration = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java deleted file mode 100644 index 3b35f8d0463e7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Calendar; -import javax.xml.bind.annotation.adapters.XmlAdapter; - -class Adapter1 - extends XmlAdapter -{ - - - public Calendar unmarshal(String value) { - return (javax.xml.bind.DatatypeConverter.parseDateTime(value)); - } - - public String marshal(Calendar value) { - if (value == null) { - return null; - } - return (javax.xml.bind.DatatypeConverter.printDateTime(value)); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java deleted file mode 100644 index 4d5d2f468fe44..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; - -class ChunkedGoalStateDeserializer implements GoalStateDeserializer { - private final XmlGoalStateDeserializer deserializer; - private BufferedReader reader; - - public ChunkedGoalStateDeserializer() { - this.deserializer = new XmlGoalStateDeserializer(); - } - - @Override - public void initialize(InputStream inputStream) { - try { - reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); - } - catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - - @Override - public GoalState deserialize() { - try { - String lengthString = reader.readLine(); - - if (lengthString == null) { - return null; - } - - int length = Integer.parseInt(lengthString.toString(), 16); - char chunkData[] = new char[length]; - - reader.read(chunkData, 0, length); - - GoalState goalState = deserializer.deserialize(new String(chunkData)); - - reader.readLine(); - - return goalState; - } - catch (IOException e) { - e.printStackTrace(); - - return null; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java deleted file mode 100644 index 3c52c56eb5688..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for ConfigurationSettingInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="ConfigurationSettingInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ConfigurationSettingInfo") -class ConfigurationSettingInfo { - - @XmlAttribute(required = true) - protected String name; - @XmlAttribute(required = true) - protected String value; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java deleted file mode 100644 index 152228cced1bb..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for ConfigurationSettingsInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="ConfigurationSettingsInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="ConfigurationSetting" type="{}ConfigurationSettingInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ConfigurationSettingsInfo", propOrder = { - "configurationSetting" -}) -class ConfigurationSettingsInfo { - - @XmlElement(name = "ConfigurationSetting") - protected List configurationSetting; - - /** - * Gets the value of the configurationSetting property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the configurationSetting property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getConfigurationSetting().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link ConfigurationSettingInfo } - * - * - */ - public List getConfigurationSetting() { - if (configurationSetting == null) { - configurationSetting = new ArrayList(); - } - return this.configurationSetting; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java deleted file mode 100644 index 78ae4283605f0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for CurrentRoleInstanceInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="CurrentRoleInstanceInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="ConfigurationSettings" type="{}ConfigurationSettingsInfo" minOccurs="0"/>
- *         <element name="LocalResources" type="{}LocalResourcesInfo" minOccurs="0"/>
- *         <element name="Endpoints" type="{}EndpointsInfo" minOccurs="0"/>
- *       </all>
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="roleName" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="faultDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="updateDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "CurrentRoleInstanceInfo", propOrder = { - -}) -class CurrentRoleInstanceInfo { - - @XmlElement(name = "ConfigurationSettings") - protected ConfigurationSettingsInfo configurationSettings; - @XmlElement(name = "LocalResources") - protected LocalResourcesInfo localResources; - @XmlElement(name = "Endpoints") - protected EndpointsInfo endpoints; - @XmlAttribute(required = true) - protected String id; - @XmlAttribute(required = true) - protected String roleName; - @XmlAttribute(required = true) - protected int faultDomain; - @XmlAttribute(required = true) - protected int updateDomain; - - /** - * Gets the value of the configurationSettings property. - * - * @return - * possible object is - * {@link ConfigurationSettingsInfo } - * - */ - public ConfigurationSettingsInfo getConfigurationSettings() { - return configurationSettings; - } - - /** - * Sets the value of the configurationSettings property. - * - * @param value - * allowed object is - * {@link ConfigurationSettingsInfo } - * - */ - public void setConfigurationSettings(ConfigurationSettingsInfo value) { - this.configurationSettings = value; - } - - /** - * Gets the value of the localResources property. - * - * @return - * possible object is - * {@link LocalResourcesInfo } - * - */ - public LocalResourcesInfo getLocalResources() { - return localResources; - } - - /** - * Sets the value of the localResources property. - * - * @param value - * allowed object is - * {@link LocalResourcesInfo } - * - */ - public void setLocalResources(LocalResourcesInfo value) { - this.localResources = value; - } - - /** - * Gets the value of the endpoints property. - * - * @return - * possible object is - * {@link EndpointsInfo } - * - */ - public EndpointsInfo getEndpoints() { - return endpoints; - } - - /** - * Sets the value of the endpoints property. - * - * @param value - * allowed object is - * {@link EndpointsInfo } - * - */ - public void setEndpoints(EndpointsInfo value) { - this.endpoints = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the roleName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRoleName() { - return roleName; - } - - /** - * Sets the value of the roleName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRoleName(String value) { - this.roleName = value; - } - - /** - * Gets the value of the faultDomain property. - * - */ - public int getFaultDomain() { - return faultDomain; - } - - /** - * Sets the value of the faultDomain property. - * - */ - public void setFaultDomain(int value) { - this.faultDomain = value; - } - - /** - * Gets the value of the updateDomain property. - * - */ - public int getUpdateDomain() { - return updateDomain; - } - - /** - * Sets the value of the updateDomain property. - * - */ - public void setUpdateDomain(int value) { - this.updateDomain = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java deleted file mode 100644 index a297210f77e46..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -class CurrentState { - private final String clientId; - - public CurrentState(String clientId) { - this.clientId = clientId; - } - - public String getClientId() { - return clientId; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java deleted file mode 100644 index e9ae55b96a160..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for CurrentStateInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="CurrentStateInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <choice>
- *         <element name="StatusLease" type="{}StatusLeaseInfo"/>
- *       </choice>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "CurrentStateInfo", propOrder = { - "statusLease" -}) -class CurrentStateInfo { - - @XmlElement(name = "StatusLease") - protected StatusLeaseInfo statusLease; - - /** - * Gets the value of the statusLease property. - * - * @return - * possible object is - * {@link StatusLeaseInfo } - * - */ - public StatusLeaseInfo getStatusLease() { - return statusLease; - } - - /** - * Sets the value of the statusLease property. - * - * @param value - * allowed object is - * {@link StatusLeaseInfo } - * - */ - public void setStatusLease(StatusLeaseInfo value) { - this.statusLease = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java deleted file mode 100644 index b972bc6c4f516..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.OutputStream; - -/** - * - */ -interface CurrentStateSerializer { - public void serialize(CurrentState state, OutputStream stream); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java deleted file mode 100644 index 4117871ddac56..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -enum CurrentStatus { - STARTED, BUSY, RECYCLE, STOPPED, -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java deleted file mode 100644 index 01ce61f3ae834..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for CurrentStatusEnum. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="CurrentStatusEnum">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="Started"/>
- *     <enumeration value="Busy"/>
- *     <enumeration value="Recycle"/>
- *     <enumeration value="Stopped"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "CurrentStatusEnum") -@XmlEnum -enum CurrentStatusEnum { - - @XmlEnumValue("Started") - STARTED("Started"), - @XmlEnumValue("Busy") - BUSY("Busy"), - @XmlEnumValue("Recycle") - RECYCLE("Recycle"), - @XmlEnumValue("Stopped") - STOPPED("Stopped"); - private final String value; - - CurrentStatusEnum(String v) { - value = v; - } - - public String value() { - return value; - } - - public static CurrentStatusEnum fromValue(String v) { - for (CurrentStatusEnum c: CurrentStatusEnum.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java deleted file mode 100644 index 90b28659fa77a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for DeploymentInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="DeploymentInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="emulated" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "DeploymentInfo") -class DeploymentInfo { - - @XmlAttribute(required = true) - protected String id; - @XmlAttribute(required = true) - protected boolean emulated; - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the emulated property. - * - */ - public boolean isEmulated() { - return emulated; - } - - /** - * Sets the value of the emulated property. - * - */ - public void setEmulated(boolean value) { - this.emulated = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java deleted file mode 100644 index 38a846701d74c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for EndpointInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="EndpointInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="address" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="port" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="protocol" use="required" type="{}ProtocolEnum" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "EndpointInfo") -class EndpointInfo { - - @XmlAttribute(required = true) - protected String name; - @XmlAttribute(required = true) - protected String address; - @XmlAttribute(required = true) - protected int port; - @XmlAttribute(required = true) - protected ProtocolEnum protocol; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the address property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAddress() { - return address; - } - - /** - * Sets the value of the address property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAddress(String value) { - this.address = value; - } - - /** - * Gets the value of the port property. - * - */ - public int getPort() { - return port; - } - - /** - * Sets the value of the port property. - * - */ - public void setPort(int value) { - this.port = value; - } - - /** - * Gets the value of the protocol property. - * - * @return - * possible object is - * {@link ProtocolEnum } - * - */ - public ProtocolEnum getProtocol() { - return protocol; - } - - /** - * Sets the value of the protocol property. - * - * @param value - * allowed object is - * {@link ProtocolEnum } - * - */ - public void setProtocol(ProtocolEnum value) { - this.protocol = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java deleted file mode 100644 index 208070113082d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for EndpointsInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="EndpointsInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Endpoint" type="{}EndpointInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "EndpointsInfo", propOrder = { - "endpoint" -}) -class EndpointsInfo { - - @XmlElement(name = "Endpoint") - protected List endpoint; - - /** - * Gets the value of the endpoint property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the endpoint property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getEndpoint().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link EndpointInfo } - * - * - */ - public List getEndpoint() { - if (endpoint == null) { - endpoint = new ArrayList(); - } - return this.endpoint; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java deleted file mode 100644 index c341d8630e501..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -enum ExpectedState { - STARTED, STOPPED, -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java deleted file mode 100644 index 9f07267449bb1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for ExpectedStateEnum. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="ExpectedStateEnum">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="Started"/>
- *     <enumeration value="Stopped"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "ExpectedStateEnum") -@XmlEnum -enum ExpectedStateEnum { - - @XmlEnumValue("Started") - STARTED("Started"), - @XmlEnumValue("Stopped") - STOPPED("Stopped"); - private final String value; - - ExpectedStateEnum(String v) { - value = v; - } - - public String value() { - return value; - } - - public static ExpectedStateEnum fromValue(String v) { - for (ExpectedStateEnum c: ExpectedStateEnum.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java deleted file mode 100644 index 75c85fb7e05b8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -/** - * - */ -class FileInputChannel implements InputChannel { - public FileInputChannel() { - } - - public InputStream getInputStream(String name) { - try { - return new FileInputStream(name); - } - catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java deleted file mode 100644 index a377a8f42b729..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.OutputStream; - -/** - * - */ -class FileOutputChannel implements OutputChannel { - public FileOutputChannel() { - } - - public OutputStream getOutputStream(String name) { - try { - return new FileOutputStream(name); - } - catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java deleted file mode 100644 index 963b1e88abaf8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.math.BigInteger; -import java.util.Calendar; - -/** - * - */ -class GoalState { - private final BigInteger incarnation; - private final ExpectedState expectedState; - private final String environmentPath; - private final Calendar deadline; - private final String currentStateEndpoint; - - public GoalState(BigInteger incarnation, ExpectedState expectedState, String environmentPath, Calendar deadline, - String currentStateEndpoint) { - this.incarnation = incarnation; - this.expectedState = expectedState; - this.environmentPath = environmentPath; - this.deadline = deadline; - this.currentStateEndpoint = currentStateEndpoint; - } - - public BigInteger getIncarnation() { - return incarnation; - } - - public ExpectedState getExpectedState() { - return expectedState; - } - - public String getEnvironmentPath() { - return environmentPath; - } - - public Calendar getDeadline() { - return deadline; - } - - public String getCurrentStateEndpoint() { - return currentStateEndpoint; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java deleted file mode 100644 index 68af2418ea7c3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -interface GoalStateChangedListener { - public void goalStateChanged(GoalState newGoalState); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java deleted file mode 100644 index c255037d4393b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; - -/** - * - */ -interface GoalStateDeserializer { - public void initialize(InputStream inputStream); - - public GoalState deserialize(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java deleted file mode 100644 index fa26a21d40464..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.math.BigInteger; -import java.util.Calendar; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSchemaType; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - - -/** - *

Java class for GoalStateInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="GoalStateInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="Incarnation" type="{http://www.w3.org/2001/XMLSchema}unsignedLong"/>
- *         <element name="ExpectedState" type="{}ExpectedStateEnum"/>
- *         <element name="RoleEnvironmentPath" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="CurrentStateEndpoint" type="{http://www.w3.org/2001/XMLSchema}string"/>
- *         <element name="Deadline" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
- *       </all>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "GoalStateInfo", propOrder = { - -}) -class GoalStateInfo { - - @XmlElement(name = "Incarnation", required = true) - @XmlSchemaType(name = "unsignedLong") - protected BigInteger incarnation; - @XmlElement(name = "ExpectedState", required = true) - protected ExpectedStateEnum expectedState; - @XmlElement(name = "RoleEnvironmentPath", required = true) - protected String roleEnvironmentPath; - @XmlElement(name = "CurrentStateEndpoint", required = true) - protected String currentStateEndpoint; - @XmlElement(name = "Deadline", required = true, type = String.class) - @XmlJavaTypeAdapter(Adapter1 .class) - @XmlSchemaType(name = "dateTime") - protected Calendar deadline; - - /** - * Gets the value of the incarnation property. - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getIncarnation() { - return incarnation; - } - - /** - * Sets the value of the incarnation property. - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setIncarnation(BigInteger value) { - this.incarnation = value; - } - - /** - * Gets the value of the expectedState property. - * - * @return - * possible object is - * {@link ExpectedStateEnum } - * - */ - public ExpectedStateEnum getExpectedState() { - return expectedState; - } - - /** - * Sets the value of the expectedState property. - * - * @param value - * allowed object is - * {@link ExpectedStateEnum } - * - */ - public void setExpectedState(ExpectedStateEnum value) { - this.expectedState = value; - } - - /** - * Gets the value of the roleEnvironmentPath property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getRoleEnvironmentPath() { - return roleEnvironmentPath; - } - - /** - * Sets the value of the roleEnvironmentPath property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setRoleEnvironmentPath(String value) { - this.roleEnvironmentPath = value; - } - - /** - * Gets the value of the currentStateEndpoint property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCurrentStateEndpoint() { - return currentStateEndpoint; - } - - /** - * Sets the value of the currentStateEndpoint property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCurrentStateEndpoint(String value) { - this.currentStateEndpoint = value; - } - - /** - * Gets the value of the deadline property. - * - * @return - * possible object is - * {@link String } - * - */ - public Calendar getDeadline() { - return deadline; - } - - /** - * Sets the value of the deadline property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDeadline(Calendar value) { - this.deadline = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java deleted file mode 100644 index 9623dfd83541f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; - -/** - * - */ -interface InputChannel { - public abstract InputStream getInputStream(String name); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java deleted file mode 100644 index c62ff4aaf8667..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents a local storage resource reserved for a service. - */ -public final class LocalResource { - - /** - * maximum size in megabytes allocated for the local storage resource, as - * defined in the service - */ - private int maximumSizeInMegabytes; - - /** - * name of the local store as declared in the service definition file. - */ - private String name; - - /** - * full directory path to the local storage resource. - */ - private String rootPath; - - /** - * Package accessible constructor - * - * @param maximumSizeInMegabytes - * @param name - * @param rootPath - */ - LocalResource(int maximumSizeInMegabytes, String name, String rootPath) { - this.maximumSizeInMegabytes = maximumSizeInMegabytes; - this.name = name; - this.rootPath = rootPath; - } - - /** - * Returns the maximum size, in megabytes, allocated for the local storage - * resource, as defined in the service. - * - * @return The maximum size, in megabytes, allocated for the local storage - * resource. - */ - public int getMaximumSizeInMegabytes() { - return maximumSizeInMegabytes; - } - - /** - * Returns the name of the local store as declared in the service definition - * file. - * - * @return A String object that represents the name of the - * local store. - */ - public String getName() { - return name; - } - - /** - * Returns the full directory path to the local storage resource. - * - * @return A String object that represents the path to the - * local storage resource. - */ - public String getRootPath() { - return rootPath; - } - - /** - * Returns the name, maximum size, and full directory path of the local - * resource. - * - * @return A String object that contains the local resource - * name, maximum size, and directory path. - */ - @Override - public String toString() { - return name + " max:" + maximumSizeInMegabytes + "MB path:" + rootPath; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java deleted file mode 100644 index 524a072ca85a3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for LocalResourceInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="LocalResourceInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="path" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="sizeInMB" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "LocalResourceInfo") -class LocalResourceInfo { - - @XmlAttribute(required = true) - protected String name; - @XmlAttribute(required = true) - protected String path; - @XmlAttribute(required = true) - protected int sizeInMB; - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the value of the path property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPath() { - return path; - } - - /** - * Sets the value of the path property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPath(String value) { - this.path = value; - } - - /** - * Gets the value of the sizeInMB property. - * - */ - public int getSizeInMB() { - return sizeInMB; - } - - /** - * Sets the value of the sizeInMB property. - * - */ - public void setSizeInMB(int value) { - this.sizeInMB = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java deleted file mode 100644 index e4c1f724e57c7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for LocalResourcesInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="LocalResourcesInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="LocalResource" type="{}LocalResourceInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "LocalResourcesInfo", propOrder = { - "localResource" -}) -class LocalResourcesInfo { - - @XmlElement(name = "LocalResource") - protected List localResource; - - /** - * Gets the value of the localResource property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the localResource property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getLocalResource().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link LocalResourceInfo } - * - * - */ - public List getLocalResource() { - if (localResource == null) { - localResource = new ArrayList(); - } - return this.localResource; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java deleted file mode 100644 index 043b15c7dc373..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java +++ /dev/null @@ -1,264 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.JAXBElement; -import javax.xml.bind.annotation.XmlElementDecl; -import javax.xml.bind.annotation.XmlRegistry; -import javax.xml.namespace.QName; - - -/** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.microsoft.windowsazure.serviceruntime package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. - * - */ -@XmlRegistry -class ObjectFactory { - - private final static QName _GoalState_QNAME = new QName("", "GoalState"); - private final static QName _RoleEnvironment_QNAME = new QName("", "RoleEnvironment"); - private final static QName _CurrentState_QNAME = new QName("", "CurrentState"); - private final static QName _RuntimeServerDiscovery_QNAME = new QName("", "RuntimeServerDiscovery"); - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.windowsazure.serviceruntime - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link StatusLeaseInfo.Release } - * - */ - public StatusLeaseInfo.Release createStatusLeaseInfoRelease() { - return new StatusLeaseInfo.Release(); - } - - /** - * Create an instance of {@link RuntimeServerEndpointsInfo } - * - */ - public RuntimeServerEndpointsInfo createRuntimeServerEndpointsInfo() { - return new RuntimeServerEndpointsInfo(); - } - - /** - * Create an instance of {@link RuntimeServerEndpointInfo } - * - */ - public RuntimeServerEndpointInfo createRuntimeServerEndpointInfo() { - return new RuntimeServerEndpointInfo(); - } - - /** - * Create an instance of {@link RuntimeServerDiscoveryInfo } - * - */ - public RuntimeServerDiscoveryInfo createRuntimeServerDiscoveryInfo() { - return new RuntimeServerDiscoveryInfo(); - } - - /** - * Create an instance of {@link GoalStateInfo } - * - */ - public GoalStateInfo createGoalStateInfo() { - return new GoalStateInfo(); - } - - /** - * Create an instance of {@link LocalResourcesInfo } - * - */ - public LocalResourcesInfo createLocalResourcesInfo() { - return new LocalResourcesInfo(); - } - - /** - * Create an instance of {@link ConfigurationSettingInfo } - * - */ - public ConfigurationSettingInfo createConfigurationSettingInfo() { - return new ConfigurationSettingInfo(); - } - - /** - * Create an instance of {@link CurrentStateInfo } - * - */ - public CurrentStateInfo createCurrentStateInfo() { - return new CurrentStateInfo(); - } - - /** - * Create an instance of {@link CurrentRoleInstanceInfo } - * - */ - public CurrentRoleInstanceInfo createCurrentRoleInstanceInfo() { - return new CurrentRoleInstanceInfo(); - } - - /** - * Create an instance of {@link LocalResourceInfo } - * - */ - public LocalResourceInfo createLocalResourceInfo() { - return new LocalResourceInfo(); - } - - /** - * Create an instance of {@link RolesInfo } - * - */ - public RolesInfo createRolesInfo() { - return new RolesInfo(); - } - - /** - * Create an instance of {@link StatusLeaseInfo } - * - */ - public StatusLeaseInfo createStatusLeaseInfo() { - return new StatusLeaseInfo(); - } - - /** - * Create an instance of {@link DeploymentInfo } - * - */ - public DeploymentInfo createDeploymentInfo() { - return new DeploymentInfo(); - } - - /** - * Create an instance of {@link RoleInstancesInfo } - * - */ - public RoleInstancesInfo createRoleInstancesInfo() { - return new RoleInstancesInfo(); - } - - /** - * Create an instance of {@link RoleInfo } - * - */ - public RoleInfo createRoleInfo() { - return new RoleInfo(); - } - - /** - * Create an instance of {@link ConfigurationSettingsInfo } - * - */ - public ConfigurationSettingsInfo createConfigurationSettingsInfo() { - return new ConfigurationSettingsInfo(); - } - - /** - * Create an instance of {@link EndpointsInfo } - * - */ - public EndpointsInfo createEndpointsInfo() { - return new EndpointsInfo(); - } - - /** - * Create an instance of {@link AcquireLeaseInfo } - * - */ - public AcquireLeaseInfo createAcquireLeaseInfo() { - return new AcquireLeaseInfo(); - } - - /** - * Create an instance of {@link EndpointInfo } - * - */ - public EndpointInfo createEndpointInfo() { - return new EndpointInfo(); - } - - /** - * Create an instance of {@link RoleEnvironmentInfo } - * - */ - public RoleEnvironmentInfo createRoleEnvironmentInfo() { - return new RoleEnvironmentInfo(); - } - - /** - * Create an instance of {@link RoleInstanceInfo } - * - */ - public RoleInstanceInfo createRoleInstanceInfo() { - return new RoleInstanceInfo(); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link GoalStateInfo }{@code >}} - * - */ - @XmlElementDecl(namespace = "", name = "GoalState") - public JAXBElement createGoalState(GoalStateInfo value) { - return new JAXBElement(_GoalState_QNAME, GoalStateInfo.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link RoleEnvironmentInfo }{@code >}} - * - */ - @XmlElementDecl(namespace = "", name = "RoleEnvironment") - public JAXBElement createRoleEnvironment(RoleEnvironmentInfo value) { - return new JAXBElement(_RoleEnvironment_QNAME, RoleEnvironmentInfo.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link CurrentStateInfo }{@code >}} - * - */ - @XmlElementDecl(namespace = "", name = "CurrentState") - public JAXBElement createCurrentState(CurrentStateInfo value) { - return new JAXBElement(_CurrentState_QNAME, CurrentStateInfo.class, null, value); - } - - /** - * Create an instance of {@link JAXBElement }{@code <}{@link RuntimeServerDiscoveryInfo }{@code >}} - * - */ - @XmlElementDecl(namespace = "", name = "RuntimeServerDiscovery") - public JAXBElement createRuntimeServerDiscovery(RuntimeServerDiscoveryInfo value) { - return new JAXBElement(_RuntimeServerDiscovery_QNAME, RuntimeServerDiscoveryInfo.class, null, value); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java deleted file mode 100644 index 02588c1bbd76f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.OutputStream; - -/** - * - */ -interface OutputChannel { - public abstract OutputStream getOutputStream(String name); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java deleted file mode 100644 index 145fd690c46ba..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -class Protocol1RuntimeClient implements RuntimeClient { - private final Protocol1RuntimeGoalStateClient goalStateClient; - private final Protocol1RuntimeCurrentStateClient currentStateClient; - - public Protocol1RuntimeClient(Protocol1RuntimeGoalStateClient goalStateClient, - Protocol1RuntimeCurrentStateClient currentStateClient, String endpoint) { - this.goalStateClient = goalStateClient; - this.currentStateClient = currentStateClient; - - this.goalStateClient.setEndpoint(endpoint); - } - - @Override - public GoalState getCurrentGoalState() throws InterruptedException { - return goalStateClient.getCurrentGoalState(); - } - - @Override - public RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException { - return goalStateClient.getRoleEnvironmentData(); - } - - @Override - public void addGoalStateChangedListener(GoalStateChangedListener listener) { - goalStateClient.addGoalStateChangedListener(listener); - } - - @Override - public void removeGoalStateChangedListener(GoalStateChangedListener listener) { - goalStateClient.removeGoalStateChangedListener(listener); - } - - @Override - public void setCurrentState(CurrentState state) { - currentStateClient.setCurrentState(state); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java deleted file mode 100644 index 5629f11bcf2c6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.concurrent.atomic.AtomicReference; - -/** - * - */ -class Protocol1RuntimeCurrentStateClient implements RuntimeCurrentStateClient { - private final CurrentStateSerializer serializer; - private final OutputChannel outputChannel; - private final AtomicReference endpoint; - - public Protocol1RuntimeCurrentStateClient(CurrentStateSerializer serializer, OutputChannel outputChannel) { - this.serializer = serializer; - this.outputChannel = outputChannel; - this.endpoint = new AtomicReference(); - } - - public void setEndpoint(String endpoint) { - this.endpoint.set(endpoint); - } - - @Override - public void setCurrentState(CurrentState state) { - OutputStream outputStream = outputChannel.getOutputStream(endpoint.get()); - - serializer.serialize(state, outputStream); - - try { - outputStream.close(); - } - catch (IOException e) { - throw new RoleEnvironmentNotAvailableException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java deleted file mode 100644 index 5ad4692c4352f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -/** - * - */ -class Protocol1RuntimeGoalStateClient implements RuntimeGoalStateClient { - private final Protocol1RuntimeCurrentStateClient currentStateClient; - private Thread ioThread; - private final GoalStateDeserializer goalStateDeserializer; - private final RoleEnvironmentDataDeserializer roleEnvironmentDeserializer; - private final InputChannel inputChannel; - private final CountDownLatch goalStateLatch; - private final List listeners; - private String endpoint; - - private AtomicReference currentGoalState; - private AtomicReference currentEnvironmentData; - - public Protocol1RuntimeGoalStateClient(Protocol1RuntimeCurrentStateClient currentStateClient, - GoalStateDeserializer goalStateDeserializer, RoleEnvironmentDataDeserializer roleEnvironmentDeserializer, - InputChannel inputChannel) { - this.currentStateClient = currentStateClient; - this.goalStateDeserializer = goalStateDeserializer; - this.roleEnvironmentDeserializer = roleEnvironmentDeserializer; - this.inputChannel = inputChannel; - - this.listeners = new LinkedList(); - this.goalStateLatch = new CountDownLatch(1); - - this.currentGoalState = new AtomicReference(); - this.currentEnvironmentData = new AtomicReference(); - } - - public GoalState getCurrentGoalState() throws InterruptedException { - ensureGoalStateRetrieved(); - - return currentGoalState.get(); - } - - public synchronized RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException { - ensureGoalStateRetrieved(); - - if (currentEnvironmentData.get() == null) { - GoalState current = currentGoalState.get(); - - if (current.getEnvironmentPath() == null) { - throw new InterruptedException("No role environment data for the current goal state."); - } - - InputStream environmentStream = inputChannel.getInputStream(current.getEnvironmentPath()); - - currentEnvironmentData.set(roleEnvironmentDeserializer.deserialize(environmentStream)); - } - - return currentEnvironmentData.get(); - } - - public void addGoalStateChangedListener(GoalStateChangedListener listener) { - listeners.add(listener); - } - - public void removeGoalStateChangedListener(GoalStateChangedListener listener) { - listeners.remove(listener); - } - - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - } - - private void ensureGoalStateRetrieved() throws InterruptedException { - ensureThread(); - - if (currentGoalState.get() == null) { - while (!goalStateLatch.await(100, TimeUnit.MILLISECONDS)) { - ensureThread(); - } - } - } - - private void ensureThread() { - if (ioThread == null || !ioThread.isAlive()) { - startGoalStateTask(); - } - } - - private void startGoalStateTask() { - Runnable goalStateListener = new Runnable() { - public void run() { - InputStream inputStream = inputChannel.getInputStream(endpoint); - - goalStateDeserializer.initialize(inputStream); - - GoalState goalState = goalStateDeserializer.deserialize(); - - if (goalState == null) { - return; - } - - currentGoalState.set(goalState); - - if (goalState.getEnvironmentPath() != null) { - currentEnvironmentData.set(null); - } - - currentStateClient.setEndpoint(currentGoalState.get().getCurrentStateEndpoint()); - - goalStateLatch.countDown(); - - while (true) { - goalState = goalStateDeserializer.deserialize(); - - if (goalState == null) { - return; - } - - currentGoalState.set(goalState); - - if (goalState.getEnvironmentPath() != null) { - currentEnvironmentData.set(null); - } - - currentStateClient.setEndpoint(currentGoalState.get().getCurrentStateEndpoint()); - - for (GoalStateChangedListener listener : listeners) { - listener.goalStateChanged(currentGoalState.get()); - } - } - } - }; - - ioThread = new Thread(goalStateListener); - - ioThread.setDaemon(true); - - ioThread.start(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java deleted file mode 100644 index db453e64c4fc6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for ProtocolEnum. - * - *

The following schema fragment specifies the expected content contained within this class. - *

- *

- * <simpleType name="ProtocolEnum">
- *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
- *     <enumeration value="ip"/>
- *     <enumeration value="tcp"/>
- *     <enumeration value="tls"/>
- *     <enumeration value="http"/>
- *     <enumeration value="https"/>
- *     <enumeration value="wcf:tcp"/>
- *     <enumeration value="wcf:tls"/>
- *     <enumeration value="wcf:http"/>
- *     <enumeration value="wcf:https"/>
- *     <enumeration value="wcf:https:certificate"/>
- *     <enumeration value="udp"/>
- *     <enumeration value="raw"/>
- *   </restriction>
- * </simpleType>
- * 
- * - */ -@XmlType(name = "ProtocolEnum") -@XmlEnum -enum ProtocolEnum { - - @XmlEnumValue("ip") - IP("ip"), - @XmlEnumValue("tcp") - TCP("tcp"), - @XmlEnumValue("tls") - TLS("tls"), - @XmlEnumValue("http") - HTTP("http"), - @XmlEnumValue("https") - HTTPS("https"), - @XmlEnumValue("wcf:tcp") - WCF_TCP("wcf:tcp"), - @XmlEnumValue("wcf:tls") - WCF_TLS("wcf:tls"), - @XmlEnumValue("wcf:http") - WCF_HTTP("wcf:http"), - @XmlEnumValue("wcf:https") - WCF_HTTPS("wcf:https"), - @XmlEnumValue("wcf:https:certificate") - WCF_HTTPS_CERTIFICATE("wcf:https:certificate"), - @XmlEnumValue("udp") - UDP("udp"), - @XmlEnumValue("raw") - RAW("raw"); - private final String value; - - ProtocolEnum(String v) { - value = v; - } - - public String value() { - return value; - } - - public static ProtocolEnum fromValue(String v) { - for (ProtocolEnum c: ProtocolEnum.values()) { - if (c.value.equals(v)) { - return c; - } - } - throw new IllegalArgumentException(v); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java deleted file mode 100644 index a1f55f0c57e14..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -class ReleaseCurrentState extends CurrentState { - public ReleaseCurrentState(String clientId) { - super(clientId); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java deleted file mode 100644 index aacdb7393c327..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Map; - -/** - * Represents a role that is defined as part of a hosted service. - */ -public final class Role { - private final String name; - private final Map instances; - - /** - * Constructor - * - * @param name - * @param instances - */ - Role(String name, Map instances) { - this.name = name; - this.instances = instances; - } - - /** - * Returns the collection of instances for the role. - *

- * The number of instances of a role to be deployed to Windows Azure is specified in the service's configuration - * file. - *

- * A role must define at least one internal endpoint in order for its set of instances to be known at runtime. - * - * @return A read-only java.util.Map object that contains the - * instances for the role, or null if the instances - * could not be retrieved. - */ - public Map getInstances() { - return instances; - } - - /** - * Returns the name of the role as it is declared in the service definition - * file. - * - * @return A String object that represents the name of the role - * as it is declared in the service definition file. - */ - public String getName() { - return name; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java deleted file mode 100644 index f0bc096b8a1e8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ /dev/null @@ -1,603 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; - -/** - * Represents the Windows Azure environment in which an instance of a role is - * running. - */ -public final class RoleEnvironment { - private static final String VersionEndpointEnvironmentName = "WaRuntimeEndpoint"; - private static final String VersionEndpointFixedPath = "\\\\.\\pipe\\WindowsAzureRuntime"; - private static final String clientId; - - private static RuntimeClient runtimeClient; - private static AtomicReference currentGoalState; - private static AtomicReference currentEnvironmentData; - private static List changingListeners; - private static List changedListeners; - private static List stoppingListeners; - private static AtomicReference lastState; - private static final Calendar maxDateTime; - - static { - try { - JAXBContext.newInstance(RoleEnvironment.class.getPackage().getName()); - } - catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - clientId = UUID.randomUUID().toString(); - maxDateTime = javax.xml.bind.DatatypeConverter.parseDateTime("9999-12-31T23:59:59.9999999"); - } - - private RoleEnvironment() { - }; - - private static synchronized void initialize() { - if (runtimeClient == null) { - String endpoint = System.getenv(VersionEndpointEnvironmentName); - - if (endpoint == null) { - endpoint = VersionEndpointFixedPath; - } - - RuntimeKernel kernel = RuntimeKernel.getKernel(); - - try { - runtimeClient = kernel.getRuntimeVersionManager().getRuntimeClient(endpoint); - } - catch (Throwable t) { - throw new RoleEnvironmentNotAvailableException(t); - } - - changingListeners = new LinkedList(); - changedListeners = new LinkedList(); - stoppingListeners = new LinkedList(); - - try { - currentGoalState = new AtomicReference(runtimeClient.getCurrentGoalState()); - currentEnvironmentData = new AtomicReference( - runtimeClient.getRoleEnvironmentData()); - } - catch (InterruptedException e) { - throw new RoleEnvironmentNotAvailableException(e); - } - - lastState = new AtomicReference(); - - runtimeClient.addGoalStateChangedListener(new GoalStateChangedListener() { - public void goalStateChanged(GoalState newGoalState) { - switch (newGoalState.getExpectedState()) { - case STARTED: - if (newGoalState.getIncarnation().compareTo(currentGoalState.get().getIncarnation()) > 0) { - processGoalStateChange(newGoalState); - } - break; - case STOPPED: - raiseStoppingEvent(); - - CurrentState stoppedState = new AcquireCurrentState(clientId, - newGoalState.getIncarnation(), CurrentStatus.STOPPED, maxDateTime); - - runtimeClient.setCurrentState(stoppedState); - break; - } - } - }); - } - else { - try { - currentGoalState.set(runtimeClient.getCurrentGoalState()); - currentEnvironmentData.set(runtimeClient.getRoleEnvironmentData()); - } - catch (InterruptedException e) { - throw new RoleEnvironmentNotAvailableException(e); - } - } - } - - private static void processGoalStateChange(GoalState newGoalState) { - List changes = new LinkedList(); - RoleEnvironmentChangingEvent changingEvent = new RoleEnvironmentChangingEvent(changes); - CurrentState last = lastState.get(); - - calculateChanges(changes); - - if (changes.isEmpty()) { - acceptLatestIncarnation(newGoalState, last); - } - else { - for (RoleEnvironmentChangingListener listener : changingListeners) { - try { - listener.roleEnvironmentChanging(changingEvent); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - - if (changingEvent.isCancelled()) { - CurrentState recycleState = new AcquireCurrentState(clientId, newGoalState.getIncarnation(), - CurrentStatus.RECYCLE, maxDateTime); - - runtimeClient.setCurrentState(recycleState); - - return; - } - - acceptLatestIncarnation(newGoalState, last); - - try { - currentEnvironmentData.set(runtimeClient.getRoleEnvironmentData()); - } - catch (InterruptedException e) { - throw new RoleEnvironmentNotAvailableException(e); - } - - for (RoleEnvironmentChangedListener listener : changedListeners) { - try { - listener.roleEnvironmentChanged(new RoleEnvironmentChangedEvent(changes)); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - } - - private static void acceptLatestIncarnation(GoalState newGoalState, CurrentState last) { - if (last != null && last instanceof AcquireCurrentState) { - AcquireCurrentState acquireState = (AcquireCurrentState) last; - - CurrentState acceptState = new AcquireCurrentState(clientId, newGoalState.getIncarnation(), - acquireState.getStatus(), acquireState.getExpiration()); - - runtimeClient.setCurrentState(acceptState); - } - - currentGoalState.set(newGoalState); - } - - private static void calculateChanges(List changes) { - RoleEnvironmentData current = currentEnvironmentData.get(); - RoleEnvironmentData newData; - - try { - newData = runtimeClient.getRoleEnvironmentData(); - } - catch (InterruptedException e) { - throw new RoleEnvironmentNotAvailableException(e); - } - - Map currentConfig = current.getConfigurationSettings(); - Map newConfig = newData.getConfigurationSettings(); - Map currentRoles = current.getRoles(); - Map newRoles = newData.getRoles(); - - for (String setting : currentConfig.keySet()) { - if (newConfig.containsKey(setting)) { - if (!newConfig.get(setting).equals(currentConfig.get(setting))) { - changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); - } - } - else { - changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); - } - } - - for (String setting : newConfig.keySet()) { - if (!currentConfig.containsKey(setting)) { - changes.add(new RoleEnvironmentConfigurationSettingChange(setting)); - } - } - - Set changedRoleSet = new HashSet(); - - for (String role : currentRoles.keySet()) { - if (newRoles.containsKey(role)) { - Role currentRole = currentRoles.get(role); - Role newRole = newRoles.get(role); - - for (String instance : currentRole.getInstances().keySet()) { - if (newRole.getInstances().containsKey(instance)) { - RoleInstance currentInstance = currentRole.getInstances().get(instance); - RoleInstance newInstance = newRole.getInstances().get(instance); - - if (currentInstance.getUpdateDomain() == newInstance.getUpdateDomain() - && currentInstance.getFaultDomain() == newInstance.getFaultDomain()) { - for (String endpoint : currentInstance.getInstanceEndpoints().keySet()) { - if (newInstance.getInstanceEndpoints().containsKey(endpoint)) { - RoleInstanceEndpoint currentEndpoint = currentInstance.getInstanceEndpoints().get( - endpoint); - RoleInstanceEndpoint newEndpoint = newInstance.getInstanceEndpoints().get(endpoint); - - if (!currentEndpoint.getProtocol().equals(newEndpoint.getProtocol()) - || !currentEndpoint.getIpEndPoint().equals(newEndpoint.getIpEndPoint())) { - changedRoleSet.add(role); - } - } - else { - changedRoleSet.add(role); - } - } - } - else { - changedRoleSet.add(role); - } - } - else { - changedRoleSet.add(role); - } - } - } - else { - changedRoleSet.add(role); - } - } - - for (String role : newRoles.keySet()) { - if (currentRoles.containsKey(role)) { - Role currentRole = currentRoles.get(role); - Role newRole = newRoles.get(role); - - for (String instance : newRole.getInstances().keySet()) { - if (currentRole.getInstances().containsKey(instance)) { - RoleInstance currentInstance = currentRole.getInstances().get(instance); - RoleInstance newInstance = newRole.getInstances().get(instance); - - if (currentInstance.getUpdateDomain() == newInstance.getUpdateDomain() - && currentInstance.getFaultDomain() == newInstance.getFaultDomain()) { - for (String endpoint : newInstance.getInstanceEndpoints().keySet()) { - if (currentInstance.getInstanceEndpoints().containsKey(endpoint)) { - RoleInstanceEndpoint currentEndpoint = currentInstance.getInstanceEndpoints().get( - endpoint); - RoleInstanceEndpoint newEndpoint = newInstance.getInstanceEndpoints().get(endpoint); - - if (!currentEndpoint.getProtocol().equals(newEndpoint.getProtocol()) - || !currentEndpoint.getIpEndPoint().equals(newEndpoint.getIpEndPoint())) { - changedRoleSet.add(role); - } - } - else { - changedRoleSet.add(role); - } - } - } - else { - changedRoleSet.add(role); - } - } - else { - changedRoleSet.add(role); - } - } - } - else { - changedRoleSet.add(role); - } - } - - for (String role : changedRoleSet) { - changes.add(new RoleEnvironmentTopologyChange(role)); - } - } - - private static synchronized void raiseStoppingEvent() { - for (RoleEnvironmentStoppingListener listener : stoppingListeners) { - try { - listener.roleEnvironmentStopping(); - } - catch (Throwable t) { - t.printStackTrace(); - } - } - } - - /** - * Returns a {@link RoleInstance} object that represents the role instance - * in which this code is currently executing. - * - * @return A RoleInstance object that represents the role - * instance in which this code is currently executing. - */ - public static RoleInstance getCurrentRoleInstance() { - initialize(); - - return currentEnvironmentData.get().getCurrentInstance(); - } - - /** - * Returns the deployment ID that uniquely identifies the deployment in - * which this role instance is running. - * - * @return A String object that represents the deployment ID. - */ - public static String getDeploymentId() { - initialize(); - - return currentEnvironmentData.get().getDeploymentId(); - } - - /** - * Indicates whether the role instance is running in the Windows Azure - * environment. - * - * @return true if this instance is running in the development - * fabric or in the Windows Azure environment in the cloud; - * otherwise, false. - */ - public static boolean isAvailable() { - try { - initialize(); - } - catch (RoleEnvironmentNotAvailableException ex) { - } - - return runtimeClient != null; - } - - /** - * Indicates whether the role instance is running in the development fabric. - * - * @return true if this instance is running in the development - * fabric; otherwise, false. - */ - public static boolean isEmulated() { - initialize(); - - return currentEnvironmentData.get().isEmulated(); - } - - /** - * Returns the set of {@link Role} objects defined for your service. - *

- * Roles are defined in the service definition file. - * - * @return A java.util.Map object containing the set of {@link Role} objects that represent the roles - * defined for your - * service. - */ - public static Map getRoles() { - initialize(); - - return currentEnvironmentData.get().getRoles(); - } - - /** - * Retrieves the settings in the service configuration file. - *

- * A role's configuration settings are defined in the service definition file. Values for configuration settings are - * set in the service configuration file. - * - * @return A java.util.Map object containing the String objects that represent the - * configuration - * settings. - */ - public static Map getConfigurationSettings() { - initialize(); - - return currentEnvironmentData.get().getConfigurationSettings(); - } - - /** - * Retrieves the set of named local storage resources. - * - * @return A java.util.Map object containing the String objects that represent the local - * storage - * resources. - */ - public static Map getLocalResources() { - initialize(); - - return currentEnvironmentData.get().getLocalResources(); - } - - /** - * Requests that the current role instance be stopped and restarted. - *

- * Before the role instance is recycled, the Windows Azure load balancer takes the role instance out of rotation. - * This ensures that no new requests are routed to the instance while it is restarting. - * - * A call to RequestRecycle initiates the normal shutdown cycle. Windows Azure raises the - * Stopping event and calls the OnStop method so that you can run the necessary code to - * prepare the instance to be recycled. - */ - public static void requestRecycle() { - initialize(); - - CurrentState recycleState = new AcquireCurrentState(clientId, currentGoalState.get().getIncarnation(), - CurrentStatus.RECYCLE, maxDateTime); - - runtimeClient.setCurrentState(recycleState); - } - - /** - * Sets the status of the role instance. - *

- * An instance may indicate that it is in one of two states: Ready or Busy. If an instance's state is Ready, it is - * prepared to receive requests from the load balancer. If the instance's state is Busy, it will not receive - * requests from the load balancer. - * - * @param status - * A {@link RoleInstanceStatus} value that indicates whether the - * instance is ready or busy. - * @param expiration_utc - * A java.util.Date value that specifies the - * expiration date and time of the status. - * - */ - public static void setStatus(RoleInstanceStatus status, Date expiration_utc) { - initialize(); - - CurrentStatus currentStatus = CurrentStatus.STARTED; - - switch (status) { - case Busy: - currentStatus = CurrentStatus.BUSY; - break; - case Ready: - currentStatus = CurrentStatus.STARTED; - } - - Calendar expiration = Calendar.getInstance(); - expiration.setTime(expiration_utc); - - CurrentState newState = new AcquireCurrentState(clientId, currentGoalState.get().getIncarnation(), - currentStatus, expiration); - - lastState.set(newState); - - runtimeClient.setCurrentState(newState); - } - - /** - * Clears the status of the role instance. - *

- * An instance may indicate that it has completed communicating status by calling this method. - * - */ - public static void clearStatus() { - initialize(); - - CurrentState newState = new ReleaseCurrentState(clientId); - - lastState.set(newState); - - runtimeClient.setCurrentState(newState); - } - - /** - * Adds an event listener for the Changed event, which occurs - * after a configuration change has been applied to a role instance. - *

- * A Changed event is encapsulated in a {@link RoleEnvironmentChangedEvent} object. - * - * @param listener - * A {@link RoleEnvironmentChangedListener} object that - * represents the event listener to add. - * - * @see #removeRoleEnvironmentChangedListener - */ - public static synchronized void addRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener) { - initialize(); - - changedListeners.add(listener); - } - - /** - * Removes an event listener for the Changed event. - * - * @param listener - * A {@link RoleEnvironmentChangedListener} object that - * represents the event listener to remove. - * - * @see #addRoleEnvironmentChangedListener - */ - public static synchronized void removeRoleEnvironmentChangedListener(RoleEnvironmentChangedListener listener) { - initialize(); - - changedListeners.remove(listener); - } - - /** - * Adds an event listener for the Changing event, which occurs - * before a change to the service configuration is applied to the running - * instances of the role. - *

- * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include - * changes to the service configuration changes and changes to the number of instances in the service. - *

- * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes - * have been applied to each running role instance. This event can be cancelled for a given instance to prevent the - * configuration change. - *

- * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, - * the configuration change is applied when it restarts. - *

- * A Changing event is encapsulated in a {@link RoleEnvironmentChangingEvent} object. - * - * @param listener - * A {@link RoleEnvironmentChangingListener} object that - * represents the event listener to add. - * - * @see #removeRoleEnvironmentChangingListener - */ - public static synchronized void addRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener) { - initialize(); - - changingListeners.add(listener); - } - - /** - * Removes an event listener for the Changing event. - * - * @param listener - * A {@link RoleEnvironmentChangingListener} object that - * represents the event listener to remove. - * - * @see #addRoleEnvironmentChangingListener - */ - public static void removeRoleEnvironmentChangingListener(RoleEnvironmentChangingListener listener) { - initialize(); - - changingListeners.remove(listener); - } - - /** - * Adds an event listener for the Stopping event, which occurs - * wheen the role is stopping. - * - * @param listener - * A {@link RoleEnvironmentStoppingListener} object that - * represents the event listener to add. - * - * @see #removeRoleEnvironmentStoppingListener - */ - public static synchronized void addRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener) { - initialize(); - - stoppingListeners.add(listener); - } - - /** - * Removes an event listener for the Stopping event. - * - * @param listener - * A {@link RoleEnvironmentStoppingListener} object that - * represents the event listener to remove. - * - * @see #addRoleEnvironmentStoppingListener - */ - public static synchronized void removeRoleEnvironmentStoppingListener(RoleEnvironmentStoppingListener listener) { - initialize(); - - stoppingListeners.remove(listener); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java deleted file mode 100644 index 25f1471358ef3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Abstract class that represents a change to the service's configuration. - */ -public abstract class RoleEnvironmentChange { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java deleted file mode 100644 index 9dceff6aaa21e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Collection; - -/** - * Occurs after a change to the service configuration has been applied to the - * running instances of the role. - */ -public class RoleEnvironmentChangedEvent { - - private Collection changes; - - /** - * Constructor. Can only be called by the deserialization logic - * - * @param changes - */ - RoleEnvironmentChangedEvent(Collection changes) { - this.changes = changes; - } - - /** - * Returns a collection of the configuration changes that were applied to - * the role instance. - * - * @return A java.util.Collection object containing the {@link RoleEnvironmentChange} objects that - * represent the - * configuration changes that were applied to the role instance. - * - * @see RoleEnvironmentChange - */ - public Collection getChanges() { - return changes; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java deleted file mode 100644 index f97f3254bf799..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents the listener for the environment changed event. - *

- * The environment changed event is encapsulated in a {@link RoleEnvironmentChangedEvent} object. - */ -public interface RoleEnvironmentChangedListener { - - /** - * Occurs after a change to the service configuration has been applied to - * the running instances of the role. - * - * @param event - * A {@link RoleEnvironmentChangedEvent} object that represents - * the environment changed event. - * - * @see RoleEnvironmentChangingListener#roleEnvironmentChanging - */ - public void roleEnvironmentChanged(RoleEnvironmentChangedEvent event); - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java deleted file mode 100644 index 165c01ae04453..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Collection; - -/** - * - * Occurs before a change to the service configuration is applied to the running - * instances of the role. - *

- * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include changes - * to the service configuration changes and changes to the number of instances in the service. - *

- * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes have - * been applied to each running role instance. This event can be cancelled for a given instance to prevent the - * configuration change. - *

- * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, the - * configuration change is applied when it restarts. - * - * @see RoleEnvironmentChangingListener - * @see RoleEnvironmentChangedEvent - */ -public class RoleEnvironmentChangingEvent { - private final Collection changes; - private boolean cancelled; - - RoleEnvironmentChangingEvent(Collection changes) { - this.changes = changes; - - cancelled = false; - } - - /** - * Cancel the configuration change. - *

- * Cancellation causes the role instance to be immediately recycled. The configuration changes are applied when the - * instance restarts. - * - */ - public void cancel() { - cancelled = true; - } - - boolean isCancelled() { - return cancelled; - } - - /** - * Returns a collection of the configuration changes that are about to be - * applied to the role instance. - * - * @return A java.util.Collection object containing {@link RoleEnvironmentChange} objects that - * represent the - * configuration changes that are about to be applied to the role - * instance. - * - * @see RoleEnvironmentChange - */ - public Collection getChanges() { - return changes; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java deleted file mode 100644 index d23826c7636d5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents the listener for the environment changing event. - *

- * The environment changing event is encapsulated in an - * {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironmentChangingEvent} object. - */ -public interface RoleEnvironmentChangingListener { - - /** - * Occurs before a change to the service configuration is applied to the - * running instances of the role. - *

- * Service configuration changes are applied on-the-fly to running role instances. Configuration changes include - * changes to the service configuration changes and changes to the number of instances in the service. - *

- * This event occurs after the new configuration file has been submitted to Windows Azure but before the changes - * have been applied to each running role instance. This event can be cancelled for a given instance to prevent the - * configuration change. - *

- * Note that cancelling this event causes the instance to be automatically recycled. When the instance is recycled, - * the configuration change is applied when it restarts. - * - * @param event - * A {@link RoleEnvironmentChangingEvent} object that represents - * the environment changing event. - * - * @see RoleEnvironmentChangedListener#roleEnvironmentChanged - */ - public void roleEnvironmentChanging(RoleEnvironmentChangingEvent event); - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java deleted file mode 100644 index 8cacec8f39369..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents a change to a configuration setting. - * - * @see RoleEnvironmentTopologyChange - */ -public class RoleEnvironmentConfigurationSettingChange extends RoleEnvironmentChange { - - private String settingName; - - RoleEnvironmentConfigurationSettingChange(String settingName) { - this.settingName = settingName; - } - - /** - * Returns the name of the configuration setting that has been changed. - * - * @return A String object that represents the name of the - * configuration setting that has been changed. - */ - public String getConfigurationSettingName() { - return settingName; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java deleted file mode 100644 index 28d7583ec2dd1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Map; - -/** - * - */ -class RoleEnvironmentData { - private final String deploymentId; - private final Map configurationSettings; - private final Map localResources; - private final RoleInstance currentInstance; - private final Map roles; - private final boolean isEmulated; - - public RoleEnvironmentData(String deploymentId, Map configurationSettings, - Map localResources, RoleInstance currentInstance, Map roles, - boolean isEmulated) { - this.deploymentId = deploymentId; - this.configurationSettings = configurationSettings; - this.localResources = localResources; - this.currentInstance = currentInstance; - this.roles = roles; - this.isEmulated = isEmulated; - } - - public Map getConfigurationSettings() { - return configurationSettings; - } - - public Map getLocalResources() { - return localResources; - } - - public RoleInstance getCurrentInstance() { - return currentInstance; - } - - public Map getRoles() { - return roles; - } - - public String getDeploymentId() { - return deploymentId; - } - - public boolean isEmulated() { - return isEmulated; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java deleted file mode 100644 index acb58d29d2139..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; - -/** - * - */ -interface RoleEnvironmentDataDeserializer { - public RoleEnvironmentData deserialize(InputStream stream); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java deleted file mode 100644 index d12e8be57331b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RoleEnvironmentInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RoleEnvironmentInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="Deployment" type="{}DeploymentInfo"/>
- *         <element name="CurrentInstance" type="{}CurrentRoleInstanceInfo"/>
- *         <element name="Roles" type="{}RolesInfo" minOccurs="0"/>
- *       </all>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RoleEnvironmentInfo", propOrder = { - -}) -class RoleEnvironmentInfo { - - @XmlElement(name = "Deployment", required = true) - protected DeploymentInfo deployment; - @XmlElement(name = "CurrentInstance", required = true) - protected CurrentRoleInstanceInfo currentInstance; - @XmlElement(name = "Roles") - protected RolesInfo roles; - - /** - * Gets the value of the deployment property. - * - * @return - * possible object is - * {@link DeploymentInfo } - * - */ - public DeploymentInfo getDeployment() { - return deployment; - } - - /** - * Sets the value of the deployment property. - * - * @param value - * allowed object is - * {@link DeploymentInfo } - * - */ - public void setDeployment(DeploymentInfo value) { - this.deployment = value; - } - - /** - * Gets the value of the currentInstance property. - * - * @return - * possible object is - * {@link CurrentRoleInstanceInfo } - * - */ - public CurrentRoleInstanceInfo getCurrentInstance() { - return currentInstance; - } - - /** - * Sets the value of the currentInstance property. - * - * @param value - * allowed object is - * {@link CurrentRoleInstanceInfo } - * - */ - public void setCurrentInstance(CurrentRoleInstanceInfo value) { - this.currentInstance = value; - } - - /** - * Gets the value of the roles property. - * - * @return - * possible object is - * {@link RolesInfo } - * - */ - public RolesInfo getRoles() { - return roles; - } - - /** - * Sets the value of the roles property. - * - * @param value - * allowed object is - * {@link RolesInfo } - * - */ - public void setRoles(RolesInfo value) { - this.roles = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java deleted file mode 100644 index 5d677fc39c4b5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents an exception indicating the role environment is not available. - */ -public class RoleEnvironmentNotAvailableException extends RuntimeException { - - private static final long serialVersionUID = -6218741025124056882L; - - /** - * Creates an instance of the RoleEnvironmentNotAvailableException class. - * - * @param t - * A java.lang.Throwable object that represents the - * cause for the exception. - * - */ - - public RoleEnvironmentNotAvailableException(Throwable t) { - initCause(t); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java deleted file mode 100644 index e226db05b84b0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents the listener for the stopping event. - */ -public interface RoleEnvironmentStoppingListener { - /** - * Occurs when the role instance is about to be stopped. - *

- * This event is raised after the instance has been taken out of the load balancer's rotation before the - * OnStop method is called. You can use this event to run code that is required for the role instance - * to shut down in an orderly fashion. - */ - - public void roleEnvironmentStopping(); - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java deleted file mode 100644 index b6e93c6f2defd..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Represents a change to the topology of the service. - *

- * The service's topology refers to the number of instances deployed for each role that the service defines. - */ -public class RoleEnvironmentTopologyChange extends RoleEnvironmentChange { - - private String roleName; - - RoleEnvironmentTopologyChange(String roleName) { - this.roleName = roleName; - } - - /** - * Returns the name of the affected role. - * - * @return A String object that represents the name of the - * affected role. - */ - public String getRoleName() { - return roleName; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java deleted file mode 100644 index a658b35195ef7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RoleInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RoleInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="Instances" type="{}RoleInstancesInfo"/>
- *       </all>
- *       <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RoleInfo", propOrder = { - -}) -class RoleInfo { - - @XmlElement(name = "Instances", required = true) - protected RoleInstancesInfo instances; - @XmlAttribute(required = true) - protected String name; - - /** - * Gets the value of the instances property. - * - * @return - * possible object is - * {@link RoleInstancesInfo } - * - */ - public RoleInstancesInfo getInstances() { - return instances; - } - - /** - * Sets the value of the instances property. - * - * @param value - * allowed object is - * {@link RoleInstancesInfo } - * - */ - public void setInstances(RoleInstancesInfo value) { - this.instances = value; - } - - /** - * Gets the value of the name property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getName() { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setName(String value) { - this.name = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java deleted file mode 100644 index e43948abd8b3b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.Map; - -/** - * Represents an instance of a role. - */ -public final class RoleInstance { - private final String id; - private final int faultDomain; - private final int updateDomain; - private final Map endpoints; - private Role role; - - /** - * Constructor - * - * @param id - * @param faultDomain - * @param updateDomain - * @param endpoints - */ - RoleInstance(String id, int faultDomain, int updateDomain, Map endpoints) { - this.id = id; - this.faultDomain = faultDomain; - this.updateDomain = updateDomain; - this.endpoints = endpoints; - } - - void setRole(Role role) { - this.role = role; - } - - /** - * Returns an integer value that indicates the fault domain in which this - * instance resides. - * - * @return The fault domain in which this instance resides. - */ - public int getFaultDomain() { - return faultDomain; - } - - /** - * Returns the ID of this instance. - *

- * The returned ID is unique to the application domain of the role's instance. If an instance is terminated and has - * been configured to restart automatically, the restarted instance will have the same ID as the terminated - * instance. - * - * @return A String object that represents the ID of this - * instance. - */ - public String getId() { - return id; - } - - /** - * Returns an integer value that indicates the update domain in which this - * instance resides. - * - * @return The update domain in which this instance resides. - */ - public int getUpdateDomain() { - return updateDomain; - } - - /** - * Returns the {@link Role} object associated with this instance. - * - * @return The Role object associated with this instance - */ - public Role getRole() { - return role; - } - - /** - * Returns the set of endpoints associated with this role instance. - * - * @return A Map object of {@link RoleInstanceEndpoint} objects - * that represent the set of endpoints associated with this - * role instance. - */ - public Map getInstanceEndpoints() { - return endpoints; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java deleted file mode 100644 index 2e13e5fb7b09c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.net.InetSocketAddress; - -/** - * Represents an endpoint associated with a role instance. - */ -public final class RoleInstanceEndpoint { - - /** - * Gets the RoleInstance object associated with this endpoint. - */ - private RoleInstance roleInstance; - - /** - * Gets the protocol associated with the endpoint - */ - private final String protocol; - - /** - * Represents a network endpoint as an IP address and a port number. - */ - private final InetSocketAddress ipEndPoint; - - /** - * Package accessible constructor - * - * @param protocol - * @param ipEndPoint - */ - RoleInstanceEndpoint(String protocol, InetSocketAddress ipEndPoint) { - this.protocol = protocol; - this.ipEndPoint = ipEndPoint; - } - - void setRoleInstance(RoleInstance roleInstance) { - this.roleInstance = roleInstance; - } - - /** - * Returns the {@link RoleInstance} object associated with this endpoint. - * - * @return A RoleInstance object that represents the role - * instance associated with this endpoint. - */ - public RoleInstance getRoleInstance() { - return roleInstance; - } - - /** - * Returns the protocol associated with the endpoint. - * - * @return A String object that represents the protocol - * associated with the endpoint. - */ - public String getProtocol() { - return protocol; - } - - /** - * Returns an InetSocketAddress object for this role instance - * endpoint. The InetSocketAddress object provides the IP - * address and port number for the endpoint. - * - * @return A java.net.InetSocketAddress object that contains - * the IP address and port number for the endpoint. - */ - public InetSocketAddress getIpEndPoint() { - return ipEndPoint; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java deleted file mode 100644 index 16f5d51cdd256..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RoleInstanceInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RoleInstanceInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="Endpoints" type="{}EndpointsInfo"/>
- *       </all>
- *       <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="faultDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="updateDomain" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RoleInstanceInfo", propOrder = { - -}) -class RoleInstanceInfo { - - @XmlElement(name = "Endpoints", required = true) - protected EndpointsInfo endpoints; - @XmlAttribute(required = true) - protected String id; - @XmlAttribute(required = true) - protected int faultDomain; - @XmlAttribute(required = true) - protected int updateDomain; - - /** - * Gets the value of the endpoints property. - * - * @return - * possible object is - * {@link EndpointsInfo } - * - */ - public EndpointsInfo getEndpoints() { - return endpoints; - } - - /** - * Sets the value of the endpoints property. - * - * @param value - * allowed object is - * {@link EndpointsInfo } - * - */ - public void setEndpoints(EndpointsInfo value) { - this.endpoints = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the faultDomain property. - * - */ - public int getFaultDomain() { - return faultDomain; - } - - /** - * Sets the value of the faultDomain property. - * - */ - public void setFaultDomain(int value) { - this.faultDomain = value; - } - - /** - * Gets the value of the updateDomain property. - * - */ - public int getUpdateDomain() { - return updateDomain; - } - - /** - * Sets the value of the updateDomain property. - * - */ - public void setUpdateDomain(int value) { - this.updateDomain = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java deleted file mode 100644 index f1dd9d12e3d92..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * Defines role instance status values, such as Busy and Ready. - *

- * The {@link RoleEnvironment#setStatus} method uses a value from this enumeration. - */ -public enum RoleInstanceStatus { - /** - * The role instance is unavailable for requests. - */ - Busy, - /** - * The role instance is ready to accept requests. - */ - Ready -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java deleted file mode 100644 index 128754996001b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RoleInstancesInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RoleInstancesInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Instance" type="{}RoleInstanceInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RoleInstancesInfo", propOrder = { - "instance" -}) -class RoleInstancesInfo { - - @XmlElement(name = "Instance") - protected List instance; - - /** - * Gets the value of the instance property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the instance property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getInstance().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link RoleInstanceInfo } - * - * - */ - public List getInstance() { - if (instance == null) { - instance = new ArrayList(); - } - return this.instance; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java deleted file mode 100644 index 75c91dd919307..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RolesInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RolesInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="Role" type="{}RoleInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RolesInfo", propOrder = { - "role" -}) -class RolesInfo { - - @XmlElement(name = "Role") - protected List role; - - /** - * Gets the value of the role property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the role property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getRole().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link RoleInfo } - * - * - */ - public List getRole() { - if (role == null) { - role = new ArrayList(); - } - return this.role; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java deleted file mode 100644 index 8e628daccffb1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -interface RuntimeClient extends RuntimeGoalStateClient, RuntimeCurrentStateClient { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java deleted file mode 100644 index 5e08d97c63291..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -interface RuntimeClientFactory { - public String getVersion(); - - public RuntimeClient createRuntimeClient(String path); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java deleted file mode 100644 index 253dbe5432640..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -interface RuntimeCurrentStateClient { - public void setCurrentState(CurrentState state); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java deleted file mode 100644 index 74f1166990e69..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -interface RuntimeGoalStateClient { - public GoalState getCurrentGoalState() throws InterruptedException; - - public RoleEnvironmentData getRoleEnvironmentData() throws InterruptedException; - - public void addGoalStateChangedListener(GoalStateChangedListener listener); - - public void removeGoalStateChangedListener(GoalStateChangedListener listener); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java deleted file mode 100644 index 58bc3927ad723..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/** - * - */ -class RuntimeKernel { - private static RuntimeKernel theKernel; - - private final CurrentStateSerializer currentStateSerializer; - private final GoalStateDeserializer goalStateDeserializer; - private final InputChannel inputChannel; - private final OutputChannel outputChannel; - private final Protocol1RuntimeCurrentStateClient protocol1RuntimeCurrentStateClient; - private final RoleEnvironmentDataDeserializer roleEnvironmentDataDeserializer; - private final Protocol1RuntimeGoalStateClient protocol1RuntimeGoalStateClient; - private final RuntimeVersionProtocolClient runtimeVersionProtocolClient; - private final RuntimeVersionManager runtimeVersionManager; - - private RuntimeKernel() { - this.currentStateSerializer = new XmlCurrentStateSerializer(); - this.goalStateDeserializer = new ChunkedGoalStateDeserializer(); - this.inputChannel = new FileInputChannel(); - this.outputChannel = new FileOutputChannel(); - this.protocol1RuntimeCurrentStateClient = new Protocol1RuntimeCurrentStateClient(currentStateSerializer, - outputChannel); - this.roleEnvironmentDataDeserializer = new XmlRoleEnvironmentDataDeserializer(); - this.protocol1RuntimeGoalStateClient = new Protocol1RuntimeGoalStateClient(protocol1RuntimeCurrentStateClient, - goalStateDeserializer, roleEnvironmentDataDeserializer, inputChannel); - this.runtimeVersionProtocolClient = new RuntimeVersionProtocolClient(inputChannel); - this.runtimeVersionManager = new RuntimeVersionManager(runtimeVersionProtocolClient); - } - - public static RuntimeKernel getKernel() { - if (theKernel == null) { - theKernel = new RuntimeKernel(); - } - - return theKernel; - } - - public CurrentStateSerializer getCurrentStateSerializer() { - return currentStateSerializer; - } - - public GoalStateDeserializer getGoalStateDeserializer() { - return goalStateDeserializer; - } - - public InputChannel getInputChannel() { - return inputChannel; - } - - public OutputChannel getOutputChannel() { - return outputChannel; - } - - public Protocol1RuntimeCurrentStateClient getProtocol1RuntimeCurrentStateClient() { - return protocol1RuntimeCurrentStateClient; - } - - public RoleEnvironmentDataDeserializer getRoleEnvironmentDataDeserializer() { - return roleEnvironmentDataDeserializer; - } - - public Protocol1RuntimeGoalStateClient getProtocol1RuntimeGoalStateClient() { - return protocol1RuntimeGoalStateClient; - } - - public RuntimeVersionProtocolClient getRuntimeVersionProtocolClient() { - return runtimeVersionProtocolClient; - } - - public RuntimeVersionManager getRuntimeVersionManager() { - return runtimeVersionManager; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java deleted file mode 100644 index df4dac6e76ed1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RuntimeServerDiscoveryInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RuntimeServerDiscoveryInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <all>
- *         <element name="RuntimeServerEndpoints" type="{}RuntimeServerEndpointsInfo"/>
- *       </all>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RuntimeServerDiscoveryInfo", propOrder = { - -}) -class RuntimeServerDiscoveryInfo { - - @XmlElement(name = "RuntimeServerEndpoints", required = true) - protected RuntimeServerEndpointsInfo runtimeServerEndpoints; - - /** - * Gets the value of the runtimeServerEndpoints property. - * - * @return - * possible object is - * {@link RuntimeServerEndpointsInfo } - * - */ - public RuntimeServerEndpointsInfo getRuntimeServerEndpoints() { - return runtimeServerEndpoints; - } - - /** - * Sets the value of the runtimeServerEndpoints property. - * - * @param value - * allowed object is - * {@link RuntimeServerEndpointsInfo } - * - */ - public void setRuntimeServerEndpoints(RuntimeServerEndpointsInfo value) { - this.runtimeServerEndpoints = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java deleted file mode 100644 index 071da2b2710d0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RuntimeServerEndpointInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RuntimeServerEndpointInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="path" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RuntimeServerEndpointInfo") -class RuntimeServerEndpointInfo { - - @XmlAttribute(required = true) - protected String version; - @XmlAttribute(required = true) - protected String path; - - /** - * Gets the value of the version property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVersion() { - return version; - } - - /** - * Sets the value of the version property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVersion(String value) { - this.version = value; - } - - /** - * Gets the value of the path property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPath() { - return path; - } - - /** - * Sets the value of the path property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPath(String value) { - this.path = value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java deleted file mode 100644 index 13dfdd6359893..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for RuntimeServerEndpointsInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="RuntimeServerEndpointsInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element name="RuntimeServerEndpoint" type="{}RuntimeServerEndpointInfo" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "RuntimeServerEndpointsInfo", propOrder = { - "runtimeServerEndpoint" -}) -class RuntimeServerEndpointsInfo { - - @XmlElement(name = "RuntimeServerEndpoint") - protected List runtimeServerEndpoint; - - /** - * Gets the value of the runtimeServerEndpoint property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the runtimeServerEndpoint property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getRuntimeServerEndpoint().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link RuntimeServerEndpointInfo } - * - * - */ - public List getRuntimeServerEndpoint() { - if (runtimeServerEndpoint == null) { - runtimeServerEndpoint = new ArrayList(); - } - return this.runtimeServerEndpoint; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java deleted file mode 100644 index 272cc36f59a26..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * - */ -class RuntimeVersionManager { - private final RuntimeVersionProtocolClient protocolClient; - private final List supportedVersionList; - - RuntimeVersionManager(RuntimeVersionProtocolClient protocolClient) { - this.protocolClient = protocolClient; - - this.supportedVersionList = new ArrayList(1); - - this.supportedVersionList.add(new RuntimeClientFactory() { - public String getVersion() { - return "2011-03-08"; - } - - public RuntimeClient createRuntimeClient(String path) { - RuntimeKernel kernel = RuntimeKernel.getKernel(); - - return new Protocol1RuntimeClient(kernel.getProtocol1RuntimeGoalStateClient(), kernel - .getProtocol1RuntimeCurrentStateClient(), path); - } - }); - } - - public RuntimeClient getRuntimeClient(String versionEndpoint) { - Map versionMap = protocolClient.getVersionMap(versionEndpoint); - - for (RuntimeClientFactory factory : supportedVersionList) { - if (versionMap.containsKey(factory.getVersion())) { - return factory.createRuntimeClient(versionMap.get(factory.getVersion())); - } - } - - throw new RuntimeException("Server does not support any known protocol versions."); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java deleted file mode 100644 index 4bea2131f367c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -/** - * - */ -class RuntimeVersionProtocolClient { - private final InputChannel inputChannel; - - public RuntimeVersionProtocolClient(InputChannel inputChannel) { - this.inputChannel = inputChannel; - } - - public Map getVersionMap(String connectionPath) { - try { - Map versions = new HashMap(); - JAXBContext context = JAXBContext.newInstance(RuntimeServerDiscoveryInfo.class.getPackage().getName()); - Unmarshaller unmarshaller = context.createUnmarshaller(); - InputStream input = inputChannel.getInputStream(connectionPath); - - @SuppressWarnings("unchecked") - RuntimeServerDiscoveryInfo discoveryInfo = ((JAXBElement) unmarshaller - .unmarshal(input)).getValue(); - - for (RuntimeServerEndpointInfo endpointInfo : discoveryInfo.getRuntimeServerEndpoints() - .getRuntimeServerEndpoint()) { - versions.put(endpointInfo.getVersion(), endpointInfo.getPath()); - } - - return versions; - } - catch (JAXBException e) { - throw new RuntimeException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java deleted file mode 100644 index 3d4b1e55bc71f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2011.11.14 at 04:34:45 PM PST -// - - -package com.microsoft.windowsazure.serviceruntime; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for StatusLeaseInfo complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType name="StatusLeaseInfo">
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <choice>
- *         <element name="Acquire" type="{}AcquireLeaseInfo"/>
- *         <element name="Release">
- *           <complexType>
- *             <complexContent>
- *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *               </restriction>
- *             </complexContent>
- *           </complexType>
- *         </element>
- *       </choice>
- *       <attribute name="ClientId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "StatusLeaseInfo", propOrder = { - "acquire", - "release" -}) -class StatusLeaseInfo { - - @XmlElement(name = "Acquire") - protected AcquireLeaseInfo acquire; - @XmlElement(name = "Release") - protected StatusLeaseInfo.Release release; - @XmlAttribute(name = "ClientId", required = true) - protected String clientId; - - /** - * Gets the value of the acquire property. - * - * @return - * possible object is - * {@link AcquireLeaseInfo } - * - */ - public AcquireLeaseInfo getAcquire() { - return acquire; - } - - /** - * Sets the value of the acquire property. - * - * @param value - * allowed object is - * {@link AcquireLeaseInfo } - * - */ - public void setAcquire(AcquireLeaseInfo value) { - this.acquire = value; - } - - /** - * Gets the value of the release property. - * - * @return - * possible object is - * {@link StatusLeaseInfo.Release } - * - */ - public StatusLeaseInfo.Release getRelease() { - return release; - } - - /** - * Sets the value of the release property. - * - * @param value - * allowed object is - * {@link StatusLeaseInfo.Release } - * - */ - public void setRelease(StatusLeaseInfo.Release value) { - this.release = value; - } - - /** - * Gets the value of the clientId property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getClientId() { - return clientId; - } - - /** - * Sets the value of the clientId property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setClientId(String value) { - this.clientId = value; - } - - - /** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

-     * <complexType>
-     *   <complexContent>
-     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
-     *     </restriction>
-     *   </complexContent>
-     * </complexType>
-     * 
- * - * - */ - @XmlAccessorType(XmlAccessType.FIELD) - @XmlType(name = "") - public static class Release { - - - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java deleted file mode 100644 index b947685e5c855..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.OutputStream; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; - -/** - * - */ -class XmlCurrentStateSerializer implements CurrentStateSerializer { - public XmlCurrentStateSerializer() { - } - - public void serialize(CurrentState state, OutputStream stream) { - try { - JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class.getPackage().getName()); - Marshaller marshaller = context.createMarshaller(); - - ObjectFactory factory = new ObjectFactory(); - CurrentStateInfo info = factory.createCurrentStateInfo(); - StatusLeaseInfo leaseInfo = factory.createStatusLeaseInfo(); - - leaseInfo.setClientId(state.getClientId()); - - if (state instanceof AcquireCurrentState) { - AcquireCurrentState acquireState = (AcquireCurrentState) state; - AcquireLeaseInfo acquire = factory.createAcquireLeaseInfo(); - - acquire.setExpiration(acquireState.getExpiration()); - acquire.setIncarnation(acquireState.getIncarnation()); - - switch (acquireState.getStatus()) { - case BUSY: - acquire.setStatus(CurrentStatusEnum.BUSY); - break; - case RECYCLE: - acquire.setStatus(CurrentStatusEnum.RECYCLE); - break; - case STARTED: - acquire.setStatus(CurrentStatusEnum.STARTED); - break; - case STOPPED: - acquire.setStatus(CurrentStatusEnum.STOPPED); - break; - } - - leaseInfo.setAcquire(acquire); - } - else if (state instanceof ReleaseCurrentState) { - leaseInfo.setRelease(factory.createStatusLeaseInfoRelease()); - } - - info.setStatusLease(leaseInfo); - - marshaller.marshal(factory.createCurrentState(info), stream); - } - catch (JAXBException e) { - throw new RuntimeException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java deleted file mode 100644 index 8499f43b7dd0b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.StringReader; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -import org.xml.sax.InputSource; - -/** - * - */ -class XmlGoalStateDeserializer { - public XmlGoalStateDeserializer() { - } - - public GoalState deserialize(String document) { - try { - JAXBContext context = JAXBContext.newInstance(GoalStateInfo.class.getPackage().getName()); - Unmarshaller unmarshaller = context.createUnmarshaller(); - InputSource source = new InputSource(new StringReader(document)); - - @SuppressWarnings("unchecked") - GoalStateInfo goalStateInfo = ((JAXBElement) unmarshaller.unmarshal(source)).getValue(); - - return new GoalState(goalStateInfo.incarnation, Enum.valueOf(ExpectedState.class, - goalStateInfo.expectedState.toString()), goalStateInfo.getRoleEnvironmentPath(), - goalStateInfo.getDeadline(), goalStateInfo.getCurrentStateEndpoint()); - - } - catch (JAXBException e) { - throw new RuntimeException(e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java deleted file mode 100644 index 8f27d2a1e3469..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; -import java.net.InetSocketAddress; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; - -/** - * - */ -class XmlRoleEnvironmentDataDeserializer implements RoleEnvironmentDataDeserializer { - public XmlRoleEnvironmentDataDeserializer() { - } - - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - try { - JAXBContext context = JAXBContext.newInstance(RoleEnvironmentInfo.class.getPackage().getName()); - Unmarshaller unmarshaller = context.createUnmarshaller(); - - @SuppressWarnings("unchecked") - RoleEnvironmentInfo environmentInfo = ((JAXBElement) unmarshaller.unmarshal(stream)) - .getValue(); - - Map configurationSettings = translateConfigurationSettings(environmentInfo); - Map localResources = translateLocalResources(environmentInfo); - RoleInstance currentInstance = translateCurrentInstance(environmentInfo); - Map roles = translateRoles(environmentInfo, currentInstance, environmentInfo - .getCurrentInstance().getRoleName()); - - return new RoleEnvironmentData(environmentInfo.getDeployment().getId(), configurationSettings, - localResources, currentInstance, roles, environmentInfo.getDeployment().isEmulated()); - } - catch (JAXBException e) { - throw new RuntimeException(e); - } - } - - private Map translateConfigurationSettings(RoleEnvironmentInfo environmentInfo) { - Map configurationSettings = new HashMap(); - - for (ConfigurationSettingInfo settingInfo : environmentInfo.getCurrentInstance().getConfigurationSettings() - .getConfigurationSetting()) { - configurationSettings.put(settingInfo.getName(), settingInfo.getValue()); - } - - return configurationSettings; - } - - private Map translateLocalResources(RoleEnvironmentInfo environmentInfo) { - Map localResources = new HashMap(); - - for (LocalResourceInfo resourceInfo : environmentInfo.getCurrentInstance().getLocalResources() - .getLocalResource()) { - localResources.put(resourceInfo.getName(), - new LocalResource(resourceInfo.getSizeInMB(), resourceInfo.getName(), resourceInfo.getPath())); - } - - return localResources; - } - - private Map translateRoles(RoleEnvironmentInfo environmentInfo, RoleInstance currentInstance, - String currentRole) { - Map roles = new HashMap(); - - for (RoleInfo roleInfo : environmentInfo.getRoles().getRole()) { - Map instances = translateRoleInstances(roleInfo.getInstances()); - - if (roleInfo.getName().equals(currentRole)) { - instances.put(currentInstance.getId(), currentInstance); - } - - Role role = new Role(roleInfo.getName(), instances); - - for (RoleInstance instance : role.getInstances().values()) { - instance.setRole(role); - } - - roles.put(roleInfo.getName(), role); - } - - if (!roles.containsKey(currentRole)) { - Map instances = new HashMap(); - - instances.put(currentInstance.getId(), currentInstance); - - Role singleRole = new Role(currentRole, instances); - - currentInstance.setRole(singleRole); - - roles.put(currentRole, singleRole); - } - - return roles; - } - - private Map translateRoleInstances(RoleInstancesInfo instancesInfo) { - Map roleInstances = new HashMap(); - - for (RoleInstanceInfo instanceInfo : instancesInfo.getInstance()) { - RoleInstance instance = new RoleInstance(instanceInfo.getId(), instanceInfo.getFaultDomain(), - instanceInfo.getUpdateDomain(), translateRoleInstanceEndpoints(instanceInfo.getEndpoints())); - - for (RoleInstanceEndpoint endpoint : instance.getInstanceEndpoints().values()) { - endpoint.setRoleInstance(instance); - } - - roleInstances.put(instance.getId(), instance); - } - - return roleInstances; - } - - private Map translateRoleInstanceEndpoints(EndpointsInfo endpointsInfo) { - Map endpoints = new HashMap(); - - for (EndpointInfo endpointInfo : endpointsInfo.getEndpoint()) { - RoleInstanceEndpoint endpoint = new RoleInstanceEndpoint(endpointInfo.getProtocol().toString(), - new InetSocketAddress(endpointInfo.getAddress(), endpointInfo.getPort())); - - endpoints.put(endpointInfo.getName(), endpoint); - } - - return endpoints; - } - - private RoleInstance translateCurrentInstance(RoleEnvironmentInfo environmentInfo) { - CurrentRoleInstanceInfo currentInstanceInfo = environmentInfo.getCurrentInstance(); - RoleInstance currentInstance = new RoleInstance(currentInstanceInfo.getId(), - currentInstanceInfo.getFaultDomain(), currentInstanceInfo.getUpdateDomain(), - translateRoleInstanceEndpoints(environmentInfo.getCurrentInstance().getEndpoints())); - - for (RoleInstanceEndpoint endpoint : currentInstance.getInstanceEndpoints().values()) { - endpoint.setRoleInstance(currentInstance); - } - - return currentInstance; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html deleted file mode 100644 index d7ef5eb2b9629..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/overview.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -Classes in this namespace enable you to interact with the Windows Azure environment from code running within your role. - - \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html deleted file mode 100644 index a55c41d6e4bfe..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/package.html +++ /dev/null @@ -1,16 +0,0 @@ - - - -This package contains classes and interfaces that allow your roles to interact with the Windows Azure environment. -For example, the {@link com.microsoft.windowsazure.serviceruntime.RoleEnvironment#requestRecycle} method allows an instance of your role to request to be stopped and then restarted. - - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java deleted file mode 100644 index d561bcb73a87e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -public class BlobConfiguration { - public final static String ACCOUNT_NAME = "blob.accountName"; - public final static String ACCOUNT_KEY = "blob.accountKey"; - public final static String URI = "blob.uri"; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java deleted file mode 100644 index e334771a68819..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -import java.io.InputStream; -import java.util.HashMap; - -import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; -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.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.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; -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.GetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -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; -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.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; -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.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; - -public interface BlobContract extends FilterableService { - GetServicePropertiesResult getServiceProperties() throws ServiceException; - - GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException; - - void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException; - - void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) throws ServiceException; - - ListContainersResult listContainers() throws ServiceException; - - ListContainersResult listContainers(ListContainersOptions options) throws ServiceException; - - void createContainer(String container) throws ServiceException; - - void createContainer(String container, CreateContainerOptions options) throws ServiceException; - - void deleteContainer(String container) throws ServiceException; - - void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException; - - GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException; - - GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) - throws ServiceException; - - GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException; - - GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) - throws ServiceException; - - GetContainerACLResult getContainerACL(String container) throws ServiceException; - - GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException; - - void setContainerACL(String container, ContainerACL acl) throws ServiceException; - - void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException; - - void setContainerMetadata(String container, HashMap metadata) throws ServiceException; - - void setContainerMetadata(String container, HashMap metadata, SetContainerMetadataOptions options) - throws ServiceException; - - ListBlobsResult listBlobs(String container) throws ServiceException; - - ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException; - - void createPageBlob(String container, String blob, int length) throws ServiceException; - - void createPageBlob(String container, String blob, int length, CreateBlobOptions options) throws ServiceException; - - void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException; - - void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) - throws ServiceException; - - CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException; - - CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, CreateBlobPagesOptions options) - throws ServiceException; - - CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream) 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; - - void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, - CreateBlobBlockOptions options) throws ServiceException; - - void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException; - - void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) - throws ServiceException; - - ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException; - - ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) - throws ServiceException; - - GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException; - - GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) - throws ServiceException; - - GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException; - - GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) - throws ServiceException; - - ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException; - - ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) - throws ServiceException; - - SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) - throws ServiceException; - - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) - throws ServiceException; - - SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, - SetBlobMetadataOptions options) throws ServiceException; - - GetBlobResult getBlob(String container, String blob) throws ServiceException; - - GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException; - - void deleteBlob(String container, String blob) throws ServiceException; - - void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException; - - CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException; - - CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) - throws ServiceException; - - void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) - throws ServiceException; - - void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob, - CopyBlobOptions options) throws ServiceException; - - AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException; - - AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) throws ServiceException; - - AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException; - - AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException; - - void releaseLease(String container, String blob, String leaseId) throws ServiceException; - - void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException; - - void breakLease(String container, String blob, String leaseId) throws ServiceException; - - void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException; -} 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/BlobService.java deleted file mode 100644 index 6a35854124a0e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobService.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -import com.microsoft.windowsazure.services.core.Configuration; - -public class BlobService { - private BlobService() { - } - - public static BlobContract create() { - return create(null, Configuration.getInstance()); - } - - public static BlobContract create(Configuration config) { - return create(null, config); - } - - public static BlobContract create(String profile) { - return create(profile, Configuration.getInstance()); - } - - public static BlobContract create(String profile, Configuration config) { - return config.create(profile, BlobContract.class); - } -} 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 deleted file mode 100644 index 197537a9db826..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/Exports.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; -import com.microsoft.windowsazure.services.blob.implementation.BlobRestProxy; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter; -import com.microsoft.windowsazure.services.core.Builder; - -public class Exports implements Builder.Exports { - @Override - public void register(Builder.Registry registry) { - registry.add(BlobContract.class, BlobExceptionProcessor.class); - registry.add(BlobExceptionProcessor.class); - registry.add(BlobRestProxy.class); - registry.add(SharedKeyLiteFilter.class); - registry.add(SharedKeyFilter.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java deleted file mode 100644 index 3354bbc7c2ba4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/AccessPolicyResponse.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.InputStream; -import java.text.ParseException; -import java.util.HashMap; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. A class used to parse SharedAccessPolicies from an input stream. - */ -final class AccessPolicyResponse { - /** - * Holds a flag indicating if the response has been parsed or not. - */ - private boolean isParsed; - - /** - * Holds the Hashmap of policies parsed from the stream - */ - private final HashMap policies = new HashMap(); - - /** - * Holds a reference to the input stream to read from. - */ - private final InputStream streamRef; - - /** - * Initializes the AccessPolicyResponse object - * - * @param stream - * the input stream to read error details from. - */ - public AccessPolicyResponse(final InputStream stream) { - this.streamRef = stream; - } - - /** - * Gets the HashMap of SharedAccessPolicies from the response - * - * @return the HashMap of SharedAccessPolicies from the response - * @throws XMLStreamException - * if an XMLStreamException occurs. - * @throws ParseException - * if a date is incorrectly encoded in the stream - */ - public HashMap getAccessIdentifiers() throws XMLStreamException, ParseException { - if (!this.isParsed) { - this.parseResponse(); - } - - return this.policies; - } - - /** - * Parses the response for the Shared Access Policies - * - * @throws XMLStreamException - * if an XMLStreamException occurs. - * @throws ParseException - * if a date is incorrectly encoded in the stream - */ - public void parseResponse() throws XMLStreamException, ParseException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT - && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { - this.readPolicies(xmlr); - } - else if (eventType == XMLStreamConstants.END_ELEMENT - && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { - break; - } - } - else if (eventType == XMLStreamConstants.END_DOCUMENT) { - break; - } - } - - this.isParsed = true; - } - - /** - * Reads all the policies from the XMLStreamReader - * - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if an XMLStreamException occurs. - * @throws ParseException - * if a date is incorrectly encoded in the stream - */ - private void readPolicies(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { - int eventType = xmlr.getEventType(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT - && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { - this.readSignedIdentifier(xmlr); - } - else if (eventType == XMLStreamConstants.END_ELEMENT - && name.equals(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT)) { - break; - } - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); - } - - /** - * Populates the object from the XMLStreamReader, reader must be at Start element of AccessPolicy. - * - * @param xmlr - * the XMLStreamReader object - * @throws XMLStreamException - * if there is a parsing exception - * @throws ParseException - * if a date value is not correctly encoded - */ - private SharedAccessPolicy readPolicyFromXML(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { - int eventType = xmlr.getEventType(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.ACCESS_POLICY); - final SharedAccessPolicy retPolicy = new SharedAccessPolicy(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.PERMISSION)) { - retPolicy.setPermissions(SharedAccessPolicy.permissionsFromString(Utility.readElementFromXMLReader( - xmlr, BlobConstants.PERMISSION))); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.START)) { - final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START); - retPolicy.setSharedAccessStartTime(Utility.parseISO8061LongDateFromString(tempString)); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.EXPIRY)) { - final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.EXPIRY); - retPolicy.setSharedAccessExpiryTime(Utility.parseISO8061LongDateFromString(tempString)); - } - else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { - break; - } - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.ACCESS_POLICY); - return retPolicy; - } - - /** - * Reads a policy identifier / Shared Access Policy pair from the stream - * - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if an XMLStreamException occurs. - * @throws ParseException - * if a date is incorrectly encoded in the stream - */ - private void readSignedIdentifier(final XMLStreamReader xmlr) throws XMLStreamException, ParseException { - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIER_ELEMENT); - - String id = null; - SharedAccessPolicy policy = null; - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ID)) { - id = Utility.readElementFromXMLReader(xmlr, Constants.ID); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.ACCESS_POLICY)) { - policy = this.readPolicyFromXML(xmlr); - } - else if (eventType == XMLStreamConstants.END_ELEMENT - && name.equals(BlobConstants.SIGNED_IDENTIFIER_ELEMENT)) { - this.policies.put(id, policy); - break; - } - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.SIGNED_IDENTIFIER_ELEMENT); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java deleted file mode 100644 index 2b54ba8578bd7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.URI; -import java.util.HashMap; - -/** - * RESERVED FOR INTERNAL USE. Represents a blob's attributes. - */ -final class BlobAttributes { - - /** - * Holds the metadata for the blob. - */ - private HashMap metadata; - - /** - * Holds the properties of the blob. - */ - private BlobProperties properties; - - /** - * Holds the snapshot ID - */ - public String snapshotID; - - /** - * Holds the URI of the blob, Setting this is RESERVED for internal use. - */ - protected URI uri; - - /** - * Initializes a new instance of the BlobAttributes class - */ - public BlobAttributes(final BlobType type) { - this.setMetadata(new HashMap()); - this.setProperties(new BlobProperties(type)); - } - - public HashMap getMetadata() { - return this.metadata; - } - - public BlobProperties getProperties() { - return this.properties; - } - - protected void setMetadata(final HashMap metadata) { - this.metadata = metadata; - } - - protected void setProperties(final BlobProperties properties) { - this.properties = properties; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java deleted file mode 100644 index 2180e0f452f05..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java +++ /dev/null @@ -1,347 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Holds the Constants used for the Queue Service. - */ -final class BlobConstants { - /** - * Defines constants for use with query strings. - */ - public static class QueryConstants { - /** - * The query component for the SAS signature. - */ - public static final String SIGNATURE = "sig"; - - /** - * The query component for the signed SAS expiry time. - */ - public static final String SIGNED_EXPIRY = "se"; - - /** - * The query component for the signed SAS identifier. - */ - public static final String SIGNED_IDENTIFIER = "si"; - - /** - * The query component for the signed SAS permissions. - */ - public static final String SIGNED_PERMISSIONS = "sp"; - - /** - * The query component for the signed SAS resource. - */ - public static final String SIGNED_RESOURCE = "sr"; - - /** - * The query component for the signed SAS start time. - */ - public static final String SIGNED_START = "st"; - - /** - * The query component for the signed SAS version. - */ - public static final String SIGNED_VERSION = "sv"; - - /** - * The query component for snapshot time. - */ - public static final String SNAPSHOT = "snapshot"; - } - - /** - * XML element for an access policy. - */ - public static final String ACCESS_POLICY = "AccessPolicy"; - - /** - * XML element for authentication error details. - */ - public static final String AUTHENTICATION_ERROR_DETAIL = "AuthenticationErrorDetail"; - - /** - * The header that specifies blob content MD5. - */ - public static final String BLOB_CONTENT_MD5_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-md5"; - - /** - * XML element for a blob. - */ - public static final String BLOB_ELEMENT = "Blob"; - - /** - * XML element for blob prefixes. - */ - public static final String BLOB_PREFIX_ELEMENT = "BlobPrefix"; - - /** - * The header that specifies public access to blobs. - */ - public static final String BLOB_PUBLIC_ACCESS_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-public-access"; - - /** - * XML element for a blob type. - */ - public static final String BLOB_TYPE_ELEMENT = "BlobType"; - /** - * The header for the blob type. - */ - public static final String BLOB_TYPE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-type"; - - /** - * XML element for blobs. - */ - public static final String BLOBS_ELEMENT = "Blobs"; - - /** - * Specifies the block blob type. - */ - public static final String BLOCK_BLOB = "BlockBlob"; - - /** - * Constant signaling a block blob. - */ - public static final String BLOCK_BLOB_VALUE = "BlockBlob"; - - /** - * XML element for blocks. - */ - public static final String BLOCK_ELEMENT = "Block"; - - /** - * XML element for a block list. - */ - public static final String BLOCK_LIST_ELEMENT = "BlockList"; - - /** - * XML element for committed blocks. - */ - public static final String COMMITTED_BLOCKS_ELEMENT = "CommittedBlocks"; - - /** - * XML element for committed blocks. - */ - public static final String COMMITTED_ELEMENT = "Committed"; - - /** - * XML element for a container. - */ - public static final String CONTAINER_ELEMENT = "Container"; - - /** - * XML element for containers. - */ - public static final String CONTAINERS_ELEMENT = "Containers"; - - /** - * The header that specifies blob content encoding. - */ - public static final String CONTENT_ENCODING_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-encoding"; - - /** - * The header that specifies blob content language. - */ - public static final String CONTENT_LANGUAGE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-language"; - - /** - * The header that specifies blob content length. - */ - public static final String CONTENT_LENGTH_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-length"; - - /** - * The header that specifies blob content type. - */ - public static final String CONTENT_TYPE_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-type"; - - /** - * The number of default concurrent requests for parallel operation. - */ - public static final int DEFAULT_CONCURRENT_REQUEST_COUNT = 1; - - /** - * The default delimiter used to create a virtual directory structure of blobs. - */ - public static final String DEFAULT_DELIMITER = "/"; - - /** - * The default write pages size, in bytes, used by blob stream for page blobs. - */ - public static final int DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; - - /** - * The default minimum read size, in bytes, for streams. - */ - public static final int DEFAULT_MINIMUM_READ_SIZE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; - - /** - * The default maximum size, in bytes, of a blob before it must be separated into blocks. - */ - public static final int DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES = 32 * com.microsoft.windowsazure.services.core.storage.Constants.MB; - - /** - * The default write block size, in bytes, used by blob streams. - */ - public static final int DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES = 4 * com.microsoft.windowsazure.services.core.storage.Constants.MB; - - /** - * XML element for the end time of an access policy. - */ - public static final String EXPIRY = "Expiry"; - - /** - * Specifies snapshots are to be included. - */ - public static final String INCLUDE_SNAPSHOTS_VALUE = "include"; - - /** - * XML element for the latest. - */ - public static final String LATEST_ELEMENT = "Latest"; - - /** - * Maximum number of shared access policy identifiers supported by server. - */ - public static final int MAX_SHARED_ACCESS_POLICY_IDENTIFIERS = 5; - - /** - * The maximum size, in bytes, of a blob before it must be separated into blocks. - */ - public static final int MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES = 64 * com.microsoft.windowsazure.services.core.storage.Constants.MB; - - /** - * Specifies the page blob type. - */ - public static final String PAGE_BLOB = "PageBlob"; - - /** - * Constant signaling a page blob. - */ - public static final String PAGE_BLOB_VALUE = "PageBlob"; - - /** - * XML element for page list elements. - */ - public static final String PAGE_LIST_ELEMENT = "PageList"; - - /** - * XML element for a page range. - */ - public static final String PAGE_RANGE_ELEMENT = "PageRange"; - - /** - * The size of a page, in bytes, in a page blob. - */ - public static final int PAGE_SIZE = 512; - - /** - * The header that specifies page write mode. - */ - public static final String PAGE_WRITE = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "page-write"; - - /** - * XML element for the permission of an access policy. - */ - public static final String PERMISSION = "Permission"; - - /** - * XML element for properties. - */ - public static final String PROPERTIES = "Properties"; - - /** - * The header for specifying the sequence number. - */ - public static final String SEQUENCE_NUMBER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-sequence-number"; - - /** - * XML element for a signed identifier. - */ - public static final String SIGNED_IDENTIFIER_ELEMENT = "SignedIdentifier"; - - /** - * XML element for signed identifiers. - */ - public static final String SIGNED_IDENTIFIERS_ELEMENT = "SignedIdentifiers"; - - /** - * The header for the blob content length. - */ - public static final String SIZE = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "blob-content-length"; - - /** - * XML element for the block length. - */ - public static final String SIZE_ELEMENT = "Size"; - - /** - * The Snapshot value. - */ - public static final String SNAPSHOT = "snapshot"; - - /** - * XML element for a snapshot. - */ - public static final String SNAPSHOT_ELEMENT = "Snapshot"; - - /** - * The header for snapshots. - */ - public static final String SNAPSHOT_HEADER = com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "snapshot"; - - /** - * Specifies only snapshots are to be included. - */ - public static final String SNAPSHOTS_ONLY_VALUE = "only"; - - /** - * XML element for the start time of an access policy. - */ - public static final String START = "Start"; - - /** - * XML element for page range start elements. - */ - public static final String START_ELEMENT = "Start"; - - /** - * XML element for uncommitted blocks. - */ - public static final String UNCOMMITTED_BLOCKS_ELEMENT = "UncommittedBlocks"; - - /** - * XML element for uncommitted blocks. - */ - public static final String UNCOMMITTED_ELEMENT = "Uncommitted"; - - /** - * Private Default Ctor - */ - private BlobConstants() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java deleted file mode 100644 index e895bc323f75a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.URI; -import java.util.HashMap; - -/** - * RESERVED FOR INTERNAL USE. Represents a container's attributes, including its properties and metadata. - */ -final class BlobContainerAttributes { - /** - * Holds the Container Metadata - */ - private HashMap metadata; - - /** - * Holds the Container Properties - */ - private BlobContainerProperties properties; - - /** - * Holds the Name of the Container - */ - private String name; - - /** - * Holds the URI of the container - */ - private URI uri; - - /** - * Initializes a new instance of the BlobContainerAttributes class - */ - public BlobContainerAttributes() { - this.setMetadata(new HashMap()); - this.setProperties(new BlobContainerProperties()); - } - - public HashMap getMetadata() { - return this.metadata; - } - - public String getName() { - return this.name; - } - - public BlobContainerProperties getProperties() { - return this.properties; - } - - public URI getUri() { - return this.uri; - } - - public void setMetadata(final HashMap metadata) { - this.metadata = metadata; - } - - public void setName(final String name) { - this.name = name; - } - - public void setProperties(final BlobContainerProperties properties) { - this.properties = properties; - } - - public void setUri(final URI uri) { - this.uri = uri; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java deleted file mode 100644 index c68f845b18e65..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.HashMap; - -/** - * Represents the permissions for a container. - *

- * The container's permissions encompass two types of access settings for the container: - *

    - *
  • The container's public access setting, represented by the {@link #publicAccess} property. The public access - * setting indicates whether the container and its blobs can be read via an anonymous request.
  • - *
  • The container's access policies, represented by the {@link #getSharedAccessPolicies} method. This setting - * references a collection of shared access policies for the container. A shared access policy may be used to control - * the start time, expiry time, and permissions for one or more shared access signatures. A shared access signature - * provides delegated access to the container's resources.
  • - *
- * For more information on managing container permissions, see Managing Access to Containers and Blobs. - */ -public final class BlobContainerPermissions { - - /** - * Represents the public access setting for the container. - *

- * The public access setting indicates whether the container and its blobs can be read via an anonymous request. - *

- * The {@link BlobContainerPublicAccessType} enumeration provides three levels of anonymous read access: - *

    - *
  • {@link BlobContainerPublicAccessType#OFF}, which prevents anonymous access.
  • - *
  • {@link BlobContainerPublicAccessType#BLOB}, which permits anonymous read access to blob resources, but not to - * container metadata or to the list of blobs in the container.
  • - *
  • {@link BlobContainerPublicAccessType#CONTAINER}, which permits anonymous read access to blob resources, - * container metadata, and the list of blobs in the container.
  • - *
- * For more information on managing anonymous access to Blob service resources, see Setting Access Control for Containers. - */ - private BlobContainerPublicAccessType publicAccess; - - /** - * Gets the set of shared access policies for the container. - */ - private HashMap sharedAccessPolicies; - - /** - * Creates an instance of the BlobContainerPermissions class. - */ - public BlobContainerPermissions() { - this.setPublicAccess(BlobContainerPublicAccessType.OFF); - this.sharedAccessPolicies = new HashMap(); - } - - /** - * @return the publicAccess - */ - public BlobContainerPublicAccessType getPublicAccess() { - return this.publicAccess; - } - - /** - * Returns the set of shared access policies for the container. - * - * @return A HashMap object of {@link SharedAccessPolicy} objects that represent the set of shared - * access policies for the container. - */ - public HashMap getSharedAccessPolicies() { - return this.sharedAccessPolicies; - } - - /** - * @param publicAccess - * the publicAccess to set - */ - public void setPublicAccess(final BlobContainerPublicAccessType publicAccess) { - this.publicAccess = publicAccess; - } - - /** - * @param sharedAccessPolicies - * the sharedAccessPolicies to set - */ - public void setSharedAccessPolicies(final HashMap sharedAccessPolicies) { - this.sharedAccessPolicies = sharedAccessPolicies; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java deleted file mode 100644 index 0c4bcb89db9d7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; - -/** - * Represents the system properties for a container. - */ -public final class BlobContainerProperties { - - /** - * Represents the ETag value for the container. - *

- * The ETag value is a unique identifier that is updated when a write operation is performed against the container. - * It may be used to perform operations conditionally, providing concurrency control and improved efficiency. - *

- * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return - * an {@link AccessCondition} object that may be specified on the request. - */ - private String etag; - - /** - * Represents the container's last-modified time. - */ - private Date lastModified; - - /** - * @return the etag - */ - public String getEtag() { - return this.etag; - } - - /** - * @return the lastModified - */ - public Date getLastModified() { - return this.lastModified; - } - - /** - * @param etag - * the etag to set - */ - public void setEtag(final String etag) { - this.etag = etag; - } - - /** - * @param lastModified - * the lastModified to set - */ - public void setLastModified(final Date lastModified) { - this.lastModified = lastModified; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java deleted file mode 100644 index 5bec62642940d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Specifies the level of public access that is allowed on the container. - * - */ -public enum BlobContainerPublicAccessType { - /** - * Specifies blob-level public access. Clients can read the content and metadata of blobs within this container, but - * cannot read container metadata or list the blobs within the container. - */ - BLOB, - - /** - * Specifies container-level public access. Clients can read blob content and metadata and container metadata, and - * can list the blobs within the container. - **/ - CONTAINER, - - /** - * Specifies no public access. Only the account owner can access resources in this container. - */ - OFF -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java deleted file mode 100644 index c04b3123bad66..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java +++ /dev/null @@ -1,608 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.URI; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.LeaseStatus; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.DeserializationHelper; - -/** - * RESERVED FOR INTERNAL USE. Class to provide object deserialization for blobs and containers. - */ -final class BlobDeserializationHelper { - /** - * Reserved for internal use. Populates the blob from an XMLStreamReader, reader must be at Start element of Blob - * - * @param xmlr - * the XMLStreamReader to read from - * @param serviceClient - * the CloudBlobClient associated with the objects. - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - protected static CloudBlob readBlob(final XMLStreamReader xmlr, final CloudBlobClient serviceClient, - final CloudBlobContainer container) throws XMLStreamException, ParseException, URISyntaxException, - StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_ELEMENT); - - String blobName = Constants.EMPTY_STRING; - - String snapshotID = null; - String urlString = null; - HashMap metadata = null; - BlobProperties properties = null; - - int eventType = xmlr.getEventType(); - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(Constants.URL_ELEMENT)) { - urlString = Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT); - } - else if (name.equals(BlobConstants.SNAPSHOT_ELEMENT)) { - snapshotID = Utility.readElementFromXMLReader(xmlr, BlobConstants.SNAPSHOT_ELEMENT); - } - else if (name.equals(Constants.NAME_ELEMENT)) { - blobName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } - else if (name.equals(BlobConstants.PROPERTIES)) { - properties = BlobDeserializationHelper.readBlobProperties(xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - } - else if (name.equals(Constants.METADATA_ELEMENT)) { - metadata = DeserializationHelper.parseMetadateFromXML(xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.BLOB_ELEMENT)) { - break; - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOB_ELEMENT); - - // Assemble and return - if (properties != null) { - CloudBlob retBlob = null; - final int blobNameSectionIndex = urlString.lastIndexOf("/".concat(blobName)); - final URI baseUri = new URI(urlString.substring(0, blobNameSectionIndex + 1)); - String query = null; - if (blobNameSectionIndex + 1 + blobName.length() < urlString.length()) { - // Snapshot blob URI - // example:http://.blob.core.windows.net//?snapshot=2009-12-03T15%3a26%3a19.4466877Z - query = urlString.substring(blobNameSectionIndex + blobName.length() + 1); - } - - final URI blobURI = new URI(baseUri.getScheme(), baseUri.getAuthority(), baseUri.getRawPath().concat( - blobName), query, null); - - if (properties.getBlobType() == BlobType.BLOCK_BLOB) { - retBlob = new CloudBlockBlob(blobURI, serviceClient, container); - } - else if (properties.getBlobType() == BlobType.PAGE_BLOB) { - retBlob = new CloudPageBlob(blobURI, serviceClient, container); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - retBlob.uri = blobURI; - retBlob.snapshotID = snapshotID; - retBlob.properties = properties; - retBlob.metadata = metadata; - return retBlob; - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - - /** - * Reads BlobItems from the XMLStreamReader, reader must be at Start element of BlobsElement - * - * @param xmlr - * the XMLStreamReader to read from - * @param searchMode - * the block search mode - * @return BlockEntry from the stream. - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - public static ArrayList readBlobBlocks(final XMLStreamReader xmlr, final BlockSearchMode searchMode) - throws XMLStreamException, StorageException { - int eventType = xmlr.getEventType(); - final ArrayList retBlocks = new ArrayList(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOCK_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext() && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { - String blockName = null; - long blockSize = -1; - - // Read a block - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(Constants.NAME_ELEMENT)) { - blockName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } - else if (name.equals(BlobConstants.SIZE_ELEMENT)) { - final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.SIZE_ELEMENT); - blockSize = Long.parseLong(sizeString); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT) { - final BlockEntry newBlock = new BlockEntry(blockName, searchMode); - newBlock.setSize(blockSize); - retBlocks.add(newBlock); - break; - } - } - - eventType = xmlr.next(); - } - - return retBlocks; - } - - /** - * Populates the object from the XMLStreamReader - * - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - */ - protected static BlobContainerAttributes readBlobContainerAttributes(final XMLStreamReader xmlr) - throws XMLStreamException, ParseException, URISyntaxException { - int eventType = xmlr.getEventType(); - - final BlobContainerAttributes attributes = new BlobContainerAttributes(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(BlobConstants.PROPERTIES)) { - attributes.setProperties(BlobDeserializationHelper.readBlobContainerProperties(xmlr)); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - } - else if (name.equals(Constants.URL_ELEMENT)) { - attributes.setUri(new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT))); - } - else if (name.equals(Constants.NAME_ELEMENT)) { - attributes.setName(Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT)); - } - else if (name.equals(Constants.METADATA_ELEMENT)) { - // parse metadata - attributes.setMetadata(DeserializationHelper.parseMetadateFromXML(xmlr)); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(BlobConstants.CONTAINER_ELEMENT)) { - break; - } - } - - return attributes; - } - - /** - * Populates the object from the XMLStreamReader, reader must be at Start element of Properties - * - * @param xmlr - * the XMLStreamReader object - * @throws XMLStreamException - * if there is a parsing exception - * @throws ParseException - * if a date value is not correctly encoded - */ - protected static BlobContainerProperties readBlobContainerProperties(final XMLStreamReader xmlr) - throws XMLStreamException, ParseException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PROPERTIES); - int eventType = xmlr.getEventType(); - final BlobContainerProperties properties = new BlobContainerProperties(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { - properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility - .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); - } - else if (name.equals(Constants.ETAG_ELEMENT)) { - properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); - } - } - else { - // expect end of properties - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - break; - } - } - - return properties; - } - - /** - * Reads BlobItems from the XMLStreamReader, reader must be at Start element of BlobsElement - * - * @param xmlr - * the XMLStreamReader to read from - * @param serviceClient - * the CloudBlobClient associated with the objects. - * @param container - * the container associated with the objects. - * @return the BlobItems from the stream - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - public static ArrayList readBlobItems(final XMLStreamReader xmlr, - final CloudBlobClient serviceClient, final CloudBlobContainer container) throws XMLStreamException, - ParseException, URISyntaxException, StorageException { - int eventType = xmlr.getEventType(); - final ArrayList retBlobs = new ArrayList(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(BlobConstants.BLOB_ELEMENT)) { - retBlobs.add(BlobDeserializationHelper.readBlob(xmlr, serviceClient, container)); - } - else if (name.equals(BlobConstants.BLOB_PREFIX_ELEMENT)) { - retBlobs.add(BlobDeserializationHelper.readDirectory(xmlr, serviceClient, container)); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else { - break; - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); - return retBlobs; - } - - /** - * Populates the object from the XMLStreamReader, reader must be at Start element of Properties - * - * @param xmlr - * the XMLStreamReader object - * @return the BlobProperties that was read. - * @throws XMLStreamException - * if there is a parsing exception - * @throws ParseException - * if a date value is not correctly encoded - * @throws StorageException - */ - protected static BlobProperties readBlobProperties(final XMLStreamReader xmlr) throws XMLStreamException, - ParseException, StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PROPERTIES); - int eventType = xmlr.getEventType(); - final BlobProperties properties = new BlobProperties(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(Constants.LAST_MODIFIED_ELEMENT)) { - properties.setLastModified(Utility.parseRFC1123DateFromStringInGMT(Utility - .readElementFromXMLReader(xmlr, Constants.LAST_MODIFIED_ELEMENT))); - } - else if (name.equals(Constants.ETAG_ELEMENT)) { - properties.setEtag(Utility.readElementFromXMLReader(xmlr, Constants.ETAG_ELEMENT)); - } - else if (name.equals(Constants.HeaderConstants.CONTENT_LENGTH)) { - final String tempString = Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CONTENT_LENGTH); - properties.setLength(Long.parseLong(tempString)); - } - else if (name.equals(Constants.HeaderConstants.CONTENT_TYPE)) { - properties.setContentType(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CONTENT_TYPE)); - } - else if (name.equals(Constants.HeaderConstants.CONTENT_ENCODING)) { - properties.setContentEncoding(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CONTENT_ENCODING)); - } - else if (name.equals(Constants.HeaderConstants.CONTENT_LANGUAGE)) { - properties.setContentLanguage(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CONTENT_LANGUAGE)); - } - else if (name.equals(Constants.HeaderConstants.CONTENT_MD5)) { - properties.setContentMD5(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CONTENT_MD5)); - } - else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { - properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CACHE_CONTROL)); - } - else if (name.equals(Constants.HeaderConstants.CACHE_CONTROL)) { - properties.setCacheControl(Utility.readElementFromXMLReader(xmlr, - Constants.HeaderConstants.CACHE_CONTROL)); - } - else if (name.equals(BlobConstants.SEQUENCE_NUMBER)) { - Utility.readElementFromXMLReader(xmlr, BlobConstants.SEQUENCE_NUMBER); - } - else if (name.equals(BlobConstants.BLOB_TYPE_ELEMENT)) { - final String tempString = Utility.readElementFromXMLReader(xmlr, BlobConstants.BLOB_TYPE_ELEMENT); - if (tempString.equals(BlobConstants.BLOCK_BLOB_VALUE)) { - properties.setBlobType(BlobType.BLOCK_BLOB); - } - else if (tempString.equals(BlobConstants.PAGE_BLOB_VALUE)) { - properties.setBlobType(BlobType.PAGE_BLOB); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else if (name.equals(Constants.LEASE_STATUS_ELEMENT)) { - final String tempString = Utility.readElementFromXMLReader(xmlr, Constants.LEASE_STATUS_ELEMENT); - if (tempString.equals(Constants.LOCKED_VALUE.toLowerCase())) { - properties.setLeaseStatus(LeaseStatus.LOCKED); - } - else if (tempString.equals(Constants.UNLOCKED_VALUE.toLowerCase())) { - properties.setLeaseStatus(LeaseStatus.UNLOCKED); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT) { - // expect end of properties - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.PROPERTIES); - break; - } - } - - return properties; - } - - /** - * Populates the container from an XMLStreamReader - * - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - protected static CloudBlobContainer readContainer(final XMLStreamReader xmlr, final CloudBlobClient serviceClient) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.CONTAINER_ELEMENT); - - final BlobContainerAttributes attributes = BlobDeserializationHelper.readBlobContainerAttributes(xmlr); - - final CloudBlobContainer retContainer = new CloudBlobContainer(attributes.getUri(), serviceClient); - retContainer.setMetadata(attributes.getMetadata()); - retContainer.setName(attributes.getName()); - retContainer.setProperties(attributes.getProperties()); - retContainer.setUri(attributes.getUri()); - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINER_ELEMENT); - return retContainer; - } - - /** - * Populates CloudBlobContainer objects from the XMLStreamReader, reader must be at Start element of - * ContainersElement - * - * @param xmlr - * the XMLStreamReader object - * @param serviceClient - * the CloudBlobClient associated with the objects. - * @return an ArrayList of CloudBlobContainer from the stream. - * @throws XMLStreamException - * if there is a parsing exception - * @throws ParseException - * if a date value is not correctly encoded - * @throws URISyntaxException - * @throws StorageException - */ - public static ArrayList readContainers(final XMLStreamReader xmlr, - final CloudBlobClient serviceClient) throws XMLStreamException, ParseException, URISyntaxException, - StorageException { - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); - - final ArrayList containers = new ArrayList(); - - eventType = xmlr.next(); - while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() - && BlobConstants.CONTAINER_ELEMENT.equals(xmlr.getName().toString())) { - containers.add(BlobDeserializationHelper.readContainer(xmlr, serviceClient)); - eventType = xmlr.next(); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); - return containers; - } - - /** - * Populates the CloudBlobDirectory from an XMLStreamReader, reader must be at Start element of BlobPrefix - * - * @param xmlr - * the XMLStreamReader to read from - * @param serviceClient - * the CloudBlobClient associated with the objects. - * @param container - * the container associated with the objects. - * @return a CloudBlobDirectory parsed from the stream. - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - protected static CloudBlobDirectory readDirectory(final XMLStreamReader xmlr, final CloudBlobClient serviceClient, - final CloudBlobContainer container) throws XMLStreamException, ParseException, URISyntaxException, - StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOB_PREFIX_ELEMENT); - - // Move to Name element - xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.NAME_ELEMENT); - - final String prefixName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - - // Move from End name element to end prefix element - xmlr.next(); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOB_PREFIX_ELEMENT); - - return container.getDirectoryReference(prefixName); - } - - /** - * Reads PageRanges from the XMLStreamReader, reader must be at Start element of PageRangeElement - * - * @param xmlr - * the XMLStreamReader to read from - * @return the PageRange from the stream. - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - */ - public static ArrayList readPageRanges(final XMLStreamReader xmlr) throws XMLStreamException, - StorageException { - int eventType = xmlr.getEventType(); - final ArrayList retRanges = new ArrayList(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PAGE_RANGE_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext() && BlobConstants.PAGE_RANGE_ELEMENT.equals(xmlr.getName().toString())) { - long startOffset = -1; - long endOffset = -1; - - // Read a Page Range - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(BlobConstants.START_ELEMENT)) { - final String sizeString = Utility.readElementFromXMLReader(xmlr, BlobConstants.START_ELEMENT); - startOffset = Long.parseLong(sizeString); - } - else if (name.equals(Constants.END_ELEMENT)) { - final String sizeString = Utility.readElementFromXMLReader(xmlr, Constants.END_ELEMENT); - endOffset = Long.parseLong(sizeString); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT) { - if (startOffset == -1 || endOffset == -1) { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - final PageRange pageRef = new PageRange(startOffset, endOffset); - retRanges.add(pageRef); - break; - } - } - - eventType = xmlr.next(); - } - - return retRanges; - } - - /** - * Private Default Ctor - */ - private BlobDeserializationHelper() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java deleted file mode 100644 index 9b75c6d216eb3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ /dev/null @@ -1,635 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCode; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Provides an input stream to read a given blob resource. - */ -public final class BlobInputStream extends InputStream { - /** - * Holds the reference to the blob this stream is associated with. - */ - private final CloudBlob parentBlobRef; - - /** - * Holds the reference to the MD5 digest for the blob. - */ - private MessageDigest md5Digest; - - /** - * A flag to determine if the stream is faulted, if so the lasterror will be thrown on next operation. - */ - private volatile boolean streamFaulted; - - /** - * Holds the last exception this stream encountered. - */ - private IOException lastError; - - /** - * Holds the OperationContext for the current stream. - */ - private final OperationContext opContext; - - /** - * Holds the options for the current stream - */ - private final BlobRequestOptions options; - - /** - * Holds the stream length. - */ - private long streamLength = -1; - - /** - * Holds the stream read size for both block and page blobs. - */ - private final int readSize; - - /** - * A flag indicating if the Blob MD5 should be validated. - */ - private boolean validateBlobMd5; - - /** - * Holds the reference to the current buffered data. - */ - private ByteArrayInputStream currentBuffer; - - /** - * Holds an absolute byte position for the mark feature. - */ - private long markedPosition; - - /** - * Holds the mark delta for which the mark position is expired. - */ - private int markExpiry; - - /** - * Holds the List of PageRanges when reading a page blob and using the sparse page blob feature. - */ - private ArrayList pageBlobRanges; - - /** - * Holds an index to the current page range. - */ - private int currentPageRangeIndex; - - /** - * Holds an absolute byte position of the current read position. - */ - private long currentAbsoluteReadPosition; - - /** - * Holds the absolute byte position of the start of the current buffer. - */ - private long bufferStartOffset; - - /** - * Holds the length of the current buffer in bytes. - */ - private int bufferSize; - - /** - * Holds the {@link AccessCondition} object that represents the access conditions for the blob. - */ - private AccessCondition accessCondition = null; - - /** - * Initializes a new instance of the BlobInputStream class. - * - * @param parentBlob - * the blob that this stream is associated with. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - @DoesServiceRequest - protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition accessCondition, - final BlobRequestOptions options, final OperationContext opContext) throws StorageException { - this.parentBlobRef = parentBlob; - this.parentBlobRef.assertCorrectBlobType(); - this.options = new BlobRequestOptions(options); - this.opContext = opContext; - this.streamFaulted = false; - this.currentAbsoluteReadPosition = 0; - this.readSize = parentBlob.blobServiceClient.getStreamMinimumReadSizeInBytes(); - - if (options.getUseTransactionalContentMD5() && this.readSize > 4 * Constants.MB) { - throw new IllegalArgumentException( - "Cannot specify x-ms-range-get-content-md5 header on ranges larger than 4 MB"); - } - - parentBlob.downloadAttributes(accessCondition, this.options, this.opContext); - - final HttpURLConnection attributesRequest = this.opContext.getCurrentRequestObject(); - - final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - - // Will validate it if it was returned - this.validateBlobMd5 = !options.getDisableContentMD5Validation() - && !Utility.isNullOrEmpty(retrievedContentMD5Value); - - // Validates the first option, and sets future requests to use if match - // request option. - - // If there is an existing conditional validate it, as we intend to - // replace if for future requests. - String previousLeaseId = null; - if (accessCondition != null) { - previousLeaseId = accessCondition.getLeaseID(); - - if (!accessCondition.verifyConditional(this.parentBlobRef.getProperties().getEtag(), this.parentBlobRef - .getProperties().getLastModified())) { - throw new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), - "The conditionals specified for this operation did not match server.", - HttpURLConnection.HTTP_PRECON_FAILED, null, null); - } - } - - this.accessCondition = AccessCondition.generateIfMatchCondition(this.parentBlobRef.getProperties().getEtag()); - this.accessCondition.setLeaseID(previousLeaseId); - - this.streamLength = parentBlob.getProperties().getLength(); - - if (this.validateBlobMd5) { - try { - this.md5Digest = MessageDigest.getInstance("MD5"); - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - if (this.parentBlobRef.getProperties().getBlobType() == BlobType.PAGE_BLOB - && this.options.getUseSparsePageBlob()) { - this.pageBlobRanges = ((CloudPageBlob) parentBlob).downloadPageRanges(this.accessCondition, options, - opContext); - } - else if (this.parentBlobRef.getProperties().getBlobType() == BlobType.BLOCK_BLOB) { - if (this.options.getUseSparsePageBlob()) { - throw new IllegalArgumentException( - "The UseSparsePageBlob option is not applicable of Block Blob streams."); - } - } - this.reposition(0); - } - - /** - * Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without - * blocking by the next invocation of a method for this input stream. The next invocation might be the same thread - * or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. - * - * @throws IOException - * - if an I/O error occurs. - * @return an estimate of the number of bytes that can be read (or skipped over) from this input stream without - * blocking or 0 when it reaches the end of the input stream. - */ - @Override - public synchronized int available() throws IOException { - return this.bufferSize - (int) (this.currentAbsoluteReadPosition - this.bufferStartOffset); - } - - /** - * Helper function to check if the stream is faulted, if it is it surfaces the exception. - * - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - private synchronized void checkStreamState() throws IOException { - if (this.streamFaulted) { - throw this.lastError; - } - } - - /** - * Closes this input stream and releases any system resources associated with the stream. - * - * @throws IOException - * - if an I/O error occurs. - */ - @Override - public synchronized void close() throws IOException { - this.currentBuffer = null; - this.streamFaulted = true; - this.lastError = new IOException("Stream is closed"); - } - - /** - * Dispatches a read operation of N bytes. When using sparspe page blobs the page ranges are evaluated and zero - * bytes may be generated on the client side for some ranges that do not exist. - * - * @param readLength - * the number of bytes to read. - * @throws IOException - * if an I/O error occurs. - */ - @DoesServiceRequest - private synchronized void dispatchRead(final int readLength) throws IOException { - try { - final byte[] byteBuffer = new byte[readLength]; - if (this.options.getUseSparsePageBlob()) { - long resolvedReadStart = this.currentAbsoluteReadPosition; - long resolvedReadEnd = this.currentAbsoluteReadPosition + readLength; - - PageRange startRange = this.getCurrentRange(); - if (startRange != null) { - resolvedReadStart = startRange.getStartOffset(); - resolvedReadEnd = startRange.getEndOffset() + 1; - - // seek start range - while (this.currentAbsoluteReadPosition > startRange.getEndOffset()) { - this.currentPageRangeIndex++; - startRange = this.getCurrentRange(); - - if (startRange != null) { - resolvedReadStart = startRange.getStartOffset(); - resolvedReadEnd = startRange.getEndOffset() + 1; - } - else { - break; - } - } - } - - if (startRange != null) { - // seek end range - int endDex = this.currentPageRangeIndex + 1; - PageRange endRange = endDex < this.pageBlobRanges.size() ? this.pageBlobRanges.get(endDex) : null; - - while (endDex < this.pageBlobRanges.size() - 1 - && this.currentAbsoluteReadPosition + readLength >= endRange.getEndOffset()) { - endDex++; - endRange = this.pageBlobRanges.get(endDex); - resolvedReadEnd = endRange.getEndOffset() + 1; - } - - resolvedReadEnd = Math.min(resolvedReadEnd, this.currentAbsoluteReadPosition + readLength); - - final int bufferOffset = (int) (resolvedReadStart - this.currentAbsoluteReadPosition); - final int opReadLength = (int) Math.min(readLength - bufferOffset, resolvedReadEnd - - resolvedReadStart); - - // Do read - if (opReadLength > 0) { - this.parentBlobRef.downloadRangeInternal(resolvedReadStart, opReadLength, byteBuffer, - bufferOffset, this.accessCondition, this.options, this.opContext); - } - } - - // ELSE=> no op, buffer already contains zeros. - - } - else { - // Non sparse read, do entire read length - this.parentBlobRef.downloadRangeInternal(this.currentAbsoluteReadPosition, readLength, byteBuffer, 0, - this.accessCondition, this.options, this.opContext); - } - - this.currentBuffer = new ByteArrayInputStream(byteBuffer); - this.bufferSize = readLength; - this.bufferStartOffset = this.currentAbsoluteReadPosition; - } - catch (final StorageException e) { - this.streamFaulted = true; - this.lastError = Utility.initIOException(e); - throw this.lastError; - } - } - - /** - * A helper method to get the current Page Range based on the current page range index. - * - * @return the current Page Range based on the current page range index. - */ - private PageRange getCurrentRange() { - if (this.currentPageRangeIndex >= this.pageBlobRanges.size()) { - return null; - } - return this.pageBlobRanges.get(this.currentPageRangeIndex); - } - - /** - * Gets a value indicating if MD5 should be validated. - * - * @return a value indicating if MD5 should be validated. - */ - protected synchronized boolean getValidateBlobMd5() { - return this.validateBlobMd5; - } - - /** - * Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at - * the last marked position so that subsequent reads re-read the same bytes. - * - * @param readlimit - * - the maximum limit of bytes that can be read before the mark position becomes invalid. - */ - @Override - public synchronized void mark(final int readlimit) { - this.markedPosition = this.currentAbsoluteReadPosition; - this.markExpiry = readlimit; - } - - /** - * Tests if this input stream supports the mark and reset methods. Whether or not mark and reset are supported is an - * invariant property of a particular input stream instance. The markSupported method of InputStream returns false. - * - * @return True if this stream instance supports the mark and reset methods; False - * otherwise. - */ - @Override - public boolean markSupported() { - return true; - } - - /** - * Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If - * no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks - * until input data is available, the end of the stream is detected, or an exception is thrown. - * - * @return the next byte of data, or -1 if the end of the stream is reached. - * @throws IOException - * - if an I/O error occurs. - */ - @Override - @DoesServiceRequest - public int read() throws IOException { - final byte[] tBuff = new byte[1]; - this.read(tBuff, 0, 1); - return tBuff[0]; - } - - /** - * Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes - * actually read is returned as an integer. This method blocks until input data is available, end of file is - * detected, or an exception is thrown. If the length of b is zero, then no bytes are read and 0 is returned; - * otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the - * end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b. - * - * The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, - * at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in - * elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected. - * - * The read(b) method for class InputStream has the same effect as: - * - * read(b, 0, b.length) - * - * @param b - * - the buffer into which the data is read. - * @return the total number of bytes read into the buffer, or -1 is there is no more data because the end of the - * stream has been reached. - * - * @throws IOException - * - If the first byte cannot be read for any reason other than the end of the file, if the input stream - * has been closed, or if some other I/O error occurs. - * @throws NullPointerException - * - if b is null. - */ - @Override - @DoesServiceRequest - public int read(final byte[] b) throws IOException { - return this.read(b, 0, b.length); - } - - /** - * Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as - * len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer. This - * method blocks until input data is available, end of file is detected, or an exception is thrown. - * - * If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one - * byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least - * one byte is read and stored into b. - * - * The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes - * read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in - * elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected. - * - * In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected. - * - * The read(b, off, len) method for class InputStream simply calls the method read() repeatedly. If the first such - * call results in an IOException, that exception is returned from the call to the read(b, off, len) method. If any - * subsequent call to read() results in a IOException, the exception is caught and treated as if it were end of - * file; the bytes read up to that point are stored into b and the number of bytes read before the exception - * occurred is returned. The default implementation of this method blocks until the requested amount of input data - * len has been read, end of file is detected, or an exception is thrown. Subclasses are encouraged to provide a - * more efficient implementation of this method. - * - * @param b - * the buffer into which the data is read. - * @param off - * the start offset in array b at which the data is written. - * @param len - * the maximum number of bytes to read. - * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the - * stream has been reached. - * @throws IOException - * If the first byte cannot be read for any reason other than end of file, or if the input stream has - * been closed, or if some other I/O error occurs. - * @throws NullPointerException - * If b is null. - * @throws IndexOutOfBoundsException - * If off is negative, len is negative, or len is greater than b.length - off - */ - @Override - @DoesServiceRequest - public int read(final byte[] b, final int off, final int len) throws IOException { - if (off < 0 || len < 0 || len > b.length - off) { - throw new IndexOutOfBoundsException(); - } - - return this.readInternal(b, off, len); - } - - /** - * Performs internal read to the given byte buffer. - * - * @param b - * the buffer into which the data is read. - * @param off - * the start offset in array b at which the data is written. - * @param len - * the maximum number of bytes to read. - * @return the total number of bytes read into the buffer, or -1 if there is no more data because the end of the - * stream has been reached. - * @throws IOException - * If the first byte cannot be read for any reason other than end of file, or if the input stream has - * been closed, or if some other I/O error occurs. - */ - @DoesServiceRequest - private synchronized int readInternal(final byte[] b, final int off, int len) throws IOException { - this.checkStreamState(); - - // if buffer is empty do next get operation - if ((this.currentBuffer == null || this.currentBuffer.available() == 0) - && this.currentAbsoluteReadPosition < this.streamLength) { - this.dispatchRead((int) Math.min(this.readSize, this.streamLength - this.currentAbsoluteReadPosition)); - } - - len = Math.min(len, this.readSize); - - // do read from buffer - final int numberOfBytesRead = this.currentBuffer.read(b, off, len); - - if (numberOfBytesRead > 0) { - this.currentAbsoluteReadPosition += numberOfBytesRead; - - if (this.validateBlobMd5) { - this.md5Digest.update(b, off, numberOfBytesRead); - - if (this.currentAbsoluteReadPosition == this.streamLength) { - // Reached end of stream, validate md5. - final String calculatedMd5 = Base64.encode(this.md5Digest.digest()); - if (!calculatedMd5.equals(this.parentBlobRef.getProperties().getContentMD5())) { - this.lastError = Utility - .initIOException(new StorageException( - StorageErrorCodeStrings.INVALID_MD5, - String.format( - "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - this.parentBlobRef.getProperties().getContentMD5(), calculatedMd5), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null)); - this.streamFaulted = true; - throw this.lastError; - } - } - } - } - - // update markers - if (this.markExpiry > 0 && this.markedPosition + this.markExpiry < this.currentAbsoluteReadPosition) { - this.markedPosition = 0; - this.markExpiry = 0; - } - - return numberOfBytesRead; - } - - /** - * Repositions the stream to the given absolute byte offset. - * - * @param absolutePosition - * the absolute byte offset to reposition to. - */ - private synchronized void reposition(final long absolutePosition) { - this.currentAbsoluteReadPosition = absolutePosition; - this.currentBuffer = new ByteArrayInputStream(new byte[0]); - } - - /** - * Repositions this stream to the position at the time the mark method was last called on this input stream. Note - * repositioning the blob read stream will disable blob MD5 checking. - * - * @throws IOException - * if this stream has not been marked or if the mark has been invalidated. - */ - @Override - public synchronized void reset() throws IOException { - if (this.markedPosition + this.markExpiry < this.currentAbsoluteReadPosition) { - throw new IOException("Mark expired!"); - } - - this.validateBlobMd5 = false; - this.md5Digest = null; - this.reposition(this.markedPosition); - } - - /** - * Sets a value indicating if MD5 should be validated. - * - * @param validateBlobMd5 - * a value indicating if MD5 should be validated. - */ - protected synchronized void setValidateBlobMd5(final boolean validateBlobMd5) { - this.validateBlobMd5 = validateBlobMd5; - } - - /** - * Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, - * end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of - * conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of - * bytes skipped is returned. If n is negative, no bytes are skipped. - * - * Note repositioning the blob read stream will disable blob MD5 checking. - * - * @param n - * the number of bytes to skip - */ - @Override - public synchronized long skip(final long n) throws IOException { - if (n == 0) { - return 0; - } - - if (n < 0 || this.currentAbsoluteReadPosition + n > this.streamLength) { - throw new IndexOutOfBoundsException(); - } - - this.validateBlobMd5 = false; - this.md5Digest = null; - this.reposition(this.currentAbsoluteReadPosition + n); - return n; - } - - /** - * Writes the entire blob contents from the Windows Azure Blob service to the given output stream. - * - * @param outStream - * the output stream to write to. - * @return the number of bytes written. - * @throws IOException - * if an I/O Error occurs - */ - @DoesServiceRequest - protected long writeTo(final OutputStream outStream) throws IOException { - final byte[] buffer = new byte[Constants.BUFFER_COPY_LENGTH]; - long total = 0; - int count = this.read(buffer); - - while (count != -1) { - outStream.write(buffer, 0, count); - total += count; - count = this.read(buffer); - } - - return total; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java deleted file mode 100644 index 77c61deb98f30..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.EnumSet; - -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; - -/** - * RESERVED FOR INTERNAL USE. Provides the listing context for blobs including the delimiter and listingdetails - */ -final class BlobListingContext extends ListingContext { - - /** - * Gets or sets the delimiter for a blob listing operation. The delimiter parameter enables the caller to traverse - * the blob namespace by using a user-configured delimiter. Using this parameter, it is possible to traverse a - * virtual hierarchy of blobs as though it were a file system. - */ - private String delimiter; - - /** - * Gets or sets the details for the listing operation, which indicates the types of data to include in the response. - * The include parameter specifies that the response should include one or more of the following subsets: snapshots, - * metadata, uncommitted blobs. - */ - private EnumSet listingDetails; - - /** - * Initializes a new instance of the BlobListingContext class - * - * @param prefix - * the prefix to use. - * @param maxResults - * the maximum results to download. - */ - public BlobListingContext(final String prefix, final Integer maxResults) { - super(prefix, maxResults); - } - - /** - * Initializes a new instance of the BlobListingContext class - * - * @param prefix - * the prefix to use. - * @param maxResults - * the maximum results to download. - * @param delimiter - * the delimiter to use - * @param listingDetails - * the BlobListingDetails to use. - */ - public BlobListingContext(final String prefix, final Integer maxResults, final String delimiter, - final EnumSet listingDetails) { - super(prefix, maxResults); - this.setDelimiter(delimiter); - this.setListingDetails(listingDetails); - } - - /** - * @return the delimiter - */ - protected String getDelimiter() { - return this.delimiter; - } - - /** - * @return the listingDetails - */ - protected EnumSet getListingDetails() { - return this.listingDetails; - } - - /** - * @param delimiter - * the delimiter to set - */ - protected void setDelimiter(final String delimiter) { - this.delimiter = delimiter; - } - - /** - * @param listingDetails - * the listingDetails to set - */ - protected void setListingDetails(final EnumSet listingDetails) { - this.listingDetails = listingDetails; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java deleted file mode 100644 index c1e569d0fdebb..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * 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. - *

- */ -public enum BlobListingDetails { - /** - * 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(final int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java deleted file mode 100644 index 50de3fca38c0e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ /dev/null @@ -1,628 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Random; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * The class is an append-only stream for writing into storage. - */ -public final class BlobOutputStream extends OutputStream { - /** - * Holds the random number generator used to create starting blockIDs. - */ - private static Random blockSequenceGenerator = new Random(); - - /** - * Holds the reference to the blob this stream is associated with. - */ - private final CloudBlob parentBlobRef; - - /** - * Determines if this stream is used against a page blob or block blob. - */ - private BlobType streamType = BlobType.UNSPECIFIED; - - /** - * A flag to determine if the stream is faulted, if so the lasterror will be thrown on next operation. - */ - volatile boolean streamFaulted; - - /** - * Holds the lock for synchronized access to the last error. - */ - Object lastErrorLock = new Object(); - - /** - * Holds the last exception this stream encountered. - */ - IOException lastError; - - /** - * Holds the OperationContext for the current stream. - */ - OperationContext opContext; - - /** - * Holds the options for the current stream. - */ - BlobRequestOptions options; - - /** - * Holds the reference to the MD5 digest for the blob. - */ - private MessageDigest md5Digest; - - /** - * Used for block blobs, holds the current BlockID Sequence number. - */ - private long blockIdSequenceNumber = -1; - - /** - * Used for block blobs, holds the block list. - */ - private ArrayList blockList; - - /** - * Used for page blobs, holds the currentOffset the stream is writing to. - */ - private long currentPageOffset; - - /** - * Used for page blobs, when uploading UseSparsePageBlob is true holds the buffer index of the first non zero byte. - */ - private long firstNonZeroBufferedByte = -1; - - /** - * Used for page blobs, when uploading UseSparsePageBlob is true holds the buffer index of the last non zero byte. - */ - private long lastNonZeroBufferedByte = -1; - - /** - * A private buffer to store data prior to committing to the cloud. - */ - private ByteArrayOutputStream outBuffer; - - /** - * Holds the number of currently buffered bytes. - */ - private int currentBufferedBytes; - - /** - * Holds the write threshold of number of bytes to buffer prior to dispatching a write. For block blob this is the - * block size, for page blob this is the Page commit size. - */ - private int internalWriteThreshold = -1; - - /** - * Holds the number of current outstanding requests. - */ - private volatile int outstandingRequests; - - /** - * The ExecutorService used to schedule tasks for this stream. - */ - private final ExecutorService threadExecutor; - - /** - * The CompletionService used to await task completion for this stream. - */ - private final CompletionService completionService; - - /** - * Holds the {@link AccessCondition} object that represents the access conditions for the blob. - */ - AccessCondition accessCondition = null; - - /** - * Initializes a new instance of the BlobWriteStream class. - * - * @param parentBlob - * the blob that this stream is associated with. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - protected BlobOutputStream(final CloudBlob parentBlob, final AccessCondition accessCondition, - final BlobRequestOptions options, final OperationContext opContext) throws StorageException { - this.accessCondition = accessCondition; - this.parentBlobRef = parentBlob; - this.parentBlobRef.assertCorrectBlobType(); - this.options = new BlobRequestOptions(options); - this.outBuffer = new ByteArrayOutputStream(); - this.opContext = opContext; - this.streamFaulted = false; - - if (this.options.getConcurrentRequestCount() < 1) { - throw new IllegalArgumentException("ConcurrentRequestCount"); - } - - if (this.options.getStoreBlobContentMD5()) { - try { - this.md5Digest = MessageDigest.getInstance("MD5"); - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - // V2 cachedThreadPool for perf. - this.threadExecutor = Executors.newFixedThreadPool(this.options.getConcurrentRequestCount()); - this.completionService = new ExecutorCompletionService(this.threadExecutor); - } - - /** - * Initializes a new instance of the BlobWriteStream class for a CloudBlockBlob - * - * @param parentBlob - * the blob that this stream is associated with. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - protected BlobOutputStream(final CloudBlockBlob parentBlob, final AccessCondition accessCondition, - final BlobRequestOptions options, final OperationContext opContext) throws StorageException { - this((CloudBlob) parentBlob, accessCondition, options, opContext); - this.blockIdSequenceNumber = (long) (blockSequenceGenerator.nextInt(Integer.MAX_VALUE)) - + blockSequenceGenerator.nextInt(Integer.MAX_VALUE - 100000); - this.blockList = new ArrayList(); - - this.streamType = BlobType.BLOCK_BLOB; - this.internalWriteThreshold = this.parentBlobRef.blobServiceClient.getWriteBlockSizeInBytes(); - } - - /** - * Initializes a new instance of the BlobWriteStream class for a CloudPageBlob - * - * @param parentBlob - * the blob that this stream is associated with. - * @param length - * the length of the page blob in bytes, must be a multiple of 512. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - @DoesServiceRequest - protected BlobOutputStream(final CloudPageBlob parentBlob, final long length, - final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) - throws StorageException { - this(parentBlob, accessCondition, options, opContext); - this.streamType = BlobType.PAGE_BLOB; - this.internalWriteThreshold = (int) Math.min( - this.parentBlobRef.blobServiceClient.getPageBlobStreamWriteSizeInBytes(), length); - - if (length % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page blob length must be multiple of 512."); - } - - if (this.options.getStoreBlobContentMD5()) { - throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); - } - - parentBlob.create(length, accessCondition, options, opContext); - } - - /** - * Helper function to check if the stream is faulted, if it is it surfaces the exception. - * - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - private void checkStreamState() throws IOException { - synchronized (this.lastErrorLock) { - if (this.streamFaulted) { - throw this.lastError; - } - } - } - - /** - * Closes this output stream and releases any system resources associated with this stream. If any data remains in - * the buffer it is committed to the service. - */ - @Override - @DoesServiceRequest - public void close() throws IOException { - this.flush(); - this.checkStreamState(); - Exception tempException = null; - - synchronized (this.lastErrorLock) { - this.streamFaulted = true; - this.lastError = new IOException("Stream is already closed."); - tempException = this.lastError; - } - - while (this.outstandingRequests > 0) { - this.waitForTaskToComplete(); - } - - this.threadExecutor.shutdown(); - synchronized (this.lastErrorLock) { - // if one of the workers threw an exception, realize it now. - if (tempException != this.lastError) { - throw this.lastError; - } - } - - try { - this.commit(); - } - catch (final StorageException e) { - throw Utility.initIOException(e); - } - } - - /** - * Commits the blob, for block blob this uploads the block list. - * - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @DoesServiceRequest - private void commit() throws StorageException, IOException { - if (this.options.getStoreBlobContentMD5()) { - this.parentBlobRef.getProperties().setContentMD5(Base64.encode(this.md5Digest.digest())); - } - - if (this.streamType == BlobType.BLOCK_BLOB) { - // wait for all blocks to finish - final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; - - blobRef.commitBlockList(this.blockList, this.accessCondition, this.options, this.opContext); - } - else if (this.streamType == BlobType.PAGE_BLOB) { - this.parentBlobRef.uploadProperties(this.accessCondition, this.options, this.opContext); - } - } - - /** - * Dispatches a write operation for a given length. - * - * @param writeLength - * the length of the data to write, this is the write threshold that triggered the write. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @DoesServiceRequest - private synchronized void dispatchWrite(final int writeLength) throws IOException { - if (writeLength == 0) { - return; - } - - Callable worker = null; - - if (this.outstandingRequests > this.options.getConcurrentRequestCount() * 2) { - this.waitForTaskToComplete(); - } - - final ByteArrayInputStream bufferRef = new ByteArrayInputStream(this.outBuffer.toByteArray()); - - if (this.streamType == BlobType.BLOCK_BLOB) { - final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef; - final String blockID = Base64.encode(Utility.getBytesFromLong(this.blockIdSequenceNumber++)); - this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED)); - - worker = new Callable() { - @Override - public Void call() { - try { - blobRef.uploadBlock(blockID, bufferRef, writeLength, BlobOutputStream.this.accessCondition, - BlobOutputStream.this.options, BlobOutputStream.this.opContext); - } - catch (final IOException e) { - synchronized (BlobOutputStream.this.lastErrorLock) { - BlobOutputStream.this.streamFaulted = true; - BlobOutputStream.this.lastError = e; - } - } - catch (final StorageException e) { - synchronized (BlobOutputStream.this.lastErrorLock) { - BlobOutputStream.this.streamFaulted = true; - BlobOutputStream.this.lastError = Utility.initIOException(e); - } - } - return null; - } - }; - } - else if (this.streamType == BlobType.PAGE_BLOB) { - final CloudPageBlob blobRef = (CloudPageBlob) this.parentBlobRef; - long tempOffset = this.currentPageOffset; - long tempLength = writeLength; - - if (this.options.getUseSparsePageBlob()) { - if (this.lastNonZeroBufferedByte == -1) { - // All zero page range, reset buffer and return - this.firstNonZeroBufferedByte = -1; - this.lastNonZeroBufferedByte = -1; - this.currentBufferedBytes = 0; - this.currentPageOffset += writeLength; - this.outBuffer = new ByteArrayOutputStream(); - return; - } - - // Offset is currentOffset - extra data to page align write - final long bufferOffset = this.firstNonZeroBufferedByte - this.firstNonZeroBufferedByte - % BlobConstants.PAGE_SIZE; - - tempOffset = this.currentPageOffset + bufferOffset; - - // Find end of last full page - to do this Calculate the end of - // last full page of non zero - // data and subtract the bufferStarting offset calculated above - tempLength = (this.lastNonZeroBufferedByte - bufferOffset) - + (BlobConstants.PAGE_SIZE - (this.lastNonZeroBufferedByte % BlobConstants.PAGE_SIZE)); - - // Reset buffer markers. - this.firstNonZeroBufferedByte = -1; - this.lastNonZeroBufferedByte = -1; - - // Fast forward buffer past zero data if applicable - if (bufferOffset > 0) { - if (bufferOffset != bufferRef.skip(bufferOffset)) { - // Since this buffer is a byte array buffer this should - // always skip the correct number - // of bytes. - throw Utility.initIOException(Utility.generateNewUnexpectedStorageException(null)); - } - } - } - - final long opWriteLength = tempLength; - final long opOffset = tempOffset; - this.currentPageOffset += writeLength; - - worker = new Callable() { - @Override - public Void call() { - try { - blobRef.uploadPages(bufferRef, opOffset, opWriteLength, BlobOutputStream.this.accessCondition, - BlobOutputStream.this.options, BlobOutputStream.this.opContext); - } - catch (final IOException e) { - synchronized (BlobOutputStream.this.lastErrorLock) { - BlobOutputStream.this.streamFaulted = true; - BlobOutputStream.this.lastError = e; - } - } - catch (final StorageException e) { - synchronized (BlobOutputStream.this.lastErrorLock) { - BlobOutputStream.this.streamFaulted = true; - BlobOutputStream.this.lastError = Utility.initIOException(e); - } - } - return null; - } - }; - } - - // Do work and rest buffer. - this.completionService.submit(worker); - this.outstandingRequests++; - this.currentBufferedBytes = 0; - this.outBuffer = new ByteArrayOutputStream(); - } - - /** - * Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the - * buffer it is committed to the service. - */ - @Override - @DoesServiceRequest - public synchronized void flush() throws IOException { - this.checkStreamState(); - - if (this.streamType == BlobType.PAGE_BLOB && this.currentBufferedBytes > 0 - && (this.currentBufferedBytes % BlobConstants.PAGE_SIZE != 0)) { - throw new IOException(String.format( - "Page data must be a multiple of 512 bytes, buffer currently contains %d bytes.", - this.currentBufferedBytes)); - - // Non 512 byte remainder, uncomment to pad with bytes and commit. - /* - * byte[] nullBuff = new byte[BlobConstants.PageSize - this.currentBufferedBytes % BlobConstants.PageSize]; - * this.write(nullBuff); - */ - } - - this.dispatchWrite(this.currentBufferedBytes); - } - - /** - * Waits for one task to complete - * - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - private void waitForTaskToComplete() throws IOException { - try { - final Future future = this.completionService.take(); - future.get(); - } - catch (final InterruptedException e) { - throw Utility.initIOException(e); - } - catch (final ExecutionException e) { - throw Utility.initIOException(e); - } - - this.outstandingRequests--; - } - - /** - * Writes b.length bytes from the specified byte array to this output stream. - * - * @param data - * the byte array to write. - * - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @Override - @DoesServiceRequest - public void write(final byte[] data) throws IOException { - this.write(data, 0, data.length); - } - - /** - * Writes length bytes from the specified byte array starting at offset to this output stream. - * - * @param data - * the byte array to write. - * @param offset - * the start offset in the data. - * @param length - * the number of bytes to write. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @Override - @DoesServiceRequest - public void write(final byte[] data, final int offset, final int length) throws IOException { - if (offset < 0 || length < 0 || length > data.length - offset) { - throw new IndexOutOfBoundsException(); - } - - this.writeInternal(data, offset, length); - } - - /** - * Writes all data from the InputStream to the Blob. - * - * @param sourceStream - * the InputStram to consume. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - * @throws StorageException - */ - @DoesServiceRequest - public void write(final InputStream sourceStream, final long writeLength) throws IOException, StorageException { - Utility.writeToOutputStream(sourceStream, this, writeLength, false, false, null, this.opContext); - } - - /** - * Writes the specified byte to this output stream. The general contract for write is that one byte is written to - * the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits - * of b are ignored. - * - * @param byteVal - * the byteValue to write. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @Override - public void write(final int byteVal) throws IOException { - this.write(new byte[] { (byte) (byteVal & 0xFF) }); - } - - /** - * Writes the data to the buffer and triggers writes to the service as needed. - * - * @param data - * the byte array to write. - * @param offset - * the start offset in the data. - * @param length - * the number of bytes to write. - * @throws IOException - * if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been - * closed. - */ - @DoesServiceRequest - private synchronized void writeInternal(final byte[] data, int offset, int length) throws IOException { - while (length > 0) { - this.checkStreamState(); - final int availableBufferBytes = this.internalWriteThreshold - this.currentBufferedBytes; - final int nextWrite = Math.min(availableBufferBytes, length); - - // If we need to set MD5 then update the digest accordingly - if (this.options.getStoreBlobContentMD5()) { - this.md5Digest.update(data, offset, nextWrite); - } - - // If Page blob and UseSparsePageBlob is true, then track first and - // last non zero bytes. - if (this.options.getUseSparsePageBlob()) { - for (int m = 0; m < nextWrite; m++) { - if (data[m + offset] != 0) { - if (this.firstNonZeroBufferedByte == -1) { - this.firstNonZeroBufferedByte = this.currentBufferedBytes + m; - } - - this.lastNonZeroBufferedByte = this.currentBufferedBytes + m; - } - } - } - - this.outBuffer.write(data, offset, nextWrite); - this.currentBufferedBytes += nextWrite; - offset += nextWrite; - length -= nextWrite; - - if (this.currentBufferedBytes == this.internalWriteThreshold) { - this.dispatchWrite(this.internalWriteThreshold); - } - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java deleted file mode 100644 index 03ed5236b9741..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ /dev/null @@ -1,284 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.LeaseStatus; - -/** - * Represents the system properties for a blob. - */ -public final class BlobProperties { - - /** - * Represents the type of the blob. - */ - private BlobType blobType = BlobType.UNSPECIFIED; - - /** - * Represents the cache-control value stored for the blob. - */ - private String cacheControl; - - /** - * Represents the content-encoding value stored for the blob. If this field has not been set for the blob, the field - * returns null. - */ - private String contentEncoding; - - /** - * Represents the content-language value stored for the blob. If this field has not been set for the blob, the field - * returns null. - */ - private String contentLanguage; - - /** - * Represents the content MD5 value stored for the blob. - */ - private String contentMD5; - - /** - * Represents the content type value stored for the blob. If this field has not been set for the blob, the field - * returns null. - */ - private String contentType; - - /** - * Represents the blob's ETag value. - *

- * The ETag value is a unique identifier that is updated when a write operation is performed against the container. - * It may be used to perform operations conditionally, providing concurrency control and improved efficiency. - *

- * The {@link AccessCondition#ifMatch} and {@link AccessCondition#ifNoneMatch} methods take an ETag value and return - * an {@link AccessCondition} object that may be specified on the request. - */ - private String etag; - - /** - * Represents the last-modified time for the blob. - */ - private Date lastModified; - - /** - * Represents the blob's lease status. - */ - private LeaseStatus leaseStatus = com.microsoft.windowsazure.services.core.storage.LeaseStatus.UNLOCKED; - - /** - * Represents the size, in bytes, of the blob. - */ - private long length; - - /** - * Creates an instance of the BlobProperties class. - */ - public BlobProperties() { - // No op - } - - /** - * Creates an instance of the BlobProperties class by copying values from another instance of the - * BlobProperties class. - * - * @param other - * A BlobProperties object that represents the blob properties to copy. - */ - public BlobProperties(final BlobProperties other) { - this.blobType = other.blobType; - this.contentEncoding = other.contentEncoding; - this.contentLanguage = other.contentLanguage; - this.contentType = other.contentType; - this.etag = other.etag; - this.leaseStatus = other.leaseStatus; - this.length = other.length; - this.lastModified = other.lastModified; - this.contentMD5 = other.contentMD5; - this.cacheControl = other.cacheControl; - } - - /** - * Creates an instance of the BlobProperties class. - */ - public BlobProperties(final BlobType type) { - this.blobType = type; - } - - /** - * Returns the blob type for the blob. - * - * @return A {@link BlobType} value that represents the blob type. - */ - public BlobType getBlobType() { - return this.blobType; - } - - /** - * @return the cacheControl - */ - public String getCacheControl() { - return this.cacheControl; - } - - /** - * @return the contentEncoding - */ - public String getContentEncoding() { - return this.contentEncoding; - } - - /** - * @return the contentLanguage - */ - public String getContentLanguage() { - return this.contentLanguage; - } - - /** - * @return the contentMD5 - */ - public String getContentMD5() { - return this.contentMD5; - } - - /** - * @return the contentType - */ - public String getContentType() { - return this.contentType; - } - - /** - * @return the etag - */ - public String getEtag() { - return this.etag; - } - - /** - * @return the lastModified - */ - public Date getLastModified() { - return this.lastModified; - } - - /** - * Reserved for internal use. - * - * @return the leaseStatus - */ - public LeaseStatus getLeaseStatus() { - return this.leaseStatus; - } - - /** - * @return the length - */ - public long getLength() { - return this.length; - } - - /** - * Reserved for internal use. - * - * @param blobType - * the blobType to set - */ - protected void setBlobType(final BlobType blobType) { - this.blobType = blobType; - } - - /** - * @param cacheControl - * the cacheControl to set - */ - public void setCacheControl(final String cacheControl) { - this.cacheControl = cacheControl; - } - - /** - * @param contentEncoding - * the contentEncoding to set - */ - public void setContentEncoding(final String contentEncoding) { - this.contentEncoding = contentEncoding; - } - - /** - * @param contentLanguage - * the contentLanguage to set - */ - public void setContentLanguage(final String contentLanguage) { - this.contentLanguage = contentLanguage; - } - - /** - * @param contentMD5 - * the contentMD5 to set - */ - public void setContentMD5(final String contentMD5) { - this.contentMD5 = contentMD5; - } - - /** - * @param contentType - * the contentType to set - */ - public void setContentType(final String contentType) { - this.contentType = contentType; - } - - /** - * Reserved for internal use. - * - * @param etag - * the etag to set - */ - public void setEtag(final String etag) { - this.etag = etag; - } - - /** - * Reserved for internal use. - * - * @param lastModified - * the lastModified to set - */ - public void setLastModified(final Date lastModified) { - this.lastModified = lastModified; - } - - /** - * Reserved for internal use. - * - * @param leaseStatus - * the leaseStatus to set - */ - public void setLeaseStatus(final LeaseStatus leaseStatus) { - this.leaseStatus = leaseStatus; - } - - /** - * Reserved for internal use. - * - * @param length - * the length to set - */ - public void setLength(final long length) { - this.length = length; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java deleted file mode 100644 index b958fe925f7b3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java +++ /dev/null @@ -1,970 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.LeaseAction; - -/** - * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing requests for blob operations. - */ -final class BlobRequest { - /** - * Adds the metadata. - * - * @param request - * The request. - * @param metadata - * The metadata. - */ - public static void addMetadata(final HttpURLConnection request, final HashMap metadata, - final OperationContext opContext) { - BaseRequest.addMetadata(request, metadata, opContext); - } - - /** - * Adds the metadata. - * - * @param request - * The request. - * @param name - * The metadata name. - * @param value - * The metadata value. - */ - public static void addMetadata(final HttpURLConnection request, final String name, final String value, - final OperationContext opContext) { - BaseRequest.addMetadata(request, name, value, opContext); - } - - /** - * Creates a request to copy a blob, Sign with 0 length. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @param source - * The canonical path to the source blob, in the form ///. - * @param sourceSnapshotID - * The snapshot version, if the source blob is a snapshot. - * @param sourceAccessConditionType - * A type of condition to check on the source blob. - * @param sourceAccessConditionValue - * The value of the condition to check on the source blob - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - * @throws IOException - * @throws URISyntaxException - */ - public static HttpURLConnection copyFrom(final URI uri, final int timeout, String source, - final String sourceSnapshotID, final AccessCondition sourceAccessCondition, - final AccessCondition destinationAccessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws StorageException, IOException, URISyntaxException { - - if (sourceSnapshotID != null) { - source = source.concat("?snapshot="); - source = source.concat(sourceSnapshotID); - } - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, null, opContext); - - request.setFixedLengthStreamingMode(0); - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - request.setRequestProperty(Constants.HeaderConstants.COPY_SOURCE_HEADER, source); - - if (sourceAccessCondition != null) { - sourceAccessCondition.applyConditionToRequest(request, true); - } - - if (destinationAccessCondition != null) { - destinationAccessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Creates the web request. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @param query - * The query builder to use. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - private static HttpURLConnection createURLConnection(final URI uri, final int timeout, final UriQueryBuilder query, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - return BaseRequest.createURLConnection(uri, timeout, query, opContext); - } - - /** - * Constructs a HttpURLConnection to delete the blob, Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param deleteSnapshotsOption - * A set of options indicating whether to delete only blobs, only snapshots, or both. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection delete(final URI uri, final int timeout, final String snapshotVersion, - final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - - if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) { - throw new IllegalArgumentException(String.format( - "The option '%s' must be 'None' to delete a specific snapshot specified by '%s'", - "deleteSnapshotsOption", "snapshot")); - } - - final UriQueryBuilder builder = new UriQueryBuilder(); - BaseRequest.addSnapshot(builder, snapshotVersion); - final HttpURLConnection request = BaseRequest.delete(uri, timeout, builder, opContext); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - switch (deleteSnapshotsOption) { - case NONE: - // nop - break; - case INCLUDE_SNAPSHOTS: - request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER, - BlobConstants.INCLUDE_SNAPSHOTS_VALUE); - break; - case DELETE_SNAPSHOTS_ONLY: - request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER, - BlobConstants.SNAPSHOTS_ONLY_VALUE); - break; - default: - break; - } - - return request; - } - - /** - * Constructs a HttpURLConnection to download the blob, Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param offset - * The offset at which to begin returning content. - * @param count - * The number of bytes to return. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection get(final URI uri, final int timeout, final String snapshotVersion, - final long offset, final long count, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - final HttpURLConnection request = get(uri, timeout, snapshotVersion, accessCondition, blobOptions, opContext); - - final String rangeHeaderValue = String.format(Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, - offset, offset + count - 1); - - request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, rangeHeaderValue); - - return request; - } - - /** - * Constructs a HttpURLConnection to download the blob, Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection get(final URI uri, final int timeout, final String snapshotVersion, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - BaseRequest.addSnapshot(builder, snapshotVersion); - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - request.setRequestMethod("GET"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to return a list of the block blobs blocks. Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param blockFilter - * The types of blocks to include in the list: committed, uncommitted, or both. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection getBlockList(final URI uri, final int timeout, final String snapshotVersion, - final BlockListingFilter blockFilter, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws StorageException, - IOException, URISyntaxException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - - builder.add("comp", "blocklist"); - builder.add("blocklisttype", blockFilter.toString()); - BaseRequest.addSnapshot(builder, snapshotVersion); - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - request.setRequestMethod("GET"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to return a list of the PageBlob's page ranges. Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection getPageRanges(final URI uri, final int timeout, final String snapshotVersion, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws StorageException, IOException, URISyntaxException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "pagelist"); - BaseRequest.addSnapshot(builder, snapshotVersion); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - request.setRequestMethod("GET"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - BaseRequest.addOptionalHeader(request, BlobConstants.SNAPSHOT, snapshotVersion); - return request; - } - - /** - * Constructs a HttpURLConnection to return the blob's system properties, Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param snapshotVersion - * The snapshot version, if the blob is a snapshot. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection getProperties(final URI uri, final int timeout, final String snapshotVersion, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws StorageException, IOException, URISyntaxException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - BaseRequest.addSnapshot(builder, snapshotVersion); - final HttpURLConnection request = BaseRequest.getProperties(uri, timeout, builder, opContext); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a blob lease. Sign with 0 length. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param action - * the LeaseAction to perform - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection lease(final URI uri, final int timeout, final LeaseAction action, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "lease"); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setDoOutput(true); - request.setRequestMethod("PUT"); - request.setFixedLengthStreamingMode(0); - request.setRequestProperty("x-ms-lease-action", action.toString()); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - return request; - } - - /** - * Constructs a HttpURLConnection to list blobs. Sign with no length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param listingContext - * A set of parameters for the listing operation. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection configured for the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - * */ - public static HttpURLConnection list(final URI uri, final int timeout, final BlobListingContext listingContext, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws URISyntaxException, - IOException, StorageException { - - final UriQueryBuilder builder = ContainerRequest.getContainerUriQueryBuilder(); - builder.add("comp", "list"); - - if (listingContext != null) { - if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { - builder.add("prefix", listingContext.getPrefix()); - } - - if (!Utility.isNullOrEmpty(listingContext.getDelimiter())) { - builder.add("delimiter", listingContext.getDelimiter()); - } - - if (!Utility.isNullOrEmpty(listingContext.getMarker())) { - builder.add("marker", listingContext.getMarker()); - } - - if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { - builder.add("maxresults", listingContext.getMaxResults().toString()); - } - - if (listingContext.getListingDetails().size() > 0) { - final StringBuilder sb = new StringBuilder(); - - boolean started = false; - - if (listingContext.getListingDetails().contains(BlobListingDetails.SNAPSHOTS)) { - if (!started) { - started = true; - } - else { - sb.append(","); - } - - sb.append("snapshots"); - } - - if (listingContext.getListingDetails().contains(BlobListingDetails.UNCOMMITTED_BLOBS)) { - if (!started) { - started = true; - } - else { - sb.append(","); - } - - sb.append("uncommittedblobs"); - } - - if (listingContext.getListingDetails().contains(BlobListingDetails.METADATA)) { - if (!started) { - started = true; - } - else { - sb.append(","); - } - - sb.append("metadata"); - } - - builder.add("include", sb.toString()); - } - } - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Constructs a HttpURLConnection to upload a blob. Sign with blob length, or -1 for pageblob create. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param properties - * The properties to set for the blob. - * @param blobType - * The type of the blob. - * @param pageBlobSize - * For a page blob, the size of the blob. This parameter is ignored for block blobs. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection put(final URI uri, final int timeout, final BlobProperties properties, - final BlobType blobType, final long pageBlobSize, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - if (blobType == BlobType.UNSPECIFIED) { - throw new IllegalArgumentException("The blob type cannot be undefined."); - } - - final HttpURLConnection request = BlobRequest.createURLConnection(uri, timeout, null, blobOptions, opContext); - - request.setDoOutput(true); - - request.setRequestMethod("PUT"); - - // use set optional header - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL, properties.getCacheControl()); - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_TYPE, properties.getContentType()); - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_MD5, properties.getContentMD5()); - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_LANGUAGE, - properties.getContentLanguage()); - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CONTENT_ENCODING, - properties.getContentEncoding()); - - if (blobType == BlobType.PAGE_BLOB) { - request.setFixedLengthStreamingMode(0); - request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0"); - - request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.PAGE_BLOB); - request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize)); - - properties.setLength(pageBlobSize); - } - else { - request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB); - } - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to upload a block. Sign with length of block data. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param blockId - * the Base64 ID for the block - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection putBlock(final URI uri, final int timeout, final String blockId, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "block"); - builder.add("blockid", blockId); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection putBlockList(final URI uri, final int timeout, final BlobProperties properties, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "blocklist"); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL_HEADER, - properties.getCacheControl()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); - BaseRequest.addOptionalHeader(request, BlobConstants.BLOB_CONTENT_MD5_HEADER, properties.getContentMD5()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_TYPE_HEADER, properties.getContentType()); - - return request; - } - - /** - * Constructs a HttpURLConnection to upload a block. Sign with page length for update, or 0 for clear. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param properties - * the page properties - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection putPage(final URI uri, final int timeout, final PageProperties properties, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "page"); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - if (properties.getPageOperation() == PageOperationType.CLEAR) { - request.setFixedLengthStreamingMode(0); - } - - // Page write is either update or clean; required - request.setRequestProperty(BlobConstants.PAGE_WRITE, properties.getPageOperation().toString()); - request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, properties.getRange().toString()); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to set the blob's metadata, Sign with 0 length. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection setMetadata(final URI uri, final int timeout, - final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - final HttpURLConnection request = BaseRequest.setMetadata(uri, timeout, null, opContext); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param newBlobSize - * The new blob size, if the blob is a page blob. Set this parameter to null to keep the existing blob - * size. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection setProperties(final URI uri, final int timeout, final BlobProperties properties, - final Long newBlobSize, final AccessCondition accessCondition, final BlobRequestOptions blobOptions, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "properties"); - - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setFixedLengthStreamingMode(0); - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - if (newBlobSize != null) { - request.setRequestProperty(BlobConstants.SIZE, newBlobSize.toString()); - properties.setLength(newBlobSize); - } - - BaseRequest.addOptionalHeader(request, Constants.HeaderConstants.CACHE_CONTROL_HEADER, - properties.getCacheControl()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_ENCODING_HEADER, properties.getContentEncoding()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_LANGUAGE_HEADER, properties.getContentLanguage()); - BaseRequest.addOptionalHeader(request, BlobConstants.BLOB_CONTENT_MD5_HEADER, properties.getContentMD5()); - BaseRequest.addOptionalHeader(request, BlobConstants.CONTENT_TYPE_HEADER, properties.getContentType()); - - return request; - } - - /** - * Constructs a HttpURLConnection to create a snapshot of the blob. Sign with 0 length. - * - * @param uri - * The absolute URI to the blob - * @param timeout - * The server timeout interval - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param blobOptions - * the options to use for the request. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection to use to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if the resource URI is invalid - * @throws StorageException - * an exception representing any error which occurred during the operation. - * @throws IllegalArgumentException - */ - public static HttpURLConnection snapshot(final URI uri, final int timeout, final AccessCondition accessCondition, - final BlobRequestOptions blobOptions, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add(Constants.HeaderConstants.COMP, BlobConstants.SNAPSHOT); - final HttpURLConnection request = BlobRequest - .createURLConnection(uri, timeout, builder, blobOptions, opContext); - - request.setFixedLengthStreamingMode(0); - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - if (accessCondition != null) { - accessCondition.applyConditionToRequest(request); - } - - return request; - } - - /** - * Writes a Block List and returns the corresponding UTF8 bytes. - * - * @param blockList - * the Iterable of BlockEntry to write - * @param opContext - * a tracking object for the request - * @return a byte array of the UTF8 bytes representing the serialized block list. - * @throws XMLStreamException - * if there is an error writing the block list. - * @throws StorageException - */ - public static byte[] writeBlockListToStream(final Iterable blockList, final OperationContext opContext) - throws XMLStreamException, StorageException { - - final StringWriter outWriter = new StringWriter(); - final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); - final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); - - // default is UTF8 - xmlw.writeStartDocument(); - xmlw.writeStartElement(BlobConstants.BLOCK_LIST_ELEMENT); - - for (final BlockEntry block : blockList) { - if (block.searchMode == BlockSearchMode.COMMITTED) { - xmlw.writeStartElement(BlobConstants.COMMITTED_ELEMENT); - } - else if (block.searchMode == BlockSearchMode.UNCOMMITTED) { - xmlw.writeStartElement(BlobConstants.UNCOMMITTED_ELEMENT); - } - else if (block.searchMode == BlockSearchMode.LATEST) { - xmlw.writeStartElement(BlobConstants.LATEST_ELEMENT); - } - - xmlw.writeCharacters(block.getId()); - xmlw.writeEndElement(); - } - - // end BlockListElement - xmlw.writeEndElement(); - - // end doc - xmlw.writeEndDocument(); - try { - return outWriter.toString().getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * Private Default Ctor - */ - private BlobRequest() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java deleted file mode 100644 index d1d46a0536c4d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import com.microsoft.windowsazure.services.core.storage.RequestOptions; - -/** - * Represents a set of options that may be specified on a request. - */ -public final class BlobRequestOptions extends RequestOptions { - - /** - * Represents the concurrent number of simultaneous requests per operation. If it's null, it will be set to the - * value specified by the cloud blob client's {@link CloudBlobClient#getConcurrentRequestCount} method during upload - * operations. - */ - private Integer concurrentRequestCount = null; - - /** - * Specifies whether a range PUT or GET operation will use the Content-MD5 header to enforce transactional security. - * All partial blob uploads or downloads will be restricted to 4 MB. The default value is false. - */ - private Boolean useTransactionalContentMD5 = false; - - /** - * Specifies whether the blob's ContentMD5 header should be set on uploads. This field is not supported for page - * blobs. The default value is false. - */ - private Boolean storeBlobContentMD5 = false; - - /** - * Specifies whether download and {@link BlobInputStream} methods should ignore the blob's ContentMD5 header. The - * default value is false. - */ - private Boolean disableContentMD5Validation = false; - - /** - * Specifies whether to use sparse page blobs. - * - * When true, "zero" pages are not explicitly uploaded for a page blob; additionally, GET page ranges - * are used only to download explicit information for the page blob. The default value is false. - */ - private Boolean useSparsePageBlob = false; - - /** - * Creates an instance of the BlobRequestOptions class. - */ - public BlobRequestOptions() { - // Empty Default Ctor - } - - /** - * Creates an instance of the BlobRequestOptions class by copying values from another - * BlobRequestOptions instance. - * - * @param other - * A BlobRequestOptions object that represents the blob request options to copy. - */ - public BlobRequestOptions(final BlobRequestOptions other) { - super(other); - this.setConcurrentRequestCount(other.getConcurrentRequestCount()); - this.setStoreBlobContentMD5(other.getStoreBlobContentMD5()); - this.setUseTransactionalContentMD5(other.getUseTransactionalContentMD5()); - this.setUseSparsePageBlob(other.getUseSparsePageBlob()); - this.disableContentMD5Validation = other.disableContentMD5Validation; - } - - /** - * Uses the default timeout interval and retry policy from the specified client if the timeout interval and retry - * policy are null, and also sets the concurrent request count (whether or not it has already been - * assigned a value). - * - * @param client - * A {@link CloudBlobClient} object that represents the service client used to set the default timeout - * interval and retry policy, if they are null. Additionally, if the - * {@link #concurrentRequestCount} field's value is null, it will be set to the value specified by the - * cloud blob client's {@link CloudBlobClient#getConcurrentRequestCount} method. - */ - protected void applyDefaults(final CloudBlobClient client) { - super.applyBaseDefaults(client); - - if (this.getConcurrentRequestCount() == null) { - this.setConcurrentRequestCount(client.getConcurrentRequestCount()); - } - } - - /** - * @return the concurrentRequestCount - */ - public Integer getConcurrentRequestCount() { - return this.concurrentRequestCount; - } - - /** - * @return the disableContentMD5Validation - */ - protected boolean getDisableContentMD5Validation() { - return this.disableContentMD5Validation; - } - - /** - * @return the storeBlobContentMD5 - */ - public boolean getStoreBlobContentMD5() { - return this.storeBlobContentMD5; - } - - /** - * @return the useSparsePageBlob - */ - public boolean getUseSparsePageBlob() { - return this.useSparsePageBlob; - } - - /** - * @return the useTransactionalContentMD5 - */ - public boolean getUseTransactionalContentMD5() { - return this.useTransactionalContentMD5; - } - - /** - * @param concurrentRequestCount - * the concurrentRequestCount to set - */ - public void setConcurrentRequestCount(final Integer concurrentRequestCount) { - this.concurrentRequestCount = concurrentRequestCount; - } - - /** - * @param disableContentMD5Validation - * the disableContentMD5Validation to set - */ - public void setDisableContentMD5Validation(final boolean disableContentMD5Validation) { - this.disableContentMD5Validation = disableContentMD5Validation; - } - - /** - * @param storeBlobContentMD5 - * the storeBlobContentMD5 to set - */ - public void setStoreBlobContentMD5(final boolean storeBlobContentMD5) { - this.storeBlobContentMD5 = storeBlobContentMD5; - } - - /** - * @param useSparsePageBlob - * the useSparsePageBlob to set - */ - public void setUseSparsePageBlob(final boolean useSparsePageBlob) { - this.useSparsePageBlob = useSparsePageBlob; - } - - /** - * @param useTransactionalContentMD5 - * the useTransactionalContentMD5 to set - */ - public void setUseTransactionalContentMD5(final boolean useTransactionalContentMD5) { - this.useTransactionalContentMD5 = useTransactionalContentMD5; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java deleted file mode 100644 index 2f08d6ee5f1f0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.HttpURLConnection; -import java.net.URI; -import java.util.Calendar; -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; - -/** - * RESERVED FOR INTERNAL USE. A class for parsing various responses from the blob service - */ -final class BlobResponse extends BaseResponse { - - /** - * Gets the BlobAttributes from the given request - * - * @param request - * The response from server. - * @param resourceURI - * The blob uri to set. - * @param snapshotID - * The snapshot version, if the blob is a snapshot. - * @param opContext - * a tracking object for the request - * @return the BlobAttributes from the given request - */ - public static BlobAttributes getAttributes(final HttpURLConnection request, final URI resourceURI, - final String snapshotID, final OperationContext opContext) { - - final String blobType = request.getHeaderField(BlobConstants.BLOB_TYPE_HEADER); - final BlobAttributes attributes = new BlobAttributes(BlobType.parse(blobType)); - final BlobProperties properties = attributes.getProperties(); - - properties.setCacheControl(request.getHeaderField(Constants.HeaderConstants.CACHE_CONTROL)); - properties.setContentEncoding(request.getHeaderField(Constants.HeaderConstants.CONTENT_ENCODING)); - properties.setContentLanguage(request.getHeaderField(Constants.HeaderConstants.CONTENT_LANGUAGE)); - properties.setContentMD5(request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5)); - properties.setContentType(request.getHeaderField(Constants.HeaderConstants.CONTENT_TYPE)); - properties.setEtag(request.getHeaderField(Constants.HeaderConstants.ETAG)); - - final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); - lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); - lastModifiedCalendar.setTime(new Date(request.getLastModified())); - properties.setLastModified(lastModifiedCalendar.getTime()); - - final String leaseStatus = request.getHeaderField(Constants.HeaderConstants.LEASE_STATUS); - if (!Utility.isNullOrEmpty(leaseStatus)) { - properties.setLeaseStatus(com.microsoft.windowsazure.services.core.storage.LeaseStatus.parse(leaseStatus)); - } - - final String rangeHeader = request.getHeaderField(Constants.HeaderConstants.CONTENT_RANGE); - final String xContentLengthHeader = request.getHeaderField(BlobConstants.CONTENT_LENGTH_HEADER); - - if (!Utility.isNullOrEmpty(rangeHeader)) { - properties.setLength(Long.parseLong(rangeHeader)); - } - else if (!Utility.isNullOrEmpty(xContentLengthHeader)) { - properties.setLength(Long.parseLong(xContentLengthHeader)); - } - else { - // using this instead of the request property since the request - // property only returns an int. - final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - - if (!Utility.isNullOrEmpty(contentLength)) { - properties.setLength(Long.parseLong(contentLength)); - } - } - - attributes.uri = resourceURI; - attributes.snapshotID = snapshotID; - - attributes.setMetadata(getMetadata(request)); - return attributes; - } - - /** - * Gets the lease id from the request header. - * - * @param request - * The response from server. - * @param opContext - * a tracking object for the request - * @return the lease id from the request header. - */ - public static String getLeaseID(final HttpURLConnection request, final OperationContext opContext) { - return request.getHeaderField("x-ms-lease-id"); - } - - /** - * Gets the lease Time from the request header. - * - * @param request - * The response from server. - * @param opContext - * a tracking object for the request - * @return the lease Time from the request header. - */ - public static String getLeaseTime(final HttpURLConnection request, final OperationContext opContext) { - return request.getHeaderField("x-ms-lease-time"); - } - - /** - * Gets the snapshot ID from the request header. - * - * @param request - * The response from server. - * @param opContext - * a tracking object for the request - * @return the snapshot ID from the request header. - */ - public static String getSnapshotTime(final HttpURLConnection request, final OperationContext opContext) { - return request.getHeaderField("x-ms-snapshot"); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java deleted file mode 100644 index 4ef9b4278e972..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.Locale; - -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Specifies the type of a blob. - */ -public enum BlobType { - /** - * Specifies the blob type is not specified. - */ - UNSPECIFIED, - - /** - * Specifies the blob is a block blob. - */ - BLOCK_BLOB, - - /** - * Specifies the blob is a page blob. - */ - PAGE_BLOB; - - /** - * Returns the enum value representing the blob type for the specified string. - * - * @param typeString - * A String that represents a blob type, such as "blockblob" or "pageblob". - * - * @return A BlobType value corresponding to the string specified by typeString. - */ - public static BlobType parse(final String typeString) { - if (Utility.isNullOrEmpty(typeString)) { - return UNSPECIFIED; - } - else if ("blockblob".equals(typeString.toLowerCase(Locale.US))) { - return BLOCK_BLOB; - } - else if ("pageblob".equals(typeString.toLowerCase(Locale.US))) { - return PAGE_BLOB; - } - else { - return UNSPECIFIED; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java deleted file mode 100644 index aa736238f1e67..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * A class which is used to list and commit blocks of a {@link CloudBlockBlob}. - */ -public final class BlockEntry { - /** - * Represents the name of the block. - */ - private String id; - - /** - * Represents the size, in bytes, of the block. - */ - private long size; - - /** - * Represents the block search mode. The default value is {@link BlockSearchMode#LATEST}. - */ - public BlockSearchMode searchMode = BlockSearchMode.LATEST; - - /** - * Creates an instance of the BlockEntry class. - * - * @param id - * A String that represents the name of the block. - * @param searchMode - * A {@link BlockSearchMode} value that represents the block search mode. - */ - public BlockEntry(final String id, final BlockSearchMode searchMode) { - this.setId(id); - this.searchMode = searchMode; - } - - /** - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * @return the size - */ - public long getSize() { - return this.size; - } - - /** - * @param id - * the id to set - */ - public void setId(final String id) { - this.id = id; - } - - /** - * @param size - * the size to set - */ - public void setSize(final long size) { - this.size = size; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java deleted file mode 100644 index f792bb272e081..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Specifies whether to list only committed blocks, only uncommitted blocks, or all blocks. - */ -public enum BlockListingFilter { - /** - * List only committed blocks. - */ - COMMITTED, - - /** - * List only uncommitted blocks. - */ - UNCOMMITTED, - - /** - * List both committed and uncommitted blocks. - */ - ALL -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java deleted file mode 100644 index 709f620c33817..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Specifies which block lists should be searched to find a specified block. - */ -public enum BlockSearchMode { - /** - * Specifies searching only the committed block list. - */ - COMMITTED, - - /** - * Specifies searching only the uncommitted block list. - */ - UNCOMMITTED, - - /** - * Specifies searching the uncommitted block list first, and if the block is not found, then search the committed - * block list. - */ - LATEST -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java deleted file mode 100644 index b669f76f223f9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ /dev/null @@ -1,2342 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.LeaseStatus; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; -import com.microsoft.windowsazure.services.core.storage.RetryPolicy; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.LeaseAction; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * - * Represents a Windows Azure blob. This is the base class for the {@link CloudBlockBlob} and {@link CloudPageBlob} - * classes. - */ -public abstract class CloudBlob implements ListBlobItem { - /** - * Holds the metadata for the blob. - */ - HashMap metadata; - - /** - * Holds the properties of the blob. - */ - BlobProperties properties; - - /** - * Holds the URI of the blob, Setting this is RESERVED for internal use. - */ - URI uri; - - /** - * Holds the snapshot ID. - */ - String snapshotID; - - /** - * Holds the Blobs container Reference. - */ - private CloudBlobContainer container; - - /** - * Represents the blob's directory. - */ - protected CloudBlobDirectory parent; - - /** - * Holds the Blobs Name. - */ - private String name; - - /** - * Represents the blob client. - */ - protected CloudBlobClient blobServiceClient; - - /** - * Creates an instance of the CloudBlob class. - * - * @param type - * the type of the blob. - */ - protected CloudBlob(final BlobType type) { - this.metadata = new HashMap(); - this.properties = new BlobProperties(type); - } - - /** - * Creates an instance of the CloudBlob class using the specified URI and cloud blob client. - * - * @param type - * the type of the blob. - * @param uri - * A java.net.URI object that represents the URI to the blob, beginning with the container - * name. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - */ - protected CloudBlob(final BlobType type, final URI uri, final CloudBlobClient client) throws StorageException { - this(type); - - Utility.assertNotNull("blobAbsoluteUri", uri); - Utility.assertNotNull("serviceClient", client); - - this.blobServiceClient = client; - this.uri = uri; - - this.parseURIQueryStringAndVerify(uri, client, client.isUsePathStyleUris()); - } - - /** - * Creates an instance of the CloudBlob class using the specified URI, cloud blob client, and cloud - * blob container. - * - * @param type - * the type of the blob. - * @param uri - * A java.net.URI object that represents the absolute URI to the blob, beginning with the - * container name. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * @param container - * A {@link CloudBlobContainer} object that represents the container to use for the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - protected CloudBlob(final BlobType type, final URI uri, final CloudBlobClient client, - final CloudBlobContainer container) throws StorageException { - this(type, uri, client); - this.container = container; - } - - /** - * Creates an instance of the CloudBlob class using the specified URI, snapshot ID, and cloud blob - * client. - * - * @param type - * the type of the blob. - * @param uri - * A java.net.URI object that represents the absolute URI to the blob, beginning with the - * container name. - * @param snapshotID - * A String that represents the snapshot version, if applicable. - * @param client - * A {@link CloudBlobContainer} object that represents the container to use for the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - protected CloudBlob(final BlobType type, final URI uri, final String snapshotID, final CloudBlobClient client) - throws StorageException { - this(type, uri, client); - if (snapshotID != null) { - if (this.snapshotID != null) { - throw new IllegalArgumentException( - "Snapshot query parameter is already defined in the blobUri. Either pass in a snapshotTime parameter or use a full URL with a snapshot query parameter."); - } - else { - this.snapshotID = snapshotID; - } - } - } - - /** - * Creates an instance of the CloudBlob class by copying values from another blob. - * - * @param otherBlob - * A CloudBlob object that represents the blob to copy. - */ - protected CloudBlob(final CloudBlob otherBlob) { - this.metadata = new HashMap(); - this.properties = new BlobProperties(otherBlob.properties); - - if (otherBlob.metadata != null) { - this.metadata = new HashMap(); - for (final String key : otherBlob.metadata.keySet()) { - this.metadata.put(key, otherBlob.metadata.get(key)); - } - } - - this.snapshotID = otherBlob.snapshotID; - this.uri = otherBlob.uri; - this.container = otherBlob.container; - this.parent = otherBlob.parent; - this.blobServiceClient = otherBlob.blobServiceClient; - this.name = otherBlob.name; - } - - /** - * Acquires a new lease on the blob. - * - * @return A String that represents the lease ID. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final String acquireLease() throws StorageException { - return this.acquireLease(null, null, null); - } - - /** - * Acquires a new lease on the blob using the specified request options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the lease ID. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final String acquireLease(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public String execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.ACQUIRE, accessCondition, - blobOptions, opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - blob.properties.setLeaseStatus(LeaseStatus.LOCKED); - - return BlobResponse.getLeaseID(request, opContext); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Asserts that the blob has the correct blob type specified in the blob attributes. - * - * @throws StorageException - * If an incorrect blob type is used. - */ - protected final void assertCorrectBlobType() throws StorageException { - if (this instanceof CloudBlockBlob && this.properties.getBlobType() != BlobType.BLOCK_BLOB) { - throw new StorageException( - StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format( - "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - BlobType.BLOCK_BLOB, this.properties.getBlobType()), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - if (this instanceof CloudPageBlob && this.properties.getBlobType() != BlobType.PAGE_BLOB) { - throw new StorageException( - StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format( - "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - BlobType.PAGE_BLOB, this.properties.getBlobType()), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - - } - } - - /** - * Breaks the lease but ensures that another client cannot acquire a new lease until the current lease period has - * expired. - * - * @return The time, in seconds, remaining in the lease period. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final long breakLease() throws StorageException { - return this.breakLease(null, null, null); - } - - /** - * Breaks the lease, using the specified request options and operation context, but ensures that another client - * cannot acquire a new lease until the current lease period has expired. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return The time, in seconds, remaining in the lease period. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final long breakLease(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Long execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, accessCondition, blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return -1L; - } - - blob.updatePropertiesFromResponse(request); - final String leaseTime = BlobResponse.getLeaseTime(request, opContext); - - blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); - return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Copies an existing blob's contents, properties, and metadata to this instance of the CloudBlob - * class. - * - * @param sourceBlob - * A CloudBlob object that represents the source blob to copy. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void copyFromBlob(final CloudBlob sourceBlob) throws StorageException { - this.copyFromBlob(sourceBlob, null, null, null, null); - } - - /** - * Copies an existing blob's contents, properties, and metadata to this instance of the CloudBlob - * class, using the specified access conditions, lease ID, request options, and operation context. - * - * @param sourceBlob - * A CloudBlob object that represents the source blob to copy. - * @param sourceAccessCondition - * An {@link AccessCondition} object that represents the access conditions for the source blob. - * @param destinationAccessCondition - * An {@link AccessCondition} object that represents the access conditions for the destination blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - * - */ - @DoesServiceRequest - public final void copyFromBlob(final CloudBlob sourceBlob, final AccessCondition sourceAccessCondition, - final AccessCondition destinationAccessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.copyFrom(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), sourceBlob.getCanonicalName(false), blob.snapshotID, - sourceAccessCondition, destinationAccessCondition, blobOptions, opContext); - - BlobRequest.addMetadata(request, sourceBlob.metadata, opContext); - client.getCredentials().signRequest(request, 0); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Creates a snapshot of the blob. - * - * @return A CloudBlob object that represents the snapshot of the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final CloudBlob createSnapshot() throws StorageException { - return this.createSnapshot(null, null, null); - } - - /** - * Creates a snapshot of the blob using the specified request options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A CloudBlob object that represents the snapshot of the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final CloudBlob createSnapshot(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public CloudBlob execute(final CloudBlobClient client, final CloudBlob blob, - final OperationContext opContext) throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.snapshot(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - CloudBlob snapshot = null; - final String snapshotTime = BlobResponse.getSnapshotTime(request, opContext); - if (blob instanceof CloudBlockBlob) { - snapshot = new CloudBlockBlob(blob.getUri(), snapshotTime, client); - } - else if (blob instanceof CloudPageBlob) { - snapshot = new CloudPageBlob(blob.getUri(), snapshotTime, client); - } - - blob.updatePropertiesFromResponse(request); - return snapshot; - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Deletes the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void delete() throws StorageException { - this.delete(DeleteSnapshotsOption.NONE, null, null, null); - } - - /** - * Deletes the blob using the specified snapshot and request options, and operation context. - *

- * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use - * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value - * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob - * is deleted. - * - * @param deleteSnapshotsOption - * A {@link DeleteSnapshotsOption} object that indicates whether to delete only blobs, only snapshots, or - * both. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void delete(final DeleteSnapshotsOption deleteSnapshotsOption, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException { - Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, - accessCondition, blobOptions, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Deletes the blob if it exists. - *

- * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use - * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value - * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob - * is deleted. - * - * @return true if the blob was deleted; otherwise, false. - * - * @throws StorageException - * If a storage service error occurred. - * - */ - @DoesServiceRequest - public final boolean deleteIfExists() throws StorageException { - return this.deleteIfExists(DeleteSnapshotsOption.NONE, null, null, null); - } - - /** - * Deletes the blob if it exists, using the specified snapshot and request options, and operation context. - *

- * A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use - * the {@link DeleteSnapshotsOption#DELETE_SNAPSHOTS_ONLY} or {@link DeleteSnapshotsOption#INCLUDE_SNAPSHOTS} value - * in the deleteSnapshotsOption parameter to specify how the snapshots should be handled when the blob - * is deleted. - * - * @param deleteSnapshotsOption - * A {@link DeleteSnapshotsOption} object that indicates whether to delete only blobs, only snapshots, or - * both. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the blob was deleted; otherwise, false - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final boolean deleteIfExists(final DeleteSnapshotsOption deleteSnapshotsOption, - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { - Utility.assertNotNull("deleteSnapshotsOption", deleteSnapshotsOption); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.delete(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, deleteSnapshotsOption, - accessCondition, blobOptions, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - blob.updatePropertiesFromResponse(request); - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } - else { - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Downloads the contents of a blob to a stream. - * - * @param outStream - * An OutputStream object that represents the target stream. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void download(final OutputStream outStream) throws StorageException, IOException { - this.download(outStream, null, null, null); - } - - /** - * Downloads the contents of a blob to a stream using the specified request options and operation context. - * - * @param outStream - * An OutputStream object that represents the target stream. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void download(final OutputStream outStream, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); - - client.getCredentials().signRequest(request, -1L); - final InputStream streamRef = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); - - final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - final Boolean validateMD5 = !blobOptions.getDisableContentMD5Validation() - && !Utility.isNullOrEmpty(contentMD5); - - final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - final long expectedLength = Long.parseLong(contentLength); - - blob.updatePropertiesFromResponse(request); - ExecutionEngine.getResponseCode(this.getResult(), request, opContext); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, - validateMD5, this.getResult(), opContext); - - if (descriptor.getLength() != expectedLength) { - throw new StorageException( - StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect number of bytes was read from the connection. The connection may have been closed", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - if (validateMD5 && !contentMD5.equals(descriptor.getMd5())) { - throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( - "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - contentMD5, descriptor.getMd5()), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - return null; - } - }; - - try { - // Executed with no retries so that the first failure will move out - // to the read Stream. - ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, RetryNoRetry.getInstance(), opContext); - opContext.setIntermediateMD5(null); - } - catch (final StorageException ex) { - // Check if users has any retries specified, Or if the exception is retryable - final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext); - if (ex.getHttpStatusCode() == Constants.HeaderConstants.HTTP_UNUSED_306 - || ex.getHttpStatusCode() == HttpURLConnection.HTTP_PRECON_FAILED - || !dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), - (Exception) ex.getCause(), opContext).isShouldRetry()) { - opContext.setIntermediateMD5(null); - throw ex; - } - - // Continuation, fail gracefully into a read stream. This needs to - // be outside the operation above as it would get retried resulting - // in a nested retry - - // Copy access condition, and update etag. This will potentially replace the if match value, but not on the - // users object. - - AccessCondition etagLockCondition = new AccessCondition(); - etagLockCondition.setIfMatch(this.getProperties().getEtag()); - if (accessCondition != null) { - etagLockCondition.setLeaseID(accessCondition.getLeaseID()); - } - - // 1. Open Read Stream - final BlobInputStream streamRef = this.openInputStream(etagLockCondition, options, opContext); - - // Cache value indicating if we need - final boolean validateMd5 = streamRef.getValidateBlobMd5(); - - streamRef.setValidateBlobMd5(false); - streamRef.mark(Integer.MAX_VALUE); - - try { - // 2. Seek to current position, this will disable read streams - // internal content md5 checks. - if (opContext.getCurrentOperationByteCount() > 0) { - // SCA will say this if a failure as we do not validate the - // return of skip. - // The Blob class repositioning a virtual pointer and will - // always skip the correct - // number of bytes. - streamRef.skip(opContext.getCurrentOperationByteCount()); - } - - // 3. Continue copying - final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false, - validateMd5, null, opContext); - - if (validateMd5 && !this.properties.getContentMD5().equals(descriptor.getMd5())) { - throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( - "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - this.properties.getContentMD5(), descriptor.getMd5()), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - catch (final IOException secondEx) { - opContext.setIntermediateMD5(null); - if (secondEx.getCause() != null && secondEx.getCause() instanceof StorageException) { - throw (StorageException) secondEx.getCause(); - } - else { - throw secondEx; - } - } - } - } - - /** - * Populates a blob's properties and metadata. - *

- * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties - * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and - * metadata from the Windows Azure storage service. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void downloadAttributes() throws StorageException { - this.downloadAttributes(null, null, null); - } - - /** - * Populates a blob's properties and metadata using the specified request options and operation context. - *

- * This method populates the blob's system properties and user-defined metadata. Before reading a blob's properties - * or metadata, call this method or its overload to retrieve the latest values for the blob's properties and - * metadata from the Windows Azure storage service. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void downloadAttributes(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - // Set attributes - final BlobAttributes retrievedAttributes = BlobResponse.getAttributes(request, blob.getUri(), - blob.snapshotID, opContext); - - if (retrievedAttributes.getProperties().getBlobType() != blob.properties.getBlobType()) { - throw new StorageException( - StorageErrorCodeStrings.INCORRECT_BLOB_TYPE, - String.format( - "Incorrect Blob type, please use the correct Blob type to access a blob on the server. Expected %s, actual %s", - blob.properties.getBlobType(), retrievedAttributes.getProperties().getBlobType()), - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - blob.properties = retrievedAttributes.getProperties(); - blob.metadata = retrievedAttributes.getMetadata(); - - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Downloads a range of bytes from the blob to the given byte buffer. - * - * @param offset - * The byte offset to use as the starting point for the source. - * @param length - * The number of bytes to read. - * @param buffer - * The byte buffer, as an array of bytes, to which the blob bytes are downloaded. - * @param bufferOffet - * The byte offset to use as the starting point for the target. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void downloadRange(final long offset, final int length, final byte[] buffer, final int bufferOffet) - throws StorageException { - this.downloadRangeInternal(offset, length, buffer, bufferOffet, null, null, null); - } - - /** - * Downloads a range of bytes from the blob to the given byte buffer, using the specified request options and - * operation context. - * - * @param offset - * The byte offset to use as the starting point for the source. - * @param length - * The number of bytes to read. - * @param buffer - * The byte buffer, as an array of bytes, to which the blob bytes are downloaded. - * @param bufferOffet - * The byte offset to use as the starting point for the target. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void downloadRange(final long offset, final int length, final byte[] buffer, final int bufferOffet, - final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) - throws StorageException { - if (offset < 0 || length <= 0) { - throw new IndexOutOfBoundsException(); - } - - Utility.assertNotNull("buffer", buffer); - - if (length + bufferOffet > buffer.length) { - throw new IndexOutOfBoundsException(); - } - - opContext.initialize(); - this.downloadRangeInternal(offset, length, buffer, bufferOffet, accessCondition, options, opContext); - } - - /** - * Downloads a range of bytes from the blob to the given byte buffer. - * - * @param blobOffset - * the offset of the blob to begin downloading at - * @param length - * the number of bytes to read - * @param buffer - * the byte buffer to write to. - * @param bufferOffet - * the offset in the byte buffer to begin writing. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - @DoesServiceRequest - protected final void downloadRangeInternal(final long blobOffset, final int length, final byte[] buffer, - final int bufferOffset, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (blobOffset < 0 || length <= 0) { - throw new IndexOutOfBoundsException(); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - if (options.getUseTransactionalContentMD5() && length > 4 * Constants.MB) { - throw new IllegalArgumentException( - "Cannot specify x-ms-range-get-content-md5 header on ranges larger than 4 MB. Either use a BlobReadStream via openRead, or disable TransactionalMD5 checking via the BlobRequestOptions."); - } - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.get(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blobOffset, length, accessCondition, - blobOptions, opContext); - - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, "true"); - } - - client.getCredentials().signRequest(request, -1L); - - final InputStream sourceStream = ExecutionEngine.getInputStream(request, opContext); - this.setResult(opContext.getLastResult()); - - int totalRead = 0; - int nextRead = buffer.length - bufferOffset; - int count = sourceStream.read(buffer, bufferOffset, nextRead); - - while (count > 0) { - totalRead += count; - nextRead = buffer.length - (bufferOffset + totalRead); - - if (nextRead == 0) { - // check for case where more data is returned - if (sourceStream.read(new byte[1], 0, 1) != -1) { - throw new StorageException( - StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect number of bytes was read from the connection. The connection may have been closed", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - count = sourceStream.read(buffer, bufferOffset + totalRead, nextRead); - } - - ExecutionEngine.getResponseCode(this.getResult(), request, opContext); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_PARTIAL) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - final long expectedLength = Long.parseLong(contentLength); - if (totalRead != expectedLength) { - throw new StorageException( - StorageErrorCodeStrings.OUT_OF_RANGE_INPUT, - "An incorrect number of bytes was read from the connection. The connection may have been closed", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - - if (blobOptions.getUseTransactionalContentMD5()) { - final String contentMD5 = request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - - try { - final MessageDigest digest = MessageDigest.getInstance("MD5"); - digest.update(buffer, bufferOffset, length); - final String calculatedMD5 = Base64.encode(digest.digest()); - if (!contentMD5.equals(calculatedMD5)) { - throw new StorageException(StorageErrorCodeStrings.INVALID_MD5, String.format( - "Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s", - contentMD5, calculatedMD5), Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Checks to see if the blob exists. - * - * @return true if the blob exists, other wise false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final boolean exists() throws StorageException { - return this.exists(null, null, null); - } - - /** - * Checks to see if the blob exists, using the specified request options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the blob exists, other wise false. - * - * @throws StorageException - * f a storage service error occurred. - */ - @DoesServiceRequest - public final boolean exists(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.getProperties(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - blob.updatePropertiesFromResponse(request); - return Boolean.valueOf(true); - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } - else { - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Returns a shared access signature for the blob using the specified shared access policy. Note this does not - * contain the leading "?". - * - * @param policy - * A SharedAccessPolicy object that represents the access policy for the shared access - * signature. - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are unable to sign the request or if the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public final String generateSharedAccessSignature(final SharedAccessPolicy policy) throws InvalidKeyException, - StorageException { - return this.generateSharedAccessSignature(policy, null); - } - - /** - * Returns a shared access signature for the blob using the specified shared access policy and operation context. - * Note this does not contain the leading "?". - * - * @param policy - * A SharedAccessPolicy object that represents the access policy for the shared access - * signature. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are unable to sign the request or if the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public final String generateSharedAccessSignature(final SharedAccessPolicy policy, OperationContext opContext) - throws InvalidKeyException, StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - return this.generateSharedAccessSignatureCore(policy, null, opContext); - } - - /** - * Returns a shared access signature for the blob using the specified group policy identifier. Note this does not - * contain the leading "?". - * - * @param groupPolicyIdentifier - * A String that represents the container-level access policy. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are unable to sign the request or if the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public final String generateSharedAccessSignature(final String groupPolicyIdentifier) throws InvalidKeyException, - StorageException { - return this.generateSharedAccessSignature(groupPolicyIdentifier, null); - } - - /** - * Returns a shared access signature for the blob using the specified group policy identifier and operation context. - * Note this does not contain the leading "?". - * - * @param groupPolicyIdentifier - * A String that represents the container-level access policy. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are unable to sign the request or if the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public final String generateSharedAccessSignature(final String groupPolicyIdentifier, OperationContext opContext) - throws InvalidKeyException, StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - return this.generateSharedAccessSignatureCore(null, groupPolicyIdentifier, opContext); - } - - /** - * Returns a shared access signature for the blob using the specified group policy identifier and operation context. - * Note this does not contain the leading "?". - * - * @param policy - * A SharedAccessPolicy object that represents the access policy for the shared access - * signature. - * @param groupPolicyIdentifier - * A String that represents the container-level access policy. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are invalid or the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - private String generateSharedAccessSignatureCore(final SharedAccessPolicy policy, - final String groupPolicyIdentifier, OperationContext opContext) throws InvalidKeyException, - StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (!this.blobServiceClient.getCredentials().canCredentialsSignRequest()) { - throw new IllegalArgumentException( - "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."); - } - - if (this.isSnapshot()) { - throw new IllegalArgumentException( - "Cannot create Shared Access Signature for snapshots. Perform the operation on the root blob instead."); - } - - final String resourceName = this.getCanonicalName(true); - - final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, - groupPolicyIdentifier, resourceName, this.blobServiceClient, opContext); - - final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignature(policy, - groupPolicyIdentifier, "b", signature); - - return builder.toString(); - } - - /** - * Returns the canonical name of the blob in the format of - * /<account-name>/<container-name>/<blob-name>. - *

- * This format is used by both Shared Access and Copy blob operations. - * - * @param ignoreSnapshotTime - * true if the snapshot time is ignored; otherwise, false. - * - * @return The canonical name in the format of /<account-name>/<container - * -name>/<blob-name>. - */ - String getCanonicalName(final boolean ignoreSnapshotTime) { - String canonicalName; - if (this.blobServiceClient.isUsePathStyleUris()) { - canonicalName = this.getUri().getRawPath(); - } - else { - canonicalName = PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this - .getUri().getRawPath()); - } - - if (!ignoreSnapshotTime && this.snapshotID != null) { - canonicalName = canonicalName.concat("?snapshot="); - canonicalName = canonicalName.concat(this.snapshotID); - } - - return canonicalName; - } - - /** - * Returns the blob's container. - * - * @return A {@link CloudBlobContainer} object that represents the container of the blob. - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @Override - public final CloudBlobContainer getContainer() throws StorageException, URISyntaxException { - if (this.container == null) { - final URI containerURI = PathUtility.getContainerURI(this.getUri(), - this.blobServiceClient.isUsePathStyleUris()); - this.container = new CloudBlobContainer(containerURI, this.blobServiceClient); - } - - return this.container; - } - - /** - * Returns the metadata for the blob. - * - * @return A java.util.HashMap object that represents the metadata for the blob. - */ - public final HashMap getMetadata() { - return this.metadata; - } - - /** - * Returns the name of the blob. - * - * @return A String that represents the name of the blob. - * - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public final String getName() throws URISyntaxException { - if (Utility.isNullOrEmpty(this.name)) { - this.name = PathUtility.getBlobNameFromURI(this.getUri(), this.blobServiceClient.isUsePathStyleUris()); - } - return this.name; - } - - /** - * Returns the blob item's parent. - * - * @return A {@link CloudBlobDirectory} object that represents the parent directory for the blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @Override - public final CloudBlobDirectory getParent() throws URISyntaxException, StorageException { - if (this.parent == null) { - final URI parentURI = PathUtility.getParentAddress(this.getUri(), - this.blobServiceClient.getDirectoryDelimiter(), this.blobServiceClient.isUsePathStyleUris()); - this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); - } - return this.parent; - } - - /** - * Returns the blob's properties. - * - * @return A {@link BlobProperties} object that represents the properties of the blob. - */ - public final BlobProperties getProperties() { - return this.properties; - } - - /** - * Returns the snapshot or shared access signature qualified URI for this blob. - * - * @return A java.net.URI object that represents the snapshot or shared access signature. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public final URI getQualifiedUri() throws URISyntaxException, StorageException { - if (this.isSnapshot()) { - return PathUtility.addToQuery(this.getUri(), String.format("snapshot=%s", this.snapshotID)); - } - else if (this.blobServiceClient.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { - return this.blobServiceClient.getCredentials().transformUri(this.getUri()); - } - else { - return this.getUri(); - } - } - - /** - * Returns the Blob service client associated with the blob. - * - * @return A {@link CloudBlobClient} object that represents the client. - */ - public final CloudBlobClient getServiceClient() { - return this.blobServiceClient; - } - - /** - * Gets the Blob Snapshot ID. - * - * @return the Blob Snapshot ID. - */ - public final String getSnapshotID() { - return this.snapshotID; - } - - /** - * Returns the transformed URI for the resource if the given credentials require transformation. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A java.net.URI object that represents the transformed URI. - * - * @throws IllegalArgumentException - * If the URI is not absolute. - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - protected final URI getTransformedAddress(final OperationContext opContext) throws URISyntaxException, - StorageException { - if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { - if (this.getUri().isAbsolute()) { - return this.blobServiceClient.getCredentials().transformUri(this.getUri(), opContext); - } - else { - final StorageException ex = Utility.generateNewUnexpectedStorageException(null); - ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); - throw ex; - } - } - else { - return this.getUri(); - } - } - - /** - * Returns the URI for this blob. - * - * @return A java.net.URI object that represents the URI for the blob. - */ - @Override - public final URI getUri() { - return this.uri; - } - - /** - * Indicates whether this blob is a snapshot. - * - * @return true if the blob is a snapshot, otherwise false. - * - * @see DeleteSnapshotsOption - */ - public final boolean isSnapshot() { - return this.snapshotID != null; - } - - /** - * Opens a blob input stream to download the blob. - *

- * Use {@link CloudBlobClient#setStreamMinimumReadSizeInBytes} to configure the read size. - * - * @return An InputStream object that represents the stream to use for reading from the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final BlobInputStream openInputStream() throws StorageException { - return this.openInputStream(null, null, null); - } - - /** - * Opens a blob input stream to download the blob using the specified request options and operation context. - *

- * Use {@link CloudBlobClient#setStreamMinimumReadSizeInBytes} to configure the read size. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An InputStream object that represents the stream to use for reading from the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final BlobInputStream openInputStream(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - return new BlobInputStream(this, accessCondition, options, opContext); - } - - /** - * Parse Uri for SAS (Shared access signature) information. - * - * Validate that no other query parameters are passed in. Any SAS information will be recorded as corresponding - * credentials instance. If existingClient is passed in, any SAS information found will not be supported. Otherwise - * a new client is created based on SAS information or as anonymous credentials. - * - * @param completeUri - * The complete Uri. - * @param existingClient - * The client to use. - * @param usePathStyleUris - * If true, path style Uris are used. - * @throws StorageException - * If a storage service error occurred. - * */ - private void parseURIQueryStringAndVerify(final URI completeUri, final CloudBlobClient existingClient, - final boolean usePathStyleUris) throws StorageException { - Utility.assertNotNull("resourceUri", completeUri); - - if (!completeUri.isAbsolute()) { - final String errorMessage = String.format( - "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", - completeUri.toString()); - throw new IllegalArgumentException(errorMessage); - } - - this.uri = PathUtility.stripURIQueryAndFragment(completeUri); - - final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); - - final StorageCredentialsSharedAccessSignature sasCreds = SharedAccessSignatureHelper - .parseQuery(queryParameters); - - final String[] snapshotIDs = queryParameters.get(BlobConstants.SNAPSHOT); - if (snapshotIDs != null && snapshotIDs.length > 0) { - this.snapshotID = snapshotIDs[0]; - } - - if (sasCreds == null) { - return; - } - - final Boolean sameCredentials = existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, - existingClient.getCredentials()); - - if (existingClient == null || !sameCredentials) { - try { - this.blobServiceClient = new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress( - this.getUri(), usePathStyleUris)), sasCreds); - } - catch (final URISyntaxException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - if (existingClient != null && !sameCredentials) { - this.blobServiceClient - .setPageBlobStreamWriteSizeInBytes(existingClient.getPageBlobStreamWriteSizeInBytes()); - this.blobServiceClient.setSingleBlobPutThresholdInBytes(existingClient.getSingleBlobPutThresholdInBytes()); - this.blobServiceClient.setStreamMinimumReadSizeInBytes(existingClient.getStreamMinimumReadSizeInBytes()); - this.blobServiceClient.setWriteBlockSizeInBytes(existingClient.getWriteBlockSizeInBytes()); - this.blobServiceClient.setConcurrentRequestCount(existingClient.getConcurrentRequestCount()); - this.blobServiceClient.setDirectoryDelimiter(existingClient.getDirectoryDelimiter()); - this.blobServiceClient.setRetryPolicyFactory(existingClient.getRetryPolicyFactory()); - this.blobServiceClient.setTimeoutInMs(existingClient.getTimeoutInMs()); - } - } - - void updatePropertiesFromResponse(HttpURLConnection request) { - String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); - - // ETag - if (!Utility.isNullOrEmpty(tempStr)) { - this.getProperties().setEtag(tempStr); - } - - // Last Modified - if (0 != request.getLastModified()) { - final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); - lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); - lastModifiedCalendar.setTime(new Date(request.getLastModified())); - this.getProperties().setLastModified(lastModifiedCalendar.getTime()); - } - - // using this instead of the request property since the request - // property only returns an int. - tempStr = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH); - - if (!Utility.isNullOrEmpty(tempStr)) { - this.getProperties().setLength(Long.parseLong(tempStr)); - } - } - - /** - * Releases the lease on the blob. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void releaseLease(final AccessCondition accessCondition) throws StorageException { - this.releaseLease(accessCondition, null, null); - } - - /** - * Releases the lease on the blob using the specified request options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob.The LeaseID is - * required to be set on the AccessCondition. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void releaseLease(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - Utility.assertNotNull("accessCondition", accessCondition); - Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RELEASE, accessCondition, - blobOptions, opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - blob.properties.setLeaseStatus(LeaseStatus.UNLOCKED); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Renews an existing lease. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void renewLease(final AccessCondition accessCondition) throws StorageException { - this.renewLease(accessCondition, null, null); - } - - /** - * Renews an existing lease using the specified request options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. The LeaseID is - * required to be set on the AccessCondition. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void renewLease(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - Utility.assertNotNull("accessCondition", accessCondition); - Utility.assertNotNullOrEmpty("leaseID", accessCondition.getLeaseID()); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.RENEW, accessCondition, blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Sets the container for the blob. - * - * @param container - * A {@link CloudBlobContainer} object that represents the container being assigned to the blob. - */ - protected final void setContainer(final CloudBlobContainer container) { - this.container = container; - } - - /** - * Sets the metadata for the blob. - * - * @param metadata - * A java.util.HashMap object that contains the metadata being assigned to the blob. - */ - public final void setMetadata(final HashMap metadata) { - this.metadata = metadata; - } - - /** - * Sets the properties for the blob. - * - * @param properties - * A {@link BlobProperties} object that represents the properties being assigned to the blob. - */ - protected final void setProperties(final BlobProperties properties) { - this.properties = properties; - } - - /** - * Sets the blob snapshot ID. - * - * @param snapshotID - * A String that represents the snapshot ID being assigned to the blob. - */ - public final void setSnapshotID(final String snapshotID) { - this.snapshotID = snapshotID; - } - - /** - * Attempts to break the lease and ensure that another client cannot acquire a new lease until the current lease - * period has expired. - * - * @return Time, in seconds, remaining in the lease period, or -1 if the lease is already broken. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final long tryBreakLease() throws StorageException { - return this.tryBreakLease(null, null, null); - } - - /** - * Attempts to breaks the lease using the specified request options and operation context, and ensure that another - * client cannot acquire a new lease until the current lease period has expired. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return Time, in seconds, remaining in the lease period, -1 if the lease is already broken. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final long tryBreakLease(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Long execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.lease(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), LeaseAction.BREAK, accessCondition, blobOptions, - opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = StorageException.translateException(request, - null, opContext); - - StorageExtendedErrorInformation extendedInfo = potentialConflictException - .getExtendedErrorInformation(); - - if (extendedInfo == null) { - // If we cant validate the error then the error must be surfaced to the user. - throw potentialConflictException; - } - - if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - } - - return -1L; - } - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return -1L; - } - - blob.updatePropertiesFromResponse(request); - final String leaseTime = BlobResponse.getLeaseTime(request, opContext); - - return Utility.isNullOrEmpty(leaseTime) ? -1L : Long.parseLong(leaseTime); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Uploads the source stream data to the blob. - * - * @param sourceStream - * An InputStream object that represents the source stream to upload. - * - * @param length - * The length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a - * multiple of 512 for page blobs. - * - * @throws IOException - * If an I/O exception occurred. - * - * @throws StorageException - * If a storage service error occurred. - * - */ - @DoesServiceRequest - public abstract void upload(InputStream sourceStream, long length) throws StorageException, IOException; - - /** - * Uploads the source stream data to the blob using the specified lease ID, request options, and operation context. - * - * @param sourceStream - * An InputStream object that represents the source stream to upload. - * @param length - * The length of the stream data in bytes, or -1 if unknown. The length must be greater than zero and a - * multiple of 512 for page blobs. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public abstract void upload(InputStream sourceStream, long length, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException; - - /** - * Uploads a blob in a single operation. - * - * @param sourceStream - * A InputStream object that represents the source stream to upload. - * @param length - * The length, in bytes, of the stream, or -1 if unknown. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - protected final void uploadFullBlob(final InputStream sourceStream, final long length, - final AccessCondition accessCondition, final BlobRequestOptions options, final OperationContext opContext) - throws StorageException, IOException { - // Mark sourceStream for current position. - sourceStream.mark(Integer.MAX_VALUE); - - if (length < 0) { - throw new IllegalArgumentException("Invalid stream length, specify a positive number of bytes"); - } - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, blob.properties.getBlobType(), - 0, accessCondition, blobOptions, opContext); - - BlobRequest.addMetadata(request, blob.metadata, opContext); - - client.getCredentials().signRequest(request, length); - - final StreamMd5AndLength descriptor = Utility.writeToOutputStream(sourceStream, - request.getOutputStream(), length, true, false, null, opContext); - - if (length != descriptor.getLength()) { - throw new StorageException( - StorageErrorCodeStrings.INVALID_INPUT, - "An incorrect stream length was specified, resulting in an authentication failure. Please specify correct length, or -1.", - HttpURLConnection.HTTP_FORBIDDEN, null, null); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Uploads the blob's metadata to the storage service. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void uploadMetadata() throws StorageException { - this.uploadMetadata(null, null, null); - } - - /** - * Uploads the blob's metadata to the storage service using the specified lease ID, request options, and operation - * context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void uploadMetadata(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.setMetadata(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), accessCondition, blobOptions, opContext); - - BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Updates the blob's properties to the storage service. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void uploadProperties() throws StorageException { - this.uploadProperties(null, null, null); - } - - /** - * Updates the blob's properties using the specified lease ID, request options, and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public final void uploadProperties(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.setProperties(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, null, accessCondition, - blobOptions, opContext); - - BlobRequest.addMetadata(request, blob.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java deleted file mode 100644 index 5c721220734c8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ /dev/null @@ -1,690 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RequestOptions; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; -import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; -import com.microsoft.windowsazure.services.core.storage.ResultSegment; -import com.microsoft.windowsazure.services.core.storage.ServiceClient; -import com.microsoft.windowsazure.services.core.storage.StorageCredentials; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAnonymous; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * Provides a client for accessing the Windows Azure Blob service. - *

- * This class provides a point of access to the Blob service. The service client encapsulates the base URI for the Blob - * service. If the service client will be used for authenticated access, it also encapsulates the credentials for - * accessing the storage account. - */ -public final class CloudBlobClient extends ServiceClient { - /** - * Holds the maximum size of a blob in bytes that may be uploaded as a single blob. - */ - private int singleBlobPutThresholdInBytes = BlobConstants.DEFAULT_SINGLE_BLOB_PUT_THRESHOLD_IN_BYTES; - - /** - * Holds the maximum block size for writing to a block blob. - */ - private int writeBlockSizeInBytes = BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES; - - /** - * Holds the number of bytes a BlobStream will write at once for a page blob. - */ - private int pageBlobStreamWriteSizeInBytes = BlobConstants.DEFAULT_MINIMUM_PAGE_STREAM_WRITE_IN_BYTES; - - /** - * Holds the minimum read size when using a BlobReadStream. - */ - private int streamMinimumReadSizeInBytes = BlobConstants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES; - - /** - * Holds the number of simultaneous operations a given blob operation may perform. - */ - private int concurrentRequestCount = BlobConstants.DEFAULT_CONCURRENT_REQUEST_COUNT; - - /** - * Holds the default delimiter that may be used to create a virtual directory structure of blobs. - */ - private String directoryDelimiter = BlobConstants.DEFAULT_DELIMITER; - - /** - * Creates an instance of the CloudBlobClient class using the specified Blob service endpoint. - * - * @param baseUri - * A java.net.URI object that represents the Blob service endpoint used to create the - * client. - */ - public CloudBlobClient(final URI baseUri) { - this(baseUri, StorageCredentialsAnonymous.ANONYMOUS); - } - - /** - * Creates an instance of the CloudBlobClient class using the specified Blob service endpoint and - * account credentials. - * - * @param baseUri - * A java.net.URI object that represents the Blob service endpoint used to create the - * client. - * @param credentials - * A {@link StorageCredentials} object that represents the account credentials. - */ - public CloudBlobClient(final URI baseUri, StorageCredentials credentials) { - super(baseUri, credentials); - this.directoryDelimiter = BlobConstants.DEFAULT_DELIMITER; - this.streamMinimumReadSizeInBytes = BlobConstants.DEFAULT_MINIMUM_READ_SIZE_IN_BYTES; - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, - StorageException { - return this.getBlockBlobReference(blobAddressUri, null); - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container, using the - * specified snapshot ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) - throws StorageException, URISyntaxException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI completeUri = PathUtility.appendPathToUri(this.endpoint, blobAddressUri); - - return new CloudBlockBlob(completeUri, snapshotID, this); - } - - /** - * Returns the number of maximum concurrent requests allowed. - * - * @return The number of maximum concurrent requests allowed. - */ - public int getConcurrentRequestCount() { - return this.concurrentRequestCount; - } - - /** - * Returns a reference to a {@link CloudBlobContainer} object that represents the cloud blob container for the - * specified address. - * - * @param containerAddress - * A String that represents the name of the container, or the absolute URI to the container. - * @return A {@link CloudBlobContainer} object that represents a reference to the cloud blob container. - * - * @throws URISyntaxException - * If the resource URI is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public CloudBlobContainer getContainerReference(final String containerAddress) throws URISyntaxException, - StorageException { - Utility.assertNotNullOrEmpty("containerAddress", containerAddress); - return new CloudBlobContainer(containerAddress, this); - } - - /** - * Returns the value for the default delimiter used for cloud blob directories. The default is '/'. - * - * @return The value for the default delimiter. - */ - public String getDirectoryDelimiter() { - return this.directoryDelimiter; - } - - /** - * Returns a reference to the specified virtual blob directory. - *

- * A blob directory simplifies working with a hierarchical organization of blobs. A blob directory is a blob name - * prefix that can be used to navigate a hierarchy. The prefix may end in a delimiter character, but a delimiter is - * not required; the directory can end in any character. - * - * @param relativeAddress - * A String that represents the name of the virtual blob directory, or the absolute URI to - * the virtual blob directory. - * - * @return A {@link CloudBlobDirectory} object that represents the specified virtual blob directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlobDirectory getDirectoryReference(final String relativeAddress) throws URISyntaxException, - StorageException { - Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); - - return new CloudBlobDirectory(relativeAddress, this); - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { - return this.getPageBlobReference(blobAddressUri, null); - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob, using the specified snapshot - * ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) - throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI completeUri = PathUtility.appendPathToUri(this.endpoint, blobAddressUri); - - return new CloudPageBlob(completeUri, snapshotID, this); - } - - /** - * Returns the write page size in use for this Blob service client. - * - * @return The maximum block size, in bytes, for writing to a page blob. - */ - public int getPageBlobStreamWriteSizeInBytes() { - return this.pageBlobStreamWriteSizeInBytes; - } - - /** - * Returns the threshold size used for writing a single blob for this Blob service client. - * - * @return The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 to 64 MB - * inclusive. The default value is 32 MBs. - *

- * If a blob size is above the threshold, it will be uploaded as blocks. - */ - public int getSingleBlobPutThresholdInBytes() { - return this.singleBlobPutThresholdInBytes; - } - - /** - * Returns the minimum read size in use for this Blob service client. - * - * @return The minimum read size, in bytes, when using a {@link BlobInputStream} object. - */ - public int getStreamMinimumReadSizeInBytes() { - return this.streamMinimumReadSizeInBytes; - } - - /** - * Returns the write block size in use for this Blob service client. - * - * @return The maximum block size, in bytes, for writing to a block blob while using a {@link BlobOutputStream} - * object. - */ - public int getWriteBlockSizeInBytes() { - return this.writeBlockSizeInBytes; - } - - /** - * Returns an enumerable collection of blob containers for this Blob service client. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for this - * client. - */ - @DoesServiceRequest - public Iterable listContainers() { - return this.listContainersWithPrefix(null, ContainerListingDetails.NONE, null, null); - } - - /** - * Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob - * service client. - * - * @param prefix - * A String that represents the container name prefix. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for this - * client whose names begin with the specified prefix. - */ - @DoesServiceRequest - public Iterable listContainers(final String prefix) { - return this.listContainersWithPrefix(prefix, ContainerListingDetails.NONE, null, null); - } - - /** - * Returns an enumerable collection of blob containers whose names begin with the specified prefix for this Blob - * service client, using the specified details setting, request options, and operation context. - * - * @param prefix - * A String that represents the container name prefix. - * @param detailsIncluded - * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represents the containers for this - * client. - */ - @DoesServiceRequest - public Iterable listContainers(final String prefix, - final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, - final OperationContext opContext) { - return this.listContainersWithPrefix(prefix, detailsIncluded, options, opContext); - } - - /** - * Returns a result segment containing a collection of containers whose names begin with the specified prefix. - * - * @param prefix - * A String that represents the container name prefix. - * @param detailsIncluded - * A value that indicates whether to return container metadata with the listing. - * @param maxResults - * the maximum results to retrieve. - * @param continuationToken - * A continuation token returned by a previous listing operation. - * @param options - * the request options to use for the operation - * @param taskReference - * a reference to the encapsulating task - * @param opContext - * a tracking object for the operation - * @return a result segment containing a collection of containers whose names begin with the specified prefix. - * @throws IOException - * @throws URISyntaxException - * @throws XMLStreamException - * @throws InvalidKeyException - * @throws StorageException - */ - @DoesServiceRequest - ResultSegment listContainersCore(final String prefix, - final ContainerListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, final RequestOptions options, - final StorageOperation> taskReference, - final OperationContext opContext) throws IOException, URISyntaxException, XMLStreamException, - InvalidKeyException, StorageException { - - Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); - - final ListingContext listingContext = new ListingContext(prefix, maxResults); - listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - - final HttpURLConnection listContainerRequest = ContainerRequest.list(this.getEndpoint(), - options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); - - this.getCredentials().signRequest(listContainerRequest, -1L); - - taskReference.setResult(ExecutionEngine.processRequest(listContainerRequest, opContext)); - - if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - taskReference.setNonExceptionedRetryableFailure(true); - return null; - } - - final ListContainersResponse response = new ListContainersResponse(listContainerRequest.getInputStream()); - response.parseResponse(this); - - ResultContinuation newToken = null; - - if (response.getNextMarker() != null) { - newToken = new ResultContinuation(); - newToken.setNextMarker(response.getNextMarker()); - newToken.setContinuationType(ResultContinuationType.CONTAINER); - } - - final ResultSegment resSegment = new ResultSegment( - response.getContainers(this), maxResults, newToken); - - return resSegment; - } - - /** - * Returns a result segment of an enumerable collection of blob containers for this Blob service client. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers in this container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented() throws StorageException { - return this.listContainersSegmented(null, ContainerListingDetails.NONE, 0, null, null, null); - } - - /** - * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified - * prefix for this Blob service client. - * - * @param prefix - * A String that represents the prefix of the container name. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified - * prefix. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented(final String prefix) throws StorageException { - return this.listContainersWithPrefixSegmented(prefix, null, 0, null, null, null); - } - - /** - * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified - * prefix for this container, using the specified listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the container name. - * @param detailsIncluded - * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. - * @param maxResults - * The maximum number of results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers in this container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented(final String prefix, - final ContainerListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, final BlobRequestOptions options, - final OperationContext opContext) throws StorageException { - - return this.listContainersWithPrefixSegmented(prefix, detailsIncluded, maxResults, continuationToken, options, - opContext); - } - - /** - * Returns an enumerable collection of blob containers whose names begin with the specified prefix, using the - * specified details setting, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the container name. - * @param detailsIncluded - * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers whose names - * begin with the specified prefix. - */ - @DoesServiceRequest - protected Iterable listContainersWithPrefix(final String prefix, - final ContainerListingDetails detailsIncluded, BlobRequestOptions options, OperationContext opContext) { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this); - - final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( - options, null) { - @Override - public ResultSegment execute(final CloudBlobClient client, final Void dontCare, - final OperationContext opContext) throws Exception { - - final ResultSegment result = CloudBlobClient.this.listContainersCore(prefix, - detailsIncluded, -1, this.getToken(), this.getRequestOptions(), this, opContext); - - // Note, setting the token on the SegmentedStorageOperation is - // key, this is how the iterator - // will share the token across executions - this.setToken(result.getContinuationToken()); - return result; - } - }; - - return new LazySegmentedIterator(impl, this, null, - options.getRetryPolicyFactory(), opContext); - } - - /** - * Returns a result segment of an enumerable collection of blob containers whose names begin with the specified - * prefix for this container, using the specified listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the container name. - * @param detailsIncluded - * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. - * @param maxResults - * The maximum number of results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers in this container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - protected ResultSegment listContainersWithPrefixSegmented(final String prefix, - final ContainerListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, BlobRequestOptions options, OperationContext opContext) - throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this); - - Utility.assertContinuationType(continuationToken, ResultContinuationType.CONTAINER); - - final StorageOperation> impl = new StorageOperation>( - options) { - @Override - public ResultSegment execute(final CloudBlobClient client, final Void dontCare, - final OperationContext opContext) throws Exception { - return CloudBlobClient.this.listContainersCore(prefix, detailsIncluded, maxResults, continuationToken, - this.getRequestOptions(), this, opContext); - } - }; - - return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Sets the maximum number of concurrent requests allowed for the Blob service client. - * - * @param concurrentRequestCount - * The value being assigned as the maximum number of concurrent requests allowed for the Blob service - * client. - */ - public void setConcurrentRequestCount(final int concurrentRequestCount) { - this.concurrentRequestCount = concurrentRequestCount; - } - - /** - * Sets the value for the default delimiter used for cloud blob directories. - * - * @param directoryDelimiter - * A String that represents the value for the default directory delimiter. - */ - public void setDirectoryDelimiter(final String directoryDelimiter) { - this.directoryDelimiter = directoryDelimiter; - } - - /** - * Sets the write page size in use for this Blob Service client. - * - * @param pageBlobStreamWriteSizeInBytes - * The maximum block size, in bytes, for writing to a page blob. This value must be a multiple of 512 and - * less than or equal to 4 MB. - */ - public void setPageBlobStreamWriteSizeInBytes(final int pageBlobStreamWriteSizeInBytes) { - if (pageBlobStreamWriteSizeInBytes > BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES - || pageBlobStreamWriteSizeInBytes < BlobConstants.PAGE_SIZE - || pageBlobStreamWriteSizeInBytes % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("PageBlobStreamWriteSizeInBytes"); - } - - this.pageBlobStreamWriteSizeInBytes = pageBlobStreamWriteSizeInBytes; - } - - /** - * Sets the threshold size used for writing a single blob to use with this Blob service client. - * - * @param singleBlobPutThresholdInBytes - * The maximum size, in bytes, of a blob that may be uploaded as a single blob, ranging from 1 MB to 64 - * MB inclusive. If a blob size is above the threshold, it will be uploaded as blocks. - * - * @throws IllegalArgumentException - * If minimumReadSize is less than 1 MB or greater than 64 MB. - */ - public void setSingleBlobPutThresholdInBytes(final int singleBlobPutThresholdInBytes) { - if (singleBlobPutThresholdInBytes > BlobConstants.MAX_SINGLE_UPLOAD_BLOB_SIZE_IN_BYTES - || singleBlobPutThresholdInBytes < 1 * Constants.MB) { - throw new IllegalArgumentException("SingleBlobUploadThresholdInBytes"); - } - - this.singleBlobPutThresholdInBytes = singleBlobPutThresholdInBytes; - } - - /** - * Sets the minimum read block size to use with this Blob service client. - * - * @param minimumReadSize - * The maximum block size, in bytes, for reading from a block blob while using a {@link BlobInputStream} - * object, ranging from 512 bytes to 64 MB, inclusive. - */ - public void setStreamMinimumReadSizeInBytes(final int minimumReadSize) { - if (minimumReadSize > 64 * Constants.MB || minimumReadSize < BlobConstants.PAGE_SIZE) { - throw new IllegalArgumentException("MinimumReadSize"); - } - - this.streamMinimumReadSizeInBytes = minimumReadSize; - } - - /** - * Sets the write block size to use with this Blob service client. - * - * @param writeBlockSizeInBytes - * The maximum block size, in bytes, for writing to a block blob while using a {@link BlobOutputStream} - * object, ranging from 1 MB to 4 MB, inclusive. - * - * @throws IllegalArgumentException - * If writeBlockSizeInBytes is less than 1 MB or greater than 4 MB. - */ - public void setWriteBlockSizeInBytes(final int writeBlockSizeInBytes) { - if (writeBlockSizeInBytes > BlobConstants.DEFAULT_WRITE_BLOCK_SIZE_IN_BYTES - || writeBlockSizeInBytes < 1 * Constants.MB) { - throw new IllegalArgumentException("WriteBlockSizeInBytes"); - } - - this.writeBlockSizeInBytes = writeBlockSizeInBytes; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java deleted file mode 100644 index 3d9acd152d6a0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ /dev/null @@ -1,1857 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.Calendar; -import java.util.Date; -import java.util.EnumSet; -import java.util.HashMap; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; -import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; -import com.microsoft.windowsazure.services.core.storage.ResultSegment; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * Represents a container in the Windows Azure Blob service. - *

- * Containers hold directories, which are encapsulated as {@link CloudBlobDirectory} objects, and directories hold block - * blobs and page blobs. Directories can also contain sub-directories. - */ -public final class CloudBlobContainer { - - /** - * Converts the ACL string to a BlobContainerPermissions object. - * - * @param aclString - * the string to convert. - * @return The resulting BlobContainerPermissions object. - */ - static BlobContainerPermissions getContainerAcl(final String aclString) { - BlobContainerPublicAccessType accessType = BlobContainerPublicAccessType.OFF; - - if (!Utility.isNullOrEmpty(aclString)) { - final String lowerAclString = aclString.toLowerCase(); - if ("container".equals(lowerAclString)) { - accessType = BlobContainerPublicAccessType.CONTAINER; - } - else if ("blob".equals(lowerAclString)) { - accessType = BlobContainerPublicAccessType.BLOB; - } - else { - throw new IllegalArgumentException(String.format( - "Invalid acl public access type returned '%s'. Expected blob or container.", aclString)); - } - } - - final BlobContainerPermissions retVal = new BlobContainerPermissions(); - retVal.setPublicAccess(accessType); - - return retVal; - } - - /** - * Represents the container metadata. - */ - protected HashMap metadata; - - /** - * Holds the container properties. - */ - BlobContainerProperties properties; - - /** - * Holds the name of the container. - */ - String name; - - /** - * Holds the URI of the container. - */ - URI uri; - - /** - * Holds a reference to the associated service client. - */ - private CloudBlobClient blobServiceClient; - - /** - * Initializes a new instance of the CloudBlobContainer class. - * - * @param client - * the reference to the associated service client. - */ - private CloudBlobContainer(final CloudBlobClient client) { - this.metadata = new HashMap(); - this.properties = new BlobContainerProperties(); - this.blobServiceClient = client; - } - - /** - * Creates an instance of the CloudBlobContainer class using the specified address and client. - * - * @param containerAddress - * A String that represents either the absolute URI to the container, or the container name. - * @param client - * A {@link CloudBlobClient} object that represents the associated service client, and that specifies the - * endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlobContainer(final String containerAddress, final CloudBlobClient client) throws URISyntaxException, - StorageException { - this(client); - - final URI resURI = PathUtility.appendPathToUri(client.getEndpoint(), containerAddress); - - this.uri = resURI; - this.name = PathUtility.getContainerNameFromUri(resURI, client.isUsePathStyleUris()); - - this.parseQueryAndVerify(this.uri, client, client.isUsePathStyleUris()); - } - - /** - * Creates an instance of the CloudBlobContainer class using the specified URI and client. - * - * @param uri - * A java.net.URI object that represents the URI of the container. - * @param client - * A {@link CloudBlobClient} object that represents the associated service client, and that specifies the - * endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlobContainer(final URI uri, final CloudBlobClient client) throws URISyntaxException, StorageException { - this(client); - - this.uri = uri; - this.name = PathUtility.getContainerNameFromUri(uri, client.isUsePathStyleUris()); - - this.parseQueryAndVerify(this.uri, client, client.isUsePathStyleUris()); - } - - /** - * Creates the container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void create() throws StorageException { - this.create(null, null); - } - - /** - * Creates the container using the specified options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void create(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - // Set attributes - final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, - client.isUsePathStyleUris()); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Creates the container if it does not exist. - * - * @return true if the container did not already exist and was created; otherwise, false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean createIfNotExist() throws StorageException { - return this.createIfNotExist(null, null); - } - - /** - * Creates the container if it does not exist, using the specified request options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the container did not already exist and was created; otherwise, false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean createIfNotExist(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = ContainerRequest.create(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - // Validate response code here - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - // Set attributes - final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, - client.isUsePathStyleUris()); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = StorageException.translateException(request, - null, opContext); - - StorageExtendedErrorInformation extendedInfo = potentialConflictException - .getExtendedErrorInformation(); - if (extendedInfo == null) { - // If we can't validate the error then the error must be surfaced to the user. - throw potentialConflictException; - } - - if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - - // return false instead of null to avoid SCA issues - return false; - } - - return false; - } - else { - throw StorageException.translateException(request, null, opContext); - } - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Deletes the container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void delete() throws StorageException { - this.delete(null, null); - } - - /** - * Deletes the container using the specified request options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void delete(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - - } - - /** - * Deletes the container if it exists. - * - * @return true if the container did not already exist and was created; otherwise, false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean deleteIfExists() throws StorageException { - return this.deleteIfExists(null, null); - } - - /** - * Deletes the container if it exists using the specified request options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the container did not already exist and was created; otherwise, false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean deleteIfExists(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = ContainerRequest.delete(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_ACCEPTED) { - container.updatePropertiesFromResponse(request); - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } - else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Downloads the container's attributes, which consist of metadata and properties. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void downloadAttributes() throws StorageException { - this.downloadAttributes(null, null); - } - - /** - * Downloads the container's attributes, which consist of metadata and properties, using the specified request - * options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void downloadAttributes(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this - .getRequestOptions().getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - // Set attributes - final BlobContainerAttributes attributes = ContainerResponse.getAttributes(request, - client.isUsePathStyleUris()); - container.metadata = attributes.getMetadata(); - container.properties = attributes.getProperties(); - container.name = attributes.getName(); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Downloads the permission settings for the container. - * - * @return A {@link BlobContainerPermissions} object that represents the container's permissions. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public BlobContainerPermissions downloadPermissions() throws StorageException { - return this.downloadPermissions(null, null); - } - - /** - * Downloads the permissions settings for the container using the specified request options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link BlobContainerPermissions} object that represents the container's permissions. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public BlobContainerPermissions downloadPermissions(BlobRequestOptions options, OperationContext opContext) - throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public BlobContainerPermissions execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = ContainerRequest.getAcl(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } - - container.updatePropertiesFromResponse(request); - final String aclString = ContainerResponse.getAcl(request); - final BlobContainerPermissions containerAcl = getContainerAcl(aclString); - - final AccessPolicyResponse response = new AccessPolicyResponse(request.getInputStream()); - - for (final String key : response.getAccessIdentifiers().keySet()) { - containerAcl.getSharedAccessPolicies().put(key, response.getAccessIdentifiers().get(key)); - } - - return containerAcl; - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Returns a value that indicates whether the container exists. - * - * @return true if the container exists, otherwise false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean exists() throws StorageException { - return this.exists(null, null); - } - - /** - * Returns a value that indicates whether the container exists, using the specified request options and operation - * context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the container exists, otherwise false. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public boolean exists(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = ContainerRequest.getProperties(container.uri, this - .getRequestOptions().getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - container.updatePropertiesFromResponse(request); - return Boolean.valueOf(true); - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } - else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Returns a shared access signature for the blob using the specified shared access policy. Note this does not - * contain the leading "?". - *

- * A shared access signature is a token that provides delegated access to blob resources. You can provide this token - * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared - * access signature created for a blob grants access just to the content and metadata of that blob. A shared access - * signature created for a container grants access to the content and metadata of any blob in the container, and to - * the list of blobs in the container. - *

- * The parameters of the shared access signature that govern access are: - *

    - *
  • The start time at which the signature becomes valid.
  • - *
  • The time at which it expires.
  • - *
  • The permissions that it grants.
  • - *
- * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There - * are two ways to specify an access policy: - *
    - *
  • - * You can specify it on a single shared access signature. In this case, the interval over which the signature may - * be valid is limited to one hour.
  • - *
  • - * You can specify it by creating a container-level access policy, which can be associated with one or more shared - * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if - * it should be compromised. To specify that the access policy should be used by the signature, call an overload - * that includes the groupPolicyIdentifier parameter.
  • - *
- * You can also specify some parameters of the access policy on the signature and some on a container-level access - * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides - * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For - * details on container-level access policies, see Specifying a Container-Level Access Policy. - * - * @param policy - * A SharedAccessPolicy object that represents the access policy for the shared access - * signature. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are invalid or the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public String generateSharedAccessSignature(final SharedAccessPolicy policy) throws InvalidKeyException, - StorageException { - return this.generateSharedAccessSignature(policy, null); - } - - /** - * Returns a shared access signature for the blob using the shared access policy and operation context. Note this - * does not contain the leading "?". - *

- * A shared access signature is a token that provides delegated access to blob resources. You can provide this token - * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared - * access signature created for a blob grants access just to the content and metadata of that blob. A shared access - * signature created for a container grants access to the content and metadata of any blob in the container, and to - * the list of blobs in the container. - *

- * The parameters of the shared access signature that govern access are: - *

    - *
  • The start time at which the signature becomes valid.
  • - *
  • The time at which it expires.
  • - *
  • The permissions that it grants.
  • - *
- * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There - * are two ways to specify an access policy: - *
    - *
  • - * You can specify it on a single shared access signature. In this case, the interval over which the signature may - * be valid is limited to one hour.
  • - *
  • - * You can specify it by creating a container-level access policy, which can be associated with one or more shared - * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if - * it should be compromised. To specify that the access policy should be used by the signature, call an overload - * that includes the groupPolicyIdentifier parameter.
  • - *
- * You can also specify some parameters of the access policy on the signature and some on a container-level access - * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides - * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For - * details on container-level access policies, see Specifying a Container-Level Access Policy. - * - * @param policy - * A SharedAccessPolicy object that represents the access policy for the shared access - * signature. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are invalid or the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public String generateSharedAccessSignature(final SharedAccessPolicy policy, OperationContext opContext) - throws InvalidKeyException, StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - return this.generateSharedAccessSignatureCore(policy, null, opContext); - } - - /** - * Returns a shared access signature for the blob using the specified group policy identifier. Note this does not - * contain the leading "?". - *

- * A shared access signature is a token that provides delegated access to blob resources. You can provide this token - * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared - * access signature created for a blob grants access just to the content and metadata of that blob. A shared access - * signature created for a container grants access to the content and metadata of any blob in the container, and to - * the list of blobs in the container. - *

- * The parameters of the shared access signature that govern access are: - *

    - *
  • The start time at which the signature becomes valid.
  • - *
  • The time at which it expires.
  • - *
  • The permissions that it grants.
  • - *
- * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There - * are two ways to specify an access policy: - *
    - *
  • - * You can specify it on a single shared access signature. In this case, the interval over which the signature may - * be valid is limited to one hour.
  • - *
  • - * You can specify it by creating a container-level access policy, which can be associated with one or more shared - * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if - * it should be compromised. To specify that the access policy should be used by the signature, call an overload - * that includes the groupPolicyIdentifier parameter.
  • - *
- * You can also specify some parameters of the access policy on the signature and some on a container-level access - * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides - * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For - * details on container-level access policies, see Specifying a Container-Level Access Policy. - * - * @param groupPolicyIdentifier - * A String that represents the container-level access policy. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are invalid or the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public String generateSharedAccessSignature(final String groupPolicyIdentifier) throws InvalidKeyException, - StorageException { - return this.generateSharedAccessSignature(groupPolicyIdentifier, null); - } - - /** - * Returns a shared access signature for the blob using the specified group policy identifier and operation context. - * Note this does not contain the leading "?". - *

- * A shared access signature is a token that provides delegated access to blob resources. You can provide this token - * to clients in order to grant them specific permissions to resources for a controlled period of time. A shared - * access signature created for a blob grants access just to the content and metadata of that blob. A shared access - * signature created for a container grants access to the content and metadata of any blob in the container, and to - * the list of blobs in the container. - *

- * The parameters of the shared access signature that govern access are: - *

    - *
  • The start time at which the signature becomes valid.
  • - *
  • The time at which it expires.
  • - *
  • The permissions that it grants.
  • - *
- * These parameters are specified in an access policy, represented by the {@link SharedAccessPolicy} class. There - * are two ways to specify an access policy: - *
    - *
  • - * You can specify it on a single shared access signature. In this case, the interval over which the signature may - * be valid is limited to one hour.
  • - *
  • - * You can specify it by creating a container-level access policy, which can be associated with one or more shared - * access signatures. This approach has the advantage of making it possible to revoke a shared access signature, if - * it should be compromised. To specify that the access policy should be used by the signature, call an overload - * that includes the groupPolicyIdentifier parameter.
  • - *
- * You can also specify some parameters of the access policy on the signature and some on a container-level access - * policy. However, if you specify a parameter in both places, the parameter specified for the signature overrides - * that provided by the container-level access policy. For more information on shared access signatures, see Creating a Shared Access Signature. For - * details on container-level access policies, see Specifying a Container-Level Access Policy. - * - * @param groupPolicyIdentifier - * A String that represents the container-level access policy. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that represents the shared access signature. - * - * @throws IllegalArgumentException - * If the credentials are invalid or the blob is a snapshot. - * @throws InvalidKeyException - * If the credentials are invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public String generateSharedAccessSignature(final String groupPolicyIdentifier, OperationContext opContext) - throws InvalidKeyException, StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - return this.generateSharedAccessSignatureCore(null, groupPolicyIdentifier, opContext); - } - - /** - * Returns a shared access signature for the container. Note this does not contain the leading "?". - * - * @param policy - * The access policy for the shared access signature. - * @param groupPolicyIdentifier - * A container-level access policy. - * @return a shared access signature for the container. - * @throws InvalidKeyException - * @throws StorageException - * @throws IllegalArgumentException - */ - private String generateSharedAccessSignatureCore(final SharedAccessPolicy policy, - final String groupPolicyIdentifier, OperationContext opContext) throws InvalidKeyException, - StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (!this.blobServiceClient.getCredentials().canCredentialsSignRequest()) { - final String errorMessage = "Cannot create Shared Access Signature unless the Account Key credentials are used by the BlobServiceClient."; - throw new IllegalArgumentException(errorMessage); - } - - final String resourceName = this.getSharedAccessCanonicalName(); - - final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHash(policy, - groupPolicyIdentifier, resourceName, this.blobServiceClient, opContext); - - final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignature(policy, - groupPolicyIdentifier, "c", signature); - - return builder.toString(); - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, - StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); - - return new CloudBlockBlob(address, this.blobServiceClient, this); - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this container, using the - * specified snapshot ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) - throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); - - final CloudBlockBlob retBlob = new CloudBlockBlob(address, snapshotID, this.blobServiceClient); - retBlob.setContainer(this); - return retBlob; - } - - /** - * Returns a reference to a {@link CloudBlobDirectory} object that represents a virtual blob directory within this - * container. - * - * @param relativeAddress - * A String that represents the name of the virtual blob directory, or the absolute URI to - * the virtual blob directory. - * - * @return A {@link CloudBlobDirectory} that represents a virtual blob directory within this container. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlobDirectory getDirectoryReference(final String relativeAddress) throws URISyntaxException, - StorageException { - Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); - final URI address = PathUtility.appendPathToUri(this.uri, relativeAddress); - - return new CloudBlobDirectory(address, null, this.blobServiceClient); - } - - /** - * Returns the metadata for the container. - * - * @return A java.util.HashMap object that represents the metadata for the container. - */ - public HashMap getMetadata() { - return this.metadata; - } - - /** - * Returns the name of the container. - * - * @return A String that represents the name of the container. - */ - public String getName() { - return this.name; - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in this container. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); - - return new CloudPageBlob(address, this.blobServiceClient, this); - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the - * specified snapshot ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudPageBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) - throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri); - - final CloudPageBlob retBlob = new CloudPageBlob(address, snapshotID, this.blobServiceClient); - retBlob.setContainer(this); - return retBlob; - } - - /** - * Returns the properties for the container. - * - * @return A {@link BlobContainerProperties} object that represents the properties for the container. - */ - public BlobContainerProperties getProperties() { - return this.properties; - } - - /** - * Returns the Blob service client associated with this container. - * - * @return A {@link CloudBlobClient} object that represents the service client associated with this container. - */ - public CloudBlobClient getServiceClient() { - return this.blobServiceClient; - } - - /** - * Returns the canonical name for shared access. - * - * @return the canonical name for shared access. - */ - private String getSharedAccessCanonicalName() { - if (this.blobServiceClient.isUsePathStyleUris()) { - return this.getUri().getPath(); - } - else { - return PathUtility.getCanonicalPathFromCredentials(this.blobServiceClient.getCredentials(), this.getUri() - .getPath()); - } - } - - /** - * Returns the URI after applying the authentication transformation. - * - * @return A java.net.URI object that represents the URI after applying the authentication - * transformation. - * - * @throws IllegalArgumentException - * If an unexpected value is passed. - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - protected URI getTransformedAddress() throws URISyntaxException, StorageException { - if (this.blobServiceClient.getCredentials().doCredentialsNeedTransformUri()) { - if (this.uri.isAbsolute()) { - return this.blobServiceClient.getCredentials().transformUri(this.uri); - } - else { - final StorageException ex = Utility.generateNewUnexpectedStorageException(null); - ex.getExtendedErrorInformation().setErrorMessage("Blob Object relative URIs not supported."); - throw ex; - } - } - else { - return this.uri; - } - } - - /** - * Returns the URI for this container. - * - * @return The absolute URI to the container. - */ - public URI getUri() { - return this.uri; - } - - /** - * Returns an enumerable collection of blob items for the container. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represents the items in this container. - */ - @DoesServiceRequest - public Iterable listBlobs() { - return this.listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null); - } - - /** - * Returns an enumerable collection of blob items for the container whose names begin with the specified prefix. - * - * @param prefix - * A String that represents the blob name prefix. This value must be preceded either by the - * name of the container or by the absolute path to the container. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represents the items whose names begin with - * the specified prefix in this container. - */ - @DoesServiceRequest - public Iterable listBlobs(final String prefix) { - return this.listBlobs(prefix, false, EnumSet.noneOf(BlobListingDetails.class), null, null); - } - - /** - * Returns an enumerable collection of blob items whose names begin with the specified prefix, using the specified - * flat or hierarchical option, listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the blob name prefix. This value must be preceded either by the - * name of the container or by the absolute path to the container. - * @param useFlatBlobListing - * true to indicate that the returned list will be flat; false to indicate that - * the returned list will be hierarchical. - * @param listingDetails - * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate - * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always - * returned. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin - * with the specified prefix in this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public Iterable listBlobs(final String prefix, final boolean useFlatBlobListing, - final EnumSet listingDetails, BlobRequestOptions options, OperationContext opContext) { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - if (!useFlatBlobListing && listingDetails != null && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { - throw new IllegalArgumentException( - "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); - } - - final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( - options, null) { - - @Override - public ResultSegment execute(final CloudBlobClient client, - final CloudBlobContainer container, final OperationContext opContext) throws Exception { - - final ResultSegment result = CloudBlobContainer.this.listBlobsCore(prefix, - useFlatBlobListing, listingDetails, -1, this.getToken(), - (BlobRequestOptions) this.getRequestOptions(), this, opContext); - - // Note, setting the token on the SegmentedStorageOperation is - // key, this is how the iterator - // will share the token across executions - if (result != null) { - this.setToken(result.getContinuationToken()); - } - return result; - } - }; - - return new LazySegmentedIterator(impl, - this.blobServiceClient, this, options.getRetryPolicyFactory(), opContext); - } - - /** - * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. - * - * @param prefix - * The blob name prefix. This value must be preceded either by the name of the container or by the - * absolute path to the container. - * @param useFlatBlobListing - * a value indicating whether the blob listing operation will list all blobs in a container in a flat - * listing, or whether it will list blobs hierarchically, by virtual directory. - * @param listingDetails - * a EnumSet BlobListingDetails that indicates what items a listing operation will return. - * @param maxResults - * the maximum results to retrieve. - * @param continuationToken - * A continuation token returned by a previous listing operation. - * @param options - * An object that specifies any additional options for the request - * @param taskReference - * a reference to the encapsulating task - * @param opContext - * a tracking object for the operation - * @return a result segment containing a collection of blob items whose names begin with the specified - * @throws IllegalArgumentException - * @throws URISyntaxException - * @throws IOException - * @throws StorageException - * @throws InvalidKeyException - * @throws XMLStreamException - */ - @DoesServiceRequest - ResultSegment listBlobsCore(final String prefix, final boolean useFlatBlobListing, - EnumSet listingDetails, final int maxResults, - final ResultContinuation continuationToken, final BlobRequestOptions options, - final StorageOperation> taskReference, - final OperationContext opContext) throws URISyntaxException, IOException, StorageException, - InvalidKeyException, XMLStreamException { - Utility.assertContinuationType(continuationToken, ResultContinuationType.BLOB); - Utility.assertNotNull("options", options); - - if (listingDetails == null) { - listingDetails = EnumSet.noneOf(BlobListingDetails.class); - } - - if (!useFlatBlobListing && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { - throw new IllegalArgumentException( - "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); - } - - final String delimiter = useFlatBlobListing ? null : this.blobServiceClient.getDirectoryDelimiter(); - - final BlobListingContext listingContext = new BlobListingContext(prefix, maxResults, delimiter, listingDetails); - listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - - final HttpURLConnection listBlobsRequest = BlobRequest.list(this.getTransformedAddress(), - options.getTimeoutIntervalInMs(), listingContext, options, opContext); - - this.blobServiceClient.getCredentials().signRequest(listBlobsRequest, -1L); - - taskReference.setResult(ExecutionEngine.processRequest(listBlobsRequest, opContext)); - - if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - taskReference.setNonExceptionedRetryableFailure(true); - return null; - } - - final ListBlobsResponse response = new ListBlobsResponse(listBlobsRequest.getInputStream()); - response.parseResponse(this.blobServiceClient, this); - - ResultContinuation newToken = null; - - if (response.getNextMarker() != null) { - newToken = new ResultContinuation(); - newToken.setNextMarker(response.getNextMarker()); - newToken.setContinuationType(ResultContinuationType.BLOB); - } - - final ResultSegment resSegment = new ResultSegment(response.getBlobs( - this.blobServiceClient, this), maxResults, newToken); - - return resSegment; - } - - /** - * Returns a result segment of an enumerable collection of blob items in the container. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the blob items in the container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented() throws StorageException { - return this.listBlobsSegmented(null, false, EnumSet.noneOf(BlobListingDetails.class), -1, null, null, null); - } - - /** - * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. - * - * @param prefix - * A String that represents the prefix of the blob name. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the blob items whose names begin with the specified prefix in - * the container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented(final String prefix) throws StorageException { - return this.listBlobsSegmented(prefix, false, EnumSet.noneOf(BlobListingDetails.class), -1, null, null, null); - } - - /** - * Returns a result segment containing a collection of blob items whose names begin with the specified prefix, using - * the specified flat or hierarchical option, listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the blob name. - * @param useFlatBlobListing - * true to indicate that the returned list will be flat; false to indicate that - * the returned list will be hierarchical. - * @param listingDetails - * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate - * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always - * returned. - * @param maxResults - * The maximum number of results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the block items whose names begin with the specified prefix - * in the container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented(final String prefix, final boolean useFlatBlobListing, - final EnumSet listingDetails, final int maxResults, - final ResultContinuation continuationToken, BlobRequestOptions options, OperationContext opContext) - throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - Utility.assertContinuationType(continuationToken, ResultContinuationType.BLOB); - - if (!useFlatBlobListing && listingDetails != null && listingDetails.contains(BlobListingDetails.SNAPSHOTS)) { - throw new IllegalArgumentException( - "Listing snapshots is only supported in flat mode (no delimiter). Consider setting useFlatBlobListing to true."); - } - - final StorageOperation> impl = new StorageOperation>( - options) { - - @Override - public ResultSegment execute(final CloudBlobClient client, final CloudBlobContainer parent, - final OperationContext opContext) throws Exception { - - return CloudBlobContainer.this.listBlobsCore(prefix, useFlatBlobListing, listingDetails, maxResults, - continuationToken, (BlobRequestOptions) this.getRequestOptions(), this, opContext); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Returns an enumerable collection of containers for the service client associated with this container. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers for the - * service client associated with this container. - */ - @DoesServiceRequest - public Iterable listContainers() { - return this.blobServiceClient.listContainers(); - } - - /** - * Returns an enumerable collection of containers whose names begin with the specified prefix for the service client - * associated with this container. - * - * @param prefix - * A String that represents the container name prefix. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represent the containers whose names - * begin with the specified prefix for the service client associated with this container. - */ - @DoesServiceRequest - public Iterable listContainers(final String prefix) { - return this.blobServiceClient.listContainers(prefix); - } - - /** - * Returns an enumerable collection of containers whose names begin with the specified prefix for the service client - * associated with this container, using the specified details setting, request options, and operation context. - * - * @param prefix - * A String that represents the container name prefix. - * @param detailsIncluded - * A {@link ContainerListingDetails} value that indicates whether container metadata will be returned. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link CloudBlobContainer} objects that represents the containers for the - * service client associated with this container. - */ - @DoesServiceRequest - public Iterable listContainers(final String prefix, - final ContainerListingDetails detailsIncluded, final BlobRequestOptions options, - final OperationContext opContext) { - return this.blobServiceClient.listContainers(prefix, detailsIncluded, options, opContext); - } - - /** - * Returns a result segment of an enumerable collection of containers for the service client associated with this - * container. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers for the service client associated with - * this container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented() throws StorageException { - return this.blobServiceClient.listContainersSegmented(); - } - - /** - * Returns a result segment of an enumerable collection of containers whose names begin with the specified prefix - * for the service client associated with this container. - * - * @param prefix - * A String that represents the blob name prefix. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified - * prefix for the service client associated with this container. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented(final String prefix) throws StorageException { - return this.blobServiceClient.listContainersSegmented(prefix); - } - - /** - * Returns a result segment containing a collection of containers whose names begin with the specified prefix for - * the service client associated with this container, using the specified listing details options, request options, - * and operation context. - * - * @param prefix - * A String that represents the prefix of the container name. - * @param detailsIncluded - * A {@link ContainerListingDetails} object that indicates whether metadata is included. - * @param maxResults - * The maximum number of results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link CloudBlobContainer} objects that represent the containers whose names begin with the specified - * prefix for the service client associated with this container. - * - * @throws StorageException - * If a storage service error occurred. - * - */ - @DoesServiceRequest - public ResultSegment listContainersSegmented(final String prefix, - final ContainerListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, final BlobRequestOptions options, - final OperationContext opContext) throws StorageException { - return this.blobServiceClient.listContainersSegmented(prefix, detailsIncluded, maxResults, continuationToken, - options, opContext); - } - - /** - * Parse Uri for SAS (Shared access signature) information. - * - * Validate that no other query parameters are passed in. Any SAS information will be recorded as corresponding - * credentials instance. If existingClient is passed in, any SAS information found will not be supported. Otherwise - * a new client is created based on SAS information or as anonymous credentials. - * - * @param completeUri - * The complete Uri. - * @param existingClient - * The client to use. - * @param usePathStyleUris - * If true, path style Uris are used. - * @throws URISyntaxException - * @throws StorageException - */ - private void parseQueryAndVerify(final URI completeUri, final CloudBlobClient existingClient, - final boolean usePathStyleUris) throws URISyntaxException, StorageException { - Utility.assertNotNull("completeUri", completeUri); - - if (!completeUri.isAbsolute()) { - final String errorMessage = String.format( - "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", - completeUri.toString()); - throw new IllegalArgumentException(errorMessage); - } - - this.uri = PathUtility.stripURIQueryAndFragment(completeUri); - - final HashMap queryParameters = PathUtility.parseQueryString(completeUri.getQuery()); - final StorageCredentialsSharedAccessSignature sasCreds = SharedAccessSignatureHelper - .parseQuery(queryParameters); - - if (sasCreds == null) { - return; - } - - final Boolean sameCredentials = existingClient == null ? false : Utility.areCredentialsEqual(sasCreds, - existingClient.getCredentials()); - - if (existingClient == null || !sameCredentials) { - this.blobServiceClient = new CloudBlobClient(new URI(PathUtility.getServiceClientBaseAddress(this.getUri(), - usePathStyleUris)), sasCreds); - } - - if (existingClient != null && !sameCredentials) { - this.blobServiceClient - .setPageBlobStreamWriteSizeInBytes(existingClient.getPageBlobStreamWriteSizeInBytes()); - this.blobServiceClient.setSingleBlobPutThresholdInBytes(existingClient.getSingleBlobPutThresholdInBytes()); - this.blobServiceClient.setStreamMinimumReadSizeInBytes(existingClient.getStreamMinimumReadSizeInBytes()); - this.blobServiceClient.setWriteBlockSizeInBytes(existingClient.getWriteBlockSizeInBytes()); - this.blobServiceClient.setConcurrentRequestCount(existingClient.getConcurrentRequestCount()); - this.blobServiceClient.setDirectoryDelimiter(existingClient.getDirectoryDelimiter()); - this.blobServiceClient.setRetryPolicyFactory(existingClient.getRetryPolicyFactory()); - this.blobServiceClient.setTimeoutInMs(existingClient.getTimeoutInMs()); - } - } - - void updatePropertiesFromResponse(HttpURLConnection request) { - String tempStr = request.getHeaderField(Constants.HeaderConstants.ETAG); - - // ETag - if (!Utility.isNullOrEmpty(tempStr)) { - this.getProperties().setEtag(tempStr); - } - - // Last Modified - if (0 != request.getLastModified()) { - final Calendar lastModifiedCalendar = Calendar.getInstance(Utility.LOCALE_US); - lastModifiedCalendar.setTimeZone(Utility.UTC_ZONE); - lastModifiedCalendar.setTime(new Date(request.getLastModified())); - this.getProperties().setLastModified(lastModifiedCalendar.getTime()); - } - } - - /** - * Sets the metadata for the container. - * - * @param metadata - * A java.util.HashMap object that represents the metadata being assigned to the container. - */ - public void setMetadata(final HashMap metadata) { - this.metadata = metadata; - } - - /** - * Sets the name of the container. - * - * @param name - * A String that represents the name being assigned to the container. - */ - protected void setName(final String name) { - this.name = name; - } - - /** - * Sets the properties for the container. - * - * @param properties - * A {@link BlobContainerProperties} object that represents the properties being assigned to the - * container. - */ - protected void setProperties(final BlobContainerProperties properties) { - this.properties = properties; - } - - /** - * Sets the URI of the container. - * - * @param uri - * A java.net.URI object that represents the URI being assigned to the container. - */ - protected void setUri(final URI uri) { - this.uri = uri; - } - - /** - * Uploads the container's metadata. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadMetadata() throws StorageException { - this.uploadMetadata(null, null); - } - - /** - * Uploads the container's metadata using the specified request options and operation context. - * - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadMetadata(BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = ContainerRequest.setMetadata(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - ContainerRequest.addMetadata(request, container.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } - - container.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - - } - - /** - * Uploads the container's permissions. - * - * @param permissions - * A {@link BlobContainerPermissions} object that represents the permissions to upload. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadPermissions(final BlobContainerPermissions permissions) throws StorageException { - this.uploadPermissions(permissions, null, null); - } - - /** - * Uploads the container's permissions using the specified request options and operation context. - * - * @param permissions - * A {@link BlobContainerPermissions} object that represents the permissions to upload. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadPermissions(final BlobContainerPermissions permissions, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlobContainer container, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = ContainerRequest.setAcl(container.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), permissions.getPublicAccess(), opContext); - - final StringWriter outBuffer = new StringWriter(); - - ContainerRequest.writeSharedAccessIdentifiersToStream(permissions.getSharedAccessPolicies(), outBuffer); - - final byte[] aclBytes = outBuffer.toString().getBytes("UTF8"); - client.getCredentials().signRequest(request, aclBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(aclBytes); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - } - - container.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java deleted file mode 100644 index 10e90f9193d26..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java +++ /dev/null @@ -1,466 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.EnumSet; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; -import com.microsoft.windowsazure.services.core.storage.ResultSegment; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Represents a virtual directory of blobs, designated by a delimiter character. - *

- * Containers, which are encapsulated as {@link CloudBlobContainer} objects, hold directories, and directories hold - * block blobs and page blobs. Directories can also contain sub-directories. - */ -public final class CloudBlobDirectory implements ListBlobItem { - - /** - * Holds the Blobs container Reference. - */ - private CloudBlobContainer container; - - /** - * Represents the blob's directory. - */ - protected CloudBlobDirectory parent; - - /** - * Represents the blob client. - */ - protected CloudBlobClient blobServiceClient; - - /** - * Holds the URI of the directory. - */ - private final URI uri; - - /** - * Holds the prefix for the directory. - */ - private String prefix; - - /** - * Creates an instance of the CloudBlobDirectory class using the specified address and client. - * - * @param relativeAddress - * A String that represents the blob directory's relative address. - * @param client - * A {@link CloudBlobClient} object that represents the associated service client. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - protected CloudBlobDirectory(String relativeAddress, final CloudBlobClient client) throws URISyntaxException, - StorageException { - Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); - Utility.assertNotNull("client", client); - - this.blobServiceClient = client; - - if (this.blobServiceClient.getDirectoryDelimiter() != null - && !relativeAddress.endsWith(this.blobServiceClient.getDirectoryDelimiter())) { - relativeAddress = relativeAddress.concat(this.blobServiceClient.getDirectoryDelimiter()); - } - - this.uri = PathUtility.appendPathToUri(this.blobServiceClient.getEndpoint(), relativeAddress); - } - - /** - * Creates an instance of the CloudBlobDirectory class using the specified address, directory parent, - * and client. - * - * @param uri - * A String that represents the blob directory's address. - * @param parent - * A CloudBlobDirectory object that represents the parent directory, if applicable. - * @param client - * A {@link CloudBlobClient} object that represents the associated service client. - */ - protected CloudBlobDirectory(final URI uri, final CloudBlobDirectory parent, final CloudBlobClient client) { - Utility.assertNotNull("uri", uri); - Utility.assertNotNull("client", client); - - this.blobServiceClient = client; - this.uri = uri; - this.parent = parent; - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri) throws URISyntaxException, - StorageException { - return this.getBlockBlobReference(blobAddressUri, null); - } - - /** - * Returns a reference to a {@link CloudBlockBlob} object that represents a block blob in this directory, using the - * specified snapshot ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified block blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlockBlob getBlockBlobReference(final String blobAddressUri, final String snapshotID) - throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri, - this.blobServiceClient.getDirectoryDelimiter()); - - final CloudBlockBlob retBlob = new CloudBlockBlob(address, snapshotID, this.blobServiceClient); - retBlob.setContainer(this.container); - return retBlob; - } - - /** - * Returns the container for this directory. - * - * @return A {@link CloudBlobContainer} that represents the container for this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @Override - public CloudBlobContainer getContainer() throws StorageException, URISyntaxException { - if (this.container == null) { - final URI containerURI = PathUtility.getContainerURI(this.uri, this.blobServiceClient.isUsePathStyleUris()); - this.container = new CloudBlobContainer(containerURI, this.blobServiceClient); - } - - return this.container; - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri) throws URISyntaxException, StorageException { - return this.getPageBlobReference(blobAddressUri, null); - } - - /** - * Returns a reference to a {@link CloudPageBlob} object that represents a page blob in the directory, using the - * specified snapshot ID. - * - * @param blobAddressUri - * A String that represents the name of the blob, or the absolute URI to the blob. - * @param snapshotID - * A String that represents the snapshot ID of the blob. - * - * @return A {@link CloudBlockBlob} object that represents a reference to the specified page blob. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudPageBlob getPageBlobReference(final String blobAddressUri, final String snapshotID) - throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("blobAddressUri", blobAddressUri); - - final URI address = PathUtility.appendPathToUri(this.uri, blobAddressUri, - this.blobServiceClient.getDirectoryDelimiter()); - - final CloudPageBlob retBlob = new CloudPageBlob(address, snapshotID, this.blobServiceClient); - retBlob.setContainer(this.container); - - return retBlob; - } - - /** - * Returns the parent directory of this directory. - * - * @return A {@link CloudBlobDirectory} object that represents the parent of this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @Override - public CloudBlobDirectory getParent() throws URISyntaxException, StorageException { - if (this.parent == null) { - final URI parentURI = PathUtility.getParentAddress(this.uri, - this.blobServiceClient.getDirectoryDelimiter(), this.blobServiceClient.isUsePathStyleUris()); - this.parent = new CloudBlobDirectory(parentURI, null, this.blobServiceClient); - } - return this.parent; - } - - /** - * Returns the prefix for this directory. - * - * @return A String that represents the prefix for this directory. - * - * @throws StorageException - * If a storage service error occurred. - */ - protected String getPrefix() throws StorageException { - if (this.prefix == null) { - try { - final String containerUri = this.getContainer().getUri().toString().concat("/"); - this.prefix = Utility.safeRelativize(new URI(containerUri), this.uri); - } - catch (final URISyntaxException e) { - final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); - throw wrappedUnexpectedException; - } - } - - return this.prefix; - } - - /** - * Returns the Blob service client associated with this directory. - * - * @return An {@link CloudBlobClient} object that represents the service client associated with the directory. - */ - public CloudBlobClient getServiceClient() { - return this.blobServiceClient; - } - - /** - * Returns a reference to a virtual blob directory beneath this directory. - * - * @param relativeAddress - * A String that represents the name of the virtual blob directory, or the absolute URI to - * the virtual blob directory. - * - * @return A CloudBlobDirectory object that represents a virtual blob directory beneath this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudBlobDirectory getSubDirectoryReference(final String relativeAddress) throws StorageException, - URISyntaxException { - Utility.assertNotNullOrEmpty("relativeAddress", relativeAddress); - - final URI address = PathUtility.appendPathToUri(this.uri, relativeAddress, - this.blobServiceClient.getDirectoryDelimiter()); - - return new CloudBlobDirectory(address, this, this.blobServiceClient); - } - - /** - * Returns the URI for this directory. - * - * @return A java.net.URI object that represents the URI for this directory. - */ - @Override - public URI getUri() { - return this.uri; - } - - /** - * Returns an enumerable collection of blob items for the directory. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items in this - * container. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public Iterable listBlobs() throws StorageException, URISyntaxException { - return this.getContainer().listBlobs(this.getPrefix()); - } - - /** - * Returns an enumerable collection of blob items whose names begin with the specified prefix for the directory. - * - * @param prefix - * A String that represents the blob name prefix. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin - * with the specified prefix in this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public Iterable listBlobs(String prefix) throws URISyntaxException, StorageException { - prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobs(this.getPrefix().concat(prefix)); - } - - /** - * Returns an enumerable collection of blob items whose names begin with the specified prefix, using the specified - * flat or hierarchical option, listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the blob name. - * @param useFlatBlobListing - * true to indicate that the returned list will be flat; false to indicate that - * the returned list will be hierarchical. - * @param listingDetails - * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate - * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always - * returned. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link ListBlobItem} objects that represent the block items whose names begin - * with the specified prefix in this directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public Iterable listBlobs(String prefix, final boolean useFlatBlobListing, - final EnumSet listingDetails, final BlobRequestOptions options, - final OperationContext opContext) throws URISyntaxException, StorageException { - prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobs(this.getPrefix().concat(prefix), useFlatBlobListing, listingDetails, - options, opContext); - } - - /** - * Returns a result segment of an enumerable collection of blob items in the directory. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the blob items in the directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented() throws StorageException, URISyntaxException { - return this.getContainer().listBlobsSegmented(this.getPrefix()); - } - - /** - * Returns a result segment containing a collection of blob items whose names begin with the specified prefix. - * - * @param prefix - * A String that represents the prefix of the blob name. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the blob items whose names begin with the specified prefix in - * the directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented(String prefix) throws StorageException, URISyntaxException { - prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix)); - } - - /** - * Returns a result segment containing a collection of blob items whose names begin with the specified prefix, using - * the specified flat or hierarchical option, listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the blob name. - * @param useFlatBlobListing - * true to indicate that the returned list will be flat; false to indicate that - * the returned list will be hierarchical. - * @param listingDetails - * A java.util.EnumSet object that contains {@link BlobListingDetails} values that indicate - * whether snapshots, metadata, and/or uncommitted blocks are returned. Committed blocks are always - * returned. - * @param maxResults - * The maximum number of results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a continuation token returned by a previous - * listing operation. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link ResultSegment} object that contains a segment of the enumerable collection of - * {@link ListBlobItem} objects that represent the block items whose names begin with the specified prefix - * in the directory. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - @DoesServiceRequest - public ResultSegment listBlobsSegmented(String prefix, final boolean useFlatBlobListing, - final EnumSet listingDetails, final int maxResults, - final ResultContinuation continuationToken, final BlobRequestOptions options, - final OperationContext opContext) throws StorageException, URISyntaxException { - prefix = prefix == null ? Constants.EMPTY_STRING : prefix; - return this.getContainer().listBlobsSegmented(this.getPrefix().concat(prefix), useFlatBlobListing, - listingDetails, maxResults, continuationToken, options, opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java deleted file mode 100644 index f0b6706e07398..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ /dev/null @@ -1,610 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.util.ArrayList; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * Represents a blob that is uploaded as a set of blocks. - * - */ -public final class CloudBlockBlob extends CloudBlob { - - /** - * Creates an instance of the CloudBlockBlob class by copying values from another cloud block blob. - * - * @param otherBlob - * A CloudBlockBlob object that represents the block blob to copy. - * - * @throws StorageException - * If a storage service error occurs. - */ - public CloudBlockBlob(final CloudBlockBlob otherBlob) throws StorageException { - super(otherBlob); - } - - /** - * Creates an instance of the CloudBlockBlob class using the specified relative URI and storage service - * client. - * - * @param uri - * A java.net.URI object that represents the relative URI to the blob, beginning with the - * container name. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudBlockBlob(final URI uri, final CloudBlobClient client) throws StorageException { - super(BlobType.BLOCK_BLOB, uri, client); - } - - /** - * Creates an instance of the CloudBlockBlob class using the specified relative URI, storage service - * client and container. - * - * @param uri - * A java.net.URI object that represents the relative URI to the blob. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * @param container - * A {@link CloudBlobContainer} object that represents the container to use for the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudBlockBlob(final URI uri, final CloudBlobClient client, final CloudBlobContainer container) - throws StorageException { - super(BlobType.BLOCK_BLOB, uri, client, container); - } - - /** - * Creates an instance of the CloudBlockBlob class using the specified relative URI, snapshot ID, and - * storage service client. - * - * @param uri - * A java.net.URI object that represents the relative URI to the blob. - * @param snapshotID - * A String that represents the snapshot version, if applicable. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudBlockBlob(final URI uri, final String snapshotID, final CloudBlobClient client) throws StorageException { - super(BlobType.BLOCK_BLOB, uri, snapshotID, client); - } - - /** - * Commits a block list to the storage service. - * - * @param blockList - * An enumerable collection of BlockEntry objects that represents the list block items being - * committed. The size field is ignored. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void commitBlockList(final Iterable blockList) throws StorageException { - this.commitBlockList(blockList, null, null, null); - } - - /** - * Commits a block list to the storage service using the specified lease ID, request options, and operation context. - * - * @param blockList - * An enumerable collection of BlockEntry objects that represents the list block items being - * committed. The size field is ignored. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void commitBlockList(final Iterable blockList, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.putBlockList(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blob.properties, accessCondition, blobOptions, opContext); - BlobRequest.addMetadata(request, blob.metadata, opContext); - - // Potential optimization, we can write this stream outside of - // the StorageOperation, so it wont need to be rewritten for each retry. Because it would - // need to be a final member this would require refactoring into an internal method which - // receives the block list bytestream as a final param. - - final byte[] blockListBytes = BlobRequest.writeBlockListToStream(blockList, opContext); - - final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(blockListBytes); - - final StreamMd5AndLength descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); - - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - - client.getCredentials().signRequest(request, descriptor.getLength()); - Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), - false, false, null, opContext); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Downloads the committed block list from the block blob. - *

- * The committed block list includes the list of blocks that have been successfully committed to the block blob. The - * list of committed blocks is returned in the same order that they were committed to the blob. No block may appear - * more than once in the committed block list. - * - * @return An ArrayList object of BlockEntry objects that represent the committed list - * block items downloaded from the block blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ArrayList downloadBlockList() throws StorageException { - return this.downloadBlockList(BlockListingFilter.COMMITTED, null, null, null); - } - - /** - * Downloads the block list from the block blob using the specified block listing filter, request options, and - * operation context. - * - * @param blockListingFilter - * A {@link BlockListingFilter} value that specifies whether to download committed blocks, uncommitted - * blocks, or all blocks. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An ArrayList object of BlockEntry objects that represent the list block items - * downloaded from the block blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ArrayList downloadBlockList(final BlockListingFilter blockListingFilter, - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException { - Utility.assertNotNull("blockListingFilter", blockListingFilter); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - - final StorageOperation> impl = new StorageOperation>( - options) { - - @Override - public ArrayList execute(final CloudBlobClient client, final CloudBlob blob, - final OperationContext opContext) throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.getBlockList(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, blockListingFilter, accessCondition, - blobOptions, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - final GetBlockListResponse response = new GetBlockListResponse(request.getInputStream()); - return response.getBlocks(); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Creates and opens an output stream to write data to the block blob. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - public BlobOutputStream openOutputStream() throws StorageException { - return this.openOutputStream(null, null, null); - } - - /** - * Creates and opens an output stream to write data to the block blob using the specified request options and - * operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - public BlobOutputStream openOutputStream(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - return new BlobOutputStream(this, accessCondition, options, opContext); - } - - /** - * Uploads the source stream data to the block blob. - * - * @param sourceStream - * An InputStream object that represents the input stream to write to the block blob. - * @param length - * The length, in bytes, of the stream data, or -1 if unknown. - * - * @throws IOException - * If an I/O error occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - @DoesServiceRequest - public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException { - this.upload(sourceStream, length, null, null, null); - } - - /** - * Uploads the source stream data to the blob, using the specified lease ID, request options, and operation context. - * - * @param sourceStream - * An InputStream object that represents the input stream to write to the block blob. - * @param length - * The length, in bytes, of the stream data, or -1 if unknown. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O error occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - @DoesServiceRequest - public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { - if (length < -1) { - throw new IllegalArgumentException( - "Invalid stream length, specify -1 for unkown length stream, or a positive number of bytes"); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.blobServiceClient); - // Mark sourceStream for current position. - sourceStream.mark(Integer.MAX_VALUE); - - StreamMd5AndLength descriptor = new StreamMd5AndLength(); - descriptor.setLength(length); - - // If the stream is rewindable and the length is unknown or we need to - // set md5, then analyze the stream. - // Note this read will abort at - // serviceClient.getSingleBlobPutThresholdInBytes() bytes and return - // -1 as length in which case we will revert to using a stream as it is - // over the single put threshold. - if (sourceStream.markSupported() && (length < 0 || options.getStoreBlobContentMD5())) { - // If the stream is of unknown length or we need to calculate - // the MD5, then we we need to read the stream contents first - - descriptor = Utility.analyzeStream(sourceStream, length, - this.blobServiceClient.getSingleBlobPutThresholdInBytes(), true, options.getStoreBlobContentMD5()); - - if (descriptor.getMd5() != null && options.getStoreBlobContentMD5()) { - this.properties.setContentMD5(descriptor.getMd5()); - } - } - - // If the stream is rewindable, and the length is known and less than - // threshold the upload in a single put, otherwise use a stream. - if (sourceStream.markSupported() && descriptor.getLength() != -1 - && descriptor.getLength() < this.blobServiceClient.getSingleBlobPutThresholdInBytes()) { - this.uploadFullBlob(sourceStream, descriptor.getLength(), accessCondition, options, opContext); - } - else { - final BlobOutputStream writeStream = this.openOutputStream(accessCondition, options, opContext); - writeStream.write(sourceStream, length); - writeStream.close(); - } - } - - /** - * Uploads a block to the block blob, using the specified block ID and lease ID. - * - * @param blockId - * A String that represents the Base-64 encoded block ID. Note for a given blob the length - * of all Block IDs must be identical. - * @param sourceStream - * An InputStream object that represents the input stream to write to the block blob. - * @param length - * The length, in bytes, of the stream data, or -1 if unknown. - * @throws IOException - * If an I/O error occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadBlock(final String blockId, final InputStream sourceStream, final long length) - throws StorageException, IOException { - this.uploadBlock(blockId, sourceStream, length, null, null, null); - } - - /** - * Uploads a block to the block blob, using the specified block ID, lease ID, request options, and operation - * context. - * - * @param blockId - * A String that represents the Base-64 encoded block ID. Note for a given blob the length - * of all Block IDs must be identical. - * - * @param sourceStream - * An InputStream object that represents the input stream to write to the block blob. - * @param length - * The length, in bytes, of the stream data, or -1 if unknown. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O error occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadBlock(final String blockId, final InputStream sourceStream, final long length, - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException, IOException { - if (length < -1) { - throw new IllegalArgumentException( - "Invalid stream length, specify -1 for unkown length stream, or a positive number of bytes"); - } - - if (length > 4 * Constants.MB) { - throw new IllegalArgumentException( - "Invalid stream length, length must be less than or equal to 4 MB in size."); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - // Assert block length - if (Utility.isNullOrEmpty(blockId) || !Base64.validateIsBase64String(blockId)) { - throw new IllegalArgumentException("Invalid blockID, BlockID must be a valid Base64 String."); - } - - // Mark sourceStream for current position. - sourceStream.mark(Integer.MAX_VALUE); - - InputStream bufferedStreamReference = sourceStream; - StreamMd5AndLength descriptor = new StreamMd5AndLength(); - descriptor.setLength(length); - - if (!sourceStream.markSupported()) { - // needs buffering - final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - descriptor = Utility.writeToOutputStream(sourceStream, byteStream, length, false, - options.getUseTransactionalContentMD5(), null, opContext); - - bufferedStreamReference = new ByteArrayInputStream(byteStream.toByteArray()); - } - else if (length < 0 || options.getUseTransactionalContentMD5()) { - // If the stream is of unknown length or we need to calculate the - // MD5, then we we need to read - // the stream contents first - - descriptor = Utility - .analyzeStream(sourceStream, length, -1L, true, options.getUseTransactionalContentMD5()); - } - - if (descriptor.getLength() > 4 * Constants.MB) { - throw new IllegalArgumentException( - "Invalid stream length, length must be less than or equal to 4 MB in size."); - } - - this.uploadBlockInternal(blockId, descriptor.getMd5(), bufferedStreamReference, descriptor.getLength(), - accessCondition, options, opContext); - } - - /** - * Uploads a block of the blob to the server. - * - * @param blockId - * the Base64 Encoded Block ID - * @param md5 - * the MD5 to use if it will be set. - * @param sourceStream - * the InputStream to read from - * @param length - * the OutputStream to write the blob to. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * An object that specifies any additional options for the request - * @param opContext - * an object used to track the execution of the operation - * @throws StorageException - * If a storage service error occurred. - * @throws IOException - */ - @DoesServiceRequest - private void uploadBlockInternal(final String blockId, final String md5, final InputStream sourceStream, - final long length, final AccessCondition accessCondition, final BlobRequestOptions options, - final OperationContext opContext) throws StorageException, IOException { - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.putBlock(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blockId, accessCondition, blobOptions, opContext); - - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); - } - - client.getCredentials().signRequest(request, length); - - Utility.writeToOutputStream(sourceStream, request.getOutputStream(), length, true, false, null, - opContext); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java deleted file mode 100644 index 145bc4a30a9b8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ /dev/null @@ -1,666 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; - -import com.microsoft.windowsazure.services.core.storage.AccessCondition; -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * Represents a Windows Azure page blob. - * - */ -public final class CloudPageBlob extends CloudBlob { - - /** - * Creates an instance of the CloudPageBlob class by copying values from another page blob. - * - * @param otherBlob - * A CloudPageBlob object that represents the page blob to copy. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudPageBlob(final CloudPageBlob otherBlob) throws StorageException { - super(otherBlob); - } - - /** - * Creates an instance of the CloudPageBlob class using the specified URI and cloud blob client. - * - * @param uri - * A java.net.URI object that represents the absolute URI to the blob, beginning with the - * container name. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudPageBlob(final URI uri, final CloudBlobClient client) throws StorageException { - super(BlobType.PAGE_BLOB, uri, client); - } - - /** - * Creates an instance of the CloudPageBlob class using the specified URI, cloud blob client, and cloud - * blob container. - * - * @param uri - * A java.net.URI object that represents the relative URI to the blob, beginning with the - * container name. - * @param client - * A {@link CloudBlobClient} object that specifies the endpoint for the Blob service. - * @param container - * A {@link CloudBlobContainer} object that represents the container to use for the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudPageBlob(final URI uri, final CloudBlobClient client, final CloudBlobContainer container) - throws StorageException { - super(BlobType.PAGE_BLOB, uri, client, container); - } - - /** - * Creates an instance of the CloudPageBlob class using the specified URI, snapshot ID, and cloud blob - * client. - * - * @param uri - * A java.net.URI object that represents the absolute URI to the blob, beginning with the - * container name. - * @param snapshotID - * A String that represents the snapshot version, if applicable. - * @param client - * A {@link CloudBlobContainer} object that represents the container to use for the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - public CloudPageBlob(final URI uri, final String snapshotID, final CloudBlobClient client) throws StorageException { - super(BlobType.PAGE_BLOB, uri, snapshotID, client); - } - - /** - * Clears pages from a page blob. - *

- * Calling clearPages releases the storage space used by the specified pages. Pages that have been - * cleared are no longer tracked as part of the page blob, and no longer incur a charge against the storage account. - * - * @param offset - * The offset, in bytes, at which to begin clearing pages. This value must be a multiple of 512. - * @param length - * The length, in bytes, of the data range to be cleared. This value must be a multiple of 512. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void clearPages(final long offset, final long length) throws StorageException, IOException { - this.clearPages(offset, length, null, null, null); - } - - /** - * Clears pages from a page blob using the specified lease ID, request options, and operation context. - *

- * Calling clearPages releases the storage space used by the specified pages. Pages that have been - * cleared are no longer tracked as part of the page blob, and no longer incur a charge against the storage account. - * - * @param offset - * The offset, in bytes, at which to begin clearing pages. This value must be a multiple of 512. - * @param length - * The length, in bytes, of the data range to be cleared. This value must be a multiple of 512. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void clearPages(final long offset, final long length, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { - if (offset % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page start offset must be multiple of 512!"); - } - - if (length % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page data must be multiple of 512!"); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - final PageProperties pageProps = new PageProperties(); - pageProps.setPageOperation(PageOperationType.CLEAR); - pageProps.getRange().setStartOffset(offset); - pageProps.getRange().setEndOffset(offset + length - 1); - - this.putPagesInternal(pageProps, null, length, null, accessCondition, options, opContext); - } - - /** - * Creates a page blob. - * - * @param length - * The size, in bytes, of the page blob. - * - * @throws IllegalArgumentException - * If the length is not a multiple of 512. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void create(final long length) throws StorageException { - this.create(length, null, null, null); - } - - /** - * Creates a page blob using the specified request options and operation context. - * - * @param length - * The size, in bytes, of the page blob. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IllegalArgumentException - * If the length is not a multiple of 512. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void create(final long length, final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - if (length % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page blob length must be multiple of 512."); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.put(blob.getTransformedAddress(opContext), this - .getRequestOptions().getTimeoutIntervalInMs(), blob.properties, BlobType.PAGE_BLOB, length, - accessCondition, blobOptions, opContext); - - BlobRequest.addMetadata(request, blob.metadata, opContext); - - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Returns a collection of page ranges and their starting and ending byte offsets. - *

- * The start and end byte offsets for each page range are inclusive. - * - * @return An ArrayList object that represents the set of page ranges and their starting and ending - * byte offsets. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ArrayList downloadPageRanges() throws StorageException { - return this.downloadPageRanges(null, null, null); - } - - /** - * Returns a collection of page ranges and their starting and ending byte offsets using the specified request - * options and operation context. - * - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An ArrayList object that represents the set of page ranges and their starting and ending - * byte offsets. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public ArrayList downloadPageRanges(final AccessCondition accessCondition, BlobRequestOptions options, - OperationContext opContext) throws StorageException { - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - final StorageOperation> impl = new StorageOperation>( - options) { - - @Override - public ArrayList execute(final CloudBlobClient client, final CloudBlob blob, - final OperationContext opContext) throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.getPageRanges(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), blob.snapshotID, accessCondition, blobOptions, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - final GetPageRangesResponse response = new GetPageRangesResponse(request.getInputStream()); - return response.getPageRanges(); - } - }; - - return ExecutionEngine.executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Opens an input stream object to write data to the page blob. - * - * @param length - * The length, in bytes, of the stream to create. This value must be a multiple of 512. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public BlobOutputStream openOutputStream(final long length) throws StorageException { - return this.openOutputStream(length, null, null, null); - } - - /** - * Opens an input stream object to write data to the page blob, using the specified lease ID, request options and - * operation context. - * - * @param length - * The length, in bytes, of the stream to create. This value must be a multiple of 512. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link BlobOutputStream} object used to write data to the blob. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public BlobOutputStream openOutputStream(final long length, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - if (options.getStoreBlobContentMD5()) { - throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); - } - - return new BlobOutputStream(this, length, accessCondition, options, opContext); - } - - /** - * Used for both uploadPages and clearPages. - * - * @param pageProperties - * The page properties. - * @param data - * The data to write. - * @param length - * The number of bytes to write. - * @param md5 - * the MD5 hash for the data. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - private void putPagesInternal(final PageProperties pageProperties, final byte[] data, final long length, - final String md5, final AccessCondition accessCondition, final BlobRequestOptions options, - final OperationContext opContext) throws StorageException { - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudBlobClient client, final CloudBlob blob, final OperationContext opContext) - throws Exception { - final BlobRequestOptions blobOptions = (BlobRequestOptions) this.getRequestOptions(); - - final HttpURLConnection request = BlobRequest.putPage(blob.getTransformedAddress(opContext), - blobOptions.getTimeoutIntervalInMs(), pageProperties, accessCondition, blobOptions, opContext); - - if (pageProperties.getPageOperation() == PageOperationType.UPDATE) { - if (blobOptions.getUseTransactionalContentMD5()) { - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, md5); - } - - client.getCredentials().signRequest(request, length); - request.getOutputStream().write(data); - } - else { - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - blob.updatePropertiesFromResponse(request); - return null; - } - }; - - ExecutionEngine - .executeWithRetry(this.blobServiceClient, this, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Uploads the source stream data to the page blob. - * - * @param sourceStream - * An IntputStream object to read from. - * @param length - * The length, in bytes, of the stream data, must be non zero and a multiple of 512. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - @DoesServiceRequest - public void upload(final InputStream sourceStream, final long length) throws StorageException, IOException { - this.upload(sourceStream, length, null, null, null); - } - - /** - * Uploads the source stream data to the page blob using the specified lease ID, request options, and operation - * context. - * - * @param sourceStream - * An IntputStream object to read from. - * @param length - * The length, in bytes, of the stream data. This must be great than zero and a multiple of 512. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - @DoesServiceRequest - public void upload(final InputStream sourceStream, final long length, final AccessCondition accessCondition, - BlobRequestOptions options, OperationContext opContext) throws StorageException, IOException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - if (length <= 0 || length % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page data must be multiple of 512!"); - } - - if (options.getStoreBlobContentMD5()) { - throw new IllegalArgumentException("Blob Level MD5 is not supported for PageBlob"); - } - - // Mark sourceStream for current position. - sourceStream.mark(Integer.MAX_VALUE); - - if (length <= 4 * Constants.MB) { - this.create(length, accessCondition, options, opContext); - this.uploadPages(sourceStream, 0, length, accessCondition, options, opContext); - } - else { - final OutputStream streamRef = this.openOutputStream(length, accessCondition, options, opContext); - Utility.writeToOutputStream(sourceStream, streamRef, length, false, false, null, opContext); - streamRef.close(); - } - } - - /** - * Uploads a range of contiguous pages, up to 4 MB in size, at the specified offset in the page blob. - * - * @param sourceStream - * An InputStream object that represents the input stream to write to the page blob. - * @param offset - * The offset, in number of bytes, at which to begin writing the data. This value must be a multiple of - * 512. - * @param length - * The length, in bytes, of the data to write. This value must be a multiple of 512. - * - * @throws IllegalArgumentException - * If the offset or length are not multiples of 512, or if the length is greater than 4 MB. - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadPages(final InputStream sourceStream, final long offset, final long length) - throws StorageException, IOException { - this.uploadPages(sourceStream, offset, length, null, null, null); - } - - /** - * Uploads a range of contiguous pages, up to 4 MB in size, at the specified offset in the page blob, using the - * specified lease ID, request options, and operation context. - * - * @param sourceStream - * An InputStream object that represents the input stream to write to the page blob. - * @param offset - * The offset, in number of bytes, at which to begin writing the data. This value must be a multiple of - * 512. - * @param length - * The length, in bytes, of the data to write. This value must be a multiple of 512. - * @param accessCondition - * An {@link AccessCondition} object that represents the access conditions for the blob. - * @param options - * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws IllegalArgumentException - * If the offset or length are not multiples of 512, or if the length is greater than 4 MB. - * @throws IOException - * If an I/O exception occurred. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadPages(final InputStream sourceStream, final long offset, final long length, - final AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext) - throws StorageException, IOException { - - if (offset % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page start offset must be multiple of 512!"); - } - - if (length % BlobConstants.PAGE_SIZE != 0) { - throw new IllegalArgumentException("Page data must be multiple of 512!"); - } - - if (length > 4 * Constants.MB) { - throw new IllegalArgumentException("Max write size is 4MB. Please specify a smaller range."); - } - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new BlobRequestOptions(); - } - - options.applyDefaults(this.blobServiceClient); - - final PageProperties pageProps = new PageProperties(); - pageProps.setPageOperation(PageOperationType.UPDATE); - pageProps.getRange().setStartOffset(offset); - pageProps.getRange().setEndOffset(offset + length - 1); - final byte[] data = new byte[(int) length]; - String md5 = null; - - int count = 0; - long total = 0; - while (total < length) { - count = sourceStream.read(data, 0, (int) Math.min(length - total, Integer.MAX_VALUE)); - total += count; - } - - if (options.getUseTransactionalContentMD5()) { - try { - final MessageDigest digest = MessageDigest.getInstance("MD5"); - digest.update(data, 0, data.length); - md5 = Base64.encode(digest.digest()); - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - this.putPagesInternal(pageProps, data, length, md5, accessCondition, options, opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java deleted file mode 100644 index 4b5740909ef91..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Specifies which details to include when listing the containers in this storage account. - * - */ -public enum ContainerListingDetails { - /** - * Specifies including all available details. - */ - ALL(1), - - /** - * Specifies including container metadata. - */ - METADATA(1), - - /** - * Specifies including no additional details. - */ - NONE(0); - - /** - * Returns the value of this enum. - */ - public int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - ContainerListingDetails(final int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java deleted file mode 100644 index 1615cebeac00c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java +++ /dev/null @@ -1,401 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.IOException; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.HashMap; -import java.util.Map.Entry; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.Credentials; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; - -/** - * RESERVED FOR INTERNAL USE. A class used to generate requests for contianer objects. - * - */ -final class ContainerRequest { - /** - * Adds user-defined metadata to the request as one or more name-value pairs. - * - * @param request - * The web request. - * @param metadata - * The user-defined metadata. - * */ - public static void addMetadata(final HttpURLConnection request, final HashMap metadata, - final OperationContext opContext) { - BaseRequest.addMetadata(request, metadata, opContext); - } - - /** - * Adds user-defined metadata to the request as a single name-value pair. - * - * @param request - * The web request. - * @param name - * The metadata name. - * @param value - * The metadata value. - * */ - public static void addMetadata(final HttpURLConnection request, final String name, final String value, - final OperationContext opContext) { - BaseRequest.addMetadata(request, name, value, opContext); - } - - /** - * Constructs a web request to create a new container. Sign with 0 length. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * @throws IllegalArgumentException - */ - public static HttpURLConnection create(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); - return BaseRequest.create(uri, timeout, containerBuilder, opContext); - } - - /** - * Creates the web request. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @param query - * The query builder to use. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * @throws IllegalArgumentException - */ - private static HttpURLConnection createURLConnection(final URI uri, final int timeout, final UriQueryBuilder query, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - return BaseRequest.createURLConnection(uri, timeout, query, opContext); - } - - /** - * Constructs a web request to delete the container and all of blobs within it. Sign with no length specified. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * @throws IllegalArgumentException - */ - public static HttpURLConnection delete(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); - return BaseRequest.delete(uri, timeout, containerBuilder, opContext); - } - - /** - * Constructs a web request to return the ACL for this container. Sign with no length specified. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - */ - public static HttpURLConnection getAcl(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder builder = getContainerUriQueryBuilder(); - builder.add("comp", "acl"); - - final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Gets the container Uri query builder. - * - * A UriQueryBuilder for the container. - * - * @throws StorageException - */ - protected static UriQueryBuilder getContainerUriQueryBuilder() throws StorageException { - final UriQueryBuilder uriBuilder = new UriQueryBuilder(); - try { - uriBuilder.add("restype", "container"); - } - catch (final IllegalArgumentException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - return uriBuilder; - } - - /** - * Constructs a web request to retrieve the container's metadata. Sign with no length specified. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - */ - public static HttpURLConnection getMetadata(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); - return BaseRequest.getMetadata(uri, timeout, containerBuilder, opContext); - } - - /** - * Constructs a web request to return the user-defined metadata for this container. Sign with no length specified. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * */ - public static HttpURLConnection getProperties(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); - return BaseRequest.getProperties(uri, timeout, containerBuilder, opContext); - } - - /** - * Constructs a request to return a listing of all containers in this storage account. Sign with no length - * specified. - * - * @param uri - * The absolute URI for the account. - * @param timeout - * The absolute URI for the account. - * @param listingContext - * A set of parameters for the listing operation. - * @param detailsIncluded - * Additional details to return with the listing. - * @param opContext - * a tracking object for the request - * @return a HttpURLConnection configured for the operation. - * @throws IOException - * @throws URISyntaxException - * @throws StorageException - * @throws IllegalArgumentException - */ - public static HttpURLConnection list(final URI uri, final int timeout, final ListingContext listingContext, - final ContainerListingDetails detailsIncluded, final OperationContext opContext) throws URISyntaxException, - IOException, StorageException { - - final UriQueryBuilder builder = getContainerUriQueryBuilder(); - builder.add("comp", "list"); - - if (listingContext != null) { - if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { - builder.add("prefix", listingContext.getPrefix()); - } - - if (!Utility.isNullOrEmpty(listingContext.getMarker())) { - builder.add("marker", listingContext.getMarker()); - } - - if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { - builder.add("maxresults", listingContext.getMaxResults().toString()); - } - } - - if (detailsIncluded == ContainerListingDetails.ALL || detailsIncluded == ContainerListingDetails.METADATA) { - builder.add("include", "metadata"); - } - - final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Sets the ACL for the container. , Sign with length of aclBytes. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * @param publicAccess - * The type of public access to allow for the container. - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * */ - public static HttpURLConnection setAcl(final URI uri, final int timeout, - final BlobContainerPublicAccessType publicAccess, final OperationContext opContext) throws IOException, - URISyntaxException, StorageException { - final UriQueryBuilder builder = getContainerUriQueryBuilder(); - builder.add("comp", "acl"); - - final HttpURLConnection request = createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("PUT"); - request.setDoOutput(true); - - if (publicAccess != BlobContainerPublicAccessType.OFF) { - request.setRequestProperty(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER, publicAccess.toString().toLowerCase()); - } - - return request; - } - - /** - * Constructs a web request to set user-defined metadata for the container, Sign with 0 Length. - * - * @param uri - * The absolute URI to the container. - * @param timeout - * The server timeout interval. - * - * @return a HttpURLConnection configured for the operation. - * @throws StorageException - * */ - public static HttpURLConnection setMetadata(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - final UriQueryBuilder containerBuilder = getContainerUriQueryBuilder(); - return BaseRequest.setMetadata(uri, timeout, containerBuilder, opContext); - } - - /** - * Signs the request for Shared Key authentication. - * - * @param request - * The web request. - * @param credentials - * The account credentials. - * @throws StorageException - * */ - public static void signRequest(final HttpURLConnection request, final Credentials credentials, - final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { - BaseRequest.signRequestForBlobAndQueue(request, credentials, contentLength, opContext); - } - - /** - * Signs the request for Shared Key Lite authentication. - * - * @param request - * The web request. - * @param credentials - * The account credentials. - * @throws StorageException - * @throws InvalidKeyException - * */ - public static void signRequestForSharedKeyLite(final HttpURLConnection request, final Credentials credentials, - final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { - BaseRequest.signRequestForBlobAndQueueSharedKeyLite(request, credentials, contentLength, opContext); - } - - /** - * Writes a collection of shared access policies to the specified stream in XML format. - * - * @param sharedAccessPolicies - * A collection of shared access policies - * @param outWriter - * an sink to write the output to. - * @throws XMLStreamException - */ - public static void writeSharedAccessIdentifiersToStream( - final HashMap sharedAccessPolicies, final StringWriter outWriter) - throws XMLStreamException { - Utility.assertNotNull("sharedAccessPolicies", sharedAccessPolicies); - Utility.assertNotNull("outWriter", outWriter); - - final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); - final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); - - if (sharedAccessPolicies.keySet().size() > BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS) { - final String errorMessage = String - .format("Too many %d shared access policy identifiers provided. Server does not support setting more than %d on a single container.", - sharedAccessPolicies.keySet().size(), BlobConstants.MAX_SHARED_ACCESS_POLICY_IDENTIFIERS); - - throw new IllegalArgumentException(errorMessage); - } - - // default is UTF8 - xmlw.writeStartDocument(); - xmlw.writeStartElement(BlobConstants.SIGNED_IDENTIFIERS_ELEMENT); - - for (final Entry entry : sharedAccessPolicies.entrySet()) { - final SharedAccessPolicy policy = entry.getValue(); - xmlw.writeStartElement(BlobConstants.SIGNED_IDENTIFIER_ELEMENT); - - // Set the identifier - xmlw.writeStartElement(Constants.ID); - xmlw.writeCharacters(entry.getKey()); - xmlw.writeEndElement(); - - xmlw.writeStartElement(BlobConstants.ACCESS_POLICY); - - // Set the Start Time - xmlw.writeStartElement(BlobConstants.START); - xmlw.writeCharacters(Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime())); - // end Start - xmlw.writeEndElement(); - - // Set the Expiry Time - xmlw.writeStartElement(BlobConstants.EXPIRY); - xmlw.writeCharacters(Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime())); - // end Expiry - xmlw.writeEndElement(); - - // Set the Permissions - xmlw.writeStartElement(BlobConstants.PERMISSION); - xmlw.writeCharacters(SharedAccessPolicy.permissionsToString(policy.getPermissions())); - // end Permission - xmlw.writeEndElement(); - - // end AccessPolicy - xmlw.writeEndElement(); - // end SignedIdentifier - xmlw.writeEndElement(); - } - - // end SignedIdentifiers - xmlw.writeEndElement(); - // end doc - xmlw.writeEndDocument(); - } - - /** - * Private Default Ctor - */ - private ContainerRequest() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java deleted file mode 100644 index 7c78dd518927a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; - -/** - * RESERVED FOR INTERNAL USE. A class used to parse the response from container operations - */ -final class ContainerResponse extends BaseResponse { - - /** - * Gets the ACL for the container from the response. - * - * @param request - * the request object for this operation - * @return the ACL value indicating the public access level for the container - */ - public static String getAcl(final HttpURLConnection request) { - return request.getHeaderField(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER); - } - - /** - * Gets the BlobContainerAttributes from the given request. - * - * @param request - * the request to get attributes from. - * @param usePathStyleUris - * a value indicating if the account is using pathSytleUris. - * @return the BlobContainerAttributes from the given request. - * @throws StorageException - */ - public static BlobContainerAttributes getAttributes(final HttpURLConnection request, final boolean usePathStyleUris) - throws StorageException { - final BlobContainerAttributes containerAttributes = new BlobContainerAttributes(); - URI tempURI; - try { - tempURI = PathUtility.stripURIQueryAndFragment(request.getURL().toURI()); - } - catch (final URISyntaxException e) { - final StorageException wrappedUnexpectedException = Utility.generateNewUnexpectedStorageException(e); - throw wrappedUnexpectedException; - } - - containerAttributes.setUri(tempURI); - containerAttributes.setName(PathUtility.getContainerNameFromUri(tempURI, usePathStyleUris)); - - final BlobContainerProperties containerProperties = containerAttributes.getProperties(); - containerProperties.setEtag(BaseResponse.getEtag(request)); - containerProperties.setLastModified(new Date(request.getLastModified())); - - containerAttributes.setMetadata(getMetadata(request)); - - return containerAttributes; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java deleted file mode 100644 index 254f7dfaa953b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Specifies options when calling delete operations. - */ -public enum DeleteSnapshotsOption { - /** - * Specifies deleting only the blob's snapshots. - */ - DELETE_SNAPSHOTS_ONLY, - - /** - * Specifies deleting the blob and its snapshots. - */ - INCLUDE_SNAPSHOTS, - - /** - * Specifies deleting the blob but not its snapshots. - */ - NONE -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java deleted file mode 100644 index fbc8c3b69c958..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.InputStream; -import java.util.ArrayList; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. A class used to parse a get block list response stream. - */ -final class GetBlockListResponse { - /** - * Holds the ArrayList of CloudBlobs from the response. - */ - private final ArrayList blocks = new ArrayList(); - - /** - * Stores the value indicating if the response has been fully parsed. - */ - private boolean isParsed; - - /** - * Stores the InputStream to read from. - */ - private final InputStream streamRef; - - /** - * Constructs the response from the inputstream. - * - * @param stream - * the inputstream for the response the server returned. - */ - public GetBlockListResponse(final InputStream stream) { - this.streamRef = stream; - } - - /** - * Returns an ArrayList of BlockEntrys for the given block blob. - * - * @return an ArrayList of BlockEntrys for the given block blob. - * @throws XMLStreamException - * @throws StorageException - */ - public ArrayList getBlocks() throws XMLStreamException, StorageException { - if (!this.isParsed) { - this.parseResponse(); - } - - return this.blocks; - } - - /** - * Parses the XML stream. - * - * @throws XMLStreamException - * @throws StorageException - */ - public void parseResponse() throws XMLStreamException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get BlockList Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.BLOCK_LIST_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - if (name.equals(BlobConstants.COMMITTED_BLOCKS_ELEMENT)) { - // Move to block element - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.START_ELEMENT - && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { - this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.COMMITTED)); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.COMMITTED_BLOCKS_ELEMENT); - } - } - else if (name.equals(BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT)) { - // Move to block element - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.START_ELEMENT - && BlobConstants.BLOCK_ELEMENT.equals(xmlr.getName().toString())) { - this.blocks.addAll(BlobDeserializationHelper.readBlobBlocks(xmlr, BlockSearchMode.UNCOMMITTED)); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.UNCOMMITTED_BLOCKS_ELEMENT); - } - } - else if (name.equals(BlobConstants.BLOCK_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { - break; - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - } - - this.isParsed = true; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java deleted file mode 100644 index d6ea710ad400b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.InputStream; -import java.util.ArrayList; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. A class used to parse a get page ranges response stream. - */ -final class GetPageRangesResponse { - /** - * Holds the ArrayList of Page Ranges from the response. - */ - private ArrayList pageRanges = new ArrayList(); - - /** - * Stores the value indicating if the response has been fully parsed. - */ - private boolean isParsed; - - /** - * Stores the InputStream to read from. - */ - private final InputStream streamRef; - - /** - * Constructs the response from the inputstream. - * - * @param stream - * the inputstream for the response the server returned. - */ - public GetPageRangesResponse(final InputStream stream) { - this.streamRef = stream; - } - - /** - * Returns an ArrayList of Page Ranges for the given page blob. - * - * @return an ArrayList of Page Ranges for the given page blob. - * @throws XMLStreamException - * @throws StorageException - */ - public ArrayList getPageRanges() throws XMLStreamException, StorageException { - if (!this.isParsed) { - this.parseResponse(); - } - - return this.pageRanges; - } - - /** - * Parses the XML stream. - * - * @throws XMLStreamException - * @throws StorageException - */ - public void parseResponse() throws XMLStreamException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get BlockList Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, BlobConstants.PAGE_LIST_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (name.equals(BlobConstants.PAGE_RANGE_ELEMENT)) { - this.pageRanges = BlobDeserializationHelper.readPageRanges(xmlr); - } - else if (name.equals(BlobConstants.PAGE_LIST_ELEMENT) && eventType == XMLStreamConstants.END_ELEMENT) { - break; - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - } - - this.isParsed = true; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java deleted file mode 100644 index d096e92e001ce..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.net.URI; -import java.net.URISyntaxException; - -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * Represents an item that may be returned by a blob listing operation. - */ -public interface ListBlobItem { - - /** - * Returns the container for the blob item. - * - * @return A {@link CloudBlobContainer} object that represents the blob item's container. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - CloudBlobContainer getContainer() throws URISyntaxException, StorageException; - - /** - * Returns the parent for the blob item. - * - * @return A {@link CloudBlobDirectory} object that represents the blob item's parent. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is invalid. - */ - CloudBlobDirectory getParent() throws URISyntaxException, StorageException; - - /** - * Returns the URI for the blob item. - * - * @return A java.net.URI object that represents the blob item's URI. - */ - URI getUri(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java deleted file mode 100644 index 9e658d4f54c09..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.InputStream; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.ArrayList; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. A class used to parse a list blobs response stream. - */ -final class ListBlobsResponse { - - /** - * Holds the ArrayList of CloudBlobs from the response. - */ - private ArrayList blobs = new ArrayList(); - - /** - * Stores the value indicating if the response has been fully parsed. - */ - private boolean isParsed; - - /** - * Stores the marker. - */ - private String marker; - - /** - * Stores the max results. - */ - private int maxResults; - - /** - * Stores the next marker. - */ - private String nextMarker; - - /** - * Stores the container prefix. - */ - private String prefix; - - /** - * Stores the InputStream to read from. - */ - private final InputStream streamRef; - - /** - * Stores the blob delimiter. - */ - private String delimiter; - - public ListBlobsResponse(final InputStream stream) { - this.streamRef = stream; - } - - public ArrayList getBlobs(final CloudBlobClient serviceClient, final CloudBlobContainer container) - throws XMLStreamException, StorageException { - if (!this.isParsed) { - this.parseResponse(serviceClient, container); - } - - return this.blobs; - } - - public String getDelimiter() { - return this.delimiter; - } - - public String getMarker() { - return this.marker; - } - - public int getMaxResults() { - return this.maxResults; - } - - public String getNextMarker() { - return this.nextMarker; - } - - public String getPrefix() { - return this.prefix; - } - - public void parseResponse(final CloudBlobClient serviceClient, final CloudBlobContainer container) - throws XMLStreamException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - String tempParseString = null; - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get enumerationResults Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); - this.maxResults = Integer.parseInt(tempParseString); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { - this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { - this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { - this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.DELIMITER_ELEMENT)) { - this.delimiter = Utility.readElementFromXMLReader(xmlr, Constants.DELIMITER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.BLOBS_ELEMENT)) { - try { - this.blobs = BlobDeserializationHelper.readBlobItems(xmlr, serviceClient, container); - } - catch (final URISyntaxException e) { - throw new XMLStreamException(e); - } - catch (final ParseException e) { - throw new XMLStreamException(e); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.BLOBS_ELEMENT); - } - else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { - break; - } - } - } - - this.isParsed = true; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java deleted file mode 100644 index cb565025d436d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.io.InputStream; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.ArrayList; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. A class for parsing a list containers response stream. - */ -final class ListContainersResponse { - - /** - * Holds the list of containers. - */ - private ArrayList containers = new ArrayList(); - - /** - * Stores the value indicating if the response has been fully parsed. - */ - private boolean isParsed; - - /** - * Stores the marker. - */ - private String marker; - - /** - * Stores the max results. - */ - private int maxResults; - - /** - * Stores the next marker. - */ - private String nextMarker; - - /** - * Stores the container prefix. - */ - private String prefix; - - /** - * Stores the InputStream to read from. - */ - private final InputStream streamRef; - - public ListContainersResponse(final InputStream stream) { - this.streamRef = stream; - } - - /** - * Returns an ArrayList of CloudBlobContainer - * - * @param serviceClient - * a reference to the client object associated with this object. - * @return an ArrayList of CloudBlobContainer - * @throws XMLStreamException - * @throws StorageException - */ - public ArrayList getContainers(final CloudBlobClient serviceClient) throws XMLStreamException, - StorageException { - if (!this.isParsed) { - this.parseResponse(serviceClient); - } - - return this.containers; - } - - public String getMarker() { - return this.marker; - } - - public int getMaxResults() { - return this.maxResults; - } - - public String getNextMarker() { - return this.nextMarker; - } - - public String getPrefix() { - return this.prefix; - } - - /** - * Parses the XML stream. - * - * @param serviceClient - * a reference to the client object associated with this object. - * @throws XMLStreamException - * @throws StorageException - */ - public void parseResponse(final CloudBlobClient serviceClient) throws XMLStreamException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - String tempParseString = null; - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get enumerationResults Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); - this.maxResults = Integer.parseInt(tempParseString); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { - this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { - this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { - this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(BlobConstants.CONTAINERS_ELEMENT)) { - try { - this.containers = BlobDeserializationHelper.readContainers(xmlr, serviceClient); - } - catch (final URISyntaxException e) { - throw new XMLStreamException(e); - } - catch (final ParseException e) { - throw new XMLStreamException(e); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, BlobConstants.CONTAINERS_ELEMENT); - // eventType = xmlr.next(); - } - else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { - break; - } - } - } - - this.isParsed = true; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java deleted file mode 100644 index e9c010f4d0772..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * RESERVED FOR INTERNAL USE. Describes actions that may be used for writing to a page blob or clearing a set of pages. - */ -enum PageOperationType { - /** - * Update the page with new data. - */ - UPDATE, - - /** - * Clear the page. - */ - CLEAR -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java deleted file mode 100644 index e01609e967cb9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * RESERVED FOR INTERNAL USE. Represents properties for writing to a page blob. - */ -final class PageProperties { - - /** - * Gets or sets the type of write operation. - */ - private PageOperationType pageOperation = PageOperationType.UPDATE; - - /** - * Gets or sets the range of bytes to write to. - */ - private PageRange range = new PageRange(-1, -1); - - /** - * Initializes a new instance of the PageProperties class. - */ - public PageProperties() { - // Empty Default Ctor - } - - /** - * @return the pageOperation - */ - public PageOperationType getPageOperation() { - return this.pageOperation; - } - - /** - * @return the range - */ - public PageRange getRange() { - return this.range; - } - - /** - * @param pageOperation - * the pageOperation to set - */ - public void setPageOperation(final PageOperationType pageOperation) { - this.pageOperation = pageOperation; - } - - /** - * @param range - * the range to set - */ - public void setRange(final PageRange range) { - this.range = range; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java deleted file mode 100644 index 9196b0e9deb79..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -/** - * Represents a range of pages in a page blob. - */ -public final class PageRange { - /** - * Represents the ending offset of the page range. - */ - private long endOffset; - - /** - * Represents the starting offset of the page range. - */ - private long startOffset; - - /** - * Creates an instance of the PageRange class. - * - * @param start - * The starting offset. - * @param end - * The ending offset. - */ - public PageRange(final long start, final long end) { - this.setStartOffset(start); - this.setEndOffset(end); - } - - /** - * @return the endOffset - */ - public long getEndOffset() { - return this.endOffset; - } - - /** - * @return the startOffset - */ - public long getStartOffset() { - return this.startOffset; - } - - /** - * @param endOffset - * the endOffset to set - */ - public void setEndOffset(final long endOffset) { - this.endOffset = endOffset; - } - - /** - * @param startOffset - * the startOffset to set - */ - public void setStartOffset(final long startOffset) { - this.startOffset = startOffset; - } - - /** - * Returns the content of the page range as a string. - * - * @return A String that represents the contents of the page range. - */ - @Override - public String toString() { - return String.format("bytes=%d-%d", this.getStartOffset(), this.getEndOffset()); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java deleted file mode 100644 index 79be8d8d25ad9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPermissions.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.EnumSet; - -/** - * Specifies the set of possible permissions for a shared access policy. - */ -public enum SharedAccessPermissions { - /** - * Specifies Read access granted. - */ - READ((byte) 0x1), - - /** - * Specifies Write access granted. - */ - WRITE((byte) 0x2), - - /** - * Specifies Delete access granted for blobs. - */ - DELETE((byte) 0x4), - - /** - * Specifies List access granted. - */ - LIST((byte) 0x8); - - /** - * Returns the enum set representing the shared access permissions for the specified byte value. - * - * @param value - * The byte value to convert to the corresponding enum set. - * @return A java.util.EnumSet object that contains the SharedAccessPermissions values - * corresponding to the specified byte value. - */ - protected static EnumSet fromByte(final byte value) { - final EnumSet retSet = EnumSet.noneOf(SharedAccessPermissions.class); - - if (value == READ.value) { - retSet.add(READ); - } - - if (value == WRITE.value) { - retSet.add(WRITE); - } - if (value == DELETE.value) { - retSet.add(DELETE); - } - if (value == LIST.value) { - retSet.add(LIST); - } - - return retSet; - } - - /** - * Returns the value of this enum. - */ - private byte value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - SharedAccessPermissions(final byte val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java deleted file mode 100644 index 7509c8bcee0c4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessPolicy.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.util.Date; -import java.util.EnumSet; - -import com.microsoft.windowsazure.services.core.storage.Constants; - -/** - * Represents a shared access policy, which specifies the start time, expiry time, and permissions for a shared access - * signature. - */ -public final class SharedAccessPolicy { - - /** - * Assigns shared access permissions using the specified permissions string. - * - * @param value - * A String that represents the shared access permissions. The string must contain one or - * more of the following values. Note they must be lowercase, and the order that they are specified must - * be in the order of "rwdl". - *

    - *
  • d: Delete access.
  • - *
  • l: List access.
  • - *
  • r: Read access.
  • - *
  • w: Write access.
  • - *
- * - * @return A java.util.EnumSet object that contains {@link SharedAccessPermissions} values that - * represents the set of shared access permissions. - */ - public static EnumSet permissionsFromString(final String value) { - final char[] chars = value.toCharArray(); - final EnumSet retSet = EnumSet.noneOf(SharedAccessPermissions.class); - - for (final char c : chars) { - switch (c) { - case 'r': - retSet.add(SharedAccessPermissions.READ); - break; - case 'w': - retSet.add(SharedAccessPermissions.WRITE); - break; - case 'd': - retSet.add(SharedAccessPermissions.DELETE); - break; - case 'l': - retSet.add(SharedAccessPermissions.LIST); - break; - default: - throw new IllegalArgumentException("value"); - } - } - - return retSet; - } - - /** - * Converts the permissions specified for the shared access policy to a string. - * - * @param permissions - * A {@link SharedAccessPermissions} object that represents the shared access permissions. - * - * @return A String that represents the shared access permissions in the "rwdl" format, which is - * described at {@link SharedAccessPolicy#permissionsFromString}. - */ - public static String permissionsToString(final EnumSet permissions) { - if (permissions == null) { - return Constants.EMPTY_STRING; - } - - // The service supports a fixed order => rwdl - final StringBuilder builder = new StringBuilder(); - - if (permissions.contains(SharedAccessPermissions.READ)) { - builder.append("r"); - } - - if (permissions.contains(SharedAccessPermissions.WRITE)) { - builder.append("w"); - } - - if (permissions.contains(SharedAccessPermissions.DELETE)) { - builder.append("d"); - } - - if (permissions.contains(SharedAccessPermissions.LIST)) { - builder.append("l"); - } - - return builder.toString(); - } - - /** - * The permissions for a shared access signature associated with this shared access policy. - */ - private EnumSet permissions; - - /** - * The expiry time for a shared access signature associated with this shared access policy. - */ - private Date sharedAccessExpiryTime; - - /** - * The start time for a shared access signature associated with this shared access policy. - */ - private Date sharedAccessStartTime; - - /** - * Creates an instance of the SharedAccessPolicy class. - * */ - public SharedAccessPolicy() { - // Empty Default Ctor - } - - /** - * @return the permissions - */ - public EnumSet getPermissions() { - return this.permissions; - } - - /** - * @return the sharedAccessExpiryTime - */ - public Date getSharedAccessExpiryTime() { - return this.sharedAccessExpiryTime; - } - - /** - * @return the sharedAccessStartTime - */ - public Date getSharedAccessStartTime() { - return this.sharedAccessStartTime; - } - - /** - * @param permissions - * the permissions to set - */ - public void setPermissions(final EnumSet permissions) { - this.permissions = permissions; - } - - /** - * @param sharedAccessExpiryTime - * the sharedAccessExpiryTime to set - */ - public void setSharedAccessExpiryTime(final Date sharedAccessExpiryTime) { - this.sharedAccessExpiryTime = sharedAccessExpiryTime; - } - - /** - * @param sharedAccessStartTime - * the sharedAccessStartTime to set - */ - public void setSharedAccessStartTime(final Date sharedAccessStartTime) { - this.sharedAccessStartTime = sharedAccessStartTime; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java deleted file mode 100644 index 896c47b5c339a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessSignatureHelper.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.client; - -import java.security.InvalidKeyException; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Contains helper methods for implementing shared access signatures. - */ -final class SharedAccessSignatureHelper { - /** - * Get the complete query builder for creating the Shared Access Signature query. - * - * @param policy - * The shared access policy to hash. - * @param groupPolicyIdentifier - * An optional identifier for the policy. - * @param resourceType - * Either "b" for blobs or "c" for containers. - * @param signature - * The signature to use. - * @return The finished query builder - * @throws IllegalArgumentException - * @throws StorageException - */ - protected static UriQueryBuilder generateSharedAccessSignature(final SharedAccessPolicy policy, - final String groupPolicyIdentifier, final String resourceType, final String signature) - throws StorageException { - Utility.assertNotNullOrEmpty("resourceType", resourceType); - Utility.assertNotNull("signature", signature); - - final UriQueryBuilder builder = new UriQueryBuilder(); - if (policy != null) { - String permissions = SharedAccessPolicy.permissionsToString(policy.getPermissions()); - - if (Utility.isNullOrEmpty(permissions)) { - permissions = null; - } - - final String startString = Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()); - if (!Utility.isNullOrEmpty(startString)) { - builder.add(BlobConstants.QueryConstants.SIGNED_START, startString); - } - - final String stopString = Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()); - if (!Utility.isNullOrEmpty(stopString)) { - builder.add(BlobConstants.QueryConstants.SIGNED_EXPIRY, stopString); - } - - if (!Utility.isNullOrEmpty(permissions)) { - builder.add(BlobConstants.QueryConstants.SIGNED_PERMISSIONS, permissions); - } - } - - builder.add(BlobConstants.QueryConstants.SIGNED_RESOURCE, resourceType); - - if (!Utility.isNullOrEmpty(groupPolicyIdentifier)) { - builder.add(BlobConstants.QueryConstants.SIGNED_IDENTIFIER, groupPolicyIdentifier); - } - - if (!Utility.isNullOrEmpty(signature)) { - builder.add(BlobConstants.QueryConstants.SIGNATURE, signature); - } - - return builder; - } - - /** - * Get the signature hash embedded inside the Shared Access Signature. - * - * @param policy - * The shared access policy to hash. - * @param groupPolicyIdentifier - * An optional identifier for the policy. - * @param resourceName - * the resource name. - * @param client - * the CloudBlobClient associated with the object. - * @param opContext - * an object used to track the execution of the operation - * @return the signature hash embedded inside the Shared Access Signature. - * @throws InvalidKeyException - * @throws StorageException - */ - protected static String generateSharedAccessSignatureHash(final SharedAccessPolicy policy, - final String groupPolicyIdentifier, final String resourceName, final CloudBlobClient client, - final OperationContext opContext) throws InvalidKeyException, StorageException { - Utility.assertNotNullOrEmpty("resourceName", resourceName); - Utility.assertNotNull("client", client); - - String stringToSign = null; - - if (policy == null) { - // Revokable access - Utility.assertNotNullOrEmpty("groupPolicyIdentifier", groupPolicyIdentifier); - stringToSign = String.format("%s\n%s\n%s\n%s\n%s", Constants.EMPTY_STRING, Constants.EMPTY_STRING, - Constants.EMPTY_STRING, resourceName, groupPolicyIdentifier); - } - else { - // Non Revokable access - if (policy.getSharedAccessExpiryTime() == null) { - throw new IllegalArgumentException("Policy Expiry time is mandatory and cannot be null"); - } - - if (policy.getPermissions() == null) { - throw new IllegalArgumentException("Policy permissions are mandatory and cannot be null"); - } - - stringToSign = String.format("%s\n%s\n%s\n%s\n%s", - SharedAccessPolicy.permissionsToString(policy.getPermissions()), - Utility.getUTCTimeOrEmpty(policy.getSharedAccessStartTime()), - Utility.getUTCTimeOrEmpty(policy.getSharedAccessExpiryTime()), resourceName, - groupPolicyIdentifier == null ? Constants.EMPTY_STRING : groupPolicyIdentifier); - } - - stringToSign = Utility.safeDecode(stringToSign); - final String signature = client.getCredentials().computeHmac256(stringToSign, opContext); - - // add logging - return signature; - } - - /** - * Parses the query parameters and populates a StorageCredentialsSharedAccessSignature object if one is present. - * - * @param queryParams - * the parameters to parse - * @return the StorageCredentialsSharedAccessSignature if one is present, otherwise null - * @throws IllegalArgumentException - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - protected static StorageCredentialsSharedAccessSignature parseQuery(final HashMap queryParams) - throws StorageException { - String signature = null; - String signedStart = null; - String signedExpiry = null; - String signedResource = null; - String sigendPermissions = null; - String signedIdentifier = null; - String signedVersion = null; - - boolean sasParameterFound = false; - - StorageCredentialsSharedAccessSignature credentials = null; - - for (final Entry entry : queryParams.entrySet()) { - final String lowerKey = entry.getKey().toLowerCase(Utility.LOCALE_US); - - if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_START)) { - signedStart = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_EXPIRY)) { - signedExpiry = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_PERMISSIONS)) { - sigendPermissions = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_RESOURCE)) { - signedResource = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_IDENTIFIER)) { - signedIdentifier = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNATURE)) { - signature = entry.getValue()[0]; - sasParameterFound = true; - } - else if (lowerKey.equals(BlobConstants.QueryConstants.SIGNED_VERSION)) { - signedVersion = entry.getValue()[0]; - sasParameterFound = true; - } - } - - if (sasParameterFound) { - if (signature == null || signedResource == null) { - final String errorMessage = "Missing mandatory parameters for valid Shared Access Signature"; - throw new IllegalArgumentException(errorMessage); - } - - final UriQueryBuilder builder = new UriQueryBuilder(); - - if (!Utility.isNullOrEmpty(signedStart)) { - builder.add(BlobConstants.QueryConstants.SIGNED_START, signedStart); - } - - if (!Utility.isNullOrEmpty(signedExpiry)) { - builder.add(BlobConstants.QueryConstants.SIGNED_EXPIRY, signedExpiry); - } - - if (!Utility.isNullOrEmpty(sigendPermissions)) { - builder.add(BlobConstants.QueryConstants.SIGNED_PERMISSIONS, sigendPermissions); - } - - builder.add(BlobConstants.QueryConstants.SIGNED_RESOURCE, signedResource); - - if (!Utility.isNullOrEmpty(signedIdentifier)) { - builder.add(BlobConstants.QueryConstants.SIGNED_IDENTIFIER, signedIdentifier); - } - - if (!Utility.isNullOrEmpty(signedVersion)) { - builder.add(BlobConstants.QueryConstants.SIGNED_VERSION, signedVersion); - } - - if (!Utility.isNullOrEmpty(signature)) { - builder.add(BlobConstants.QueryConstants.SIGNATURE, signature); - } - - final String token = builder.toString(); - credentials = new StorageCredentialsSharedAccessSignature(token); - } - - return credentials; - } - - /** - * Private Default Ctor. - */ - private SharedAccessSignatureHelper() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java deleted file mode 100644 index 167add68535be..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ /dev/null @@ -1,913 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.io.InputStream; -import java.util.HashMap; - -import javax.inject.Inject; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.blob.BlobContract; -import com.microsoft.windowsazure.services.blob.models.AcquireLeaseOptions; -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.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.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; -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.GetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -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; -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.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; -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.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; - -public class BlobExceptionProcessor implements BlobContract { - private static Log log = LogFactory.getLog(BlobExceptionProcessor.class); - private final BlobContract service; - - @Inject - public BlobExceptionProcessor(BlobRestProxy service) { - this.service = service; - } - - public BlobExceptionProcessor(BlobContract service) { - this.service = service; - } - - @Override - public BlobContract withFilter(ServiceFilter filter) { - return new BlobExceptionProcessor(service.withFilter(filter)); - } - - private ServiceException processCatch(ServiceException e) { - log.warn(e.getMessage(), e.getCause()); - return ServiceExceptionFactory.process("blob", e); - } - - @Override - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - try { - return service.getServiceProperties(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { - try { - return service.getServiceProperties(options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) - throws ServiceException { - try { - service.setServiceProperties(serviceProperties, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - try { - service.setServiceProperties(serviceProperties); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListContainersResult listContainers() throws ServiceException { - try { - return service.listContainers(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { - try { - return service.listContainers(options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createContainer(String container) throws ServiceException { - try { - service.createContainer(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createContainer(String container, CreateContainerOptions options) throws ServiceException { - try { - service.createContainer(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteContainer(String container) throws ServiceException { - try { - service.deleteContainer(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { - try { - service.deleteContainer(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { - try { - return service.getContainerProperties(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) - throws ServiceException { - try { - return service.getContainerProperties(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { - try { - return service.getContainerMetadata(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) - throws ServiceException { - try { - return service.getContainerMetadata(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerACLResult getContainerACL(String container) throws ServiceException { - try { - return service.getContainerACL(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { - try { - return service.getContainerACL(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setContainerACL(String container, ContainerACL acl) throws ServiceException { - try { - service.setContainerACL(container, acl); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { - try { - service.setContainerACL(container, acl, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { - try { - service.setContainerMetadata(container, metadata); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void setContainerMetadata(String container, HashMap metadata, - SetContainerMetadataOptions options) throws ServiceException { - try { - service.setContainerMetadata(container, metadata, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobsResult listBlobs(String container) throws ServiceException { - try { - return service.listBlobs(container); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - try { - return service.listBlobs(container, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createPageBlob(String container, String blob, int length) throws ServiceException { - try { - service.createPageBlob(container, blob, length); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) - throws ServiceException { - try { - service.createPageBlob(container, blob, length, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { - try { - service.createBlockBlob(container, blob, contentStream); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) - throws ServiceException { - try { - service.createBlockBlob(container, blob, contentStream, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { - try { - return service.clearBlobPages(container, blob, range); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, - CreateBlobPagesOptions options) throws ServiceException { - try { - return service.clearBlobPages(container, blob, range, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream) throws ServiceException { - try { - return service.createBlobPages(container, blob, range, length, contentStream); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - try { - return service.createBlobPages(container, blob, range, length, contentStream, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) - throws ServiceException { - try { - service.createBlobBlock(container, blob, blockId, contentStream); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, - CreateBlobBlockOptions options) throws ServiceException { - try { - service.createBlobBlock(container, blob, blockId, contentStream, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { - try { - service.commitBlobBlocks(container, blob, blockList); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) - throws ServiceException { - try { - service.commitBlobBlocks(container, blob, blockList, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { - try { - return service.listBlobBlocks(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) - throws ServiceException { - try { - return service.listBlobBlocks(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { - try { - return service.getBlobProperties(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) - throws ServiceException { - try { - return service.getBlobProperties(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { - try { - return service.getBlobMetadata(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) - throws ServiceException { - try { - return service.getBlobMetadata(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { - try { - return service.listBlobRegions(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) - throws ServiceException { - try { - return service.listBlobRegions(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) - throws ServiceException { - try { - return service.setBlobProperties(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) - throws ServiceException { - try { - return service.setBlobMetadata(container, blob, metadata); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, - SetBlobMetadataOptions options) throws ServiceException { - try { - return service.setBlobMetadata(container, blob, metadata, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobResult getBlob(String container, String blob) throws ServiceException { - try { - return service.getBlob(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { - try { - return service.getBlob(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteBlob(String container, String blob) throws ServiceException { - try { - service.deleteBlob(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { - try { - service.deleteBlob(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { - try { - return service.createBlobSnapshot(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) - throws ServiceException { - try { - return service.createBlobSnapshot(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) - throws ServiceException { - try { - service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, - String sourceBlob, CopyBlobOptions options) throws ServiceException { - try { - service.copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { - try { - return service.acquireLease(container, blob); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) - throws ServiceException { - try { - return service.acquireLease(container, blob, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { - try { - return service.renewLease(container, blob, leaseId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - try { - return service.renewLease(container, blob, leaseId, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void releaseLease(String container, String blob, String leaseId) throws ServiceException { - try { - service.releaseLease(container, blob, leaseId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - try { - service.releaseLease(container, blob, leaseId, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void breakLease(String container, String blob, String leaseId) throws ServiceException { - try { - service.breakLease(container, blob, leaseId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - try { - service.breakLease(container, blob, leaseId, 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/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java deleted file mode 100644 index 3907ac20db407..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ /dev/null @@ -1,923 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import com.microsoft.windowsazure.services.blob.BlobConfiguration; -import com.microsoft.windowsazure.services.blob.BlobContract; -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; -import com.microsoft.windowsazure.services.blob.models.ContainerACL; -import com.microsoft.windowsazure.services.blob.models.ContainerACL.PublicAccessType; -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.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; -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.GetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -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; -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.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; -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.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers.EnumCommaStringBuilder; -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 BlobRestProxy implements BlobContract { - private static final String API_VERSION = "2011-08-18"; - private final HttpURLConnectionClient channel; - private final String accountName; - private final String url; - private final RFC1123DateConverter dateMapper; - private final ServiceFilter[] filters; - private final SharedKeyFilter filter; - - @Inject - public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, - @Named(BlobConfiguration.URI) String url, SharedKeyFilter 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 BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, String accountName, String url, - SharedKeyFilter filter, RFC1123DateConverter dateMapper) { - - this.channel = client; - this.filters = filters; - this.accountName = accountName; - this.url = url; - this.filter = filter; - this.dateMapper = dateMapper; - } - - @Override - public BlobContract withFilter(ServiceFilter filter) { - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new BlobRestProxy(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); - } - - private void ThrowIfError(ClientResponse r) { - PipelineHelpers.ThrowIfError(r); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); - } - - private Builder addOptionalHeader(Builder builder, String name, Object value) { - return PipelineHelpers.addOptionalHeader(builder, name, value); - } - - private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); - } - - private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { - return PipelineHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); - } - - private Builder addOptionalAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - return PipelineHelpers.addOptionalAccessContitionHeader(builder, accessCondition); - } - - private Builder addOptionalSourceAccessContitionHeader(Builder builder, AccessCondition accessCondition) { - return PipelineHelpers.addOptionalSourceAccessContitionHeader(builder, accessCondition); - } - - private HashMap getMetadataFromHeaders(ClientResponse response) { - return PipelineHelpers.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.getValue()); - return webResource; - } - - private WebResource addOptionalContainerIncludeQueryParam(ListContainersOptions options, WebResource webResource) { - EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); - sb.addValue(options.isIncludeMetadata(), "metadata"); - webResource = addOptionalQueryParam(webResource, "include", sb.getValue()); - return webResource; - } - - private Builder addPutBlobHeaders(CreateBlobOptions options, Builder builder) { - builder = addOptionalHeader(builder, "Content-Type", options.getContentType()); - if (options.getContentType() == null) { - // Note: Add content type here to enable proper HMAC signing - builder = builder.type("application/octet-stream"); - } - builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - return builder; - } - - private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { - // Properties - BlobProperties properties = new BlobProperties(); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); - properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); - - properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); - properties.setContentType(response.getHeaders().getFirst("Content-Type")); - properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); - properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); - properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); - - 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"))); - } - - // Metadata - HashMap metadata = getMetadataFromHeaders(response); - - // Result - GetBlobPropertiesResult result = new GetBlobPropertiesResult(); - result.setMetadata(metadata); - result.setProperties(properties); - return result; - } - - private WebResource getResource(BlobServiceOptions 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 String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { - // Specifies the name of the source blob, in one of the following - // formats: - // Blob in named container: /accountName/containerName/blobName - // - // Snapshot in named container: - // /accountName/containerName/blobName?snapshot= - // - // Blob in root container: /accountName/blobName - // - // Snapshot in root container: /accountName/blobName?snapshot= - String sourceName = "/" + this.accountName; - if (sourceContainer != null) { - sourceName += "/" + sourceContainer; - } - sourceName += "/" + sourceBlob; - if (options.getSourceSnapshot() != null) { - sourceName += "?snapshot=" + options.getSourceSnapshot(); - } - return sourceName; - } - - @Override - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - return getServiceProperties(new BlobServiceOptions()); - } - - @Override - public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - GetServicePropertiesResult result = new GetServicePropertiesResult(); - result.setValue(builder.get(ServiceProperties.class)); - return result; - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - setServiceProperties(serviceProperties, new BlobServiceOptions()); - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder.put(serviceProperties); - } - - @Override - public void createContainer(String container) throws ServiceException { - createContainer(container, new CreateContainerOptions()); - } - - @Override - public void createContainer(String container, CreateContainerOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); - - builder.put(); - } - - @Override - public void deleteContainer(String container) throws ServiceException { - deleteContainer(container, new DeleteContainerOptions()); - } - - @Override - public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.delete(); - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { - return getContainerProperties(container, new BlobServiceOptions()); - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) - throws ServiceException { - return getContainerPropertiesImpl(container, options, null); - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { - return getContainerMetadata(container, new BlobServiceOptions()); - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) - throws ServiceException { - return getContainerPropertiesImpl(container, options, "metadata"); - } - - private GetContainerPropertiesResult getContainerPropertiesImpl(String container, BlobServiceOptions options, - String operation) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - webResource = addOptionalQueryParam(webResource, "comp", operation); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetContainerPropertiesResult properties = new GetContainerPropertiesResult(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; - } - - @Override - public GetContainerACLResult getContainerACL(String container) throws ServiceException { - return getContainerACL(container, new BlobServiceOptions()); - } - - @Override - public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container") - .queryParam("comp", "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); - ContainerACL acl = new ContainerACL(); - acl.setSignedIdentifiers(si.getSignedIdentifiers()); - if ("container".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { - acl.setPublicAccess(PublicAccessType.CONTAINER_AND_BLOBS); - } - else if ("blob".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { - acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); - } - else { - acl.setPublicAccess(PublicAccessType.NONE); - } - acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - GetContainerACLResult result = new GetContainerACLResult(); - result.setValue(acl); - return result; - } - - @Override - public void setContainerACL(String container, ContainerACL acl) throws ServiceException { - setContainerACL(container, acl, new BlobServiceOptions()); - } - - @Override - public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container") - .queryParam("comp", "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - if (acl.getPublicAccess() == PublicAccessType.BLOBS_ONLY) { - builder = addOptionalHeader(builder, "x-ms-blob-public-access", "blob"); - } - else if (acl.getPublicAccess() == PublicAccessType.CONTAINER_AND_BLOBS) { - builder = addOptionalHeader(builder, "x-ms-blob-public-access", "container"); - } - - ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); - si.setSignedIdentifiers(acl.getSignedIdentifiers()); - - builder.put(si); - } - - @Override - public void setContainerMetadata(String container, HashMap metadata) throws ServiceException { - setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); - } - - @Override - public void setContainerMetadata(String container, HashMap metadata, - SetContainerMetadataOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("resType", "container") - .queryParam("comp", "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.put(); - } - - @Override - public ListContainersResult listContainers() throws ServiceException { - return listContainers(new ListContainersOptions()); - } - - @Override - public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); - webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); - webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); - webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); - webResource = addOptionalContainerIncludeQueryParam(options, webResource); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - return builder.get(ListContainersResult.class); - } - - @Override - public ListBlobsResult listBlobs(String container) throws ServiceException { - return listBlobs(container, new ListBlobsOptions()); - } - - @Override - public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).queryParam("comp", "list") - .queryParam("resType", "container"); - 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); - - return builder.get(ListBlobsResult.class); - } - - @Override - public void createPageBlob(String container, String blob, int length) throws ServiceException { - createPageBlob(container, blob, length, new CreateBlobOptions()); - } - - @Override - public void createPageBlob(String container, String blob, int length, CreateBlobOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container + "/" + blob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); - builder = addOptionalHeader(builder, "Content-Length", 0); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addPutBlobHeaders(options, builder); - - builder.put(); - } - - @Override - public void createBlockBlob(String container, String blob, InputStream contentStream) throws ServiceException { - createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); - } - - @Override - public void createBlockBlob(String container, String blob, InputStream contentStream, CreateBlobOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container + "/" + blob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder = builder.header("x-ms-blob-type", "BlockBlob"); - builder = addPutBlobHeaders(options, builder); - - Object contentObject = (contentStream == null ? new byte[0] : contentStream); - builder.put(contentObject); - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { - return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.method("HEAD", ClientResponse.class); - ThrowIfError(response); - - return getBlobPropertiesResultFromResponse(response); - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { - return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetBlobMetadataResult properties = new GetBlobMetadataResult(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; - } - - @Override - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); - builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - SetBlobPropertiesResult result = new SetBlobPropertiesResult(); - - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); - } - - return result; - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata) - throws ServiceException { - return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap metadata, - SetBlobMetadataOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - SetBlobMetadataResult result = new SetBlobMetadataResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - return result; - } - - @Override - public GetBlobResult getBlob(String container, String blob) throws ServiceException { - return getBlob(container, blob, new GetBlobOptions()); - } - - @Override - public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response); - GetBlobResult blobResult = new GetBlobResult(); - blobResult.setProperties(properties.getProperties()); - blobResult.setMetadata(properties.getMetadata()); - blobResult.setContentStream(response.getEntityInputStream()); - return blobResult; - } - - @Override - public void deleteBlob(String container, String blob) throws ServiceException { - deleteBlob(container, blob, new DeleteBlobOptions()); - } - - @Override - public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container + "/" + blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" - : "include"); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.delete(); - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { - return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container + "/" + blob).queryParam("comp", "snapshot"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); - blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); - blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); - blobSnapshot.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return blobSnapshot; - } - - @Override - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, String sourceBlob) - throws ServiceException { - copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); - } - - @Override - public void copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, - String sourceBlob, CopyBlobOptions options) { - WebResource webResource = getResource(options).path(destinationContainer).path(destinationBlob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); - builder = addOptionalHeader(builder, "x-ms-copy-source", - getCopyBlobSourceName(sourceContainer, sourceBlob, options)); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - builder = addOptionalSourceAccessContitionHeader(builder, options.getSourceAccessCondition()); - - builder.put(); - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { - return acquireLease(container, blob, new AcquireLeaseOptions()); - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) - throws ServiceException { - return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { - return renewLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); - } - - @Override - public void releaseLease(String container, String blob, String leaseId) throws ServiceException { - releaseLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); - } - - @Override - public void breakLease(String container, String blob, String leaseId) throws ServiceException { - breakLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); - } - - private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, - BlobServiceOptions options, AccessCondition accessCondition) throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "lease"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); - builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); - builder = addOptionalAccessContitionHeader(builder, accessCondition); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - AcquireLeaseResult result = new AcquireLeaseResult(); - result.setLeaseId(response.getHeaders().getFirst("x-ms-lease-id")); - return result; - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { - return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, - CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream) throws ServiceException { - return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); - } - - 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"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - 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()); - builder = addOptionalHeader(builder, "x-ms-page-write", action); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class, contentStream); - ThrowIfError(response); - - CreateBlobPagesResult result = new CreateBlobPagesResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); - - return result; - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { - return listBlobRegions(container, blob, new ListBlobRegionsOptions()); - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "pagelist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return result; - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) - throws ServiceException { - createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, - CreateBlobBlockOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - - builder.put(contentStream); - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { - commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessContitionHeader(builder, options.getAccessCondition()); - - builder.put(blockList); - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { - return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(container).path(blob).queryParam("comp", "blocklist"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - if (options.isCommittedList() && options.isUncommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "all"); - } - else if (options.isCommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "committed"); - } - else if (options.isUncommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "uncommitted"); - } - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentType(response.getHeaders().getFirst("Content-Type")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return result; - } -} 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 deleted file mode 100644 index 39e67d931a384..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.Date; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -/* - * JAXB adapter for a "not quite" ISO 8601 date time element - */ -public class ContainerACLDateAdapter extends XmlAdapter { - - @Override - public Date unmarshal(String arg0) throws Exception { - return new ContainerACLDateConverter().parse(arg0); - } - - @Override - public String marshal(Date arg0) throws Exception { - return new ContainerACLDateConverter().format(arg0); - } -} 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 deleted file mode 100644 index 209a345d26a0a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ContainerACLDateConverter.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; - -/* - * "not quite" ISO 8601 date time conversion routines - */ -public class ContainerACLDateConverter { - // Note: because of the trailing "0000000", this is not quite ISO 8601 compatible - private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; - - public String format(Date date) { - return getFormat().format(date); - } - - public Date parse(String date) throws ParseException { - return getFormat().parse(date); - } - - public Date parseNoThrow(String date) { - try { - return parse(date); - } - catch (ParseException e) { - return null; - } - } - - private DateFormat getFormat() { - DateFormat iso8601Format = new SimpleDateFormat(DATETIME_PATTERN, Locale.US); - iso8601Format.setTimeZone(TimeZone.getTimeZone("GMT")); - return iso8601Format; - } -} 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 deleted file mode 100644 index 395d7d9cd393a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -import com.sun.jersey.core.util.Base64; - -public class HmacSHA256Sign { - private final String accessKey; - - public HmacSHA256Sign(String accessKey) { - this.accessKey = accessKey; - } - - public String sign(String stringToSign) { - try { - // Encoding the Signature - // Signature=Base64(HMAC-SHA256(UTF8(StringToSign))) - - Mac hmac = Mac.getInstance("hmacSHA256"); - hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); - byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); - return new String(Base64.encode(digest)); - } - catch (Exception e) { - throw new IllegalArgumentException("accessKey", e); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java deleted file mode 100644 index fb07884c72a3e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.naming.OperationNotSupportedException; -import javax.xml.bind.annotation.XmlAnyElement; -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import org.w3c.dom.Element; - -/* - * JAXB adapter for element - */ -public class MetadataAdapter extends XmlAdapter> { - - @Override - public HashMap unmarshal(MetadataHashMapType arg0) throws Exception { - HashMap result = new HashMap(); - for (Element entry : arg0.getEntries()) { - result.put(entry.getLocalName(), entry.getFirstChild().getNodeValue()); - } - return result; - } - - @Override - public MetadataHashMapType marshal(HashMap arg0) throws Exception { - // We don't need marshaling for blob/container metadata - throw new OperationNotSupportedException(); - } - - public static class MetadataHashMapType { - private List entries = new ArrayList(); - - @XmlAnyElement - public List getEntries() { - return entries; - } - - public void setEntries(List entries) { - this.entries = entries; - } - } -} 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 deleted file mode 100644 index 79387438534b3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.Date; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -/* - * JAXB adapter for RFC 1123 date element - */ -public class RFC1123DateAdapter extends XmlAdapter { - - @Override - public Date unmarshal(String arg0) throws Exception { - return new RFC1123DateConverter().parse(arg0); - } - - @Override - public String marshal(Date arg0) throws Exception { - return new RFC1123DateConverter().format(arg0); - } -} 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 deleted file mode 100644 index 67d1738a3889d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/RFC1123DateConverter.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; - -/* - * RFC 1123 date to string conversion - */ -public class RFC1123DateConverter { - private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; - - public String format(Date date) { - return getFormat().format(date); - } - - public Date parse(String date) { - try { - return getFormat().parse(date); - } - catch (ParseException e) { - String msg = String.format("The value \"%s\" is not a valid RFC 1123 date.", date); - throw new IllegalArgumentException(msg, e); - } - } - - private DateFormat getFormat() { - DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, Locale.US); - rfc1123Format.setTimeZone(TimeZone.getTimeZone("GMT")); - return rfc1123Format; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java deleted file mode 100644 index 6481932c7cde0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import javax.inject.Named; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.blob.BlobConfiguration; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; -import com.microsoft.windowsazure.services.core.utils.pipeline.EntityStreamingListener; -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; - -public class SharedKeyFilter extends ClientFilter implements EntityStreamingListener { - private static Log log = LogFactory.getLog(SharedKeyFilter.class); - - private final String accountName; - private final HmacSHA256Sign signer; - - public SharedKeyFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, - @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { - this.accountName = accountName; - this.signer = new HmacSHA256Sign(accountKey); - } - - @Override - public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - // Only sign if no other filter is handling authorization - if (cr.getProperties().get(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER) == null) { - cr.getProperties().put(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER, null); - - // Register ourselves as listener so we are called back when the entity is - // written to the output stream by the next filter in line. - if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { - cr.getProperties().put(EntityStreamingListener.class.getName(), this); - } - - } - return this.getNext().handle(cr); - } - - public void onBeforeStreamingEntity(ClientRequest clientRequest) { - // All headers should be known at this point, time to sign! - sign(clientRequest); - } - - /* - * StringToSign = VERB + "\n" + - * Content-Encoding + "\n" - * Content-Language + "\n" - * Content-Length + "\n" - * Content-MD5 + "\n" + - * Content-Type + "\n" + - * Date + "\n" + - * If-Modified-Since + "\n" - * If-Match + "\n" - * If-None-Match + "\n" - * If-Unmodified-Since + "\n" - * Range + "\n" - * CanonicalizedHeaders + - * CanonicalizedResource; - */ - public void sign(ClientRequest cr) { - // gather signed material - addOptionalDateHeader(cr); - - // build signed string - String stringToSign = cr.getMethod() + "\n" + getHeader(cr, "Content-Encoding") + "\n" - + getHeader(cr, "Content-Language") + "\n" + getHeader(cr, "Content-Length") + "\n" - + getHeader(cr, "Content-MD5") + "\n" + getHeader(cr, "Content-Type") + "\n" + getHeader(cr, "Date") - + "\n" + getHeader(cr, "If-Modified-Since") + "\n" + getHeader(cr, "If-Match") + "\n" - + getHeader(cr, "If-None-Match") + "\n" + getHeader(cr, "If-Unmodified-Since") + "\n" - + getHeader(cr, "Range") + "\n"; - - stringToSign += getCanonicalizedHeaders(cr); - stringToSign += getCanonicalizedResource(cr); - - if (log.isDebugEnabled()) { - log.debug(String.format("String to sign: \"%s\"", stringToSign)); - } - //System.out.println(String.format("String to sign: \"%s\"", stringToSign)); - - String signature = this.signer.sign(stringToSign); - cr.getHeaders().putSingle("Authorization", "SharedKey " + this.accountName + ":" + signature); - } - - private void addOptionalDateHeader(ClientRequest cr) { - String date = getHeader(cr, "Date"); - if (date == "") { - date = new RFC1123DateConverter().format(new Date()); - cr.getHeaders().add("Date", date); - } - } - - /** - * Constructing the Canonicalized Headers String - * - * To construct the CanonicalizedHeaders portion of the signature string, - * follow these steps: - * - * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header. - * - * 2. Convert each HTTP header name to lowercase. - * - * 3. Sort the headers lexicographically by header name, in ascending order. Note that each header may appear only - * once in the string. - * - * 4. Unfold the string by replacing any breaking white space with a - * single space. - * - * 5. Trim any white space around the colon in the header. - * - * 6. Finally, append a new line character to each canonicalized header in the resulting list. Construct the - * CanonicalizedHeaders string by concatenating all headers in this list into a single string. - */ - private String getCanonicalizedHeaders(ClientRequest cr) { - return SharedKeyUtils.getCanonicalizedHeaders(cr); - } - - /** - * This format supports Shared Key authentication for the 2009-09-19 version of the Blob and Queue services. - * Construct the CanonicalizedResource string in this format as follows: - * - * 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns - * the resource being accessed. - * - * 2. Append the resource's encoded URI path, without any query parameters. - * - * 3. Retrieve all query parameters on the resource URI, including the comp parameter if it exists. - * - * 4. Convert all parameter names to lowercase. - * - * 5. Sort the query parameters lexicographically by parameter name, in ascending order. - * - * 6. URL-decode each query parameter name and value. - * - * 7. Append each query parameter name and value to the string in the following format, making sure to include the - * colon (:) between the name and the value: - * - * parameter-name:parameter-value - * - * 8. If a query parameter has more than one value, sort all values lexicographically, then include them in a - * comma-separated list: - * - * parameter-name:parameter-value-1,parameter-value-2,parameter-value-n - * - * 9. Append a new line character (\n) after each name-value pair. - */ - private String getCanonicalizedResource(ClientRequest cr) { - // 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns - // the resource being accessed. - String result = "/" + this.accountName; - - // 2. Append the resource's encoded URI path, without any query parameters. - result += cr.getURI().getPath(); - - // 3. Retrieve all query parameters on the resource URI, including the comp parameter if it exists. - // 6. URL-decode each query parameter name and value. - List queryParams = SharedKeyUtils.getQueryParams(cr.getURI().getQuery()); - - // 4. Convert all parameter names to lowercase. - for (QueryParam param : queryParams) { - param.setName(param.getName().toLowerCase(Locale.US)); - } - - // 5. Sort the query parameters lexicographically by parameter name, in ascending order. - Collections.sort(queryParams); - - // 7. Append each query parameter name and value to the string - // 8. If a query parameter has more than one value, sort all values lexicographically, then include them in a comma-separated list - for (int i = 0; i < queryParams.size(); i++) { - QueryParam param = queryParams.get(i); - - List values = param.getValues(); - //Collections.sort(values); - - // 9. Append a new line character (\n) after each name-value pair. - result += "\n"; - result += param.getName(); - result += ":"; - for (int j = 0; j < values.size(); j++) { - if (j > 0) { - result += ","; - } - result += values.get(j); - } - } - - return result; - } - - private String getHeader(ClientRequest cr, String headerKey) { - return SharedKeyUtils.getHeader(cr, headerKey); - } -} 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 deleted file mode 100644 index 0134195d5c3aa..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyLiteFilter.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.Date; -import java.util.List; - -import javax.inject.Named; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.blob.BlobConfiguration; -import com.microsoft.windowsazure.services.blob.implementation.SharedKeyUtils.QueryParam; -import com.microsoft.windowsazure.services.core.utils.pipeline.EntityStreamingListener; -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; - -public class SharedKeyLiteFilter extends ClientFilter implements EntityStreamingListener { - private static Log log = LogFactory.getLog(SharedKeyLiteFilter.class); - - private final String accountName; - private final HmacSHA256Sign signer; - - public SharedKeyLiteFilter(@Named(BlobConfiguration.ACCOUNT_NAME) String accountName, - @Named(BlobConfiguration.ACCOUNT_KEY) String accountKey) { - - this.accountName = accountName; - this.signer = new HmacSHA256Sign(accountKey); - } - - @Override - public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - // Only sign if no other filter is handling authorization - if (cr.getProperties().get(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER) == null) { - cr.getProperties().put(SharedKeyUtils.AUTHORIZATION_FILTER_MARKER, null); - - // Register ourselves as listener so we are called back when the entity is - // written to the output stream by the next filter in line. - if (cr.getProperties().get(EntityStreamingListener.class.getName()) == null) { - cr.getProperties().put(EntityStreamingListener.class.getName(), this); - } - } - - return this.getNext().handle(cr); - } - - public void onBeforeStreamingEntity(ClientRequest clientRequest) { - // All headers should be known at this point, time to sign! - sign(clientRequest); - } - - /* - * StringToSign = VERB + "\n" + Content-MD5 + "\n" + Content-Type + "\n" + - * Date + "\n" + CanonicalizedHeaders + CanonicalizedResource; - */ - public void sign(ClientRequest cr) { - // gather signed material - String requestMethod = cr.getMethod(); - String contentMD5 = getHeader(cr, "Content-MD5"); - String contentType = getHeader(cr, "Content-Type"); - String date = getHeader(cr, "Date"); - - if (date == "") { - date = new RFC1123DateConverter().format(new Date()); - cr.getHeaders().add("Date", date); - } - - // build signed string - String stringToSign = requestMethod + "\n" + contentMD5 + "\n" + contentType + "\n" + date + "\n"; - - stringToSign += addCanonicalizedHeaders(cr); - stringToSign += addCanonicalizedResource(cr); - - if (log.isDebugEnabled()) { - log.debug(String.format("String to sign: \"%s\"", stringToSign)); - } - - String signature = this.signer.sign(stringToSign); - cr.getHeaders().putSingle("Authorization", "SharedKeyLite " + this.accountName + ":" + signature); - } - - /** - * Constructing the Canonicalized Headers String - * - * To construct the CanonicalizedHeaders portion of the signature string, - * follow these steps: - * - * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header. - * - * 2. Convert each HTTP header name to lowercase. - * - * 3. Sort the headers lexicographically by header name in ascending order. Note that each header may appear only - * once in the string. - * - * 4. Unfold the string by replacing any breaking white space with a single space. - * - * 5. Trim any white space around the colon in the header. - * - * 6. Finally, append a new line character to each canonicalized header in the resulting list. Construct the - * CanonicalizedHeaders string by concatenating all headers in this list into a single string. - */ - private String addCanonicalizedHeaders(ClientRequest cr) { - return SharedKeyUtils.getCanonicalizedHeaders(cr); - } - - /** - * This format supports Shared Key and Shared Key Lite for all versions of the Table service, and Shared Key Lite - * for the 2009-09-19 version of the Blob and Queue services. This format is identical to that used with previous - * versions of the storage services. Construct the CanonicalizedResource string in this format as follows: - * - * 1. Beginning with an empty string (""), append a forward slash (/), followed by the name of the account that owns - * the resource being accessed. - * - * 2. Append the resource's encoded URI path. If the request URI addresses a component of the resource, append the - * appropriate query string. The query string should include the question mark and the comp parameter (for example, - * ?comp=metadata). No other parameters should be included on the query string. - */ - private String addCanonicalizedResource(ClientRequest cr) { - String result = "/" + this.accountName; - - result += cr.getURI().getPath(); - - List queryParams = SharedKeyUtils.getQueryParams(cr.getURI().getQuery()); - for (QueryParam p : queryParams) { - if ("comp".equals(p.getName())) { - result += "?" + p.getName() + "=" + p.getValues().get(0); - } - } - return result; - } - - private String getHeader(ClientRequest cr, String headerKey) { - return SharedKeyUtils.getHeader(cr, headerKey); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java deleted file mode 100644 index b3cfcecbf5451..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.implementation; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; - -import com.sun.jersey.api.client.ClientRequest; - -public class SharedKeyUtils { - public static final String AUTHORIZATION_FILTER_MARKER = SharedKeyUtils.class.getName(); - - /* - * Constructing the Canonicalized Headers String - * - * To construct the CanonicalizedHeaders portion of the signature string, - * follow these steps: 1. Retrieve all headers for the resource that begin - * with x-ms-, including the x-ms-date header. 2. Convert each HTTP header - * name to lowercase. 3. Sort the headers lexicographically by header name, - * in ascending order. Note that each header may appear only once in the - * string. 4. Unfold the string by replacing any breaking white space with a - * single space. 5. Trim any white space around the colon in the header. 6. - * Finally, append a new line character to each canonicalized header in the - * resulting list. Construct the CanonicalizedHeaders string by - * concatenating all headers in this list into a single string. - */ - public static String getCanonicalizedHeaders(ClientRequest cr) { - ArrayList msHeaders = new ArrayList(); - for (String key : cr.getHeaders().keySet()) { - if (key.toLowerCase(Locale.US).startsWith("x-ms-")) { - msHeaders.add(key.toLowerCase(Locale.US)); - } - } - Collections.sort(msHeaders); - - String result = ""; - for (String msHeader : msHeaders) { - result += msHeader + ":" + cr.getHeaders().getFirst(msHeader) + "\n"; - } - return result; - } - - public static String getHeader(ClientRequest cr, String headerKey) { - List values = cr.getHeaders().get(headerKey); - if (values == null || values.size() != 1) { - return nullEmpty(null); - } - - return nullEmpty(values.get(0).toString()); - } - - private static String nullEmpty(String value) { - return value != null ? value : ""; - } - - public static List getQueryParams(String queryString) { - ArrayList result = new ArrayList(); - - if (queryString != null) { - String[] params = queryString.split("&"); - for (String param : params) { - result.add(getQueryParam(param)); - } - } - - return result; - } - - private static QueryParam getQueryParam(String param) { - QueryParam result = new QueryParam(); - - int index = param.indexOf("="); - if (index < 0) { - result.setName(param); - } - else { - result.setName(param.substring(0, index)); - - String value = param.substring(index + 1); - int commaIndex = value.indexOf(','); - if (commaIndex < 0) { - result.addValue(value); - } - else { - for (String v : value.split(",")) { - result.addValue(v); - } - } - } - - return result; - } - - public static class QueryParam implements Comparable { - private String name; - private final List values = new ArrayList(); - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getValues() { - return values; - } - - public void addValue(String value) { - values.add(value); - } - - public int compareTo(QueryParam o) { - return this.name.compareTo(o.name); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java deleted file mode 100644 index 24018221dc132..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; - -import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; - -/** - * Represents a set of access conditions to be used for operations against the storage services. - */ -public final class AccessCondition { - - /** - * Specifies that no access condition is set. - */ - public static final AccessCondition NONE = new AccessCondition(AccessConditionHeaderType.NONE, null); - - /** - * Returns an access condition such that an operation will be performed only if the resource's ETag value matches - * the specified ETag value. - *

- * Setting this access condition modifies the request to include the HTTP If-Match conditional header. If - * this access condition is set, the operation is performed only if the ETag of the resource matches the specified - * ETag. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param etag - * A String that represents the ETag value to check. - * - * @return An AccessCondition object that represents the If-Match condition. - */ - public static AccessCondition ifMatch(String etag) { - return new AccessCondition(AccessConditionHeaderType.IF_MATCH, etag); - } - - /** - * Returns an access condition such that an operation will be performed only if the resource has been modified since - * the specified time. - *

- * Setting this access condition modifies the request to include the HTTP If-Modified-Since conditional - * header. If this access condition is set, the operation is performed only if the resource has been modified since - * the specified time. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param lastMotified - * A java.util.Date object that represents the last-modified time to check for the resource. - * - * @return An AccessCondition object that represents the If-Modified-Since condition. - */ - public static AccessCondition ifModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_MODIFIED_SINCE, - new RFC1123DateConverter().format(lastMotified)); - } - - /** - * Returns an access condition such that an operation will be performed only if the resource's ETag value does not - * match the specified ETag value. - *

- * Setting this access condition modifies the request to include the HTTP If-None-Match conditional header. - * If this access condition is set, the operation is performed only if the ETag of the resource does not match the - * specified ETag. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param etag - * A String that represents the ETag value to check. - * - * @return An AccessCondition object that represents the If-None-Match condition. - */ - public static AccessCondition ifNoneMatch(String etag) { - return new AccessCondition(AccessConditionHeaderType.IF_NONE_MATCH, etag); - } - - /** - * Returns an access condition such that an operation will be performed only if the resource has not been modified - * since the specified time. - *

- * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional - * header. If this access condition is set, the operation is performed only if the resource has not been modified - * since the specified time. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param lastMotified - * A java.util.Date object that represents the last-modified time to check for the resource. - * - * @return An AccessCondition object that represents the If-Unmodified-Since condition. - */ - public static AccessCondition ifNotModifiedSince(Date lastMotified) { - return new AccessCondition(AccessConditionHeaderType.IF_UNMODIFIED_SINCE, - new RFC1123DateConverter().format(lastMotified)); - } - - /** - * Represents the header type. - */ - private AccessConditionHeaderType header = AccessConditionHeaderType.NONE; - - /** - * Represents the header value. - */ - private String value; - - /** - * Creates an instance of the AccessCondition class. - */ - protected AccessCondition() { - // Empty Default Ctor - } - - /** - * Creates an instance of the AccessCondition class using the specified header type and value. - * - * @param headerType - * An {@link AccessConditionHeaderType} value that represents the header type. - * @param value - * A String that represents the value of the header. - */ - protected AccessCondition(AccessConditionHeaderType headerType, String value) { - this.setHeader(headerType); - this.setValue(value); - } - - public AccessConditionHeaderType getHeader() { - return header; - } - - public void setHeader(AccessConditionHeaderType header) { - this.header = header; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} 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 deleted file mode 100644 index 30045ee84b981..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessConditionHeaderType.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -/** - * Specifies the kinds of conditional headers that may be set for a request. - */ -public enum AccessConditionHeaderType { - /** - * Specifies that no conditional headers are set. - */ - NONE, - - /** - * Specifies the If-Unmodified-Since conditional header is set. - */ - IF_UNMODIFIED_SINCE, - - /** - * Specifies the If-Match conditional header is set. - */ - IF_MATCH, - - /** - * Specifies the If-Modified-Since conditional header is set. - */ - IF_MODIFIED_SINCE, - - /** - * Specifies the If-None-Match conditional header is set. - */ - IF_NONE_MATCH; - - /** - * 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. - */ - @Override - public String toString() { - switch (this) { - case IF_MATCH: - return "If-Match"; - case IF_UNMODIFIED_SINCE: - return "If-Unmodified-Since"; - case IF_MODIFIED_SINCE: - return "If-Modified-Since"; - case IF_NONE_MATCH: - return "If-None-Match"; - default: - return ""; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java deleted file mode 100644 index af9ea1931ee2c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - - -public class AcquireLeaseOptions extends BlobServiceOptions { - private AccessCondition accessCondition; - - @Override - public AcquireLeaseOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public AcquireLeaseOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java deleted file mode 100644 index 1565c42585004..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class AcquireLeaseResult { - private String leaseId; - - public String getLeaseId() { - return leaseId; - } - - public void setLeaseId(String leaseId) { - this.leaseId = leaseId; - } -} 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 deleted file mode 100644 index 73d968d1153f6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobProperties.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.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; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java deleted file mode 100644 index 879986c2640c5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class BlobServiceOptions { - // Nullable because it is optional - private Integer timeout; - - public Integer getTimeout() { - return timeout; - } - - public BlobServiceOptions setTimeout(Integer timeout) { - this.timeout = timeout; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java deleted file mode 100644 index 7fcdfe314651b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlElementRefs; -import javax.xml.bind.annotation.XmlMixed; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.core.utils.pipeline.Base64StringAdapter; - -@XmlRootElement(name = "BlockList") -public class BlockList { - private List entries = new ArrayList(); - - public BlockList addCommittedEntry(String blockId) { - CommittedEntry entry = new CommittedEntry(); - entry.setBlockId(blockId); - getEntries().add(entry); - return this; - } - - public BlockList addUncommittedEntry(String blockId) { - UncommittedEntry entry = new UncommittedEntry(); - entry.setBlockId(blockId); - getEntries().add(entry); - return this; - } - - public BlockList addLatestEntry(String blockId) { - LatestEntry entry = new LatestEntry(); - entry.setBlockId(blockId); - getEntries().add(entry); - return this; - } - - @XmlElementRefs({ @XmlElementRef(name = "Committed", type = CommittedEntry.class), - @XmlElementRef(name = "Uncommitted", type = UncommittedEntry.class), - @XmlElementRef(name = "Latest", type = LatestEntry.class) }) - @XmlMixed - public List getEntries() { - return entries; - } - - public BlockList setEntries(List entries) { - this.entries = entries; - return this; - } - - public abstract static class Entry { - private String blockId; - - @XmlJavaTypeAdapter(Base64StringAdapter.class) - @XmlValue - public String getBlockId() { - return blockId; - } - - public void setBlockId(String blockId) { - this.blockId = blockId; - } - } - - @XmlRootElement(name = "Committed") - public static class CommittedEntry extends Entry { - } - - @XmlRootElement(name = "Uncommitted") - public static class UncommittedEntry extends Entry { - } - - @XmlRootElement(name = "Latest") - public static class LatestEntry extends Entry { - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java deleted file mode 100644 index b502f18929df1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class CommitBlobBlocksOptions extends BlobServiceOptions { - private String blobContentType; - private String blobContentEncoding; - private String blobContentLanguage; - private String blobContentMD5; - private String blobCacheControl; - private HashMap metadata = new HashMap(); - private String leaseId; - private AccessCondition accessCondition; - - @Override - public CommitBlobBlocksOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getBlobContentType() { - return blobContentType; - } - - public CommitBlobBlocksOptions setBlobContentType(String blobContentType) { - this.blobContentType = blobContentType; - return this; - } - - public String getBlobContentEncoding() { - return blobContentEncoding; - } - - public CommitBlobBlocksOptions setBlobContentEncoding(String blobContentEncoding) { - this.blobContentEncoding = blobContentEncoding; - return this; - } - - public String getBlobContentLanguage() { - return blobContentLanguage; - } - - public CommitBlobBlocksOptions setBlobContentLanguage(String blobContentLanguage) { - this.blobContentLanguage = blobContentLanguage; - return this; - } - - public String getBlobContentMD5() { - return blobContentMD5; - } - - public CommitBlobBlocksOptions setBlobContentMD5(String blobContentMD5) { - this.blobContentMD5 = blobContentMD5; - return this; - } - - public String getBlobCacheControl() { - return blobCacheControl; - } - - public CommitBlobBlocksOptions setBlobCacheControl(String blobCacheControl) { - this.blobCacheControl = blobCacheControl; - return this; - } - - public HashMap getMetadata() { - return metadata; - } - - public CommitBlobBlocksOptions setMetadata(HashMap metadata) { - this.metadata = metadata; - return this; - } - - public CommitBlobBlocksOptions addMetadata(String key, String value) { - this.getMetadata().put(key, value); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CommitBlobBlocksOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public CommitBlobBlocksOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java deleted file mode 100644 index 628d08d95cab6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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.ContainerACLDateAdapter; - -public class ContainerACL { - private String etag; - private Date lastModified; - private PublicAccessType publicAccess; - private List signedIdentifiers = new ArrayList(); - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public PublicAccessType getPublicAccess() { - return publicAccess; - } - - public void setPublicAccess(PublicAccessType publicAccess) { - this.publicAccess = publicAccess; - } - - public List getSignedIdentifiers() { - return signedIdentifiers; - } - - public void setSignedIdentifiers(List signedIdentifiers) { - this.signedIdentifiers = signedIdentifiers; - } - - public void addSignedIdentifier(String id, Date start, Date expiry, String permission) { - AccessPolicy accessPolicy = new AccessPolicy(); - accessPolicy.setStart(start); - accessPolicy.setExpiry(expiry); - accessPolicy.setPermission(permission); - - SignedIdentifier signedIdentifier = new SignedIdentifier(); - signedIdentifier.setId(id); - signedIdentifier.setAccessPolicy(accessPolicy); - - this.getSignedIdentifiers().add(signedIdentifier); - } - - @XmlRootElement(name = "SignedIdentifiers") - public static class SignedIdentifiers { - private List signedIdentifiers = new ArrayList(); - - @XmlElement(name = "SignedIdentifier") - public List getSignedIdentifiers() { - return signedIdentifiers; - } - - public void setSignedIdentifiers(List signedIdentifiers) { - this.signedIdentifiers = signedIdentifiers; - } - } - - public static class SignedIdentifier { - private String id; - private AccessPolicy accessPolicy; - - @XmlElement(name = "Id") - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @XmlElement(name = "AccessPolicy") - public AccessPolicy getAccessPolicy() { - return accessPolicy; - } - - public void setAccessPolicy(AccessPolicy accessPolicy) { - this.accessPolicy = accessPolicy; - } - } - - public static class AccessPolicy { - private Date start; - private Date expiry; - private String permission; - - @XmlElement(name = "Start") - @XmlJavaTypeAdapter(ContainerACLDateAdapter.class) - public Date getStart() { - return start; - } - - public void setStart(Date start) { - this.start = start; - } - - @XmlElement(name = "Expiry") - @XmlJavaTypeAdapter(ContainerACLDateAdapter.class) - public Date getExpiry() { - return expiry; - } - - public void setExpiry(Date expiry) { - this.expiry = expiry; - } - - @XmlElement(name = "Permission") - public String getPermission() { - return permission; - } - - public void setPermission(String permission) { - this.permission = permission; - } - } - - public static enum PublicAccessType { - NONE, BLOBS_ONLY, CONTAINER_AND_BLOBS, - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java deleted file mode 100644 index dcecf99c157f3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class CopyBlobOptions extends BlobServiceOptions { - private String leaseId; - private AccessCondition accessCondition; - private String sourceLeaseId; - private String sourceSnapshot; - private HashMap metadata = new HashMap(); - private AccessCondition sourceAccessCondition; - - @Override - public CopyBlobOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getSourceSnapshot() { - return sourceSnapshot; - } - - public CopyBlobOptions setSourceSnapshot(String sourceSnapshot) { - this.sourceSnapshot = sourceSnapshot; - return this; - } - - public HashMap getMetadata() { - return metadata; - } - - public CopyBlobOptions setMetadata(HashMap metadata) { - this.metadata = metadata; - return this; - } - - public CopyBlobOptions addMetadata(String key, String value) { - this.getMetadata().put(key, value); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CopyBlobOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getSourceLeaseId() { - return sourceLeaseId; - } - - public CopyBlobOptions setSourceLeaseId(String sourceLeaseId) { - this.sourceLeaseId = sourceLeaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public CopyBlobOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } - - public AccessCondition getSourceAccessCondition() { - return sourceAccessCondition; - } - - public CopyBlobOptions setSourceAccessCondition(AccessCondition sourceAccessCondition) { - this.sourceAccessCondition = sourceAccessCondition; - return this; - } -} 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 deleted file mode 100644 index 65b3d4b40855f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobBlockOptions.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class CreateBlobBlockOptions extends BlobServiceOptions { - private String leaseId; - private String contentMD5; - - @Override - public CreateBlobBlockOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CreateBlobBlockOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getContentMD5() { - return contentMD5; - } - - public CreateBlobBlockOptions setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java deleted file mode 100644 index 41fef87ff0cbf..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class CreateBlobOptions extends BlobServiceOptions { - private String contentType; - private String contentEncoding; - private String contentLanguage; - private String contentMD5; - private String cacheControl; - private String blobContentType; - private String blobContentEncoding; - private String blobContentLanguage; - private String blobContentMD5; - private String blobCacheControl; - private HashMap metadata = new HashMap(); - private String leaseId; - private Long sequenceNumber; - private AccessCondition accessCondition; - - @Override - public CreateBlobOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getContentType() { - return contentType; - } - - public CreateBlobOptions setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - public String getContentEncoding() { - return contentEncoding; - } - - public CreateBlobOptions setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - public String getContentLanguage() { - return contentLanguage; - } - - public CreateBlobOptions setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - public String getContentMD5() { - return contentMD5; - } - - public CreateBlobOptions setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - return this; - } - - public String getCacheControl() { - return cacheControl; - } - - public CreateBlobOptions setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - public String getBlobContentType() { - return blobContentType; - } - - public CreateBlobOptions setBlobContentType(String blobContentType) { - this.blobContentType = blobContentType; - return this; - } - - public String getBlobContentEncoding() { - return blobContentEncoding; - } - - public CreateBlobOptions setBlobContentEncoding(String blobContentEncoding) { - this.blobContentEncoding = blobContentEncoding; - return this; - } - - public String getBlobContentLanguage() { - return blobContentLanguage; - } - - public CreateBlobOptions setBlobContentLanguage(String blobContentLanguage) { - this.blobContentLanguage = blobContentLanguage; - return this; - } - - public String getBlobContentMD5() { - return blobContentMD5; - } - - public CreateBlobOptions setBlobContentMD5(String blobContentMD5) { - this.blobContentMD5 = blobContentMD5; - return this; - } - - public String getBlobCacheControl() { - return blobCacheControl; - } - - public CreateBlobOptions setBlobCacheControl(String blobCacheControl) { - this.blobCacheControl = blobCacheControl; - return this; - } - - public HashMap getMetadata() { - return metadata; - } - - public CreateBlobOptions setMetadata(HashMap metadata) { - this.metadata = metadata; - return this; - } - - public CreateBlobOptions addMetadata(String key, String value) { - this.getMetadata().put(key, value); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CreateBlobOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public Long getSequenceNumber() { - return sequenceNumber; - } - - public CreateBlobOptions setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public CreateBlobOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java deleted file mode 100644 index cbbde22e0f99b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class CreateBlobPagesOptions extends BlobServiceOptions { - private String leaseId; - private String contentMD5; - private AccessCondition accessCondition; - - @Override - public CreateBlobPagesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CreateBlobPagesOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getContentMD5() { - return contentMD5; - } - - public CreateBlobPagesOptions setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public CreateBlobPagesOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java deleted file mode 100644 index b7eb8e83f56df..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; - -public class CreateBlobPagesResult { - private String etag; - private Date lastModified; - private String contentMD5; - private long sequenceNumber; - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public String getContentMD5() { - return contentMD5; - } - - public void setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - } - - public long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java deleted file mode 100644 index 35ffd6419f97a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class CreateBlobSnapshotOptions extends BlobServiceOptions { - private HashMap metadata = new HashMap(); - private String leaseId; - private AccessCondition accessCondition; - - @Override - public CreateBlobSnapshotOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public HashMap getMetadata() { - return metadata; - } - - public CreateBlobSnapshotOptions setMetadata(HashMap metadata) { - this.metadata = metadata; - return this; - } - - public CreateBlobSnapshotOptions addMetadata(String key, String value) { - this.getMetadata().put(key, value); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public CreateBlobSnapshotOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public CreateBlobSnapshotOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java deleted file mode 100644 index eeaf0fb61b377..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; - -public class CreateBlobSnapshotResult { - private String snapshot; - private String etag; - private Date lastModified; - - public String getSnapshot() { - return snapshot; - } - - public void setSnapshot(String snapshot) { - this.snapshot = snapshot; - } - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } -} 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 deleted file mode 100644 index 2ad569ba45423..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateContainerOptions.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class CreateContainerOptions extends BlobServiceOptions { - private String publicAccess; - private HashMap metadata = new HashMap(); - - @Override - public CreateContainerOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public HashMap getMetadata() { - return metadata; - } - - public CreateContainerOptions setMetadata(HashMap metadata) { - this.metadata = metadata; - return this; - } - - public CreateContainerOptions addMetadata(String key, String value) { - this.getMetadata().put(key, value); - return this; - } - - public String getPublicAccess() { - return publicAccess; - } - - public CreateContainerOptions setPublicAccess(String publicAccess) { - this.publicAccess = publicAccess; - return this; - } -} 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 deleted file mode 100644 index 729a68c9e99f9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteBlobOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class DeleteBlobOptions extends BlobServiceOptions { - private String snapshot; - private String leaseId; - private boolean deleteSnaphotsOnly; - private AccessCondition accessCondition; - - @Override - public DeleteBlobOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public DeleteBlobOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public DeleteBlobOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public boolean getDeleteSnaphotsOnly() { - return deleteSnaphotsOnly; - } - - public DeleteBlobOptions setDeleteSnaphotsOnly(boolean deleteSnaphotsOnly) { - this.deleteSnaphotsOnly = deleteSnaphotsOnly; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public DeleteBlobOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} 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 deleted file mode 100644 index 1916ecb70320c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/DeleteContainerOptions.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class DeleteContainerOptions extends BlobServiceOptions { - private AccessCondition accessCondition; - - @Override - public DeleteContainerOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public DeleteContainerOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} 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 deleted file mode 100644 index 9b1e055d8ae8f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataOptions.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class GetBlobMetadataOptions extends BlobServiceOptions { - private String snapshot; - private String leaseId; - private AccessCondition accessCondition; - - @Override - public GetBlobMetadataOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public GetBlobMetadataOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public GetBlobMetadataOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public GetBlobMetadataOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java deleted file mode 100644 index 93348f23cdba6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; -import java.util.HashMap; - -public class GetBlobMetadataResult { - private String etag; - private Date lastModified; - private HashMap metadata; - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public HashMap getMetadata() { - return metadata; - } - - public void setMetadata(HashMap metadata) { - this.metadata = metadata; - } -} 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 deleted file mode 100644 index e35db2b0c05f6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class GetBlobOptions extends BlobServiceOptions { - private String snapshot; - private String leaseId; - private boolean computeRangeMD5; - private Long rangeStart; - private Long rangeEnd; - private AccessCondition accessCondition; - - @Override - public GetBlobOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public GetBlobOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public GetBlobOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public boolean isComputeRangeMD5() { - return computeRangeMD5; - } - - public GetBlobOptions setComputeRangeMD5(boolean computeRangeMD5) { - this.computeRangeMD5 = computeRangeMD5; - return this; - } - - public Long getRangeStart() { - return rangeStart; - } - - public GetBlobOptions setRangeStart(Long rangeStart) { - this.rangeStart = rangeStart; - return this; - } - - public Long getRangeEnd() { - return rangeEnd; - } - - public GetBlobOptions setRangeEnd(Long rangeEnd) { - this.rangeEnd = rangeEnd; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public GetBlobOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} 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 deleted file mode 100644 index 8c252723fc180..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesOptions.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class GetBlobPropertiesOptions extends BlobServiceOptions { - private String snapshot; - private String leaseId; - private AccessCondition accessCondition; - - @Override - public GetBlobPropertiesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public GetBlobPropertiesOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public GetBlobPropertiesOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public GetBlobPropertiesOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} 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 deleted file mode 100644 index 9d20e5221e945..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobPropertiesResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.HashMap; - -public class GetBlobPropertiesResult { - private BlobProperties properties; - private HashMap metadata = new HashMap(); - - public BlobProperties getProperties() { - return properties; - } - - public void setProperties(BlobProperties properties) { - this.properties = properties; - } - - public HashMap getMetadata() { - return metadata; - } - - public void setMetadata(HashMap metadata) { - this.metadata = metadata; - } -} 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 deleted file mode 100644 index b29a99fee7a27..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.io.InputStream; -import java.util.HashMap; - -public class GetBlobResult { - private InputStream contentStream; - private BlobProperties properties; - private HashMap metadata; - - public InputStream getContentStream() { - return contentStream; - } - - public void setContentStream(InputStream contentStream) { - this.contentStream = contentStream; - } - - public BlobProperties getProperties() { - return properties; - } - - public void setProperties(BlobProperties properties) { - this.properties = properties; - } - - public HashMap getMetadata() { - return metadata; - } - - public void setMetadata(HashMap metadata) { - this.metadata = metadata; - } -} 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 deleted file mode 100644 index b0277c1b0bac0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerACLResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.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/GetContainerPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java deleted file mode 100644 index 24c6d318e4995..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; -import java.util.HashMap; - -public class GetContainerPropertiesResult { - private String etag; - private Date lastModified; - private HashMap metadata; - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public HashMap getMetadata() { - return metadata; - } - - public void setMetadata(HashMap metadata) { - this.metadata = 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 deleted file mode 100644 index 0a5a0e0f16f8b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetServicePropertiesResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.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/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 deleted file mode 100644 index 624474ea57f74..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class ListBlobBlocksOptions extends BlobServiceOptions { - private String leaseId; - private String snapshot; - private boolean committedList; - private boolean uncommittedList; - - @Override - public ListBlobBlocksOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public ListBlobBlocksOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public ListBlobBlocksOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public boolean isCommittedList() { - return committedList; - } - - public ListBlobBlocksOptions setCommittedList(boolean committedList) { - this.committedList = committedList; - return this; - } - - public boolean isUncommittedList() { - return uncommittedList; - } - - public ListBlobBlocksOptions setUncommittedList(boolean uncommittedList) { - this.uncommittedList = uncommittedList; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java deleted file mode 100644 index 125c5cb6934e9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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.windowsazure.services.core.utils.pipeline.Base64StringAdapter; - -@XmlRootElement(name = "BlockList") -public class ListBlobBlocksResult { - private Date lastModified; - private String etag; - private String contentType; - private long contentLength; - private List committedBlocks = new ArrayList(); - private List uncommittedBlocks = new ArrayList(); - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String contentType) { - this.contentType = contentType; - } - - public long getContentLength() { - return contentLength; - } - - public void setContentLength(long contentLength) { - this.contentLength = contentLength; - } - - @XmlElementWrapper(name = "CommittedBlocks") - @XmlElement(name = "Block") - public List getCommittedBlocks() { - return committedBlocks; - } - - public void setCommittedBlocks(List committedBlocks) { - this.committedBlocks = committedBlocks; - } - - @XmlElementWrapper(name = "UncommittedBlocks") - @XmlElement(name = "Block") - public List getUncommittedBlocks() { - return uncommittedBlocks; - } - - public void setUncommittedBlocks(List uncommittedBlocks) { - this.uncommittedBlocks = uncommittedBlocks; - } - - public static class Entry { - private String blockId; - private long blockLength; - - @XmlElement(name = "Name") - @XmlJavaTypeAdapter(Base64StringAdapter.class) - public String getBlockId() { - return blockId; - } - - public void setBlockId(String blockId) { - this.blockId = blockId; - } - - @XmlElement(name = "Size") - public long getBlockLength() { - return blockLength; - } - - public void setBlockLength(long blockLength) { - this.blockLength = blockLength; - } - } -} 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 deleted file mode 100644 index 916981de10f51..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsOptions.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class ListBlobRegionsOptions extends BlobServiceOptions { - private String leaseId; - private String snapshot; - private Long rangeStart; - private Long rangeEnd; - private AccessCondition accessCondition; - - @Override - public ListBlobRegionsOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public ListBlobRegionsOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getSnapshot() { - return snapshot; - } - - public ListBlobRegionsOptions setSnapshot(String snapshot) { - this.snapshot = snapshot; - return this; - } - - public Long getRangeStart() { - return rangeStart; - } - - public ListBlobRegionsOptions setRangeStart(Long rangeStart) { - this.rangeStart = rangeStart; - return this; - } - - public Long getRangeEnd() { - return rangeEnd; - } - - public ListBlobRegionsOptions setRangeEnd(Long rangeEnd) { - this.rangeEnd = rangeEnd; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public ListBlobRegionsOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} 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 deleted file mode 100644 index da1ea2e16854b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobRegionsResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "PageList") -public class ListBlobRegionsResult { - private Date lastModified; - private String etag; - private long contentLength; - private List pageRanges; - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public long getContentLength() { - return contentLength; - } - - public void setContentLength(long contentLength) { - this.contentLength = contentLength; - } - - @XmlElement(name = "PageRange") - public List getPageRanges() { - return pageRanges; - } - - public void setPageRanges(List pageRanges) { - this.pageRanges = pageRanges; - } -} 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 deleted file mode 100644 index d437f99b8ae7d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsOptions.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class ListBlobsOptions extends BlobServiceOptions { - private String prefix; - private String marker; - private int maxResults; - private String delimiter; - private boolean includeMetadata; - private boolean includeSnapshots; - private boolean includeUncommittedBlobs; - - @Override - public ListBlobsOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getPrefix() { - return prefix; - } - - public ListBlobsOptions setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - public String getMarker() { - return marker; - } - - public ListBlobsOptions setMarker(String marker) { - this.marker = marker; - return this; - } - - public int getMaxResults() { - return maxResults; - } - - public ListBlobsOptions setMaxResults(int maxResults) { - this.maxResults = maxResults; - return this; - } - - public String getDelimiter() { - return delimiter; - } - - public ListBlobsOptions setDelimiter(String delimiter) { - this.delimiter = delimiter; - return this; - } - - 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 setIncludeUncommittedBlobs(boolean includeUncommittedBlobs) { - this.includeUncommittedBlobs = includeUncommittedBlobs; - return this; - } -} 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 deleted file mode 100644 index 35acf17541c56..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobsResult.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.ArrayList; -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.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; - -import com.microsoft.windowsazure.services.blob.implementation.MetadataAdapter; - -@XmlRootElement(name = "EnumerationResults") -public class ListBlobsResult { - private List blobPrefixes = new ArrayList(); - private List blobs = new ArrayList(); - private String containerName; - private String prefix; - private String marker; - private String nextMarker; - private String delimiter; - private int maxResults; - - @XmlElementWrapper(name = "Blobs") - @XmlElementRefs({ @XmlElementRef(name = "BlobPrefix", type = BlobPrefixEntry.class), - @XmlElementRef(name = "Blob", type = BlobEntry.class) }) - public List getEntries() { - ArrayList result = new ArrayList(); - result.addAll(this.blobPrefixes); - result.addAll(this.blobs); - return result; - } - - public void setEntries(List 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") - 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; - } - - @XmlElement(name = "Delimiter") - public String getDelimiter() { - return delimiter; - } - - public void setDelimiter(String delimiter) { - this.delimiter = delimiter; - } - - @XmlAttribute(name = "ContainerName") - public String getContainerName() { - return containerName; - } - - public void setContainerName(String containerName) { - this.containerName = containerName; - } - - public static abstract class ListBlobsEntry { - - } - - @XmlRootElement(name = "BlobPrefix") - public static class BlobPrefixEntry 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 BlobEntry extends ListBlobsEntry { - private String name; - private String url; - private String snapshot; - private HashMap metadata = new HashMap(); - private BlobProperties properties; - - @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 = "Properties") - public BlobProperties getProperties() { - return properties; - } - - public void setProperties(BlobProperties properties) { - this.properties = properties; - } - - @XmlElement(name = "Snapshot") - public String getSnapshot() { - return snapshot; - } - - public void setSnapshot(String snapshot) { - this.snapshot = snapshot; - } - - @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/windowsazure/services/blob/models/ListContainersOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java deleted file mode 100644 index 4d795d2410c08..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class ListContainersOptions extends BlobServiceOptions { - private String prefix; - private String marker; - private int maxResults; - private boolean includeMetadata; - - @Override - public ListContainersOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getPrefix() { - return prefix; - } - - public ListContainersOptions setPrefix(String prefix) { - this.prefix = prefix; - return this; - } - - public String getMarker() { - return marker; - } - - public ListContainersOptions setMarker(String marker) { - this.marker = marker; - return this; - } - - public int getMaxResults() { - return maxResults; - } - - public ListContainersOptions setMaxResults(int maxResults) { - this.maxResults = maxResults; - return this; - } - - public boolean isIncludeMetadata() { - return includeMetadata; - } - - public ListContainersOptions setIncludeMetadata(boolean includeMetadata) { - this.includeMetadata = includeMetadata; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java deleted file mode 100644 index 36ca841ed734d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; -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.windowsazure.services.blob.implementation.MetadataAdapter; -import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateAdapter; - -@XmlRootElement(name = "EnumerationResults") -public class ListContainersResult { - private List containers; - private String accountName; - private String prefix; - private String marker; - private String nextMarker; - private int maxResults; - - @XmlElementWrapper(name = "Containers") - @XmlElement(name = "Container") - public List getContainers() { - return containers; - } - - public void setContainers(List value) { - this.containers = 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 Container { - private String name; - private String url; - private HashMap metadata = new HashMap(); - private ContainerProperties properties; - - @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 = "Properties") - public ContainerProperties getProperties() { - return properties; - } - - public void setProperties(ContainerProperties properties) { - this.properties = properties; - } - - @XmlElement(name = "Metadata") - @XmlJavaTypeAdapter(MetadataAdapter.class) - public HashMap getMetadata() { - return metadata; - } - - public void setMetadata(HashMap metadata) { - this.metadata = metadata; - } - } - - public static class ContainerProperties { - private Date lastModified; - private String etag; - - @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; - } - } -} 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 deleted file mode 100644 index afef6edd6096b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/PageRange.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.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; - } -} 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 deleted file mode 100644 index 4171ef288f4a7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ServiceProperties.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "StorageServiceProperties") -public class ServiceProperties { - private Logging logging = new Logging(); - private Metrics metrics = new 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/windowsazure/services/blob/models/SetBlobMetadataOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java deleted file mode 100644 index c30ec2b0d1f04..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataOptions.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class SetBlobMetadataOptions extends BlobServiceOptions { - private String leaseId; - private AccessCondition accessCondition; - - @Override - public SetBlobMetadataOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public SetBlobMetadataOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public SetBlobMetadataOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java deleted file mode 100644 index abda2abdfdb60..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; - -public class SetBlobMetadataResult { - private String etag; - private Date lastModified; - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } -} 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 deleted file mode 100644 index ed1e9c631cd7d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class SetBlobPropertiesOptions extends BlobServiceOptions { - private String leaseId; - private String contentType; - private Long contentLength; - private String contentEncoding; - private String contentLanguage; - private String contentMD5; - private String cacheControl; - private String sequenceNumberAction; - private Long sequenceNumber; - private AccessCondition accessCondition; - - @Override - public SetBlobPropertiesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public String getContentType() { - return contentType; - } - - public SetBlobPropertiesOptions setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - public Long getContentLength() { - return contentLength; - } - - public SetBlobPropertiesOptions setContentLength(Long contentLength) { - this.contentLength = contentLength; - return this; - } - - public String getContentEncoding() { - return contentEncoding; - } - - public SetBlobPropertiesOptions setContentEncoding(String contentEncoding) { - this.contentEncoding = contentEncoding; - return this; - } - - public String getContentLanguage() { - return contentLanguage; - } - - public SetBlobPropertiesOptions setContentLanguage(String contentLanguage) { - this.contentLanguage = contentLanguage; - return this; - } - - public String getContentMD5() { - return contentMD5; - } - - public SetBlobPropertiesOptions setContentMD5(String contentMD5) { - this.contentMD5 = contentMD5; - return this; - } - - public String getCacheControl() { - return cacheControl; - } - - public SetBlobPropertiesOptions setCacheControl(String cacheControl) { - this.cacheControl = cacheControl; - return this; - } - - public Long getSequenceNumber() { - return sequenceNumber; - } - - public SetBlobPropertiesOptions setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - return this; - } - - public String getLeaseId() { - return leaseId; - } - - public SetBlobPropertiesOptions setLeaseId(String leaseId) { - this.leaseId = leaseId; - return this; - } - - public String getSequenceNumberAction() { - return sequenceNumberAction; - } - - public SetBlobPropertiesOptions setSequenceNumberAction(String sequenceNumberAction) { - this.sequenceNumberAction = sequenceNumberAction; - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public SetBlobPropertiesOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java deleted file mode 100644 index f505058f1890c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -import java.util.Date; - -public class SetBlobPropertiesResult { - private String etag; - private Date lastModified; - private Long sequenceNumber; - - public String getEtag() { - return etag; - } - - public void setEtag(String etag) { - this.etag = etag; - } - - public Date getLastModified() { - return lastModified; - } - - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - public Long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } -} 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 deleted file mode 100644 index f27304a09b755..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetContainerMetadataOptions.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob.models; - -public class SetContainerMetadataOptions extends BlobServiceOptions { - private AccessCondition accessCondition; - - @Override - public SetContainerMetadataOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public AccessCondition getAccessCondition() { - return accessCondition; - } - - public SetContainerMetadataOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java deleted file mode 100644 index 5b7459507322c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.util.Map; - -public interface Builder { - - public abstract T build(String profile, Class service, Map properties); - - public interface Factory { - T create(String profile, Builder builder, Map properties); - } - - public interface Alteration { - T alter(T instance, Builder builder, Map properties); - } - - public interface Registry { - Registry add(Class service); - - Registry add(Class service, Class implementation); - - Registry add(Factory factory); - - void alter(Class service, Alteration alteration); - } - - public interface Exports { - void register(Registry registry); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java deleted file mode 100644 index 1664dec987818..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.sun.jersey.api.client.config.ClientConfig; - -public class Configuration { - - private static Configuration instance; - Map properties; - Builder builder; - - static Log log = LogFactory.getLog(Configuration.class); - - public Configuration() { - this.properties = new HashMap(); - this.builder = DefaultBuilder.create(); - init(); - } - - public Configuration(Builder builder) { - this.properties = new HashMap(); - this.builder = builder; - init(); - } - - private void init() { - setProperty("ClientConfig", builder.build("", ClientConfig.class, properties)); - } - - public static Configuration getInstance() { - if (instance == null) { - try { - instance = Configuration.load(); - } - catch (IOException e) { - log.error("Unable to load META-INF/com.microsoft.windowsazure.properties", e); - instance = new Configuration(); - } - } - return instance; - } - - public static void setInstance(Configuration instance) { - Configuration.instance = instance; - } - - public static Configuration load() throws IOException { - Configuration config = new Configuration(); - - InputStream stream = Configuration.class.getClassLoader().getResourceAsStream( - "META-INF/com.microsoft.windowsazure.properties"); - if (stream != null) { - Properties properties = new Properties(); - properties.load(stream); - for (Object key : properties.keySet()) { - config.setProperty(key.toString(), properties.get(key)); - } - } - - return config; - } - - public T create(Class service) { - return builder.build("", service, properties); - } - - public T create(String profile, Class service) { - return builder.build(profile, service, properties); - } - - public Builder getBuilder() { - return builder; - } - - public Object getProperty(String name) { - return properties.get(name); - } - - public void setProperty(String name, Object value) { - properties.put(name, value); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java deleted file mode 100644 index 90fae9f80a1b5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -public class ConfigurationException extends RuntimeException { - - private static final long serialVersionUID = -5570476914992165380L; - - public ConfigurationException() { - } - - public ConfigurationException(String message) { - super(message); - } - - public ConfigurationException(Throwable cause) { - super(cause); - } - - public ConfigurationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java deleted file mode 100644 index 9db58f6417612..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ServiceLoader; - -import javax.inject.Inject; -import javax.inject.Named; - -public class DefaultBuilder implements Builder, Builder.Registry { - Map, Factory> factories; - Map, List>> alterations; - - public DefaultBuilder() { - factories = new HashMap, Factory>(); - alterations = new HashMap, List>>(); - } - - public static DefaultBuilder create() { - DefaultBuilder builder = new DefaultBuilder(); - - for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class)) { - exports.register(builder); - } - - return builder; - } - - void addFactory(Class service, Factory factory) { - factories.put(service, factory); - } - - public Builder.Registry add(Class service) { - return add(service, service); - } - - Constructor findInjectConstructor(Class implementation) { - - Constructor withInject = null; - Constructor withoutInject = null; - int count = 0; - - for (Constructor ctor : implementation.getConstructors()) { - if (ctor.getAnnotation(Inject.class) != null) { - if (withInject != null) { - throw new RuntimeException("Class must not have multple @Inject annotations: " - + implementation.getName()); - } - withInject = ctor; - } - else { - ++count; - withoutInject = ctor; - } - } - if (withInject != null) { - return withInject; - } - if (count != 1) { - throw new RuntimeException("Class without @Inject annotation must have one constructor: " - + implementation.getName()); - } - return withoutInject; - } - - public Builder.Registry add(Class service, final Class implementation) { - final Constructor ctor = findInjectConstructor(implementation); - final Class[] parameterTypes = ctor.getParameterTypes(); - final Annotation[][] parameterAnnotations = ctor.getParameterAnnotations(); - - addFactory(service, new Builder.Factory() { - @SuppressWarnings("unchecked") - public T create(String profile, Builder builder, Map properties) { - Object[] initargs = new Object[parameterTypes.length]; - for (int i = 0; i != parameterTypes.length; ++i) { - - boolean located = false; - - String named = findNamedAnnotation(parameterAnnotations[i]); - String fullName = dotCombine(profile, named); - - boolean probeProperties = fullName != null && fullName != ""; - int startingIndex = 0; - while (!located && probeProperties) { - String probeName = fullName.substring(startingIndex); - if (!located && named != null && properties.containsKey(probeName)) { - located = true; - initargs[i] = properties.get(probeName); - } - else { - startingIndex = fullName.indexOf('.', startingIndex) + 1; - if (startingIndex == 0) { - probeProperties = false; - } - } - } - - if (!located) { - located = true; - initargs[i] = builder.build(fullName, parameterTypes[i], properties); - } - } - - try { - return (T) ctor.newInstance(initargs); - } - catch (InstantiationException e) { - throw new ConfigurationException(e); - } - catch (IllegalAccessException e) { - throw new ConfigurationException(e); - } - catch (InvocationTargetException e) { - throw new ConfigurationException(e); - } - } - }); - return this; - } - - protected String dotCombine(String profile, String named) { - boolean noProfile = profile == null || profile == ""; - boolean noName = named == null || named == ""; - if (noName) - return profile; - if (noProfile) - return named; - return profile + "." + named; - } - - protected String findNamedAnnotation(Annotation[] annotations) { - for (Annotation annotation : annotations) { - if (Named.class.isAssignableFrom(annotation.getClass())) { - return ((Named) annotation).value(); - } - } - return null; - } - - public Registry add(Factory factory) { - for (Type genericInterface : factory.getClass().getGenericInterfaces()) { - ParameterizedType parameterizedType = (ParameterizedType) genericInterface; - if (parameterizedType.getRawType().equals(Builder.Factory.class)) { - Type typeArgument = parameterizedType.getActualTypeArguments()[0]; - addFactory((Class) typeArgument, factory); - } - } - return this; - } - - @SuppressWarnings("unchecked") - public T build(String profile, Class service, Map properties) { - Factory factory = (Factory) factories.get(service); - if (factory == null) { - throw new RuntimeException("Service or property not registered: " + profile + " " + service.getName()); - } - T instance = factory.create(profile, this, properties); - List> alterationList = alterations.get(service); - if (alterationList != null) { - for (Alteration alteration : alterationList) { - instance = ((Alteration) alteration).alter(instance, this, properties); - } - } - return instance; - } - - public void alter(Class service, Alteration alteration) { - if (!this.alterations.containsKey(service)) { - this.alterations.put(service, new ArrayList>()); - } - this.alterations.get(service).add(alteration); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java deleted file mode 100644 index a5ff7c5bbae4a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.util.Arrays; -import java.util.Random; - -import com.microsoft.windowsazure.services.core.ServiceFilter.Response; - -public class ExponentialRetryPolicy extends RetryPolicy { - private final int deltaBackoffIntervalInMs; - private final int maximumAttempts; - private final Random randRef = new Random(); - private final int resolvedMaxBackoff = DEFAULT_MAX_BACKOFF; - private final int resolvedMinBackoff = DEFAULT_MIN_BACKOFF; - private final int[] retryableStatusCodes; - - public ExponentialRetryPolicy(int[] retryableStatusCodes) { - this(DEFAULT_CLIENT_BACKOFF, DEFAULT_CLIENT_RETRY_COUNT, retryableStatusCodes); - } - - public ExponentialRetryPolicy(int deltaBackoff, int maximumAttempts, int[] retryableStatusCodes) { - this.deltaBackoffIntervalInMs = deltaBackoff; - this.maximumAttempts = maximumAttempts; - this.retryableStatusCodes = Arrays.copyOf(retryableStatusCodes, retryableStatusCodes.length); - Arrays.sort(this.retryableStatusCodes); - } - - @Override - public boolean shouldRetry(int retryCount, Response response, Exception error) { - if (response == null) - return false; - - if (retryCount >= this.maximumAttempts) - return false; - - // Don't retry if not retryable status code - if (Arrays.binarySearch(this.retryableStatusCodes, response.getStatus()) < 0) - return false; - - return true; - } - - @Override - public int calculateBackoff(int currentRetryCount, Response response, Exception error) { - // Calculate backoff Interval between 80% and 120% of the desired - // backoff, multiply by 2^n -1 for - // exponential - int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); - int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) - + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - - (int) (this.deltaBackoffIntervalInMs * 0.8)); - incrementDelta *= boundedRandDelta; - - // Enforce max / min backoffs - return Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java deleted file mode 100644 index 0e9563b0131ba..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -public interface FilterableService { - T withFilter(ServiceFilter filter); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java deleted file mode 100644 index 26c6fbd0ca507..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import com.microsoft.windowsazure.services.core.ServiceFilter.Response; - -public abstract class RetryPolicy { - public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; - public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; - public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; - public static final int DEFAULT_MIN_BACKOFF = 100 * 3; - - public abstract boolean shouldRetry(int retryCount, Response response, Exception error); - - public abstract int calculateBackoff(int retryCount, Response response, Exception error); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java deleted file mode 100644 index 72686dcb2e200..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.io.InputStream; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class RetryPolicyFilter implements ServiceFilter { - private static final Log log = LogFactory.getLog(RetryPolicyFilter.class); - private final RetryPolicy retryPolicy; - - public RetryPolicyFilter(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - } - - @Override - public Response handle(Request request, Next next) throws Exception { - // Only the last added retry policy should be active - if (request.getProperties().containsKey("RetryPolicy")) - return next.handle(request); - request.getProperties().put("RetryPolicy", this); - - // Retry the operation as long as retry policy tells us to do so - for (int retryCount = 0;; ++retryCount) { - // Mark the stream before passing the request through - if (getEntityStream(request) != null) { - getEntityStream(request).mark(Integer.MAX_VALUE); - } - - // Pass the request to the next handler - Response response = null; - Exception error = null; - try { - response = next.handle(request); - } - catch (Exception e) { - error = e; - } - - // Determine if we should retry according to retry policy - boolean shouldRetry = retryPolicy.shouldRetry(retryCount, response, error); - if (!shouldRetry) { - if (error != null) - throw error; - return response; - } - - // Reset the stream before retrying - if (getEntityStream(request) != null) { - getEntityStream(request).reset(); - } - - // Backoff for some time according to retry policy - int backoffTime = retryPolicy.calculateBackoff(retryCount, response, error); - log.info(String.format("Request failed. Backing off for %1s milliseconds before retrying (retryCount=%2d)", - backoffTime, retryCount)); - backoff(backoffTime); - } - } - - private InputStream getEntityStream(Request request) { - if (request.getEntity() == null) - return null; - - if (!(request.getEntity() instanceof InputStream)) - return null; - - InputStream entityStream = (InputStream) request.getEntity(); - - // If the entity is an InputStream that doesn't support "mark/reset", we can't - // implement a retry logic, so we simply throw. - if (!entityStream.markSupported()) { - throw new IllegalArgumentException("The input stream for the request entity must support 'mark' and " - + "'reset' to be compatible with a retry policy filter."); - } - - return entityStream; - } - - private void backoff(int milliseconds) { - try { - Thread.sleep(milliseconds); - } - catch (InterruptedException e) { - // Restore the interrupted status - Thread.currentThread().interrupt(); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java deleted file mode 100644 index e9f292f180f94..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.util.HashMap; -import java.util.Map; - -public class ServiceException extends Exception { - - private static final long serialVersionUID = -4942076377009150131L; - - int httpStatusCode; - String httpReasonPhrase; - String serviceName; - - String errorCode; - String errorMessage; - Map errorValues; - String rawResponseBody; - - public ServiceException() { - init(); - } - - public ServiceException(String message) { - super(message); - init(); - } - - public ServiceException(String message, Throwable cause) { - super(message, cause); - init(); - } - - public ServiceException(Throwable cause) { - super(cause); - init(); - } - - private void init() { - errorValues = new HashMap(); - } - - @Override - public String getMessage() { - if (this.rawResponseBody == null) - return super.getMessage(); - else - return super.getMessage() + "\nResponse Body: " + this.rawResponseBody; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public String getHttpReasonPhrase() { - return httpReasonPhrase; - } - - public void setHttpReasonPhrase(String httpReasonPhrase) { - this.httpReasonPhrase = httpReasonPhrase; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public Map getErrorValues() { - return errorValues; - } - - public void setErrorValues(Map errorValues) { - this.errorValues = errorValues; - } - - public String getErrorValue(String name) { - return errorValues.get(name); - } - - public void setErrorValue(String name, String value) { - this.errorValues.put(name, value); - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public void setRawResponseBody(String body) { - this.rawResponseBody = body; - } - - public String getRawResponseBody() { - return rawResponseBody; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java deleted file mode 100644 index 552202540bc36..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core; - -import java.io.InputStream; -import java.net.URI; -import java.util.Map; - -import javax.ws.rs.core.MultivaluedMap; - -public interface ServiceFilter { - Response handle(Request request, Next next) throws Exception; - - public interface Next { - Response handle(Request request) throws Exception; - } - - public interface Request { - public String getMethod(); - - public void setMethod(String method); - - public URI getURI(); - - public void setURI(URI uri); - - public MultivaluedMap getHeaders(); - - public Object getEntity(); - - public void setEntity(Object entity); - - public Map getProperties(); - - public void setProperties(Map properties); - } - - public interface Response { - int getStatus(); - - void setStatus(int status); - - MultivaluedMap getHeaders(); - - boolean hasEntity(); - - InputStream getEntityInputStream(); - - void setEntityInputStream(InputStream entity); - - Map getProperties(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java deleted file mode 100644 index 354f61604b872..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ /dev/null @@ -1,387 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.HttpURLConnection; -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; - -/** - * Represents a set of access conditions to be used for operations against the storage services. - */ -public final class AccessCondition { - /** - * Generates a new empty AccessCondition. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @return An AccessCondition object that has no conditions set. - */ - public static AccessCondition generateEmptyCondition() { - return new AccessCondition(); - } - - /** - * Returns an access condition such that an operation will be performed only if the resource's ETag value matches - * the specified ETag value. - *

- * Setting this access condition modifies the request to include the HTTP If-Match conditional header. If - * this access condition is set, the operation is performed only if the ETag of the resource matches the specified - * ETag. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param etag - * A String that represents the ETag value to check. - * - * @return An AccessCondition object that represents the If-Match condition. - */ - public static AccessCondition generateIfMatchCondition(final String etag) { - AccessCondition retCondition = new AccessCondition(); - retCondition.setIfMatch(etag); - return retCondition; - } - - /** - * Returns an access condition such that an operation will be performed only if the resource has been modified since - * the specified time. - *

- * Setting this access condition modifies the request to include the HTTP If-Modified-Since conditional - * header. If this access condition is set, the operation is performed only if the resource has been modified since - * the specified time. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param lastMotified - * A java.util.Date object that represents the last-modified time to check for the resource. - * - * @return An AccessCondition object that represents the If-Modified-Since condition. - */ - public static AccessCondition generateIfModifiedSinceCondition(final Date lastMotified) { - AccessCondition retCondition = new AccessCondition(); - retCondition.ifModifiedSinceDate = lastMotified; - return retCondition; - } - - /** - * Returns an access condition such that an operation will be performed only if the resource's ETag value does not - * match the specified ETag value. - *

- * Setting this access condition modifies the request to include the HTTP If-None-Match conditional header. - * If this access condition is set, the operation is performed only if the ETag of the resource does not match the - * specified ETag. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param etag - * A String that represents the ETag value to check. - * - * @return An AccessCondition object that represents the If-None-Match condition. - */ - public static AccessCondition generateIfNoneMatchCondition(final String etag) { - AccessCondition retCondition = new AccessCondition(); - retCondition.setIfNoneMatch(etag); - return retCondition; - } - - /** - * Returns an access condition such that an operation will be performed only if the resource has not been modified - * since the specified time. - *

- * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional - * header. If this access condition is set, the operation is performed only if the resource has not been modified - * since the specified time. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param lastMotified - * A java.util.Date object that represents the last-modified time to check for the resource. - * - * @return An AccessCondition object that represents the If-Unmodified-Since condition. - */ - public static AccessCondition generateIfNotModifiedSinceCondition(final Date lastMotified) { - AccessCondition retCondition = new AccessCondition(); - retCondition.ifUnmodifiedSinceDate = lastMotified; - return retCondition; - } - - /** - * Returns an access condition such that an operation will be performed only if the resource is accessible under the - * specified lease id. - *

- * Setting this access condition modifies the request to include the HTTP If-Unmodified-Since conditional - * header. If this access condition is set, the operation is performed only if the resource has not been modified - * since the specified time. - *

- * For more information, see Specifying - * Conditional Headers for Blob Service Operations. - * - * @param leaseID - * The lease id to specify. - * - */ - public static AccessCondition generateLeaseCondition(final String leaseID) { - AccessCondition retCondition = new AccessCondition(); - retCondition.leaseID = leaseID; - return retCondition; - } - - private String leaseID = null; - - /** - * Represents the etag of the resource for if [none] match conditions - */ - private String etag = null; - - /** - * Represents the date for IfModifiedSince conditions. - */ - private Date ifModifiedSinceDate = null; - - /** - * Represents the date for IfUn,odifiedSince conditions. - */ - private Date ifUnmodifiedSinceDate = null; - - /** - * Represents the ifMatchHeaderType type. - */ - private String ifMatchHeaderType = null; - - /** - * Creates an instance of the AccessCondition class. - */ - public AccessCondition() { - // Empty Default Ctor - } - - /** - * RESERVED FOR INTERNAL USE. Applies the access condition to the request. - * - * @param request - * A java.net.HttpURLConnection object that represents the request to which the condition is - * being applied. - * - * @throws StorageException - * If there is an error parsing the date value of the access condition. - */ - public void applyConditionToRequest(final HttpURLConnection request) { - applyConditionToRequest(request, false); - } - - /** - * RESERVED FOR INTERNAL USE. Applies the access condition to the request. - * - * @param request - * A java.net.HttpURLConnection object that represents the request to which the condition is - * being applied. - * @param useSourceAccessHeaders - * If true will use the Source_ headers for the conditions, otherwise standard headers are used. - * @throws StorageException - * If there is an error parsing the date value of the access condition. - */ - public void applyConditionToRequest(final HttpURLConnection request, boolean useSourceAccessHeaders) { - // When used as a source access condition - if (useSourceAccessHeaders) { - if (!Utility.isNullOrEmpty(this.leaseID)) { - request.setRequestProperty(Constants.HeaderConstants.SOURCE_LEASE_ID_HEADER, this.leaseID); - } - - if (this.ifModifiedSinceDate != null) { - request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, - Utility.getGMTTime(this.ifModifiedSinceDate)); - } - - if (this.ifUnmodifiedSinceDate != null) { - request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, - Utility.getGMTTime(this.ifUnmodifiedSinceDate)); - } - - if (!Utility.isNullOrEmpty(this.etag)) { - if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH)) { - request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_MATCH_HEADER, this.etag); - } - else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { - request.setRequestProperty(Constants.HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, this.etag); - } - } - } - else { - if (!Utility.isNullOrEmpty(this.leaseID)) { - BaseRequest.addLeaseId(request, this.leaseID); - } - - if (this.ifModifiedSinceDate != null) { - // The IfModifiedSince has a special helper in HttpURLConnection, use it instead of manually setting the - // header. - request.setIfModifiedSince(this.ifModifiedSinceDate.getTime()); - } - - if (this.ifUnmodifiedSinceDate != null) { - request.setRequestProperty(Constants.HeaderConstants.IF_UNMODIFIED_SINCE, - Utility.getGMTTime(this.ifUnmodifiedSinceDate)); - } - - if (!Utility.isNullOrEmpty(this.etag)) { - request.setRequestProperty(this.ifMatchHeaderType, this.etag); - } - } - } - - /** - * @return the etag when the If-Match condition is set. - */ - public String getIfMatch() { - return this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH) ? this.etag : null; - } - - /** - * @return the ifModifiedSinceDate - */ - public Date getIfModifiedSinceDate() { - return this.ifModifiedSinceDate; - } - - /** - * @return the etag when the If-None-Match condition is set. - */ - public String getIfNoneMatch() { - return this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH) ? this.etag : null; - } - - /** - * @return the ifUnmodifiedSinceDate - */ - public Date getIfUnmodifiedSinceDate() { - return this.ifUnmodifiedSinceDate; - } - - /** - * @return the leaseID - */ - public String getLeaseID() { - return this.leaseID; - } - - /** - * @param etag - * the etag to set - */ - public void setIfMatch(String etag) { - this.etag = normalizeEtag(etag); - this.ifMatchHeaderType = Constants.HeaderConstants.IF_MATCH; - } - - /** - * @param ifModifiedSinceDate - * the ifModifiedSinceDate to set - */ - public void setIfModifiedSinceDate(Date ifModifiedSinceDate) { - this.ifModifiedSinceDate = ifModifiedSinceDate; - } - - /** - * @param etag - * the etag to set - */ - public void setIfNoneMatch(String etag) { - this.etag = normalizeEtag(etag); - this.ifMatchHeaderType = Constants.HeaderConstants.IF_NONE_MATCH; - } - - /** - * @param ifUnmodifiedSinceDate - * the ifUnmodifiedSinceDate to set - */ - public void setIfUnmodifiedSinceDate(Date ifUnmodifiedSinceDate) { - this.ifUnmodifiedSinceDate = ifUnmodifiedSinceDate; - } - - /** - * @param leaseID - * the leaseID to set - */ - public void setLeaseID(String leaseID) { - this.leaseID = leaseID; - } - - /** - * Reserved for internal use. Verifies the condition is satisfied. - * - * @param etag - * A String that represents the ETag to check. - * @param lastModified - * A java.util.Date object that represents the last modified date/time. - * - * @return true if the condition is satisfied; otherwise, false. - * - */ - public boolean verifyConditional(final String etag, final Date lastModified) { - if (this.ifModifiedSinceDate != null) { - // The IfModifiedSince has a special helper in HttpURLConnection, use it instead of manually setting the - // header. - if (!lastModified.after(this.ifModifiedSinceDate)) { - return false; - } - } - - if (this.ifUnmodifiedSinceDate != null) { - if (lastModified.after(this.ifUnmodifiedSinceDate)) { - return false; - } - } - - if (!Utility.isNullOrEmpty(this.etag)) { - if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_MATCH)) { - if (!this.etag.equals(etag) && !this.etag.equals("*")) { - return false; - } - } - else if (this.ifMatchHeaderType.equals(Constants.HeaderConstants.IF_NONE_MATCH)) { - if (this.etag.equals(etag)) { - return false; - } - } - } - - return true; - } - - /** - * Normalizes an Etag to be quoted, unless it is * - * - * @param inTag - * the etag to normalize - * @return the quoted etag - */ - private static String normalizeEtag(String inTag) { - if (Utility.isNullOrEmpty(inTag) || inTag.equals("*")) { - return inTag; - } - else if (inTag.startsWith("\"") && inTag.endsWith("\"")) { - return inTag; - } - else { - return String.format("\"%s\"", inTag); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java deleted file mode 100644 index f2d3371e49244..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ /dev/null @@ -1,691 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.queue.client.CloudQueueClient; - -/** - * Represents a Windows Azure storage account. - */ -public final class CloudStorageAccount { - /** - * Represents the setting name for the account key. - */ - protected static final String ACCOUNT_KEY_NAME = "AccountKey"; - - /** - * Represents the setting name for the account name. - */ - protected static final String ACCOUNT_NAME_NAME = "AccountName"; - - /** - * The root blob storage DNS name. - */ - private static final String BLOB_BASE_DNS_NAME = "blob.core.windows.net"; - - /** - * Represents the setting name for a custom blob storage endpoint. - */ - protected static final String BLOB_ENDPOINT_NAME = "BlobEndpoint"; - - /** - * The setting name for using the default storage endpoints with the specified protocol. - */ - private static final String DEFAULT_ENDPOINTS_PROTOCOL_NAME = "DefaultEndpointsProtocol"; - - /** - * The setting name for specifying a development storage proxy Uri. - */ - private static final String DEVELOPMENT_STORAGE_PROXY_URI_NAME = "DevelopmentStorageProxyUri"; - /** - * The default account key for the development storage. - */ - private static final String DEVSTORE_ACCOUNT_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; - - /** - * The default account name for the development storage. - */ - private static final String DEVSTORE_ACCOUNT_NAME = "devstoreaccount1"; - - /** - * The credentials string used to test for the development storage credentials. - */ - private static final String DEVSTORE_CREDENTIALS_IN_STRING = CloudStorageAccount.ACCOUNT_NAME_NAME + "=" - + CloudStorageAccount.DEVSTORE_ACCOUNT_NAME + ";" + CloudStorageAccount.ACCOUNT_KEY_NAME + "=" - + CloudStorageAccount.DEVSTORE_ACCOUNT_KEY; - - /** - * A CloudStorageAccount that represents the development storage account. - */ - private static CloudStorageAccount devStoreAccount; - - /** - * Represents the root queue DNS name. - */ - protected static final String QUEUE_BASE_DNS_NAME = "queue.core.windows.net"; - - /** - * Represents the setting name for a custom queue endpoint. - */ - protected static final String QUEUE_ENDPOINT_NAME = "QueueEndpoint"; - - /** - * Represents the setting name for a shared access key. - */ - protected static final String SHARED_ACCESS_SIGNATURE_NAME = "SharedAccessSignature"; - - /** - * Represents the root table storage DNS name. - */ - protected static final String TABLE_BASE_DNS_NAME = "table.core.windows.net"; - - /** - * Represents the setting name for a custom table storage endpoint. - */ - protected static final String TABLE_ENDPOINT_NAME = "TableEndpoint"; - - /** - * The setting name for using the development storage. - */ - private static final String USE_DEVELOPMENT_STORAGE_NAME = "UseDevelopmentStorage"; - - /** - * Gets the default blob endpoint using specified settings. - * - * @param settings - * The settings to use - * @return The default blob endpoint. - */ - private static String getDefaultBlobEndpoint(final HashMap settings) { - final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; - - return getDefaultBlobEndpoint(scheme, accountName); - } - - /** - * Gets the default blob endpoint using the specified protocol and account name. - * - * @param scheme - * The protocol to use. - * @param accountName - * The name of the storage account. - * @return The default blob endpoint. - */ - private static String getDefaultBlobEndpoint(final String scheme, final String accountName) { - return String.format("%s://%s.%s", scheme, accountName, BLOB_BASE_DNS_NAME); - } - - /** - * Gets the default queue endpoint using the specified settings. - * - * @param settings - * The settings. - * @return The default queue endpoint. - */ - private static String getDefaultQueueEndpoint(final HashMap settings) { - final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - - final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; - - return getDefaultQueueEndpoint(scheme, accountName); - } - - /** - * Gets the default queue endpoint using the specified protocol and account name. - * - * @param scheme - * The protocol to use. - * @param accountName - * The name of the storage account. - * @return The default queue endpoint. - */ - private static String getDefaultQueueEndpoint(final String scheme, final String accountName) { - return String.format("%s://%s.%s", scheme, accountName, QUEUE_BASE_DNS_NAME); - } - - /** - * Gets the default table endpoint using the specified settings. - * - * @param settings - * The settings. - * @return The default table endpoint. - */ - private static String getDefaultTableEndpoint(final HashMap settings) { - final String scheme = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) : Constants.HTTP; - final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; - - return getDefaultTableEndpoint(scheme, accountName); - } - - /** - * Gets the default table endpoint using the specified protocol and account name. - * - * @param scheme - * The protocol to use. - * @param accountName - * The name of the storage account. - * @return The default table endpoint, - */ - private static String getDefaultTableEndpoint(final String scheme, final String accountName) { - return String.format("%s://%s.%s", scheme, accountName, TABLE_BASE_DNS_NAME); - } - - /** - * Returns a {@link CloudStorageAccount} object that represents the development storage credentials. - * - * @return A {@link CloudStorageAccount} object for the development storage credentials. - */ - public static CloudStorageAccount getDevelopmentStorageAccount() { - if (devStoreAccount == null) { - try { - devStoreAccount = getDevelopmentStorageAccount(new URI("http://127.0.0.1")); - } - catch (final URISyntaxException e) { - // this wont happen since we know the uri above. - } - } - return devStoreAccount; - } - - /** - * Returns a {@link CloudStorageAccount} object that represents the development storage credentials, using the - * specified proxy URI. - * - * @param proxyUri - * A java.net.URI object that represents the proxy endpoint to use. - * - * @return A {@link CloudStorageAccount} object for the development storage credentials. - * - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public static CloudStorageAccount getDevelopmentStorageAccount(final URI proxyUri) throws URISyntaxException { - if (proxyUri == null) { - return getDevelopmentStorageAccount(); - } - - String prefix = proxyUri.getScheme().concat("://"); - prefix = prefix.concat(proxyUri.getHost()); - - return new CloudStorageAccount( - new StorageCredentialsAccountAndKey(DEVSTORE_ACCOUNT_NAME, DEVSTORE_ACCOUNT_KEY), new URI( - prefix.concat(":10000/devstoreaccount1")), new URI(prefix.concat(":10001/devstoreaccount1")), - new URI(prefix.concat(":10002/devstoreaccount1"))); - - } - - /** - * Parses a connection string and returns a cloud storage account created from the connection string. - *

- * Note this method is not supported for shared access signature credentials as they do not contain the required - * endpoint configuration parameters. - * - * @param connectionString - * A String that represents the connection string to parse. - * - * @return A {@link CloudStorageAccount} object that represents the cloud storage account constructed from the - * values provided in the connection string. - * - * @throws InvalidKeyException - * If credentials in the connection string contain an invalid key. - * @throws URISyntaxException - * If the connection string specifies an invalid URI. - */ - public static CloudStorageAccount parse(final String connectionString) throws URISyntaxException, - InvalidKeyException { - if (connectionString == null || connectionString.length() == 0) { - throw new IllegalArgumentException("Invalid Connection String"); - } - - // 1. Parse connection string in to key / value pairs - final HashMap settings = Utility.parseAccountString(connectionString); - - // 2 Validate General Settings rules, - // - only setting value per key - // - setting must have value - for (final Entry entry : settings.entrySet()) { - if (entry.getValue() == null || entry.getValue().equals(Constants.EMPTY_STRING)) { - throw new IllegalArgumentException("Invalid Connection String"); - } - } - - // 3. Validate scenario specific constraints - CloudStorageAccount retVal = tryConfigureDevStore(settings); - if (retVal != null) { - return retVal; - } - - retVal = tryConfigureServiceAccount(settings); - if (retVal != null) { - return retVal; - } - - throw new IllegalArgumentException("Invalid Connection String"); - } - - /** - * Evaluates connection settings and returns a CloudStorageAccount representing Development Storage. - * - * @param settings - * A Hashmap of key value pairs representing the connection. - * @return A CloudStorageAccount object constructed from the values provided in the connection settings, or null if - * one cannot be constructed. - * @throws URISyntaxException - * if the connection settings contains an invalid URI - */ - private static CloudStorageAccount tryConfigureDevStore(final HashMap settings) - throws URISyntaxException { - if (settings.containsKey(USE_DEVELOPMENT_STORAGE_NAME)) { - final String useDevStoreSetting = settings.get(USE_DEVELOPMENT_STORAGE_NAME); - URI devStoreProxyUri = null; - - if (!Boolean.parseBoolean(useDevStoreSetting)) { - return null; - } - - if (settings.containsKey(DEVELOPMENT_STORAGE_PROXY_URI_NAME)) { - devStoreProxyUri = new URI(settings.get(DEVELOPMENT_STORAGE_PROXY_URI_NAME)); - } - - return getDevelopmentStorageAccount(devStoreProxyUri); - - } - else { - return null; - } - } - - /** - * Evaluates connection settings and configures a CloudStorageAccount accordingly. - * - * @param settings - * A Hashmap of key value pairs representing the connection. - * @return A CloudStorageAccount represented by the settings. - * @throws URISyntaxException - * if the connectionString specifies an invalid URI. - * @throws InvalidKeyException - * if credentials in the connection settings contain an invalid key. - */ - private static CloudStorageAccount tryConfigureServiceAccount(final HashMap settings) - throws URISyntaxException, InvalidKeyException { - - final String defaultEndpointSetting = settings.get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME) != null ? settings - .get(CloudStorageAccount.DEFAULT_ENDPOINTS_PROTOCOL_NAME).toLowerCase() : null; - - if (defaultEndpointSetting != null && !defaultEndpointSetting.equals(Constants.HTTP) - && !defaultEndpointSetting.equals(Constants.HTTPS)) { - return null; - } - - final StorageCredentials credentials = StorageCredentials.tryParseCredentials(settings); - final URI blobURI = settings.containsKey(CloudStorageAccount.BLOB_ENDPOINT_NAME) ? new URI( - settings.get(CloudStorageAccount.BLOB_ENDPOINT_NAME)) : null; - final URI queueURI = settings.containsKey(CloudStorageAccount.QUEUE_ENDPOINT_NAME) ? new URI( - settings.get(CloudStorageAccount.QUEUE_ENDPOINT_NAME)) : null; - final URI tableURI = settings.containsKey(CloudStorageAccount.TABLE_ENDPOINT_NAME) ? new URI( - settings.get(CloudStorageAccount.TABLE_ENDPOINT_NAME)) : null; - - if (credentials != null) { - // Automatic endpoint Case - if (defaultEndpointSetting != null && settings.containsKey(CloudStorageAccount.ACCOUNT_NAME_NAME) - && settings.containsKey(CloudStorageAccount.ACCOUNT_KEY_NAME)) { - return new CloudStorageAccount(credentials, blobURI == null ? new URI(getDefaultBlobEndpoint(settings)) - : blobURI, queueURI == null ? new URI(getDefaultQueueEndpoint(settings)) : queueURI, - tableURI == null ? new URI(getDefaultTableEndpoint(settings)) : tableURI); - } - - // Explicit endpoint Case - if (settings.containsKey(CloudStorageAccount.BLOB_ENDPOINT_NAME) - || settings.containsKey(CloudStorageAccount.QUEUE_ENDPOINT_NAME) - || settings.containsKey(CloudStorageAccount.TABLE_ENDPOINT_NAME)) { - return new CloudStorageAccount(credentials, blobURI, queueURI, tableURI); - } - } - - return null; - } - - /** - * The internal Blob endpoint. - */ - private final URI blobEndpoint; - - /** - * The internal Storage Credentials. - */ - private StorageCredentials credentials; - - /** - * The internal Queue endpoint. - */ - private final URI queueEndpoint; - - /** - * The internal Table endpoint. - */ - private final URI tableEndpoint; - - /** - * Creates an instance of the CloudStorageAccount class using the specified account credentials. - *

- * With this constructor, the CloudStorageAccount object is constructed using the default HTTP storage - * service endpoints. The default HTTP storage service endpoints are - * http://myaccount.blob.core.windows.net, - * http://myaccount.queue.core.windows.net, and - * http://myaccount.table.core.windows.net, where myaccount is the name of - * your storage account. - *

- * The credentials provided when constructing the CloudStorageAccount object are used to authenticate - * all further requests against resources that are accessed via the CloudStorageAccount object or a - * client object created from it. A client object may be a {@link CloudBlobClient} object. - * - * @param storageCredentials - * A {@link StorageCredentials} object that represents the storage credentials to use to authenticate - * this account. - * - * @throws URISyntaxException - * If storageCredentials specify an invalid account name. - */ - public CloudStorageAccount(final StorageCredentials storageCredentials) throws URISyntaxException { - this.credentials = storageCredentials; - - this.blobEndpoint = new URI(getDefaultBlobEndpoint(Constants.HTTP, this.credentials.getAccountName())); - - this.queueEndpoint = new URI(getDefaultQueueEndpoint(Constants.HTTP, this.credentials.getAccountName())); - - this.tableEndpoint = new URI(getDefaultTableEndpoint(Constants.HTTP, this.credentials.getAccountName())); - } - - /** - * Creates an instance of the CloudStorageAccount class using the specified account credentials and - * service endpoints. - *

- * Use this constructor to construct a CloudStorageAccount object using custom endpoints, in the case - * where you've configured a custom domain name for your storage account. - *

- * The credentials provided when constructing the CloudStorageAccount object are used to authenticate - * all further requests against resources that are accessed via the CloudStorageAccount object or a - * client object created from it. A client object may be a {@link CloudBlobClient} object. - * - * @param storageCredentials - * A {@link StorageCredentials} object that represents the storage credentials to use to authenticate - * this account. - * @param blobEndpoint - * A java.net.URI object that represents the Blob service endpoint. - * @param queueEndpoint - * A java.net.URI object that represents the Queue service endpoint. - * @param tableEndpoint - * A java.net.URI object that represents the Table service endpoint. - */ - public CloudStorageAccount(final StorageCredentials storageCredentials, final URI blobEndpoint, - final URI queueEndpoint, final URI tableEndpoint) { - this.credentials = storageCredentials; - this.blobEndpoint = blobEndpoint; - this.queueEndpoint = queueEndpoint; - this.tableEndpoint = tableEndpoint; - } - - /** - * Creates an instance of the CloudStorageAccount class using the specified account credentials and the - * default service endpoints, using HTTP or HTTPS as specified. - *

- * With this constructor, the CloudStorageAccount object is constructed using the default storage - * service endpoints. The default storage service endpoints are - * [http|https]://myaccount.blob.core.windows.net; - * [http|https]://myaccount.queue.core.windows.net; and - * [http|https]://myaccount.table.core.windows.net, where myaccount is the - * name of your storage account. Access to the cloud storage account may be via HTTP or HTTPS, as specified by the - * useHttps parameter. - *

- * The credentials provided when constructing the CloudStorageAccount object are used to authenticate - * all further requests against resources that are accessed via the CloudStorageAccount object or a - * client object created from it. A client object may be a {@link CloudBlobClient} object. - * - * @param storageCredentials - * A {@link StorageCredentialsAccountAndKey} object that represents the storage credentials to use to - * authenticate this account. - * @param useHttps - * true to use HTTPS to connect to the storage service endpoints; otherwise, - * false. - * - * @throws URISyntaxException - * If storageCredentials specify an invalid account name. - */ - - // In order to call another constructor the this() must be the first - // statement and cannot be wrapped with a try catch - // as such, the URI constructors could technically throw a - // URISyntaxException, but wont since we are using our internal default - // endpoints. - // We are forced to document the URISyntaxException as a throws, but it - // won't ever really happen. - - // Also eclipse's auto formatting below is horrible - public CloudStorageAccount(final StorageCredentialsAccountAndKey storageCredentials, final boolean useHttps) - throws URISyntaxException { - this(storageCredentials, new URI(getDefaultBlobEndpoint(useHttps ? Constants.HTTPS : Constants.HTTP, - storageCredentials.getAccountName())), new URI(getDefaultQueueEndpoint(useHttps ? Constants.HTTPS - : Constants.HTTP, storageCredentials.getAccountName())), new URI(getDefaultTableEndpoint( - useHttps ? Constants.HTTPS : Constants.HTTP, storageCredentials.getAccountName()))); - } - - /** - * Creates a new Blob service client. - * - * @return A {@link CloudBlobClient} that represents the cloud blob client. - * - */ - public CloudBlobClient createCloudBlobClient() { - if (this.getBlobEndpoint() == null) { - throw new IllegalArgumentException("No blob endpoint configured."); - } - - if (this.credentials == null) { - throw new IllegalArgumentException("No credentials provided."); - } - - if (!this.credentials.canCredentialsSignRequest()) { - throw new IllegalArgumentException("CloudBlobClient requires a credential that can sign request"); - } - return new CloudBlobClient(this.getBlobEndpoint(), this.getCredentials()); - } - - /** - * Creates a new queue service client. - * - * @return A client object that uses the Queue service endpoint. - */ - public CloudQueueClient createCloudQueueClient() { - if (this.getQueueEndpoint() == null) { - throw new IllegalArgumentException("No queue endpoint configured."); - } - - if (this.credentials == null) { - throw new IllegalArgumentException("No credentials provided."); - } - - if (!this.credentials.canCredentialsSignRequest()) { - throw new IllegalArgumentException("CloudQueueClient requires a credential that can sign request"); - } - return new CloudQueueClient(this.getQueueEndpoint(), this.getCredentials()); - } - - /** - * Returns the endpoint for the Blob service, as configured for the storage account. This method is not supported - * when using shared access signature credentials. - * - * @return A java.net.URI object that represents the blob endpoint associated with this account. - */ - public URI getBlobEndpoint() { - if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { - throw new IllegalArgumentException( - "Endpoint information not available for Account using Shared Access Credentials."); - } - - return this.blobEndpoint; - } - - /** - * Returns the credentials for the Blob service, as configured for the storage account. - * - * @return A {@link StorageCredentials} object that represents the credentials for this storage account. - */ - public StorageCredentials getCredentials() { - return this.credentials; - } - - /** - * Returns the endpoint for the Queue service, as configured for the storage account. - * - * @return A java.net.URI object that represents the queue endpoint associated with this account. - */ - public URI getQueueEndpoint() { - if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { - throw new IllegalArgumentException( - "Endpoint information not available for Account using Shared Access Credentials."); - } - - return this.queueEndpoint; - } - - /** - * Returns the endpoint for the table service, as configured for the storage account. - * - * @return A java.net.URI object that represents the table endpoint associated with this account. - */ - public URI getTableEndpoint() { - if (this.getCredentials() instanceof StorageCredentialsSharedAccessSignature) { - throw new IllegalArgumentException( - "Endpoint information not available for Account using Shared Access Credentials."); - } - - return this.tableEndpoint; - } - - // - // Sets the StorageCredentials to use with this account. Warning internal - // use only, updating the credentials to a new account can potentially - // invalidate a bunch of pre-existingobjects. - // - // @param credentials - // the credentials to set - // - /** - * Reserved for internal use. - * - * @param credentials - * Reserved. - */ - protected void setCredentials(final StorageCredentials credentials) { - this.credentials = credentials; - } - - /** - * Returns a connection string for this storage account, without sensitive data. - * - * @return A String that represents the connection string for this storage account, without sensitive - * data. - */ - @Override - public String toString() { - return this.toString(false); - } - - /** - * Returns a connection string for this storage account, optionally with sensitive data. - * - * @return A String that represents the connection string for this storage account, optionally with - * sensitive data. - * @param exportSecrets - * true to include sensitive data in the string; otherwise, false. - */ - public String toString(final boolean exportSecrets) { - if (this.credentials != null && Utility.isNullOrEmpty(this.credentials.getAccountName())) { - return this.credentials.toString(exportSecrets); - } - - final ArrayList retVals = new ArrayList(); - if (this == devStoreAccount) { - retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); - } - else if (this.credentials != null && DEVSTORE_ACCOUNT_NAME.equals(this.credentials.getAccountName()) - && this.credentials.toString(true).equals(CloudStorageAccount.DEVSTORE_CREDENTIALS_IN_STRING) - && this.blobEndpoint != null - && this.getBlobEndpoint().getHost().equals(this.getQueueEndpoint().getHost()) - && this.getQueueEndpoint().getHost().equals(this.getTableEndpoint().getHost()) - && this.getBlobEndpoint().getScheme().equals(this.getQueueEndpoint().getScheme()) - && this.getQueueEndpoint().getScheme().equals(this.getTableEndpoint().getScheme())) { - retVals.add(String.format("%s=true", USE_DEVELOPMENT_STORAGE_NAME)); - retVals.add(String.format("%s=%s://%s", DEVELOPMENT_STORAGE_PROXY_URI_NAME, this.getBlobEndpoint() - .getScheme(), this.getBlobEndpoint().getHost())); - } - else if (this.getBlobEndpoint().getHost().endsWith(BLOB_BASE_DNS_NAME) - && this.getQueueEndpoint().getHost().endsWith(QUEUE_BASE_DNS_NAME) - && this.getTableEndpoint().getHost().endsWith(TABLE_BASE_DNS_NAME) - && this.getBlobEndpoint().getScheme().equals(this.getQueueEndpoint().getScheme()) - && this.getQueueEndpoint().getScheme().equals(this.getTableEndpoint().getScheme())) { - retVals.add(String.format("%s=%s", DEFAULT_ENDPOINTS_PROTOCOL_NAME, this.getBlobEndpoint().getScheme())); - if (this.getCredentials() != null) { - retVals.add(this.getCredentials().toString(exportSecrets)); - } - } - else { - if (this.getBlobEndpoint() != null) { - retVals.add(String.format("%s=%s", BLOB_ENDPOINT_NAME, this.getBlobEndpoint())); - } - - if (this.getQueueEndpoint() != null) { - retVals.add(String.format("%s=%s", QUEUE_ENDPOINT_NAME, this.getQueueEndpoint())); - } - - if (this.getTableEndpoint() != null) { - retVals.add(String.format("%s=%s", TABLE_ENDPOINT_NAME, this.getTableEndpoint())); - } - - if (this.getCredentials() != null) { - retVals.add(this.getCredentials().toString(exportSecrets)); - } - } - - final StringBuilder returnString = new StringBuilder(); - for (final String val : retVals) { - returnString.append(val); - returnString.append(';'); - } - - // Remove trailing ';' - if (retVals.size() > 0) { - returnString.deleteCharAt(returnString.length() - 1); - } - - return returnString.toString(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java deleted file mode 100644 index b9cbfe3c43105..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ /dev/null @@ -1,469 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Defines constants for use with blob operations, HTTP headers, and query strings. - */ -public final class Constants { - /** - * Defines constants for use Analytics requests. - */ - public static class AnalyticsConstants { - /** - * The XML element for the Analytics RetentionPolicy Days. - */ - public static final String DAYS_ELEMENT = "Days"; - - /** - * The XML element for the Default Service Version. - */ - public static final String DEFAULT_SERVICE_VERSION = "DefaultServiceVersion"; - - /** - * The XML element for the Analytics Logging Delete type. - */ - public static final String DELETE_ELEMENT = "Delete"; - - /** - * The XML element for the Analytics RetentionPolicy Enabled. - */ - public static final String ENABLED_ELEMENT = "Enabled"; - - /** - * The XML element for the Analytics Metrics IncludeAPIs. - */ - public static final String INCLUDE_APIS_ELEMENT = "IncludeAPIs"; - - /** - * The XML element for the Analytics Logging - */ - public static final String LOGGING_ELEMENT = "Logging"; - - /** - * The XML element for the Analytics Metrics - */ - public static final String METRICS_ELEMENT = "Metrics"; - - /** - * The XML element for the Analytics Logging Read type. - */ - public static final String READ_ELEMENT = "Read"; - - /** - * The XML element for the Analytics RetentionPolicy. - */ - public static final String RETENTION_POLICY_ELEMENT = "RetentionPolicy"; - - /** - * The XML element for the StorageServiceProperties - */ - public static final String STORAGE_SERVICE_PROPERTIES_ELEMENT = "StorageServiceProperties"; - - /** - * The XML element for the Analytics Version - */ - public static final String VERSION_ELEMENT = "Version"; - - /** - * The XML element for the Analytics Logging Write type. - */ - public static final String WRITE_ELEMENT = "Write"; - } - - /** - * Defines constants for use with HTTP headers. - */ - public static class HeaderConstants { - /** - * The Accept header. - */ - public static final String ACCEPT = "Accept"; - - /** - * The Accept header. - */ - public static final String ACCEPT_CHARSET = "Accept-Charset"; - - /** - * The Authorization header. - */ - public static final String AUTHORIZATION = "Authorization"; - - /** - * The CacheControl header. - */ - public static final String CACHE_CONTROL = "Cache-Control"; - - /** - * The header that specifies blob caching control. - */ - public static final String CACHE_CONTROL_HEADER = PREFIX_FOR_STORAGE_HEADER + "blob-cache-control"; - - /** - * The Comp value. - */ - public static final String COMP = "comp"; - - /** - * The ContentEncoding header. - */ - public static final String CONTENT_ENCODING = "Content-Encoding"; - - /** - * The ContentLangauge header. - */ - public static final String CONTENT_LANGUAGE = "Content-Language"; - - /** - * The ContentLength header. - */ - public static final String CONTENT_LENGTH = "Content-Length"; - - /** - * The ContentMD5 header. - */ - public static final String CONTENT_MD5 = "Content-MD5"; - - /** - * The ContentRange header. - */ - public static final String CONTENT_RANGE = "Cache-Range"; - - /** - * The ContentType header. - */ - public static final String CONTENT_TYPE = "Content-Type"; - - /** - * The header for copy source. - */ - public static final String COPY_SOURCE_HEADER = PREFIX_FOR_STORAGE_HEADER + "copy-source"; - - /** - * The header that specifies the date. - */ - public static final String DATE = PREFIX_FOR_STORAGE_HEADER + "date"; - - /** - * The header to delete snapshots. - */ - public static final String DELETE_SNAPSHOT_HEADER = PREFIX_FOR_STORAGE_HEADER + "delete-snapshots"; - - /** - * The ETag header. - */ - public static final String ETAG = "ETag"; - - /** - * Buffer width used to copy data to output streams. - */ - public static final int HTTP_UNUSED_306 = 306; - - /** - * The IfMatch header. - */ - public static final String IF_MATCH = "If-Match"; - - /** - * The IfModifiedSince header. - */ - public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; - - /** - * The IfNoneMatch header. - */ - public static final String IF_NONE_MATCH = "If-None-Match"; - - /** - * The IfUnmodifiedSince header. - */ - public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; - - /** - * The header that specifies lease ID. - */ - public static final String LEASE_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "lease-id"; - - /** - * The header that specifies lease status. - */ - public static final String LEASE_STATUS = PREFIX_FOR_STORAGE_HEADER + "lease-status"; - - /** - * The header prefix for metadata. - */ - public static final String PREFIX_FOR_STORAGE_METADATA = "x-ms-meta-"; - - /** - * The header prefix for properties. - */ - public static final String PREFIX_FOR_STORAGE_PROPERTIES = "x-ms-prop-"; - - /** - * The Range header. - */ - public static final String RANGE = "Range"; - - /** - * The header that specifies if the request will populate the ContentMD5 header for range gets. - */ - public static final String RANGE_GET_CONTENT_MD5 = PREFIX_FOR_STORAGE_HEADER + "range-get-content-md5"; - - /** - * The format string for specifying ranges. - */ - public static final String RANGE_HEADER_FORMAT = "bytes=%d-%d"; - - /** - * The header that indicates the request ID. - */ - public static final String REQUEST_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "request-id"; - - /** - * The header for the If-Match condition. - */ - public static final String SOURCE_IF_MATCH_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-if-match"; - - /** - * The header for the If-Modified-Since condition. - */ - public static final String SOURCE_IF_MODIFIED_SINCE_HEADER = PREFIX_FOR_STORAGE_HEADER - + "source-if-modified-since"; - - /** - * The header for the If-None-Match condition. - */ - public static final String SOURCE_IF_NONE_MATCH_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-if-none-match"; - - /** - * The header for the If-Unmodified-Since condition. - */ - public static final String SOURCE_IF_UNMODIFIED_SINCE_HEADER = PREFIX_FOR_STORAGE_HEADER - + "source-if-unmodified-since"; - - /** - * The header for the source lease id. - */ - public static final String SOURCE_LEASE_ID_HEADER = PREFIX_FOR_STORAGE_HEADER + "source-lease-id"; - - /** - * The header for data ranges. - */ - public static final String STORAGE_RANGE_HEADER = PREFIX_FOR_STORAGE_HEADER + "range"; - - /** - * The header for storage version. - */ - public static final String STORAGE_VERSION_HEADER = PREFIX_FOR_STORAGE_HEADER + "version"; - - /** - * The current storage version header value. - */ - public static final String TARGET_STORAGE_VERSION = "2011-08-18"; - - /** - * The UserAgent header. - */ - public static final String USER_AGENT = "User-Agent"; - - /** - * Specifies the value to use for UserAgent header. - */ - public static final String USER_AGENT_PREFIX = "WA-Storage"; - - /** - * Specifies the value to use for UserAgent header. - */ - public static final String USER_AGENT_VERSION = "Client v0.1"; - } - - /** - * The master Windows Azure Storage header prefix. - */ - public static final String PREFIX_FOR_STORAGE_HEADER = "x-ms-"; - - /** - * Constant representing a kilobyte (Non-SI version). - */ - public static final int KB = 1024; - - /** - * Constant representing a megabyte (Non-SI version). - */ - public static final int MB = 1024 * KB; - - /** - * Constant representing a gigabyte (Non-SI version). - */ - public static final int GB = 1024 * MB; - - /** - * Buffer width used to copy data to output streams. - */ - public static final int BUFFER_COPY_LENGTH = 8 * KB; - - /** - * Default client side timeout, in milliseconds, for all service clients. - */ - public static final int DEFAULT_TIMEOUT_IN_MS = 90 * 1000; - - /** - * XML element for delimiters. - */ - public static final String DELIMITER_ELEMENT = "Delimiter"; - - /** - * An empty String to use for comparison. - */ - public static final String EMPTY_STRING = ""; - - /** - * XML element for page range end elements. - */ - public static final String END_ELEMENT = "End"; - - /** - * XML element for error codes. - */ - public static final String ERROR_CODE = "Code"; - - /** - * XML element for exception details. - */ - public static final String ERROR_EXCEPTION = "ExceptionDetails"; - - /** - * XML element for exception messages. - */ - public static final String ERROR_EXCEPTION_MESSAGE = "ExceptionMessage"; - - /** - * XML element for stack traces. - */ - public static final String ERROR_EXCEPTION_STACK_TRACE = "StackTrace"; - - /** - * XML element for error messages. - */ - public static final String ERROR_MESSAGE = "Message"; - - /** - * XML root element for errors. - */ - public static final String ERROR_ROOT_ELEMENT = "Error"; - - /** - * XML element for the ETag. - */ - public static final String ETAG_ELEMENT = "Etag"; - - /** - * Constant for False. - */ - public static final String FALSE = "false"; - - /** - * Specifies HTTP. - */ - public static final String HTTP = "http"; - - /** - * Specifies HTTPS. - */ - public static final String HTTPS = "https"; - - /** - * XML attribute for IDs. - */ - public static final String ID = "Id"; - - /** - * XML element for an invalid metadata name. - */ - public static final String INVALID_METADATA_NAME = "x-ms-invalid-name"; - - /** - * XML element for the last modified date. - */ - public static final String LAST_MODIFIED_ELEMENT = "Last-Modified"; - - /** - * XML element for the lease status. - */ - public static final String LEASE_STATUS_ELEMENT = "LeaseStatus"; - - /** - * Constant signaling the resource is locked. - */ - public static final String LOCKED_VALUE = "Locked"; - - /** - * XML element for a marker. - */ - public static final String MARKER_ELEMENT = "Marker"; - - /** - * XML element for maximum results. - */ - public static final String MAX_RESULTS_ELEMENT = "MaxResults"; - - /** - * Number of default concurrent requests for parallel operation. - */ - public static final int MAXIMUM_SEGMENTED_RESULTS = 5000; - - /** - * XML element for the metadata. - */ - public static final String METADATA_ELEMENT = "Metadata"; - - /** - * XML element for names. - */ - public static final String NAME_ELEMENT = "Name"; - - /** - * XML element for the next marker. - */ - public static final String NEXT_MARKER_ELEMENT = "NextMarker"; - - /** - * XML element for a prefix. - */ - public static final String PREFIX_ELEMENT = "Prefix"; - - /** - * Constant for True. - */ - public static final String TRUE = "true"; - - /** - * Constant signaling the resource is unlocked. - */ - public static final String UNLOCKED_VALUE = "Unlocked"; - - /** - * XML element for the URL. - */ - public static final String URL_ELEMENT = "Url"; - - /** - * Private Default Ctor - */ - private Constants() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java deleted file mode 100644 index d3b03adc72461..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import com.microsoft.windowsazure.services.core.storage.utils.Base64; - -/** - * Represents the credentials used to sign a request against the storage services. - */ -public final class Credentials { - /** - * Stores the Account name for the credentials. - */ - private String accountName; - - /** - * Stores the StorageKey for the credentials. - */ - private final StorageKey key; - - /** - * Creates an instance of the Credentials class, using the specified storage account name and access - * key; the specified access key is in the form of a byte array. - * - * @param accountName - * A String that represents the name of the storage account. - * @param key - * An array of bytes that represent the account access key. - * - */ - public Credentials(final String accountName, final byte[] key) { - if (accountName == null || accountName.length() == 0) { - throw new IllegalArgumentException("Invalid accountName"); - } - - if (key == null) { - throw new IllegalArgumentException("Invalid key"); - } - - this.accountName = accountName; - this.key = new StorageKey(key); - } - - /** - * Creates an instance of the Credentials class, using the specified storage account name and access - * key; the specified access key is stored as a String. - * - * @param accountName - * A String that represents the name of the storage account. - * @param key - * A String that represents the Base-64-encoded account access key. - * - */ - public Credentials(final String accountName, final String key) { - this(accountName, Base64.decode(key)); - } - - /** - * Exports the value of the access key to a Base64-encoded string. - * - * @return A String that represents the Base64-encoded access key. - */ - public String exportBase64EncodedKey() { - return this.getKey().getBase64EncodedKey(); - } - - /** - * Exports the value of the access key to an array of bytes. - * - * @return A byte array that represents the access key. - */ - public byte[] exportKey() { - return this.getKey().getKey(); - } - - /** - * Returns the account name to be used in signing the request. - * - * @return A String that represents the account name to be used in signing the request. - */ - public String getAccountName() { - return this.accountName; - } - - /** - * Returns the access key to be used in signing the request. - * - * @return A String that represents the access key to be used in signing the request. - */ - public StorageKey getKey() { - return this.key; - } - - /** - * Sets the account name to be used in signing the request. - * - * @param accountName - * A String that represents the account name being set. - */ - protected void setAccountName(final String accountName) { - this.accountName = accountName; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java deleted file mode 100644 index 405ccf2fa56d5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * An attribute used to describe a method that will make a request to the storage service. - */ -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface DoesServiceRequest { - // No attributes -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java deleted file mode 100644 index d7707825b5419..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.Locale; - -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Specifies the lease status of a blob. - *

- * You can check the lease status of a blob to determine whether it currently has an active lease (locked for - * exclusive-write access), or whether it is available for exclusive-write access. - */ -public enum LeaseStatus { - /** - * Specifies the blob is locked for exclusive-write access. - */ - LOCKED, - - /** - * Specifies the blob is available to be locked for exclusive-write access. - */ - UNLOCKED, - - /** - * Specifies the lease status is not specified. - */ - UNSPECIFIED; - - /** - * Parses a lease status from the given string. - * - * @param typeString - * A String that represents the string to parse. - * - * @return A LeaseStatus value that represents the lease status. - */ - public static LeaseStatus parse(final String typeString) { - if (Utility.isNullOrEmpty(typeString)) { - return UNSPECIFIED; - } - else if ("unlocked".equals(typeString.toLowerCase(Locale.US))) { - return UNLOCKED; - } - else if ("locked".equals(typeString.toLowerCase(Locale.US))) { - return LOCKED; - } - else { - return UNSPECIFIED; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java deleted file mode 100644 index b17398e168013..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * - * Specifies which types of operations the service should log. - */ -public enum LoggingOperations { - /** - * Log Read Operations . - */ - READ, - - /** - * Log Write Operations. - */ - WRITE, - - /** - * Log Delete Operations. - */ - DELETE; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java deleted file mode 100644 index 490b081a57955..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.EnumSet; - -/** - * Represents the logging properties for the analytics service. - */ -public final class LoggingProperties { - - /** - * The analytics version to use. - */ - private String version = "1.0"; - - /** - * A EnumSet of LoggingOperationTypes that represent which storage operations should be logged. - */ - private EnumSet logOperationTypes = EnumSet.noneOf(LoggingOperations.class); - - /** - * The Retention policy for the logging data. - */ - private Integer retentionIntervalInDays; - - /** - * @return the logOperationTypes - */ - public EnumSet getLogOperationTypes() { - return this.logOperationTypes; - } - - /** - * @return the retentionIntervalInDays - */ - public Integer getRetentionIntervalInDays() { - return this.retentionIntervalInDays; - } - - /** - * @return the version - */ - public String getVersion() { - return this.version; - } - - /** - * @param logOperationTypes - * the logOperationTypes to set - */ - public void setLogOperationTypes(final EnumSet logOperationTypes) { - this.logOperationTypes = logOperationTypes; - } - - /** - * @param retentionIntervalInDays - * the retentionIntervalInDays to set - */ - public void setRetentionIntervalInDays(final Integer retentionIntervalInDays) { - this.retentionIntervalInDays = retentionIntervalInDays; - } - - /** - * @param version - * the version to set - */ - public void setVersion(final String version) { - this.version = version; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java deleted file mode 100644 index 94cf8ba67c346..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Enumeration representing the state of metrics collection in a service. - */ -public enum MetricsLevel { - /** - * Metrics collection is disabled. - */ - DISABLED, - - /** - * Service-level metrics collection is enabled. - */ - SERVICE, - - /** - * Service-level and API metrics collection are enabled. - */ - SERVICE_AND_API; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java deleted file mode 100644 index d1f2acca61bfa..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents the metrics properties for the analytics service. - */ -public final class MetricsProperties { - /** - * The analytics version to use. - */ - private String version = "1.0"; - - /** - * A {@link MetricsLevel} level used to enable Metric and API logging - */ - private MetricsLevel metricsLevel = com.microsoft.windowsazure.services.core.storage.MetricsLevel.DISABLED; - - /** - * The Retention policy for the Metrics data. - */ - private Integer retentionIntervalInDays; - - /** - * @return the metricsLevel - */ - public MetricsLevel getMetricsLevel() { - return this.metricsLevel; - } - - /** - * @return the retentionIntervalInDays - */ - public Integer getRetentionIntervalInDays() { - return this.retentionIntervalInDays; - } - - /** - * @return the version - */ - public String getVersion() { - return this.version; - } - - /** - * @param metricsLevel - * the metricsLevel to set - */ - public void setMetricsLevel(final MetricsLevel metricsLevel) { - this.metricsLevel = metricsLevel; - } - - /** - * @param retentionIntervalInDays - * the retentionIntervalInDays to set - */ - public void setRetentionIntervalInDays(final Integer retentionIntervalInDays) { - this.retentionIntervalInDays = retentionIntervalInDays; - } - - /** - * @param version - * the version to set - */ - public void setVersion(final String version) { - this.version = version; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java deleted file mode 100644 index ce9f10672f90e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ /dev/null @@ -1,226 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.HttpURLConnection; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.UUID; -import java.util.logging.Logger; - -/** - * Represents the current logical operation. A logical operation has potentially a one-to-many relationship with - * individual physical requests. - */ -public final class OperationContext { - - /** - * Represents the operation latency, in milliseconds, from the client's perspective. This may include any potential - * retries. - */ - private long clientTimeInMs; - - /** - * The UUID representing the client side trace ID. - */ - // V2 expose when logging is available. - @SuppressWarnings("unused") - private final String clientTraceID; - - /** - * The Logger object associated with this operation. - */ - private Logger logger; - - /** - * Represents request results, in the form of an ArrayList object that contains the - * {@link RequestResult} objects, for each physical request that is made. - */ - private final ArrayList requestResults; - - /** - * Represents an event that is triggered when a response is received from the storage service while processing a - * request. - * - * @see StorageEvent - * @see StorageEventMultiCaster - * @see ResponseReceivedEvent - */ - private StorageEventMultiCaster> responseReceivedEventHandler = new StorageEventMultiCaster>(); - - /** - * Reserved for internal use. - */ - // Represents the intermediate MD5 value, which is used in resuming downloads. - private MessageDigest intermediateMD5; - - /** - * Reserved for internal use. Represents the current request object, which is used in continuation. - */ - private HttpURLConnection currentRequestObject; - - /** - * Represents the current operation state object. - */ - protected Object operationState; - - /** - * Reserved for internal use. - */ - // Used internally for download resume. - private volatile int currentOperationByteCount; - - /** - * Creates an instance of the OperationContext class. - */ - public OperationContext() { - this.clientTraceID = UUID.randomUUID().toString(); - this.requestResults = new ArrayList(); - } - - /** - * @return the clientTimeInMs - */ - public long getClientTimeInMs() { - return this.clientTimeInMs; - } - - /** - * @return the currentOperationByteCount - */ - public int getCurrentOperationByteCount() { - return this.currentOperationByteCount; - } - - /** - * @return the currentRequestObject - */ - public HttpURLConnection getCurrentRequestObject() { - return this.currentRequestObject; - } - - /** - * @return the intermediateMD5 - */ - public MessageDigest getIntermediateMD5() { - return this.intermediateMD5; - } - - /** - * Returns the last request result encountered for the operation. - * - * @return A {@link RequestResult} object that represents the last request result. - */ - public RequestResult getLastResult() { - if (this.requestResults == null || this.requestResults.size() == 0) { - return null; - } - else { - return this.requestResults.get(this.requestResults.size() - 1); - } - } - - /** - * Gets the Logger associated with this operation. - * - * @return the Logger associated with this operation - */ - @SuppressWarnings("unused") - private Logger getLogger() { - // V2 throw on null logger reference , use default dummy logger. - return this.logger; - } - - /** - * Returns the set of request results that the current operation has created. - * - * @return An ArrayList object that contains {@link RequestResult} objects that represent the request - * results created by the current operation. - */ - public ArrayList getRequestResults() { - return this.requestResults; - } - - /** - * @return the responseReceivedEventHandler - */ - public StorageEventMultiCaster> getResponseReceivedEventHandler() { - return this.responseReceivedEventHandler; - } - - /** - * Initializes the OperationContext in order to begin processing a new operation. All operation specific information - * is erased. - */ - public void initialize() { - this.setClientTimeInMs(0); - this.requestResults.clear(); - this.setIntermediateMD5(null); - this.operationState = null; - this.setCurrentRequestObject(null); - } - - /** - * @param clientTimeInMs - * the clientTimeInMs to set - */ - public void setClientTimeInMs(final long clientTimeInMs) { - this.clientTimeInMs = clientTimeInMs; - } - - /** - * @param currentOperationByteCount - * the currentOperationByteCount to set - */ - public void setCurrentOperationByteCount(final int currentOperationByteCount) { - this.currentOperationByteCount = currentOperationByteCount; - } - - /** - * @param currentRequestObject - * the currentRequestObject to set - */ - public void setCurrentRequestObject(final HttpURLConnection currentRequestObject) { - this.currentRequestObject = currentRequestObject; - } - - /** - * @param intermediateMD5 - * the intermediateMD5 to set - */ - public void setIntermediateMD5(final MessageDigest intermediateMD5) { - this.intermediateMD5 = intermediateMD5; - } - - /** - * Sets the Logger for this operation. - * - * @param logger - * the Logger to use for this operation - */ - @SuppressWarnings("unused") - private void setLogger(final Logger logger) { - this.logger = logger; - } - - /** - * @param responseReceivedEventHandler - * the responseReceivedEventHandler to set - */ - public void setResponseReceivedEventHandler( - final StorageEventMultiCaster> responseReceivedEventHandler) { - this.responseReceivedEventHandler = responseReceivedEventHandler; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java deleted file mode 100644 index af0a5c5a07daf..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents the options to use while processing a given request. - */ -public class RequestOptions { - - /** - * The instance of the {@link RetryPolicyFactory} interface to use for the request. - */ - private RetryPolicyFactory retryPolicyFactory; - - /** - * The timeout interval, in milliseconds, to use for the request. - */ - private Integer timeoutIntervalInMs; - - /** - * Creates an instance of the RequestOptions class. - */ - public RequestOptions() { - // Empty Default Ctor - } - - /** - * Creates an instance of the RequestOptions class by copying values from another - * RequestOptions instance. - * - * @param other - * A RequestOptions object that represents the request options to copy. - */ - public RequestOptions(final RequestOptions other) { - this.setTimeoutIntervalInMs(other.getTimeoutIntervalInMs()); - this.setRetryPolicyFactory(other.getRetryPolicyFactory()); - } - - /** - * Populates the default timeout and retry policy from client if they are null. - * - * @param client - * the service client to populate from - */ - protected final void applyBaseDefaults(final ServiceClient client) { - if (this.getRetryPolicyFactory() == null) { - this.setRetryPolicyFactory(client.getRetryPolicyFactory()); - } - - if (this.getTimeoutIntervalInMs() == null) { - this.setTimeoutIntervalInMs(client.getTimeoutInMs()); - } - } - - /** - * @return the retryPolicyFactory - */ - public final RetryPolicyFactory getRetryPolicyFactory() { - return this.retryPolicyFactory; - } - - /** - * @return the timeoutIntervalInMs - */ - public final Integer getTimeoutIntervalInMs() { - return this.timeoutIntervalInMs; - } - - /** - * @param retryPolicyFactory - * the retryPolicyFactory to set - */ - public final void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) { - this.retryPolicyFactory = retryPolicyFactory; - } - - /** - * @param timeoutIntervalInMs - * the timeoutIntervalInMs to set - */ - public final void setTimeoutIntervalInMs(final Integer timeoutIntervalInMs) { - this.timeoutIntervalInMs = timeoutIntervalInMs; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java deleted file mode 100644 index 050dfcbdb7eea..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.Date; - -/** - * Represents the result of a physical request. - */ -public final class RequestResult { - - /** - * Represents an exception that occurred while processing the request. This field may be null. - */ - private Exception exception; - - /** - * Represents the request ID supplied by the storage service. - */ - private String serviceRequestID; - - /** - * Represents the ContentMD5 header returned by the storage service. - */ - private String contentMD5; - - /** - * Represents the date header returned by the storage service. - */ - private String requestDate; - - /** - * Represents the ETag header returned by the storage service. - */ - private String etag; - - /** - * Represents the start date of the operation. - */ - private Date startDate; - - /** - * Represents the HTTP status code for the request. - */ - private int statusCode = -1; - - /** - * Represents the HTTP status message for the request. - */ - private String statusMessage; - - /** - * Represents the stop date of the operation. - */ - private Date stopDate; - - /** - * @return the contentMD5 - */ - public String getContentMD5() { - return this.contentMD5; - } - - /** - * @return the etag - */ - public String getEtag() { - return this.etag; - } - - /** - * @return the exception - */ - public Exception getException() { - return this.exception; - } - - /** - * @return the requestDate - */ - public String getRequestDate() { - return this.requestDate; - } - - /** - * @return the serviceRequestID - */ - public String getServiceRequestID() { - return this.serviceRequestID; - } - - /** - * @return the startDate - */ - public Date getStartDate() { - return this.startDate; - } - - /** - * @return the statusCode - */ - public int getStatusCode() { - return this.statusCode; - } - - /** - * @return the statusMessage - */ - public String getStatusMessage() { - return this.statusMessage; - } - - /** - * @return the stopDate - */ - public Date getStopDate() { - return this.stopDate; - } - - /** - * @param contentMD5 - * the contentMD5 to set - */ - public void setContentMD5(final String contentMD5) { - this.contentMD5 = contentMD5; - } - - /** - * @param etag - * the etag to set - */ - public void setEtag(final String etag) { - this.etag = etag; - } - - /** - * @param exception - * the exception to set - */ - public void setException(final Exception exception) { - this.exception = exception; - } - - /** - * @param requestDate - * the date to set - */ - public void setRequestDate(final String requestDate) { - this.requestDate = requestDate; - } - - /** - * @param serviceRequestID - * the serviceRequestID to set - */ - public void setServiceRequestID(final String serviceRequestID) { - this.serviceRequestID = serviceRequestID; - } - - /** - * @param startDate - * the startDate to set - */ - public void setStartDate(final Date startDate) { - this.startDate = startDate; - } - - /** - * @param statusCode - * the statusCode to set - */ - public void setStatusCode(final int statusCode) { - this.statusCode = statusCode; - } - - /** - * @param statusMessage - * the statusMessage to set - */ - public void setStatusMessage(final String statusMessage) { - this.statusMessage = statusMessage; - } - - /** - * @param stopDate - * the stopDate to set - */ - public void setStopDate(final Date stopDate) { - this.stopDate = stopDate; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java deleted file mode 100644 index a4cc29204915d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents an event that is fired when a response is received. - */ -public final class ResponseReceivedEvent { - - /** - * Represents a connection object. Currently only java.net.HttpURLConnection is supported as a - * connection object. - */ - private final Object connectionObject; - - /** - * Represents a context for the current operation. This object is used to track requests to the storage service, and - * to provide additional runtime information about the operation. - */ - private final OperationContext opContext; - - /** - * Creates an instance of the ResponseReceivedEvent class. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * @param connectionObject - * Represents a connection object. Currently only java.net.HttpURLConnection is supported as - * a connection object. - */ - public ResponseReceivedEvent(final OperationContext opContext, final Object connectionObject) { - this.opContext = opContext; - this.connectionObject = connectionObject; - } - - /** - * @return the connectionObject - */ - public Object getConnectionObject() { - return this.connectionObject; - } - - /** - * @return the opContext - */ - public OperationContext getOpContext() { - return this.opContext; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java deleted file mode 100644 index c8450867aa9ef..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import com.microsoft.windowsazure.services.blob.client.CloudBlobDirectory; - -/** - * Represents a continuation token for listing operations. Continuation tokens are used in methods that return a - * {@link ResultSegment} object, such as {@link CloudBlobDirectory#listBlobsSegmented}. - */ -public final class ResultContinuation { - /** - * Represents the next marker for continuing results of listing operations. - */ - private String nextMarker; - - /** - * Gets or sets the NextPartitionKey for TableServiceEntity enumeration operations. - */ - private String nextPartitionKey; - - /** - * Gets or sets the NextRowKey for TableServiceEntity enumeration operations. - */ - private String nextRowKey; - - /** - * Gets or sets the NextTableName for Table enumeration operations. - */ - private String nextTableName; - - /** - * Gets or sets the type of the continuation token. - */ - private ResultContinuationType continuationType; - - /** - * Creates an instance of the ResultContinuation class. - */ - public ResultContinuation() { - // Empty Default Ctor - } - - /** - * @return the continuationType - */ - public ResultContinuationType getContinuationType() { - return this.continuationType; - } - - /** - * @return the nextMarker - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * @return the nextPartitionKey - */ - public String getNextPartitionKey() { - return this.nextPartitionKey; - } - - /** - * @return the nextRowKey - */ - public String getNextRowKey() { - return this.nextRowKey; - } - - /** - * @return the nextTableName - */ - public String getNextTableName() { - return this.nextTableName; - } - - /** - * Returns a value that indicates whether continuation information is available. - * - * @return true if any continuation information is available; otherwise false. - */ - public boolean hasContinuation() { - return this.getNextMarker() != null || this.nextPartitionKey != null || this.nextRowKey != null - || this.nextTableName != null; - } - - /** - * @param continuationType - * the continuationType to set - */ - public void setContinuationType(final ResultContinuationType continuationType) { - this.continuationType = continuationType; - } - - /** - * @param nextMarker - * the nextMarker to set - */ - public void setNextMarker(final String nextMarker) { - this.nextMarker = nextMarker; - } - - /** - * @param nextPartitionKey - * the nextPartitionKey to set - */ - public void setNextPartitionKey(final String nextPartitionKey) { - this.nextPartitionKey = nextPartitionKey; - } - - /** - * @param nextRowKey - * the nextRowKey to set - */ - public void setNextRowKey(final String nextRowKey) { - this.nextRowKey = nextRowKey; - } - - /** - * @param nextTableName - * the nextTableName to set - */ - public void setNextTableName(final String nextTableName) { - this.nextTableName = nextTableName; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java deleted file mode 100644 index a36eb2ef722ce..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Specifies the type of a continuation token. - */ -public enum ResultContinuationType { - /** - * Specifies no continuation. - */ - NONE, - - /** - * Specifies the token is a blob listing continuation token. - */ - BLOB, - - /** - * Specifies the token is a container listing continuation token. - */ - CONTAINER, - - /** - * Specifies the token is a queue listing continuation token (reserved for future use). - */ - QUEUE, - - /** - * Specifies the token is a table query continuation token (reserved for future use). - */ - TABLE -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java deleted file mode 100644 index 63afc5805f6b8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.ArrayList; - -/** - * Represents a segment of results and contains continuation and pagination information. - * - * @param - * The type of the result that the segment contains. - */ -public class ResultSegment { - /** - * Stores the continuation token used to retrieve the next segment of results. - */ - private final ResultContinuation continuationToken; - - /** - * Holds the number of the results. - */ - private final int length; - - /** - * Holds the size of the requested page. - */ - private final int pageSize; - - /** - * Holds the Iterable collection of results. - */ - private final Iterable results; - - /** - * Reserved for internal use. Creates an instance of the ResultSegment class. - * - * @param results - * An ArrayList object that represents the results for the segment. - * @param pageSize - * The number of elements in a page of results. - * @param token - * A {@link ResultContinuation} object that represents the continuation token. - */ - public ResultSegment(final ArrayList results, final int pageSize, final ResultContinuation token) { - this.results = results; - this.length = results.size(); - this.pageSize = pageSize; - this.continuationToken = token; - } - - /** - * Returns the continuation token for the result segment. - * - * @return A {@link ResultContinuation} object that represents the continuation token. - */ - public ResultContinuation getContinuationToken() { - return this.continuationToken; - } - - /** - * Returns a value that indicates whether there are more results available from the server. - * - * @return true if there are more results available from the server; otherwise, false. - */ - public boolean getHasMoreResults() { - return this.continuationToken != null; - } - - /** - * Returns a value that indicates whether the page has more results. - * - * @return true if the page has more results; otherwise, false. - */ - public boolean getIsPageComplete() { - return this.length == this.pageSize; - } - - /** - * Returns the number of results in the segment. - * - * @return The actual number of the results in the segment. - */ - public int getLength() { - return this.length; - } - - /** - * Returns the size of the requested page. - * - * @return The size of the requested page. - */ - public int getPageSize() { - return this.pageSize; - } - - /** - * Returns the count of remaining results needed to fulfill the requested page size. - * - * @return The count of remaining results needed to fulfill the requested page size. - */ - public int getRemainingPageResults() { - return this.pageSize - this.length; - } - - /** - * Returns an enumerable set of results from the blob service. - * - * @return The results retrieved from the blob service. - */ - public Iterable getResults() { - return this.results; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java deleted file mode 100644 index 5dc967bcbbeb6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.Random; - -/** - * Represents a retry policy that performs a specified number of retries, using a randomized exponential backoff scheme - * to determine the interval between retries. - * - * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the - * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. - */ -public final class RetryExponentialRetry extends RetryPolicy implements RetryPolicyFactory { - - /** - * Holds the random number generator used to calculate randomized backoff interavals. - */ - private final Random randRef = new Random(); - - /** - * Holds the actual maximum backoff interval to enforce. - */ - private int resolvedMaxBackoff = RetryPolicy.DEFAULT_MAX_BACKOFF; - - /** - * Holds the actual minimum backoff interval to enforce. - */ - private int resolvedMinBackoff = RetryPolicy.DEFAULT_MIN_BACKOFF; - - /** - * Creates an instance of the RetryExponentialRetry class. - */ - public RetryExponentialRetry() { - this(RetryPolicy.DEFAULT_CLIENT_BACKOFF, RetryPolicy.DEFAULT_CLIENT_RETRY_COUNT); - } - - /** - * Creates an instance of the RetryExponentialRetry class using the specified delta backoff and maximum - * retry attempts. - * - * @param deltaBackoff - * The backoff interval, in milliseconds, between retries. - * @param maxAttempts - * The maximum number of retry attempts. - */ - public RetryExponentialRetry(final int deltaBackoff, final int maxAttempts) { - super(deltaBackoff, maxAttempts); - } - - /** - * Creates an instance of the RetryExponentialRetry class using the specified minimum, maximum, and - * delta backoff amounts, and maximum number of retry attempts. - * - * @param minBackoff - * The minimum backoff interval, in milliseconds, between retries. - * @param deltaBackoff - * The backoff interval, in milliseconds, between retries. - * @param maxBackOff - * The maximum backoff interval, in milliseconds, between retries. - * @param maxAttempts - * The maximum retry attempts, in milliseconds, between retries. - */ - public RetryExponentialRetry(final int minBackoff, final int deltaBackoff, final int maxBackOff, - final int maxAttempts) { - super(deltaBackoff, maxAttempts); - this.resolvedMinBackoff = minBackoff; - this.resolvedMaxBackoff = maxBackOff; - } - - /** - * Generates a new retry policy for the current request attempt. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. - */ - @Override - public RetryPolicy createInstance(final OperationContext opContext) { - return new RetryExponentialRetry(this.resolvedMinBackoff, this.deltaBackoffIntervalInMs, - this.resolvedMaxBackoff, this.maximumAttempts); - } - - /** - * Determines if the operation should be retried and how long to wait until the next retry. - * - * @param currentRetryCount - * The number of retries for the given operation. A value of zero signifies this is the first error - * encountered. - * @param statusCode - * The status code for the last operation. - * @param lastException - * A Exception object that represents the last exception encountered. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be - * retried and how long to backoff. - */ - @Override - public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, - final OperationContext opContext) { - - if (statusCode >= 400 && statusCode < 500) { - return new RetryResult(0, false); - } - - if (currentRetryCount < this.maximumAttempts) { - - // Calculate backoff Interval between 80% and 120% of the desired - // backoff, multiply by 2^n -1 for - // exponential - int incrementDelta = (int) (Math.pow(2, currentRetryCount) - 1); - final int boundedRandDelta = (int) (this.deltaBackoffIntervalInMs * 0.8) - + this.randRef.nextInt((int) (this.deltaBackoffIntervalInMs * 1.2) - - (int) (this.deltaBackoffIntervalInMs * 0.8)); - incrementDelta *= boundedRandDelta; - - // Enforce max / min backoffs - return new RetryResult(Math.min(this.resolvedMinBackoff + incrementDelta, this.resolvedMaxBackoff), true); - } - else { - return new RetryResult(-1, false); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java deleted file mode 100644 index d74d0595bf695..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents a retry policy that performs a specified number of retries, using a specified fixed time interval between - * retries. - * - * This class extends the {@link RetryPolicy} class and implements the {@link RetryPolicyFactory} interface. - */ -public final class RetryLinearRetry extends RetryPolicy implements RetryPolicyFactory { - - /** - * Creates an instance of the RetryLinearRetry class. - */ - public RetryLinearRetry() { - this(RetryPolicy.DEFAULT_CLIENT_BACKOFF, RetryPolicy.DEFAULT_CLIENT_RETRY_COUNT); - } - - /** - * Creates an instance of the RetryLinearRetry class using the specified delta backoff and maximum - * retry attempts. - * - * @param deltaBackoff - * The backoff interval, in milliseconds, between retries. - * @param maxAttempts - * The maximum number of retry attempts. - */ - public RetryLinearRetry(final int deltaBackoff, final int maxAttempts) { - super(deltaBackoff, maxAttempts); - } - - /** - * Generates a new retry policy for the current request attempt. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. - */ - @Override - public RetryPolicy createInstance(final OperationContext opContext) { - return new RetryLinearRetry(this.deltaBackoffIntervalInMs, this.maximumAttempts); - } - - /** - * Determines if the operation should be retried and how long to wait until the next retry. - * - * @param currentRetryCount - * The number of retries for the given operation. A value of zero signifies this is the first error - * encountered. - * @param statusCode - * The status code for the last operation. - * @param lastException - * A Exception object that represents the last exception encountered. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be - * retried and how long to backoff. - */ - @Override - public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, - final OperationContext opContext) { - if (statusCode >= 400 && statusCode < 500) { - return new RetryResult(0, false); - } - - final int backoff = Math.max(Math.min(this.deltaBackoffIntervalInMs, RetryPolicy.DEFAULT_MAX_BACKOFF), - RetryPolicy.DEFAULT_MIN_BACKOFF); - - return new RetryResult(backoff, currentRetryCount < this.maximumAttempts); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java deleted file mode 100644 index 4818851a2e396..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents a retry policy that performs no retries. - * - * This class extends the {@link com.microsoft.windowsazure.services.core.storage.RetryPolicy} class and implements the - * {@link com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory} interface. - */ -public final class RetryNoRetry extends RetryPolicy implements RetryPolicyFactory { - - /** - * Holds the static instance of the no retry policy. - */ - private static RetryNoRetry instance = new RetryNoRetry(); - - /** - * Returns the static instance of a no retry policy. - * - * @return A RetryNoRetry object that represents a no retry policy. - */ - public static RetryNoRetry getInstance() { - return instance; - } - - /** - * Generates a new retry policy for the current request attempt. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryPolicy} object that represents the retry policy for the current request attempt. - */ - @Override - public RetryPolicy createInstance(final OperationContext opContext) { - return getInstance(); - } - - /** - * Determines if the operation should be retried and how long to wait until the next retry. - * - * @param currentRetryCount - * The number of retries for the given operation. A value of zero signifies this is the first error - * encountered. - * @param statusCode - * The status code for the last operation. - * @param lastException - * A Exception object that represents the last exception encountered. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryResult} object that represents the retry result, indicating whether the operation should be - * retried and how long to backoff. - * - */ - @Override - public RetryResult shouldRetry(final int currentRetryCount, final int statusCode, final Exception lastException, - final OperationContext opContext) { - return new RetryResult(0, false); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java deleted file mode 100644 index 7be148342cf2d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Abstract class that represents a retry policy. - */ -public abstract class RetryPolicy { - - /** - * Represents the default client backoff interval, in milliseconds. - */ - public static final int DEFAULT_CLIENT_BACKOFF = 1000 * 30; - - /** - * Represents the default client retry count. - */ - public static final int DEFAULT_CLIENT_RETRY_COUNT = 3; - - /** - * Represents the default maximum backoff interval, in milliseconds. - */ - public static final int DEFAULT_MAX_BACKOFF = 1000 * 90; - - /** - * Represents the default minimum backoff interval, in milliseconds. - */ - public static final int DEFAULT_MIN_BACKOFF = 1000 * 3; - - /** - * Represents the realized backoff interval, in milliseconds. - */ - protected int deltaBackoffIntervalInMs; - - /** - * Represents the maximum retries that the retry policy should attempt. - */ - protected int maximumAttempts; - - /** - * Creates an instance of the RetryPolicy class. - */ - public RetryPolicy() { - // Empty Default Ctor - } - - /** - * Creates an instance of the RetryPolicy class using the specified delta backoff and maximum retry - * attempts. - * - * @param deltaBackoff - * The backoff interval, in milliseconds, between retries. - * @param maxAttempts - * The maximum number of retry attempts. - */ - public RetryPolicy(final int deltaBackoff, final int maxAttempts) { - this.deltaBackoffIntervalInMs = deltaBackoff; - this.maximumAttempts = maxAttempts; - } - - /** - * Determines if the operation should be retried and how long to wait until the next retry. - * - * @param currentRetryCount - * The number of retries for the given operation. A value of zero signifies this is the first error - * encountered. - * @param statusCode - * The status code for the last operation. - * @param lastException - * A Exception object that represents the last exception encountered. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryResult} object that indicates whether the operation should be retried and how long to - * backoff. - */ - public abstract RetryResult shouldRetry(int currentRetryCount, int statusCode, Exception lastException, - OperationContext opContext); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java deleted file mode 100644 index 3345063f2785c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents a retry policy factory that creates a new {@link RetryPolicy} object per transaction. - */ -public interface RetryPolicyFactory { - - /** - * Creates a new {@link RetryPolicy} object for the current request attempt. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link RetryPolicy} object that represents the new retry policy for the current request attempt. - */ - RetryPolicy createInstance(OperationContext opContext); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java deleted file mode 100644 index 80d74744c470f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents the result of a retry policy evaluation. - */ -public final class RetryResult { - /** - * Represents the backoff interval in milliseconds. - */ - private final int backOffIntervalInMs; - - /** - * Indicates whether to retry the operation. Set to true to retry; otherwise, false. - */ - private boolean shouldRetry; - - /** - * Creates an instance of the RetryResult class. - * - * @param backOff - * The backoff interval, in milliseconds, to wait before attempting the retry. - * @param shouldRetry - * true if the operation should be retried, otherwise, false. - * - */ - public RetryResult(final int backOff, final boolean shouldRetry) { - this.backOffIntervalInMs = backOff; - this.setShouldRetry(shouldRetry); - } - - /** - * Sleeps the amount of time specified by the backoff interval, if the retry policy indicates the operation should - * be retried. - */ - public void doSleep() { - if (this.isShouldRetry()) { - try { - Thread.sleep(this.backOffIntervalInMs); - } - catch (final InterruptedException e) { - // Restore the interrupted status - Thread.currentThread().interrupt(); - } - } - } - - /** - * @return the shouldRetry - */ - public boolean isShouldRetry() { - return this.shouldRetry; - } - - /** - * @param shouldRetry - * the shouldRetry to set - */ - public void setShouldRetry(final boolean shouldRetry) { - this.shouldRetry = shouldRetry; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java deleted file mode 100644 index 871f95bc36bdc..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.io.ByteArrayInputStream; -import java.net.HttpURLConnection; -import java.net.URI; - -import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; -import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; -import com.microsoft.windowsazure.services.queue.client.CloudQueueClient; - -/** - * Reserved for internal use. Provides a client for accessing the Windows Azure Storage service. - */ -public abstract class ServiceClient { - - /** - * Holds the base URI for the Service Client. - */ - protected URI endpoint; - - /** - * Holds the StorageCredentials associated with this Service Client. - */ - protected StorageCredentials credentials; - - /** - * Reserved for internal use. An internal flag which indicates if path style uris should be used. - */ - private boolean usePathStyleUris; - - /** - * Holds the default retry policy for requests made via the service client to set. - */ - protected RetryPolicyFactory retryPolicyFactory = new RetryExponentialRetry(); - - /** - * Holds the default server and client timeout for requests made by the service client. - */ - protected int timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; - - /** - * Creates an instance of the ServiceClient class using the specified service endpoint. - * - * @param baseUri - * A java.net.URI object that represents the service endpoint used to create the client. - */ - public ServiceClient(final URI baseUri) { - this(baseUri, null); - } - - /** - * Creates an instance of the ServiceClient class using the specified service endpoint and account - * credentials. - * - * @param baseUri - * A java.net.URI object that represents the service endpoint used to create the client. - * - * @param credentials - * A {@link StorageCredentials} object that represents the account credentials. - */ - public ServiceClient(final URI baseUri, final StorageCredentials credentials) { - Utility.assertNotNull("baseUri", baseUri); - if (!baseUri.isAbsolute()) { - throw new IllegalArgumentException(String.format( - "Address '%s' is not an absolute address. Relative addresses are not permitted in here.", baseUri)); - } - - this.credentials = credentials == null ? StorageCredentialsAnonymous.ANONYMOUS : credentials; - - this.retryPolicyFactory = new RetryExponentialRetry(); - this.timeoutInMs = Constants.DEFAULT_TIMEOUT_IN_MS; - - this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, this.credentials.getAccountName()); - this.endpoint = baseUri; - } - - /** - * Retrieves the current ServiceProperties for the given storage service. This includes Metrics and Logging - * Configurations. - * - * @return the ServiceProperties object representing the current configuration of the service. - * @throws StorageException - * If a storage service error occurred. - */ - public final ServiceProperties downloadServiceProperties() throws StorageException { - return this.downloadServiceProperties(null, null); - } - - /** - * Retrieves the current ServiceProperties for the given storage service. This includes Metrics and Logging - * Configurations. - * - * @param options - * A {@link RequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}{@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * @return the ServiceProperties object representing the current configuration of the service. - * @throws StorageException - * If a storage service error occurred. - */ - public final ServiceProperties downloadServiceProperties(RequestOptions options, OperationContext opContext) - throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new RequestOptions(); - } - - opContext.initialize(); - options.applyBaseDefaults(this); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public ServiceProperties execute(final ServiceClient client, final Void v, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = BaseRequest.getServiceProperties(client.getEndpoint(), this - .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); - - client.getCredentials().signRequest(request, -1); - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - return BaseResponse.readServicePropertiesFromStream(request.getInputStream(), opContext); - } - }; - - return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Returns the storage credentials associated with this service client. - * - * @return A {@link StorageCredentials} object that represents the storage credentials associated with this client. - */ - public final StorageCredentials getCredentials() { - return this.credentials; - } - - /** - * Returns the base URI for this service client. - * - * @return A java.net.URI object that represents the base URI for the service client. - */ - public final URI getEndpoint() { - return this.endpoint; - } - - /** - * Returns the retry policy currently in effect for this Blob service client. - * - * @return An {@link RetryPolicyFactory} object that represents the current retry policy. - * - * @see RetryPolicy - * @see RetryExponentialRetry - * @see RetryLinearRetry - * @see RetryNoRetry - */ - public final RetryPolicyFactory getRetryPolicyFactory() { - return this.retryPolicyFactory; - } - - /** - * Returns the timeout value for requests made to the service. For more information about the timeout, see - * {@link #setTimeoutInMs}. - * - * @return The current timeout value, in milliseconds, for requests made to the storage service. - */ - public final int getTimeoutInMs() { - return this.timeoutInMs; - } - - /** - * @return the usePathStyleUris - */ - public final boolean isUsePathStyleUris() { - return this.usePathStyleUris; - } - - /** - * Sets the base URI for the service client. - * - * @param baseUri - * A java.net.URI object that represents the base URI being assigned to the service client. - */ - protected final void setBaseURI(final URI baseUri) { - this.usePathStyleUris = Utility.determinePathStyleFromUri(baseUri, this.credentials.getAccountName()); - this.endpoint = baseUri; - } - - /** - * Sets the credentials to use with this service client. - * - * @param credentials - * A Credentials object that represents the credentials being assigned for the service - * client. - */ - protected final void setCredentials(final StorageCredentials credentials) { - this.credentials = credentials; - } - - /** - * Sets the RetryPolicyFactory object to use when making service requests. - * - * @param retryPolicyFactory - * the RetryPolicyFactory object to use when making service requests. - */ - public void setRetryPolicyFactory(final RetryPolicyFactory retryPolicyFactory) { - this.retryPolicyFactory = retryPolicyFactory; - } - - /** - * Sets the timeout to use when making requests to the storage service. - *

- * The server timeout interval begins at the time that the complete request has been received by the service, and - * the server begins processing the response. If the timeout interval elapses before the response is returned to the - * client, the operation times out. The timeout interval resets with each retry, if the request is retried. - * - * The default timeout interval for a request made via the service client is 90 seconds. You can change this value - * on the service client by setting this property, so that all subsequent requests made via the service client will - * use the new timeout interval. You can also change this value for an individual request, by setting the - * {@link RequestOptions#timeoutIntervalInMs} property. - * - * If you are downloading a large blob, you should increase the value of the timeout beyond the default value. - * - * @param timeoutInMs - * The timeout, in milliseconds, to use when making requests to the storage service. - */ - public final void setTimeoutInMs(final int timeoutInMs) { - this.timeoutInMs = timeoutInMs; - } - - /** - * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. - * - * @param properties - * The ServiceProperties to upload. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { - this.uploadServiceProperties(properties, null, null); - } - - /** - * Uploads a new configuration to the storage service. This includes Metrics and Logging Configuration. - * - * @param properties - * The ServiceProperties to upload. - * @param options - * A {@link RequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudBlobClient}{@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * @throws StorageException - * If a storage service error occurred. - */ - @DoesServiceRequest - public void uploadServiceProperties(final ServiceProperties properties, RequestOptions options, - OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new RequestOptions(); - } - - opContext.initialize(); - options.applyBaseDefaults(this); - - Utility.assertNotNull("properties", properties); - Utility.assertNotNull("properties.Logging", properties.getLogging()); - Utility.assertNotNull("properties.Logging.LogOperationTypes", properties.getLogging().getLogOperationTypes()); - Utility.assertNotNull("properties.Merics", properties.getMetrics()); - Utility.assertNotNull("properties.Merics.Configuration", properties.getMetrics().getMetricsLevel()); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final ServiceClient client, final Void v, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = BaseRequest.setServiceProperties(client.getEndpoint(), this - .getRequestOptions().getTimeoutIntervalInMs(), null, opContext); - - final byte[] propertiesBytes = BaseRequest.serializeServicePropertiesToByteArray(properties, opContext); - - final ByteArrayInputStream blockListInputStream = new ByteArrayInputStream(propertiesBytes); - - final StreamMd5AndLength descriptor = Utility.analyzeStream(blockListInputStream, -1L, -1L, true, true); - request.setRequestProperty(Constants.HeaderConstants.CONTENT_MD5, descriptor.getMd5()); - - client.getCredentials().signRequest(request, descriptor.getLength()); - Utility.writeToOutputStream(blockListInputStream, request.getOutputStream(), descriptor.getLength(), - false, false, null, opContext); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_ACCEPTED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java deleted file mode 100644 index b88fb17e75215..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java +++ /dev/null @@ -1,479 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.io.InputStream; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Represents the analytics properties for the service. - */ -public final class ServiceProperties { - /** - * Populates the Logging Properties form the xml reader. XmlStreamReader must be at start of Logging element. - * - * @param retProps - * the ServiceProperties to populate - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if the xml is invalid. - * @throws StorageException - * if unexpected xml is found. - */ - private static void readLoggingProperties(final ServiceProperties retProps, final XMLStreamReader xmlr) - throws XMLStreamException, StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); - - int eventType = xmlr.getEventType(); - String tempParseString = null; - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - final String name = xmlr.getName().toString(); - if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { - retProps.getLogging().setVersion( - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.VERSION_ELEMENT)); - } - else if (name.equals(Constants.AnalyticsConstants.DELETE_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.DELETE_ELEMENT); - if (Boolean.parseBoolean(tempParseString)) { - retProps.getLogging().getLogOperationTypes().add(LoggingOperations.DELETE); - } - } - else if (name.equals(Constants.AnalyticsConstants.READ_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.READ_ELEMENT); - if (Boolean.parseBoolean(tempParseString)) { - retProps.getLogging().getLogOperationTypes().add(LoggingOperations.READ); - } - } - else if (name.equals(Constants.AnalyticsConstants.WRITE_ELEMENT)) { - tempParseString = Utility - .readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.WRITE_ELEMENT); - if (Boolean.parseBoolean(tempParseString)) { - retProps.getLogging().getLogOperationTypes().add(LoggingOperations.WRITE); - } - } - else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { - retProps.getLogging().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else { - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); - break; - } - } - } - - /** - * Populates the Metrics Properties form the xml reader. XmlStreamReader must be at start of Metrics element. - * - * @param retProps - * the ServiceProperties to populate - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if the xml is invalid. - * @throws StorageException - * if unexpected xml is found. - */ - private static void readMetricsProperties(final ServiceProperties retProps, final XMLStreamReader xmlr) - throws XMLStreamException, StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); - - int eventType = xmlr.getEventType(); - String tempParseString = null; - retProps.getMetrics().setMetricsLevel(null); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - final String name = xmlr.getName().toString(); - if (name.equals(Constants.AnalyticsConstants.VERSION_ELEMENT)) { - retProps.getMetrics().setVersion( - Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.VERSION_ELEMENT)); - } - else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.ENABLED_ELEMENT); - - if (Boolean.parseBoolean(tempParseString)) { - retProps.getMetrics() - .setMetricsLevel( - retProps.getMetrics().getMetricsLevel() != MetricsLevel.SERVICE_AND_API ? MetricsLevel.SERVICE - : MetricsLevel.SERVICE_AND_API); - } - else { - retProps.getMetrics().setMetricsLevel(MetricsLevel.DISABLED); - } - } - else if (name.equals(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); - if (Boolean.parseBoolean(tempParseString) - && retProps.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED) { - retProps.getMetrics().setMetricsLevel(MetricsLevel.SERVICE_AND_API); - } - } - else if (name.equals(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT)) { - retProps.getMetrics().setRetentionIntervalInDays(readRetentionPolicy(xmlr)); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else { - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); - break; - } - } - } - - /** - * Parses the retention policy from the xml reader. XmlStreamReader must be at start of retention policy element. - * - * @param xmlr - * the XMLStreamReader to read from - * @return a nullable Integer representing the retention policy - * @throws XMLStreamException - * if the xml is invalid. - * @throws StorageException - * if unexpected xml is found. - */ - private static Integer readRetentionPolicy(final XMLStreamReader xmlr) throws XMLStreamException, StorageException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); - - Integer retVal = -1; - int eventType = xmlr.getEventType(); - String tempParseString = null; - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT) { - final String name = xmlr.getName().toString(); - - if (name.equals(Constants.AnalyticsConstants.DAYS_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.AnalyticsConstants.DAYS_ELEMENT); - - // if we have already detected that the retention policy is disabled dont return a value; - if (retVal != null) { - retVal = Integer.parseInt(tempParseString); - } - } - else if (name.equals(Constants.AnalyticsConstants.ENABLED_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.ENABLED_ELEMENT); - - if (!Boolean.parseBoolean(tempParseString)) { - retVal = null; - } - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else { - xmlr.require(XMLStreamConstants.END_ELEMENT, null, - Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); - break; - } - } - - return retVal; - } - - /** - * Deserializes the ServiceProperties object from an input stream. - * - * @param inStream - * the stream to read from. - * @param opContext - * an object used to track the execution of the operation - * @return a ServiceProperties object representing the Analytics configuration for the client. - * @throws XMLStreamException - * if the xml is invalid. - * @throws StorageException - * if unexpected xml is found. - */ - public static ServiceProperties readServicePropertiesFromStream(final InputStream inStream, - final OperationContext opContext) throws XMLStreamException, StorageException { - final ServiceProperties retProps = new ServiceProperties(); - - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(inStream); - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get StorageServiceProperties Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, - Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.START_ELEMENT) { - final String name = xmlr.getName().toString(); - if (name.equals(Constants.AnalyticsConstants.LOGGING_ELEMENT)) { - readLoggingProperties(retProps, xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.LOGGING_ELEMENT); - } - else if (name.equals(Constants.AnalyticsConstants.METRICS_ELEMENT)) { - readMetricsProperties(retProps, xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.AnalyticsConstants.METRICS_ELEMENT); - } - else if (name.equals(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)) { - retProps.setDefaultServiceVersion(Utility.readElementFromXMLReader(xmlr, - Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION)); - } - else { - throw new StorageException(StorageErrorCodeStrings.INVALID_XML_DOCUMENT, - "The response recieved is invalid or improperly formatted.", - Constants.HeaderConstants.HTTP_UNUSED_306, null, null); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT) { - if (xmlr.getName().toString().equals(Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT)) { - break; - } - } - } - - return retProps; - } - - /** - * Writes the retention policy to the XMLStreamWriter. - * - * @param xmlw - * the XMLStreamWriter to write to. - * @param val - * the nullable Integer indicating if the retention policy is enabled, and how long - * @throws XMLStreamException - */ - private static void writeRetentionPolicy(final XMLStreamWriter xmlw, final Integer val) throws XMLStreamException { - xmlw.writeStartElement(Constants.AnalyticsConstants.RETENTION_POLICY_ELEMENT); - - // Enabled - xmlw.writeStartElement(Constants.AnalyticsConstants.ENABLED_ELEMENT); - xmlw.writeCharacters(val != null ? Constants.TRUE : Constants.FALSE); - xmlw.writeEndElement(); - - if (val != null) { - // Days - xmlw.writeStartElement(Constants.AnalyticsConstants.DAYS_ELEMENT); - xmlw.writeCharacters(val.toString()); - xmlw.writeEndElement(); - } - - // End Retention Policy - xmlw.writeEndElement(); - } - - /** - * The service logging properties. This may not be null. - */ - private LoggingProperties logging; - - /** - * The service metrics properties. - */ - private MetricsProperties metrics; - - /** - * The default service version for the blob service, or null if no default is specified. This must be null for queue - * and table service properties. - */ - private String defaultServiceVersion; - - public ServiceProperties() { - this.setLogging(new LoggingProperties()); - this.setMetrics(new MetricsProperties()); - } - - /** - * @return the defaultServiceVersion - */ - public String getDefaultServiceVersion() { - return this.defaultServiceVersion; - } - - /** - * @return the logging - */ - public LoggingProperties getLogging() { - return this.logging; - } - - /** - * @return the metrics - */ - public MetricsProperties getMetrics() { - return this.metrics; - } - - /** - * Writes the contents of the ServiceProperties to the stream in xml format. - * - * @param opContext - * a tracking object for the request - * @return a byte array of the content to write to the stream. - * @throws XMLStreamException - * if there is an error writing content to the stream. - * @throws StorageException - */ - public byte[] serializeToByteArray(final OperationContext opContext) throws XMLStreamException, StorageException { - Utility.assertNotNull("Logging", this.getLogging()); - Utility.assertNotNull("Logging.LogOperationTypes", this.getLogging().getLogOperationTypes()); - Utility.assertNotNull("Merics", this.getMetrics()); - Utility.assertNotNull("Merics.Configuration", this.getMetrics().getMetricsLevel()); - - final StringWriter outWriter = new StringWriter(); - final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); - final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); - - // default is UTF8 - xmlw.writeStartDocument(); - xmlw.writeStartElement(Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT); - - // Logging - xmlw.writeStartElement(Constants.AnalyticsConstants.LOGGING_ELEMENT); - - // Version - xmlw.writeStartElement(Constants.AnalyticsConstants.VERSION_ELEMENT); - xmlw.writeCharacters(this.getLogging().getVersion()); - xmlw.writeEndElement(); - - // Delete - xmlw.writeStartElement(Constants.AnalyticsConstants.DELETE_ELEMENT); - xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.DELETE) ? Constants.TRUE - : Constants.FALSE); - xmlw.writeEndElement(); - - // Read - xmlw.writeStartElement(Constants.AnalyticsConstants.READ_ELEMENT); - xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.READ) ? Constants.TRUE - : Constants.FALSE); - xmlw.writeEndElement(); - - // Write - xmlw.writeStartElement(Constants.AnalyticsConstants.WRITE_ELEMENT); - xmlw.writeCharacters(this.getLogging().getLogOperationTypes().contains(LoggingOperations.WRITE) ? Constants.TRUE - : Constants.FALSE); - xmlw.writeEndElement(); - - // Retention Policy - writeRetentionPolicy(xmlw, this.getLogging().getRetentionIntervalInDays()); - - // end Logging - xmlw.writeEndElement(); - - // Metrics - xmlw.writeStartElement(Constants.AnalyticsConstants.METRICS_ELEMENT); - - // Version - xmlw.writeStartElement(Constants.AnalyticsConstants.VERSION_ELEMENT); - xmlw.writeCharacters(this.getMetrics().getVersion()); - xmlw.writeEndElement(); - - // Enabled - xmlw.writeStartElement(Constants.AnalyticsConstants.ENABLED_ELEMENT); - xmlw.writeCharacters(this.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED ? Constants.TRUE - : Constants.FALSE); - xmlw.writeEndElement(); - - if (this.getMetrics().getMetricsLevel() != MetricsLevel.DISABLED) { - // Include APIs - xmlw.writeStartElement(Constants.AnalyticsConstants.INCLUDE_APIS_ELEMENT); - xmlw.writeCharacters(this.getMetrics().getMetricsLevel() == MetricsLevel.SERVICE_AND_API ? Constants.TRUE - : Constants.FALSE); - xmlw.writeEndElement(); - } - - // Retention Policy - writeRetentionPolicy(xmlw, this.getMetrics().getRetentionIntervalInDays()); - - // end Metrics - xmlw.writeEndElement(); - - // Default Service Version - if (this.getDefaultServiceVersion() != null) { - xmlw.writeStartElement(Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION); - xmlw.writeCharacters(this.getDefaultServiceVersion()); - xmlw.writeEndElement(); - } - - // end StorageServiceProperties - xmlw.writeEndElement(); - - // end doc - xmlw.writeEndDocument(); - - try { - return outWriter.toString().getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * @param defaultServiceVersion - * the defaultServiceVersion to set - */ - public void setDefaultServiceVersion(final String defaultServiceVersion) { - this.defaultServiceVersion = defaultServiceVersion; - } - - /** - * @param logging - * the logging to set - */ - public void setLogging(final LoggingProperties logging) { - this.logging = logging; - } - - /** - * @param metrics - * the metrics to set - */ - public void setMetrics(final MetricsProperties metrics) { - this.metrics = metrics; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java deleted file mode 100644 index c48c19b173606..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ /dev/null @@ -1,333 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.HashMap; - -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Represents a set of credentials used to authenticate access to a Windows Azure storage account. This is the base - * class for the {@link StorageCredentialsAccountAndKey} and {@link StorageCredentialsSharedAccessSignature} classes. - */ -public abstract class StorageCredentials { - - /** - * Tries to determine the storage credentials from a collection of name/value pairs. - * - * @param settings - * A HashMap object of the name/value pairs that represent the settings to use to configure - * the credentials. - *

- * Either include an account name with an account key (specifying values for - * {@link CloudStorageAccount#ACCOUNT_NAME_NAME} and {@link CloudStorageAccount#ACCOUNT_KEY_NAME} ), or a - * shared access signature (specifying a value for - * {@link CloudStorageAccount#SHARED_ACCESS_SIGNATURE_NAME} ). If you use an account name and account - * key, do not include a shared access signature, and vice versa. - * - * @return A {@link StorageCredentials} object representing the storage credentials determined from the name/value - * pairs. - * - * @throws InvalidKeyException - * If the key value specified for {@link CloudStorageAccount#ACCOUNT_KEY_NAME} is not a valid - * Base64-encoded string. - */ - protected static StorageCredentials tryParseCredentials(final HashMap settings) - throws InvalidKeyException { - final String accountName = settings.get(CloudStorageAccount.ACCOUNT_NAME_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_NAME_NAME) : null; - - final String accountKey = settings.get(CloudStorageAccount.ACCOUNT_KEY_NAME) != null ? settings - .get(CloudStorageAccount.ACCOUNT_KEY_NAME) : null; - - final String sasSignature = settings.get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) != null ? settings - .get(CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME) : null; - - if (accountName != null && accountKey != null && sasSignature == null) { - if (Base64.validateIsBase64String(accountKey)) { - return new StorageCredentialsAccountAndKey(accountName, accountKey); - } - else { - throw new InvalidKeyException("Storage Key is not a valid base64 encoded string."); - } - } - if (accountName == null && accountKey == null && sasSignature != null) { - return new StorageCredentialsSharedAccessSignature(sasSignature); - } - - return null; - } - - /** - * Tries to determine the storage credentials from a connection string. - * - * @param connectionString - * A String that contains the key/value pairs that represent the storage credentials. - *

- * The format for the connection string is in the pattern "keyname=value". Multiple key/value - * pairs can be separated by a semi-colon, for example, "keyname1=value1;keyname2=value2". - * - * @return A {@link StorageCredentials} object representing the storage credentials determined from the connection - * string. - * - * @throws InvalidKeyException - * If the account key specified in connectionString is not valid. - * @throws StorageException - * If a storage service error occurred. - */ - public static StorageCredentials tryParseCredentials(final String connectionString) throws InvalidKeyException, - StorageException { - return tryParseCredentials(Utility.parseAccountString(connectionString)); - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // ComputeHmac method will return a valid HMAC-encoded - // signature string when called using the specified credentials. - // - // @return True if these credentials will yield a valid - // signature string; otherwise, false - // - /** Reserved. */ - public abstract boolean canCredentialsComputeHmac(); - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key authentication scheme using - // the specified credentials. - // - // @return True if a request can be signed with these - // credentials; otherwise, false - // - /** Reserved. */ - public abstract boolean canCredentialsSignRequest(); - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key Lite authentication scheme - // using the specified credentials. - // - // @return true if a request can be signed with these - // credentials; otherwise, false - // - /** Reserved. */ - public abstract boolean canCredentialsSignRequestLite(); - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA256-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - public abstract String computeHmac256(String value) throws InvalidKeyException; - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation - * context. - * - * @param value - * The UTF-8-encoded string to sign. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that contains the HMAC-SHA256-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - public abstract String computeHmac256(String value, OperationContext opContext) throws InvalidKeyException; - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA512-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - public abstract String computeHmac512(String value) throws InvalidKeyException; - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation - * context. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that contains the HMAC-SHA512-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - public abstract String computeHmac512(String value, OperationContext opContext) throws InvalidKeyException; - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // TransformUri method should be called to transform a resource - // URI to a URI that includes a token for a shared access signature. - // - // @return True if the URI must be transformed; otherwise, - // false - // - /** Reserved. */ - public abstract boolean doCredentialsNeedTransformUri(); - - /** - * Returns the associated account name for the credentials. - * - * @return A String that represents the associated account name for the credentials - */ - public abstract String getAccountName(); - - /** - * Signs a request under the Shared Key authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * - * @throws InvalidKeyException - * If the given key is invalid. - * - * @throws StorageException - * If a storage service error occurred. - */ - public abstract void signRequest(HttpURLConnection request, long contentLength) throws InvalidKeyException, - StorageException; - - /** - * Signs a request using the specified operation context under the Shared Key authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public abstract void signRequest(HttpURLConnection request, long contentLength, OperationContext opContext) - throws InvalidKeyException, StorageException; - - /** - * Signs a request under the Shared Key Lite authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If an unspecified storage exception occurs. - */ - public abstract void signRequestLite(HttpURLConnection request, long contentLength) throws StorageException, - InvalidKeyException; - - /** - * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - public abstract void signRequestLite(HttpURLConnection request, long contentLength, OperationContext opContext) - throws StorageException, InvalidKeyException; - - /** - * Returns a String that represents this instance. - * - * @param exportSecrets - * true to include sensitive data in the return string; otherwise, false. - * @return A String that represents this object, optionally including sensitive data. - */ - public abstract String toString(boolean exportSecrets); - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - public abstract URI transformUri(URI resourceUri) throws URISyntaxException, StorageException; - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the - * specified operation context. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - public abstract URI transformUri(URI resourceUri, OperationContext opContext) throws URISyntaxException, - StorageException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java deleted file mode 100644 index cc27ffcb430b5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ /dev/null @@ -1,371 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; - -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; - -/** - * Represents storage account credentials, based on storage account and access key, for accessing the Windows Azure - * storage services. - */ -public final class StorageCredentialsAccountAndKey extends StorageCredentials { - - /** - * The internal Credentials associated with the StorageCredentials. - */ - private Credentials credentials; - - /** - * Creates an instance of the StorageCredentialsAccountAndKey class, using the specified storage - * account name and access key; the specified access key is in the form of a byte array. - * - * @param accountName - * A String that represents the name of the storage account. - * @param key - * An array of bytes that represent the account access key. - */ - public StorageCredentialsAccountAndKey(final String accountName, final byte[] key) { - this.credentials = new Credentials(accountName, key); - } - - /** - * Creates an instance of the StorageCredentialsAccountAndKey class, using the specified storage - * account name and access key; the specified access key is stored as a String. - * - * @param accountName - * A String that represents the name of the storage account. - * @param key - * A String that represents the Base-64-encoded account access key. - */ - public StorageCredentialsAccountAndKey(final String accountName, final String key) { - this(accountName, Base64.decode(key)); - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // ComputeHmac method will return a valid HMAC-encoded - // signature string when called using the specified credentials. - // - // @return True - // - /** Reserved. */ - @Override - public boolean canCredentialsComputeHmac() { - return true; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key authentication scheme using - // the specified credentials. - // - // @return True - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequest() { - return true; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key Lite authentication scheme - // using the specified credentials. - // - // @return True - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequestLite() { - return true; - } - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA256-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - @Override - public String computeHmac256(final String value) throws InvalidKeyException { - return this.computeHmac256(value, null); - } - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation - * context. - * - * @param value - * The UTF-8-encoded string to sign. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that contains the HMAC-SHA256-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - @Override - public String computeHmac256(final String value, final OperationContext opContext) throws InvalidKeyException { - return StorageKey.computeMacSha256(this.credentials.getKey(), value); - } - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA512-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - @Override - public String computeHmac512(final String value) throws InvalidKeyException { - return this.computeHmac512(value, null); - } - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation - * context. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A String that contains the HMAC-SHA512-encoded signature. - * - * @throws InvalidKeyException - * If the key is not a valid Base64-encoded string. - */ - @Override - public String computeHmac512(final String value, final OperationContext opContext) throws InvalidKeyException { - return StorageKey.computeMacSha512(this.credentials.getKey(), value); - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // TransformUri method should be called to transform a resource - // URI to a URI that includes a token for a shared access signature. - // - // @return False. - // - /** Reserved. */ - @Override - public boolean doCredentialsNeedTransformUri() { - return false; - } - - /** - * Returns the associated account name for the credentials. - * - * @return A String that contains the account name for the credentials. - */ - @Override - public String getAccountName() { - return this.credentials.getAccountName(); - } - - /** - * Returns the Base64-encoded key for the credentials. - * - * @return A String that contains the Base64-encoded key. - */ - protected String getBase64EncodedKey() { - return this.credentials.getKey().getBase64EncodedKey(); - } - - /** - * Returns the internal credentials associated with the storage credentials. - * - * @return A Credentials object that contains the internal credentials associated with this instance of - * the StorageCredentialsAccountAndKey class. - */ - public Credentials getCredentials() { - return this.credentials; - } - - /** - * Sets the credentials. - * - * @param credentials - * A Credentials object that represents the credentials to set for this instance of the - * StorageCredentialsAccountAndKey class. - */ - public void setCredentials(final Credentials credentials) { - this.credentials = credentials; - } - - /** - * Signs a request under the Shared Key authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength) - throws InvalidKeyException, StorageException { - this.signRequest(request, contentLength, null); - } - - /** - * Signs a request using the specified operation context under the Shared Key authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength, - OperationContext opContext) throws InvalidKeyException, StorageException { - opContext = opContext == null ? new OperationContext() : opContext; - BaseRequest.signRequestForBlobAndQueue(request, this.credentials, contentLength, opContext); - } - - /** - * Signs a request using the Shared Key Lite authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If an unspecified storage exception occurs. - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) - throws InvalidKeyException, StorageException { - this.signRequestLite(request, contentLength, null); - } - - /** - * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws InvalidKeyException - * If the given key is invalid. - * @throws StorageException - * If a storage service error occurred. - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, - OperationContext opContext) throws StorageException, InvalidKeyException { - opContext = opContext == null ? new OperationContext() : opContext; - BaseRequest.signRequestForTableSharedKeyLite(request, this.credentials, contentLength, opContext); - } - - /** - * Returns a String that represents this instance, optionally including sensitive data. - * - * @param exportSecrets - * true to include sensitive data in the return string; otherwise, false. - * - * @return A String that represents this object, optionally including sensitive data. - */ - @Override - public String toString(final boolean exportSecrets) { - return String.format("%s=%s;%s=%s", CloudStorageAccount.ACCOUNT_NAME_NAME, this.getAccountName(), - CloudStorageAccount.ACCOUNT_KEY_NAME, exportSecrets ? this.credentials.getKey().getBase64EncodedKey() - : "[key hidden]"); - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - @Override - public URI transformUri(final URI resourceUri) { - return this.transformUri(resourceUri, null); - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the - * specified operation context. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - @Override - public URI transformUri(final URI resourceUri, final OperationContext opContext) { - return resourceUri; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java deleted file mode 100644 index b50814764975e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ /dev/null @@ -1,275 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.URI; - -/** - * *RESERVED FOR INTERNAL USE* Represents credentials for anonymous access. This class is used by the internal - * implementation (not a public class, so its comments are not built into the Javadoc output). - */ -public final class StorageCredentialsAnonymous extends StorageCredentials { - - /** - * Stores the singleton instance of this class. - */ - public static final StorageCredentials ANONYMOUS = new StorageCredentialsAnonymous(); - - /** - * Returns the singleton instance of the StorageCredentials class. - * - * @return the singleton instance of this class - */ - protected static StorageCredentials getInstance() { - return StorageCredentialsAnonymous.ANONYMOUS; - } - - /** - * Enforces the singleton pattern via a private constructor. - */ - protected StorageCredentialsAnonymous() { - // Empty Default Ctor - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // ComputeHmac method will return a valid HMAC-encoded - // signature string when called using the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsComputeHmac() { - return false; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key authentication scheme using - // the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequest() { - return false; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key Lite authentication scheme - // using the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequestLite() { - return false; - } - - /** - * Encodes a Shared Key or Shared Key Lite signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded - * string-to-sign. This is not a valid operation for objects of type StorageCredentialsAnonymous so the - * method merely returns null. - * - * @param value - * the UTF-8-encoded string-to-sign - * @return null for objects of type StorageCredentialsAnonymous - */ - @Override - public String computeHmac256(final String value) { - return null; - } - - /** - * Encodes a Shared Key or Shared Key Lite signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded - * string-to-sign and the specified operation context. This is not a valid operation for objects of type - * StorageCredentialsAnonymous so the method merely returns null. - * - * @param value - * the UTF-8-encoded string-to-sign - * @param opContext - * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} - * object, that represents the current operation - * @return null for objects of type StorageCredentialsAnonymous - */ - @Override - public String computeHmac256(final String value, final OperationContext opContext) { - return null; - } - - /** - * Encodes a Shared Key signature string by using the HMAC-SHA512 algorithm over a UTF-8-encoded string-to-sign. - * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method merely - * returns null. - * - * @param value - * the UTF-8-encoded string-to-sign - * @return null for objects of type StorageCredentialsAnonymous - */ - @Override - public String computeHmac512(final String value) { - return null; - } - - /** - * Encodes a Shared Key signature string by using the HMAC-SHA256 algorithm over a UTF-8-encoded string-to-sign. - * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method merely - * returns null. - * - * @param value - * the UTF-8-encoded string-to-sign - * @param opContext - * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} - * object, that represents the current operation - * - * @return null for objects of type StorageCredentialsAnonymous - */ - @Override - public String computeHmac512(final String value, final OperationContext opContext) { - return null; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // TransformUri method should be called to transform a resource - // URI to a URI that includes a token for a shared access signature. - // - // @return False. - // - /** Reserved. */ - @Override - public boolean doCredentialsNeedTransformUri() { - return false; - } - - /** - * Returns the associated account name for the credentials. This is null for anonymous credentials. - * - * @return null for anonymous credentials - */ - @Override - public String getAccountName() { - return null; - } - - /** - * Signs a request using the specified credentials under the Shared Key authentication scheme. This is not a valid - * operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. - * - * @param connection - * the request, as an HttpURLConnection object, to sign - * @param contentLength - * the length of the content written to the output stream. If unknown, specify -1. - */ - @Override - public void signRequest(final java.net.HttpURLConnection connection, final long contentLength) { - // No op - } - - /** - * Signs a request using the specified credentials and operation context under the Shared Key authentication scheme. - * This is not a valid operation for objects of type StorageCredentialsAnonymous so the method performs - * a no-op. - * - * @param request - * the request, as an HttpURLConnection object, to sign - * @param contentLength - * the length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} - * object, that represents the current operation - */ - @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength, - final OperationContext opContext) { - // No op - } - - /** - * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a - * valid operation for objects of type StorageCredentialsAnonymous so the method performs a no-op. - * - * @param connection - * the request, as an HttpURLConnection object, to sign - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection connection, final long contentLength) { - // No op - } - - /** - * Signs a request using the specified credentials under the Shared Key Lite authentication scheme. This is not a - * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a - * no-op. - * - * @param request - * the request, as an HttpURLConnection object, to sign - * @param opContext - * an operation context, as a {@link com.microsoft.windowsazure.services.core.storage.OperationContext} - * object, that represents the current operation - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, - final OperationContext opContext) { - // No op - } - - /** - * Returns a String object that represents this instance. - * - * @param exportSecrets - * true to include sensitive data in the string; otherwise, false - * @return a string representation of the credentials, optionally including sensitive data. - */ - @Override - public String toString(final boolean exportSecrets) { - return Constants.EMPTY_STRING; - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token. No transform - * occurs for anonymous credentials, so this method returns the same URI that is passed in. - * - * @param resourceUri - * the resource URI to be transformed - * @return the unmodified value passed in for the resourceUri parameter - */ - @Override - public URI transformUri(final URI resourceUri) { - return this.transformUri(resourceUri, null); - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token. No transform - * occurs for anonymous credentials, so this method returns the same URI that is passed in. - * - * @param resourceUri - * the resource URI to be transformed - * @param opContext - * the an operation context, as a - * {@link com.microsoft.windowsazure.services.core.storage.OperationContext} object, that represents the - * current operation - * - * @return the unmodified value passed in for the resourceUri parameter - */ - @Override - public URI transformUri(final URI resourceUri, final OperationContext opContext) { - return resourceUri; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java deleted file mode 100644 index ed30c27fe8a9b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ /dev/null @@ -1,310 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.net.URI; -import java.net.URISyntaxException; - -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; - -/** - * Represents storage credentials for delegated access to Blob service resources via a shared access signature. - */ -public final class StorageCredentialsSharedAccessSignature extends StorageCredentials { - - /** - * Stores the shared access signature token. - */ - private final String token; - - /** - * Creates an instance of the StorageCredentialsSharedAccessSignature class using the specified shared - * access signature token. - * - * @param token - * A String that represents shared access signature token. - */ - public StorageCredentialsSharedAccessSignature(final String token) { - this.token = token; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // ComputeHmac method will return a valid HMAC-encoded - // signature string when called using the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsComputeHmac() { - return false; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key authentication scheme using - // the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequest() { - return false; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether a - // request can be signed under the Shared Key Lite authentication scheme - // using the specified credentials. - // - // @return False - // - /** Reserved. */ - @Override - public boolean canCredentialsSignRequestLite() { - return false; - } - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm. This is not a valid operation for - * objects of type StorageCredentialsSharedAccessSignature so the method merely returns - * null. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return null for objects of type StorageCredentialsSharedAccessSignature. - */ - @Override - public String computeHmac256(final String value) { - return null; - } - - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm with the specified operation - * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature - * so the method merely returns null. - * - * @param value - * The UTF-8-encoded string to sign. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return null for objects of type StorageCredentialsSharedAccessSignature. - */ - @Override - public String computeHmac256(final String value, final OperationContext opContext) { - return null; - } - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm. This is not a valid operation for - * objects of type StorageCredentialsSharedAccessSignature so the method merely returns - * null. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @return null for objects of type StorageCredentialsSharedAccessSignature. - */ - @Override - public String computeHmac512(final String value) { - return null; - } - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm with the specified operation - * context. This is not a valid operation for objects of type StorageCredentialsSharedAccessSignature - * so the method merely returns null. - * - * @param value - * The UTF-8-encoded string to sign. - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return null for objects of type StorageCredentialsSharedAccessSignature. - */ - @Override - public String computeHmac512(final String value, final OperationContext opContext) { - return null; - } - - // - // RESERVED, for internal use only. Gets a value indicating whether the - // TransformUri method should be called to transform a resource - // URI to a URI that includes a token for a shared access signature. - // - // @return True. - // - /** Reserved. */ - @Override - public boolean doCredentialsNeedTransformUri() { - return true; - } - - /** - * Returns the associated account name for the credentials. This is not a valid operation for objects of type - * StorageCredentialsSharedAccessSignature so the method merely returns null. - * - * @return null for objects of type StorageCredentialsSharedAccessSignature. - */ - @Override - public String getAccountName() { - return null; - } - - /** - * Returns the shared access signature token. - * - * @return A String that contains the token. - */ - public String getToken() { - return this.token; - } - - /** - * Signs a request under the Shared Key authentication scheme. This is not a valid operation for objects of type - * StorageCredentialsSharedAccessSignature so the method performs a no-op. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - */ - @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength) { - // No op - } - - /** - * Signs a request using the specified operation context under the Shared Key authentication scheme. This is not a - * valid operation for objects of type StorageCredentialsSharedAccessSignature so the method performs a - * no-op. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - */ - @Override - public void signRequest(final java.net.HttpURLConnection request, final long contentLength, - final OperationContext opContext) { - // No op - } - - /** - * Signs a request under the Shared Key Lite authentication scheme. This is not a valid operation for objects of - * type StorageCredentialsSharedAccessSignature so the method performs a no-op. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength) { - // No op - } - - /** - * Signs a request using the specified operation context under the Shared Key Lite authentication scheme. This is - * not a valid operation for objects of type StorageCredentialsSharedAccessSignature so the method - * performs a no-op. - * - * @param request - * An HttpURLConnection object that represents the request to sign. - * @param contentLength - * The length of the content written to the output stream. If unknown, specify -1. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - */ - @Override - public void signRequestLite(final java.net.HttpURLConnection request, final long contentLength, - final OperationContext opContext) { - // No op - } - - /** - * Returns a String that represents this instance, optionally including sensitive data. - * - * @param exportSecrets - * true to include sensitive data in the return string; otherwise, false. - * @return A String that represents this object, optionally including sensitive data. - */ - @Override - public String toString(final boolean exportSecrets) { - return String.format("%s=%s", CloudStorageAccount.SHARED_ACCESS_SIGNATURE_NAME, exportSecrets ? this.token - : "[signature hidden]"); - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws IllegalArgumentException - * If a parameter is invalid. - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - @Override - public URI transformUri(final URI resourceUri) throws URISyntaxException, StorageException { - return this.transformUri(resourceUri, null); - } - - /** - * Transforms a resource URI into a shared access signature URI, by appending a shared access token and using the - * specified operation context. - * - * @param resourceUri - * A java.net.URI object that represents the resource URI to be transformed. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A java.net.URI object that represents the signature, including the resource URI and the - * shared access token. - * - * @throws StorageException - * If a storage service error occurred. - * @throws URISyntaxException - * If the resource URI is not properly formatted. - */ - @Override - public URI transformUri(final URI resourceUri, final OperationContext opContext) throws URISyntaxException, - StorageException { - return PathUtility.addToQuery(resourceUri, this.token); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java deleted file mode 100644 index 222cd22f87507..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * - * Represents error codes that may be returned by the Windows Azure storage services or the storage client library. - */ -public enum StorageErrorCode { - /** - * Access was denied (client-side error). - */ - ACCESS_DENIED(12), - - /** - * The specified account was not found (client-side error). - */ - ACCOUNT_NOT_FOUND(8), - - /** - * An authentication error occurred (client-side error). - */ - AUTHENTICATION_FAILURE(11), - - /** - * There was an error with the gateway used for the request (client-side error). - */ - BAD_GATEWAY(18), - - /** - * The request was incorrect or badly formed (client-side error). - */ - BAD_REQUEST(16), - - /** - * The specified blob already exists (client-side error). - */ - BLOB_ALREADY_EXISTS(15), - - /** - * The specified blob was not found (client-side error). - */ - BLOB_NOT_FOUND(10), - - /** - * The specified condition failed (client-side error). - */ - CONDITION_FAILED(17), - - /** - * The specified container already exists (client-side error). - */ - CONTAINER_ALREADY_EXISTS(14), - - /** - * The specified container was not found (client-side error). - */ - CONTAINER_NOT_FOUND(9), - - /** - * The request version header is not supported (client-side error). - */ - HTTP_VERSION_NOT_SUPPORTED(20), - - /** - * No error specified. - */ - NONE(0), - - /** - * The requested operation is not implemented on the specified resource (client-side error). - */ - NOT_IMPLEMENTED(19), - - /** - * The specified resource already exists (client-side error). - */ - RESOURCE_ALREADY_EXISTS(13), - - /** - * The specified resource was not found (client-side error). - */ - RESOURCE_NOT_FOUND(7), - - /** - * The service returned a bad response (server-side error). - */ - SERVICE_BAD_REQUEST(6), - - /** - * A service integrity check failed (server-side error). - */ - SERVICE_INTEGRITY_CHECK_FAILED(4), - - /** - * An internal server error occurred (server-side error). - */ - SERVICE_INTERNAL_ERROR(1), - - /** - * The service timed out (server-side error). - */ - SERVICE_TIMEOUT(3), - - /** - * A transport error occurred (server-side error). - */ - TRANSPORT_ERROR(5); - - /** - * Returns the value of this enum. - */ - public int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - StorageErrorCode(final int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java deleted file mode 100644 index feed66f4f8ef0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -/** - * Represents error code strings that are common to all storage services. - */ -public final class StorageErrorCodeStrings { - /** - * Authentication failed. - */ - public static final String AUTHENTICATION_FAILED = "AuthenticationFailed"; - - /** - * The specified condition was not met. - */ - public static final String CONDITION_NOT_MET = "ConditionNotMet"; - - /** - * The specified container already exists. - */ - public static final String CONTAINER_ALREADY_EXISTS = "ContainerAlreadyExists"; - - /** - * The specified queue already exists. - */ - public static final String QUEUE_ALREADY_EXISTS = "QueueAlreadyExists"; - - /** - * The specified container is being deleted. - */ - public static final String CONTAINER_BEING_DELETED = "ContainerBeingDeleted"; - - /** - * The specified queue is being deleted. - */ - public static final String QUEUE_BEING_DELETED = "QueueBeingDeleted"; - - /** - * The specified container is disabled. - */ - public static final String CONTAINER_DISABLED = "ContainerDisabled"; - - /** - * The specified container was not found. - */ - public static final String CONTAINER_NOT_FOUND = "ContainerNotFound"; - - /** - * An incorrect blob type was specified. - */ - public static final String INCORRECT_BLOB_TYPE = "IncorrectBlobType"; - - /** - * An incorrect blob type was specified. - */ - public static final String INVALID_BLOB_TYPE = "InvalidBlobType"; - - /** - * The metadata key is empty. - */ - public static final String EMPTY_METADATA_KEY = "EmptyMetadataKey"; - - /** - * An internal error occurred. - */ - public static final String INTERNAL_ERROR = "InternalError"; - - /** - * One or more header values are invalid. - */ - public static final String INVALID_HEADER_VALUE = "InvalidHeaderValue"; - - /** - * The HTTP verb is invalid. - */ - public static final String INVALID_HTTP_VERB = "InvalidHttpVerb"; - - /** - * The input is invalid. - */ - public static final String INVALID_INPUT = "InvalidInput"; - - /** - * The specified MD5 hash is invalid. - */ - public static final String INVALID_MD5 = "InvalidMd5"; - - /** - * The specified metadata is invalid. - */ - public static final String INVALID_METADATA = "InvalidMetadata"; - - /** - * One or more query parameters are invalid. - */ - public static final String INVALID_QUERY_PARAMETER_VALUE = "InvalidQueryParameterValue"; - - /** - * The specified range is invalid. - */ - public static final String INVALID_RANGE = "InvalidRange"; - - /** - * The URI is invalid. - */ - public static final String INVALID_URI = "InvalidUri"; - - /** - * The specified XML document is invalid. - */ - public static final String INVALID_XML_DOCUMENT = "InvalidXmlDocument"; - - /** - * One or more XML node values are invalid. - */ - public static final String INVALID_XML_NODE_VALUE = "InvalidXmlNodeValue"; - - /** - * The specified MD5 hash does not match the server value. - */ - public static final String MD5_MISMATCH = "Md5Mismatch"; - - /** - * The specified metadata is too large. - */ - public static final String METADATA_TOO_LARGE = "MetadataTooLarge"; - - /** - * The Content-Length header is required for this request. - */ - public static final String MISSING_CONTENT_LENGTH_HEADER = "MissingContentLengthHeader"; - - /** - * A required header was missing. - */ - public static final String MISSING_REQUIRED_HEADER = "MissingRequiredHeader"; - - /** - * A required query parameter is missing. - */ - public static final String MISSING_REQUIRED_QUERY_PARAMETER = "MissingRequiredQueryParameter"; - - /** - * A required XML node was missing. - */ - public static final String MISSING_REQUIRED_XML_NODE = "MissingRequiredXmlNode"; - - /** - * The operation timed out. - */ - public static final String OPERATION_TIMED_OUT = "OperationTimedOut"; - - /** - * The input is out of range. - */ - public static final String OUT_OF_RANGE_INPUT = "OutOfRangeInput"; - - /** - * One or more query parameters are out of range. - */ - public static final String OUT_OF_RANGE_QUERY_PARAMETER_VALUE = "OutOfRangeQueryParameterValue"; - - /** - * The request body is too large. - */ - public static final String REQUEST_BODY_TOO_LARGE = "RequestBodyTooLarge"; - - /** - * The specified resource was not found. - */ - public static final String RESOURCE_NOT_FOUND = "ResourceNotFound"; - - /** - * The server is busy. - */ - public static final String SERVER_BUSY = "ServerBusy"; - - /** - * One or more header values are not supported. - */ - public static final String UNSUPPORTED_HEADER = "UnsupportedHeader"; - - /** - * The specified HTTP verb is not supported. - */ - public static final String UNSUPPORTED_HTTP_VERB = "UnsupportedHttpVerb"; - - /** - * One or more query parameters is not supported. - */ - public static final String UNSUPPORTED_QUERY_PARAMETER = "UnsupportedQueryParameter"; - - /** - * One or more XML nodes are not supported. - */ - public static final String UNSUPPORTED_XML_NODE = "UnsupportedXmlNode"; - - /** - * The lease is already broken. - */ - public static final String LEASE_ALREADY_BROKEN = "LeaseAlreadyBroken"; - - /** - * The lease is already present. - */ - public static final String LEASE_ALREADY_PRESENT = "LeaseAlreadyPresent"; - - /** - * The lease ID is missing. - */ - public static final String LEASE_ID_MISSING = "LeaseIdMissing"; - - /** - * Private Default Ctor. - */ - private StorageErrorCodeStrings() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java deleted file mode 100644 index 12e0d0cbf2510..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.EventListener; - -/** - * - * Abstract class that represents a generic event listener. - * - * @param - * The type of the event to be received. - */ -public abstract class StorageEvent implements EventListener { - /** - * Represents an event that occurred. - * - * @param eventArg - * The event object. - */ - public abstract void eventOccurred(T eventArg); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java deleted file mode 100644 index f89c60ab651e7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.util.ArrayList; - -/** - * Represents a generic event multi-caster that allows event listeners to be dynamically added and removed. - * - * @param - * An object that represents the type of the event. - * @param - * An object that represents the type of the event listener. - */ -public final class StorageEventMultiCaster> { - - /** - * Holds the list of listeners. - */ - private final ArrayList listeners = new ArrayList(); - - /** - * Adds a listener to the event chain. - * - * @param listener - * An EventListenerType object that represents the listener to add. - */ - public synchronized void addListener(final EVENT_LISTENTER_TYPE listener) { - this.listeners.add(listener); - } - - /** - * Fires the event to all subscribed event listeners. - * - * @param event - * An EVENTTYPEobject that represents the event being multi-casted. - */ - public synchronized void fireEvent(final EVENT_TYPE event) { - for (final StorageEvent listener : this.listeners) { - listener.eventOccurred(event); - } - } - - /** - * Returns a value that indicates whether any event listeners are registered for events. - * - * @return true if any event listeners are registered; otherwise, false. - */ - public synchronized boolean hasListeners() { - return this.listeners.size() > 0; - } - - /** - * Removes an event listener from the event chain. - * - * @param listener - * An EventListenerType object that represents the listener to remove. - */ - public synchronized void removeListener(final EVENT_LISTENTER_TYPE listener) { - this.listeners.remove(listener); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java deleted file mode 100644 index 06d97fad7e720..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.io.IOException; -import java.net.HttpURLConnection; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse; - -/** - * Represents an exception for the Windows Azure storage service. - */ -public final class StorageException extends Exception { - - /** - * Represents the serialization version number. - */ - private static final long serialVersionUID = 7972747254288274928L; - - /** - * Returns extended error information from the specified request and operation context. - * - * @param request - * An HttpURLConnection object that represents the request whose extended error information - * is being retrieved. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link StorageExtendedErrorInformation} object that represents the error details for the specified - * request. - */ - protected static StorageExtendedErrorInformation getErrorDetailsFromRequest(final HttpURLConnection request, - final OperationContext opContext) { - if (request == null) { - return null; - } - try { - final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream()); - return response.getExtendedErrorInformation(); - } - catch (final XMLStreamException e) { - return null; - } - } - - /** - * Translates the specified exception into a storage exception. - * - * @param request - * An HttpURLConnection object that represents the request whose exception is being - * translated. - * @param cause - * An Exception object that represents the exception to translate. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A StorageException object that represents translated exception. - */ - public static StorageException translateException(final HttpURLConnection request, final Exception cause, - final OperationContext opContext) { - if (request == null) { - return new StorageException("Client error", - "A Client side exception occurred, please check the inner exception for details", - Constants.HeaderConstants.HTTP_UNUSED_306, null, cause); - } - - final StorageExtendedErrorInformation extendedError = getErrorDetailsFromRequest(request, opContext); - StorageException translatedException = null; - - String responseMessage = Constants.EMPTY_STRING; - int responseCode = 0; - try { - responseCode = request.getResponseCode(); - responseMessage = request.getResponseMessage(); - } - catch (final IOException e) { - // ignore errors - } - - if (responseMessage == null) { - responseMessage = Constants.EMPTY_STRING; - } - - // 1. If extended information is available use it - if (extendedError != null) { - translatedException = new StorageException(extendedError.getErrorCode(), responseMessage, responseCode, - extendedError, cause); - - if (translatedException != null) { - return translatedException; - } - } - - // 2. If extended information is unavailable, translate exception based - // on status code - translatedException = translateFromHttpStatus(responseCode, responseMessage, null, cause); - - if (translatedException != null) { - return translatedException; - } - - return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), - "The server encountered an unknown failure: ".concat(responseMessage), - HttpURLConnection.HTTP_INTERNAL_ERROR, null, cause); - } - - /** - * Translates the specified HTTP status code into a storage exception. - * - * @param statusCode - * The HTTP status code returned by the operation. - * @param statusDescription - * A String that represents the status description. - * @param details - * A {@link StorageExtendedErrorInformation} object that represents the errror details returned by the - * operation. - * @param inner - * An Exception object that represents a reference to the initial exception, if one exists. - * - * @return A StorageException object that represents translated exception. - **/ - protected static StorageException translateFromHttpStatus(final int statusCode, final String statusDescription, - final StorageExtendedErrorInformation details, final Exception inner) { - switch (statusCode) { - case HttpURLConnection.HTTP_FORBIDDEN: - return new StorageException(StorageErrorCode.ACCESS_DENIED.toString(), statusDescription, statusCode, - details, inner); - - case HttpURLConnection.HTTP_GONE: - case HttpURLConnection.HTTP_NOT_FOUND: - return new StorageException(StorageErrorCode.RESOURCE_NOT_FOUND.toString(), statusDescription, - statusCode, details, inner); - - case HttpURLConnection.HTTP_BAD_REQUEST: - return new StorageException(StorageErrorCode.BAD_REQUEST.toString(), statusDescription, statusCode, - details, inner); - - case HttpURLConnection.HTTP_PRECON_FAILED: - case HttpURLConnection.HTTP_NOT_MODIFIED: - return new StorageException(StorageErrorCode.CONDITION_FAILED.toString(), statusDescription, - statusCode, details, inner); - - case HttpURLConnection.HTTP_CONFLICT: - return new StorageException(StorageErrorCode.RESOURCE_ALREADY_EXISTS.toString(), statusDescription, - statusCode, details, inner); - - case HttpURLConnection.HTTP_GATEWAY_TIMEOUT: - return new StorageException(StorageErrorCode.SERVICE_TIMEOUT.toString(), statusDescription, statusCode, - details, inner); - - case 416: - // RequestedRangeNotSatisfiable - No corresponding enum in HttpURLConnection - return new StorageException(StorageErrorCode.BAD_REQUEST.toString(), statusDescription, statusCode, - details, inner); - - case HttpURLConnection.HTTP_INTERNAL_ERROR: - return new StorageException(StorageErrorCode.SERVICE_INTERNAL_ERROR.toString(), statusDescription, - statusCode, details, inner); - - case HttpURLConnection.HTTP_NOT_IMPLEMENTED: - return new StorageException(StorageErrorCode.NOT_IMPLEMENTED.toString(), statusDescription, statusCode, - details, inner); - - case HttpURLConnection.HTTP_BAD_GATEWAY: - return new StorageException(StorageErrorCode.BAD_GATEWAY.toString(), statusDescription, statusCode, - details, inner); - - case HttpURLConnection.HTTP_VERSION: - return new StorageException(StorageErrorCode.HTTP_VERSION_NOT_SUPPORTED.toString(), statusDescription, - statusCode, details, inner); - default: - return null; - } - } - - /** - * Represents the error code returned by the operation. - */ - private final String errorCode; - - /** - * Represents the extended error information returned by the operation. - * - * @see StorageExtendedErrorInformation - */ - private final StorageExtendedErrorInformation extendedErrorInformation; - - /** - * Represents the HTTP status code returned by the operation. - */ - private final int httpStatusCode; - - /** - * Creates an instance of the StorageException class using the specified parameters. - * - * @param errorCode - * A String that represents the error code returned by the operation. - * @param message - * A String that represents the error message returned by the operation. - * @param statusCode - * The HTTP status code returned by the operation. - * @param extendedErrorInfo - * A {@link StorageExtendedErrorInformation} object that represents the extended error information - * returned by the operation. - * @param innerException - * An Exception object that represents a reference to the initial exception, if one exists. - * - * @see StorageExtendedErrorInformation - */ - public StorageException(final String errorCode, final String message, final int statusCode, - final StorageExtendedErrorInformation extendedErrorInfo, final Exception innerException) { - super(message, innerException); - this.errorCode = errorCode; - this.httpStatusCode = statusCode; - this.extendedErrorInformation = extendedErrorInfo; - } - - /** - * @return the errorCode - */ - public String getErrorCode() { - return this.errorCode; - } - - /** - * @return the extendedErrorInformation - */ - public StorageExtendedErrorInformation getExtendedErrorInformation() { - return this.extendedErrorInformation; - } - - /** - * @return the httpStatusCode - */ - public int getHttpStatusCode() { - return this.httpStatusCode; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java deleted file mode 100644 index 4d4e65a8f3856..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.io.Serializable; -import java.util.HashMap; - -/** - * Represents extended error information returned by the Windows Azure storage service. - */ -public final class StorageExtendedErrorInformation implements Serializable { - /** - * The serialization version number. - */ - private static final long serialVersionUID = 1527013626991334677L; - - /** - * Represents additional error details, as a java.util.HashMap object. - */ - private HashMap additionalDetails; - - /** - * Represents the storage service error code. - */ - private String errorCode; - - /** - * Represents the storage service error message. - */ - private String errorMessage; - - /** - * Creates an instance of the StorageExtendedErrorInformation class. - */ - public StorageExtendedErrorInformation() { - this.setAdditionalDetails(new HashMap()); - } - - /** - * @return the additionalDetails - */ - public HashMap getAdditionalDetails() { - return this.additionalDetails; - } - - /** - * @return the errorCode - */ - public String getErrorCode() { - return this.errorCode; - } - - /** - * @return the errorMessage - */ - public String getErrorMessage() { - return this.errorMessage; - } - - /** - * @param additionalDetails - * the additionalDetails to set - */ - protected void setAdditionalDetails(final HashMap additionalDetails) { - this.additionalDetails = additionalDetails; - } - - /** - * @param errorCode - * the errorCode to set - */ - public void setErrorCode(final String errorCode) { - this.errorCode = errorCode; - } - - /** - * @param errorMessage - * the errorMessage to set - */ - public void setErrorMessage(final String errorMessage) { - this.errorMessage = errorMessage; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java deleted file mode 100644 index 0c1dd93068b39..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.Mac; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import com.microsoft.windowsazure.services.core.storage.utils.Base64; - -/** - * Represents a container for a storage key. - */ -public final class StorageKey { - /** - * Computes a signature for the specified string using the HMAC-SHA256 algorithm. - * - * @param storageKey - * A StorageKey object that represents the storage key to use. - * @param stringToSign - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA256-encoded signature. - * - * @throws IllegalArgumentException - * If the string to sign is not a valid Base64-encoded string. - * @throws InvalidKeyException - * If the key is not a valid storage key. - */ - public static synchronized String computeMacSha256(final StorageKey storageKey, final String stringToSign) - throws InvalidKeyException { - if (storageKey.hmacSha256 == null) { - storageKey.initHmacSha256(); - } - - byte[] utf8Bytes = null; - try { - utf8Bytes = stringToSign.getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { - throw new IllegalArgumentException(e); - } - - return Base64.encode(storageKey.hmacSha256.doFinal(utf8Bytes)); - } - - /** - * Computes a signature for the specified string using the HMAC-SHA512 algorithm. - * - * @param storageKey - * A StorageKey object that represents the storage key to use. - * @param stringToSign - * The UTF-8-encoded string to sign. - * - * @return A String that contains the HMAC-SHA512-encoded signature. - * - * @throws IllegalArgumentException - * If the string to sign is not a valid Base64-encoded string. - * @throws InvalidKeyException - * If the key is not a valid storage key. - */ - public static synchronized String computeMacSha512(final StorageKey storageKey, final String stringToSign) - throws InvalidKeyException { - if (storageKey.hmacSha512 == null) { - storageKey.initHmacSha512(); - } - - byte[] utf8Bytes = null; - try { - utf8Bytes = stringToSign.getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { - throw new IllegalArgumentException(e); - } - - return Base64.encode(storageKey.hmacSha512.doFinal(utf8Bytes)); - } - - /** - * Stores a reference to the hmacsha256 Mac. - */ - private Mac hmacSha256; - - /** - * Stores a reference to the hmacsha512 Mac. - */ - private Mac hmacSha512; - - /** - * Stores a reference to the hmacsha256 SecretKey. - */ - private SecretKey key256; - - /** - * Stores a reference to the hmacsha512 SecretKey. - */ - private SecretKey key512; - - /** - * Stores the key. - */ - private byte[] key; - - /** - * Creates an instance of the StorageKey class. - * - * @param key - * An array of bytes that represent the storage key. - */ - public StorageKey(final byte[] key) { - this.setKey(key); - } - - /** - * Returns the Base64-encoded key. - * - * @return A String that represents the Base64-encoded key. - */ - public String getBase64EncodedKey() { - return Base64.encode(this.key); - } - - /** - * Returns the key. - * - * @return A byte array that represents the key. - */ - public byte[] getKey() { - final byte[] copy = this.key.clone(); - return copy; - } - - /** - * Initializes the hmacsha256 Mac and SecretKey. - * - * @throws InvalidKeyException - * if the key is not a valid SecretKey according to spec. - */ - private void initHmacSha256() throws InvalidKeyException { - this.key256 = new SecretKeySpec(this.key, "HmacSHA256"); - try { - this.hmacSha256 = Mac.getInstance("HmacSHA256"); - } - catch (final NoSuchAlgorithmException e) { - throw new IllegalArgumentException(); - } - this.hmacSha256.init(this.key256); - } - - /** - * Initializes the hmacsha512 Mac and SecretKey. - * - * @throws InvalidKeyException - * if the key is not a valid SecretKey according to spec. - */ - private void initHmacSha512() throws InvalidKeyException { - this.key512 = new SecretKeySpec(this.key, "HmacSHA512"); - try { - this.hmacSha512 = Mac.getInstance("HmacSHA512"); - } - catch (final NoSuchAlgorithmException e) { - throw new IllegalArgumentException(); - } - this.hmacSha512.init(this.key512); - } - - /** - * Sets the key to be used, using the specified byte array as the key. - *

- * This method is provided to support key rotation. This method is not thread-safe. - * - * @param key - * A byte array that represents the key being assigned. - */ - public void setKey(final byte[] key) { - this.key = key; - this.hmacSha256 = null; - this.hmacSha512 = null; - this.key256 = null; - this.key512 = null; - } - - /** - * Sets the key to be used, using the specified String as the key. - *

- * This method is provided to support key rotation. This method is not thread-safe. - * - * @param key - * A String that represents the key being assigned. - * @throws IOException - * If the specified key is not a valid Base64-encoded string. - */ - public void setKey(final String key) throws IOException { - this.key = Base64.decode(key); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java deleted file mode 100644 index 672c390496fc2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils; - -/** - * RESERVED FOR INTERNAL USE. Provides Base64 encoding, decoding, and validation functionality. - */ -public final class Base64 { - /** - * The Base 64 Characters. - */ - private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - /** - * Decoded values, -1 is invalid character, -2 is = pad character. - */ - private static final byte DECODE_64[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0-15 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* - * 16- 31 - */ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* - * 32- 47 - */ - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, /* - * 48- 63 - */ - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 64-79 */ - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* - * 80- 95 - */ - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* - * 96- 111 - */ - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 /* - * 112- 127 - */ - }; - - /** - * Decodes a given Base64 string into its corresponding byte array. - * - * @param data - * the Base64 string, as a String object, to decode - * - * @return the corresponding decoded byte array - * @throws IllegalArgumentException - * If the string is not a valid base64 encoded string - */ - public static byte[] decode(final String data) { - int byteArrayLength = 3 * data.length() / 4; - - if (data.endsWith("==")) { - byteArrayLength -= 2; - } - else if (data.endsWith("=")) { - byteArrayLength -= 1; - } - - final byte[] retArray = new byte[byteArrayLength]; - int byteDex = 0; - int charDex = 0; - - for (; charDex < data.length(); charDex += 4) { - // get 4 chars, convert to 3 bytes - final int char1 = DECODE_64[(byte) data.charAt(charDex)]; - final int char2 = DECODE_64[(byte) data.charAt(charDex + 1)]; - final int char3 = DECODE_64[(byte) data.charAt(charDex + 2)]; - final int char4 = DECODE_64[(byte) data.charAt(charDex + 3)]; - - if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { - // invalid character(-1), or bad padding (-2) - throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); - } - - int tVal = char1 << 18; - tVal += char2 << 12; - tVal += (char3 & 0xff) << 6; - tVal += char4 & 0xff; - - if (char3 == -2) { - // two "==" pad chars, check bits 12-24 - tVal &= 0x00FFF000; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - } - else if (char4 == -2) { - // one pad char "=" , check bits 6-24. - tVal &= 0x00FFFFC0; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - - } - else { - // No pads take all 3 bytes, bits 0-24 - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - retArray[byteDex++] = (byte) (tVal & 0xFF); - } - } - return retArray; - } - - /** - * Decodes a given Base64 string into its corresponding byte array. - * - * @param data - * the Base64 string, as a String object, to decode - * - * @return the corresponding decoded byte array - * @throws IllegalArgumentException - * If the string is not a valid base64 encoded string - */ - public static Byte[] decodeAsByteObjectArray(final String data) { - int byteArrayLength = 3 * data.length() / 4; - - if (data.endsWith("==")) { - byteArrayLength -= 2; - } - else if (data.endsWith("=")) { - byteArrayLength -= 1; - } - - final Byte[] retArray = new Byte[byteArrayLength]; - int byteDex = 0; - int charDex = 0; - - for (; charDex < data.length(); charDex += 4) { - // get 4 chars, convert to 3 bytes - final int char1 = DECODE_64[(byte) data.charAt(charDex)]; - final int char2 = DECODE_64[(byte) data.charAt(charDex + 1)]; - final int char3 = DECODE_64[(byte) data.charAt(charDex + 2)]; - final int char4 = DECODE_64[(byte) data.charAt(charDex + 3)]; - - if (char1 < 0 || char2 < 0 || char3 == -1 || char4 == -1) { - // invalid character(-1), or bad padding (-2) - throw new IllegalArgumentException("The String is not a valid Base64-encoded string."); - } - - int tVal = char1 << 18; - tVal += char2 << 12; - tVal += (char3 & 0xff) << 6; - tVal += char4 & 0xff; - - if (char3 == -2) { - // two "==" pad chars, check bits 12-24 - tVal &= 0x00FFF000; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - } - else if (char4 == -2) { - // one pad char "=" , check bits 6-24. - tVal &= 0x00FFFFC0; - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - - } - else { - // No pads take all 3 bytes, bits 0-24 - retArray[byteDex++] = (byte) (tVal >> 16 & 0xFF); - retArray[byteDex++] = (byte) (tVal >> 8 & 0xFF); - retArray[byteDex++] = (byte) (tVal & 0xFF); - } - } - return retArray; - } - - /** - * Encodes a byte array as a Base64 string. - * - * @param data - * the byte array to encode - * @return the Base64-encoded string, as a String object - */ - public static String encode(final byte[] data) { - final StringBuilder builder = new StringBuilder(); - final int dataRemainder = data.length % 3; - - int j = 0; - int n = 0; - for (; j < data.length; j += 3) { - - if (j < data.length - dataRemainder) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); - } - else { - if (dataRemainder == 1) { - n = (data[j] & 0xFF) << 16; - } - else if (dataRemainder == 2) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); - } - } - - // Left here for readability - // byte char1 = (byte) ((n >>> 18) & 0x3F); - // byte char2 = (byte) ((n >>> 12) & 0x3F); - // byte char3 = (byte) ((n >>> 6) & 0x3F); - // byte char4 = (byte) (n & 0x3F); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); - } - - final int bLength = builder.length(); - - // append '=' to pad - if (data.length % 3 == 1) { - builder.replace(bLength - 2, bLength, "=="); - } - else if (data.length % 3 == 2) { - builder.replace(bLength - 1, bLength, "="); - } - - return builder.toString(); - } - - /** - * Encodes a byte array as a Base64 string. - * - * @param data - * the byte array to encode - * @return the Base64-encoded string, as a String object - */ - public static String encode(final Byte[] data) { - final StringBuilder builder = new StringBuilder(); - final int dataRemainder = data.length % 3; - - int j = 0; - int n = 0; - for (; j < data.length; j += 3) { - - if (j < data.length - dataRemainder) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8) + (data[j + 2] & 0xFF); - } - else { - if (dataRemainder == 1) { - n = (data[j] & 0xFF) << 16; - } - else if (dataRemainder == 2) { - n = ((data[j] & 0xFF) << 16) + ((data[j + 1] & 0xFF) << 8); - } - } - - // Left here for readability - // byte char1 = (byte) ((n >>> 18) & 0x3F); - // byte char2 = (byte) ((n >>> 12) & 0x3F); - // byte char3 = (byte) ((n >>> 6) & 0x3F); - // byte char4 = (byte) (n & 0x3F); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 18) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 12) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) ((n >>> 6) & 0x3F))); - builder.append(BASE_64_CHARS.charAt((byte) (n & 0x3F))); - } - - final int bLength = builder.length(); - - // append '=' to pad - if (data.length % 3 == 1) { - builder.replace(bLength - 2, bLength, "=="); - } - else if (data.length % 3 == 2) { - builder.replace(bLength - 1, bLength, "="); - } - - return builder.toString(); - } - - /** - * Determines whether the given string contains only Base64 characters. - * - * @param data - * the string, as a String object, to validate - * @return true if data is a valid Base64 string, otherwise false - */ - public static boolean validateIsBase64String(final String data) { - - if (data == null || data.length() % 4 != 0) { - return false; - } - - for (int m = 0; m < data.length(); m++) { - final byte charByte = (byte) data.charAt(m); - - // pad char detected - if (DECODE_64[charByte] == -2) { - if (m < data.length() - 2) { - return false; - } - else if (m == data.length() - 2 && DECODE_64[(byte) data.charAt(m + 1)] != -2) { - return false; - } - } - - if (charByte < 0 || DECODE_64[charByte] == -1) { - return false; - } - } - - return true; - } - - /** - * Private Default Ctor. - */ - private Base64() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java deleted file mode 100644 index 34cb97fc8a814..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ /dev/null @@ -1,463 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageCredentials; -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. A class to help modify paths - */ -public final class PathUtility { - /** - * Adds a queryString to an URI. - * - * @param resourceURI - * the URI of the resource - * @param fieldCollection - * the key/ values collection to append. - * @return an appended URI. - * @throws URISyntaxException - * if the resulting URI is invalid. - * @throws StorageException - */ - public static URI addToQuery(final URI resourceURI, final HashMap fieldCollection) - throws URISyntaxException, StorageException { - final UriQueryBuilder outUri = new UriQueryBuilder(); - - // Generate new queryString - for (final Entry entry : fieldCollection.entrySet()) { - for (final String val : entry.getValue()) { - outUri.add(entry.getKey(), val); - } - } - - return outUri.addToURI(resourceURI); - } - - /** - * Adds a queryString to an URI. - * - * @param resourceURI - * the URI of the resource - * @param queryString - * the query string to add - * @return an appended URI. - * @throws URISyntaxException - * if the resulting URI is invalid. - * @throws StorageException - */ - public static URI addToQuery(final URI resourceURI, final String queryString) throws URISyntaxException, - StorageException { - return addToQuery(resourceURI, parseQueryString(queryString)); - } - - /** - * Appends a path to a Uri correctly using "/" as separator. - * - * @param uri - * The base Uri. - * @param relativeOrAbslouteUri - * The relative or absloute URI. - * @return The appended Uri. - * @throws URISyntaxException - */ - public static URI appendPathToUri(final URI uri, final String relativeOrAbslouteUri) throws URISyntaxException { - return appendPathToUri(uri, relativeOrAbslouteUri, "/"); - } - - /** - * Appends a path to a Uri correctly using the given separator. - * - * @param uri - * The base Uri. - * @param relativeOrAbsoluteUri - * The relative or absloute URI. - * @param separator - * the separator to use. - * @return The appended Uri. - * @throws URISyntaxException - */ - public static URI appendPathToUri(final URI uri, final String relativeOrAbsoluteUri, final String separator) - throws URISyntaxException { - - int hostNameBeginIndex = -1; - if (relativeOrAbsoluteUri.length() > 8) { - final String header = relativeOrAbsoluteUri.substring(0, 8).toLowerCase(); - if ("https://".equals(header)) { - hostNameBeginIndex = 8; - } - else if ("http://".equals(header.substring(0, 7))) { - hostNameBeginIndex = 7; - } - } - - // absolute URI - if (hostNameBeginIndex > 0) { - final int authorityLength = relativeOrAbsoluteUri.substring(hostNameBeginIndex).indexOf(separator); - final String authorityName = relativeOrAbsoluteUri.substring(hostNameBeginIndex, hostNameBeginIndex - + authorityLength); - final URI absoluteUri = new URI(relativeOrAbsoluteUri); - - if (uri.getAuthority().equals(authorityName)) { - return absoluteUri; - } - else { - // Happens when using fiddler, DNS aliases, or potentially NATs - return new URI(uri.getScheme(), uri.getAuthority(), absoluteUri.getPath(), absoluteUri.getRawQuery(), - absoluteUri.getRawFragment()); - } - } - else { - // relative URI - // used by directory - if (uri.getPath().length() == 0 && relativeOrAbsoluteUri.startsWith(separator)) { - return new URI(uri.getScheme(), uri.getAuthority(), relativeOrAbsoluteUri, uri.getRawQuery(), - uri.getRawFragment()); - } - - final StringBuilder pathString = new StringBuilder(uri.getPath()); - - if (uri.getPath().endsWith(separator)) { - pathString.append(relativeOrAbsoluteUri); - } - else { - pathString.append(separator); - pathString.append(relativeOrAbsoluteUri); - } - - return new URI(uri.getScheme(), uri.getAuthority(), pathString.toString(), uri.getQuery(), - uri.getFragment()); - } - } - - /** - * Gets the blob name from the URI. - * - * @param inURI - * the resource address - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return the blobs name - * @throws URISyntaxException - */ - public static String getBlobNameFromURI(final URI inURI, final boolean usePathStyleUris) throws URISyntaxException { - return Utility.safeRelativize(new URI(getContainerURI(inURI, usePathStyleUris).toString().concat("/")), inURI); - } - - /** - * Gets the canonical path for an object from the credentials. - * - * @param credentials - * the credentials to use. - * @param absolutePath - * the Absolute path of the object. - * @return the canonical path for an object from the credentials - */ - public static String getCanonicalPathFromCredentials(final StorageCredentials credentials, final String absolutePath) { - final String account = credentials.getAccountName(); - - if (account == null) { - final String errorMessage = "Cannot create Shared Access Signature as the credentials does not have account name information. Please check that the credentials used support creating Shared Access Signature."; - throw new IllegalArgumentException(errorMessage); - } - final StringBuilder builder = new StringBuilder("/"); - builder.append(account); - builder.append(absolutePath); - return builder.toString(); - } - - /** - * Get the container name from address from the URI. - * - * @param resourceAddress - * The container Uri. - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return container name from address from the URI. - * @throws IllegalArgumentException - */ - public static String getContainerNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { - return getContainerOrQueueNameFromUri(resourceAddress, usePathStyleUris, - String.format("Invalid blob address '%s', missing container information", resourceAddress)); - } - - /** - * Get the container or queue name from address from the URI. - * - * @param resourceAddress - * The queue Uri. - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return container name from address from the URI. - * @throws IllegalArgumentException - */ - private static String getContainerOrQueueNameFromUri(final URI resourceAddress, final boolean usePathStyleUris, - final String error) { - Utility.assertNotNull("resourceAddress", resourceAddress); - - final String[] pathSegments = resourceAddress.getRawPath().split("/"); - - final int expectedPartsLength = usePathStyleUris ? 3 : 2; - - if (pathSegments.length < expectedPartsLength) { - throw new IllegalArgumentException(error); - } - - final String containerOrQueueName = usePathStyleUris ? pathSegments[2] : pathSegments[1]; - - return Utility.trimEnd(containerOrQueueName, '/'); - } - - /** - * Gets the container URI from a blob address - * - * @param blobAddress - * the blob address - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return the container URI from a blob address - * @throws URISyntaxException - */ - public static URI getContainerURI(final URI blobAddress, final boolean usePathStyleUris) throws URISyntaxException { - final String containerName = getContainerNameFromUri(blobAddress, usePathStyleUris); - - final URI containerUri = appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), - containerName); - return containerUri; - } - - /** - * Retrieves the parent address for a blob Uri. - * - * @param blobAddress - * The blob address - * @param delimiter - * The delimiter. - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return The address of the parent. - * @throws URISyntaxException - * @throws StorageException - */ - public static URI getParentAddress(final URI blobAddress, final String delimiter, final boolean usePathStyleUris) - throws URISyntaxException, StorageException { - final String parentName = getParentNameFromURI(blobAddress, delimiter, usePathStyleUris); - - final URI parentUri = appendPathToUri(new URI(getServiceClientBaseAddress(blobAddress, usePathStyleUris)), - parentName); - return parentUri; - } - - /** - * Retrieves the parent name for a blob Uri. - * - * @param resourceAddress - * The resource Uri. - * @param delimiter - * the directory delimiter to use - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return the parent address for a blob Uri. - * @throws URISyntaxException - * @throws StorageException - */ - public static String getParentNameFromURI(final URI resourceAddress, final String delimiter, - final boolean usePathStyleUris) throws URISyntaxException, StorageException { - Utility.assertNotNull("resourceAddress", resourceAddress); - Utility.assertNotNullOrEmpty("delimiter", delimiter); - - final String containerName = getContainerNameFromUri(resourceAddress, usePathStyleUris); - - /* - * URI baseURI = appendPathToUri( new URI(getServiceClientBaseAddress(resourceAddress, usePathStyleUris)), - * containerName); - */ - URI baseURI = new URI(getServiceClientBaseAddress(resourceAddress, usePathStyleUris)); - if (usePathStyleUris && !baseURI.getRawPath().endsWith("/")) { - baseURI = new URI(baseURI.getScheme(), baseURI.getRawAuthority(), baseURI.getRawPath().concat("/"), null, - null); - } - - final URI relativeURI = new URI(Utility.safeRelativize(baseURI, resourceAddress)); - - String relativeURIString = relativeURI.toString(); - - if (relativeURIString.endsWith(delimiter)) { - relativeURIString = relativeURIString.substring(0, relativeURIString.length() - delimiter.length()); - } - - String parentName = Constants.EMPTY_STRING; - - if (Utility.isNullOrEmpty(relativeURIString)) { - // Case 1 /[Delimiter]*? => / - // Parent of container is container itself - parentName = containerName.concat(delimiter); - } - else { - final int lastDelimiterDex = relativeURIString.lastIndexOf(delimiter); - - if (lastDelimiterDex <= 0) { - // Case 2 // - // Parent of a folder is container - parentName = containerName.concat(delimiter); - } - else { - // Case 3 ///[/]* - // Parent of blob is folder - parentName = relativeURIString.substring(0, lastDelimiterDex + delimiter.length()); - } - } - - return parentName; - } - - /** - * Get the queue name from address from the URI. - * - * @param resourceAddress - * The queue Uri. - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return container name from address from the URI. - * @throws IllegalArgumentException - */ - public static String getQueueNameFromUri(final URI resourceAddress, final boolean usePathStyleUris) { - return getContainerOrQueueNameFromUri(resourceAddress, usePathStyleUris, - String.format("Invalid queue URI '%s'.", resourceAddress)); - } - - /** - * Get the service client address from a complete Uri. - * - * @param address - * Complete address of the resource. - * @param usePathStyleUris - * a value indicating if the address is a path style uri. - * @return the service client address from a complete Uri. - * @throws URISyntaxException - */ - public static String getServiceClientBaseAddress(final URI address, final boolean usePathStyleUris) - throws URISyntaxException { - if (usePathStyleUris) { - final String[] pathSegments = address.getRawPath().split("/"); - - if (pathSegments.length < 2) { - final String error = String - .format("Missing account name information inside path style uri. Path style uris should be of the form http:///"); - throw new IllegalArgumentException(error); - } - - final StringBuilder completeAddress = new StringBuilder(new URI(address.getScheme(), - address.getAuthority(), null, null, null).toString()); - completeAddress.append("/"); - completeAddress.append(Utility.trimEnd(pathSegments[1], '/')); - - return completeAddress.toString(); - } - else { - return new URI(address.getScheme(), address.getAuthority(), null, null, null).toString(); - } - } - - /** - * Parses a query string into a one to many hashmap. - * - * @param parseString - * the string to parse - * @return a HashMap of the key values. - * @throws StorageException - */ - public static HashMap parseQueryString(String parseString) throws StorageException { - final HashMap retVals = new HashMap(); - if (Utility.isNullOrEmpty(parseString)) { - return retVals; - } - - // 1. Remove ? if present - final int queryDex = parseString.indexOf("?"); - if (queryDex >= 0 && parseString.length() > 0) { - parseString = parseString.substring(queryDex + 1); - } - - // 2. split name value pairs by splitting on the 'c&' character - final String[] valuePairs = parseString.contains("&") ? parseString.split("&") : parseString.split(";"); - - // 3. for each field value pair parse into appropriate map entries - for (int m = 0; m < valuePairs.length; m++) { - final int equalDex = valuePairs[m].indexOf("="); - - if (equalDex < 0 || equalDex == valuePairs[m].length() - 1) { - continue; - } - - String key = valuePairs[m].substring(0, equalDex); - String value = valuePairs[m].substring(equalDex + 1); - - key = Utility.safeDecode(key); - value = Utility.safeDecode(value); - - // 3.1 add to map - String[] values = retVals.get(key); - - if (values == null) { - values = new String[] { value }; - if (!value.equals(Constants.EMPTY_STRING)) { - retVals.put(key, values); - } - } - else if (!value.equals(Constants.EMPTY_STRING)) { - final String[] newValues = new String[values.length + 1]; - for (int j = 0; j < values.length; j++) { - newValues[j] = values[j]; - } - - newValues[newValues.length] = value; - } - } - - return retVals; - } - - /** - * Strips the Query and Fragment from the uri. - * - * @param inUri - * the uri to alter - * @return the stripped uri. - * @throws StorageException - */ - public static URI stripURIQueryAndFragment(final URI inUri) throws StorageException { - try { - return new URI(inUri.getScheme(), inUri.getAuthority(), inUri.getPath(), null, null); - } - catch (final URISyntaxException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * Private Default Ctor. - */ - private PathUtility() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java deleted file mode 100644 index dd3c2d2b0bfd1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils; - -/** - * RESERVED FOR INTERNAL USE. Represents a stream descriptor that contains the stream size and MD5 hash. - */ -public final class StreamMd5AndLength { - /** - * Contains the MD5 hash for the stream data. - */ - private String streamMd5; - - /** - * Contains the length, in bytes, for the stream. - */ - private long streamLength; - - /** - * @return the length - */ - public long getLength() { - return this.streamLength; - } - - /** - * @return the md5 - */ - public String getMd5() { - return this.streamMd5; - } - - /** - * @param length - * the length to set - */ - public void setLength(final long length) { - this.streamLength = length; - } - - /** - * @param md5 - * the md5 to set - */ - public void setMd5(final String md5) { - this.streamMd5 = md5; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java deleted file mode 100644 index 0459c94d7b496..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. A helper class to help modify the query string of a URI - */ -public final class UriQueryBuilder { - /** - * Stores the one to one key/ value collection of query parameters. - */ - private final HashMap> parameters = new HashMap>(); - - /** - * Adds a value to the URI with escaping. - * - * @param name - * the query key name. - * @param value - * the query value. - * @throws StorageException - */ - public void add(final String name, final String value) throws StorageException { - if (Utility.isNullOrEmpty(name)) { - throw new IllegalArgumentException("Cannot encode a query parameter with a null or empty key"); - } - - this.insertKeyValue(name, value); - } - - /** - * Add query parameter to an existing Uri. This takes care of any existing query parameters in the Uri. - * - * @param uri - * the original uri. - * @return the appended uri - * @throws URISyntaxException - * if the resulting uri is invalid. - * @throws StorageException - */ - public URI addToURI(final URI uri) throws URISyntaxException, StorageException { - final String origRawQuery = uri.getRawQuery(); - final String rawFragment = uri.getRawFragment(); - final String uriString = uri.resolve(uri).toASCIIString(); - - final HashMap origQueryMap = PathUtility.parseQueryString(origRawQuery); - - // Try/Insert original queries to map - - for (final Entry entry : origQueryMap.entrySet()) { - for (final String val : entry.getValue()) { - this.insertKeyValue(entry.getKey(), val); - } - } - - final StringBuilder retBuilder = new StringBuilder(); - - // has a fragment - if (Utility.isNullOrEmpty(origRawQuery) && !Utility.isNullOrEmpty(rawFragment)) { - final int bangDex = uriString.indexOf('#'); - retBuilder.append(uriString.substring(0, bangDex)); - } - else if (!Utility.isNullOrEmpty(origRawQuery)) { - // has a query - final int queryDex = uriString.indexOf('?'); - retBuilder.append(uriString.substring(0, queryDex)); - } - else { - // no fragment or query - retBuilder.append(uriString); - if (uri.getRawPath().length() <= 0) { - retBuilder.append("/"); - } - } - - final String finalQuery = this.toString(); - - if (finalQuery.length() > 0) { - retBuilder.append("?"); - retBuilder.append(finalQuery); - } - - if (!Utility.isNullOrEmpty(rawFragment)) { - retBuilder.append("#"); - retBuilder.append(rawFragment); - } - - return new URI(retBuilder.toString()); - } - - /** - * Inserts a key / value in the Hashmap, assumes the value is already utf-8 encoded. - * - * @param key - * the key to insert - * @param value - * the value to insert - * @throws StorageException - */ - private void insertKeyValue(String key, String value) throws StorageException { - if (value != null) { - value = Utility.safeEncode(value); - } - if (!key.startsWith("$")) { - key = Utility.safeEncode(key); - } - - ArrayList list = this.parameters.get(key); - if (list == null) { - list = new ArrayList(); - list.add(value); - this.parameters.put(key, list); - } - else { - if (!list.contains(value)) { - list.add(value); - } - } - } - - /** - * Returns a string that represents this instance. This will construct the full URI. - * - * @return a string that represents this instance. - */ - @Override - public String toString() { - final StringBuilder outString = new StringBuilder(); - Boolean isFirstPair = true; - - for (final String key : this.parameters.keySet()) { - if (this.parameters.get(key) != null) { - for (final String val : this.parameters.get(key)) { - if (isFirstPair) { - isFirstPair = false; - } - else { - outString.append("&"); - } - - outString.append(String.format("%s=%s", key, val)); - } - } - } - - return outString.toString(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java deleted file mode 100644 index 169ff1ebfaeaa..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ /dev/null @@ -1,970 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.TimeZone; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RequestResult; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; -import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; -import com.microsoft.windowsazure.services.core.storage.StorageCredentials; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAccountAndKey; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsAnonymous; -import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCode; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse; - -/** - * RESERVED FOR INTERNAL USE. A class which provides utility methods. - */ -public final class Utility { - /** - * Stores a reference to the GMT time zone. - */ - public static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT"); - - /** - * Stores a reference to the UTC time zone. - */ - public static final TimeZone UTC_ZONE = TimeZone.getTimeZone("UTC"); - - /** - * Stores a reference to the US locale. - */ - public static final Locale LOCALE_US = Locale.US; - - /** - * Stores a reference to the RFC1123 date/time pattern. - */ - private static final String RFC1123_PATTERN = "EEE, dd MMM yyyy HH:mm:ss z"; - - /** - * Stores a reference to the ISO8061 date/time pattern. - */ - public static final String ISO8061_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - - /** - * Stores a reference to the ISO8061_LONG date/time pattern. - */ - public static final String ISO8061_LONG_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; - - /** - * - * Determines the size of an input stream, and optionally calculates the MD5 hash for the stream. - * - * @param sourceStream - * A InputStream object that represents the stream to measure. - * @param writeLength - * The number of bytes to read from the stream. - * @param abandonLength - * The number of bytes to read before the analysis is abandoned. Set this value to -1 to - * force the entire stream to be read. This parameter is provided to support upload thresholds. - * @param rewindSourceStream - * true if the stream should be rewound after it is read; otherwise, false. - * @param calculateMD5 - * true if an MD5 hash will be calculated; otherwise, false. - * - * @return A {@link StreamMd5AndLength} object that contains the stream length, and optionally the MD5 hash. - * - * @throws IOException - * If an I/O error occurs. - * @throws StorageException - * If a storage service error occurred. - */ - public static StreamMd5AndLength analyzeStream(final InputStream sourceStream, long writeLength, long abandonLength, - final boolean rewindSourceStream, final boolean calculateMD5) throws IOException, StorageException { - if (abandonLength < 0) { - abandonLength = Long.MAX_VALUE; - } - - if (rewindSourceStream) { - if (!sourceStream.markSupported()) { - throw new IllegalArgumentException("Input stream must be markable!"); - } - sourceStream.mark(Integer.MAX_VALUE); - } - - MessageDigest digest = null; - if (calculateMD5) { - try { - digest = MessageDigest.getInstance("MD5"); - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - if (writeLength < 0) { - writeLength = Long.MAX_VALUE; - } - - final StreamMd5AndLength retVal = new StreamMd5AndLength(); - int count = -1; - final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; - - int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); - count = sourceStream.read(retrievedBuff, 0, nextCopy); - - while (nextCopy > 0 && count != -1) { - if (calculateMD5) { - digest.update(retrievedBuff, 0, count); - } - retVal.setLength(retVal.getLength() + count); - - if (retVal.getLength() > abandonLength) { - // Abandon operation - retVal.setLength(-1); - retVal.setMd5(null); - break; - } - - nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); - count = sourceStream.read(retrievedBuff, 0, nextCopy); - } - - if (retVal.getLength() != -1 && calculateMD5) { - retVal.setMd5(Base64.encode(digest.digest())); - } - - if (retVal.getLength() != -1 && writeLength > 0) { - retVal.setLength(Math.min(retVal.getLength(), writeLength)); - } - - if (rewindSourceStream) { - sourceStream.reset(); - sourceStream.mark(Integer.MAX_VALUE); - } - - return retVal; - } - - /** - * Returns a value that indicates whether the specified credentials are equal. - * - * @param thisCred - * An object derived from {@link StorageCredentials} that represents the first set of credentials being - * compared for equality. - * @param thatCred - * An object derived from StorageCredentials that represents the second set of credentials - * being compared for equality. - * - * @return true if the credentials are equal; otherwise, false. - */ - public static boolean areCredentialsEqual(final StorageCredentials thisCred, final StorageCredentials thatCred) { - if (thisCred == thatCred) { - return true; - } - - if (thatCred == null || thisCred.getClass() != thatCred.getClass()) { - return false; - } - - if (thisCred instanceof StorageCredentialsAccountAndKey) { - return ((StorageCredentialsAccountAndKey) thisCred).toString(true).equals( - ((StorageCredentialsAccountAndKey) thatCred).toString(true)); - } - else if (thisCred instanceof StorageCredentialsSharedAccessSignature) { - return ((StorageCredentialsSharedAccessSignature) thisCred).getToken().equals( - ((StorageCredentialsSharedAccessSignature) thatCred).getToken()); - } - else if (thisCred instanceof StorageCredentialsAnonymous) { - return true; - } - - return thisCred.equals(thatCred); - } - - /** - * Asserts a continuation token is of the specified type. - * - * @param continuationToken - * A {@link ResultContinuation} object that represents the continuation token whose type is being - * examined. - * @param continuationType - * A {@link ResultContinuationType} value that represents the continuation token type being asserted with - * the specified continuation token. - */ - public static void assertContinuationType(final ResultContinuation continuationToken, - final ResultContinuationType continuationType) { - if (continuationToken != null) { - if (!(continuationToken.getContinuationType() == ResultContinuationType.NONE || continuationToken - .getContinuationType() == continuationType)) { - final String errorMessage = String - .format(Utility.LOCALE_US, - "The continuation type passed in is unexpected. Please verify that the correct continuation type is passed in. Expected {%s}, found {%s}", - continuationToken.getContinuationType(), continuationType); - throw new IllegalArgumentException(errorMessage); - } - } - } - - /** - * Asserts that a value is not null. - * - * @param param - * A String that represents the name of the parameter, which becomes the exception message - * text if the value parameter is null. - * @param value - * An Object object that represents the value of the specified parameter. This is the value - * being asserted as not null. - */ - public static void assertNotNull(final String param, final Object value) { - if (value == null) { - throw new IllegalArgumentException(param); - } - } - - /** - * Asserts that the specified string is not null or empty. - * - * @param param - * A String that represents the name of the parameter, which becomes the exception message - * text if the value parameter is null or an empty string. - * @param value - * A String that represents the value of the specified parameter. This is the value being - * asserted as not null and not an empty string. - */ - public static void assertNotNullOrEmpty(final String param, final String value) { - assertNotNull(param, value); - - if (Utility.isNullOrEmpty(value)) { - throw new IllegalArgumentException("The argument must not be an empty string or null:".concat(param)); - } - } - - /** - * Asserts that the specified integer is in the valid range. - * - * @param param - * A String that represents the name of the parameter, which becomes the exception message - * text if the value parameter is out of bounds. - * @param value - * The value of the specified parameter. - * @param min - * The minimum value for the specified parameter. - * @param max - * The maximum value for the specified parameter. - */ - public static void assertInBounds(final String param, final int value, final int min, final int max) { - if (value < min || value > max) { - throw new IllegalArgumentException(String.format( - "The value of the parameter %s should be between %s and %s.", param, min, max)); - } - } - - /** - * Creates an XML stream reader from the specified input stream. - * - * @param streamRef - * An InputStream object that represents the input stream to use as the source. - * - * @return A java.xml.stream.XMLStreamReader object that represents the XML stream reader created from - * the specified input stream. - * - * @throws XMLStreamException - * If the XML stream reader could not be created. - */ - public static XMLStreamReader createXMLStreamReaderFromStream(final InputStream streamRef) - throws XMLStreamException { - XMLInputFactory xmlif = null; - - xmlif = XMLInputFactory.newInstance(); - xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.TRUE); - xmlif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE); - // set the IS_COALESCING property to true , if application desires to - // get whole text data as one event. - xmlif.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); - - return xmlif.createXMLStreamReader(streamRef); - } - - /** - * Returns a value that indicates whether a specified URI is a path-style URI. - * - * @param baseURI - * A java.net.URI value that represents the URI being checked. - * @param knownAccountName - * A String that represents the known account name to examine with baseURI, or - * null to examine baseURI on its own for being a path-style URI. - * - * @return true if the specified URI is path-style; otherwise, false. - */ - public static boolean determinePathStyleFromUri(final URI baseURI, final String knownAccountName) { - if (knownAccountName == null) { - return !Utility.isNullOrEmpty(baseURI.getPath()); - } - - String path = baseURI.getPath(); - if (!Utility.isNullOrEmpty(path) && path.startsWith("/")) { - path = path.substring(1); - } - - if (Utility.isNullOrEmpty(path) || baseURI.getHost().startsWith(knownAccountName)) { - return false; - } - else if (!Utility.isNullOrEmpty(path) && path.startsWith(knownAccountName)) { - return true; - } - - return false; - } - - /** - * Returns an unexpected storage exception. - * - * @param cause - * An Exception object that represents the initial exception that caused the unexpected - * error. - * - * @return A {@link StorageException} object that represents the unexpected storage exception being thrown. - */ - public static StorageException generateNewUnexpectedStorageException(final Exception cause) { - final StorageException exceptionRef = new StorageException(StorageErrorCode.NONE.toString(), - "Unexpected internal storage client error.", 306, // unused - null, null); - exceptionRef.initCause(cause); - return exceptionRef; - } - - /** - * Returns a byte array that represents the data of a long value. - * - * @param value - * The value from which the byte array will be returned. - * - * @return A byte array that represents the data of the specified long value. - */ - public static byte[] getBytesFromLong(final long value) { - final byte[] tempArray = new byte[8]; - - for (int m = 0; m < 8; m++) { - tempArray[7 - m] = (byte) ((value >> (8 * m)) & 0xFF); - } - - return tempArray; - } - - /** - * Returns extended error information from the specified request. - * - * @param request - * An HttpURLConnection object that represents the request. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link StorageExtendedErrorInformation} object that represents the extended error information from the - * request. - */ - protected static StorageExtendedErrorInformation getErrorDetailsFromRequest(final HttpURLConnection request, - final OperationContext opContext) { - if (request == null) { - return null; - } - try { - final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream()); - return response.getExtendedErrorInformation(); - } - catch (final XMLStreamException e) { - return null; - } - } - - /** - * Returns the current GMT date/time using the RFC1123 pattern. - * - * @return A String that represents the current GMT date/time using the RFC1123 pattern. - */ - public static String getGMTTime() { - final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); - rfc1123Format.setTimeZone(GMT_ZONE); - return rfc1123Format.format(new Date()); - } - - /** - * Returns the GTM date/time for the specified value using the RFC1123 pattern. - * - * @param inDate - * A Date object that represents the date to convert to GMT date/time in the RFC1123 - * pattern. - * - * @return A String that represents the GMT date/time for the specified value using the RFC1123 - * pattern. - */ - public static String getGMTTime(final Date inDate) { - final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); - rfc1123Format.setTimeZone(GMT_ZONE); - return rfc1123Format.format(inDate); - } - - /** - * Returns the standard header value from the specified connection request, or an empty string if no header value - * has been specified for the request. - * - * @param conn - * An HttpURLConnection object that represents the request. - * @param headerName - * A String that represents the name of the header being requested. - * - * @return A String that represents the header value, or null if there is no corresponding - * header value for headerName. - */ - public static String getStandardHeaderValue(final HttpURLConnection conn, final String headerName) { - final String headerValue = conn.getRequestProperty(headerName); - - // Coalesce null value - return headerValue == null ? Constants.EMPTY_STRING : headerValue; - } - - /** - * Returns the current UTC date/time using the RFC1123 pattern. - * - * @return A String that represents the current UTC date/time using the RFC1123 pattern. - */ - protected static String getUTCTime() { - final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); - rfc1123Format.setTimeZone(UTC_ZONE); - return rfc1123Format.format(new Date()); - } - - /** - * Returns the UTC date/time for the specified value using the RFC1123 pattern. - * - * @param inDate - * A Date object that represents the date to convert to UTC date/time in the RFC1123 - * pattern. - * - * @return A String that represents the UTC date/time for the specified value using the RFC1123 - * pattern. - */ - protected static String getUTCTime(final Date inDate) { - final DateFormat rfc1123Format = new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US); - rfc1123Format.setTimeZone(UTC_ZONE); - return rfc1123Format.format(inDate); - } - - /** - * Returns the UTC date/time for the specified value using the ISO8061 pattern. - * - * @param value - * A Date object that represents the date to convert to UTC date/time in the ISO8061 - * pattern. If this value is null, this method returns an empty string. - * - * @return A String that represents the UTC date/time for the specified value using the ISO8061 - * pattern, or an empty string if value is null. - */ - public static String getUTCTimeOrEmpty(final Date value) { - if (value == null) { - return Constants.EMPTY_STRING; - } - - final DateFormat iso8061Format = new SimpleDateFormat(ISO8061_PATTERN, LOCALE_US); - iso8061Format.setTimeZone(UTC_ZONE); - - return iso8061Format.format(value); - } - - /** - * Creates an instance of the IOException class using the specified exception. - * - * @param ex - * An Exception object that represents the exception used to create the IO exception. - * - * @return A java.io.IOException object that represents the created IO exception. - */ - public static IOException initIOException(final Exception ex) { - final IOException retEx = new IOException(); - retEx.initCause(ex); - return retEx; - } - - /** - * Returns a value that indicates whether the specified string is null or empty. - * - * @param value - * A String being examined for null or empty. - * - * @return true if the specified value is null or empty; otherwise, false - */ - public static boolean isNullOrEmpty(final String value) { - return value == null || value.length() == 0; - } - - /** - * Parses a connection string and returns its values as a hash map of key/value pairs. - * - * @param parseString - * A String that represents the connection string to parse. - * - * @return A java.util.HashMap object that represents the hash map of the key / value pairs parsed from - * the connection string. - */ - public static HashMap parseAccountString(final String parseString) { - - // 1. split name value pairs by splitting on the ';' character - final String[] valuePairs = parseString.split(";"); - final HashMap retVals = new HashMap(); - - // 2. for each field value pair parse into appropriate map entries - for (int m = 0; m < valuePairs.length; m++) { - final int equalDex = valuePairs[m].indexOf("="); - if (equalDex < 1) { - throw new IllegalArgumentException("Invalid Connection String"); - } - - final String key = valuePairs[m].substring(0, equalDex); - final String value = valuePairs[m].substring(equalDex + 1); - - // 2.1 add to map - retVals.put(key, value); - } - - return retVals; - } - - /** - * Returns a GMT date in the specified format - * - * @param value - * the string to parse - * @return the GMT date, as a Date - * @throws ParseException - * If the specified string is invalid - */ - public static Date parseDateFromString(final String value, final String pattern, final TimeZone timeZone) - throws ParseException { - final DateFormat rfc1123Format = new SimpleDateFormat(pattern, Utility.LOCALE_US); - rfc1123Format.setTimeZone(timeZone); - return rfc1123Format.parse(value); - } - - /** - * Returns a date in the ISO8061 long pattern for the specified string. - * - * @param value - * A String that represents the string to parse. - * - * @return A Date object that represents the date in the ISO8061 long pattern. - * - * @throws ParseException - * If the specified string is invalid. - */ - public static Date parseISO8061LongDateFromString(final String value) throws ParseException { - return parseDateFromString(value, ISO8061_LONG_PATTERN, Utility.UTC_ZONE); - } - - /** - * Returns a GMT date in the RFC1123 pattern for the specified string. - * - * @param value - * A String that represents the string to parse. - * - * @return A Date object that represents the GMT date in the RFC1123 pattern. - * - * @throws ParseException - * If the specified string is invalid. - */ - public static Date parseRFC1123DateFromStringInGMT(final String value) throws ParseException { - return parseDateFromString(value, RFC1123_PATTERN, Utility.GMT_ZONE); - } - - /** - * Reads character data for the specified XML element from an XML stream reader. This method will read start events, - * characters, and end events from a stream. - * - * @param xmlr - * An XMLStreamReader object that represents the source XML stream reader. - * - * @param elementName - * A String that represents XML element name. - * - * @return A String that represents the character data for the specified element. - * - * @throws XMLStreamException - * If an XML stream failure occurs. - */ - public static String readElementFromXMLReader(final XMLStreamReader xmlr, final String elementName) - throws XMLStreamException { - xmlr.require(XMLStreamConstants.START_ELEMENT, null, elementName); - int eventType = xmlr.next(); - final StringBuilder retVal = new StringBuilder(); - - if (eventType == XMLStreamConstants.CHARACTERS) { - // This do while is in case the XMLStreamReader does not have - // the IS_COALESCING property set - // to true which may result in text being read in multiple events - // If we ensure all xmlreaders have this property we can optimize - // the StringBuilder and while loop - // away - do { - retVal.append(xmlr.getText()); - eventType = xmlr.next(); - - } while (eventType == XMLStreamConstants.CHARACTERS); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, elementName); - return retVal.length() == 0 ? null : retVal.toString(); - } - - /** - * Performs safe decoding of the specified string, taking care to preserve each + character, rather - * than replacing it with a space character. - * - * @param stringToDecode - * A String that represents the string to decode. - * - * @return A String that represents the decoded string. - * - * @throws StorageException - * If a storage service error occurred. - */ - public static String safeDecode(final String stringToDecode) throws StorageException { - if (stringToDecode == null) { - return null; - } - - if (stringToDecode.length() == 0) { - return Constants.EMPTY_STRING; - } - - try { - if (stringToDecode.contains("+")) { - final StringBuilder outBuilder = new StringBuilder(); - - int startDex = 0; - for (int m = 0; m < stringToDecode.length(); m++) { - if (stringToDecode.charAt(m) == '+') { - if (m > startDex) { - outBuilder.append(URLDecoder.decode(stringToDecode.substring(startDex, m), "UTF-8")); - } - - outBuilder.append("+"); - startDex = m + 1; - } - } - - if (startDex != stringToDecode.length()) { - outBuilder.append(URLDecoder.decode(stringToDecode.substring(startDex, stringToDecode.length()), - "UTF-8")); - } - - return outBuilder.toString(); - } - else { - return URLDecoder.decode(stringToDecode, "UTF-8"); - } - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * Performs safe encoding of the specified string, taking care to insert %20 for each space character, - * instead of inserting the + character. - * - * @param stringToEncode - * A String that represents the string to encode. - * - * @return A String that represents the encoded string. - * - * @throws StorageException - * If a storage service error occurred. - */ - public static String safeEncode(final String stringToEncode) throws StorageException { - if (stringToEncode == null) { - return null; - } - if (stringToEncode.length() == 0) { - return Constants.EMPTY_STRING; - } - - try { - final String tString = URLEncoder.encode(stringToEncode, "UTF-8"); - - if (stringToEncode.contains(" ")) { - final StringBuilder outBuilder = new StringBuilder(); - - int startDex = 0; - for (int m = 0; m < stringToEncode.length(); m++) { - if (stringToEncode.charAt(m) == ' ') { - if (m > startDex) { - outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, m), "UTF-8")); - } - - outBuilder.append("%20"); - startDex = m + 1; - } - } - - if (startDex != stringToEncode.length()) { - outBuilder.append(URLEncoder.encode(stringToEncode.substring(startDex, stringToEncode.length()), - "UTF-8")); - } - - return outBuilder.toString(); - } - else { - return tString; - } - - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * Determines the relative difference between the two specified URIs. - * - * @param baseURI - * A java.net.URI object that represents the base URI for which toUri will be - * made relative. - * @param toUri - * A java.net.URI object that represents the URI to make relative to baseURI. - * - * @return A String that either represents the relative URI of toUri to - * baseURI, or the URI of toUri itself, depending on whether the hostname and - * scheme are identical for toUri and baseURI. If the hostname and scheme of - * baseURI and toUri are identical, this method returns a relative URI such that - * if appended to baseURI, it will yield toUri. If the hostname or scheme of - * baseURI and toUri are not identical, this method returns the full URI specified - * by toUri. - * - * @throws URISyntaxException - * If baseURI or toUri is invalid. - */ - public static String safeRelativize(final URI baseURI, final URI toUri) throws URISyntaxException { - // For compatibility followed - // http://msdn.microsoft.com/en-us/library/system.uri.makerelativeuri.aspx - - // if host and scheme are not identical return from uri - if (!baseURI.getHost().equals(toUri.getHost()) || !baseURI.getScheme().equals(toUri.getScheme())) { - return toUri.toString(); - } - - final String basePath = baseURI.getPath(); - String toPath = toUri.getPath(); - - int truncatePtr = 1; - - // Seek to first Difference - // int maxLength = Math.min(basePath.length(), toPath.length()); - int m = 0; - int ellipsesCount = 0; - for (; m < basePath.length(); m++) { - if (m >= toPath.length()) { - if (basePath.charAt(m) == '/') { - ellipsesCount++; - } - } - else { - if (basePath.charAt(m) != toPath.charAt(m)) { - break; - } - else if (basePath.charAt(m) == '/') { - truncatePtr = m + 1; - } - } - } - - if (m == toPath.length()) { - // No path difference, return query + fragment - return new URI(null, null, null, toUri.getQuery(), toUri.getFragment()).toString(); - } - else { - toPath = toPath.substring(truncatePtr); - final StringBuilder sb = new StringBuilder(); - while (ellipsesCount > 0) { - sb.append("../"); - ellipsesCount--; - } - - if (!Utility.isNullOrEmpty(toPath)) { - sb.append(toPath); - } - - if (!Utility.isNullOrEmpty(toUri.getQuery())) { - sb.append("?"); - sb.append(toUri.getQuery()); - } - if (!Utility.isNullOrEmpty(toUri.getFragment())) { - sb.append("#"); - sb.append(toUri.getRawFragment()); - } - - return sb.toString(); - } - } - - /** - * Trims the specified character from the end of a string. - * - * @param value - * A String that represents the string to trim. - * @param trimChar - * The character to trim from the end of the string. - * - * @return The string with the specified character trimmed from the end. - */ - protected static String trimEnd(final String value, final char trimChar) { - int stopDex = value.length() - 1; - while (stopDex > 0 && value.charAt(stopDex) == trimChar) { - stopDex--; - } - - return stopDex == value.length() - 1 ? value : value.substring(stopDex); - } - - /** - * Trims whitespace from the beginning of a string. - * - * @param value - * A String that represents the string to trim. - * - * @return The string with whitespace trimmed from the beginning. - */ - public static String trimStart(final String value) { - int spaceDex = 0; - while (spaceDex < value.length() && value.charAt(spaceDex) == ' ') { - spaceDex++; - } - - return value.substring(spaceDex); - } - - /** - * Reads data from an input stream and writes it to an output stream, calculates the length of the data written, and - * optionally calculates the MD5 hash for the data. - * - * @param sourceStream - * An InputStream object that represents the input stream to use as the source. - * @param outStream - * An OutputStream object that represents the output stream to use as the destination. - * @param writeLength - * The number of bytes to read from the stream. - * @param rewindSourceStream - * true if the input stream should be rewound after it is read; otherwise, - * false. - * @param calculateMD5 - * true if an MD5 hash will be calculated; otherwise, false. - * @param currentResult - * A {@link RequestResult} object that represents the result for the current request. - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A {@link StreamMd5AndLength} object that contains the output stream length, and optionally the MD5 hash. - * - * @throws IOException - * If an I/O error occurs. - * @throws StorageException - * If a storage service error occurred. - */ - public static StreamMd5AndLength writeToOutputStream(final InputStream sourceStream, final OutputStream outStream, - long writeLength, final boolean rewindSourceStream, final boolean calculateMD5, - final RequestResult currentResult, final OperationContext opContext) throws IOException, StorageException { - if (opContext != null) { - opContext.setCurrentOperationByteCount(0); - } - - if (rewindSourceStream && sourceStream.markSupported()) { - sourceStream.reset(); - sourceStream.mark(Integer.MAX_VALUE); - } - - if (calculateMD5 && opContext.getIntermediateMD5() == null) { - try { - opContext.setIntermediateMD5(MessageDigest.getInstance("MD5")); - } - catch (final NoSuchAlgorithmException e) { - // This wont happen, throw fatal. - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - final StreamMd5AndLength retVal = new StreamMd5AndLength(); - - if (writeLength < 0) { - writeLength = Long.MAX_VALUE; - } - - int count = -1; - final byte[] retrievedBuff = new byte[Constants.BUFFER_COPY_LENGTH]; - int nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); - - count = sourceStream.read(retrievedBuff, 0, nextCopy); - - while (nextCopy > 0 && count != -1) { - outStream.write(retrievedBuff, 0, count); - if (calculateMD5) { - opContext.getIntermediateMD5().update(retrievedBuff, 0, count); - } - - retVal.setLength(retVal.getLength() + count); - if (opContext != null) { - opContext.setCurrentOperationByteCount(opContext.getCurrentOperationByteCount() + count); - } - - nextCopy = (int) Math.min(retrievedBuff.length, writeLength - retVal.getLength()); - count = sourceStream.read(retrievedBuff, 0, nextCopy); - } - - outStream.flush(); - - if (calculateMD5) { - retVal.setMd5(Base64.encode(opContext.getIntermediateMD5().digest())); - } - - return retVal; - } - - /** - * Private Default Ctor. - */ - private Utility() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java deleted file mode 100644 index e8c595045e618..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ /dev/null @@ -1,538 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.InvalidKeyException; -import java.util.HashMap; -import java.util.Map.Entry; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.Credentials; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.ServiceProperties; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.StorageKey; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. The Base Request class for the protocol layer. - */ -public final class BaseRequest { - /** - * Adds the lease id. - * - * @param request - * a HttpURLConnection for the operation. - * @param leaseId - * the lease id to add to the HttpURLConnection. - */ - public static void addLeaseId(final HttpURLConnection request, final String leaseId) { - if (leaseId != null) { - BaseRequest.addOptionalHeader(request, "x-ms-lease-id", leaseId); - } - } - - /** - * Stores the user agent to send over the wire to identify the client. - */ - private static String userAgent; - - /** - * Adds the metadata. - * - * @param request - * The request. - * @param metadata - * The metadata. - */ - public static void addMetadata(final HttpURLConnection request, final HashMap metadata, - final OperationContext opContext) { - if (metadata != null) { - for (final Entry entry : metadata.entrySet()) { - addMetadata(request, entry.getKey(), entry.getValue(), opContext); - } - } - } - - /** - * Adds the metadata. - * - * @param opContext - * an object used to track the execution of the operation - * @param request - * The request. - * @param name - * The metadata name. - * @param value - * The metadata value. - */ - public static void addMetadata(final HttpURLConnection request, final String name, final String value, - final OperationContext opContext) { - Utility.assertNotNullOrEmpty("value", value); - - request.setRequestProperty(Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA + name, value); - } - - /** - * Adds the optional header. - * - * @param request - * a HttpURLConnection for the operation. - * @param name - * the metadata name. - * @param value - * the metadata value. - */ - public static void addOptionalHeader(final HttpURLConnection request, final String name, final String value) { - if (value != null && !value.equals(Constants.EMPTY_STRING)) { - request.setRequestProperty(name, value); - } - } - - /** - * Adds the snapshot. - * - * @param builder - * a query builder. - * @param snapshotVersion - * the snapshot version to the query builder. - * @throws StorageException - */ - public static void addSnapshot(final UriQueryBuilder builder, final String snapshotVersion) throws StorageException { - if (snapshotVersion != null) { - builder.add("snapshot", snapshotVersion); - } - } - - /** - * Creates the specified resource. Note request is set to setFixedLengthStreamingMode(0); Sign with 0 length. - * - * @param uri - * the request Uri. - * @param timeout - * the timeout for the request - * @param builder - * the UriQueryBuilder for the request - * @param opContext - * an object used to track the execution of the operation - * @return a HttpURLConnection to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if there is an improperly formated URI - * @throws StorageException - * @throws IllegalArgumentException - */ - public static HttpURLConnection create(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - retConnection.setFixedLengthStreamingMode(0); - retConnection.setDoOutput(true); - retConnection.setRequestMethod("PUT"); - - return retConnection; - } - - /** - * Creates the web request. - * - * @param uri - * the request Uri. - * @param timeoutInMs - * the timeout for the request - * @param builder - * the UriQueryBuilder for the request - * @param opContext - * an object used to track the execution of the operation - * @return a HttpURLConnection to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if there is an improperly formated URI - * @throws StorageException - */ - public static HttpURLConnection createURLConnection(final URI uri, final int timeoutInMs, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - if (timeoutInMs != 0) { - builder.add("timeout", String.valueOf(timeoutInMs / 1000)); - } - - final URL resourceUrl = builder.addToURI(uri).toURL(); - - final HttpURLConnection retConnection = (HttpURLConnection) resourceUrl.openConnection(); - - retConnection.setReadTimeout(timeoutInMs); - - // Note : accept behavior, java by default sends Accept behavior - // as text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 This will need to be set for table requests. - // - // To override set retConnection.setRequestProperty("Accept", - // "application/atom+xml"); - - retConnection.setRequestProperty(Constants.HeaderConstants.STORAGE_VERSION_HEADER, - Constants.HeaderConstants.TARGET_STORAGE_VERSION); - retConnection.setRequestProperty(Constants.HeaderConstants.USER_AGENT, getUserAgent()); - - // Java6 TODO remove me, this has to be manually set or it will - // sometimes default to application/x-www-form-urlencoded without us - // knowing causing auth fails in Java5. - retConnection.setRequestProperty(Constants.HeaderConstants.CONTENT_TYPE, ""); - return retConnection; - } - - /** - * Deletes the specified resource. Sign with no length specified. - * - * @param uri - * the request Uri. - * @param timeout - * the timeout for the request - * @param builder - * the UriQueryBuilder for the request - * @param opContext - * an object used to track the execution of the operation - * @return a HttpURLConnection to perform the operation. - * @throws IOException - * if there is an error opening the connection - * @throws URISyntaxException - * if there is an improperly formated URI - * @throws StorageException - */ - public static HttpURLConnection delete(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setDoOutput(true); - retConnection.setRequestMethod("DELETE"); - - return retConnection; - } - - /** - * Gets the metadata. Sign with no length specified. - * - * @param uri - * The Uri to query. - * @param timeout - * The timeout. - * @param builder - * The builder. - * @param opContext - * an object used to track the execution of the operation - * @return a web request for performing the operation. - * @throws StorageException - * @throws URISyntaxException - * @throws IOException - * */ - public static HttpURLConnection getMetadata(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws StorageException, IOException, URISyntaxException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - builder.add("comp", "metadata"); - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setDoOutput(true); - retConnection.setRequestMethod("HEAD"); - - return retConnection; - } - - /** - * Gets the properties. Sign with no length specified. - * - * @param uri - * The Uri to query. - * @param timeout - * The timeout. - * @param builder - * The builder. - * @param opContext - * an object used to track the execution of the operation - * @return a web request for performing the operation. - * @throws StorageException - * @throws URISyntaxException - * @throws IOException - * */ - public static HttpURLConnection getProperties(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setDoOutput(true); - retConnection.setRequestMethod("HEAD"); - - return retConnection; - } - - /** - * Creates a HttpURLConnection used to retrieve the Analytics service properties from the storage service. - * - * @param uri - * The service endpoint. - * @param timeout - * The timeout. - * @param builder - * The builder. - * @param opContext - * an object used to track the execution of the operation - * @return a web request for performing the operation. - * @throws IOException - * @throws URISyntaxException - * @throws StorageException - */ - public static HttpURLConnection getServiceProperties(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - builder.add("comp", "properties"); - builder.add("restype", "service"); - - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setDoOutput(true); - retConnection.setRequestMethod("GET"); - - return retConnection; - } - - /** - * Gets the user agent to send over the wire to identify the client. - * - * @return the user agent to send over the wire to identify the client. - */ - public static String getUserAgent() { - if (userAgent == null) { - userAgent = String.format("%s/%s", Constants.HeaderConstants.USER_AGENT_PREFIX, - Constants.HeaderConstants.USER_AGENT_VERSION); - } - return userAgent; - } - - /** - * Writes the contents of the ServiceProperties object to a byte array in XML form. - * - * @param properties - * the ServiceProperties to write to the stream. - * @param opContext - * an object used to track the execution of the operation - * @return the number of bytes written to the output stream. - * @throws XMLStreamException - * if there is an error writing the content to the stream. - * @throws StorageException - */ - public static byte[] serializeServicePropertiesToByteArray(final ServiceProperties properties, - final OperationContext opContext) throws XMLStreamException, StorageException { - return properties.serializeToByteArray(opContext); - } - - /** - * Sets the metadata. Sign with 0 length. - * - * @param uri - * The blob Uri. - * @param timeout - * The timeout. - * @param builder - * The builder. - * @param opContext - * an object used to track the execution of the operation - * @return a web request for performing the operation. - * @throws StorageException - * @throws URISyntaxException - * @throws IOException - * */ - public static HttpURLConnection setMetadata(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - - if (builder == null) { - builder = new UriQueryBuilder(); - } - - builder.add("comp", "metadata"); - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setFixedLengthStreamingMode(0); - retConnection.setDoOutput(true); - retConnection.setRequestMethod("PUT"); - - return retConnection; - } - - /** - * Creates a HttpURLConnection used to set the Analytics service properties on the storage service. - * - * @param uri - * The service endpoint. - * @param timeout - * The timeout. - * @param builder - * The builder. - * @param opContext - * an object used to track the execution of the operation - * @return a web request for performing the operation. - * @throws IOException - * @throws URISyntaxException - * @throws StorageException - */ - public static HttpURLConnection setServiceProperties(final URI uri, final int timeout, UriQueryBuilder builder, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - if (builder == null) { - builder = new UriQueryBuilder(); - } - - builder.add("comp", "properties"); - builder.add("restype", "service"); - - final HttpURLConnection retConnection = createURLConnection(uri, timeout, builder, opContext); - - retConnection.setDoOutput(true); - retConnection.setRequestMethod("PUT"); - - return retConnection; - } - - /** - * Signs the request appropriately to make it an authenticated request for Blob and Queue. - * - * @param request - * a HttpURLConnection for the operation. - * @param credentials - * the credentials to use for signing. - * @param contentLength - * the length of the content written to the output stream, -1 if unknown. - * @param opContext - * an object used to track the execution of the operation - * @throws InvalidKeyException - * if the credentials key is invalid. - * @throws StorageException - */ - public static void signRequestForBlobAndQueue(final HttpURLConnection request, final Credentials credentials, - final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { - request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); - final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueFullCanonicalizer(request); - - final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, - opContext); - - final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); - - // V2 add logging - // System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); - request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, - String.format("%s %s:%s", "SharedKey", credentials.getAccountName(), computedBase64Signature)); - } - - /** - * - * Signs the request appropriately to make it an authenticated request for Blob and Queue. - * - * @param request - * a HttpURLConnection for the operation. - * @param credentials - * the credentials to use for signing. - * @param contentLength - * the length of the content written to the output stream, -1 if unknown. - * @param opContext - * an object used to track the execution of the operation - * @throws InvalidKeyException - * if the credentials key is invalid. - * @throws StorageException - */ - public static void signRequestForBlobAndQueueSharedKeyLite(final HttpURLConnection request, - final Credentials credentials, final Long contentLength, final OperationContext opContext) - throws InvalidKeyException, StorageException { - request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); - - final Canonicalizer canonicalizer = CanonicalizerFactory.getBlobQueueLiteCanonicalizer(request); - - final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, - opContext); - - final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); - - // VNext add logging - // System.out.println(String.format("Signing %s\r\n%s\r\n", - // stringToSign, computedBase64Signature)); - request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, - String.format("%s %s:%s", "SharedKeyLite", credentials.getAccountName(), computedBase64Signature)); - } - - /** - * - * Signs the request appropriately to make it an authenticated request for Blob and Queue. - * - * @param request - * a HttpURLConnection for the operation. - * @param credentials - * the credentials to use for signing. - * @param contentLength - * the length of the content written to the output stream, -1 if unknown. - * @param opContext - * an object used to track the execution of the operation - * @throws InvalidKeyException - * if the credentials key is invalid. - * @throws StorageException - */ - public static void signRequestForTableSharedKeyLite(final HttpURLConnection request, final Credentials credentials, - final Long contentLength, final OperationContext opContext) throws InvalidKeyException, StorageException { - request.setRequestProperty(Constants.HeaderConstants.DATE, Utility.getGMTTime()); - - final Canonicalizer canonicalizer = CanonicalizerFactory.getTableLiteCanonicalizer(request); - - final String stringToSign = canonicalizer.canonicalize(request, credentials.getAccountName(), contentLength, - opContext); - - final String computedBase64Signature = StorageKey.computeMacSha256(credentials.getKey(), stringToSign); - - // TODO Vnext add logging - // System.out.println(String.format("Signing %s\r\n%s\r\n", stringToSign, computedBase64Signature)); - request.setRequestProperty(Constants.HeaderConstants.AUTHORIZATION, - String.format("%s %s:%s", "SharedKeyLite", credentials.getAccountName(), computedBase64Signature)); - } - - /** - * Private Default Ctor - */ - private BaseRequest() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java deleted file mode 100644 index e6acc444a7c06..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.ServiceProperties; -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. The base response class for the protocol layer - */ -public class BaseResponse { - /** - * Gets the ContentMD5 - * - * @param request - * The response from server. - * @return The ContentMD5. - */ - public static String getContentMD5(final HttpURLConnection request) { - return request.getHeaderField(Constants.HeaderConstants.CONTENT_MD5); - } - - /** - * Gets the Date - * - * @param request - * The response from server. - * @return The Date. - */ - public static String getDate(final HttpURLConnection request) { - final String retString = request.getHeaderField("Date"); - return retString == null ? request.getHeaderField(Constants.HeaderConstants.DATE) : retString; - } - - /** - * Gets the Etag - * - * @param request - * The response from server. - * @return The Etag. - */ - public static String getEtag(final HttpURLConnection request) { - return request.getHeaderField(Constants.ETAG_ELEMENT); - } - - /** - * Gets the metadata from the request The response from server. - * - * @return the metadata from the request - */ - public static HashMap getMetadata(final HttpURLConnection request) { - return getValuesByHeaderPrefix(request, Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA); - } - - /** - * Gets the request id. - * - * @param request - * The response from server. - * @return The request ID. - */ - public static String getRequestId(final HttpURLConnection request) { - return request.getHeaderField(Constants.HeaderConstants.REQUEST_ID_HEADER); - } - - /** - * Returns all the header/value pairs with the given prefix. - * - * @param request - * the request object containing headers to parse. - * @param prefix - * the prefix for headers to be returned. - * @return all the header/value pairs with the given prefix. - */ - private static HashMap getValuesByHeaderPrefix(final HttpURLConnection request, final String prefix) { - final HashMap retVals = new HashMap(); - final Map> headerMap = request.getHeaderFields(); - final int prefixLength = prefix.length(); - - for (final Entry> entry : headerMap.entrySet()) { - if (entry.getKey() != null && entry.getKey().startsWith(prefix)) { - final List currHeaderValues = entry.getValue(); - retVals.put(entry.getKey().substring(prefixLength), currHeaderValues.get(0)); - } - } - - return retVals; - } - - /** - * Deserializes the ServiceProperties object from an input stream. - * - * @param inStream - * the stream to read from. - * @param opContext - * an object used to track the execution of the operation - * @return a ServiceProperties object representing the Analytics configuration for the client. - * @throws XMLStreamException - * if the xml is invalid. - * @throws StorageException - * if unexpected xml is found. - */ - public static ServiceProperties readServicePropertiesFromStream(final InputStream inStream, - final OperationContext opContext) throws XMLStreamException, StorageException { - return ServiceProperties.readServicePropertiesFromStream(inStream, opContext); - } - - /** - * Private Default Ctor - */ - protected BaseResponse() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java deleted file mode 100644 index 0b7e2e4d43680..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; -import java.security.InvalidParameterException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue - * Service under the Shared Key authentication scheme. - */ -final class BlobQueueFullCanonicalizer extends Canonicalizer { - - /** - * Constructs a canonicalized string for signing a request. - * - * @param conn - * the HttpURLConnection to canonicalize - * @param accountName - * the account name associated with the request - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param opContext - * the OperationContext for the given request - * @return a canonicalized string. - * @throws StorageException - */ - @Override - protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, - final OperationContext opContext) throws StorageException { - - if (contentLength < -1) { - throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); - } - - return canonicalizeHttpRequest(conn.getURL(), accountName, conn.getRequestMethod(), - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), contentLength, null, - conn, opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java deleted file mode 100644 index cf6949cdfcc33..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; -import java.security.InvalidParameterException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Blob and Queue - * Service under the Shared Key authentication scheme. - */ -final class BlobQueueLiteCanonicalizer extends Canonicalizer { - - /** - * Constructs a canonicalized string for signing a request. - * - * @param conn - * the HttpURLConnection to canonicalize - * @param accountName - * the account name associated with the request - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param opContext - * the OperationContext for the given request - * @return a canonicalized string. - * @throws StorageException - */ - @Override - protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, - final OperationContext opContext) throws StorageException { - if (contentLength < -1) { - throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); - } - - return canonicalizeHttpRequestLite(conn.getURL(), accountName, conn.getRequestMethod(), - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_TYPE), contentLength, null, - conn, opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java deleted file mode 100644 index cd2af8a81c3d5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ /dev/null @@ -1,382 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. This is a Version 2 Canoncicalization strategy conforming to the PDC 2009-09-19 - * specification - */ -abstract class Canonicalizer { - - /** - * Add x-ms- prefixed headers in a fixed order. - * - * @param conn - * the HttpURLConnection for the operation - * @param canonicalizedString - * the canonicalized string to add the canonicalized headerst to. - */ - private static void addCanonicalizedHeaders(final HttpURLConnection conn, final StringBuilder canonicalizedString) { - // Look for header names that start with - // HeaderNames.PrefixForStorageHeader - // Then sort them in case-insensitive manner. - - final Map> headers = conn.getRequestProperties(); - final ArrayList httpStorageHeaderNameArray = new ArrayList(); - - for (final String key : headers.keySet()) { - if (key.toLowerCase(Utility.LOCALE_US).startsWith(Constants.PREFIX_FOR_STORAGE_HEADER)) { - httpStorageHeaderNameArray.add(key.toLowerCase(Utility.LOCALE_US)); - } - } - - Collections.sort(httpStorageHeaderNameArray); - - // Now go through each header's values in the sorted order and append - // them to the canonicalized string. - for (final String key : httpStorageHeaderNameArray) { - final StringBuilder canonicalizedElement = new StringBuilder(key); - String delimiter = ":"; - final ArrayList values = getHeaderValues(headers, key); - - // Go through values, unfold them, and then append them to the - // canonicalized element string. - for (final String value : values) { - // Unfolding is simply removal of CRLF. - final String unfoldedValue = value.replace("\r\n", Constants.EMPTY_STRING); - - // Append it to the canonicalized element string. - canonicalizedElement.append(delimiter); - canonicalizedElement.append(unfoldedValue); - delimiter = ","; - } - - // Now, add this canonicalized element to the canonicalized header - // string. - appendCanonicalizedElement(canonicalizedString, canonicalizedElement.toString()); - } - } - - /** - * Append a string to a string builder with a newline constant - * - * @param builder - * the StringBuilder object - * @param element - * the string to append. - */ - protected static void appendCanonicalizedElement(final StringBuilder builder, final String element) { - builder.append("\n"); - builder.append(element); - } - - /** - * Constructs a canonicalized string from the request's headers that will be used to construct the signature string - * for signing a Blob or Queue service request under the Shared Key Full authentication scheme. - * - * @param address - * the request URI - * @param accountName - * the account name associated with the request - * @param method - * the verb to be used for the HTTP request. - * @param contentType - * the content type of the HTTP request. - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param date - * the date/time specification for the HTTP request - * @param conn - * the HttpURLConnection for the operation. - * @param opContext - * the OperationContext for the request. - * @return A canonicalized string. - * @throws StorageException - */ - protected static String canonicalizeHttpRequest(final java.net.URL address, final String accountName, - final String method, final String contentType, final long contentLength, final String date, - final HttpURLConnection conn, final OperationContext opContext) throws StorageException { - - // The first element should be the Method of the request. - // I.e. GET, POST, PUT, or HEAD. - final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); - - // The next elements are - // If any element is missing it may be empty. - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_ENCODING)); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_LANGUAGE)); - appendCanonicalizedElement(canonicalizedString, - contentLength == -1 ? Constants.EMPTY_STRING : String.valueOf(contentLength)); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5)); - appendCanonicalizedElement(canonicalizedString, contentType != null ? contentType : Constants.EMPTY_STRING); - - final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); - // If x-ms-date header exists, Date should be empty string - appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date - : Constants.EMPTY_STRING); - - String modifiedSinceString = Constants.EMPTY_STRING; - if (conn.getIfModifiedSince() > 0) { - modifiedSinceString = Utility.getGMTTime(new Date(conn.getIfModifiedSince())); - } - - appendCanonicalizedElement(canonicalizedString, modifiedSinceString); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_MATCH)); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_NONE_MATCH)); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.IF_UNMODIFIED_SINCE)); - appendCanonicalizedElement(canonicalizedString, - Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.RANGE)); - - addCanonicalizedHeaders(conn, canonicalizedString); - - appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName)); - - return canonicalizedString.toString(); - } - - /** - * Constructs a canonicalized string from the request's headers that will be used to construct the signature string - * for signing a Blob or Queue service request under the Shared Key Lite authentication scheme. - * - * @param address - * the request URI - * @param accountName - * the account name associated with the request - * @param method - * the verb to be used for the HTTP request. - * @param contentType - * the content type of the HTTP request. - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param date - * the date/time specification for the HTTP request - * @param conn - * the HttpURLConnection for the operation. - * @param opContext - * the OperationContext for the request. - * @return A canonicalized string. - * @throws StorageException - */ - protected static String canonicalizeHttpRequestLite(final java.net.URL address, final String accountName, - final String method, final String contentType, final long contentLength, final String date, - final HttpURLConnection conn, final OperationContext opContext) throws StorageException { - // The first element should be the Method of the request. - // I.e. GET, POST, PUT, or HEAD. - final StringBuilder canonicalizedString = new StringBuilder(conn.getRequestMethod()); - - // The second element should be the MD5 value. - // This is optional and may be empty. - final String httpContentMD5Value = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.CONTENT_MD5); - appendCanonicalizedElement(canonicalizedString, httpContentMD5Value); - - // The third element should be the content type. - appendCanonicalizedElement(canonicalizedString, contentType); - - // The fourth element should be the request date. - // See if there's an storage date header. - // If there's one, then don't use the date header. - - final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); - // If x-ms-date header exists, Date should be empty string - appendCanonicalizedElement(canonicalizedString, dateString.equals(Constants.EMPTY_STRING) ? date - : Constants.EMPTY_STRING); - - addCanonicalizedHeaders(conn, canonicalizedString); - - appendCanonicalizedElement(canonicalizedString, getCanonicalizedResource(address, accountName)); - - return canonicalizedString.toString(); - } - - /** - * Gets the canonicalized resource string for a Blob or Queue service request under the Shared Key Lite - * authentication scheme. - * - * @param address - * the resource URI. - * @param accountName - * the account name for the request. - * @return the canonicalized resource string. - * @throws StorageException - */ - protected static String getCanonicalizedResource(final java.net.URL address, final String accountName) - throws StorageException { - // Resource path - final StringBuilder resourcepath = new StringBuilder("/"); - resourcepath.append(accountName); - - // Note that AbsolutePath starts with a '/'. - resourcepath.append(address.getPath()); - final StringBuilder canonicalizedResource = new StringBuilder(resourcepath.toString()); - - // query parameters - final Map queryVariables = PathUtility.parseQueryString(address.getQuery()); - - final Map lowercasedKeyNameValue = new HashMap(); - - for (final Entry entry : queryVariables.entrySet()) { - // sort the value and organize it as comma separated values - final List sortedValues = Arrays.asList(entry.getValue()); - Collections.sort(sortedValues); - - final StringBuilder stringValue = new StringBuilder(); - - for (final String value : sortedValues) { - if (stringValue.length() > 0) { - stringValue.append(","); - } - - stringValue.append(value); - } - - // key turns out to be null for ?a&b&c&d - lowercasedKeyNameValue.put(entry.getKey() == null ? null : entry.getKey().toLowerCase(Utility.LOCALE_US), - stringValue.toString()); - } - - final ArrayList sortedKeys = new ArrayList(lowercasedKeyNameValue.keySet()); - - Collections.sort(sortedKeys); - - for (final String key : sortedKeys) { - final StringBuilder queryParamString = new StringBuilder(); - - queryParamString.append(key); - queryParamString.append(":"); - queryParamString.append(lowercasedKeyNameValue.get(key)); - - appendCanonicalizedElement(canonicalizedResource, queryParamString.toString()); - } - - return canonicalizedResource.toString(); - } - - /** - * Gets the canonicalized resource string for a Blob or Queue service request under the Shared Key Lite - * authentication scheme. - * - * @param address - * the resource URI. - * @param accountName - * the account name for the request. - * @return the canonicalized resource string. - * @throws StorageException - */ - protected static String getCanonicalizedResourceLite(final java.net.URL address, final String accountName) - throws StorageException { - // Resource path - final StringBuilder resourcepath = new StringBuilder("/"); - resourcepath.append(accountName); - - // Note that AbsolutePath starts with a '/'. - resourcepath.append(address.getPath()); - final StringBuilder canonicalizedResource = new StringBuilder(resourcepath.toString()); - - // query parameters - final Map queryVariables = PathUtility.parseQueryString(address.getQuery()); - - final String[] compVals = queryVariables.get("comp"); - - if (compVals != null) { - - final List sortedValues = Arrays.asList(compVals); - Collections.sort(sortedValues); - - canonicalizedResource.append("?comp="); - - final StringBuilder stringValue = new StringBuilder(); - for (final String value : sortedValues) { - if (stringValue.length() > 0) { - stringValue.append(","); - } - - stringValue.append(value); - } - - appendCanonicalizedElement(canonicalizedResource, stringValue.toString()); - } - - return canonicalizedResource.toString(); - } - - /** - * Gets all the values for the given header in the one to many map, performs a trimStart() on each return value - * - * @param headers - * a one to many map of key / values representing the header values for the connection. - * @param headerName - * the name of the header to lookup - * @return an ArrayList of all trimmed values cooresponding to the requested headerName. This may be empty - * if the header is not found. - */ - private static ArrayList getHeaderValues(final Map> headers, final String headerName) { - - final ArrayList arrayOfValues = new ArrayList(); - List values = null; - - for (final Entry> entry : headers.entrySet()) { - if (entry.getKey().toLowerCase(Utility.LOCALE_US).equals(headerName)) { - values = entry.getValue(); - break; - } - } - if (values != null) { - for (final String value : values) { - // canonicalization formula requires the string to be left - // trimmed. - arrayOfValues.add(Utility.trimStart(value)); - } - } - return arrayOfValues; - } - - /** - * Constructs a canonicalized string for signing a request. - * - * @param conn - * the HttpURLConnection to canonicalize - * @param accountName - * the account name associated with the request - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param opContext - * the OperationContext for the given request - * @return a canonicalized string. - */ - protected abstract String canonicalize(HttpURLConnection conn, String accountName, Long contentLength, - OperationContext opContext) throws StorageException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java deleted file mode 100644 index 05b3607322cb4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Retrieve appropriate version of CanonicalizationStrategy based on the webrequest for Blob - * and Queue. - */ -final class CanonicalizerFactory { - /** - * The Canonicalizer instance for Blob & Queue - */ - private static final BlobQueueFullCanonicalizer BLOB_QUEUE_FULL_V2_INSTANCE = new BlobQueueFullCanonicalizer(); - - /** - * The Canonicalizer instance for Blob & Queue Shared Key Lite - */ - private static final BlobQueueLiteCanonicalizer BLOB_QUEUE_LITE_INSTANCE = new BlobQueueLiteCanonicalizer(); - - /** - * The Canonicalizer instance for Table - */ - private static final TableLiteCanonicalizer TABLE_LITE_INSTANCE = new TableLiteCanonicalizer(); - - /** - * Gets the Blob queue Canonicalizer full version 2. - * - * @param conn - * the HttpURLConnection for the current operation - * @return the appropriate Canonicalizer for the operation. - */ - protected static Canonicalizer getBlobQueueFullCanonicalizer(final HttpURLConnection conn) { - if (validateVersionIsSupported(conn)) { - return BLOB_QUEUE_FULL_V2_INSTANCE; - } - else { - throw new UnsupportedOperationException("Storage protocol version prior to 2009-09-19 are not supported."); - } - } - - /** - * Gets the Blob queue lite Canonicalizer - * - * @param conn - * the HttpURLConnection for the current operation - * @return the appropriate Canonicalizer for the operation. - */ - protected static Canonicalizer getBlobQueueLiteCanonicalizer(final HttpURLConnection conn) { - if (validateVersionIsSupported(conn)) { - return BLOB_QUEUE_LITE_INSTANCE; - } - else { - throw new UnsupportedOperationException( - "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); - } - } - - /** - * Gets the Blob queue lite Canonicalizer - * - * @param conn - * the HttpURLConnection for the current operation - * @return the appropriate Canonicalizer for the operation. - */ - protected static Canonicalizer getTableLiteCanonicalizer(final HttpURLConnection conn) { - if (validateVersionIsSupported(conn)) { - return TABLE_LITE_INSTANCE; - } - else { - throw new UnsupportedOperationException( - "Versions before 2009-09-19 do not support Shared Key Lite for Blob And Queue."); - } - } - - /** - * Determines if the current request is using a protocol post PDC 2009. - * - * @param conn - * the HttpURLConnection for the current operation - * @return true if is greater or equal PDC 09'; otherwise, false. - */ - private static Boolean validateVersionIsSupported(final HttpURLConnection conn) { - final String versionString = Utility.getStandardHeaderValue(conn, - Constants.HeaderConstants.STORAGE_VERSION_HEADER); - - if (versionString.length() == 0 || versionString.length() == 0) { - return true; - } - - try { - final Calendar versionThresholdCalendar = Calendar.getInstance(Utility.LOCALE_US); - versionThresholdCalendar.set(2009, Calendar.SEPTEMBER, 19, 0, 0, 0); - versionThresholdCalendar.set(Calendar.MILLISECOND, 0); - - final DateFormat versionFormat = new SimpleDateFormat("yyyy-MM-dd"); - final Date versionDate = versionFormat.parse(versionString); - final Calendar requestVersionCalendar = Calendar.getInstance(Utility.LOCALE_US); - requestVersionCalendar.setTime(versionDate); - requestVersionCalendar.set(Calendar.HOUR_OF_DAY, 0); - requestVersionCalendar.set(Calendar.MINUTE, 0); - requestVersionCalendar.set(Calendar.SECOND, 0); - requestVersionCalendar.set(Calendar.MILLISECOND, 1); - - return requestVersionCalendar.compareTo(versionThresholdCalendar) >= 0; - - } - catch (final ParseException e) { - return false; - } - } - - /** - * Private Default Ctor - */ - private CanonicalizerFactory() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java deleted file mode 100644 index 7d85bcb3e5941..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.util.HashMap; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. An internal helper class used to parse objects from responses. - */ -public final class DeserializationHelper { - /** - * Reads Metadata from the XMLStreamReader. - * - * @param xmlr - * the XMLStreamReader object - * @return the metadata as a hashmap. - * @throws XMLStreamException - * if there is a parsing exception - */ - public static HashMap parseMetadateFromXML(final XMLStreamReader xmlr) throws XMLStreamException { - final HashMap retVals = new HashMap(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.METADATA_ELEMENT); - - int eventType = xmlr.getEventType(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.END_ELEMENT && Constants.METADATA_ELEMENT.equals(name)) { - break; - } - else if (Constants.INVALID_METADATA_NAME.equals(name)) { - // no op , skip - } - else if (eventType == XMLStreamConstants.START_ELEMENT) { - final String tValue = Utility.readElementFromXMLReader(xmlr, name); - if (!Utility.isNullOrEmpty(tValue)) { - retVals.put(name, tValue); - } - } - } - - return retVals; - } - - /** - * Private Default Ctor - */ - private DeserializationHelper() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java deleted file mode 100644 index 061c47d340e32..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ /dev/null @@ -1,324 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.SocketTimeoutException; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; -import java.util.Date; -import java.util.concurrent.TimeoutException; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RequestResult; -import com.microsoft.windowsazure.services.core.storage.ResponseReceivedEvent; -import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; -import com.microsoft.windowsazure.services.core.storage.RetryPolicy; -import com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory; -import com.microsoft.windowsazure.services.core.storage.RetryResult; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. A class that handles execution of StorageOperations and enforces retry policies. - */ -public final class ExecutionEngine { - - /** - * Executes an operation without a retry policy. - * - * @param - * The service client type - * @param - * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. - * @param - * The type of the expected result - * @param client - * the service client associated with the request - * @param parentObject - * the parent object - * @param task - * the StorageOperation to execute - * @param opContext - * an object used to track the execution of the operation - * @return the result of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - protected static RESULT_TYPE execute(final CLIENT_TYPE client, - final PARENT_TYPE parentObject, final StorageOperation task, - final OperationContext opContext) throws StorageException { - return executeWithRetry(client, parentObject, task, RetryNoRetry.getInstance(), opContext); - } - - /** - * Executes an operation and enforces a retrypolicy to handle any potential errors - * - * @param - * The service client type - * @param - * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. - * @param - * The type of the expected result - * @param client - * the service client associated with the request - * @param parentObject - * the parent object - * @param task - * the StorageOperation to execute - * @param policyFactory - * the factory used to generate a new retry policy instance - * @param opContext - * an object used to track the execution of the operation - * @return the result of the operation - * @throws StorageException - * an exception representing any error which occurred during the operation. - */ - public static RESULT_TYPE executeWithRetry(final CLIENT_TYPE client, - final PARENT_TYPE parentObject, final StorageOperation task, - final RetryPolicyFactory policyFactory, final OperationContext opContext) throws StorageException { - - final RetryPolicy policy = policyFactory.createInstance(opContext); - RetryResult retryRes; - int currentRetryCount = 0; - StorageException translatedException = null; - final long startTime = new Date().getTime(); - - while (true) { - try { - // reset result flags - task.initialize(); - - final RESULT_TYPE result = task.execute(client, parentObject, opContext); - - opContext.setClientTimeInMs(new Date().getTime() - startTime); - - if (!task.isNonExceptionedRetryableFailure()) { - // Success return result, the rest of the return paths throw. - return result; - } - else { - // The task may have already parsed an exception. - translatedException = task.materializeException(getLastRequestObject(opContext), opContext); - setLastException(opContext, translatedException); - - // throw on non retryable status codes: 501, 505, blob type - // mismatch - if (task.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_IMPLEMENTED - || task.getResult().getStatusCode() == HttpURLConnection.HTTP_VERSION - || translatedException.getErrorCode().equals(StorageErrorCodeStrings.INVALID_BLOB_TYPE)) { - throw translatedException; - } - } - } - catch (final TimeoutException e) { - // Retryable - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - } - catch (final SocketTimeoutException e) { - // Retryable - translatedException = new StorageException(StorageErrorCodeStrings.OPERATION_TIMED_OUT, - "The operation did not complete in the specified time.", -1, null, e); - setLastException(opContext, translatedException); - } - catch (final IOException e) { - // Retryable - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - } - catch (final XMLStreamException e) { - // Non Retryable, just throw - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - throw translatedException; - } - catch (final InvalidKeyException e) { - // Non Retryable, just throw - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - throw translatedException; - } - catch (final URISyntaxException e) { - // Non Retryable, just throw - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - throw translatedException; - } - catch (final StorageException e) { - // Non Retryable, just throw - // do not translate StorageException - setLastException(opContext, e); - throw e; - } - catch (final Exception e) { - // Non Retryable, just throw - translatedException = StorageException - .translateException(getLastRequestObject(opContext), e, opContext); - setLastException(opContext, translatedException); - throw translatedException; - } - - // Evaluate Retry Policy - retryRes = policy.shouldRetry(currentRetryCount, task.getResult().getStatusCode(), opContext - .getLastResult().getException(), opContext); - - if (!retryRes.isShouldRetry()) { - throw translatedException; - } - else { - retryRes.doSleep(); - currentRetryCount++; - } - } - } - - /** - * Gets the input stream from the request - * - * @param request - * the request to process - * @param opContext - * an object used to track the execution of the operation - * @return the input stream from the request - * @throws IOException - * if there is an error making the connection - */ - public static InputStream getInputStream(final HttpURLConnection request, final OperationContext opContext) - throws IOException { - final RequestResult currResult = new RequestResult(); - opContext.setCurrentRequestObject(request); - currResult.setStartDate(new Date()); - opContext.getRequestResults().add(currResult); - try { - return request.getInputStream(); - } - catch (final IOException ex) { - getResponseCode(currResult, request, opContext); - throw ex; - } - } - - /** - * Gets the last request object in a safe way, returns null if there was not last request result. - * - * @param opContext - * an object used to track the execution of the operation - * @return the last request object in a safe way, returns null if there was not last request result. - */ - private static HttpURLConnection getLastRequestObject(final OperationContext opContext) { - if (opContext == null || opContext.getCurrentRequestObject() == null) { - return null; - } - - return opContext.getCurrentRequestObject(); - } - - /** - * Gets the response code form the request - * - * @param currResult - * the current RequestResult object - * @param request - * the request to process - * @param opContext - * an object used to track the execution of the operation - * @throws IOException - * if there is an error making the connection - */ - public static void getResponseCode(final RequestResult currResult, final HttpURLConnection request, - final OperationContext opContext) throws IOException { - // Send the request - currResult.setStatusCode(request.getResponseCode()); - currResult.setStatusMessage(request.getResponseMessage()); - - currResult.setStopDate(new Date()); - currResult.setServiceRequestID(BaseResponse.getRequestId(request)); - currResult.setEtag(BaseResponse.getEtag(request)); - currResult.setRequestDate(BaseResponse.getDate(request)); - currResult.setContentMD5(BaseResponse.getContentMD5(request)); - - if (opContext.getResponseReceivedEventHandler().hasListeners()) { - opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); - } - } - - /** - * Gets the response for a given HttpURLConnection, populates the opContext with the result, and fires an event if - * it has listeners. - * - * @param request - * the request to process - * @param opContext - * an object used to track the execution of the operation - * @return a RequestResult object representing the status code/ message of the current request - * @throws IOException - * if there is an error making the connection - */ - public static RequestResult processRequest(final HttpURLConnection request, final OperationContext opContext) - throws IOException { - final RequestResult currResult = new RequestResult(); - currResult.setStartDate(new Date()); - opContext.getRequestResults().add(currResult); - opContext.setCurrentRequestObject(request); - - // Send the request - currResult.setStatusCode(request.getResponseCode()); - currResult.setStatusMessage(request.getResponseMessage()); - - currResult.setStopDate(new Date()); - currResult.setServiceRequestID(BaseResponse.getRequestId(request)); - currResult.setEtag(BaseResponse.getEtag(request)); - currResult.setRequestDate(BaseResponse.getDate(request)); - currResult.setContentMD5(BaseResponse.getContentMD5(request)); - - if (opContext.getResponseReceivedEventHandler().hasListeners()) { - opContext.getResponseReceivedEventHandler().fireEvent(new ResponseReceivedEvent(opContext, request)); - } - - return currResult; - } - - /** - * Sets the exception on the last request result in a safe way, if there is no last result one is added. - * - * @param opContext - * an object used to track the execution of the operation - * @param exceptionToSet - * the exception to set on the result. - */ - private static void setLastException(final OperationContext opContext, final Exception exceptionToSet) { - if (opContext.getLastResult() == null) { - opContext.getRequestResults().add(new RequestResult()); - } - opContext.getLastResult().setException(exceptionToSet); - } - - /** - * Private default Ctor for Utility Class - */ - private ExecutionEngine() { - // private ctor - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java deleted file mode 100644 index 3cada7d30b23a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.ResultSegment; -import com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory; -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. Provides a lazy iterator which will retrieve the next segment of a result as the iterator - * is consumed - * - * @param - * The service client type - * @param - * The type of the parent object, i.e. CloudBlobClient for ListContainers etc. - * @param - * The type of the objects the resulting iterable objects - */ -public final class LazySegmentedIterator implements Iterator, - Iterable { - - /** - * Holds the current segment of results. - */ - private ResultSegment currentSegment; - - /** - * Holds the iterator for the current Segment. - */ - private Iterator currentSegmentIterator; - - /** - * Holds the service client associated with the operations. - */ - private final CLIENT_TYPE client; - - /** - * Holds a reference to the parent object, i.e. CloudBlobContainer for list blobs. - */ - private final PARENT_TYPE parentObject; - - /** - * Holds the reference to the RetryPolicyFactory object. - */ - private final RetryPolicyFactory policyFactory; - - /** - * Holds the SegmentedStorageOperation which is used to retrieve the next segment of results. - */ - private final SegmentedStorageOperation> segmentGenerator; - - /** - * Holds an object used to track the execution of the operation - */ - private final OperationContext opContext; - - /** - * Initializes the LazySegmentedIterator. - * - * @param segmentGenerator - * a SegmentedStorageOperation to execute in order to retrieve the next segment of the result. - * @param client - * the service client associated with the request - * @param parent - * the parent object - * @param policyFactory - * the factory used to generate a new retry policy instance - * @param opContext - * an object used to track the execution of the operation - */ - public LazySegmentedIterator( - final SegmentedStorageOperation> segmentGenerator, - final CLIENT_TYPE client, final PARENT_TYPE parent, final RetryPolicyFactory policyFactory, - final OperationContext opContext) { - this.segmentGenerator = segmentGenerator; - this.parentObject = parent; - this.opContext = opContext; - this.policyFactory = policyFactory; - this.client = client; - } - - /** - * Indicates if the iterator has another element. - */ - @Override - @DoesServiceRequest - public boolean hasNext() { - while (this.currentSegment == null - || (!this.currentSegmentIterator.hasNext() && this.currentSegment != null && this.currentSegment - .getHasMoreResults())) { - try { - this.currentSegment = ExecutionEngine.executeWithRetry(this.client, this.parentObject, - this.segmentGenerator, this.policyFactory, this.opContext); - } - catch (final StorageException e) { - final NoSuchElementException ex = new NoSuchElementException( - "An error occurred while enumerating the result, check the original exception for details."); - ex.initCause(e); - throw ex; - } - this.currentSegmentIterator = this.currentSegment.getResults().iterator(); - - if (!this.currentSegmentIterator.hasNext() && !this.currentSegment.getHasMoreResults()) { - return false; - } - } - - return this.currentSegmentIterator.hasNext(); - } - - /** - * Gets a reference to the iterator. - */ - @Override - public Iterator iterator() { - return this; - } - - /** - * Returns the next element. - */ - @Override - public ENTITY_TYPE next() { - return this.currentSegmentIterator.next(); - } - - /** - * Removes an element, not supported - */ - @Override - public void remove() { - // read only, no-op - throw new UnsupportedOperationException(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java deleted file mode 100644 index 6206d2ef9dda4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import com.microsoft.windowsazure.services.core.storage.Constants; - -/** - * RESERVED FOR INTERNAL USE. Describes actions that can be performed on a lease. - */ -public enum LeaseAction { - - /** - * Acquire the lease. - */ - ACQUIRE, - - /** - * Renew the lease. - */ - RENEW, - - /** - * Release the lease. - */ - RELEASE, - - /** - * Break the lease. - */ - BREAK; - - @Override - public String toString() { - switch (this) { - case ACQUIRE: - return "Acquire"; - case RENEW: - return "Renew"; - case RELEASE: - return "Release"; - case BREAK: - return "Break"; - default: - // Wont Happen, all possible values covered above. - return Constants.EMPTY_STRING; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java deleted file mode 100644 index 167b7cfaf0d73..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -/** - * RESERVED FOR INTERNAL USE. A class which holds the current context of a listing - */ -public class ListingContext { - - /** - * The Marker value. - */ - private String marker; - - /** - * The MaxResults value. - */ - private Integer maxResults; - - /** - * The Prefix value. - */ - private String prefix; - - /** - * Initializes a new instance of the ListingContext class. - * - * @param prefix - * the listing prefix to use - * @param maxResults - * the maximum number of results to retrieve. - */ - public ListingContext(final String prefix, final Integer maxResults) { - this.setPrefix(prefix); - this.setMaxResults(maxResults); - this.setMarker(null); - } - - /** - * @return the marker - */ - public final String getMarker() { - return this.marker; - } - - /** - * @return the maxResults - */ - public final Integer getMaxResults() { - return this.maxResults; - } - - /** - * @return the prefix - */ - public final String getPrefix() { - return this.prefix; - } - - /** - * @param marker - * the marker to set - */ - public final void setMarker(final String marker) { - this.marker = marker; - } - - /** - * @param maxResults - * the maxResults to set - */ - protected final void setMaxResults(final Integer maxResults) { - this.maxResults = maxResults; - } - - /** - * @param prefix - * the prefix to set - */ - public final void setPrefix(final String prefix) { - this.prefix = prefix; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java deleted file mode 100644 index 91bdfda5e19c3..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import com.microsoft.windowsazure.services.core.storage.RequestOptions; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; - -/** - * RESERVED FOR INTERNAL USE. A base class which encapsulate the execution of a given segmented storage operation. - * - * @param - * The service client type - * @param

- * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. - * @param - * The type of the expected result - */ -public abstract class SegmentedStorageOperation extends StorageOperation { - - /** - * Holds the ResultContinuation between executions. - */ - private ResultContinuation token; - - /** - * Initializes a new instance of the SegmentedStorageOperation class. - * - * @param options - * the RequestOptions to use - */ - public SegmentedStorageOperation(final RequestOptions options) { - super(options); - } - - /** - * Initializes a new instance of the SegmentedStorageOperation class. - * - * @param options - * the RequestOptions to use - * @param token - * the ResultContinuation to use - */ - public SegmentedStorageOperation(final RequestOptions options, final ResultContinuation token) { - super(options); - this.setToken(token); - } - - /** - * @return the token. - */ - protected final ResultContinuation getToken() { - return this.token; - } - - /** - * @param token - * the token to set. - */ - protected final void setToken(final ResultContinuation token) { - this.token = token; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java deleted file mode 100644 index 7779324a8c8e7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.io.InputStream; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/*** - * RESERVED FOR INTERNAL USE. A class to help parse the Error details from an input stream. - */ -public final class StorageErrorResponse { - /** - * Holds the StorageExtendedErrorInformation to return. - */ - private final StorageExtendedErrorInformation errorInfo; - - /** - * Holds a flag indicating if the response has been parsed or not. - */ - private boolean isParsed; - - /** - * Holds a reference to the input stream to read from. - */ - private final InputStream streamRef; - - /** - * Initializes the StorageErrorResponse object. - * - * @param stream - * the input stream to read error details from. - */ - public StorageErrorResponse(final InputStream stream) { - this.streamRef = stream; - this.errorInfo = new StorageExtendedErrorInformation(); - } - - /** - * Gets the Extended Error information from the response stream. - * - * @return the Extended Error information from the response stream - * @throws XMLStreamException - * if an xml exception occurs - */ - public StorageExtendedErrorInformation getExtendedErrorInformation() throws XMLStreamException { - if (!this.isParsed) { - this.parseResponse(); - } - - return this.errorInfo; - } - - /** - * Parses the Error Exception details from the response. - * - * @param xmlr - * the XMLStreamReader to read from - * @throws XMLStreamException - * if an xml exception occurs - */ - private void parseErrorException(final XMLStreamReader xmlr) throws XMLStreamException { - int eventType = xmlr.getEventType(); - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.ERROR_EXCEPTION); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION_MESSAGE)) { - final String errorExceptionMessage = Utility.readElementFromXMLReader(xmlr, - Constants.ERROR_EXCEPTION_MESSAGE); - this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_MESSAGE, - new String[] { errorExceptionMessage }); - - } - else if (eventType == XMLStreamConstants.START_ELEMENT - && name.equals(Constants.ERROR_EXCEPTION_STACK_TRACE)) { - final String errorExceptionStack = Utility.readElementFromXMLReader(xmlr, - Constants.ERROR_EXCEPTION_STACK_TRACE); - this.errorInfo.getAdditionalDetails().put(Constants.ERROR_EXCEPTION_STACK_TRACE, - new String[] { errorExceptionStack }); - } - else if (eventType == XMLStreamConstants.END_ELEMENT) { - break; - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ERROR_EXCEPTION); - } - - /** - * Parses the extended error information from the response stream. - * - * @throws XMLStreamException - * if an xml exception occurs - */ - private void parseResponse() throws XMLStreamException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - String tempParseString; - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get Error Root Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, Constants.ERROR_ROOT_ELEMENT); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - if (eventType == XMLStreamConstants.END_ELEMENT) { - break; - } - - final String name = xmlr.getName().toString(); - - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_CODE)) { - this.errorInfo.setErrorCode(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_CODE)); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_MESSAGE)) { - this.errorInfo.setErrorMessage(Utility.readElementFromXMLReader(xmlr, Constants.ERROR_MESSAGE)); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.ERROR_EXCEPTION)) { - // get error exception - this.parseErrorException(xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.ERROR_EXCEPTION); - } - else if (eventType == XMLStreamConstants.START_ELEMENT) { - // get additional details - tempParseString = Utility.readElementFromXMLReader(xmlr, name); - - this.errorInfo.getAdditionalDetails().put(name, new String[] { tempParseString }); - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, null); - } - - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java deleted file mode 100644 index 2da55c04def5d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; - -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RequestOptions; -import com.microsoft.windowsazure.services.core.storage.RequestResult; -import com.microsoft.windowsazure.services.core.storage.StorageException; - -/** - * RESERVED FOR INTERNAL USE. A base class which encapsulate the execution of a given storage operation. - * - * @param - * The service client type - * @param

- * The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc. - * @param - * The type of the expected result - */ -public abstract class StorageOperation { - - /** - * Holds a reference to a realized exception which occurred during execution. - */ - private StorageException exceptionReference; - - /** - * A flag to indicate a failure which did not result in an exceptin, i.e a 400 class status code. - */ - private boolean nonExceptionedRetryableFailure; - - /** - * The RequestOptions to use for the request. - */ - private RequestOptions requestOptions; - - /** - * Holds the result for the operation. - */ - private RequestResult result; - - /** - * Default Ctor. - */ - protected StorageOperation() { - // no op - } - - /** - * Initializes a new instance of the StorageOperation class. - * - * @param options - * the RequestOptions to use - */ - public StorageOperation(final RequestOptions options) { - this.setRequestOptions(options); - } - - /** - * Executes the operation. - * - * @param client - * a reference to the service client associated with the object being operated against - * @param parentObject - * a reference to the parent object of the operation, (i.e. CloudBlobContainer for Create) - * @param opContext - * an object used to track the execution of the operation - * @return the result from the operation - * @throws Exception - * an error which occurred during execution - */ - public abstract R execute(C client, P parentObject, OperationContext opContext) throws Exception; - - /** - * @return the exception - */ - public final StorageException getException() { - return this.exceptionReference; - } - - /** - * @return the requestOptions - */ - public final RequestOptions getRequestOptions() { - return this.requestOptions; - } - - /** - * @return the result - */ - public final RequestResult getResult() { - return this.result; - } - - /** - * Resets the operation status flags between operations. - */ - protected final void initialize() { - this.setResult(new RequestResult()); - this.setException(null); - this.setNonExceptionedRetryableFailure(false); - } - - /** - * @return the nonExceptionedRetryableFailure - */ - public final boolean isNonExceptionedRetryableFailure() { - return this.nonExceptionedRetryableFailure; - } - - /** - * Returns either the held exception from the operation if it is set, othwerwise the translated exception. - * - * @param request - * the reference to the HttpURLConnection for the operation. - * @param opContext - * an object used to track the execution of the operation - * @return the exception to throw. - */ - protected final StorageException materializeException(final HttpURLConnection request, - final OperationContext opContext) { - if (this.getException() != null) { - return this.getException(); - } - - return StorageException.translateException(request, null, opContext); - } - - /** - * @param exceptionReference - * the exception to set - */ - protected final void setException(final StorageException exceptionReference) { - this.exceptionReference = exceptionReference; - } - - /** - * @param nonExceptionedRetryableFailure - * the nonExceptionedRetryableFailure to set - */ - public final void setNonExceptionedRetryableFailure(final boolean nonExceptionedRetryableFailure) { - this.nonExceptionedRetryableFailure = nonExceptionedRetryableFailure; - } - - /** - * @param requestOptions - * the requestOptions to set - */ - protected final void setRequestOptions(final RequestOptions requestOptions) { - this.requestOptions = requestOptions; - } - - /** - * @param result - * the result to set - */ - public final void setResult(final RequestResult result) { - this.result = result; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java deleted file mode 100644 index 8c76b38cd2614..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.storage.utils.implementation; - -import java.net.HttpURLConnection; -import java.security.InvalidParameterException; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Provides an implementation of the Canonicalizer class for requests against Table Service - * under the Shared Key Lite authentication scheme. - */ -class TableLiteCanonicalizer extends Canonicalizer { - /** - * Constructs a canonicalized string for signing a request. - * - * @param conn - * the HttpURLConnection to canonicalize - * @param accountName - * the account name associated with the request - * @param contentLength - * the length of the content written to the outputstream in bytes, -1 if unknown - * @param opContext - * the OperationContext for the given request - * @return a canonicalized string. - * @throws StorageException - */ - @Override - protected String canonicalize(final HttpURLConnection conn, final String accountName, final Long contentLength, - final OperationContext opContext) throws StorageException { - if (contentLength < -1) { - throw new InvalidParameterException("ContentLength must be set to -1 or positive Long value"); - } - - final String dateString = Utility.getStandardHeaderValue(conn, Constants.HeaderConstants.DATE); - if (Utility.isNullOrEmpty(dateString)) { - throw new IllegalArgumentException( - "Canonicalization did not find a non empty x-ms-date header in the request. Please use a request with a valid x-ms-date header in RFC 123 format."); - } - - final StringBuilder canonicalizedString = new StringBuilder(dateString); - appendCanonicalizedElement(canonicalizedString, getCanonicalizedResourceLite(conn.getURL(), accountName)); - - return canonicalizedString.toString(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java deleted file mode 100644 index 10db79d098ce8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils; - -import java.util.Date; - -public interface DateFactory { - Date getDate(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java deleted file mode 100644 index 77e779fcf10b5..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils; - -import java.util.Date; - -public class DefaultDateFactory implements DateFactory { - public Date getDate() { - return new Date(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java deleted file mode 100644 index c9960912fb974..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils; - -import com.microsoft.windowsazure.services.core.Builder; - -public class Exports implements Builder.Exports { - public void register(Builder.Registry registry) { - registry.add(DateFactory.class, DefaultDateFactory.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java deleted file mode 100644 index 90210ac0e6254..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.ClientResponse.Status; -import com.sun.jersey.api.client.UniformInterfaceException; - -public class ServiceExceptionFactory { - - public static ServiceException process(String serviceName, ServiceException exception) { - Throwable cause = exception.getCause(); - - for (Throwable scan = cause; scan != null; scan = scan.getCause()) { - if (ServiceException.class.isAssignableFrom(scan.getClass())) { - return populate(exception, serviceName, (ServiceException) scan); - } - else if (UniformInterfaceException.class.isAssignableFrom(scan.getClass())) { - return populate(exception, serviceName, (UniformInterfaceException) scan); - } - } - - exception.setServiceName(serviceName); - - return exception; - } - - static ServiceException populate(ServiceException exception, String serviceName, UniformInterfaceException cause) { - exception.setServiceName(serviceName); - - if (cause != null) { - ClientResponse response = cause.getResponse(); - if (response != null) { - // Set status - Status status = response.getClientResponseStatus(); - if (status == null) { - status = Status.fromStatusCode(response.getStatus()); - } - if (status == null) { - exception.setHttpStatusCode(response.getStatus()); - } - else { - exception.setHttpStatusCode(status.getStatusCode()); - exception.setHttpReasonPhrase(status.getReasonPhrase()); - } - - // Set raw response body - if (response.hasEntity()) { - try { - String body = response.getEntity(String.class); - exception.setRawResponseBody(body); - } - catch (Exception e) { - // Skip exceptions as getting the response body as a string is a best effort thing - } - } - } - } - return exception; - } - - static ServiceException populate(ServiceException exception, String serviceName, ServiceException cause) { - exception.setServiceName(cause.getServiceName()); - exception.setHttpStatusCode(cause.getHttpStatusCode()); - exception.setHttpReasonPhrase(cause.getHttpReasonPhrase()); - exception.setErrorCode(cause.getErrorCode()); - exception.setErrorMessage(cause.getErrorMessage()); - exception.setRawResponseBody(cause.getRawResponseBody()); - exception.setErrorValues(cause.getErrorValues()); - return exception; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java deleted file mode 100644 index 7a28be44bed93..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import com.sun.jersey.core.util.Base64; - -/* - * JAXB adapter for a Base64 encoded string element - */ -public class Base64StringAdapter extends XmlAdapter { - - @Override - public String marshal(String arg0) throws Exception { - return new String(Base64.encode(arg0)); - } - - @Override - public String unmarshal(String arg0) throws Exception { - return Base64.base64Decode(arg0); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java deleted file mode 100644 index f486cbbf14015..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import java.io.InputStream; -import java.net.URI; -import java.util.Map; - -import javax.ws.rs.core.MultivaluedMap; - -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.ServiceFilter.Request; -import com.microsoft.windowsazure.services.core.ServiceFilter.Response; -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; - -public class ClientFilterAdapter extends ClientFilter { - ServiceFilter filter; - - public ClientFilterAdapter(ServiceFilter filter) { - this.filter = filter; - } - - @Override - public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { - - final ClientRequest cr = clientRequest; - try { - Response resp = filter.handle(new ServiceFilterRequest(clientRequest), new ServiceFilter.Next() { - public Response handle(Request request) { - return new ServiceFilterResponse(getNext().handle(cr)); - } - }); - - return ((ServiceFilterResponse) resp).clientResponse; - } - catch (Exception e) { - throw new ClientHandlerException(e); - } - } -} - -class ServiceFilterRequest implements ServiceFilter.Request { - ClientRequest clientRequest; - - public ServiceFilterRequest(ClientRequest clientRequest) { - this.clientRequest = clientRequest; - } - - public Map getProperties() { - return clientRequest.getProperties(); - } - - public void setProperties(Map properties) { - clientRequest.setProperties(properties); - } - - public URI getURI() { - return clientRequest.getURI(); - } - - public void setURI(URI uri) { - clientRequest.setURI(uri); - } - - public String getMethod() { - return clientRequest.getMethod(); - } - - public void setMethod(String method) { - clientRequest.setMethod(method); - } - - public Object getEntity() { - return clientRequest.getEntity(); - } - - public void setEntity(Object entity) { - clientRequest.setEntity(entity); - } - - public MultivaluedMap getHeaders() { - return clientRequest.getHeaders(); - } - -} - -class ServiceFilterResponse implements ServiceFilter.Response { - ClientResponse clientResponse; - - public ServiceFilterResponse(ClientResponse clientResponse) { - this.clientResponse = clientResponse; - } - - public Map getProperties() { - return clientResponse.getProperties(); - } - - public int getStatus() { - return clientResponse.getStatus(); - } - - public void setStatus(int status) { - clientResponse.setStatus(status); - } - - public MultivaluedMap getHeaders() { - return clientResponse.getHeaders(); - } - - public boolean hasEntity() { - return clientResponse.hasEntity(); - } - - public InputStream getEntityInputStream() { - return clientResponse.getEntityInputStream(); - } - - public void setEntityInputStream(InputStream entity) { - clientResponse.setEntityInputStream(entity); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java deleted file mode 100644 index c3366788b5de7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import com.sun.jersey.api.client.ClientRequest; - -public interface EntityStreamingListener { - /** - * This method is called just before the entity is streamed to the underlying connection. This is the last chance - * for filters to inspect and modify the headers of the client request if necessary. - * - * @param clientRequest - * The client request - */ - void onBeforeStreamingEntity(ClientRequest clientRequest); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java deleted file mode 100644 index a562b7c2122e7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import java.util.Map; -import java.util.Map.Entry; - -import com.microsoft.windowsazure.services.core.Builder; -import com.microsoft.windowsazure.services.core.Builder.Registry; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - -public class Exports implements Builder.Exports { - - public void register(Registry registry) { - registry.add(new Builder.Factory() { - public ClientConfig create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = new DefaultClientConfig(); - for (Entry entry : properties.entrySet()) { - clientConfig.getProperties().put(entry.getKey(), entry.getValue()); - } - return clientConfig; - } - }); - - registry.add(new Builder.Factory() { - public Client create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - Client client = Client.create(clientConfig); - return client; - } - }); - - registry.add(new Builder.Factory() { - public HttpURLConnectionClient create(String profile, Builder builder, Map properties) { - ClientConfig clientConfig = (ClientConfig) properties.get("ClientConfig"); - HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); - //client.addFilter(new LoggingFilter()); - return client; - } - }); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java deleted file mode 100644 index 9b7ca1dd32482..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; - -public class HttpURLConnectionClient extends Client { - private final HttpURLConnectionClientHandler rootHandler; - - public HttpURLConnectionClient(HttpURLConnectionClientHandler handler, ClientConfig config) { - super(handler, config); - this.rootHandler = handler; - } - - public static HttpURLConnectionClient create(ClientConfig config) { - return new HttpURLConnectionClient(new HttpURLConnectionClientHandler(), config); - } - - public HttpURLConnectionClientHandler getRootHandler() { - return rootHandler; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java deleted file mode 100644 index 0610eb8d7bc94..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java +++ /dev/null @@ -1,299 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.ProtocolException; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.core.MultivaluedMap; - -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers.EnumCommaStringBuilder; -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.CommittingOutputStream; -import com.sun.jersey.api.client.TerminatingClientHandler; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.core.header.InBoundHeaders; - -public class HttpURLConnectionClientHandler extends TerminatingClientHandler { - /** - * Empty "no-op" listener if none registered - */ - private static final EntityStreamingListener EMPTY_STREAMING_LISTENER = new EntityStreamingListener() { - public void onBeforeStreamingEntity(ClientRequest clientRequest) { - } - }; - - /** - * OutputStream used for buffering entity body when "Content-Length" is not known in advance. - */ - private final class BufferingOutputStream extends OutputStream { - private final ByteArrayOutputStream outputStream; - private final HttpURLConnection urlConnection; - private final ClientRequest clientRequest; - private final EntityStreamingListener entityStreamingListener; - private boolean closed; - - private BufferingOutputStream(HttpURLConnection urlConnection, ClientRequest clientRequest, - EntityStreamingListener entityStreamingListener) { - this.outputStream = new ByteArrayOutputStream(); - this.urlConnection = urlConnection; - this.clientRequest = clientRequest; - this.entityStreamingListener = entityStreamingListener; - } - - @Override - public void close() throws IOException { - outputStream.close(); - - if (!closed) { - closed = true; - - // Give the listener a last change to modify headers now that the content length is known - setContentLengthHeader(clientRequest, outputStream.size()); - entityStreamingListener.onBeforeStreamingEntity(clientRequest); - - // Write headers, then entity to the http connection. - setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); - - // Since we buffered the entity and we know the content size, we might as well - // use the "fixed length" streaming mode of HttpURLConnection to stream - // the buffer directly. - urlConnection.setFixedLengthStreamingMode(outputStream.size()); - OutputStream httpOutputStream = urlConnection.getOutputStream(); - outputStream.writeTo(httpOutputStream); - httpOutputStream.flush(); - httpOutputStream.close(); - } - } - - @Override - public void flush() throws IOException { - outputStream.flush(); - } - - @Override - public void write(byte[] b, int off, int len) { - outputStream.write(b, off, len); - } - - @Override - public void write(byte[] b) throws IOException { - outputStream.write(b); - } - - @Override - public void write(int b) { - outputStream.write(b); - } - } - - /** - * OutputStream used for directly streaming entity to url connection stream. Headers are written just before sending - * the first bytes to the output stream. - */ - private final class StreamingOutputStream extends CommittingOutputStream { - private final HttpURLConnection urlConnection; - private final ClientRequest clientRequest; - - private StreamingOutputStream(HttpURLConnection urlConnection, ClientRequest clientRequest) { - this.urlConnection = urlConnection; - this.clientRequest = clientRequest; - } - - @Override - protected OutputStream getOutputStream() throws IOException { - return urlConnection.getOutputStream(); - } - - @Override - public void commit() throws IOException { - setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); - } - } - - /** - * Simple response implementation around an HttpURLConnection response - */ - private final class URLConnectionResponse extends ClientResponse { - private final String method; - private final HttpURLConnection urlConnection; - - URLConnectionResponse(int status, InBoundHeaders headers, InputStream entity, String method, - HttpURLConnection urlConnection) { - super(status, headers, entity, getMessageBodyWorkers()); - this.method = method; - this.urlConnection = urlConnection; - } - - @Override - public boolean hasEntity() { - if (method.equals("HEAD") || getEntityInputStream() == null) - return false; - - // Length "-1" means "unknown" - int length = urlConnection.getContentLength(); - return length > 0 || length == -1; - } - - @Override - public String toString() { - return urlConnection.getRequestMethod() + " " + urlConnection.getURL() + " returned a response status of " - + this.getStatus() + " " + this.getClientResponseStatus(); - } - } - - public ClientResponse handle(final ClientRequest ro) throws ClientHandlerException { - try { - return doHandle(ro); - } - catch (Exception e) { - throw new ClientHandlerException(e); - } - } - - private ClientResponse doHandle(final ClientRequest clientRequest) throws IOException, MalformedURLException, - ProtocolException { - final HttpURLConnection urlConnection = (HttpURLConnection) clientRequest.getURI().toURL().openConnection(); - final EntityStreamingListener entityStreamingListener = getEntityStreamingListener(clientRequest); - - urlConnection.setRequestMethod(clientRequest.getMethod()); - - // Write the request headers - setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); - - // Write the entity (if any) - Object entity = clientRequest.getEntity(); - - // If no entity and "PUT method, force an empty entity to force the underlying - // connection to set the "Content-Length" header to 0. - // This is needed because some web servers require a "Content-Length" field for - // all PUT method calls (unless chunked encoding is used). - if (entity == null && "PUT".equals(clientRequest.getMethod())) { - entity = new byte[0]; - clientRequest.setEntity(entity); - } - - // Send headers and entity on the wire - if (entity != null) { - urlConnection.setDoOutput(true); - - writeRequestEntity(clientRequest, new RequestEntityWriterListener() { - private boolean inStreamingMode; - - public void onRequestEntitySize(long size) { - if (size != -1 && size < Integer.MAX_VALUE) { - inStreamingMode = true; - setContentLengthHeader(clientRequest, (int) size); - entityStreamingListener.onBeforeStreamingEntity(clientRequest); - - urlConnection.setFixedLengthStreamingMode((int) size); - } - else { - Integer chunkedEncodingSize = (Integer) clientRequest.getProperties().get( - ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE); - if (chunkedEncodingSize != null) { - inStreamingMode = true; - entityStreamingListener.onBeforeStreamingEntity(clientRequest); - - urlConnection.setChunkedStreamingMode(chunkedEncodingSize); - } - } - } - - public OutputStream onGetOutputStream() throws IOException { - if (inStreamingMode) - return new StreamingOutputStream(urlConnection, clientRequest); - else - return new BufferingOutputStream(urlConnection, clientRequest, entityStreamingListener); - } - }); - } - else { - entityStreamingListener.onBeforeStreamingEntity(clientRequest); - setURLConnectionHeaders(clientRequest.getHeaders(), urlConnection); - } - - // Return the in-bound response - return new URLConnectionResponse(urlConnection.getResponseCode(), getInBoundHeaders(urlConnection), - getInputStream(urlConnection), clientRequest.getMethod(), urlConnection); - } - - private EntityStreamingListener getEntityStreamingListener(final ClientRequest clientRequest) { - EntityStreamingListener result = (EntityStreamingListener) clientRequest.getProperties().get( - EntityStreamingListener.class.getName()); - - if (result != null) - return result; - - return EMPTY_STREAMING_LISTENER; - } - - private void setContentLengthHeader(ClientRequest clientRequest, int size) { - // Skip if already set - if (clientRequest.getHeaders().getFirst("Content-Length") != null) - return; - - // Skip if size is unknown - if (size < 0) - return; - - clientRequest.getHeaders().putSingle("Content-Length", size); - } - - private void setURLConnectionHeaders(MultivaluedMap headers, HttpURLConnection urlConnection) { - for (Map.Entry> e : headers.entrySet()) { - List vs = e.getValue(); - if (vs.size() == 1) { - urlConnection.setRequestProperty(e.getKey(), ClientRequest.getHeaderValue(vs.get(0))); - } - else { - EnumCommaStringBuilder sb = new EnumCommaStringBuilder(); - for (Object v : e.getValue()) { - sb.add(ClientRequest.getHeaderValue(v)); - } - urlConnection.setRequestProperty(e.getKey(), sb.toString()); - } - } - } - - private InBoundHeaders getInBoundHeaders(HttpURLConnection urlConnection) { - InBoundHeaders headers = new InBoundHeaders(); - for (Map.Entry> e : urlConnection.getHeaderFields().entrySet()) { - if (e.getKey() != null) - headers.put(e.getKey(), e.getValue()); - } - return headers; - } - - private InputStream getInputStream(HttpURLConnection urlConnection) throws IOException { - if (urlConnection.getResponseCode() < 300) { - return urlConnection.getInputStream(); - } - else { - InputStream ein = urlConnection.getErrorStream(); - return (ein != null) ? ein : new ByteArrayInputStream(new byte[0]); - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java deleted file mode 100644 index 95fce9e9dbeb2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils.pipeline; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -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; -import com.sun.jersey.api.client.WebResource.Builder; - -public class PipelineHelpers { - public static void ThrowIfError(ClientResponse r) { - if (r.getStatus() >= 300) { - throw new UniformInterfaceException(r); - } - } - - public static class EnumCommaStringBuilder { - private final StringBuilder sb = new StringBuilder(); - - public void add(String representation) { - if (sb.length() > 0) { - sb.append(","); - } - sb.append(representation); - } - - public void addValue(boolean value, String representation) { - if (value) { - add(representation); - } - } - - public String getValue() { - if (sb.length() == 0) - return null; - 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/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java deleted file mode 100644 index 14850f379862e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/Exports.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -import com.microsoft.windowsazure.services.core.Builder; -import com.microsoft.windowsazure.services.queue.implementation.QueueExceptionProcessor; -import com.microsoft.windowsazure.services.queue.implementation.QueueRestProxy; -import com.microsoft.windowsazure.services.queue.implementation.SharedKeyFilter; -import com.microsoft.windowsazure.services.queue.implementation.SharedKeyLiteFilter; - -public class Exports implements Builder.Exports { - @Override - public void register(Builder.Registry registry) { - registry.add(QueueContract.class, QueueExceptionProcessor.class); - registry.add(QueueExceptionProcessor.class); - registry.add(QueueRestProxy.class); - registry.add(SharedKeyLiteFilter.class); - registry.add(SharedKeyFilter.class); - } -} 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 deleted file mode 100644 index 165df11b234b0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueConfiguration.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -public class QueueConfiguration { - public final static String ACCOUNT_NAME = "queue.accountName"; - public final static String ACCOUNT_KEY = "queue.accountKey"; - public final static String URI = "queue.uri"; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java deleted file mode 100644 index 62a6e2b5fb801..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -import java.util.HashMap; - -import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; -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; -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 QueueContract extends FilterableService { - GetServicePropertiesResult getServiceProperties() throws ServiceException; - - GetServicePropertiesResult getServiceProperties(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 messageText) throws ServiceException; - - 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, 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; - - PeekMessagesResult peekMessages(String queue) throws ServiceException; - - PeekMessagesResult peekMessages(String queue, PeekMessagesOptions 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/QueueService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java deleted file mode 100644 index c457b6b34d39f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueService.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -import com.microsoft.windowsazure.services.core.Configuration; - -public class QueueService { - private QueueService() { - } - - public static QueueContract create() { - return create(null, Configuration.getInstance()); - } - - public static QueueContract create(Configuration config) { - return create(null, config); - } - - public static QueueContract create(String profile) { - return create(profile, Configuration.getInstance()); - } - - public static QueueContract create(String profile, Configuration config) { - return config.create(profile, QueueContract.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java deleted file mode 100644 index 33b8131623496..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ /dev/null @@ -1,1354 +0,0 @@ -/* - * CloudQueue.java - * - * Copyright (c) 2011 Microsoft. All rights reserved. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; - -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation; -import com.microsoft.windowsazure.services.core.storage.utils.PathUtility; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * This class represents a queue in the Windows Azure Queue service. - */ -public final class CloudQueue { - - /** - * Gets the first message from a list of queue messages, if any. - * - * @param messages - * The Iterable collection of {@link CloudQueueMessage} objects to get the first message - * from. - * - * @return The first {@link CloudQueueMessage} from the list of queue messages, or null if the list is - * empty. - */ - static CloudQueueMessage getFirstOrNull(final Iterable messages) { - for (final CloudQueueMessage m : messages) { - return m; - } - - return null; - } - - /** - * The name of the queue. - */ - private String name; - - /** - * The absolute URI of the queue. - */ - private final URI uri; - - /** - * A reference to the queue's associated service client. - */ - private final CloudQueueClient queueServiceClient; - - /** - * The queue's Metadata collection. - */ - private HashMap metadata; - - /** - * The queue's approximate message count, as reported by the server. - */ - private long approximateMessageCount; - - /** - * The CloudQueue class using the specified address and client. - * - * @param queueAddress - * A String that represents either the absolute URI to the queue, or the queue name. - * @param client - * A {@link CloudQueueClient} object that represents the associated service client, and that specifies - * the endpoint for the Queue service. - * - * @throws URISyntaxException - * If the resource URI is invalid. - */ - public CloudQueue(final String queueAddress, final CloudQueueClient client) throws URISyntaxException { - this(PathUtility.appendPathToUri(client.getEndpoint(), queueAddress), client); - } - - /** - * Creates an instance of the CloudQueue class using the specified queue URI and client. - * - * @param uri - * A java.net.URI object that represents the absolute URI of the queue. - * @param client - * A {@link CloudQueueClient} object that represents the associated service client, and that specifies - * the endpoint for the Queue service. - */ - public CloudQueue(final URI uri, final CloudQueueClient client) { - this.uri = uri; - this.name = PathUtility.getQueueNameFromUri(uri, client.isUsePathStyleUris()); - this.queueServiceClient = client; - this.shouldEncodeMessage = true; - } - - /** - * Adds a message to the back of the queue with the default options. - * - * @param message - * A {@link CloudQueueMessage} object that specifies the message to add. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void addMessage(final CloudQueueMessage message) throws StorageException { - this.addMessage(message, 0, 0, null, null); - } - - /** - * Adds a message to the back of the queue with the specified options. - * - * @param message - * A {@link CloudQueueMessage} object that specifies the message to add. - * - * @param timeToLiveInSeconds - * The maximum time to allow the message to be in the queue. A value of zero will set the time-to-live to - * the service default value of seven days. - * - * @param initialVisibilityDelayInSeconds - * The length of time during which the message will be invisible, starting when it is added to the queue, - * or 0 to make the message visible immediately. This value must be greater than or equal to zero and - * less than or equal to the time-to-live value. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void addMessage(final CloudQueueMessage message, final int timeToLiveInSeconds, - final int initialVisibilityDelayInSeconds, QueueRequestOptions options, OperationContext opContext) - throws StorageException { - Utility.assertNotNull("message", message); - Utility.assertNotNull("messageContent", message.getMessageContentAsByte()); - Utility.assertInBounds("timeToLiveInSeconds", timeToLiveInSeconds, 0, - QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); - - final int realTimeToLiveInSeconds = timeToLiveInSeconds == 0 ? QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS - : timeToLiveInSeconds; - Utility.assertInBounds("initialVisibilityDelayInSeconds", initialVisibilityDelayInSeconds, 0, - realTimeToLiveInSeconds - 1); - - final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.putMessage(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), initialVisibilityDelayInSeconds, - timeToLiveInSeconds, opContext); - - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Clears all messages from the queue, using the default request options. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void clear() throws StorageException { - this.clear(null, null); - } - - /** - * Clears all messages from the queue, using the specified request options and operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void clear(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.clearMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Creates the queue in the storage service with default request options. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void create() throws StorageException { - this.create(null, null); - } - - /** - * Creates the queue in the storage service using the specified request options and operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void create(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_CREATED - && this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Creates the queue in the storage service using default request options if it does not already exist. - * - * @return A value of true if the queue is created in the storage service, otherwise false - * . - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean createIfNotExist() throws StorageException { - return this.createIfNotExist(null, null); - } - - /** - * Creates the queue in the storage service with the specified request options and operation context if it does not - * already exist. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A value of true if the queue is created in the storage service, otherwise false - * . - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean createIfNotExist(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.create(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CREATED) { - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return false; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) { - final StorageException potentialConflictException = StorageException.translateException(request, - null, opContext); - - StorageExtendedErrorInformation extendedInfo = potentialConflictException - .getExtendedErrorInformation(); - if (extendedInfo == null) { - // If we can't validate the error then the error must be surfaced to the user. - throw potentialConflictException; - } - - if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.QUEUE_ALREADY_EXISTS)) { - this.setException(potentialConflictException); - this.setNonExceptionedRetryableFailure(true); - } - } - else { - this.setNonExceptionedRetryableFailure(true); - } - - return false; - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Deletes the queue from the storage service. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void delete() throws StorageException { - this.delete(null, null); - } - - /** - * Deletes the queue from the storage service, using the specified request options and operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void delete(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - - } - - /** - * Deletes the queue from the storage service if it exists. - * - * @return A value of true if the queue existed in the storage service and has been deleted, otherwise - * false. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean deleteIfExists() throws StorageException { - return this.deleteIfExists(null, null); - } - - /** - * Deletes the queue from the storage service using the specified request options and operation context, if it - * exists. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return A value of true if the queue existed in the storage service and has been deleted, otherwise - * false. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean deleteIfExists(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.delete(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NO_CONTENT) { - return true; - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return false; - } - else { - this.setNonExceptionedRetryableFailure(true); - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - - } - - /** - * Deletes the specified message from the queue. - * - * @param message - * A {@link CloudQueueMessage} object that specifies the message to delete. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void deleteMessage(final CloudQueueMessage message) throws StorageException { - this.deleteMessage(message, null, null); - } - - /** - * Deletes the specified message from the queue, using the specified request options and operation context. - * - * @param message - * A {@link CloudQueueMessage} object that specifies the message to delete. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void deleteMessage(final CloudQueueMessage message, QueueRequestOptions options, OperationContext opContext) - throws StorageException { - Utility.assertNotNull("message", message); - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final String messageId = message.getId(); - final String messagePopReceipt = message.getPopReceipt(); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.deleteMessage( - queue.getIndividualMessageAddress(messageId), - this.getRequestOptions().getTimeoutIntervalInMs(), messagePopReceipt, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Downloads the queue's metadata and approximate message count value. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void downloadAttributes() throws StorageException { - this.downloadAttributes(null, null); - } - - /** - * Downloads the queue's metadata and approximate message count value, using the specified request options and - * operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueue}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void downloadAttributes(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - queue.metadata = BaseResponse.getMetadata(request); - queue.approximateMessageCount = QueueResponse.getApproximateMessageCount(request); - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Returns a value that indicates whether the queue exists in the storage service. - * - * @return true if the queue exists in the storage service, otherwise false. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean exists() throws StorageException { - return this.exists(null, null); - } - - /** - * Returns a value that indicates whether the queue exists in the storage service, using the specified request - * options and operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return true if the queue exists in the storage service, otherwise false. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public boolean exists(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Boolean execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - final HttpURLConnection request = QueueRequest.downloadAttributes(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_OK) { - return Boolean.valueOf(true); - } - else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Boolean.valueOf(false); - } - else { - this.setNonExceptionedRetryableFailure(true); - // return false instead of null to avoid SCA issues - return false; - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Gets the approximate messages count of the queue. This value is initialized by a request to - * {@link #downloadAttributes} and represents the approximate message count when that request completed. - * - * @return A Long object that represents the approximate messages count of the queue. - */ - public long getApproximateMessageCount() { - return this.approximateMessageCount; - } - - /** - * Get a single message request (Used internally only). - * - * @return The URI for a single message request. - * - * @throws URISyntaxException - * If the resource URI is invalid. - */ - URI getIndividualMessageAddress(final String messageId) throws URISyntaxException { - return PathUtility.appendPathToUri(this.messageRequestAddress, messageId); - } - - /** - * Get the message request base address (Used internally only). - * - * @return The message request URI. - * - * @throws URISyntaxException - * If the resource URI is invalid. - */ - URI getMessageRequestAddress() throws URISyntaxException { - if (this.messageRequestAddress == null) { - this.messageRequestAddress = PathUtility.appendPathToUri(this.uri, QueueConstants.MESSAGES); - } - - return this.messageRequestAddress; - } - - /** - * Gets the metadata collection for the queue as stored in this CloudQueue object. This value is - * initialized with the metadata from the queue by a call to {@link #downloadAttributes}, and is set on the queue - * with a call to {@link #uploadMetadata}. - * - * @return A java.util.HashMap object that represents the metadata for the queue. - */ - public HashMap getMetadata() { - return this.metadata; - } - - /** - * Gets the name of the queue. - * - * @return A String object that represents the name of the queue. - */ - public String getName() { - return this.name; - } - - /** - * Gets the queue service client associated with this queue. - * - * @return A {@link CloudQueueClient} object that represents the service client associated with this queue. - */ - public CloudQueueClient getServiceClient() { - return this.queueServiceClient; - } - - /** - * Gets the value indicating whether the message should be base-64 encoded. - * - * @return A Boolean that represents whether the message should be base-64 encoded. - */ - public boolean getShouldEncodeMessage() { - return this.shouldEncodeMessage; - } - - /** - * Gets the absolute URI for this queue. - * - * @return A java.net.URI object that represents the URI for this queue. - */ - public URI getUri() { - return this.uri; - } - - /** - * Peeks a message from the queue. A peek request retrieves a message from the front of the queue without changing - * its visibility. - * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public CloudQueueMessage peekMessage() throws StorageException { - return this.peekMessage(null, null); - } - - /** - * Peeks a message from the queue, using the specified request options and operation context. A peek request - * retrieves a message from the front of the queue without changing its visibility. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An {@link CloudQueueMessage} object that represents the requested message from the queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public CloudQueueMessage peekMessage(final QueueRequestOptions options, final OperationContext opContext) - throws StorageException { - return getFirstOrNull(this.peekMessages(1, null, null)); - } - - /** - * Peeks a specified number of messages from the queue. A peek request retrieves messages from the front of the - * queue without changing their visibility. - * - * @param numberOfMessages - * The number of messages to retrieve. - * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the requested messages from - * the queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public Iterable peekMessages(final int numberOfMessages) throws StorageException { - return this.peekMessages(numberOfMessages, null, null); - } - - /** - * Peeks a set of messages from the queue, using the specified request options and operation context. A peek request - * retrieves messages from the front of the queue without changing their visibility. - * - * @param numberOfMessages - * The number of messages to retrieve. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the requested messages from - * the queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public Iterable peekMessages(final int numberOfMessages, QueueRequestOptions options, - OperationContext opContext) throws StorageException { - Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation> impl = new StorageOperation>( - options) { - - @Override - public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = QueueRequest.peekMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Retrieves a message from the front of the queue using the default request options. This operation marks the - * retrieved message as invisible in the queue for the default visibility timeout period. - * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public CloudQueueMessage retrieveMessage() throws StorageException { - return this.retrieveMessage(QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, null, null); - } - - /** - * Retrieves a message from the front of the queue, using the specified request options and operation context. This - * operation marks the retrieved message as invisible in the queue for the specified visibility timeout period. - * - * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout for the message, in seconds. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An {@link CloudQueueMessage} object that represents a message in this queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public CloudQueueMessage retrieveMessage(final int visibilityTimeoutInSeconds, final QueueRequestOptions options, - final OperationContext opContext) throws StorageException { - return getFirstOrNull(this.retrieveMessages(1, visibilityTimeoutInSeconds, null, null)); - } - - /** - * Retrieves the specified number of messages from the front of the queue using the default request options. This - * operation marks the retrieved messages as invisible in the queue for the default visibility timeout period. - * - * @param numberOfMessages - * The number of messages to retrieve. - * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the retrieved messages from - * the queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public Iterable retrieveMessages(final int numberOfMessages) throws StorageException { - return this.retrieveMessages(numberOfMessages, QueueConstants.DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS, - null, null); - } - - /** - * Retrieves the specified number of messages from the front of the queue using the specified request options and - * operation context. This operation marks the retrieved messages as invisible in the queue for the default - * visibility timeout period. - * - * @param numberOfMessages - * The number of messages to retrieve. - * - * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout for the retrieved messages, in seconds. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @return An enumerable collection of {@link CloudQueueMessage} objects that represents the messages retrieved from - * the queue. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public Iterable retrieveMessages(final int numberOfMessages, - final int visibilityTimeoutInSeconds, QueueRequestOptions options, OperationContext opContext) - throws StorageException { - Utility.assertInBounds("numberOfMessages", numberOfMessages, 1, QueueConstants.MAX_NUMBER_OF_MESSAGES_TO_PEEK); - Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, - QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation> impl = new StorageOperation>( - options) { - - @Override - public ArrayList execute(final CloudQueueClient client, final CloudQueue queue, - final OperationContext opContext) throws Exception { - - final HttpURLConnection request = QueueRequest.retrieveMessages(queue.getMessageRequestAddress(), this - .getRequestOptions().getTimeoutIntervalInMs(), numberOfMessages, visibilityTimeoutInSeconds, - opContext); - - client.getCredentials().signRequest(request, -1L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - else { - return QueueDeserializationHelper.readMessages(request.getInputStream(), queue.shouldEncodeMessage); - } - } - }; - - return ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Sets the metadata collection of name-value pairs to be set on the queue with an {@link #uploadMetadata} call. - * This collection will overwrite any existing queue metadata. If this is set to an empty collection, the queue - * metadata will be cleared on an {@link #uploadMetadata} call. - * - * @param metadata - * A java.util.HashMap object that represents the metadata being assigned to the queue. - */ - public void setMetadata(final HashMap metadata) { - this.metadata = metadata; - } - - /** - * Sets the flag indicating whether the message should be base-64 encoded. - * - * @param shouldEncodeMessage - * The value indicates whether the message should be base-64 encoded. - */ - public void setShouldEncodeMessage(final boolean shouldEncodeMessage) { - this.shouldEncodeMessage = shouldEncodeMessage; - } - - /** - * Sets the name of the queue. - * - * @param name - * A String that represents the name being assigned to the queue. - */ - void setName(final String name) { - this.name = name; - } - - /** - * Updates the specified message in the queue with a new visibility timeout value in seconds. - * - * @param message - * The {@link CloudQueueMessage} to update in the queue. - * - * @param visibilityTimeoutInSeconds - * Specifies the new visibility timeout for the message, in seconds. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds) - throws StorageException { - this.updateMessage(message, visibilityTimeoutInSeconds, EnumSet.of(MessageUpdateFields.VISIBILITY), null, null); - } - - /** - * Updates a message in the queue, using the specified request options and operation context. - * - * @param message - * The {@link CloudQueueMessage} to update in the queue. - * - * @param visibilityTimeoutInSeconds - * Specifies the new visibility timeout for the message, in seconds. - * - * @param messageUpdateFields - * An EnumSet of {@link MessageUpdateFields} values that specifies which parts of the - * message are to be updated. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void updateMessage(final CloudQueueMessage message, final int visibilityTimeoutInSeconds, - final EnumSet messageUpdateFields, QueueRequestOptions options, - OperationContext opContext) throws StorageException { - Utility.assertNotNull("message", message); - Utility.assertNotNullOrEmpty("messageId", message.id); - Utility.assertNotNullOrEmpty("popReceipt", message.popReceipt); - - Utility.assertInBounds("visibilityTimeoutInSeconds", visibilityTimeoutInSeconds, 0, - QueueConstants.MAX_TIME_TO_LIVE_IN_SECONDS); - - final String stringToSend = message.getMessageContentForTransfer(this.shouldEncodeMessage); - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.updateMessage(queue.getIndividualMessageAddress(message - .getId()), this.getRequestOptions().getTimeoutIntervalInMs(), message.getPopReceipt(), - visibilityTimeoutInSeconds, opContext); - - if (messageUpdateFields.contains(MessageUpdateFields.CONTENT)) { - final byte[] messageBytes = QueueRequest.generateMessageRequestBody(stringToSend); - - client.getCredentials().signRequest(request, messageBytes.length); - final OutputStream outStreamRef = request.getOutputStream(); - outStreamRef.write(messageBytes); - } - else { - request.setFixedLengthStreamingMode(0); - client.getCredentials().signRequest(request, 0L); - } - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - return null; - } - - message.popReceipt = request.getHeaderField("x-ms-popreceipt"); - message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(request - .getHeaderField("x-ms-time-next-visible")); - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - } - - /** - * Uploads the metadata in the CloudQueue object to the queue, using the default request options. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void uploadMetadata() throws StorageException { - this.uploadMetadata(null, null); - } - - /** - * Uploads the metadata in the CloudQueue object to the queue, using the specified request options and - * operation context. - * - * @param options - * A {@link QueueRequestOptions} object that specifies any additional options for the request. Specifying - * null will use the default request options from the associated service client ( - * {@link CloudQueueClient}). - * - * @param opContext - * An {@link OperationContext} object that represents the context for the current operation. This object - * is used to track requests to the storage service, and to provide additional runtime information about - * the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public void uploadMetadata(QueueRequestOptions options, OperationContext opContext) throws StorageException { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this.queueServiceClient); - - final StorageOperation impl = new StorageOperation( - options) { - - @Override - public Void execute(final CloudQueueClient client, final CloudQueue queue, final OperationContext opContext) - throws Exception { - - final HttpURLConnection request = QueueRequest.setMetadata(queue.uri, this.getRequestOptions() - .getTimeoutIntervalInMs(), opContext); - - QueueRequest.addMetadata(request, queue.metadata, opContext); - client.getCredentials().signRequest(request, 0L); - - this.setResult(ExecutionEngine.processRequest(request, opContext)); - - if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_NO_CONTENT) { - this.setNonExceptionedRetryableFailure(true); - } - - return null; - } - }; - - ExecutionEngine.executeWithRetry(this.queueServiceClient, this, impl, options.getRetryPolicyFactory(), - opContext); - - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java deleted file mode 100644 index 71fc78af065bf..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ /dev/null @@ -1,402 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.InvalidKeyException; - -import javax.xml.stream.XMLStreamException; - -import com.microsoft.windowsazure.services.blob.client.CloudBlobClient; -import com.microsoft.windowsazure.services.core.storage.DoesServiceRequest; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.RequestOptions; -import com.microsoft.windowsazure.services.core.storage.ResultContinuation; -import com.microsoft.windowsazure.services.core.storage.ResultContinuationType; -import com.microsoft.windowsazure.services.core.storage.ResultSegment; -import com.microsoft.windowsazure.services.core.storage.ServiceClient; -import com.microsoft.windowsazure.services.core.storage.ServiceProperties; -import com.microsoft.windowsazure.services.core.storage.StorageCredentials; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.LazySegmentedIterator; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.SegmentedStorageOperation; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageOperation; - -/** - * Provides a service client for accessing the Windows Azure Queue service. - */ -public final class CloudQueueClient extends ServiceClient { - - /** - * Initializes a new instance of the CloudQueueClient class - * using the specified Queue service endpoint and account credentials. - * - * @param baseUri - * The Queue service endpoint to use to create the client - * @param credentials - * The account credentials. - */ - public CloudQueueClient(final URI baseUri, final StorageCredentials credentials) { - super(baseUri, credentials); - this.setTimeoutInMs(QueueConstants.DEFAULT_QUEUE_CLIENT_TIMEOUT_IN_MS); - - if (credentials == null) { - throw new IllegalArgumentException("StorageCredentials can't be null for the queue service."); - } - } - - /** - * Gets a {@link CloudQueue} object that represents the storage service - * queue for the specified address. - * - * @param queueAddress - * A String that represents the name of the queue, - * or the absolute URI to the queue. - * - * @return A {@link CloudQueue} object that represents a reference to the - * queue. - * - * @throws URISyntaxException - * If the resource URI is invalid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public CloudQueue getQueueReference(final String queueAddress) throws URISyntaxException, StorageException { - Utility.assertNotNullOrEmpty("queueAddress", queueAddress); - return new CloudQueue(queueAddress, this); - } - - /** - * Gets an iterable collection of queues for this queue service client. - * - * @return An iterable collection of {@link CloudQueue} objects that - * represent the queues in this client. - */ - @DoesServiceRequest - public Iterable listQueues() { - return this.listQueues(null, QueueListingDetails.NONE, null, null); - } - - /** - * Returns an iterable collection of queues whose names begin with the - * specified prefix in this Queue service client. - * - * @param prefix - * A String that represents the queue name prefix. - * - * @return An iterable collection of {@link CloudQueue} objects that - * represent the queues in this client whose names begin with the - * specified prefix. - */ - @DoesServiceRequest - public Iterable listQueues(final String prefix) { - return this.listQueues(prefix, QueueListingDetails.NONE, null, null); - } - - /** - * Returns an iterable collection of queues whose names begin with the - * specified prefix for this Queue service client, using the specified - * details setting, request options, and operation context. - * - * @param prefix - * A String that represents the queue name prefix. - * @param detailsIncluded - * A {@link QueueListingDetails} value that indicates whether - * queue metadata will be returned. - * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueue}). - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An iterable collection of {@link CloudQueue} objects that - * represents the specified queues for this client. - */ - @DoesServiceRequest - public Iterable listQueues(final String prefix, final QueueListingDetails detailsIncluded, - QueueRequestOptions options, OperationContext opContext) { - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this); - - final SegmentedStorageOperation> impl = new SegmentedStorageOperation>( - options, null) { - @Override - public ResultSegment execute(final CloudQueueClient client, final Void dontCare, - final OperationContext opContext) throws Exception { - - final ResultSegment result = CloudQueueClient.this.listQueuesCore(prefix, detailsIncluded, - -1, this.getToken(), this.getRequestOptions(), this, opContext); - - this.setToken(result.getContinuationToken()); - return result; - } - }; - - return new LazySegmentedIterator(impl, this, null, - options.getRetryPolicyFactory(), opContext); - } - - /** - * Gets a result segment containing a collection of queues from the storage - * service with the specified parameters. - * - * @param prefix - * A String containing the queue name prefix to - * filter the results with. - * @param detailsIncluded - * A {@link QueueListingDetails} value that indicates whether - * queue metadata will be returned. - * @param maxResults - * The maximum number of queue results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a - * continuation token returned by a previous listing operation. - * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueue}). - * @param taskReference - * A {@link StorageOperation} reference to the encapsulating - * task. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return A {@link ResultSegment} of {@link CloudQueue} objects that - * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested - * queues in - * the storage service. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws XMLStreamException - * @throws InvalidKeyException - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - ResultSegment listQueuesCore(final String prefix, final QueueListingDetails detailsIncluded, - final int maxResults, final ResultContinuation continuationToken, final RequestOptions options, - final StorageOperation> taskReference, - final OperationContext opContext) throws IOException, URISyntaxException, XMLStreamException, - InvalidKeyException, StorageException { - - Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); - - final ListingContext listingContext = new ListingContext(prefix, maxResults); - listingContext.setMarker(continuationToken != null ? continuationToken.getNextMarker() : null); - - final HttpURLConnection listQueueRequest = QueueRequest.list(this.getEndpoint(), - options.getTimeoutIntervalInMs(), listingContext, detailsIncluded, opContext); - - this.getCredentials().signRequest(listQueueRequest, -1L); - - taskReference.setResult(ExecutionEngine.processRequest(listQueueRequest, opContext)); - - if (taskReference.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) { - taskReference.setNonExceptionedRetryableFailure(true); - return null; - } - - final ListQueuesResponse response = new ListQueuesResponse(listQueueRequest.getInputStream()); - response.parseResponse(this); - - ResultContinuation newToken = null; - - if (response.getNextMarker() != null) { - newToken = new ResultContinuation(); - newToken.setNextMarker(response.getNextMarker()); - newToken.setContinuationType(ResultContinuationType.QUEUE); - } - - final ResultSegment resSegment = new ResultSegment(response.getQueues(this), - maxResults, newToken); - - return resSegment; - } - - /** - * Gets a result segment of an iterable collection of queues for this Queue - * service client. - * - * @return A {@link ResultSegment} of {@link CloudQueue} objects that - * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested - * queues in - * the storage service. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public ResultSegment listQueuesSegmented() throws StorageException { - return this.listQueuesSegmented(null, QueueListingDetails.NONE, 0, null, null, null); - } - - /** - * Gets a result segment of an iterable collection of queues whose names - * begin with the specified prefix for this Queue service client. - * - * @return A {@link ResultSegment} of {@link CloudQueue} objects that - * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested - * queues in - * the storage service. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public ResultSegment listQueuesSegmented(final String prefix) throws StorageException { - return this.listQueuesSegmented(prefix, QueueListingDetails.NONE, 0, null, null, null); - } - - /** - * Gets a result segment of an iterable collection of queues whose names - * begin with the specified prefix for this queue, using the specified - * listing details options, request options, and operation context. - * - * @param prefix - * A String that represents the prefix of the queue - * name to match. - * @param detailsIncluded - * A {@link QueueListingDetails} value that indicates whether - * queue metadata will be returned. - * @param maxResults - * The maximum number of queue results to retrieve. - * @param continuationToken - * A {@link ResultContinuation} object that represents a - * continuation token returned by a previous listing operation. - * @param options - * A {@link QueueRequestOptions} object that specifies any - * additional options for the request. Specifying null will use the default request options - * from - * the associated service client ( {@link CloudQueue}). - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return A {@link ResultSegment} of {@link CloudQueue} objects that - * contains a segment of the iterable collection of {@link CloudQueue} objects that represent the requested - * queues in - * the storage service. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - public ResultSegment listQueuesSegmented(final String prefix, - final QueueListingDetails detailsIncluded, final int maxResults, - final ResultContinuation continuationToken, QueueRequestOptions options, OperationContext opContext) - throws StorageException { - - if (opContext == null) { - opContext = new OperationContext(); - } - - if (options == null) { - options = new QueueRequestOptions(); - } - - opContext.initialize(); - options.applyDefaults(this); - - Utility.assertContinuationType(continuationToken, ResultContinuationType.QUEUE); - - final StorageOperation> impl = new StorageOperation>( - options) { - @Override - public ResultSegment execute(final CloudQueueClient client, final Void dontCare, - final OperationContext opContext) throws Exception { - return CloudQueueClient.this.listQueuesCore(prefix, detailsIncluded, maxResults, continuationToken, - this.getRequestOptions(), this, opContext); - } - }; - - return ExecutionEngine.executeWithRetry(this, null, impl, options.getRetryPolicyFactory(), opContext); - } - - /** - * Uploads a new configuration of service properties to the storage service, - * using the default request options. This includes Metrics and Logging - * Configuration. - * - * @param properties - * The {@link ServiceProperties} to upload. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - @Override - public void uploadServiceProperties(final ServiceProperties properties) throws StorageException { - this.uploadServiceProperties(properties, null, null); - } - - /** - * Uploads a new configuration of service properties to the storage service, - * using the specified request options and operation context. This includes - * Metrics and Logging Configuration. - * - * @param properties - * The {@link ServiceProperties} to upload. - * @param options - * A {@link RequestOptions} object that specifies any additional - * options for the request. Specifying null will use - * the default request options from the associated service client - * ( {@link CloudBlobClient}{@link CloudQueueClient}). - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @throws StorageException - * If a storage service error occurred during the operation. - */ - @DoesServiceRequest - @Override - public void uploadServiceProperties(final ServiceProperties properties, final RequestOptions options, - final OperationContext opContext) throws StorageException { - if (!Utility.isNullOrEmpty(properties.getDefaultServiceVersion())) { - throw new IllegalArgumentException( - "DefaultServiceVersion can only be set for the Blob service and the request must be made using the 2011-08-18 version"); - } - super.uploadServiceProperties(properties, options, opContext); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java deleted file mode 100644 index 6e116da0c7633..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java +++ /dev/null @@ -1,276 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.UnsupportedEncodingException; -import java.util.Date; - -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Base64; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * Represents a message in the Windows Azure Queue service. - */ -public class CloudQueueMessage { - - /** - * Holds the message ID. - */ - protected String id; - - /** - * Holds the message's pop receipt. - */ - protected String popReceipt; - - /** - * Holds the time that the message was added to the queue. - */ - protected Date insertionTime; - - /** - * Holds the time that the message expires. - */ - protected Date expirationTime; - - /** - * Holds the time that the message will next be visible. - */ - protected Date nextVisibleTime; - - /** - * Holds the message content. - */ - protected String messageContent; - - /** - * Holds the dequeue count. - */ - protected int dequeueCount; - - /** - * Holds the message type. - */ - protected QueueMessageType messageType; - - /** - * Initializes a new instance of the CloudQueueMessage class (used - * internally). - */ - CloudQueueMessage() { - // no op - } - - /** - * Initializes a new instance of the CloudQueueMessage class with an array - * of byte containing the message. - * - * @param content - * The array of byte that contains the message. - */ - public CloudQueueMessage(final byte[] content) { - this.setMessageContent(content); - } - - /** - * Initializes a new instance of the CloudQueueMessage class with a string - * containing the message. - * - * @param content - * The String that contains the message. - */ - public CloudQueueMessage(final String content) { - this.setMessageContent(content); - } - - /** - * Gets the dequeue count. - * - * @return The dequeue count. - */ - public final int getDequeueCount() { - return this.dequeueCount; - } - - /** - * Gets the time that the message expires. - * - * @return The time that the message expires. - */ - public final Date getExpirationTime() { - return this.expirationTime; - } - - /** - * Gets the message ID. - * - * @return A String that contains the message ID. - */ - public final String getId() { - return this.id; - } - - /** - * Gets the time that the message was added to the queue. - * - * @return The time that the message was added to the queue. - */ - public final Date getInsertionTime() { - return this.insertionTime; - } - - /** - * Gets the content of the message as a byte array. - * - * @return An array of byte with the content of the message. - * - * @throws StorageException - * If a storage service error occurred. - */ - public final byte[] getMessageContentAsByte() throws StorageException { - if (Utility.isNullOrEmpty(this.messageContent)) { - return new byte[0]; - } - - if (this.messageType == QueueMessageType.RAW_STRING) { - try { - return this.messageContent.getBytes("UTF8"); - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - else { - return Base64.decode(this.messageContent); - } - } - - /** - * Gets the content of the message as a string. - * - * @return A String with the content of the message. - * - * @throws StorageException - * If a storage service error occurred. - */ - public final String getMessageContentAsString() throws StorageException { - if (this.messageType == QueueMessageType.RAW_STRING) { - return this.messageContent; - } - else { - if (Utility.isNullOrEmpty(this.messageContent)) { - return null; - } - - try { - return new String(Base64.decode(this.messageContent), "UTF-8"); - } - catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - } - - /** - * Gets the content of the message for transfer (internal use only). - * - * @return A String with the content of the message. - * - * @throws StorageException - */ - protected final String getMessageContentForTransfer(final boolean shouldEncodeMessage) throws StorageException { - String result = null; - if (this.messageType == QueueMessageType.RAW_STRING && shouldEncodeMessage) { - result = Base64.encode(this.getMessageContentAsByte()); - - } - else { - result = this.messageContent; - } - - if (result != null && result.length() > QueueConstants.MAX_MESSAGE_SIZE) { - throw new IllegalArgumentException(String.format("The message size can't be larger than %s bytes. ", - QueueConstants.MAX_MESSAGE_SIZE)); - } - - return result; - } - - /** - * Gets the time that the message will next be visible. - * - * @return A java.util.Date with the time that the message will - * next be visible. - */ - public final Date getNextVisibleTime() { - return this.nextVisibleTime; - } - - /** - * Gets the message's pop receipt. - * - * @return A String containing the message's pop receipt. - */ - public final String getPopReceipt() { - return this.popReceipt; - } - - /** - * Sets the expiration time for the message. - * - * @param expirationTime - * The java.util.Date representing the expiration - * time to set on the message. - */ - public final void setExpirationTime(final Date expirationTime) { - this.expirationTime = expirationTime; - } - - /** - * Sets the content of the message as an array of byte. - * - * @param content - * The content of the message. - */ - public final void setMessageContent(final byte[] content) { - Utility.assertNotNull("content", content); - - this.messageContent = Base64.encode(content); - this.messageType = QueueMessageType.BASE_64_ENCODED; - } - - /** - * Sets the content of the message as a String. - * - * @param content - * The content of the message. - */ - public final void setMessageContent(final String content) { - this.messageContent = content; - this.messageType = QueueMessageType.RAW_STRING; - } - - /** - * Sets the time for the message to become visible in the queue. - * - * @param nextVisibleTime - * The java.util.Date representing the time to set - * for the message to be visible. - */ - public final void setNextVisibleTime(final Date nextVisibleTime) { - this.nextVisibleTime = nextVisibleTime; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java deleted file mode 100644 index 328a39e3aa7d1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.InputStream; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.ArrayList; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; - -/** - * RESERVED FOR INTERNAL USE. Provides methods for parsing the response stream - * from a queue listing operation. - */ -final class ListQueuesResponse { - - /** - * The list of queues from the response to a list queues operation. - */ - private ArrayList queues = new ArrayList(); - - /** - * A value indicating if the response has been fully parsed. - */ - private boolean isParsed; - - /** - * The marker value from the response. - */ - private String marker; - - /** - * The max results value from the response. - */ - private int maxResults; - - /** - * The next marker value from the response, to be passed as the marker value - * in the next queue listing request. - */ - private String nextMarker; - - /** - * The container prefix value from the response. - */ - private String prefix; - - /** - * The InputStream containing the response body from a queue - * listing operation. - */ - private final InputStream streamRef; - - /** - * Class constructor specifying an input stream created from the response - * body to a list queues operation. - * - * @param stream - * An InputStream to parse for the results of a list - * queues operation. - */ - public ListQueuesResponse(final InputStream stream) { - this.streamRef = stream; - } - - /** - * Gets the value of the Marker element in the response to a list queues - * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or - * {@link #parseResponse(CloudQueueClient)} has been called, and is only - * present if the list queues request specified the marker. - * - * @return A String containing the value of the Marker element - * in the response. - */ - public String getMarker() { - return this.marker; - } - - /** - * Gets the value of the MaxResults element in the response to a list queues - * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or - * {@link #parseResponse(CloudQueueClient)} has been called, and is only - * present if the request specified a maxresults value. - * - * @return An int containing the value of the MaxResults - * element in the response. - */ - public int getMaxResults() { - return this.maxResults; - } - - /** - * Gets the value of the NextMarker element in the response to a list queues - * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or - * {@link #parseResponse(CloudQueueClient)} has been called, and is only - * present when maxresults was specified in the request, and more results - * are available that have not yet been returned. This value may be sent as - * the marker value in a list queues request to retrieve the next set of - * queues. - * - * @return A String containing the value of the NextMarker - * element in the response. - */ - public String getNextMarker() { - return this.nextMarker; - } - - /** - * Gets the value of the Prefix element in the response to a list queues - * operation. This value is not initialized until {@link #getQueues(CloudQueueClient)} or - * {@link #parseResponse(CloudQueueClient)} has been called, and is only - * present if the request specified a prefix value. The list queues result - * is filtered to return only queues with names that begin with the - * specified prefix. - * - * @return A String containing the value of the Prefix element - * in the response. - */ - public String getPrefix() { - return this.prefix; - } - - /** - * Gets the list of queues returned by the list queues request as an ArrayList of (@link CloudQueue} - * objects. - * - * @param serviceClient - * A {@link CloudQueueClient} object associated with the storage - * service. - * - * @return an ArrayList of {@link CloudQueue} objects returned - * by the list queues operation. - * - * @throws XMLStreamException - * @throws StorageException - */ - public ArrayList getQueues(final CloudQueueClient serviceClient) throws XMLStreamException, - StorageException { - if (!this.isParsed) { - this.parseResponse(serviceClient); - } - - return this.queues; - } - - /** - * Parses the input stream containing the response body of the list queues - * request result and populates the class data. - * - * @param serviceClient - * A {@link CloudQueueClient} object associated with the storage - * service. - * - * @throws XMLStreamException - * If the input stream cannot be read or parsed as a list queues - * response. - * @throws StorageException - */ - public void parseResponse(final CloudQueueClient serviceClient) throws XMLStreamException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(this.streamRef); - String tempParseString = null; - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - // 1. get enumerationResults Header - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, "EnumerationResults"); - - // check if there are more events in the input stream - while (xmlr.hasNext()) { - eventType = xmlr.next(); - - if (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT) { - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MAX_RESULTS_ELEMENT)) { - tempParseString = Utility.readElementFromXMLReader(xmlr, Constants.MAX_RESULTS_ELEMENT); - this.maxResults = Integer.parseInt(tempParseString); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.MARKER_ELEMENT)) { - this.marker = Utility.readElementFromXMLReader(xmlr, Constants.MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.NEXT_MARKER_ELEMENT)) { - this.nextMarker = Utility.readElementFromXMLReader(xmlr, Constants.NEXT_MARKER_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(Constants.PREFIX_ELEMENT)) { - this.prefix = Utility.readElementFromXMLReader(xmlr, Constants.PREFIX_ELEMENT); - } - else if (eventType == XMLStreamConstants.START_ELEMENT && name.equals(QueueConstants.QUEUES_ELEMENT)) { - try { - this.queues = QueueDeserializationHelper.readQueues(xmlr, serviceClient); - } - catch (final URISyntaxException e) { - throw new XMLStreamException(e); - } - catch (final ParseException e) { - throw new XMLStreamException(e); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); - // eventType = xmlr.next(); - } - else if (eventType == XMLStreamConstants.END_ELEMENT && "EnumerationResults".equals(name)) { - break; - } - } - } - - this.isParsed = true; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java deleted file mode 100644 index 1e10b72e8b01b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -/** - * Flags for the values to set when updating messages. - */ -public enum MessageUpdateFields { - /** - * Set to update the message visibility timeout. - */ - VISIBILITY(1), - - /** - * Set to update the message content. - */ - CONTENT(2); - - /** - * Returns the value of this enum. - */ - public int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - MessageUpdateFields(final int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java deleted file mode 100644 index 3f7ecf932be75..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -/** - * RESERVED FOR INTERNAL USE. Holds the Constants used for the Queue Service. - */ -final class QueueConstants { - /** - * Default client side timeout, in milliseconds, for queue service. - */ - public static final int DEFAULT_QUEUE_CLIENT_TIMEOUT_IN_MS = 30 * 1000; - - /** - * The maximum message size in bytes. - */ - public static final long MAX_MESSAGE_SIZE = 64 * com.microsoft.windowsazure.services.core.storage.Constants.KB; - - /** - * The maximum number of messages that can be peeked or retrieved at a time. - */ - public static final int MAX_NUMBER_OF_MESSAGES_TO_PEEK = 32; - - /** - * Default visibility time out for the retrieve message operation. - */ - public static final int DEFAULT_VISIBILITY_MESSAGE_TIMEOUT_IN_SECONDS = 30; - - /** - * The maximum amount of time a message is kept inside the queue, in seconds. - */ - public static final int MAX_TIME_TO_LIVE_IN_SECONDS = 7 * 24 * 60 * 60; - - /** - * XML element for a queue. - */ - public static final String QUEUE_ELEMENT = "Queue"; - - /** - * XML element for queues. - */ - public static final String QUEUES_ELEMENT = "Queues"; - - /** - * XML element for QueueMessagesList. - */ - public static final String QUEUE_MESSAGES_LIST_ELEMENT = "QueueMessagesList"; - - /** - * XML element for QueueMessage. - */ - public static final String QUEUE_MESSAGE_ELEMENT = "QueueMessage"; - - /** - * XML element for MessageId. - */ - public static final String MESSAGE_ID_ELEMENT = "MessageId"; - - /** - * XML element for InsertionTime. - */ - public static final String INSERTION_TIME_ELEMENT = "InsertionTime"; - - /** - * XML element for ExpirationTime. - */ - public static final String EXPIRATION_TIME_ELEMENT = "ExpirationTime"; - - /** - * XML element for PopReceipt. - */ - public static final String POP_RECEIPT_ELEMENT = "PopReceipt"; - - /** - * XML element for TimeNextVisible. - */ - public static final String TIME_NEXT_VISIBLE_ELEMENT = "TimeNextVisible"; - - /** - * XML element for DequeueCount. - */ - public static final String DEQUEUE_COUNT_ELEMENT = "DequeueCount"; - - /** - * XML element for MessageText. - */ - public static final String MESSAGE_TEXT_ELEMENT = "MessageText"; - - /** - * The URI path component to access the messages in a queue. - */ - public static final String MESSAGES = "messages"; - - /** - * The header that specifies the approximate message count of a queue. - */ - public static final String APPROXIMATE_MESSAGES_COUNT = - com.microsoft.windowsazure.services.core.storage.Constants.PREFIX_FOR_STORAGE_HEADER - + "approximate-messages-count"; - - /** - * Private Default Ctor. - */ - private QueueConstants() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java deleted file mode 100644 index d2077cb2d5ac0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java +++ /dev/null @@ -1,260 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.DeserializationHelper; - -/** - * RESERVED FOR INTERNAL USE. Class to provide object deserialization for - * queues. - */ -final class QueueDeserializationHelper { - /** - * Populates the message from an XMLStreamReader. - * - * @param xmlr - * The XMLStreamReader to read from. - * @param shouldEncodeMessage - * A flag indicating whether messages should be base-64 encoded. - * - * @return A {@link CloudQueueMessage} from the stream. - * - * @throws XMLStreamException - * if there is an error parsing the stream - * @throws ParseException - * if there is an error in parsing a date - * @throws URISyntaxException - * if the uri is invalid - * @throws StorageException - * If a storage service error occurred during the operation. - */ - protected static CloudQueueMessage readMessage(final XMLStreamReader xmlr, final boolean shouldEncodeMessage) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_MESSAGE_ELEMENT); - - final CloudQueueMessage message = new CloudQueueMessage(); - message.messageType = shouldEncodeMessage ? QueueMessageType.BASE_64_ENCODED : QueueMessageType.RAW_STRING; - - int eventType = xmlr.getEventType(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(QueueConstants.MESSAGE_ID_ELEMENT)) { - message.id = Utility.readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_ID_ELEMENT); - } - else if (name.equals(QueueConstants.INSERTION_TIME_ELEMENT)) { - message.insertionTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( - xmlr, QueueConstants.INSERTION_TIME_ELEMENT)); - } - else if (name.equals(QueueConstants.EXPIRATION_TIME_ELEMENT)) { - message.expirationTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( - xmlr, QueueConstants.EXPIRATION_TIME_ELEMENT)); - } - else if (name.equals(QueueConstants.POP_RECEIPT_ELEMENT)) { - message.popReceipt = Utility.readElementFromXMLReader(xmlr, QueueConstants.POP_RECEIPT_ELEMENT); - } - else if (name.equals(QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)) { - message.nextVisibleTime = Utility.parseRFC1123DateFromStringInGMT(Utility.readElementFromXMLReader( - xmlr, QueueConstants.TIME_NEXT_VISIBLE_ELEMENT)); - } - else if (name.equals(QueueConstants.DEQUEUE_COUNT_ELEMENT)) { - message.dequeueCount = Integer.parseInt(Utility.readElementFromXMLReader(xmlr, - QueueConstants.DEQUEUE_COUNT_ELEMENT)); - } - else if (name.equals(QueueConstants.MESSAGE_TEXT_ELEMENT)) { - message.messageContent = Utility - .readElementFromXMLReader(xmlr, QueueConstants.MESSAGE_TEXT_ELEMENT); - } - - } - else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_MESSAGE_ELEMENT)) { - break; - } - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_MESSAGE_ELEMENT); - return message; - } - - /** - * Populates CloudQueueMessage objects from the XMLStreamReader; the reader - * must be at the Start element of QueuesElement. - * - * @param stream - * The InputStream object to deserialize from. - * @param shouldEncodeMessage - * A flag indicating whether messages should be base-64 encoded. - * - * @return An ArrayList of {@link CloudQueueMessage} from the - * stream. - * - * @throws XMLStreamException - * If there is a parsing exception. - * @throws ParseException - * If a date value is not correctly encoded. - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static ArrayList readMessages(final InputStream stream, final boolean shouldEncodeMessage) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { - final XMLStreamReader xmlr = Utility.createXMLStreamReaderFromStream(stream); - - // Start document - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_DOCUMENT, null, null); - - eventType = xmlr.next(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_MESSAGES_LIST_ELEMENT); - - final ArrayList messages = new ArrayList(); - - eventType = xmlr.next(); - while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() - && QueueConstants.QUEUE_MESSAGE_ELEMENT.equals(xmlr.getName().toString())) { - messages.add(QueueDeserializationHelper.readMessage(xmlr, shouldEncodeMessage)); - eventType = xmlr.next(); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_MESSAGES_LIST_ELEMENT); - return messages; - } - - /** - * Reserved for internal use. - * - * Populates the queue from an XMLStreamReader - * - * @param xmlr - * The XMLStreamReader to read from. - * @param serviceClient - * The {@link CloudQueueClient} to create the return value with. - * - * @return A {@link CloudQueue} populated with the deserialized data. - * - * @throws XMLStreamException - * If there is a parsing exception. - * @throws ParseException - * If a date value is not correctly encoded. - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - protected static CloudQueue readQueue(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { - - xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUE_ELEMENT); - - String queueName = null; - URI queueUri = null; - HashMap queueMetadata = null; - - int eventType = xmlr.getEventType(); - - while (xmlr.hasNext()) { - eventType = xmlr.next(); - final String name = xmlr.getName().toString(); - if (eventType == XMLStreamConstants.START_ELEMENT) { - if (name.equals(Constants.URL_ELEMENT)) { - queueUri = new URI(Utility.readElementFromXMLReader(xmlr, Constants.URL_ELEMENT)); - } - else if (name.equals(Constants.NAME_ELEMENT)) { - queueName = Utility.readElementFromXMLReader(xmlr, Constants.NAME_ELEMENT); - } - else if (name.equals(Constants.METADATA_ELEMENT)) { - // parse metadata - queueMetadata = DeserializationHelper.parseMetadateFromXML(xmlr); - xmlr.require(XMLStreamConstants.END_ELEMENT, null, Constants.METADATA_ELEMENT); - } - } - else if (eventType == XMLStreamConstants.END_ELEMENT && name.equals(QueueConstants.QUEUE_ELEMENT)) { - break; - } - } - - final CloudQueue queue = new CloudQueue(queueUri, serviceClient); - queue.setMetadata(queueMetadata); - queue.setName(queueName); - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUE_ELEMENT); - return queue; - } - - /** - * Populates CloudQueue objects from the XMLStreamReader; the reader must be - * at the Start element of QueuesElement. - * - * @param xmlr - * The XMLStreamReader to read from. - * @param serviceClient - * The {@link CloudQueueClient} to create the return value with. - * - * @return An ArrayList of{@link CloudQueue} populated with the - * deserialized data. - * - * @throws XMLStreamException - * If there is a parsing exception. - * @throws ParseException - * If a date value is not correctly encoded. - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static ArrayList readQueues(final XMLStreamReader xmlr, final CloudQueueClient serviceClient) - throws XMLStreamException, ParseException, URISyntaxException, StorageException { - int eventType = xmlr.getEventType(); - xmlr.require(XMLStreamConstants.START_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); - - final ArrayList queues = new ArrayList(); - - eventType = xmlr.next(); - while (eventType == XMLStreamConstants.START_ELEMENT && xmlr.hasName() - && QueueConstants.QUEUE_ELEMENT.equals(xmlr.getName().toString())) { - queues.add(readQueue(xmlr, serviceClient)); - eventType = xmlr.next(); - } - - xmlr.require(XMLStreamConstants.END_ELEMENT, null, QueueConstants.QUEUES_ELEMENT); - return queues; - } - - /** - * Private Default Ctor. - */ - private QueueDeserializationHelper() { - // No op - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java deleted file mode 100644 index dafb259c05e67..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -/** - * Specifies which details to include when listing the queues in this storage - * account. - */ -public enum QueueListingDetails { - /** - * Specifies including all available details. - */ - ALL(1), - - /** - * Specifies including queue metadata. - */ - METADATA(1), - - /** - * Specifies including no additional details. - */ - NONE(0); - - /** - * Returns the value of this enum. - */ - public int value; - - /** - * Sets the value of this enum. - * - * @param val - * The value being assigned. - */ - QueueListingDetails(final int val) { - this.value = val; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java deleted file mode 100644 index cbd3ba362450d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -/** - * Reserved for internal use. Specifies queue message type. - */ -public enum QueueMessageType { - /** - * Indicates the message object stores the raw text string. - */ - RAW_STRING, - - /** - * Indicates the message object stores the Base64-Encoded representation of - * the raw data. - */ - BASE_64_ENCODED -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java deleted file mode 100644 index 7f01ad524897c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ /dev/null @@ -1,623 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import com.microsoft.windowsazure.services.core.storage.Constants; -import com.microsoft.windowsazure.services.core.storage.OperationContext; -import com.microsoft.windowsazure.services.core.storage.StorageException; -import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder; -import com.microsoft.windowsazure.services.core.storage.utils.Utility; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseRequest; -import com.microsoft.windowsazure.services.core.storage.utils.implementation.ListingContext; - -/** - * RESERVED FOR INTERNAL USE. Provides a set of methods for constructing web - * requests for queue operations. - */ -final class QueueRequest { - /** - * Adds user-defined metadata to the web request as one or more name-value - * pairs. - * - * @param request - * The HttpURLConnection web request to add the - * metadata to. - * @param metadata - * A HashMap containing the user-defined metadata to - * add. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - */ - public static void addMetadata(final HttpURLConnection request, final HashMap metadata, - final OperationContext opContext) { - BaseRequest.addMetadata(request, metadata, opContext); - } - - /** - * Constructs a web request to clear all the messages in the queue. Sign the - * web request with a length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection clearMessages(final URI uri, final int timeout, final OperationContext opContext) - throws URISyntaxException, IOException, StorageException { - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, null, opContext); - - request.setRequestMethod("DELETE"); - - return request; - } - - /** - * Constructs a web request to create a new queue. Sign the web request with - * a length of 0. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection create(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - return BaseRequest.create(uri, timeout, null, opContext); - } - - /** - * Constructs a web request to delete the queue. Sign the web request with a - * length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection delete(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - return BaseRequest.delete(uri, timeout, null, opContext); - } - - /** - * Constructs a web request to delete a message from the queue. Sign the web - * request with a length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param popReceipt - * A String that contains the pop receipt value - * returned from an earlier call to - * {@link CloudQueueMessage#getPopReceipt} for the message to - * delete. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws URISyntaxException - * If the URI is not valid. - * @throws IOException - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection deleteMessage(final URI uri, final int timeout, final String popReceipt, - final OperationContext opContext) throws URISyntaxException, IOException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("popreceipt", popReceipt); - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("DELETE"); - - return request; - } - - /** - * Constructs a web request to download user-defined metadata and the - * approximate message count for the queue. Sign the web request with a - * length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection downloadAttributes(final URI uri, final int timeout, - final OperationContext opContext) throws IOException, URISyntaxException, StorageException { - return BaseRequest.getMetadata(uri, timeout, null, opContext); - } - - /** - * Generates the message request body from a string containing the message. - * The message must be encodable as UTF-8. To be included in a web request, - * this message request body must be written to the output stream of the web - * request. - * - * @param message - * A - * String containing the message to wrap in a message request body. - * - * @return An array of byte containing the message request body - * encoded as UTF-8. - * - * @throws XMLStreamException - * @throws StorageException - * If the message cannot be encoded as UTF-8. - */ - public static byte[] generateMessageRequestBody(final String message) throws XMLStreamException, StorageException { - final StringWriter outWriter = new StringWriter(); - final XMLOutputFactory xmlOutFactoryInst = XMLOutputFactory.newInstance(); - final XMLStreamWriter xmlw = xmlOutFactoryInst.createXMLStreamWriter(outWriter); - - // default is UTF8 - xmlw.writeStartDocument(); - xmlw.writeStartElement(QueueConstants.QUEUE_MESSAGE_ELEMENT); - - xmlw.writeStartElement(QueueConstants.MESSAGE_TEXT_ELEMENT); - xmlw.writeCharacters(message); - xmlw.writeEndElement(); - - // end QueueMessage_ELEMENT - xmlw.writeEndElement(); - - // end doc - xmlw.writeEndDocument(); - try { - return outWriter.toString().getBytes("UTF8"); - } catch (final UnsupportedEncodingException e) { - throw Utility.generateNewUnexpectedStorageException(e); - } - } - - /** - * Constructs a web request to return a listing of all queues in this - * storage account. Sign the web request with a length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the storage account. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param listingContext - * A {@link ListingContext} object that specifies parameters for - * the listing operation, if any. May be null. - * @param detailsIncluded - * A {@link QueueListingDetails} object that specifies additional - * details to return with the listing, if any. May be - * null. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection list(final URI uri, final int timeout, final ListingContext listingContext, - final QueueListingDetails detailsIncluded, final OperationContext opContext) throws URISyntaxException, - IOException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("comp", "list"); - - if (listingContext != null) { - if (!Utility.isNullOrEmpty(listingContext.getPrefix())) { - builder.add("prefix", listingContext.getPrefix()); - } - - if (!Utility.isNullOrEmpty(listingContext.getMarker())) { - builder.add("marker", listingContext.getMarker()); - } - - if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) { - builder.add("maxresults", listingContext.getMaxResults().toString()); - } - } - - if (detailsIncluded == QueueListingDetails.ALL || detailsIncluded == QueueListingDetails.METADATA) { - builder.add("include", "metadata"); - } - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Constructs a web request to retrieve a specified number of messages from - * the front of the queue without changing their visibility. Sign the web - * request with a length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param numberOfMessages - * A nonzero value that specifies the number of messages to - * retrieve from the queue, up to a maximum of 32. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection peekMessages(final URI uri, final int timeout, final int numberOfMessages, - final OperationContext opContext) throws URISyntaxException, IOException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - builder.add("peekonly", "true"); - - if (numberOfMessages != 0) { - builder.add("numofmessages", Integer.toString(numberOfMessages)); - } - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Constructs a web request to add a message to the back of the queue. Write - * the encoded message request body generated with a call to - * {@link #generateMessageRequestBody(String)} to the output stream of the - * request. Sign the web request with the length of the encoded message - * request body. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param visibilityTimeoutInSeconds - * Specifies the length of time for the message to be invisible - * in seconds, starting when it is added to the queue. A value of - * 0 will make the message visible immediately. The value must be - * greater than or equal to 0, and cannot be larger than 7 days. - * The visibility timeout of a message cannot be set to a value - * greater than the time-to-live time. - * @param timeToLiveInSeconds - * Specifies the time-to-live interval for the message, in - * seconds. The maximum time-to-live allowed is 7 days. If this - * parameter is 0, the default time-to-live of 7 days is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection putMessage(final URI uri, final int timeout, final int visibilityTimeoutInSeconds, - final int timeToLiveInSeconds, final OperationContext opContext) throws IOException, URISyntaxException, - StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - - if (visibilityTimeoutInSeconds != 0) { - builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); - } - - if (timeToLiveInSeconds != 0) { - builder.add("messagettl", Integer.toString(timeToLiveInSeconds)); - } - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setDoOutput(true); - request.setRequestMethod("POST"); - - return request; - } - - /** - * Constructs a web request to retrieve messages from the front of the - * queue. Sign the web request with a length of -1L. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param numberOfMessages - * A nonzero value that specifies the number of messages to - * retrieve from the queue, up to a maximum of 32. - * @param visibilityTimeoutInSeconds - * Specifies the visibility timeout value in seconds, relative to - * server time, to make the retrieved messages invisible until - * the visibility timeout expires. The value must be larger than - * or equal to 0, and cannot be larger than 7 days. The - * visibility timeout of a message can be set to a value later - * than the expiry time, which will prevent the message from - * being retrieved again whether it is processed or not. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection retrieveMessages(final URI uri, final int timeout, final int numberOfMessages, - final int visibilityTimeoutInSeconds, final OperationContext opContext) throws URISyntaxException, - IOException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - - if (numberOfMessages != 0) { - builder.add("numofmessages", Integer.toString(numberOfMessages)); - } - - builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setRequestMethod("GET"); - - return request; - } - - /** - * Constructs a web request to set user-defined metadata for the queue. Each - * call to this operation replaces all existing metadata attached to the - * queue. Use the {@link #addMetadata} method to specify the metadata to set - * on the queue. To remove all metadata from the queue, call this web - * request with no metadata added. Sign the web request with a length of 0. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection setMetadata(final URI uri, final int timeout, final OperationContext opContext) - throws IOException, URISyntaxException, StorageException { - return BaseRequest.setMetadata(uri, timeout, null, opContext); - } - - /** - * Constructs a web request to update the visibility timeout of a message in - * the queue. Optionally updates the message content if a message request - * body is written to the output stream of the web request. The web request - * should be signed with the length of the encoded message request body if - * one is included, or a length of 0 if no message request body is included. - * - * @param uri - * A URI object that specifies the absolute URI to - * the queue. - * @param timeout - * The server response timeout interval in milliseconds. If the - * operation does not complete within the specified timeout - * interval, a timeout error is returned by the server. If the - * timeout value is 0, the maximum timeout of 30 seconds is used. - * @param popReceipt - * A String that contains the pop receipt value - * returned from an earlier call to - * {@link CloudQueueMessage#getPopReceipt} for the message to - * update. - * @param visibilityTimeoutInSeconds - * Specifies the new visibility timeout value in seconds, - * relative to server time, to make the retrieved messages - * invisible until the visibility timeout expires. The value must - * be larger than or equal to 0, and cannot be larger than 7 - * days. The visibility timeout of a message can be set to a - * value later than the expiry time, which will prevent the - * message from being retrieved again whether it is processed or - * not. - * @param opContext - * An {@link OperationContext} object that represents the context - * for the current operation. This object is used to track - * requests to the storage service, and to provide additional - * runtime information about the operation. - * - * @return An HttpURLConnection configured for the specified - * operation. - * - * @throws IOException - * @throws URISyntaxException - * If the URI is not valid. - * @throws StorageException - * If a storage service error occurred during the operation. - */ - public static HttpURLConnection updateMessage(final URI uri, final int timeout, final String popReceipt, - final int visibilityTimeoutInSeconds, final OperationContext opContext) throws URISyntaxException, - IOException, StorageException { - - final UriQueryBuilder builder = new UriQueryBuilder(); - - builder.add("popreceipt", popReceipt); - - builder.add("visibilitytimeout", Integer.toString(visibilityTimeoutInSeconds)); - - final HttpURLConnection request = BaseRequest.createURLConnection(uri, timeout, builder, opContext); - - request.setRequestProperty(Constants.HeaderConstants.STORAGE_VERSION_HEADER, "2011-08-18"); - - request.setDoOutput(true); - request.setRequestMethod("PUT"); - - return request; - } - - /** - * Private Default Ctor. - */ - private QueueRequest() { - // No op - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java deleted file mode 100644 index f945aab8d3e65..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import com.microsoft.windowsazure.services.core.storage.RequestOptions; - -/** - * Represents a set of options that may be specified on a queue request. - */ -public final class QueueRequestOptions extends RequestOptions { - /** - * Initializes a new instance of the QueueRequestOptions class. - */ - public QueueRequestOptions() { - // no op - } - - /** - * Initializes a new instance of the QueueRequestOptions class as a copy of - * another QueueRequestOptions instance. - * - * @param other - * The {@link QueueRequestOptions} object to copy the values - * from. - */ - public QueueRequestOptions(final QueueRequestOptions other) { - super(other); - } - - /** - * Populates the default timeout and retry policy from client if they are - * not set. - * - * @param client - * The {@link CloudQueueClient} service client to populate the - * default values from. - */ - protected void applyDefaults(final CloudQueueClient client) { - super.applyBaseDefaults(client); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java deleted file mode 100644 index c3817ad822261..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.client; - -import java.net.HttpURLConnection; - -import com.microsoft.windowsazure.services.core.storage.utils.implementation.BaseResponse; - -/** - * RESERVED FOR INTERNAL USE. A class for parsing various responses from the queue service. - */ -final class QueueResponse extends BaseResponse { - - /** - * Gets the approximate messages count from the headers of a server response to a get metadata request. - * - * @param request - * The HttpURLConnection containing a web request with a response from the server. - * @return The long value of the approximate messages count header field. - */ - public static long getApproximateMessageCount(final HttpURLConnection request) { - return Long.parseLong(request.getHeaderField("x-ms-approximate-messages-count")); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java deleted file mode 100644 index 6f68d1f8ec958..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ /dev/null @@ -1,383 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.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.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.microsoft.windowsazure.services.queue.QueueContract; -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; -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; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; - -public class QueueExceptionProcessor implements QueueContract { - private static Log log = LogFactory.getLog(QueueExceptionProcessor.class); - private final QueueContract service; - - @Inject - public QueueExceptionProcessor(QueueRestProxy service) { - this.service = service; - } - - public QueueExceptionProcessor(QueueContract service) { - this.service = service; - } - - public QueueContract withFilter(ServiceFilter filter) { - return new QueueExceptionProcessor(service.withFilter(filter)); - } - - private ServiceException processCatch(ServiceException e) { - log.warn(e.getMessage(), e.getCause()); - return ServiceExceptionFactory.process("blob", e); - } - - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - try { - return service.getServiceProperties(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public GetServicePropertiesResult 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(ServiceProperties 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(ServiceProperties 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 messageText) throws ServiceException { - try { - service.createMessage(queue, messageText); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { - try { - service.createMessage(queue, messageText, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, - int visibilityTimeoutInSeconds) throws ServiceException { - try { - return service.updateMessage(queue, messageId, popReceipt, messageText, visibilityTimeoutInSeconds); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, - int visibilityTimeoutInSeconds, QueueServiceOptions options) throws ServiceException { - try { - return service - .updateMessage(queue, messageId, popReceipt, messageText, 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 messageId, String popReceipt) throws ServiceException { - try { - service.deleteMessage(queue, messageId, popReceipt); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) - throws ServiceException { - try { - service.deleteMessage(queue, messageId, 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/implementation/QueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java deleted file mode 100644 index cffc724549ac4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.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/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java deleted file mode 100644 index 4677d0431b818..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ /dev/null @@ -1,322 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.implementation; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; -import com.microsoft.windowsazure.services.queue.QueueConfiguration; -import com.microsoft.windowsazure.services.queue.QueueContract; -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; -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; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.WebResource.Builder; - -public class QueueRestProxy implements QueueContract { - //private static Log log = LogFactory.getLog(QueueRestProxy.class); - - private static final String API_VERSION = "2011-08-18"; - private final HttpURLConnectionClient channel; - private final String accountName; - private final String url; - private final RFC1123DateConverter dateMapper; - private final ServiceFilter[] filters; - private final SharedKeyFilter filter; - - @Inject - public QueueRestProxy(HttpURLConnectionClient channel, @Named(QueueConfiguration.ACCOUNT_NAME) String accountName, - @Named(QueueConfiguration.URI) String url, SharedKeyFilter 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 QueueRestProxy(HttpURLConnectionClient channel, ServiceFilter[] filters, String accountName, String url, - SharedKeyFilter filter, RFC1123DateConverter dateMapper) { - - this.channel = channel; - this.filters = filters; - this.accountName = accountName; - this.url = url; - this.filter = filter; - this.dateMapper = dateMapper; - } - - public QueueContract withFilter(ServiceFilter filter) { - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new QueueRestProxy(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); - } - - private void ThrowIfError(ClientResponse r) { - PipelineHelpers.ThrowIfError(r); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); - } - - private Builder addOptionalMetadataHeader(Builder builder, Map metadata) { - return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); - } - - private HashMap getMetadataFromHeaders(ClientResponse response) { - return PipelineHelpers.getMetadataFromHeaders(response); - } - - 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; - } - - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - return getServiceProperties(new QueueServiceOptions()); - } - - public GetServicePropertiesResult getServiceProperties(QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - GetServicePropertiesResult result = new GetServicePropertiesResult(); - result.setValue(builder.get(ServiceProperties.class)); - return result; - } - - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - setServiceProperties(serviceProperties, new QueueServiceOptions()); - } - - public void setServiceProperties(ServiceProperties serviceProperties, QueueServiceOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder.put(serviceProperties); - } - - public void createQueue(String queue) throws ServiceException { - createQueue(queue, new CreateQueueOptions()); - - } - - public void createQueue(String queue, CreateQueueOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - - builder.put(); - } - - public void deleteQueue(String queue) throws ServiceException { - deleteQueue(queue, new QueueServiceOptions()); - } - - public void deleteQueue(String queue, QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder.delete(); - } - - public ListQueuesResult listQueues() throws ServiceException { - return listQueues(new ListQueuesOptions()); - } - - public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("comp", "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 { - return getQueueMetadata(queue, new QueueServiceOptions()); - } - - public GetQueueMetadataResult getQueueMetadata(String queue, QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue).queryParam("comp", "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 { - setQueueMetadata(queue, metadata, new QueueServiceOptions()); - } - - public void setQueueMetadata(String queue, HashMap metadata, QueueServiceOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(queue).queryParam("comp", "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, metadata); - - builder.put(); - } - - public void createMessage(String queue, String messageText) throws ServiceException { - createMessage(queue, messageText, new CreateMessageOptions()); - } - - public void createMessage(String queue, String messageText, CreateMessageOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue).path("messages"); - 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(messageText); - - builder.post(queueMessage); - } - - public UpdateMessageResult updateMessage(String queue, String messageId, String popReceipt, String messageText, - int visibilityTimeoutInSeconds) throws ServiceException { - 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 { - WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); - 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); - - ClientResponse response = builder.put(ClientResponse.class, queueMessage); - ThrowIfError(response); - - UpdateMessageResult result = new UpdateMessageResult(); - result.setPopReceipt(response.getHeaders().getFirst("x-ms-popreceipt")); - result.setTimeNextVisible(dateMapper.parse(response.getHeaders().getFirst("x-ms-time-next-visible"))); - return result; - } - - public ListMessagesResult listMessages(String queue) throws ServiceException { - return listMessages(queue, new ListMessagesOptions()); - } - - public ListMessagesResult listMessages(String queue, ListMessagesOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue).path("messages"); - 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 { - return peekMessages(queue, new PeekMessagesOptions()); - } - - public PeekMessagesResult peekMessages(String queue, PeekMessagesOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue).path("messages").queryParam("peekonly", "true"); - 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 messageId, String popReceipt) throws ServiceException { - deleteMessage(queue, messageId, popReceipt, new QueueServiceOptions()); - } - - public void deleteMessage(String queue, String messageId, String popReceipt, QueueServiceOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path(queue).path("messages").path(messageId); - webResource = addOptionalQueryParam(webResource, "popreceipt", popReceipt); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder.delete(); - } - - public void clearMessages(String queue) throws ServiceException { - clearMessages(queue, new QueueServiceOptions()); - } - - public void clearMessages(String queue, QueueServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path(queue).path("messages"); - - 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/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java deleted file mode 100644 index 3707a3f119118..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.implementation; - -import javax.inject.Named; - -import com.microsoft.windowsazure.services.queue.QueueConfiguration; - -public class SharedKeyFilter extends com.microsoft.windowsazure.services.blob.implementation.SharedKeyFilter { - public SharedKeyFilter(@Named(QueueConfiguration.ACCOUNT_NAME) String accountName, - @Named(QueueConfiguration.ACCOUNT_KEY) String accountKey) { - super(accountName, accountKey); - } -} 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 deleted file mode 100644 index 351d6ed8f62f6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyLiteFilter.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.implementation; - -import javax.inject.Named; - -import com.microsoft.windowsazure.services.queue.QueueConfiguration; - -public class SharedKeyLiteFilter extends com.microsoft.windowsazure.services.blob.implementation.SharedKeyLiteFilter { - public SharedKeyLiteFilter(@Named(QueueConfiguration.ACCOUNT_NAME) String accountName, - @Named(QueueConfiguration.ACCOUNT_KEY) String accountKey) { - super(accountName, accountKey); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java deleted file mode 100644 index f227771970f49..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -public class CreateMessageOptions extends QueueServiceOptions { - private Integer visibilityTimeoutInSeconds; - private Integer timeToLiveInSeconds; - - @Override - public CreateMessageOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - public Integer getVisibilityTimeoutInSeconds() { - return visibilityTimeoutInSeconds; - } - - public CreateMessageOptions setVisibilityTimeoutInSeconds(Integer visibilityTimeoutInSeconds) { - this.visibilityTimeoutInSeconds = visibilityTimeoutInSeconds; - return this; - } - - public Integer getTimeToLiveInSeconds() { - return timeToLiveInSeconds; - } - - public CreateMessageOptions setTimeToLiveInSeconds(Integer timeToLiveInSeconds) { - this.timeToLiveInSeconds = timeToLiveInSeconds; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java deleted file mode 100644 index cb79876571241..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -import java.util.HashMap; - -public class CreateQueueOptions extends QueueServiceOptions { - private HashMap metadata = new HashMap(); - - @Override - public CreateQueueOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - 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/windowsazure/services/queue/models/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java deleted file mode 100644 index e412e00ece63a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -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/windowsazure/services/queue/models/GetServicePropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java deleted file mode 100644 index 2a7e788205659..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetServicePropertiesResult.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.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/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java deleted file mode 100644 index 2aa19b6409441..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -public class ListMessagesOptions extends QueueServiceOptions { - private Integer numberOfMessages; - private Integer visibilityTimeoutInSeconds; - - @Override - public ListMessagesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - 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/windowsazure/services/queue/models/ListMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java deleted file mode 100644 index af7c53f87ff18..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesResult.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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 { - private List queueMessages = new ArrayList(); - - @XmlElement(name = "QueueMessage") - public List getQueueMessages() { - return queueMessages; - } - - public void setQueueMessages(List queueMessages) { - this.queueMessages = queueMessages; - } - - public static class QueueMessage { - private String messageId; - private Date insertionDate; - private Date expirationDate; - private String popReceipt; - private Date timeNextVisible; - private int dequeueCount; - private String messageText; - - @XmlElement(name = "MessageId") - public String getMessageId() { - return messageId; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @XmlElement(name = "InsertionTime") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - public Date getInsertionDate() { - return insertionDate; - } - - public void setInsertionDate(Date insertionDate) { - this.insertionDate = insertionDate; - } - - @XmlElement(name = "ExpirationTime") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - 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") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - 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 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/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java deleted file mode 100644 index 6b62c7cacd2a7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -public class ListQueuesOptions extends QueueServiceOptions { - private String prefix; - private String marker; - private int maxResults; - private boolean includeMetadata; - - @Override - public ListQueuesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - 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 boolean isIncludeMetadata() { - return includeMetadata; - } - - public ListQueuesOptions setIncludeMetadata(boolean includeMetadata) { - this.includeMetadata = includeMetadata; - return this; - } -} 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 deleted file mode 100644 index 6dc3a704a930d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListQueuesResult.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -import java.util.ArrayList; -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.windowsazure.services.blob.implementation.MetadataAdapter; - -@XmlRootElement(name = "EnumerationResults") -public class ListQueuesResult { - private List queues = new ArrayList(); - 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/windowsazure/services/queue/models/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java deleted file mode 100644 index 9339f83eb958b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -public class PeekMessagesOptions extends QueueServiceOptions { - private Integer numberOfMessages; - - @Override - public PeekMessagesOptions setTimeout(Integer timeout) { - super.setTimeout(timeout); - return this; - } - - 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/windowsazure/services/queue/models/PeekMessagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java deleted file mode 100644 index 79990e4391d69..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesResult.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -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 queueMessages = new ArrayList(); - - @XmlElement(name = "QueueMessage") - public List getQueueMessages() { - return queueMessages; - } - - public void setQueueMessages(List queueMessages) { - this.queueMessages = queueMessages; - } - - public static class QueueMessage { - private String messageId; - private Date insertionDate; - private Date expirationDate; - private int dequeueCount; - private String messageText; - - @XmlElement(name = "MessageId") - public String getMessageId() { - return messageId; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @XmlElement(name = "InsertionTime") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - public Date getInsertionDate() { - return insertionDate; - } - - public void setInsertionDate(Date insertionDate) { - this.insertionDate = insertionDate; - } - - @XmlElement(name = "ExpirationTime") - @XmlJavaTypeAdapter(RFC1123DateAdapter.class) - 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 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/models/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java deleted file mode 100644 index ff574f82e1790..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -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/windowsazure/services/queue/models/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java deleted file mode 100644 index f676d600b63b7..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ServiceProperties.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "StorageServiceProperties") -public class ServiceProperties { - private Logging logging = new Logging(); - private Metrics metrics = new Metrics(); - - @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; - } - - 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/windowsazure/services/queue/models/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java deleted file mode 100644 index a57f8be013ffe..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue.models; - -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; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java deleted file mode 100644 index 053d3b7fcff51..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import java.util.Map; - -import com.microsoft.windowsazure.services.core.Builder; -import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; -import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModelProvider; -import com.microsoft.windowsazure.services.serviceBus.implementation.MarshallerProvider; -import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor; -import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusRestProxy; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.json.JSONConfiguration; - -public class Exports implements Builder.Exports { - @Override - public void register(Builder.Registry registry) { - - // provide contract implementation - registry.add(ServiceBusContract.class, ServiceBusExceptionProcessor.class); - registry.add(ServiceBusExceptionProcessor.class); - registry.add(ServiceBusRestProxy.class); - - // alter jersey client config for serviceBus - registry.alter(ClientConfig.class, new Builder.Alteration() { - - @Override - public ClientConfig alter(ClientConfig instance, Builder builder, Map properties) { - - // enable this feature for unattributed json object serialization - instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - - // need to avoid certain element prefixes, which the service does not ignore - instance.getSingletons().add(new MarshallerProvider()); - - // add body reader/writer for EntryModel descendant classes - instance.getClasses().add(EntryModelProvider.class); - - return instance; - } - }); - - // convenience provider to transform BrokerProperty headers to json - registry.add(BrokerPropertiesMapper.class); - - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java deleted file mode 100644 index 64c58d8d2a13c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import com.microsoft.windowsazure.services.core.Configuration; - -/** - * Provides functionality to create a service bus configuration. - * - */ -public class ServiceBusConfiguration { - - /** - * Defines the configuration URI constant. - * - */ - public final static String URI = "serviceBus.uri"; - - /** - * Defines the configuration wrap URI constant. - * - */ - public final static String WRAP_URI = "serviceBus.wrap.uri"; - - /** - * Defines the configuration wrap name constant. - * - */ - public final static String WRAP_NAME = "serviceBus.wrap.name"; - - /** - * Defines the configuration wrap password constant. - * - */ - public final static String WRAP_PASSWORD = "serviceBus.wrap.password"; - - /** - * Creates a service bus configuration using the specified namespace, name, and password. - * - * @param namespace - * A String object that represents the namespace. - * - * @param authenticationName - * A String object that represents the authentication name. - * - * @param authenticationPassword - * A String object that represents the authentication password. - * - * @return - * A Configuration object that can be used when creating an instance of the - * ServiceBusService class. - * - */ - public static Configuration configureWithWrapAuthentication(String namespace, String authenticationName, String authenticationPassword) { - return configureWithWrapAuthentication(null, Configuration.getInstance(), namespace, authenticationName, authenticationPassword); - } - - /** - * Creates a service bus configuration using the specified configuration, namespace, name, and password. - * - * @param configuration - * A previously instantiated Configuration object. - * - * @param namespace - * A String object that represents the namespace. - * - * @param authenticationName - * A String object that represents the authentication name. - * - * @param authenticationPassword - * A String object that represents the authentication password. - * - * @return - * A Configuration object that can be used when creating an instance of the - * ServiceBusService class. - * - */ - public static Configuration configureWithWrapAuthentication(Configuration configuration, String namespace, String authenticationName, - String authenticationPassword) { - return configureWithWrapAuthentication(null, configuration, namespace, authenticationName, authenticationPassword); - } - - /** - * Creates a service bus configuration using the specified profile, configuration, namespace, name, and password. - * - * @param profile - * A String object that represents the profile. - * - * @param configuration - * A previously instantiated Configuration object. - * - * @param namespace - * A String object that represents the namespace. - * - * @param authenticationName - * A String object that represents the authentication name. - * - * @param authenticationPassword - * A String object that represents the authentication password. - * - * @return - * A Configuration object that can be used when creating an instance of the - * ServiceBusService class. - * - */ - public static Configuration configureWithWrapAuthentication(String profile, Configuration configuration, String namespace, - String authenticationName, String authenticationPassword) { - - if (profile == null) { - profile = ""; - } - else if (profile.length() != 0 && !profile.endsWith(".")) { - profile = profile + "."; - } - - configuration.setProperty(profile + URI, "https://" + namespace + ".servicebus.windows.net/"); - - configuration - .setProperty(profile + WRAP_URI, "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9"); - - configuration.setProperty(profile + WRAP_NAME, authenticationName); - configuration.setProperty(profile + WRAP_PASSWORD, authenticationPassword); - - return configuration; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java deleted file mode 100644 index 4459ba1308d82..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ /dev/null @@ -1,440 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; -import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; -import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; - -/** - * - * Defines the service bus contract. - * - */ -public interface ServiceBusContract extends FilterableService { - - /** - * Sends a queue message. - * - * @param queuePath - * A String object that represents the name of the queue to which the message will be sent. - * @param message - * A Message object that represents the message to send. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void sendQueueMessage(String queuePath, BrokeredMessage message) throws ServiceException; - - /** - * Receives a queue message. - * - * @param queuePath - * A String object that represents the name of the queue from which to receive the message. - * - * @return A ReceiveQueueMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - ReceiveQueueMessageResult receiveQueueMessage(String queuePath) throws ServiceException; - - /** - * Receives a queue message using the specified receive message options. - * - * @param queuePath - * A String object that represents the name of the queue from which to receive the message. - * - * @param options - * A ReceiveMessageOptions object that represents the receive message options. - * - * @return A ReceiveQueueMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOptions options) - throws ServiceException; - - /** - * Sends a topic message. - * - * @param topicPath - * A String object that represents the name of the topic to which the message will be sent. - * @param message - * A Message object that represents the message to send. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void sendTopicMessage(String topicPath, BrokeredMessage message) throws ServiceException; - - /** - * Receives a subscription message. - * - * @param topicPath - * A String object that represents the name of the topic to receive. - * @param subscriptionName - * A String object that represents the name of the subscription from the message will be - * received. - * - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, String subscriptionName) - throws ServiceException; - - /** - * Receives a subscription message using the specified receive message options. - * - * @param topicPath - * A String object that represents the name of the topic to receive. - * @param subscriptionName - * A String object that represents the name of the subscription from the message will be - * received. - * @param options - * A ReceiveMessageOptions object that represents the receive message options. - * - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicPath, String subscriptionName, - ReceiveMessageOptions options) throws ServiceException; - - /** - * Unlocks a message. - * - * @param message - * A Message object that represents the message to unlock. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void unlockMessage(BrokeredMessage message) throws ServiceException; - - /** - * Sends a message. - * - * @param path - * A String object that represents the path to which the message will be sent. - * This may be the value of a queuePath or a topicPath. - * @param message - * A Message object that represents the message to send. - * - * @throws ServiceException - * If a service exception is encountered. - */ - void sendMessage(String path, BrokeredMessage message) throws ServiceException; - - /** - * Receives a message. - * - * @param path - * A String object that represents the path from which a message will be received. - * This may either be the value of queuePath or a combination of - * the topicPath + "/subscriptions/" + subscriptionName. - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * @throws ServiceException - * If a service exception is encountered. - */ - ReceiveMessageResult receiveMessage(String path) throws ServiceException; - - /** - * Receives a message using the specified receive message options. - * - * @param path - * A String object that represents the path from which a message will be received. - * This may either be the value of queuePath or a combination of - * the topicPath + "/subscriptions/" + subscriptionName. - * @param options - * A ReceiveMessageOptions object that represents the receive message options. - * @return A ReceiveSubscriptionMessageResult object that represents the result. - * @throws ServiceException - * If a service exception is encountered. - */ - ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException; - - /** - * Deletes a message. - * - * @param message - * A Message object that represents the message to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void deleteMessage(BrokeredMessage message) throws ServiceException; - - /** - * Creates a queue. - * - * @param queue - * A Queue object that represents the queue to create. - * - * @return A CreateQueueResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - CreateQueueResult createQueue(QueueInfo queue) throws ServiceException; - - /** - * Deletes a queue. - * - * @param queuePath - * A String object that represents the name of the queue to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void deleteQueue(String queuePath) throws ServiceException; - - /** - * Retrieves a queue. - * - * @param queuePath - * A String object that represents the name of the queue to retrieve. - * - * @return A GetQueueResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - GetQueueResult getQueue(String queuePath) throws ServiceException; - - /** - * Returns a list of queues. - * - * @return A ListQueuesResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ListQueuesResult listQueues() throws ServiceException; - - ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException; - - /** - * Creates a topic. - * - * @param topic - * A Topic object that represents the topic to create. - * - * @return A CreateTopicResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - CreateTopicResult createTopic(TopicInfo topic) throws ServiceException; - - /** - * Deletes a topic. - * - * @param topicPath - * A String object that represents the name of the queue to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void deleteTopic(String topicPath) throws ServiceException; - - /** - * Retrieves a topic. - * - * @param topicPath - * A String object that represents the name of the topic to retrieve. - * - * @return A GetTopicResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - GetTopicResult getTopic(String topicPath) throws ServiceException; - - /** - * Returns a list of topics. - * - * @return A ListTopicsResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ListTopicsResult listTopics() throws ServiceException; - - ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException; - - /** - * Creates a subscription. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscription - * A Subscription object that represents the subscription to create. - * - * @return A CreateSubscriptionResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) - throws ServiceException; - - /** - * Deletes a subscription. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * - * @param subscriptionName - * A String object that represents the name of the subscription to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException; - - /** - * Retrieves a subscription. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription to retrieve. - * - * @return A GetSubscriptionResult object that represents the result. - * A String object that represents the name of the subscription to retrieve. - * - * @exception ServiceException - * If a service exception is encountered. - */ - GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException; - - /** - * Returns a list of subscriptions. - * - * @param topicPath - * A String object that represents the name of the topic for the subscriptions to retrieve. - * - * @return A ListSubscriptionsResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ListSubscriptionsResult listSubscriptions(String topicPath) throws ServiceException; - - ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) - throws ServiceException; - - /** - * Creates a rule. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * created. - * @param rule - * A Rule object that represents the rule to create. - * - * @return A CreateRuleResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) throws ServiceException; - - /** - * Deletes a rule. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * deleted. - * @param ruleName - * A String object that represents the name of the rule to delete. - * - * @exception ServiceException - * If a service exception is encountered. - */ - void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; - - /** - * Retrieves a rule. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription for which the rule will be - * retrieved. - * @param ruleName - * A String object that represents the name of the rule to retrieve. - * - * @return A GetRuleResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException; - - /** - * Returns a list of rules. - * - * @param topicPath - * A String object that represents the name of the topic for the subscription. - * @param subscriptionName - * A String object that represents the name of the subscription whose rules are being - * retrieved. - * - * @return A ListRulesResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - */ - ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException; - - ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) - throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java deleted file mode 100644 index e7d12cf2dd06b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import com.microsoft.windowsazure.services.core.Configuration; - -/** - * - * Access service bus functionality. - * - */ -public class ServiceBusService { - - private ServiceBusService() { - // class is not instantiated - } - - /** - * Creates an instance of the ServiceBusContract API. - * - */ - public static ServiceBusContract create() { - return Configuration.getInstance().create(ServiceBusContract.class); - } - - /** - * Creates an instance of the ServiceBusContract API using the specified configuration. - * - * @param config - * A Configuration object that represents the configuration for the service bus service. - * - */ - public static ServiceBusContract create(Configuration config) { - return config.create(ServiceBusContract.class); - } - - /** - * Creates an instance of the ServiceBusContract API. - * - */ - public static ServiceBusContract create(String profile) { - return Configuration.getInstance().create(profile, ServiceBusContract.class); - } - - /** - * Creates an instance of the ServiceBusContract API using the specified configuration. - * - * @param config - * A Configuration object that represents the configuration for the service bus service. - * - */ - public static ServiceBusContract create(String profile, Configuration config) { - return config.create(profile, ServiceBusContract.class); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java deleted file mode 100644 index f2d6ce0404bec..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; - -public class Util { - public static Iterable iterateQueues(ServiceBusContract service) throws ServiceException { - // TODO: iterate over link rel=next pagination - return service.listQueues().getItems(); - } - - public static Iterable iterateTopics(ServiceBusContract service) throws ServiceException { - // TODO: iterate over link rel=next pagination - return service.listTopics().getItems(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java deleted file mode 100644 index 0ccbc406d66ae..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.util.Date; - -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonWriteNullProperties; - -// -// members of this class defined per specification at -// http://msdn.microsoft.com/en-us/library/windowsazure/hh367521.aspx#BKMK_REST3prod -// - -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonWriteNullProperties(false) -public class BrokerProperties { - - @JsonProperty("CorrelationId") - String correlationId; - - @JsonProperty("SessionId") - String sessionId; - - @JsonProperty("DeliveryCount") - Integer deliveryCount; - - @JsonProperty("LockedUntilUtc") - Date lockedUntilUtc; - - @JsonProperty("LockToken") - String lockToken; - - @JsonProperty("MessageId") - String messageId; - - @JsonProperty("Label") - String label; - - @JsonProperty("ReplyTo") - String replyTo; - - @JsonProperty("SequenceNumber") - Long sequenceNumber; - - @JsonProperty("TimeToLive") - Double timeToLive; - - @JsonProperty("To") - String to; - - @JsonProperty("ScheduledEnqueueTimeUtc") - Date scheduledEnqueueTimeUtc; - - @JsonProperty("ReplyToSessionId") - String replyToSessionId; - - @JsonProperty("MessageLocation") - String messageLocation; - - @JsonProperty("LockLocation") - String lockLocation; - - @JsonIgnore - public Integer getDeliveryCount() { - return deliveryCount; - } - - public void setDeliveryCount(Integer deliveryCount) { - this.deliveryCount = deliveryCount; - } - - @JsonIgnore - public String getMessageId() { - return messageId; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @JsonIgnore - public Long getSequenceNumber() { - return sequenceNumber; - } - - public void setSequenceNumber(Long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - @JsonIgnore - public Double getTimeToLive() { - return timeToLive; - } - - public void setTimeToLive(Double timeToLive) { - this.timeToLive = timeToLive; - } - - @JsonIgnore - public String getLockToken() { - return lockToken; - } - - public void setLockToken(String lockToken) { - this.lockToken = lockToken; - } - - @JsonIgnore - public Date getLockedUntilUtc() { - return lockedUntilUtc; - } - - public void setLockedUntilUtc(Date lockedUntilUtc) { - this.lockedUntilUtc = lockedUntilUtc; - } - - @JsonIgnore - public String getCorrelationId() { - return correlationId; - } - - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - @JsonIgnore - public String getSessionId() { - return sessionId; - } - - public void setSessionId(String sessionId) { - this.sessionId = sessionId; - } - - @JsonIgnore - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - @JsonIgnore - public String getReplyTo() { - return replyTo; - } - - public void setReplyTo(String replyTo) { - this.replyTo = replyTo; - } - - @JsonIgnore - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - @JsonIgnore - public Date getScheduledEnqueueTimeUtc() { - return scheduledEnqueueTimeUtc; - } - - public void setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { - this.scheduledEnqueueTimeUtc = scheduledEnqueueTimeUtc; - } - - @JsonIgnore - public String getReplyToSessionId() { - return replyToSessionId; - } - - public void setReplyToSessionId(String replyToSessionId) { - this.replyToSessionId = replyToSessionId; - } - - @JsonIgnore - public String getMessageLocation() { - return messageLocation; - } - - public void setMessageLocation(String messageLocation) { - this.messageLocation = messageLocation; - } - - @JsonIgnore - public String getLockLocation() { - return lockLocation; - } - - public void setLockLocation(String lockLocation) { - this.lockLocation = lockLocation; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java deleted file mode 100644 index e7892b7116f83..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; - -import org.codehaus.jackson.JsonGenerationException; -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; - -public class BrokerPropertiesMapper { - - public BrokerProperties fromString(String value) throws IllegalArgumentException { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.readValue(value.getBytes(), BrokerProperties.class); - } - catch (JsonParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } - catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } - catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new IllegalArgumentException(e); - } - } - - public String toString(BrokerProperties value) { - ObjectMapper mapper = new ObjectMapper(); - Writer writer = new StringWriter(); - try { - mapper.writeValue(writer, value); - } - catch (JsonGenerationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } - catch (JsonMappingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } - catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } - return writer.toString(); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java deleted file mode 100644 index 1dd76f10af730..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -public class CustomPropertiesMapper { - // Fri, 04 Mar 2011 08:49:37 GMT - private static final String RFC_1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; - - public String toString(Object value) { - if (value == null) { - return null; - } - - Class type = value.getClass(); - if (type == Byte.class) { - return value.toString(); - } - else if (type == Short.class) { - return value.toString(); - } - else if (type == Integer.class) { - return value.toString(); - } - else if (type == Long.class) { - return value.toString(); - } - else if (type == Float.class) { - return value.toString(); - } - else if (type == Double.class) { - return value.toString(); - } - else if (type == Boolean.class) { - return value.toString(); - } - else if (Calendar.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); - Calendar calendar = (Calendar) value; - format.setTimeZone(calendar.getTimeZone()); - String formatted = format.format(calendar.getTime()); - return "\"" + formatted + "\""; - } - else if (Date.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); - format.setTimeZone(TimeZone.getTimeZone("GMT")); - String formatted = format.format((Date) value); - return "\"" + formatted + "\""; - } - else { - return "\"" + value.toString() + "\""; - } - } - - public Object fromString(String value) throws ParseException { - if (value == null) { - return null; - } - - if (value.startsWith("\"") && value.endsWith("\"")) { - String text = value.substring(1, value.length() - 1); - if (isRFC1123(text)) { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); - return format.parse(text); - } - - return text; - } - else if ("true".equals(value)) { - return Boolean.TRUE; - } - else if ("false".equals(value)) { - return Boolean.FALSE; - } - else if (isInteger(value)) { - return Integer.parseInt(value); - } - else { - return Double.parseDouble(value); - } - } - - private boolean isRFC1123(String text) { - if (text.length() != RFC_1123.length()) { - return false; - } - try { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); - format.parse(text); - return true; - } - catch (ParseException e) { - return false; - } - } - - private boolean isInteger(String value) { - try { - Integer.parseInt(value); - return true; - } - catch (NumberFormatException e) { - return false; - } - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java deleted file mode 100644 index 2edab43e9419d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -public class EntryModel { - Entry entry; - T model; - - public EntryModel(Entry entry, T model) { - this.entry = entry; - this.model = model; - } - - public Entry getEntry() { - return entry; - } - - public void setEntry(Entry entry) { - this.entry = entry; - } - - public T getModel() { - return model; - } - - public void setModel(T model) { - this.model = model; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java deleted file mode 100644 index 57fe3cd996fc1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Type; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.MessageBodyWriter; - -import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; -import com.sun.jersey.spi.MessageBodyWorkers; - -public class EntryModelProvider extends AbstractMessageReaderWriterProvider> { - - MessageBodyWorkers workers; - - public EntryModelProvider(@Context MessageBodyWorkers workers) { - this.workers = workers; - } - - public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return EntryModel.class.isAssignableFrom(type); - } - - public EntryModel readFrom(Class> type, Type genericType, Annotation[] annotations, - MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { - - MessageBodyReader reader = workers - .getMessageBodyReader(Entry.class, Entry.class, annotations, mediaType); - - Entry entry = reader.readFrom(Entry.class, Entry.class, annotations, mediaType, httpHeaders, entityStream); - - // these exceptions are masked as a RuntimeException because they cannot - // be thrown by this override - try { - return type.getConstructor(Entry.class).newInstance(entry); - } - catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - catch (InstantiationException e) { - throw new RuntimeException(e); - } - } - - public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return EntryModel.class.isAssignableFrom(type); - } - - public void writeTo(EntryModel t, Class type, Type genericType, Annotation[] annotations, - MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) - throws IOException, WebApplicationException { - - Entry entry = t.getEntry(); - - MessageBodyWriter writer = workers - .getMessageBodyWriter(Entry.class, Entry.class, annotations, mediaType); - - writer.writeTo(entry, Entry.class, genericType, annotations, mediaType, httpHeaders, entityStream); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java deleted file mode 100644 index 728e70dc4273c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import com.microsoft.windowsazure.services.core.Builder; - -public class Exports implements Builder.Exports { - - public void register(Builder.Registry registry) { - registry.add(WrapContract.class, WrapRestProxy.class); - registry.add(WrapTokenManager.class); - registry.add(WrapFilter.class); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java deleted file mode 100644 index 7654604e20fd1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.PropertyException; - -@Provider -@Produces("application/atom+xml") -public class MarshallerProvider implements ContextResolver { - - @Context - private ContextResolver jaxbContextResolver; - - public Marshaller getContext(Class type) { - Marshaller marshaller; - try { - marshaller = getJAXBContext(type).createMarshaller(); - } - catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - com.sun.xml.bind.marshaller.NamespacePrefixMapper mapper = new NamespacePrefixMapperImpl(); - try { - marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper); - } - catch (PropertyException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - return marshaller; - } - - private JAXBContext getJAXBContext(Class type) throws Exception { - JAXBContext context = null; - if (jaxbContextResolver != null) { - context = jaxbContextResolver.getContext(type); - } - if (context == null) { - context = JAXBContext.newInstance(type); - } - return context; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java deleted file mode 100644 index 5af2ccf6f6df1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import com.sun.xml.bind.marshaller.NamespacePrefixMapper; - -public class NamespacePrefixMapperImpl extends NamespacePrefixMapper { - - @Override - public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { - if (namespaceUri == "http://www.w3.org/2005/Atom") { - return "atom"; - } - else if (namespaceUri == "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect") { - return ""; - } - return suggestion; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java deleted file mode 100644 index da556270bf0e1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ /dev/null @@ -1,488 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import javax.inject.Inject; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; -import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; -import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; - -public class ServiceBusExceptionProcessor implements ServiceBusContract { - - private final ServiceBusContract next; - static Log log = LogFactory.getLog(ServiceBusContract.class); - - public ServiceBusExceptionProcessor(ServiceBusContract next) { - this.next = next; - } - - @Inject - public ServiceBusExceptionProcessor(ServiceBusRestProxy next) { - this.next = next; - } - - @Override - public ServiceBusContract withFilter(ServiceFilter filter) { - return new ServiceBusExceptionProcessor(next.withFilter(filter)); - } - - private ServiceException processCatch(ServiceException e) { - log.warn(e.getMessage(), e.getCause()); - return ServiceExceptionFactory.process("serviceBus", e); - } - - @Override - public void sendQueueMessage(String path, BrokeredMessage message) throws ServiceException { - try { - next.sendQueueMessage(path, message); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { - try { - return next.receiveQueueMessage(queueName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveQueueMessageResult receiveQueueMessage(String queueName, ReceiveMessageOptions options) - throws ServiceException { - try { - return next.receiveQueueMessage(queueName, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void sendTopicMessage(String path, BrokeredMessage message) throws ServiceException { - try { - next.sendTopicMessage(path, message); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) - throws ServiceException { - try { - return next.receiveSubscriptionMessage(topicName, subscriptionName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, - ReceiveMessageOptions options) throws ServiceException { - try { - return next.receiveSubscriptionMessage(topicName, subscriptionName, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void unlockMessage(BrokeredMessage message) throws ServiceException { - try { - next.unlockMessage(message); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteMessage(BrokeredMessage message) throws ServiceException { - try { - next.deleteMessage(message); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateQueueResult createQueue(QueueInfo queue) throws ServiceException { - try { - return next.createQueue(queue); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteQueue(String queuePath) throws ServiceException { - try { - next.deleteQueue(queuePath); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetQueueResult getQueue(String queuePath) throws ServiceException { - try { - return next.getQueue(queuePath); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListQueuesResult listQueues() throws ServiceException { - try { - return next.listQueues(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateTopicResult createTopic(TopicInfo topic) throws ServiceException { - try { - return next.createTopic(topic); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteTopic(String topicPath) throws ServiceException { - try { - next.deleteTopic(topicPath); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetTopicResult getTopic(String topicPath) throws ServiceException { - try { - return next.getTopic(topicPath); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListTopicsResult listTopics() throws ServiceException { - try { - return next.listTopics(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) - throws ServiceException { - try { - return next.createSubscription(topicPath, subscription); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteSubscription(String topicPath, String subscriptionName) throws ServiceException { - try { - next.deleteSubscription(topicPath, subscriptionName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) throws ServiceException { - try { - return next.getSubscription(topicPath, subscriptionName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListSubscriptionsResult listSubscriptions(String topicPath) throws ServiceException { - try { - return next.listSubscriptions(topicPath); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) - throws ServiceException { - try { - return next.createRule(topicPath, subscriptionName, rule); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { - try { - next.deleteRule(topicPath, subscriptionName, ruleName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) throws ServiceException { - try { - return next.getRule(topicPath, subscriptionName, ruleName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListRulesResult listRules(String topicPath, String subscriptionName) throws ServiceException { - try { - return next.listRules(topicPath, subscriptionName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - try { - return next.listQueues(options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { - try { - return next.listTopics(options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListSubscriptionsResult listSubscriptions(String topicName, ListSubscriptionsOptions options) - throws ServiceException { - try { - return next.listSubscriptions(topicName, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ListRulesResult listRules(String topicName, String subscriptionName, ListRulesOptions options) - throws ServiceException { - try { - return next.listRules(topicName, subscriptionName, options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void sendMessage(String path, BrokeredMessage message) throws ServiceException { - try { - next.sendMessage(path, message); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveMessageResult receiveMessage(String path) throws ServiceException { - try { - return next.receiveMessage(path); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException { - try { - return next.receiveMessage(path, 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/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java deleted file mode 100644 index 3c6ea2b5c1101..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ /dev/null @@ -1,412 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.io.InputStream; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.core.MediaType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusContract; -import com.microsoft.windowsazure.services.serviceBus.models.AbstractListOptions; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; -import com.microsoft.windowsazure.services.serviceBus.models.CreateQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.CreateTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetQueueResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetRuleResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetSubscriptionResult; -import com.microsoft.windowsazure.services.serviceBus.models.GetTopicResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveQueueMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveSubscriptionMessageResult; -import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; -import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -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; - -public class ServiceBusRestProxy implements ServiceBusContract { - - private Client channel; - private final String uri; - private final BrokerPropertiesMapper mapper; - private final CustomPropertiesMapper customPropertiesMapper; - static Log log = LogFactory.getLog(ServiceBusContract.class); - - ServiceFilter[] filters; - - @Inject - public ServiceBusRestProxy(Client channel, @Named("serviceBus") WrapFilter authFilter, - @Named("serviceBus.uri") String uri, BrokerPropertiesMapper mapper) { - - this.channel = channel; - this.filters = new ServiceFilter[0]; - this.uri = uri; - this.mapper = mapper; - this.customPropertiesMapper = new CustomPropertiesMapper(); - channel.addFilter(authFilter); - } - - public ServiceBusRestProxy(Client channel, ServiceFilter[] filters, String uri, BrokerPropertiesMapper mapper) { - this.channel = channel; - this.filters = filters; - this.uri = uri; - this.mapper = mapper; - this.customPropertiesMapper = new CustomPropertiesMapper(); - } - - @Override - public ServiceBusContract withFilter(ServiceFilter filter) { - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new ServiceBusRestProxy(channel, newFilters, uri, mapper); - } - - public Client getChannel() { - return channel; - } - - public void setChannel(Client channel) { - this.channel = channel; - } - - private WebResource getResource() { - WebResource resource = getChannel().resource(uri); - for (ServiceFilter filter : filters) { - resource.addFilter(new ClientFilterAdapter(filter)); - } - return resource; - } - - @Override - public void sendMessage(String path, BrokeredMessage message) { - Builder request = getResource().path(path).path("messages").getRequestBuilder(); - - if (message.getContentType() != null) - request = request.type(message.getContentType()); - - if (message.getBrokerProperties() != null) - request = request.header("BrokerProperties", mapper.toString(message.getBrokerProperties())); - - for (java.util.Map.Entry entry : message.getProperties().entrySet()) { - request.header(entry.getKey(), customPropertiesMapper.toString(entry.getValue())); - } - - request.post(message.getBody()); - } - - @Override - public void sendQueueMessage(String path, BrokeredMessage message) throws ServiceException { - sendMessage(path, message); - } - - @Override - public ReceiveQueueMessageResult receiveQueueMessage(String queueName) throws ServiceException { - return receiveQueueMessage(queueName, ReceiveMessageOptions.DEFAULT); - } - - @Override - public ReceiveQueueMessageResult receiveQueueMessage(String queuePath, ReceiveMessageOptions options) - throws ServiceException { - - WebResource resource = getResource().path(queuePath).path("messages").path("head"); - - BrokeredMessage message = receiveMessage(options, resource); - return new ReceiveQueueMessageResult(message); - } - - @Override - public ReceiveMessageResult receiveMessage(String path) throws ServiceException { - return receiveMessage(path, ReceiveMessageOptions.DEFAULT); - } - - @Override - public ReceiveMessageResult receiveMessage(String path, ReceiveMessageOptions options) throws ServiceException { - - WebResource resource = getResource().path(path).path("messages").path("head"); - - BrokeredMessage message = receiveMessage(options, resource); - return new ReceiveMessageResult(message); - } - - private BrokeredMessage receiveMessage(ReceiveMessageOptions options, WebResource resource) { - if (options.getTimeout() != null) { - resource = resource.queryParam("timeout", Integer.toString(options.getTimeout())); - } - - ClientResponse clientResult; - if (options.isReceiveAndDelete()) { - clientResult = resource.delete(ClientResponse.class); - } - else if (options.isPeekLock()) { - clientResult = resource.post(ClientResponse.class, ""); - } - else { - throw new RuntimeException("Unknown ReceiveMode"); - } - - BrokerProperties brokerProperties; - if (clientResult.getHeaders().containsKey("BrokerProperties")) { - brokerProperties = mapper.fromString(clientResult.getHeaders().getFirst("BrokerProperties")); - } - else { - brokerProperties = new BrokerProperties(); - } - - String location = clientResult.getHeaders().getFirst("Location"); - if (location != null) { - brokerProperties.setLockLocation(location); - } - - BrokeredMessage message = new BrokeredMessage(brokerProperties); - - MediaType contentType = clientResult.getType(); - if (contentType != null) { - message.setContentType(contentType.toString()); - } - - Date date = clientResult.getResponseDate(); - if (date != null) { - message.setDate(date); - } - - InputStream body = clientResult.getEntityInputStream(); - if (body != null) { - message.setBody(body); - } - - for (String key : clientResult.getHeaders().keySet()) { - Object value = clientResult.getHeaders().getFirst(key); - try { - value = customPropertiesMapper.fromString(value.toString()); - message.setProperty(key, value); - } - catch (ParseException e) { - //log.warn("Unable to parse custom header", e); - } - catch (NumberFormatException e) { - //log.warn("Unable to parse custom header", e); - } - } - - return message; - } - - @Override - public void sendTopicMessage(String topicName, BrokeredMessage message) throws ServiceException { - sendMessage(topicName, message); - } - - @Override - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName) - throws ServiceException { - return receiveSubscriptionMessage(topicName, subscriptionName, ReceiveMessageOptions.DEFAULT); - } - - @Override - public ReceiveSubscriptionMessageResult receiveSubscriptionMessage(String topicName, String subscriptionName, - ReceiveMessageOptions options) throws ServiceException { - WebResource resource = getResource().path(topicName).path("subscriptions").path(subscriptionName) - .path("messages").path("head"); - - BrokeredMessage message = receiveMessage(options, resource); - return new ReceiveSubscriptionMessageResult(message); - } - - @Override - public void unlockMessage(BrokeredMessage message) throws ServiceException { - getChannel().resource(message.getLockLocation()).put(""); - } - - @Override - public void deleteMessage(BrokeredMessage message) throws ServiceException { - getChannel().resource(message.getLockLocation()).delete(); - } - - @Override - public CreateQueueResult createQueue(QueueInfo entry) throws ServiceException { - return new CreateQueueResult(getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(QueueInfo.class, entry)); - } - - @Override - public void deleteQueue(String queuePath) throws ServiceException { - getResource().path(queuePath).delete(); - } - - @Override - public GetQueueResult getQueue(String queuePath) throws ServiceException { - return new GetQueueResult(getResource().path(queuePath).get(QueueInfo.class)); - } - - @Override - public ListQueuesResult listQueues(ListQueuesOptions options) throws ServiceException { - Feed feed = listOptions(options, getResource().path("$Resources/Queues")).get(Feed.class); - ArrayList queues = new ArrayList(); - for (Entry entry : feed.getEntries()) { - queues.add(new QueueInfo(entry)); - } - ListQueuesResult result = new ListQueuesResult(); - result.setItems(queues); - return result; - } - - private WebResource listOptions(AbstractListOptions options, WebResource path) { - if (options.getTop() != null) { - path = path.queryParam("$top", options.getTop().toString()); - } - if (options.getSkip() != null) { - path = path.queryParam("$skip", options.getSkip().toString()); - } - return path; - } - - @Override - public CreateTopicResult createTopic(TopicInfo entry) throws ServiceException { - return new CreateTopicResult(getResource().path(entry.getPath()) - .type("application/atom+xml;type=entry;charset=utf-8").put(TopicInfo.class, entry)); - } - - @Override - public void deleteTopic(String TopicPath) throws ServiceException { - getResource().path(TopicPath).delete(); - } - - @Override - public GetTopicResult getTopic(String TopicPath) throws ServiceException { - return new GetTopicResult(getResource().path(TopicPath).get(TopicInfo.class)); - } - - @Override - public ListTopicsResult listTopics(ListTopicsOptions options) throws ServiceException { - Feed feed = listOptions(options, getResource().path("$Resources/Topics")).get(Feed.class); - ArrayList Topics = new ArrayList(); - for (Entry entry : feed.getEntries()) { - Topics.add(new TopicInfo(entry)); - } - ListTopicsResult result = new ListTopicsResult(); - result.setItems(Topics); - return result; - } - - @Override - public CreateSubscriptionResult createSubscription(String topicPath, SubscriptionInfo subscription) { - return new CreateSubscriptionResult(getResource().path(topicPath).path("subscriptions") - .path(subscription.getName()).type("application/atom+xml;type=entry;charset=utf-8") - .put(SubscriptionInfo.class, subscription)); - } - - @Override - public void deleteSubscription(String topicPath, String subscriptionName) { - getResource().path(topicPath).path("subscriptions").path(subscriptionName).delete(); - } - - @Override - public GetSubscriptionResult getSubscription(String topicPath, String subscriptionName) { - return new GetSubscriptionResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) - .get(SubscriptionInfo.class)); - } - - @Override - public ListSubscriptionsResult listSubscriptions(String topicPath, ListSubscriptionsOptions options) { - Feed feed = listOptions(options, getResource().path(topicPath).path("subscriptions")).get(Feed.class); - ArrayList list = new ArrayList(); - for (Entry entry : feed.getEntries()) { - list.add(new SubscriptionInfo(entry)); - } - ListSubscriptionsResult result = new ListSubscriptionsResult(); - result.setItems(list); - return result; - } - - @Override - public CreateRuleResult createRule(String topicPath, String subscriptionName, RuleInfo rule) { - return new CreateRuleResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) - .path("rules").path(rule.getName()).type("application/atom+xml;type=entry;charset=utf-8") - .put(RuleInfo.class, rule)); - } - - @Override - public void deleteRule(String topicPath, String subscriptionName, String ruleName) { - getResource().path(topicPath).path("subscriptions").path(subscriptionName).path("rules").path(ruleName) - .delete(); - } - - @Override - public GetRuleResult getRule(String topicPath, String subscriptionName, String ruleName) { - return new GetRuleResult(getResource().path(topicPath).path("subscriptions").path(subscriptionName) - .path("rules").path(ruleName).get(RuleInfo.class)); - } - - @Override - public ListRulesResult listRules(String topicPath, String subscriptionName, ListRulesOptions options) { - Feed feed = listOptions(options, - getResource().path(topicPath).path("subscriptions").path(subscriptionName).path("rules")).get( - Feed.class); - ArrayList list = new ArrayList(); - for (Entry entry : feed.getEntries()) { - list.add(new RuleInfo(entry)); - } - ListRulesResult result = new ListRulesResult(); - result.setItems(list); - return result; - } - - @Override - public ListQueuesResult listQueues() throws ServiceException { - return listQueues(ListQueuesOptions.DEFAULT); - } - - @Override - public ListTopicsResult listTopics() throws ServiceException { - return listTopics(ListTopicsOptions.DEFAULT); - } - - @Override - public ListSubscriptionsResult listSubscriptions(String topicName) throws ServiceException { - return listSubscriptions(topicName, ListSubscriptionsOptions.DEFAULT); - } - - @Override - public ListRulesResult listRules(String topicName, String subscriptionName) throws ServiceException { - return listRules(topicName, subscriptionName, ListRulesOptions.DEFAULT); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java deleted file mode 100644 index 9732c0741c571..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -public class WrapAccessTokenResult { - String accessToken; - long expiresIn; - - /** - * @return the accessToken - */ - public String getAccessToken() { - return accessToken; - } - - /** - * @param accessToken - * the accessToken to set - */ - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - /** - * @return the expiresIn - */ - public long getExpiresIn() { - return expiresIn; - } - - /** - * @param expiresIn - * the expiresIn to set - */ - public void setExpiresIn(long expiresIn) { - this.expiresIn = expiresIn; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java deleted file mode 100644 index 8514686db4329..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import com.microsoft.windowsazure.services.core.ServiceException; - -public interface WrapContract { - WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) - throws ServiceException; -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java deleted file mode 100644 index 5758ac151d004..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.net.URISyntaxException; - -import com.microsoft.windowsazure.services.core.ServiceException; -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; - -public class WrapFilter extends ClientFilter { - private final WrapTokenManager tokenManager; - - public WrapFilter(WrapTokenManager tokenManager) { - this.tokenManager = tokenManager; - } - - @Override - public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - - String accessToken; - try { - accessToken = tokenManager.getAccessToken(cr.getURI()); - } - catch (ServiceException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - catch (URISyntaxException e) { - // must wrap exception because of base class signature - throw new ClientHandlerException(e); - } - - cr.getHeaders().add("Authorization", "WRAP access_token=\"" + accessToken + "\""); - - return this.getNext().handle(cr); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java deleted file mode 100644 index d73638329561d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import javax.inject.Inject; -import javax.ws.rs.core.MediaType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.representation.Form; - -public class WrapRestProxy implements WrapContract { - Client channel; - - static Log log = LogFactory.getLog(WrapContract.class); - - @Inject - public WrapRestProxy(Client channel) { - this.channel = channel; - } - - public WrapAccessTokenResult wrapAccessToken(String uri, String name, String password, String scope) - throws ServiceException { - Form requestForm = new Form(); - requestForm.add("wrap_name", name); - requestForm.add("wrap_password", password); - requestForm.add("wrap_scope", scope); - - Form responseForm; - try { - responseForm = channel.resource(uri).accept(MediaType.APPLICATION_FORM_URLENCODED) - .type(MediaType.APPLICATION_FORM_URLENCODED).post(Form.class, requestForm); - } - catch (UniformInterfaceException e) { - log.warn("WRAP server returned error acquiring access_token", e); - throw ServiceExceptionFactory.process("WRAP", new ServiceException( - "WRAP server returned error acquiring access_token", e)); - } - - WrapAccessTokenResult response = new WrapAccessTokenResult(); - - response.setAccessToken(responseForm.getFirst("wrap_access_token")); - - String expiresIn = responseForm.getFirst("wrap_access_token_expires_in"); - response.setExpiresIn(Long.parseLong(expiresIn)); - - return response; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java deleted file mode 100644 index 48e28220249a2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Date; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.management.timer.Timer; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.utils.DateFactory; - -public class WrapTokenManager { - - WrapContract contract; - private final DateFactory dateFactory; - private final String uri; - private final String name; - private final String password; - - private final Map activeTokens; - - @Inject - public WrapTokenManager(WrapContract contract, DateFactory dateFactory, @Named("wrap.uri") String uri, - @Named("wrap.name") String name, @Named("wrap.password") String password) { - this.contract = contract; - this.dateFactory = dateFactory; - this.uri = uri; - this.name = name; - this.password = password; - activeTokens = new ConcurrentHashMap(); - } - - /** - * @return the contract - */ - public WrapContract getContract() { - return contract; - } - - /** - * @param contract - * the contract to set - */ - public void setContract(WrapContract contract) { - this.contract = contract; - } - - public String getAccessToken(URI targetUri) throws ServiceException, URISyntaxException { - Date now = dateFactory.getDate(); - - URI scopeUri = new URI("http", targetUri.getAuthority(), targetUri.getPath(), null, null); - String scope = scopeUri.toString(); - - ActiveToken active = this.activeTokens.get(scope); - - if (active != null && now.before(active.getExpiresUtc())) { - return active.getWrapResponse().getAccessToken(); - } - - // sweep expired tokens out of collection - Iterator> iterator = activeTokens.entrySet().iterator(); - while (iterator.hasNext()) { - Entry entry = iterator.next(); - if (!now.before(entry.getValue().getExpiresUtc())) { - iterator.remove(); - } - } - - WrapAccessTokenResult wrapResponse = getContract().wrapAccessToken(uri, name, password, scope); - Date expiresUtc = new Date(now.getTime() + wrapResponse.getExpiresIn() * Timer.ONE_SECOND / 2); - - ActiveToken acquired = new ActiveToken(); - acquired.setWrapResponse(wrapResponse); - acquired.setExpiresUtc(expiresUtc); - this.activeTokens.put(scope, acquired); - - return wrapResponse.getAccessToken(); - } - - class ActiveToken { - Date expiresUtc; - WrapAccessTokenResult wrapResponse; - - /** - * @return the expiresUtc - */ - public Date getExpiresUtc() { - return expiresUtc; - } - - /** - * @param expiresUtc - * the expiresUtc to set - */ - public void setExpiresUtc(Date expiresUtc) { - this.expiresUtc = expiresUtc; - } - - /** - * @return the wrapResponse - */ - public WrapAccessTokenResult getWrapResponse() { - return wrapResponse; - } - - /** - * @param wrapResponse - * the wrapResponse to set - */ - public void setWrapResponse(WrapAccessTokenResult wrapResponse) { - this.wrapResponse = wrapResponse; - } - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java deleted file mode 100644 index b7695de3aa72c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -public abstract class AbstractListOptions { - Integer skip; - Integer top; - - public Integer getSkip() { - return skip; - } - - @SuppressWarnings("unchecked") - public T setSkip(Integer skip) { - this.skip = skip; - return (T) this; - } - - public Integer getTop() { - return top; - } - - @SuppressWarnings("unchecked") - public T setTop(Integer top) { - this.top = top; - return (T) this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java deleted file mode 100644 index e149f01872e70..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; - -/** - * Represents a service bus message. - */ -public class BrokeredMessage { - BrokerProperties brokerProperties; - InputStream body; - String contentType; - Date date; - Map customProperties; - - /** - * Creates an instance of the Message class. - */ - public BrokeredMessage() { - this(new BrokerProperties()); - } - - /** - * Creates an instance of the Message class using the specified InputStream. - * - * @param body - * An InputStream object that represents the body of the message. - */ - public BrokeredMessage(InputStream body) { - this(new BrokerProperties()); - this.body = body; - } - - /** - * Creates an instance of the Message class using the specified byte array. - * - * @param body - * A byte array that represents the body of the message. - */ - public BrokeredMessage(byte[] body) { - this(new BrokerProperties()); - this.body = (body == null) ? null : new ByteArrayInputStream(body); - } - - /** - * Creates an instance of the Message class using the specified - * string. - * - * @param body - * A String object that represents the body of the message. - */ - public BrokeredMessage(String body) { - this(new BrokerProperties()); - this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); - } - - /** - * Internal - * - * @param properties - */ - public BrokeredMessage(BrokerProperties properties) { - this.brokerProperties = properties; - this.customProperties = new HashMap(); - } - - /** - * Returns the properties of the message. - * - * @return A {@link BrokerProperties} object that represents the properties of the message. - */ - public BrokerProperties getBrokerProperties() { - return brokerProperties; - } - - /** - * Returns the body of the message. - * - * @return An InputStream object that represents the body of the message. - */ - public InputStream getBody() { - return body; - } - - /** - * Specifies the body of the message. - * - * @param body - * An InputStream object that represents the body of the message. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setBody(InputStream body) { - this.body = body; - return this; - } - - /** - * Returns the content type of the message. - * - * @return A String object that represents the content type. - */ - public String getContentType() { - return contentType; - } - - /** - * Sets the content type of the message. - * - * @param contentType - * A String object that represents the content type. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Returns the date/time of the message. - * - * @return A Date object that represents the date/time of the object. - */ - public Date getDate() { - return date; - } - - /** - * Sets the date/time of the message. - * - * @param date - * A Date object that represents the date/time of the object. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setDate(Date date) { - this.date = date; - return this; - } - - /** - * Returns a user defined property of the message. - * - * @param name - * A String object that represents the name of the property. - * @return An Object object that represents the value of the property. - */ - public Object getProperty(String name) { - return customProperties.get(name); - } - - /** - * Sets a user defined property of the message. - * - * @param name - * A String object that represents the name of the property. - * @param value - * An Object object that represents the value of the property. - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setProperty(String name, Object value) { - customProperties.put(name, value); - return this; - } - - /** - * Returns the user defined properties of the message. - * - * @return A Map object that represents the user defined properties. - */ - public Map getProperties() { - return customProperties; - } - - /** - * Returns the delivery count of the message. - * - * @return The delivery count. - */ - public Integer getDeliveryCount() { - return brokerProperties.getDeliveryCount(); - } - - /** - * Returns the message ID. - * - * @return A String object that represents the message ID. - */ - public String getMessageId() { - return brokerProperties.getMessageId(); - } - - /** - * Sets the message ID. - * - * @param messageId - * A String object that represents the message ID. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setMessageId(String messageId) { - brokerProperties.setMessageId(messageId); - return this; - } - - /** - * Returns the message sequence number. - * - * @return The message sequence number. - * - */ - public Long getSequenceNumber() { - return brokerProperties.getSequenceNumber(); - } - - /** - * Returns the time-to-live for the message. - * - * @return The time, in seconds, for the message to live. - */ - public Double getTimeToLive() { - return brokerProperties.getTimeToLive(); - } - - /** - * Sets the time-to-live for the message. - * - * @param timeToLive - * The time, in seconds, for the message to live. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setTimeToLive(Double timeToLive) { - brokerProperties.setTimeToLive(timeToLive); - return this; - } - - /** - * Returns the lock token for the message. - * - * @return A String object that represents the lock token. - */ - public String getLockToken() { - return brokerProperties.getLockToken(); - } - - /** - * Returns the locked-until date/time. - * - * @return A Date object that represents the locked-until date/time, in UTC format. - */ - public Date getLockedUntilUtc() { - return brokerProperties.getLockedUntilUtc(); - } - - /** - * Returns the correlation ID. - * - * @return A String object that represents the correlation ID. - * - */ - public String getCorrelationId() { - return brokerProperties.getCorrelationId(); - } - - /** - * Sets the correlation ID. - * - * @param correlationId - * A String object that represents the correlation ID. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setCorrelationId(String correlationId) { - brokerProperties.setCorrelationId(correlationId); - return this; - } - - /** - * Returns the session ID for the message. - * - * @return A String object that represents the session ID. - * - */ - public String getSessionId() { - return brokerProperties.getSessionId(); - } - - /** - * Sets the session ID for the message. - * - * @param sessionId - * A String object that represents the session ID. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setSessionId(String sessionId) { - brokerProperties.setSessionId(sessionId); - return this; - } - - /** - * Returns the label of the message. - * - * @return A String object that represents the label. - */ - public String getLabel() { - return brokerProperties.getLabel(); - } - - /** - * Sets the label of the message. - * - * @param label - * A String object that represents the label. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setLabel(String label) { - brokerProperties.setLabel(label); - return this; - } - - /** - * Returns the Reply-To recipient of the message. - * - * @return A String object that represents the Reply-To recipient. - */ - public String getReplyTo() { - return brokerProperties.getReplyTo(); - } - - /** - * Sets the Reply-To recipient for the message. - * - * @param replyTo - * A String object that represents the Reply-To recipient. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setReplyTo(String replyTo) { - brokerProperties.setReplyTo(replyTo); - return this; - } - - /** - * Returns the To recipient of the message. - * - * @return A String object that represents the To recipient. - */ - public String getTo() { - return brokerProperties.getTo(); - } - - /** - * Sets the To recipient of the message. - * - * @param A - * String object that represents the To recipient. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setTo(String to) { - brokerProperties.setTo(to); - return this; - } - - /** - * Returns the scheduled enqueue date/time. - * - * @return A Date object that represents the date/time of the message in UTC format. - */ - public Date getScheduledEnqueueTimeUtc() { - return brokerProperties.getScheduledEnqueueTimeUtc(); - } - - /** - * Sets the scheduled enqueue time. - * - * @param scheduledEnqueueTimeUtc - * A Date object that represents the date/time of the message in UTC format. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setScheduledEnqueueTimeUtc(Date scheduledEnqueueTimeUtc) { - brokerProperties.setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtc); - return this; - } - - /** - * Returns the session ID of the Reply To recipient. - * - * @return A String object that represents the session ID of the Reply To recipient. - */ - public String getReplyToSessionId() { - return brokerProperties.getReplyToSessionId(); - } - - /** - * Sets the session ID of the Reply To recipient. - * - * @param replyToSessionId - * A String object that represents the session ID of the Reply To recipient. - * - * @return A Message object that represents the updated message. - */ - public BrokeredMessage setReplyToSessionId(String replyToSessionId) { - brokerProperties.setReplyToSessionId(replyToSessionId); - return this; - } - - /** - * Returns the message location. - * - * @return A String object that represents the message location. - */ - public String getMessageLocation() { - return brokerProperties.getMessageLocation(); - } - - /** - * Returns the lock location. - * - * @return A String object that represents the lock location. - */ - public String getLockLocation() { - return brokerProperties.getLockLocation(); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java deleted file mode 100644 index bf617d161f245..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a createQueue operation. - */ -public class CreateQueueResult { - - private QueueInfo value; - - /** - * Creates an instance of the CreateQueueResult class. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public CreateQueueResult(QueueInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public void setValue(QueueInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link QueueInfo} object that represents the value of the result. - */ - public QueueInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java deleted file mode 100644 index 4477a1a242d27..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a createRule operation. - */ -public class CreateRuleResult { - - private RuleInfo value; - - /** - * Creates an instance of the CreateRuleResult class. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public CreateRuleResult(RuleInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public void setValue(RuleInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link RuleInfo} object that represents the value of the result. - */ - public RuleInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java deleted file mode 100644 index 477e1abb50e31..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a createSubscription operation. - */ -public class CreateSubscriptionResult { - - private SubscriptionInfo value; - - /** - * Creates an instance of the CreateSubscriptionResult class. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the result. - */ - public CreateSubscriptionResult(SubscriptionInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ - public void setValue(SubscriptionInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link SubscriptionInfo} object that represents the value of the result. - */ - public SubscriptionInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java deleted file mode 100644 index 91c5f30d20e84..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a createTopic operation. - */ -public class CreateTopicResult { - - private TopicInfo value; - - /** - * Creates an instance of the CreateTopicResult class. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public CreateTopicResult(TopicInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public void setValue(TopicInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link TopicInfo} object that represents the value of the result. - */ - public TopicInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java deleted file mode 100644 index 9e3e5da19a070..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a getQueue operation. - */ -public class GetQueueResult { - - private QueueInfo value; - - /** - * Creates an instance of the GetQueueResult class. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public GetQueueResult(QueueInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link QueueInfo} object assigned as the value of the result. - */ - public void setValue(QueueInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link QueueInfo} object that represents the value of the result. - */ - public QueueInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java deleted file mode 100644 index 222ae08d8463b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a getRule operation. - */ -public class GetRuleResult { - - private RuleInfo value; - - /** - * Creates an instance of the GetRuleResult class. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public GetRuleResult(RuleInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link RuleInfo} object assigned as the value of the result. - */ - public void setValue(RuleInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link RuleInfo} object that represents the value of the result. - */ - public RuleInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java deleted file mode 100644 index 4649f6f2e4b03..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a getSubscription operation. - */ -public class GetSubscriptionResult { - - private SubscriptionInfo value; - - /** - * Creates an instance of the GetSubscriptionResult class. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ - public GetSubscriptionResult(SubscriptionInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link SubscriptionInfo} object assigned as the value of the - * result. - */ - public void setValue(SubscriptionInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link SubscriptionInfo} object that represents the value of the - * result. - */ - public SubscriptionInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java deleted file mode 100644 index d546630c39b52..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a getTopic operation. - */ -public class GetTopicResult { - - private TopicInfo value; - - /** - * Creates an instance of the GetTopicResult class. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public GetTopicResult(TopicInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link TopicInfo} object assigned as the value of the result. - */ - public void setValue(TopicInfo value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link TopicInfo} object that represents the value of the result. - */ - public TopicInfo getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java deleted file mode 100644 index db1d3a1d41c13..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -public class ListQueuesOptions extends AbstractListOptions { - public static final ListQueuesOptions DEFAULT = new ListQueuesOptions(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java deleted file mode 100644 index df68d6fd58608..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import java.util.List; - -/** - * Represents the result of a listQueues operation. - */ -public class ListQueuesResult { - - private List items; - - /** - * Returns the items in the result list. - * - * @return A List of {@link QueueInfo} objects that represent the - * items in the result list. - */ - public List getItems() { - return items; - } - - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link QueueInfo} objects assigned as the value of the - * result. - */ - public void setItems(List items) { - this.items = items; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java deleted file mode 100644 index 5ba5ed561814e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -public class ListRulesOptions extends AbstractListOptions { - public static final ListRulesOptions DEFAULT = new ListRulesOptions(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java deleted file mode 100644 index 22cc18bb0d5fd..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import java.util.List; - -/** - * Represents the result of a listRules operation. - */ -public class ListRulesResult { - - private List items; - - /** - * Returns the items in the result list. - * - * @return A List of {@link RuleInfo} objects that represent the - * items in the result list. - */ - public List getItems() { - return items; - } - - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link RuleInfo} objects assigned as the value of the - * result. - */ - public void setItems(List items) { - this.items = items; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java deleted file mode 100644 index 472b25a35e6e9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -public class ListSubscriptionsOptions extends AbstractListOptions { - public static final ListSubscriptionsOptions DEFAULT = new ListSubscriptionsOptions(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java deleted file mode 100644 index d77f40bfb519a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import java.util.List; - -/** - * Represents the result of a listSubscriptions operation. - */ -public class ListSubscriptionsResult { - - private List items; - - /** - * Returns the items in the result list. - * - * @return A List of {@link SubscriptionInfo} objects that represent the - * items in the result list. - */ - public List getItems() { - return items; - } - - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link SubscriptionInfo} objects assigned as the value of - * the result. - */ - public void setItems(List items) { - this.items = items; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java deleted file mode 100644 index 54ffa6f364d55..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -public class ListTopicsOptions extends AbstractListOptions { - public static final ListTopicsOptions DEFAULT = new ListTopicsOptions(); -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java deleted file mode 100644 index 0aa49b51d9cf9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import java.util.List; - -/** - * Represents the result of a listTopics operation. - */ -public class ListTopicsResult { - - private List items; - - /** - * Returns the items in the result list. - * - * @return A List of {@link TopicInfo} objects that represent the - * items in the result list. - */ - public List getItems() { - return items; - } - - /** - * Specfies the items in the result list. - * - * @param value - * A List object that contains the {@link TopicInfo} objects assigned as the value of the - * result. - */ - public void setItems(List items) { - this.items = items; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java deleted file mode 100644 index 65e08b395acd8..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ /dev/null @@ -1,303 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import javax.ws.rs.core.MediaType; -import javax.xml.datatype.Duration; - -import com.microsoft.windowsazure.services.serviceBus.implementation.Content; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; -import com.microsoft.windowsazure.services.serviceBus.implementation.QueueDescription; - -/** - * Represents a queue. - */ -public class QueueInfo extends EntryModel { - - /** - * Creates an instance of the Queue class. - */ - public QueueInfo() { - super(new Entry(), new QueueDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setQueueDescription(getModel()); - } - - /** - * Creates an instance of the Queue class using the specified entry. - * - * @param entry - * An Entry object. - */ - public QueueInfo(Entry entry) { - super(entry, entry.getContent().getQueueDescription()); - } - - /** - * Creates an instance of the Queue class using the specified name. - * - * @param path - * A String object that represents the name of the queue. - */ - public QueueInfo(String path) { - this(); - setPath(path); - } - - /** - * Returns the name of the queue. - * - * @return A String object that represents the name of the queue. - */ - public String getPath() { - return getEntry().getTitle(); - } - - /** - * Sets the name of the queue. - * - * @param value - * A String that represents the name of the queue. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setPath(String value) { - getEntry().setTitle(value); - return this; - } - - /** - * Returns the duration of the lock. - * - * @return A Duration object that represents the duration of the lock. - */ - public Duration getLockDuration() { - return getModel().getLockDuration(); - } - - /** - * Sets the duration of the lock. - * - * @param value - * The duration, in seconds, of the lock. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setLockDuration(Duration value) { - getModel().setLockDuration(value); - return this; - } - - /** - * Returns the maximum size of the queue. - * - * @return The maximum size, in megabytes, of the queue. - */ - public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); - } - - /** - * Sets the maximum size of the queue. - * - * @param value - * The maximum size, in megabytes, of the queue. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); - return this; - } - - /** - * Indicates whether duplicate message detection is required. - * - * @return true if duplicate message detection is required; otherwise, false. - */ - public Boolean isRequiresDuplicateDetection() { - return getModel().isRequiresDuplicateDetection(); - } - - /** - * Specifies whether duplicate message detection is required. - * - * @param value - * true if duplicate message detection is required; otherwise, false. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setRequiresDuplicateDetection(Boolean value) { - getModel().setRequiresDuplicateDetection(value); - return this; - } - - /** - * Indicates whether the queue is session-aware. - * - * @return true if the queue is session aware; otherwise, false. - */ - public Boolean isRequiresSession() { - return getModel().isRequiresSession(); - } - - /** - * Specifies whether the queue is session-aware. - * - * @param value - * true if the queue is session aware; otherwise, false. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setRequiresSession(Boolean value) { - getModel().setRequiresSession(value); - return this; - } - - /** - * Returns the default message time-to-live (TTL). This applies when dead - * lettering is in effect. - * - * @return A Duration object that represents the default message TTL. - */ - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } - - /** - * Sets the default message time-to-live (TTL). This applies when dead lettering is in effect. - * - * @param value - * A Duration object that represents the default message TTL. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } - - /** - * Indicates whether dead lettering is in effect upon message expiration. - * - * @return true if dead lettering is in effect; otherwise, false. - */ - public Boolean isDeadLetteringOnMessageExpiration() { - return getModel().isDeadLetteringOnMessageExpiration(); - } - - /** - * Specifies whether dead lettering is in effect upon message expiration. - * - * @param value - * true if dead lettering is in effect; otherwise, false. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setDeadLetteringOnMessageExpiration(Boolean value) { - getModel().setDeadLetteringOnMessageExpiration(value); - return this; - } - - /** - * Returns the time span during which the service bus will detect message duplication. This applies when duplicate - * message detection is in effect. - * - * @return A Duration object that represents the time span for - * detecting message duplication. - */ - public Duration getDuplicateDetectionHistoryTimeWindow() { - return getModel().getDuplicateDetectionHistoryTimeWindow(); - } - - /** - * Sets the time span during which the service bus will detect message duplication. This applies when duplicate - * message detection is in effect. - * - * @param value - * A Duration object that represents the time span for detecting message duplication. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setDuplicateDetectionHistoryTimeWindow(Duration value) { - getModel().setDuplicateDetectionHistoryTimeWindow(value); - return this; - } - - /** - * Returns the maximum delivery count for the queue. - * - * @return The maximum delivery count. - */ - public Integer getMaxDeliveryCount() { - return getModel().getMaxDeliveryCount(); - } - - /** - * Sets the maximum delivery count for the queue. - * - * @param value - * The maximum delivery count for the queue. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setMaxDeliveryCount(Integer value) { - getModel().setMaxDeliveryCount(value); - return this; - } - - /** - * Indicates whether batch operations are enabled. - * - * @return true if batch operations are enabled; otherwise, false. - */ - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } - - /** - * Specifies whether batch operations are enabled. - * - * @param value - * true if batch operations are enabled; otherwise, false. - * - * @return A Queue object that represents the updated queue. - */ - public QueueInfo setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } - - /** - * Returns the size of the queue. - * - * @return The size, in bytes, of the queue. - */ - public Long getSizeInBytes() { - return getModel().getSizeInBytes(); - } - - /** - * Returns the number of messages in the queue. - * - * @return The number of messages in the queue. - */ - public Long getMessageCount() { - return getModel().getMessageCount(); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java deleted file mode 100644 index 4e7ffcd2328d1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * - * Specifies options when receiving messages. - * - */ -public class ReceiveMessageOptions { - Integer timeout; - private ReceiveMode receiveMode = ReceiveMode.RECEIVE_AND_DELETE; - - /** - * Returns a new instance of the ReceiveMessageOptions class. - */ - public static final ReceiveMessageOptions DEFAULT = new ReceiveMessageOptions(); - - /** - * Returns the timeout when receiving messages. - * - * @return The timeout, in seconds. - */ - public Integer getTimeout() { - return timeout; - } - - /** - * Sets the timeout when receiving messages. - * - * @param timeout - * The timeout, in seconds. - * - * @return A ReceiveMessageOptions object that represents the updated receive message options. - */ - public ReceiveMessageOptions setTimeout(Integer timeout) { - this.timeout = timeout; - return this; - } - - /** - * Returns the receive mode when receiving messages. - * - * @return A {@link ReceiveMode} value that represents the receive mode. - */ - public ReceiveMode getReceiveMode() { - return receiveMode; - } - - /** - * Sets the receive mode when receiving messages. - * - * @param receiveMode - * A {@link ReceiveMode} value that specifies the receive mode. - * - * @return A ReceiveMessageOptions object that represents the updated receive message options. - */ - public ReceiveMessageOptions setReceiveMode(ReceiveMode receiveMode) { - this.receiveMode = receiveMode; - return this; - } - - /** - * Indicates whether the receive mode is receive and delete. - * - * @return true if the receive mode is {@link ReceiveMode#RECEIVE_AND_DELETE}; otherwise, - * false. - */ - public boolean isReceiveAndDelete() { - return receiveMode == ReceiveMode.RECEIVE_AND_DELETE; - } - - /** - * Sets the receive mode to receive and delete. - * - * @return A ReceiveMessageOptions object that represents the updated receive message options. - */ - public ReceiveMessageOptions setReceiveAndDelete() { - this.receiveMode = ReceiveMode.RECEIVE_AND_DELETE; - return this; - } - - /** - * Indicates whether the receive mode is peek/lock. - * - * @return true if the receive mode is {@link ReceiveMode#PEEK_LOCK}; otherwise, false. - */ - public boolean isPeekLock() { - return receiveMode == ReceiveMode.PEEK_LOCK; - } - - /** - * Sets the receive mode to peek/lock. - * - * @return A ReceiveMessageOptions object that represents the updated receive message options. - */ - public ReceiveMessageOptions setPeekLock() { - this.receiveMode = ReceiveMode.PEEK_LOCK; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java deleted file mode 100644 index e9ca05b07570d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a receiveMessage operation. - */ -public class ReceiveMessageResult { - - private BrokeredMessage value; - - /** - * Creates an instance of the ReceiveQueueMessageResult class. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public ReceiveMessageResult(BrokeredMessage value) { - this.setValue(value); - } - - /** - * Specifies the value of the result. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public void setValue(BrokeredMessage value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link BrokeredMessage} object that represents the value of the result. - */ - public BrokeredMessage getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java deleted file mode 100644 index 99c7e3e02d394..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Specifies the mode when a message is received. - */ -public enum ReceiveMode { - /** - * The message is retrieved and locked for processing, until either the receiver deletes the message, unlocks it, or - * the lock duration expires. - */ - PEEK_LOCK, - /** - * The message is retrieved and deleted. - */ - RECEIVE_AND_DELETE, -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java deleted file mode 100644 index 46a0c4a1ac5ca..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a receiveQueueMessage operation. - */ -public class ReceiveQueueMessageResult { - - private BrokeredMessage value; - - /** - * Creates an instance of the ReceiveQueueMessageResult class. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public ReceiveQueueMessageResult(BrokeredMessage value) { - this.setValue(value); - } - - /** - * Specifies the value of the result. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public void setValue(BrokeredMessage value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link BrokeredMessage} object that represents the value of the result. - */ - public BrokeredMessage getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java deleted file mode 100644 index 0436a5a873f16..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -/** - * Represents the result of a receiveSubscriptionMessage operation. - */ -public class ReceiveSubscriptionMessageResult { - - private BrokeredMessage value; - - /** - * Creates an instance of the ReceiveSubscriptionMessageResult class. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public ReceiveSubscriptionMessageResult(BrokeredMessage value) { - this.setValue(value); - } - - /** - * Specifies the value of the result. - * - * @param value - * A {@link BrokeredMessage} object assigned as the value of the result. - */ - public void setValue(BrokeredMessage value) { - this.value = value; - } - - /** - * Returns the value of the result. - * - * @return A {@link BrokeredMessage} object that represents the value of the result. - */ - public BrokeredMessage getValue() { - return value; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java deleted file mode 100644 index 35e30ae716508..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import javax.ws.rs.core.MediaType; - -import com.microsoft.windowsazure.services.serviceBus.implementation.Content; -import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; -import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.Filter; -import com.microsoft.windowsazure.services.serviceBus.implementation.RuleAction; -import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; -import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; -import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; - -/** - * Represents a rule. - */ -public class RuleInfo extends EntryModel { - - /** - * Creates an instance of the Rule class. - */ - public RuleInfo() { - super(new Entry(), new RuleDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setRuleDescription(getModel()); - } - - /** - * Creates an instance of the Rule class using the specified entry. - * - * @param entry - * An Entry object. - * - */ - public RuleInfo(Entry entry) { - super(entry, entry.getContent().getRuleDescription()); - } - - /** - * Creates an instance of the Rule class using the specified name. - * - * @param name - * A String object that represents the name of the rule. - * - */ - public RuleInfo(String name) { - this(); - setName(name); - } - - /** - * Returns the name of the rule. - * - * @return A String object that represents the name of the rule. - */ - public String getName() { - return getEntry().getTitle(); - } - - /** - * Sets the name of the rule. - * - * @param value - * A String object that represents the name of the rule. - * - * @return A Rule object that represents the updated rule. - */ - public RuleInfo setName(String value) { - getEntry().setTitle(value); - return this; - } - - /** - * Returns the filter used for the rule. - * - * @return A Filter object that represents the filter of the rule. - */ - public Filter getFilter() { - return getModel().getFilter(); - } - - /** - * Specifies the filter used for the rule. - * - * @param value - * A Filter object that represents the filter of the rule. - * - * @return A Rule object that represents the updated rule. - */ - public RuleInfo setFilter(Filter value) { - getModel().setFilter(value); - return this; - } - - /** - * Returns the rule action used for the rule. - * - * @return A RuleAction object that represents the rule action. - */ - public RuleAction getAction() { - return getModel().getAction(); - } - - /** - * Specifies the rule action for the rule. - * - * @param value - * A RuleAction object that represents the rule action. - * - * @return A Rule object that represents the updated rule. - */ - public RuleInfo setAction(RuleAction value) { - getModel().setAction(value); - return this; - } - - public RuleInfo withCorrelationIdFilter(String correlationId) { - CorrelationFilter filter = new CorrelationFilter(); - filter.setCorrelationId(correlationId); - return setFilter(filter); - } - - public RuleInfo withSqlExpressionFilter(String sqlExpression) { - SqlFilter filter = new SqlFilter(); - filter.setSqlExpression(sqlExpression); - filter.setCompatibilityLevel(20); - return setFilter(filter); - } - - public RuleInfo withTrueFilter() { - TrueFilter filter = new TrueFilter(); - filter.setCompatibilityLevel(20); - return setFilter(filter); - } - - public RuleInfo withFalseFilter() { - FalseFilter filter = new FalseFilter(); - filter.setCompatibilityLevel(20); - return setFilter(filter); - } - - public RuleInfo withEmptyRuleAction() { - EmptyRuleAction action = new EmptyRuleAction(); - return setAction(action); - } - - public RuleInfo withSqlRuleAction(String sqlExpression) { - SqlRuleAction action = new SqlRuleAction(); - action.setSqlExpression(sqlExpression); - action.setCompatibilityLevel(20); - return setAction(action); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java deleted file mode 100644 index e8490870583c2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ /dev/null @@ -1,269 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import javax.ws.rs.core.MediaType; -import javax.xml.datatype.Duration; - -import com.microsoft.windowsazure.services.serviceBus.implementation.Content; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; -import com.microsoft.windowsazure.services.serviceBus.implementation.RuleDescription; -import com.microsoft.windowsazure.services.serviceBus.implementation.SubscriptionDescription; - -/** - * Represents a subscription. - */ -public class SubscriptionInfo extends EntryModel { - - /** - * Creates an instance of the Subscription class. - */ - public SubscriptionInfo() { - super(new Entry(), new SubscriptionDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setSubscriptionDescription(getModel()); - } - - /** - * Creates an instance of the Subscription class using the specified entry. - * - * @param entry - * An Entry object. - */ - public SubscriptionInfo(Entry entry) { - super(entry, entry.getContent().getSubscriptionDescription()); - } - - /** - * Creates an instance of the Subscription class using the specified name. - * - * @param name - * A String object that represents the name of the subscription. - */ - public SubscriptionInfo(String name) { - this(); - setName(name); - } - - /** - * Returns the name of the subscription. - * - * @return A String object that represents the name of the subscription. - */ - public String getName() { - return getEntry().getTitle(); - } - - /** - * Sets the name of the subscription. - * - * @param value - * A String that represents the name of the subscription. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setName(String value) { - getEntry().setTitle(value); - return this; - } - - /** - * Returns the duration of the lock. - * - * @return A Duration object that represents the duration of the lock. - */ - public Duration getLockDuration() { - return getModel().getLockDuration(); - } - - /** - * Sets the duration of the lock. - * - * @param value - * The duration, in seconds, of the lock. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setLockDuration(Duration value) { - getModel().setLockDuration(value); - return this; - } - - /** - * Indicates whether the subscription is session-aware. - * - * @return true if the subscription is session aware; otherwise, false. - */ - public Boolean isRequiresSession() { - return getModel().isRequiresSession(); - } - - /** - * Specifies whether the subscription is session-aware. - * - * @param value - * true if the subscription is session aware; otherwise, false. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setRequiresSession(Boolean value) { - getModel().setRequiresSession(value); - return this; - } - - /** - * Returns the default message time-to-live (TTL). This applies when dead - * lettering is in effect. - * - * @return A Duration object that represents the default message TTL. - */ - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } - - /** - * Sets the default message time-to-live (TTL). This applies when dead lettering is in effect. - * - * @param value - * A Duration object that represents the default message TTL. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } - - /** - * Indicates whether dead lettering is in effect upon message expiration. - * - * @return true if dead lettering is in effect; otherwise, false. - */ - public Boolean isDeadLetteringOnMessageExpiration() { - return getModel().isDeadLetteringOnMessageExpiration(); - } - - /** - * Specifies whether dead lettering is in effect upon message expiration. - * - * @param value - * true if dead lettering is in effect; otherwise, false. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setDeadLetteringOnMessageExpiration(Boolean value) { - getModel().setDeadLetteringOnMessageExpiration(value); - return this; - } - - /** - * Indicates whether dead lettering is in effect when filter evaluation exceptions are encountered. - * - * @return true if dead lettering is in effect; otherwise, false. - */ - public Boolean isDeadLetteringOnFilterEvaluationExceptions() { - return getModel().isDeadLetteringOnFilterEvaluationExceptions(); - } - - /** - * Specifies whether dead lettering is in effect when filter evaluation exceptions are encountered. - * - * @param value - * true if dead lettering is in effect; otherwise, false. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setDeadLetteringOnFilterEvaluationExceptions(Boolean value) { - getModel().setDeadLetteringOnFilterEvaluationExceptions(value); - return this; - } - - /** - * Returns the description of the default rule. - * - * @return A RuleDescription object that represents the default rule description. - */ - public RuleDescription getDefaultRuleDescription() { - return getModel().getDefaultRuleDescription(); - } - - /** - * Specifies the description for the default rule. - * - * @param value - * A RuleDescription object that represents the default rule description. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setDefaultRuleDescription(RuleDescription value) { - getModel().setDefaultRuleDescription(value); - return this; - } - - /** - * Returns the number of messages in the subscription. - * - * @return The number of messages in the subscription. - */ - public Long getMessageCount() { - return getModel().getMessageCount(); - } - - /** - * Returns the maximum delivery count for the subscription. - * - * @return The maximum delivery count. - */ - public Integer getMaxDeliveryCount() { - return getModel().getMaxDeliveryCount(); - } - - /** - * Sets the maximum delivery count for the subscription. - * - * @param value - * The maximum delivery count for the subscription. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setMaxDeliveryCount(Integer value) { - getModel().setMaxDeliveryCount(value); - return this; - } - - /** - * Indicates whether batch operations are enabled. - * - * @return true if batch operations are enabled; otherwise, false. - */ - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } - - /** - * Specifies whether batch operations are enabled. - * - * @param value - * true if batch operations are enabled; otherwise, false. - * - * @return A Subscription object that represents the updated subscription. - */ - public SubscriptionInfo setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java deleted file mode 100644 index 76ac97d68196f..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ /dev/null @@ -1,202 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.models; - -import javax.ws.rs.core.MediaType; -import javax.xml.datatype.Duration; - -import com.microsoft.windowsazure.services.serviceBus.implementation.Content; -import com.microsoft.windowsazure.services.serviceBus.implementation.Entry; -import com.microsoft.windowsazure.services.serviceBus.implementation.EntryModel; -import com.microsoft.windowsazure.services.serviceBus.implementation.TopicDescription; - -/** - * Represents a topic. - */ -public class TopicInfo extends EntryModel { - /** - * Creates an instance of the Topic class. - */ - public TopicInfo() { - super(new Entry(), new TopicDescription()); - getEntry().setContent(new Content()); - getEntry().getContent().setType(MediaType.APPLICATION_XML); - getEntry().getContent().setTopicDescription(getModel()); - } - - /** - * Creates an instance of the Topic class using the specified entry. - * - * @param entry - * An Entry object that represents the entry for the topic. - */ - public TopicInfo(Entry entry) { - super(entry, entry.getContent().getTopicDescription()); - } - - /** - * Creates an instance of the Topic class using the specified name. - * - * @param path - * A String object that represents the name for the topic. - */ - public TopicInfo(String path) { - this(); - setPath(path); - } - - /** - * Returns the name of the topic. - * - * @return A String object that represents the name of the topic. - */ - public String getPath() { - return getEntry().getTitle(); - } - - /** - * Sets the name of the topic. - * - * @param value - * A String that represents the name of the topic. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setPath(String value) { - getEntry().setTitle(value); - return this; - } - - /** - * Returns the default message time-to-live (TTL). - * - * @return A Duration object that represents the default message TTL. - */ - public Duration getDefaultMessageTimeToLive() { - return getModel().getDefaultMessageTimeToLive(); - } - - /** - * Sets the default message time-to-live (TTL). - * - * @param value - * A Duration object that represents the default message TTL. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setDefaultMessageTimeToLive(Duration value) { - getModel().setDefaultMessageTimeToLive(value); - return this; - } - - /** - * Returns the maximum size of the topic. - * - * @return The maximum size, in megabytes, of the topic. - */ - public Long getMaxSizeInMegabytes() { - return getModel().getMaxSizeInMegabytes(); - } - - /** - * Sets the maximum size of the topic. - * - * @param value - * The maximum size, in megabytes, of the topic. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setMaxSizeInMegabytes(Long value) { - getModel().setMaxSizeInMegabytes(value); - return this; - } - - /** - * Indicates whether duplicate message detection is required. - * - * @return true if duplicate message detection is required; otherwise, false. - */ - public Boolean isRequiresDuplicateDetection() { - return getModel().isRequiresDuplicateDetection(); - } - - /** - * Specifies whether duplicate message detection is required. - * - * @param value - * true if duplicate message detection is required; otherwise, false. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setRequiresDuplicateDetection(Boolean value) { - getModel().setRequiresDuplicateDetection(value); - return this; - } - - /** - * Returns the time span during which the service bus will detect message duplication. - * - * @return A Duration object that represents the time span for - * detecting message duplication. - */ - public Duration getDuplicateDetectionHistoryTimeWindow() { - return getModel().getDuplicateDetectionHistoryTimeWindow(); - } - - /** - * Sets the time span during which the service bus will detect message duplication. - * - * @param value - * A Duration object that represents the time span for detecting message duplication. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setDuplicateDetectionHistoryTimeWindow(Duration value) { - getModel().setDuplicateDetectionHistoryTimeWindow(value); - return this; - } - - /** - * Indicates whether batch operations are enabled. - * - * @return true if batch operations are enabled; otherwise, false. - */ - public Boolean isEnableBatchedOperations() { - return getModel().isEnableBatchedOperations(); - } - - /** - * Specifies whether batch operations are enabled. - * - * @param value - * true if batch operations are enabled; otherwise, false. - * - * @return A Topic object that represents the updated topic. - */ - public TopicInfo setEnableBatchedOperations(Boolean value) { - getModel().setEnableBatchedOperations(value); - return this; - } - - /** - * Returns the size of the topic. - * - * @return The size, in bytes, of the topic. - */ - public Long getSizeInBytes() { - return getModel().getSizeInBytes(); - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html deleted file mode 100644 index 6d230ea5af324..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -This package contains the service bus data transfer object - classes. - - diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html deleted file mode 100644 index f320abf4cc9a2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -This package contains the service bus service class, - interface, and associated configuration and utility classes. - - diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports deleted file mode 100644 index cc7087393981f..0000000000000 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports +++ /dev/null @@ -1,6 +0,0 @@ -com.microsoft.windowsazure.services.blob.Exports -com.microsoft.windowsazure.services.queue.Exports -com.microsoft.windowsazure.services.serviceBus.Exports -com.microsoft.windowsazure.services.serviceBus.implementation.Exports -com.microsoft.windowsazure.services.core.utils.Exports -com.microsoft.windowsazure.services.core.utils.pipeline.Exports diff --git a/microsoft-azure-api/src/main/resources/package-names.xjb b/microsoft-azure-api/src/main/resources/package-names.xjb deleted file mode 100644 index 70e0e3714dd7b..0000000000000 --- a/microsoft-azure-api/src/main/resources/package-names.xjb +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd deleted file mode 100644 index 62ff1db89253b..0000000000000 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.2003.10.Serialization.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd b/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd deleted file mode 100644 index 31d324b76fbef..0000000000000 --- a/microsoft-azure-api/src/main/resources/schemas.microsoft.com.netservices.2010.10.servicebus.connect.xsd +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd b/microsoft-azure-api/src/main/resources/servicebus-atom.xsd deleted file mode 100644 index b8387023a54be..0000000000000 --- a/microsoft-azure-api/src/main/resources/servicebus-atom.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java deleted file mode 100644 index 2fa253cd5fc8c..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -import java.util.Map; - -import com.microsoft.windowsazure.services.core.Builder; - -public class AlterClassWithProperties implements Builder.Alteration { - - public ClassWithProperties alter(ClassWithProperties instance, Builder builder, Map properties) { - instance.setFoo(instance.getFoo() + " - changed"); - return instance; - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java deleted file mode 100644 index bab655d1c9a74..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -import javax.inject.Inject; - -public class ClassWithMultipleCtorMultipleInject { - @Inject - public ClassWithMultipleCtorMultipleInject() { - } - - @Inject - public ClassWithMultipleCtorMultipleInject(String x) { - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java deleted file mode 100644 index 9522d97ad251f..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -public class ClassWithMultipleCtorNoInject { - public ClassWithMultipleCtorNoInject() { - } - - public ClassWithMultipleCtorNoInject(String x) { - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java deleted file mode 100644 index cef547f4078c4..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -import javax.inject.Inject; -import javax.inject.Named; - -public class ClassWithNamedParameter { - private String hello; - - @Inject - public ClassWithNamedParameter(@Named("Foo") String hello) { - this.hello = hello; - } - - public String getHello() { - return hello; - } - - public void setHello(String hello) { - this.hello = hello; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java deleted file mode 100644 index 2c2005676163f..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -public class ClassWithProperties { - String foo; - String bar; - - public ClassWithProperties() { - foo = "one"; - bar = "two"; - } - - /** - * @return the foo - */ - public String getFoo() { - return foo; - } - - /** - * @param foo - * the foo to set - */ - public void setFoo(String foo) { - this.foo = foo; - } - - /** - * @return the bar - */ - public String getBar() { - return bar; - } - - /** - * @param bar - * the bar to set - */ - public void setBar(String bar) { - this.bar = bar; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java deleted file mode 100644 index 19ed61a0a021a..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -public class ClassWithSingleCtorNoInject { - public ClassWithSingleCtorNoInject() { - - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java deleted file mode 100644 index dc57798032bfc..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.configuration.builder; - -import java.util.HashMap; -import java.util.Map; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.microsoft.windowsazure.services.core.DefaultBuilder; - -public class DefaultBuilderTest { - - Map properties; - DefaultBuilder builder; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void init() { - properties = new HashMap(); - builder = new DefaultBuilder(); - } - - @Test - public void namedAnnotationsComeFromBuildProperties() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - - // Act - Map properties = new HashMap(); - properties.put("Foo", "world"); - ClassWithNamedParameter cwnp = builder.build("", - ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("world", cwnp.getHello()); - } - - @Test - public void namedAnnotationReportsMissingProperty() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithNamedParameter.class); - - // Act - ClassWithNamedParameter cwnp = builder.build("", - ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("world", cwnp.getHello()); - } - - @Test - public void singleCtorWithNoInjectShouldBeUsed() throws Exception { - // Arrange - builder.add(ClassWithSingleCtorNoInject.class); - - // Act - ClassWithSingleCtorNoInject result = builder.build("", - ClassWithSingleCtorNoInject.class, properties); - - // Assert - Assert.assertNotNull(result); - } - - @Test - public void multipleCtorWithNoInjectShouldFail() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithMultipleCtorNoInject.class); - - // Act - ClassWithMultipleCtorNoInject result = builder.build("", - ClassWithMultipleCtorNoInject.class, properties); - - // Assert - Assert.assertTrue("Exception must occur", false); - } - - @Test - public void multipleCtorWithMultipleInjectShouldFail() throws Exception { - // Arrange - thrown.expect(RuntimeException.class); - - builder.add(ClassWithMultipleCtorMultipleInject.class); - - // Act - ClassWithMultipleCtorMultipleInject result = builder.build("", - ClassWithMultipleCtorMultipleInject.class, properties); - - // Assert - Assert.assertTrue("Exception must occur", false); - } - - @Test - public void alterationExecutesWhenInstanceCreated() throws Exception { - // Arrange - builder.add(ClassWithProperties.class); - builder.alter(ClassWithProperties.class, new AlterClassWithProperties()); - - // Act - ClassWithProperties result = builder.build("", ClassWithProperties.class, properties); - - // Assert - Assert.assertEquals("one - changed", result.getFoo()); - } - - @Test - public void namedParametersUseProfileBasedKeysFirst() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("testing.Foo", "Profile foo value"); - - // Act - ClassWithNamedParameter result = builder.build("testing", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("Profile foo value", result.getHello()); - } - - @Test - public void namedParametersFallBackToNonProfileBasedKeys() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("testing.Foo", "Profile foo value"); - - // Act - ClassWithNamedParameter result1 = builder.build("", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result2 = builder.build("production", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("fallback", result1.getHello()); - Assert.assertEquals("fallback", result2.getHello()); - Assert.assertEquals("fallback", result2.getHello()); - } - - @Test - public void namedParamatersFallBackFromLeftToRight() throws Exception { - // Arrange - builder.add(ClassWithNamedParameter.class); - properties.put("Foo", "fallback"); - properties.put("custom.Foo", "custom.Foo value"); - properties.put("testing.custom.Foo", "testing.custom.Foo value"); - - // Act - ClassWithNamedParameter result1 = builder.build("custom", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result2 = builder.build("production.custom", ClassWithNamedParameter.class, properties); - ClassWithNamedParameter result3 = builder.build("testing.custom", ClassWithNamedParameter.class, properties); - - // Assert - Assert.assertEquals("custom.Foo value", result1.getHello()); - Assert.assertEquals("custom.Foo value", result2.getHello()); - Assert.assertEquals("testing.custom.Foo value", result3.getHello()); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java deleted file mode 100644 index 12f9656c17550..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; - -/** - * - */ -public class FileInputChannelTests { - @Test - public void getInputStreamOpensFile() { - InputChannel inputChannel = new FileInputChannel(); - - try { - File tempFile = File.createTempFile("getInputStreamOpensFile", null); - BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); - String expectedData = "test content"; - - writer.write(expectedData); - writer.close(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(inputChannel.getInputStream(tempFile - .getAbsolutePath()))); - - assertThat(reader.readLine(), equalTo(expectedData)); - } - catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java deleted file mode 100644 index 804022b81da6f..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.util.LinkedList; - -/** - * - */ -public class MockInputChannel implements InputChannel { - private final ByteArrayInputStream inputStream; - - public MockInputChannel(String channelData) { - byte data[] = null; - - try { - data = channelData.getBytes("UTF-8"); - } - catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - this.inputStream = new ByteArrayInputStream(data); - } - - public MockInputChannel(String chunks[]) { - int finalLength = 0; - LinkedList chunkBytes = new LinkedList(); - byte[] crlf = new byte[] { 0x0D, 0x0A }; - - for (String chunk : chunks) { - try { - byte chunkLengthData[] = Integer.toHexString(chunk.length()).getBytes("US-ASCII"); - byte chunkData[] = chunk.getBytes("UTF-8"); - int chunkLength = chunkLengthData.length + chunkData.length + 4; - - chunkBytes.add(chunkLengthData); - chunkBytes.add(chunkData); - - finalLength += chunkLength; - } - catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - - byte data[] = new byte[finalLength]; - int dataIndex = 0; - - for (byte[] chunk : chunkBytes) { - System.arraycopy(chunk, 0, data, dataIndex, chunk.length); - - dataIndex += chunk.length; - - System.arraycopy(crlf, 0, data, dataIndex, crlf.length); - - dataIndex += crlf.length; - } - - this.inputStream = new ByteArrayInputStream(data); - } - - @Override - public InputStream getInputStream(String name) { - return this.inputStream; - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java deleted file mode 100644 index b18feab92e441..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; - -/** - * - */ -public class Protocol1RuntimeCurrentStateClientTests { - @Test - public void setCurrentStateSerializesToEndpoint() { - final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); - final OutputStream expectedStream = new ByteArrayOutputStream(); - final String expectedEndpoint = "endpoint"; - final AtomicBoolean serializeCalled = new AtomicBoolean(false); - - CurrentStateSerializer serializer = new CurrentStateSerializer() { - @Override - public void serialize(CurrentState state, OutputStream stream) { - assertThat(state, is(expectedState)); - assertThat(stream, is(expectedStream)); - - serializeCalled.set(true); - } - }; - - OutputChannel outputChannel = new OutputChannel() { - @Override - public OutputStream getOutputStream(String name) { - assertThat(name, is(expectedEndpoint)); - - return expectedStream; - } - }; - - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, - outputChannel); - - currentStateClient.setEndpoint(expectedEndpoint); - - currentStateClient.setCurrentState(expectedState); - - assertThat(serializeCalled.get(), is(true)); - } - - @Test - public void streamCloseFailureThrowsNotAvailableException() { - final CurrentState expectedState = new AcquireCurrentState(null, null, null, null); - final OutputStream expectedStream = new OutputStream() { - @Override - public void write(int arg0) throws IOException { - } - - @Override - public void close() throws IOException { - throw new IOException(); - } - }; - - final String expectedEndpoint = "endpoint"; - final AtomicBoolean serializeCalled = new AtomicBoolean(false); - - CurrentStateSerializer serializer = new CurrentStateSerializer() { - @Override - public void serialize(CurrentState state, OutputStream stream) { - assertThat(state, is(expectedState)); - assertThat(stream, is(expectedStream)); - - serializeCalled.set(true); - } - }; - - OutputChannel outputChannel = new OutputChannel() { - @Override - public OutputStream getOutputStream(String name) { - assertThat(name, is(expectedEndpoint)); - - return expectedStream; - } - }; - - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(serializer, - outputChannel); - - currentStateClient.setEndpoint(expectedEndpoint); - - try { - currentStateClient.setCurrentState(expectedState); - } - catch (RoleEnvironmentNotAvailableException e) { - return; - } - - fail(); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java deleted file mode 100644 index c460f04cc62bb..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; - -/** - * - */ -public class Protocol1RuntimeGoalStateClientTests { - private final List goalStates = new LinkedList(); - - @Test - public void addGoalStateChangedListenerAddsListener() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + "" + "1" - + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "", - "" + "" + "2" - + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "" }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, - goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); - - client.addGoalStateChangedListener(new GoalStateChangedListener() { - @Override - public void goalStateChanged(GoalState newGoalState) { - goalStates.add(newGoalState); - } - }); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(200); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(1)); - assertThat(goalStates.get(0).getIncarnation().intValue(), is(2)); - } - - @Test - public void goalStateClientRestartsThread() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new GoalStateDeserializer() { - private ChunkedGoalStateDeserializer deserializer = new ChunkedGoalStateDeserializer(); - - @Override - public void initialize(InputStream inputStream) { - deserializer.initialize(inputStream); - } - - @Override - public GoalState deserialize() { - GoalState goalState = deserializer.deserialize(); - - try { - Thread.sleep(200); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - goalStates.add(goalState); - - return goalState; - } - }; - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { "" - + "" + "1" + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "" }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, - goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - client.getCurrentGoalState(); - } - catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(3)); - } - - @Test - public void getRoleEnvironmentDataReturnsDeserializedData() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - final RoleEnvironmentData data = new RoleEnvironmentData(null, null, null, null, null, false); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return data; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { "" - + "" + "1" + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "" }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, - goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); - - try { - assertThat(client.getRoleEnvironmentData(), is(data)); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Test - public void removeGoalStateChangedListenerRemovesListener() { - Protocol1RuntimeCurrentStateClient currentStateClient = new Protocol1RuntimeCurrentStateClient(null, null); - - GoalStateDeserializer goalStateDeserializer = new ChunkedGoalStateDeserializer(); - - RoleEnvironmentDataDeserializer roleEnvironmentDeserializer = new RoleEnvironmentDataDeserializer() { - @Override - public RoleEnvironmentData deserialize(InputStream stream) { - return null; - } - }; - - InputChannel inputChannel = new MockInputChannel(new String[] { - "" + "" + "1" - + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "", - "" + "" + "2" - + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "" }); - - Protocol1RuntimeGoalStateClient client = new Protocol1RuntimeGoalStateClient(currentStateClient, - goalStateDeserializer, roleEnvironmentDeserializer, inputChannel); - - GoalStateChangedListener listener = new GoalStateChangedListener() { - @Override - public void goalStateChanged(GoalState newGoalState) { - goalStates.add(newGoalState); - } - }; - - client.addGoalStateChangedListener(listener); - client.removeGoalStateChangedListener(listener); - - goalStates.clear(); - - try { - client.getCurrentGoalState(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(200); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - assertThat(goalStates.size(), is(0)); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java deleted file mode 100644 index 3ebd677771ca0..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; - -import java.lang.reflect.Field; -import java.util.Calendar; -import java.util.Map; -import java.util.TimeZone; - -import org.junit.Before; - -// import org.junit.Test; - -/** - * - */ -public class RoleEnvironmentTests { - @Before - public void setupTests() { - horrificEnvironmentModification("\\\\.\\pipe\\578cb0d1-a330-4019-b634-755aa3d1e9d2"); - } - - //@Test - public void roleEnvironmentIsAvailable() { - assertThat(RoleEnvironment.isAvailable(), is(true)); - } - - //@Test - public void roleEnvironmentSetStateSetsState() { - Calendar exp = Calendar.getInstance(TimeZone.getTimeZone("GMT+0:00")); - - exp.add(Calendar.MINUTE, 1); - - RoleEnvironment.setStatus(RoleInstanceStatus.Ready, exp.getTime()); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void horrificEnvironmentModification(String endpoint) { - try { - Class processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment"); - Field field = processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment"); - field.setAccessible(true); - Object obj = field.get(null); - Map map = (Map) obj; - map.put("WaRuntimeEndpoint", endpoint); - } - catch (SecurityException e) { - e.printStackTrace(); - } - catch (NoSuchFieldException e) { - e.printStackTrace(); - } - catch (IllegalArgumentException e) { - e.printStackTrace(); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java deleted file mode 100644 index 2e8c72b0beda1..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.Matchers.*; - -/** - * - */ -public class RuntimeVersionManagerTests { - @Test - public void getRuntimeClientForV1CanParseGoalState() { - RuntimeVersionManager manager = createVersionManagerWithGoalState("" - + "" + "1" + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "", "2011-03-08"); - - RuntimeClient runtimeClient = manager.getRuntimeClient(""); - GoalState goalState = null; - - try { - goalState = runtimeClient.getCurrentGoalState(); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - Calendar expectedDeadline = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); - - expectedDeadline.clear(); - expectedDeadline.set(2011, 2, 8, 3, 27, 44); - - assertThat(goalState.getIncarnation(), equalTo(BigInteger.ONE)); - assertThat(goalState.getExpectedState(), equalTo(ExpectedState.STARTED)); - assertThat(goalState.getEnvironmentPath(), equalTo("envpath")); - assertThat(goalState.getCurrentStateEndpoint(), equalTo("statepath")); - assertThat(goalState.getDeadline().getTimeInMillis(), equalTo(expectedDeadline.getTimeInMillis())); - } - - @Test - public void getRuntimeClientThrowsWhenNoSupportedVersionsFound() { - RuntimeVersionManager manager = createVersionManagerWithGoalState("" - + "" + "1" + "Started" - + "envpath" - + "statepath" - + "2011-03-08T03:27:44.0Z" + "", "notSupported"); - - try { - manager.getRuntimeClient(""); - } - catch (RuntimeException ex) { - return; - } - - fail(); - } - - private RuntimeVersionManager createVersionManagerWithGoalState(String goalStateXml, String version) { - File tempGoalState; - - try { - tempGoalState = File.createTempFile("tempGoalState", null); - FileOutputStream output = new FileOutputStream(tempGoalState); - - InputChannel goalStateChannel = new MockInputChannel(new String[] { goalStateXml }); - BufferedInputStream input = new BufferedInputStream(goalStateChannel.getInputStream("")); - - byte buffer[] = new byte[1024]; - int length = 0; - - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.close(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - - InputChannel inputChannel = new MockInputChannel("" + "" - + "" + "" + "" + ""); - RuntimeVersionProtocolClient protocolClient = new RuntimeVersionProtocolClient(inputChannel); - return new RuntimeVersionManager(protocolClient); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java deleted file mode 100644 index 4222faf05b1fd..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.serviceruntime; - -/* - * import org.junit.Test; - * import static org.junit.Assert.*; - * import static org.hamcrest.Matchers.*; - */ - -/** - * - */ -public class XmlGoalStateDeserializerTests { - -} 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 deleted file mode 100644 index 2e5d4b4d2d0e4..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/BlobServiceIntegrationTest.java +++ /dev/null @@ -1,1567 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -import static org.junit.Assert.*; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -import junit.framework.Assert; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -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.ContainerACL.PublicAccessType; -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.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; -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.ListContainersResult.Container; -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; -import com.microsoft.windowsazure.services.blob.models.SetBlobPropertiesResult; -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; -import com.microsoft.windowsazure.services.core.RetryPolicyFilter; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; - -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; - private static String CREATEABLE_CONTAINER_4; - private static String TEST_CONTAINER_FOR_BLOBS; - private static String TEST_CONTAINER_FOR_BLOBS_2; - private static String TEST_CONTAINER_FOR_LISTING; - private static String[] creatableContainers; - private static String[] testContainers; - - @BeforeClass - public static void setup() throws Exception { - // Setup container names array (list of container names used by - // integration tests) - testContainers = new String[10]; - for (int i = 0; i < testContainers.length; i++) { - testContainers[i] = String.format("%s%d", testContainersPrefix, i + 1); - } - - creatableContainers = new String[10]; - for (int i = 0; i < creatableContainers.length; i++) { - creatableContainers[i] = String.format("%s%d", createableContainersPrefix, i + 1); - } - - CREATEABLE_CONTAINER_1 = creatableContainers[0]; - CREATEABLE_CONTAINER_2 = creatableContainers[1]; - CREATEABLE_CONTAINER_3 = creatableContainers[2]; - CREATEABLE_CONTAINER_4 = creatableContainers[3]; - - TEST_CONTAINER_FOR_BLOBS = testContainers[0]; - TEST_CONTAINER_FOR_BLOBS_2 = testContainers[1]; - TEST_CONTAINER_FOR_LISTING = testContainers[2]; - - // Create all test containers and their content - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - createContainers(service, testContainersPrefix, testContainers); - } - - @AfterClass - public static void cleanup() throws Exception { - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - deleteContainers(service, testContainersPrefix, testContainers); - deleteContainers(service, createableContainersPrefix, creatableContainers); - } - - private static void createContainers(BlobContract service, String prefix, String[] list) throws Exception { - Set containers = listContainers(service, prefix); - for (String item : list) { - if (!containers.contains(item)) { - service.createContainer(item); - } - } - } - - private static void deleteContainers(BlobContract service, String prefix, String[] list) throws Exception { - Set containers = listContainers(service, prefix); - for (String item : list) { - if (containers.contains(item)) { - service.deleteContainer(item); - } - } - } - - private static Set listContainers(BlobContract service, String prefix) throws Exception { - HashSet result = new HashSet(); - ListContainersResult list = service.listContainers(new ListContainersOptions().setPrefix(prefix)); - for (Container item : list.getContainers()) { - result.add(item.getName()); - } - return result; - } - - @Test - public void getServiceProppertiesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Don't run this test with emulator, as v1.6 doesn't support this method - if (isRunningWithEmulator(config)) { - return; - } - - // Act - ServiceProperties props = service.getServiceProperties().getValue(); - - // 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(); - BlobContract service = BlobService.create(config); - - // Don't run this test with emulator, as v1.6 doesn't support this method - if (isRunningWithEmulator(config)) { - return; - } - - // Act - ServiceProperties props = service.getServiceProperties().getValue(); - - props.setDefaultServiceVersion("2009-09-19"); - props.getLogging().setRead(true); - service.setServiceProperties(props); - - props = service.getServiceProperties().getValue(); - - // 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()); - } - - @Test - public void createContainerWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createContainer(CREATEABLE_CONTAINER_1); - - // Assert - } - - @Test - public void createContainerWithMetadataWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createContainer(CREATEABLE_CONTAINER_2, new CreateContainerOptions().setPublicAccess("blob") - .addMetadata("test", "bar").addMetadata("blah", "bleah")); - - 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).setIncludeMetadata(true)); - - service.deleteContainer(CREATEABLE_CONTAINER_2); - - // Assert - assertNotNull(prop); - assertNotNull(prop.getEtag()); - assertNotNull(prop.getLastModified()); - assertNotNull(prop.getMetadata()); - assertEquals(2, prop.getMetadata().size()); - assertTrue(prop.getMetadata().containsKey("test")); - assertTrue(prop.getMetadata().containsValue("bar")); - assertTrue(prop.getMetadata().containsKey("blah")); - assertTrue(prop.getMetadata().containsValue("bleah")); - - assertNotNull(prop2); - assertNotNull(prop2.getEtag()); - assertNotNull(prop2.getLastModified()); - assertNotNull(prop2.getMetadata()); - assertEquals(2, prop2.getMetadata().size()); - assertTrue(prop2.getMetadata().containsKey("test")); - assertTrue(prop2.getMetadata().containsValue("bar")); - assertTrue(prop2.getMetadata().containsKey("blah")); - assertTrue(prop2.getMetadata().containsValue("bleah")); - - assertNotNull(results2); - assertEquals(1, results2.getContainers().size()); - assertTrue(results2.getContainers().get(0).getMetadata().containsKey("test")); - assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bar")); - assertTrue(results2.getContainers().get(0).getMetadata().containsKey("blah")); - assertTrue(results2.getContainers().get(0).getMetadata().containsValue("bleah")); - - assertNotNull(acl); - - } - - @Test - public void setContainerMetadataWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createContainer(CREATEABLE_CONTAINER_3); - - HashMap metadata = new HashMap(); - metadata.put("test", "bar"); - metadata.put("blah", "bleah"); - service.setContainerMetadata(CREATEABLE_CONTAINER_3, metadata); - GetContainerPropertiesResult prop = service.getContainerMetadata(CREATEABLE_CONTAINER_3); - - // Assert - assertNotNull(prop); - assertNotNull(prop.getEtag()); - assertNotNull(prop.getLastModified()); - assertNotNull(prop.getMetadata()); - assertEquals(2, prop.getMetadata().size()); - assertTrue(prop.getMetadata().containsKey("test")); - assertTrue(prop.getMetadata().containsValue("bar")); - assertTrue(prop.getMetadata().containsKey("blah")); - assertTrue(prop.getMetadata().containsValue("bleah")); - } - - @Test - public void setContainerACLWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - String container = CREATEABLE_CONTAINER_4; - Date expiryStartDate = new GregorianCalendar(2010, 1, 1).getTime(); - Date expiryEndDate = new GregorianCalendar(2020, 1, 1).getTime(); - - // Act - service.createContainer(container); - - ContainerACL acl = new ContainerACL(); - acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); - acl.addSignedIdentifier("test", expiryStartDate, expiryEndDate, "rwd"); - service.setContainerACL(container, acl); - - ContainerACL acl2 = service.getContainerACL(container).getContainerACL(); - service.deleteContainer(container); - - // Assert - assertNotNull(acl2); - assertNotNull(acl2.getEtag()); - assertNotNull(acl2.getLastModified()); - assertNotNull(acl2.getPublicAccess()); - assertEquals(PublicAccessType.BLOBS_ONLY, acl2.getPublicAccess()); - assertEquals(1, acl2.getSignedIdentifiers().size()); - assertEquals("test", acl2.getSignedIdentifiers().get(0).getId()); - assertEquals(expiryStartDate, acl2.getSignedIdentifiers().get(0).getAccessPolicy().getStart()); - assertEquals(expiryEndDate, acl2.getSignedIdentifiers().get(0).getAccessPolicy().getExpiry()); - assertEquals("rwd", acl2.getSignedIdentifiers().get(0).getAccessPolicy().getPermission()); - } - - @Test - public void listContainersWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - ListContainersResult results = service.listContainers(); - - // Assert - assertNotNull(results); - assertTrue(testContainers.length <= results.getContainers().size()); - assertNotNull(results.getContainers().get(0).getName()); - assertNotNull(results.getContainers().get(0).getMetadata()); - assertNotNull(results.getContainers().get(0).getProperties()); - assertNotNull(results.getContainers().get(0).getProperties().getEtag()); - assertNotNull(results.getContainers().get(0).getProperties().getLastModified()); - assertNotNull(results.getContainers().get(0).getUrl()); - } - - @Test - public void listContainersWithPaginationWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - ListContainersResult results = service.listContainers(new ListContainersOptions().setMaxResults(3)); - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results - .getNextMarker())); - - // Assert - assertNotNull(results); - assertEquals(3, results.getContainers().size()); - assertNotNull(results.getNextMarker()); - assertEquals(3, results.getMaxResults()); - - assertNotNull(results2); - assertTrue(testContainers.length - 3 <= results2.getContainers().size()); - assertEquals("", results2.getNextMarker()); - assertEquals(0, results2.getMaxResults()); - } - - @Test - public void listContainersWithPrefixWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - ListContainersResult results = service.listContainers(new ListContainersOptions().setPrefix( - testContainersPrefix).setMaxResults(3)); - // Assert - assertNotNull(results); - assertEquals(3, results.getContainers().size()); - assertNotNull(results.getNextMarker()); - assertEquals(3, results.getMaxResults()); - - // Act - ListContainersResult results2 = service.listContainers(new ListContainersOptions().setMarker(results - .getNextMarker())); - - // Assert - assertNotNull(results2); - assertEquals(testContainers.length - 3, results2.getContainers().size()); - assertNotNull(results2.getNextMarker()); - assertEquals(0, results2.getMaxResults()); - } - - @Test - public void workingWithRootContainersWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // - // 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 - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - 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()); - } - - @Test - public void listBlobsWithPrefixWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - 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("myblob1", results.getBlobs().get(0).getName()); - assertEquals("myblob2", results.getBlobs().get(1).getName()); - - assertNotNull(results2); - assertEquals(2, results2.getBlobs().size()); - assertEquals("otherblob1", results2.getBlobs().get(0).getName()); - assertEquals("otherblob2", results2.getBlobs().get(1).getName()); - } - - @Test - public void listBlobsWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - 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.getBlobs().size()); - } - - @Test - public void listBlobsWithDelimiterWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - 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(2, results.getBlobs().size()); - assertEquals(2, results.getBlobPrefixes().size()); - - assertEquals(2, results2.getBlobs().size()); - assertEquals(0, results2.getBlobPrefixes().size()); - - assertEquals(0, results3.getBlobs().size()); - assertEquals(2, results3.getBlobPrefixes().size()); - - assertEquals(1, results4.getBlobs().size()); - assertEquals(0, results4.getBlobPrefixes().size()); - - assertEquals(1, results5.getBlobs().size()); - assertEquals(0, results5.getBlobPrefixes().size()); - - assertEquals(0, results6.getBlobs().size()); - assertEquals(0, results6.getBlobPrefixes().size()); - } - - @Test - public void createPageBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512); - - // Assert - } - - @Test - public void createPageBlobWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 512, - 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 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()); - assertEquals("en-us", props.getContentLanguage()); - assertEquals("text/plain", props.getContentType()); - assertEquals(512, props.getContentLength()); - assertNotNull(props.getEtag()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("PageBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - } - - @Test - public void clearBlobPagesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - service.createPageBlob(container, blob, 512); - - CreateBlobPagesResult result = service.clearBlobPages(container, blob, new PageRange(0, 511)); - - // Assert - assertNotNull(result); - assertNull(result.getContentMD5()); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(0, result.getSequenceNumber()); - } - - @Test - public void createBlobPagesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - String content = new String(new char[512]); - service.createPageBlob(container, blob, 512); - - CreateBlobPagesResult result = service.createBlobPages(container, blob, new PageRange(0, 511), - content.length(), new ByteArrayInputStream(content.getBytes("UTF-8"))); - - // Assert - assertNotNull(result); - assertNotNull(result.getContentMD5()); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(0, result.getSequenceNumber()); - } - - @Test - public void listBlobRegionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - String content = new String(new char[512]); - service.createPageBlob(container, blob, 16384 + 512); - - 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); - - // Assert - assertNotNull(result); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(16384 + 512, result.getContentLength()); - assertNotNull(result.getPageRanges()); - assertEquals(4, result.getPageRanges().size()); - assertEquals(0, result.getPageRanges().get(0).getStart()); - assertEquals(511, result.getPageRanges().get(0).getEnd()); - assertEquals(1024, result.getPageRanges().get(1).getStart()); - assertEquals(1024 + 511, result.getPageRanges().get(1).getEnd()); - assertEquals(8192, result.getPageRanges().get(2).getStart()); - assertEquals(8192 + 511, result.getPageRanges().get(2).getEnd()); - assertEquals(16384, result.getPageRanges().get(3).getStart()); - assertEquals(16384 + 511, result.getPageRanges().get(3).getEnd()); - } - - @Test - public void listBlobBlocksOnEmptyBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test13"; - String content = new String(new char[512]); - service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); - - ListBlobBlocksResult result = service.listBlobBlocks(container, blob); - - // Assert - assertNotNull(result); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(512, result.getContentLength()); - assertNotNull(result.getCommittedBlocks()); - assertEquals(0, result.getCommittedBlocks().size()); - assertNotNull(result.getUncommittedBlocks()); - assertEquals(0, result.getUncommittedBlocks().size()); - } - - @Test - public void listBlobBlocksWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test14"; - service.createBlockBlob(container, blob, null); - service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(new byte[256])); - service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); - service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); - - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() - .setCommittedList(true).setUncommittedList(true)); - - // Assert - assertNotNull(result); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(0, result.getContentLength()); - assertNotNull(result.getCommittedBlocks()); - assertEquals(0, result.getCommittedBlocks().size()); - assertNotNull(result.getUncommittedBlocks()); - assertEquals(3, result.getUncommittedBlocks().size()); - assertEquals("123", result.getUncommittedBlocks().get(0).getBlockId()); - assertEquals(256, result.getUncommittedBlocks().get(0).getBlockLength()); - assertEquals("124", result.getUncommittedBlocks().get(1).getBlockId()); - assertEquals(512, result.getUncommittedBlocks().get(1).getBlockLength()); - assertEquals("125", result.getUncommittedBlocks().get(2).getBlockId()); - assertEquals(195, result.getUncommittedBlocks().get(2).getBlockLength()); - } - - @Test - public void listBlobBlocksWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test14"; - service.createBlockBlob(container, blob, null); - service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(new byte[256])); - - BlockList blockList = new BlockList(); - blockList.addUncommittedEntry("123"); - service.commitBlobBlocks(container, blob, blockList); - - service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(new byte[512])); - service.createBlobBlock(container, blob, "125", new ByteArrayInputStream(new byte[195])); - - ListBlobBlocksResult result1 = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() - .setCommittedList(true).setUncommittedList(true)); - ListBlobBlocksResult result2 = service.listBlobBlocks(container, blob, - new ListBlobBlocksOptions().setCommittedList(true)); - ListBlobBlocksResult result3 = service.listBlobBlocks(container, blob, - new ListBlobBlocksOptions().setUncommittedList(true)); - - // Assert - assertEquals(1, result1.getCommittedBlocks().size()); - assertEquals(2, result1.getUncommittedBlocks().size()); - - assertEquals(1, result2.getCommittedBlocks().size()); - assertEquals(0, result2.getUncommittedBlocks().size()); - - assertEquals(0, result3.getCommittedBlocks().size()); - assertEquals(2, result3.getUncommittedBlocks().size()); - } - - @Test - public void commitBlobBlocksWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test14"; - String blockId1 = "1fedcba"; - String blockId2 = "2abcdef"; - String blockId3 = "3zzzzzz"; - service.createBlockBlob(container, blob, null); - service.createBlobBlock(container, blob, blockId1, new ByteArrayInputStream(new byte[256])); - service.createBlobBlock(container, blob, blockId2, new ByteArrayInputStream(new byte[512])); - service.createBlobBlock(container, blob, blockId3, new ByteArrayInputStream(new byte[195])); - - BlockList blockList = new BlockList(); - blockList.addUncommittedEntry(blockId1).addLatestEntry(blockId3); - service.commitBlobBlocks(container, blob, blockList); - - ListBlobBlocksResult result = service.listBlobBlocks(container, blob, new ListBlobBlocksOptions() - .setCommittedList(true).setUncommittedList(true)); - - // Assert - assertNotNull(result); - assertNotNull(result.getLastModified()); - assertNotNull(result.getEtag()); - assertEquals(256 + 195, result.getContentLength()); - - assertNotNull(result.getCommittedBlocks()); - assertEquals(2, result.getCommittedBlocks().size()); - assertEquals(blockId1, result.getCommittedBlocks().get(0).getBlockId()); - assertEquals(256, result.getCommittedBlocks().get(0).getBlockLength()); - assertEquals(blockId3, result.getCommittedBlocks().get(1).getBlockId()); - assertEquals(195, result.getCommittedBlocks().get(1).getBlockLength()); - - assertNotNull(result.getUncommittedBlocks()); - assertEquals(0, result.getUncommittedBlocks().size()); - } - - @Test - public void createBlobBlockWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test13"; - String content = new String(new char[512]); - service.createBlockBlob(container, blob, new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.createBlobBlock(container, blob, "123", new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.createBlobBlock(container, blob, "124", new ByteArrayInputStream(content.getBytes("UTF-8"))); - - // Assert - } - - @Test - public void createBlockBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream("some content".getBytes())); - - // Assert - } - - @Test - public void createBlockBlobWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // 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")); - - 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()); - assertEquals("en-us", props.getContentLanguage()); - assertEquals("text/plain", props.getContentType()); - assertEquals(content.length(), props.getContentLength()); - assertNotNull(props.getEtag()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("BlockBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - } - - @Test - public void createBlobSnapshotWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test3"; - service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob); - - // Assert - assertNotNull(snapshot); - assertNotNull(snapshot.getEtag()); - assertNotNull(snapshot.getLastModified()); - assertNotNull(snapshot.getSnapshot()); - } - - @Test - public void createBlobSnapshotWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test3"; - service.createBlockBlob(container, blob, new ByteArrayInputStream("some content".getBytes())); - CreateBlobSnapshotResult snapshot = service.createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions() - .addMetadata("test", "bar").addMetadata("blah", "bleah")); - - GetBlobPropertiesResult result = service.getBlobProperties(container, blob, - new GetBlobPropertiesOptions().setSnapshot(snapshot.getSnapshot())); - - // Assert - 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 - public void getBlockBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // 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")); - - GetBlobResult result = service.getBlob(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()); - assertEquals("en-us", props.getContentLanguage()); - assertEquals("text/plain", props.getContentType()); - assertEquals(content.length(), props.getContentLength()); - assertNotNull(props.getEtag()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("BlockBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - assertEquals(content, inputStreamToString(result.getContentStream(), "UTF-8")); - } - - @Test - public void getPageBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096, - 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 result = service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test"); - - // Assert - 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()); - assertEquals("text/plain", props.getContentType()); - assertEquals(4096, props.getContentLength()); - assertNotNull(props.getEtag()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("PageBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - assertEquals(4096, inputStreamToByteArray(result.getContentStream()).length); - } - - @Test - public void getBlobWithIfMatchETagAccessConditionWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 4096); - try { - service.getBlob(TEST_CONTAINER_FOR_BLOBS, "test", - new GetBlobOptions().setAccessCondition(AccessCondition.ifMatch("123"))); - Assert.fail("getBlob should throw an exception"); - } - catch (ServiceException e) { - } - - // Assert - } - - @Test - public void getBlobWithIfNoneMatchETagAccessConditionWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - 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.getProperties().getEtag()))); - Assert.fail("getBlob should throw an exception"); - } - catch (ServiceException e) { - } - - // Assert - } - - @Test - public void getBlobWithIfModifiedSinceAccessConditionWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - 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.getProperties().getLastModified()))); - Assert.fail("getBlob should throw an exception"); - } - catch (ServiceException e) { - } - - // Assert - } - - @Test - public void getBlobWithIfNotModifiedSinceAccessConditionWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - service.createPageBlob(container, blob, 4096); - 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 - Date lastModifiedBase = (Date) props.getProperties().getLastModified().clone(); - - // +1 second - Date lastModifiedNext = new Date(lastModifiedBase.getTime() + 1 * 1000); - - while (true) { - HashMap metadata = new HashMap(); - metadata.put("test", "test1"); - SetBlobMetadataResult result = service.setBlobMetadata(container, blob, metadata); - if (result.getLastModified().compareTo(lastModifiedNext) >= 0) - break; - } - try { - service.getBlob(container, blob, - new GetBlobOptions().setAccessCondition(AccessCondition.ifNotModifiedSince(lastModifiedBase))); - Assert.fail("getBlob should throw an exception"); - } - catch (ServiceException e) { - } - - // Assert - } - - @Test - public void getBlobPropertiesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - service.createPageBlob(container, blob, 4096); - GetBlobPropertiesResult result = service.getBlobProperties(container, blob); - - // Assert - assertNotNull(result); - - assertNotNull(result.getMetadata()); - assertEquals(0, result.getMetadata().size()); - - BlobProperties props = result.getProperties(); - assertNotNull(props); - assertNull(props.getCacheControl()); - assertNull(props.getContentEncoding()); - assertNull(props.getContentLanguage()); - assertEquals("application/octet-stream", props.getContentType()); - assertEquals(4096, props.getContentLength()); - assertNotNull(props.getEtag()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("PageBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - } - - @Test - public void getBlobMetadataWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test"; - service.createPageBlob(container, blob, 4096, - new CreateBlobOptions().addMetadata("test", "bar").addMetadata("blah", "bleah")); - GetBlobMetadataResult props = service.getBlobMetadata(container, blob); - - // Assert - assertNotNull(props); - assertNotNull(props.getEtag()); - assertNotNull(props.getMetadata()); - assertEquals(2, props.getMetadata().size()); - assertTrue(props.getMetadata().containsKey("test")); - assertTrue(props.getMetadata().containsValue("bar")); - assertTrue(props.getMetadata().containsKey("blah")); - assertTrue(props.getMetadata().containsValue("bleah")); - assertNotNull(props.getLastModified()); - } - - @Test - public void setBlobPropertiesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test10"; - service.createPageBlob(container, blob, 4096); - SetBlobPropertiesResult result = service.setBlobProperties(container, blob, new SetBlobPropertiesOptions() - .setCacheControl("test").setContentEncoding("UTF-8").setContentLanguage("en-us").setContentLength(512L) - .setContentMD5(null).setContentType("text/plain").setSequenceNumberAction("increment")); - - GetBlobPropertiesResult getResult = service.getBlobProperties(container, blob); - - // Assert - assertNotNull(result); - assertNotNull(result.getEtag()); - assertNotNull(result.getLastModified()); - 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()); - assertEquals("en-us", props.getContentLanguage()); - assertEquals("text/plain", props.getContentType()); - assertEquals(512, props.getContentLength()); - assertNull(props.getContentMD5()); - assertNotNull(props.getLastModified()); - assertEquals("PageBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(1, props.getSequenceNumber()); - } - - @Test - public void setBlobMetadataWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String container = TEST_CONTAINER_FOR_BLOBS; - String blob = "test11"; - HashMap metadata = new HashMap(); - metadata.put("test", "bar"); - metadata.put("blah", "bleah"); - - service.createPageBlob(container, blob, 4096); - SetBlobMetadataResult result = service.setBlobMetadata(container, blob, metadata); - GetBlobPropertiesResult props = service.getBlobProperties(container, blob); - - // Assert - assertNotNull(result); - assertNotNull(result.getEtag()); - assertNotNull(result.getLastModified()); - - assertNotNull(props); - assertNotNull(props.getMetadata()); - assertEquals(2, props.getMetadata().size()); - assertTrue(props.getMetadata().containsKey("test")); - assertTrue(props.getMetadata().containsValue("bar")); - assertTrue(props.getMetadata().containsKey("blah")); - assertTrue(props.getMetadata().containsValue("bleah")); - } - - @Test - public void deleteBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String content = "some content"; - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test2", new ByteArrayInputStream(content.getBytes("UTF-8"))); - - service.deleteBlob(TEST_CONTAINER_FOR_BLOBS, "test2"); - - // Assert - } - - @Test - public void copyBlobWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - String content = "some content2"; - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "test6", new ByteArrayInputStream(content.getBytes("UTF-8"))); - service.copyBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5", TEST_CONTAINER_FOR_BLOBS, "test6"); - - GetBlobResult result = service.getBlob(TEST_CONTAINER_FOR_BLOBS_2, "test5"); - - // 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.getLastModified()); - assertEquals("BlockBlob", props.getBlobType()); - assertEquals("unlocked", props.getLeaseStatus()); - assertEquals(0, props.getSequenceNumber()); - assertEquals(content, inputStreamToString(result.getContentStream(), "UTF-8")); - } - - @Test - public void acquireLeaseWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // 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").getLeaseId(); - service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); - - // Assert - assertNotNull(leaseId); - } - - @Test - public void renewLeaseWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // 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").getLeaseId(); - String leaseId2 = service.renewLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId).getLeaseId(); - service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); - - // Assert - assertNotNull(leaseId); - assertNotNull(leaseId2); - } - - @Test - public void breakLeaseWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // 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").getLeaseId(); - service.breakLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); - service.releaseLease(TEST_CONTAINER_FOR_BLOBS, "test6", leaseId); - - // Assert - assertNotNull(leaseId); - } - - class RetryPolicyObserver implements ServiceFilter { - public int requestCount; - - @Override - public Response handle(Request request, Next next) throws Exception { - requestCount++; - return next.handle(request); - } - } - - @Test - public void retryPolicyWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - RetryPolicyObserver observer = new RetryPolicyObserver(); - service = service.withFilter(observer); - - // Act - service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, - 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); - - ServiceException Error = null; - try { - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 12); - } - catch (ServiceException e) { - Error = e; - } - - // Assert - assertNotNull(Error); - assertEquals(400, Error.getHttpStatusCode()); - assertEquals(4, observer.requestCount); - } - - @Test - public void retryPolicyCompositionWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - RetryPolicyObserver observer = new RetryPolicyObserver(); - service = service.withFilter(observer); - - // Act - service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, - 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); - service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, - 2/*maximumAttempts*/, new int[] { 400, 500, 503 }))); - - ServiceException Error = null; - try { - service.createPageBlob(TEST_CONTAINER_FOR_BLOBS, "test", 12); - } - catch (ServiceException e) { - Error = e; - } - - // Assert - assertNotNull(Error); - assertEquals(400, Error.getHttpStatusCode()); - assertEquals(3, observer.requestCount); - } - - private class NonResetableInputStream extends FilterInputStream { - - protected NonResetableInputStream(InputStream in) { - super(in); - } - - @Override - public boolean markSupported() { - return false; - } - } - - @Test - public void retryPolicyThrowsOnInvalidInputStream() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, - 3/*maximumAttempts*/, new int[] { 400, 500, 503 }))); - - Exception error = null; - try { - String content = "foo"; - InputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); - InputStream stream = new NonResetableInputStream(contentStream); - - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "testretry", stream); - } - catch (Exception e) { - error = e; - } - - // Assert - assertNotNull(error); - } - - private class ResetableInputStream extends FilterInputStream { - private boolean resetCalled; - - protected ResetableInputStream(InputStream in) { - super(in); - } - - @Override - public void reset() throws IOException { - super.reset(); - setResetCalled(true); - } - - public boolean isResetCalled() { - return resetCalled; - } - - public void setResetCalled(boolean resetCalled) { - this.resetCalled = resetCalled; - } - } - - @Test - public void retryPolicyCallsResetOnValidInputStream() throws Exception { - // Arrange - Configuration config = createConfiguration(); - BlobContract service = BlobService.create(config); - - // Act - service = service.withFilter(new RetryPolicyFilter(new ExponentialRetryPolicy(100/*deltaBackoff*/, - 3/*maximumAttempts*/, new int[] { 403 }))); - - ServiceException error = null; - ResetableInputStream stream = null; - try { - String content = "foo"; - InputStream contentStream = new ByteArrayInputStream(content.getBytes("UTF-8")); - stream = new ResetableInputStream(contentStream); - - service.createBlockBlob(TEST_CONTAINER_FOR_BLOBS, "invalidblobname @#$#@$@", stream); - } - catch (ServiceException e) { - error = e; - } - - // Assert - assertNotNull(error); - assertEquals(403, error.getHttpStatusCode()); - assertNotNull(stream); - assertTrue(stream.isResetCalled()); - } - - private byte[] inputStreamToByteArray(InputStream inputStream) throws IOException { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - - byte[] buffer = new byte[1024]; - try { - while (true) { - int n = inputStream.read(buffer); - if (n == -1) - break; - outputStream.write(buffer, 0, n); - } - } - finally { - inputStream.close(); - } - return outputStream.toByteArray(); - } - - private String inputStreamToString(InputStream inputStream, String encoding) throws IOException { - Writer writer = new StringWriter(); - - char[] buffer = new char[1024]; - try { - Reader reader = new BufferedReader(new InputStreamReader(inputStream, encoding)); - while (true) { - int n = reader.read(buffer); - if (n == -1) - break; - writer.write(buffer, 0, n); - } - } - finally { - inputStream.close(); - } - return writer.toString(); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java deleted file mode 100644 index 4275e212fb8c0..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.blob; - -import com.microsoft.windowsazure.services.core.Configuration; - -public abstract class IntegrationTestBase { - protected static Configuration createConfiguration() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, BlobConfiguration.ACCOUNT_NAME); - overrideWithEnv(config, BlobConfiguration.ACCOUNT_KEY); - overrideWithEnv(config, BlobConfiguration.URI); - return config; - } - - private static void overrideWithEnv(Configuration config, String key) { - String value = System.getenv(key); - if (value == null) - return; - - config.setProperty(key, value); - } - - protected static boolean isRunningWithEmulator(Configuration config) { - String accountName = "devstoreaccount1"; - String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; - - return accountName.equals(config.getProperty(BlobConfiguration.ACCOUNT_NAME)) - && accountKey.equals(config.getProperty(BlobConfiguration.ACCOUNT_KEY)); - } -} 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 deleted file mode 100644 index a854804bde36d..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/IntegrationTestBase.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -import com.microsoft.windowsazure.services.core.Configuration; - -public abstract class IntegrationTestBase { - protected static Configuration createConfiguration() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, QueueConfiguration.ACCOUNT_NAME); - overrideWithEnv(config, QueueConfiguration.ACCOUNT_KEY); - overrideWithEnv(config, QueueConfiguration.URI); - return config; - } - - private static void overrideWithEnv(Configuration config, String key) { - String value = System.getenv(key); - if (value == null) - return; - - config.setProperty(key, value); - } - - protected static boolean isRunningWithEmulator(Configuration config) { - String accountName = "devstoreaccount1"; - String accountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; - - return accountName.equals(config.getProperty(QueueConfiguration.ACCOUNT_NAME)) - && accountKey.equals(config.getProperty(QueueConfiguration.ACCOUNT_KEY)); - } -} 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 deleted file mode 100644 index db8ca0f130c1e..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/QueueServiceIntegrationTest.java +++ /dev/null @@ -1,554 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.queue; - -import static org.junit.Assert.*; - -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.TimeZone; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.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.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.ListQueuesResult.Queue; -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-"; - private static final String createableQueuesPrefix = "csdktest-"; - 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 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; - 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]; - 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]; - CREATABLE_QUEUE_3 = creatableQueues[2]; - - // Create all test containers and their content - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - createQueues(service, testQueuesPrefix, testQueues); - } - - @AfterClass - public static void cleanup() throws Exception { - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - deleteQueues(service, testQueuesPrefix, testQueues); - deleteQueues(service, createableQueuesPrefix, creatableQueues); - } - - private static void createQueues(QueueContract service, String prefix, String[] list) throws Exception { - Set containers = listQueues(service, prefix); - for (String item : list) { - if (!containers.contains(item)) { - service.createQueue(item); - } - } - } - - private static void deleteQueues(QueueContract service, String prefix, String[] list) throws Exception { - Set containers = listQueues(service, prefix); - for (String item : list) { - if (containers.contains(item)) { - service.deleteQueue(item); - } - } - } - - private static Set listQueues(QueueContract service, String prefix) throws Exception { - HashSet result = new HashSet(); - ListQueuesResult list = service.listQueues(new ListQueuesOptions().setPrefix(prefix)); - for (Queue item : list.getQueues()) { - result.add(item.getName()); - } - return result; - } - - @Test - public void getServicePropertiesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // Don't run this test with emulator, as v1.6 doesn't support this method - if (isRunningWithEmulator(config)) { - return; - } - - // Act - ServiceProperties props = service.getServiceProperties().getValue(); - - // 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 setServicePropertiesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // Don't run this test with emulator, as v1.6 doesn't support this method - if (isRunningWithEmulator(config)) { - return; - } - - // Act - ServiceProperties props = service.getServiceProperties().getValue(); - - props.getLogging().setRead(true); - service.setServiceProperties(props); - - props = service.getServiceProperties().getValue(); - - // Assert - assertNotNull(props); - assertNotNull(props.getLogging()); - assertNotNull(props.getLogging().getRetentionPolicy()); - assertNotNull(props.getLogging().getVersion()); - assertTrue(props.getLogging().isRead()); - assertNotNull(props.getMetrics().getRetentionPolicy()); - assertNotNull(props.getMetrics().getVersion()); - } - - @Test - public void createQueueWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // 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(); - QueueContract service = QueueService.create(config); - - // 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")); - } - - @Test - public void listQueuesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // 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(); - QueueContract service = QueueService.create(config); - - // 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(); - QueueContract service = QueueService.create(config); - - // 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(); - QueueContract service = QueueService.create(config); - - // 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 listMessagesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - 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.getQueueMessages().size()); - - QueueMessage entry = result.getQueueMessages().get(0); - - assertNotNull(entry.getMessageId()); - assertNotNull(entry.getMessageText()); - 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 listMessagesWithOptionsWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - 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.getQueueMessages().size()); - for (int i = 0; i < 4; i++) { - QueueMessage entry = result.getQueueMessages().get(i); - - assertNotNull(entry.getMessageId()); - assertNotNull(entry.getMessageText()); - 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(); - QueueContract service = QueueService.create(config); - 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.getQueueMessages().size()); - - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result - .getQueueMessages().get(0); - - assertNotNull(entry.getMessageId()); - assertNotNull(entry.getMessageText()); - 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(); - QueueContract service = QueueService.create(config); - 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.getQueueMessages().size()); - for (int i = 0; i < 4; i++) { - com.microsoft.windowsazure.services.queue.models.PeekMessagesResult.QueueMessage entry = result - .getQueueMessages().get(i); - - assertNotNull(entry.getMessageId()); - assertNotNull(entry.getMessageText()); - assertEquals(0, entry.getDequeueCount()); - - assertNotNull(entry.getExpirationDate()); - assertTrue(year2010.before(entry.getExpirationDate())); - - assertNotNull(entry.getInsertionDate()); - assertTrue(year2010.before(entry.getInsertionDate())); - } - } - - @Test - public void clearMessagesWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // 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()); - } - - @Test - public void deleteMessageWorks() throws Exception { - // Arrange - Configuration config = createConfiguration(); - QueueContract service = QueueService.create(config); - - // 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(); - QueueContract service = QueueService.create(config); - 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())); - - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java deleted file mode 100644 index 849fd72e606a8..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import static org.junit.Assert.*; - -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerProperties; -import com.microsoft.windowsazure.services.serviceBus.implementation.BrokerPropertiesMapper; - -public class BrokerPropertiesMapperTest { - @Test - public void jsonStringMapsToBrokerPropertiesObject() { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = mapper.fromString("{\"DeliveryCount\":5,\"MessageId\":\"something\"}"); - - // Assert - assertNotNull(properties); - assertEquals(new Integer(5), properties.getDeliveryCount()); - assertEquals("something", properties.getMessageId()); - } - - @Test - public void nonDefaultPropertiesMapToJsonString() { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = new BrokerProperties(); - properties.setMessageId("foo"); - properties.setDeliveryCount(7); - String json = mapper.toString(properties); - - // Assert - assertNotNull(json); - assertEquals("{\"DeliveryCount\":7,\"MessageId\":\"foo\"}", json); - } - - @Test - public void deserializingAllPossibleValues() { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar.set(1994, 10, 6, 8, 49, 37); - Date schedTimeUtc = calendar.getTime(); - - Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - calendar2.set(2011, 9, 14, 12, 34, 56); - Date lockedUntilUtc = calendar2.getTime(); - - // Act - BrokerProperties properties = mapper.fromString( - "{" + - "\"CorrelationId\": \"corid\"," + - "\"SessionId\": \"sesid\"," + - "\"DeliveryCount\": 5," + - "\"LockedUntilUtc\": \" Fri, 14 Oct 2011 12:34:56 GMT\"," + - "\"LockToken\": \"loctok\"," + - "\"MessageId\": \"mesid\"," + - "\"Label\": \"lab\"," + - "\"ReplyTo\": \"repto\"," + - "\"SequenceNumber\": 7," + - "\"TimeToLive\": 8.123," + - "\"To\": \"to\"," + - "\"ScheduledEnqueueTimeUtc\": \" Sun, 06 Nov 1994 08:49:37 GMT\"," + - "\"ReplyToSessionId\": \"reptosesid\"," + - "\"MessageLocation\": \"mesloc\"," + - "\"LockLocation\": \"locloc\"" + - "}"); - - // Assert - assertNotNull(properties); - - long lockedUntilDelta = properties.getLockedUntilUtc().getTime() - lockedUntilUtc.getTime(); - long schedTimeDelta = properties.getScheduledEnqueueTimeUtc().getTime() - schedTimeUtc.getTime(); - - assertEquals("corid", properties.getCorrelationId()); - assertEquals("sesid", properties.getSessionId()); - assertEquals(5, (int) properties.getDeliveryCount()); - assertTrue(Math.abs(lockedUntilDelta) < 500); - assertEquals("loctok", properties.getLockToken()); - assertEquals("mesid", properties.getMessageId()); - assertEquals("lab", properties.getLabel()); - assertEquals("repto", properties.getReplyTo()); - assertEquals(7, (long) properties.getSequenceNumber()); - assertEquals(8.123, properties.getTimeToLive(), .001); - assertEquals("to", properties.getTo()); - assertTrue(Math.abs(schedTimeDelta) < 500); - assertEquals("reptosesid", properties.getReplyToSessionId()); - assertEquals("mesloc", properties.getMessageLocation()); - assertEquals("locloc", properties.getLockLocation()); - } - - @Test - public void missingDatesDeserializeAsNull() { - // Arrange - BrokerPropertiesMapper mapper = new BrokerPropertiesMapper(); - - // Act - BrokerProperties properties = mapper.fromString("{}"); - - // Assert - assertNull(properties.getLockedUntilUtc()); - assertNull(properties.getScheduledEnqueueTimeUtc()); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java deleted file mode 100644 index 100f527ae41ec..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import static com.microsoft.windowsazure.services.serviceBus.Util.*; - -import org.junit.Before; -import org.junit.BeforeClass; - -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; - -public abstract class IntegrationTestBase { - @BeforeClass - public static void initializeSystem() { - System.setProperty("http.keepAlive", "false"); - } - - @Before - public void initialize() throws Exception { - - boolean testAlphaExists = false; - ServiceBusContract service = ServiceBusService.create(); - for (QueueInfo queue : iterateQueues(service)) { - String queueName = queue.getPath(); - if (queueName.startsWith("Test") || queueName.startsWith("test")) { - if (queueName.equalsIgnoreCase("TestAlpha")) { - testAlphaExists = true; - long count = queue.getMessageCount(); - for (long i = 0; i != count; ++i) { - service.receiveQueueMessage(queueName, new ReceiveMessageOptions().setTimeout(20)); - } - } - else { - service.deleteQueue(queueName); - } - } - } - for (TopicInfo topic : iterateTopics(service)) { - String topicName = topic.getPath(); - if (topicName.startsWith("Test") || topicName.startsWith("test")) { - service.deleteQueue(topicName); - } - } - if (!testAlphaExists) { - service.createQueue(new QueueInfo("TestAlpha")); - } - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java deleted file mode 100644 index f9262cd868747..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.Configuration; - -public class ServiceBusConfigurationTest { - @Test - public void ConfigureSetsExpectedProperties() { - // Arrange - Configuration config = new Configuration(); - - // Act - ServiceBusConfiguration.configureWithWrapAuthentication(config, "alpha", "beta", "gamma"); - - // Assert - assertEquals("https://alpha.servicebus.windows.net/", config.getProperty("serviceBus.uri")); - assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", config.getProperty("serviceBus.wrap.uri")); - assertEquals("beta", config.getProperty("serviceBus.wrap.name")); - assertEquals("gamma", config.getProperty("serviceBus.wrap.password")); - } - - @Test - public void UsingProfileAddsPrefix() { - // Arrange - Configuration config = new Configuration(); - - // Act - ServiceBusConfiguration.configureWithWrapAuthentication("backup", config, "alpha", "beta", "gamma"); - - // Assert - assertEquals("https://alpha.servicebus.windows.net/", config.getProperty("backup.serviceBus.uri")); - assertEquals("https://alpha-sb.accesscontrol.windows.net/WRAPv0.9", - config.getProperty("backup.serviceBus.wrap.uri")); - assertEquals("beta", config.getProperty("backup.serviceBus.wrap.name")); - assertEquals("gamma", config.getProperty("backup.serviceBus.wrap.password")); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java deleted file mode 100644 index aba5eace5bf60..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.serviceBus.implementation.ServiceBusExceptionProcessor; - -public class ServiceBusCreationTest { - @Test - public void theServiceClassMayBeCreatedDirectlyViaSingletonConfig() throws Exception { - ServiceBusConfiguration.configureWithWrapAuthentication("my-namespace", "my-identity", "my-shared-secret"); - ServiceBusContract service = ServiceBusService.create(); - - assertNotNull(service); - assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); - } - - public Configuration newConfiguration() { - Configuration config = new Configuration(); - ServiceBusConfiguration.configureWithWrapAuthentication(config, "my-namespace", "my-identity", "my-shared-secret"); - return config; - } - - @Test - public void theServiceClassMayBeCreatedDirectlyWithConfig() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = ServiceBusService.create(config); - - assertNotNull(service); - assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); - } - - @Test - public void theServiceClassMayAlsoBeCreatedFromConfig() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = config.create(ServiceBusContract.class); - - assertNotNull(service); - assertEquals(ServiceBusExceptionProcessor.class, service.getClass()); - } - - @Test - public void testDefaultBuilderCreatesServiceImpl() throws Exception { - Configuration config = newConfiguration(); - ServiceBusContract service = config.create(ServiceBusContract.class); - - assertNotNull(service); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java deleted file mode 100644 index 91a94b9fa5297..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ /dev/null @@ -1,514 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.Builder; -import com.microsoft.windowsazure.services.core.Builder.Alteration; -import com.microsoft.windowsazure.services.core.Builder.Registry; -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.ServiceFilter.Request; -import com.microsoft.windowsazure.services.core.ServiceFilter.Response; -import com.microsoft.windowsazure.services.serviceBus.implementation.CorrelationFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.EmptyRuleAction; -import com.microsoft.windowsazure.services.serviceBus.implementation.FalseFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.SqlFilter; -import com.microsoft.windowsazure.services.serviceBus.implementation.SqlRuleAction; -import com.microsoft.windowsazure.services.serviceBus.implementation.TrueFilter; -import com.microsoft.windowsazure.services.serviceBus.models.BrokeredMessage; -import com.microsoft.windowsazure.services.serviceBus.models.ListQueuesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListRulesResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListSubscriptionsResult; -import com.microsoft.windowsazure.services.serviceBus.models.ListTopicsResult; -import com.microsoft.windowsazure.services.serviceBus.models.QueueInfo; -import com.microsoft.windowsazure.services.serviceBus.models.ReceiveMessageOptions; -import com.microsoft.windowsazure.services.serviceBus.models.RuleInfo; -import com.microsoft.windowsazure.services.serviceBus.models.SubscriptionInfo; -import com.microsoft.windowsazure.services.serviceBus.models.TopicInfo; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.filter.LoggingFilter; - -public class ServiceBusIntegrationTest extends IntegrationTestBase { - - private ServiceBusContract service; - - static ReceiveMessageOptions RECEIVE_AND_DELETE_5_SECONDS = new ReceiveMessageOptions().setReceiveAndDelete() - .setTimeout(5); - static ReceiveMessageOptions PEEK_LOCK_5_SECONDS = new ReceiveMessageOptions().setPeekLock().setTimeout(5); - - @Before - public void createService() throws Exception { - // reinitialize configuration from known state - Configuration config = Configuration.load(); - overrideWithEnv(config, ServiceBusConfiguration.URI); - overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); - overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); - overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); - - // add LoggingFilter to any pipeline that is created - Registry builder = (Registry) config.getBuilder(); - builder.alter(Client.class, new Alteration() { - @Override - public Client alter(Client instance, Builder builder, Map properties) { - instance.addFilter(new LoggingFilter()); - return instance; - } - }); - - // applied as default configuration - Configuration.setInstance(config); - service = ServiceBusService.create(); - } - - private static void overrideWithEnv(Configuration config, String key) { - String value = System.getenv(key); - if (value == null) - return; - - config.setProperty(key, value); - } - - @Test - public void fetchQueueAndListQueuesWorks() throws Exception { - // Arrange - - // Act - QueueInfo entry = service.getQueue("TestAlpha").getValue(); - ListQueuesResult feed = service.listQueues(); - - // Assert - assertNotNull(entry); - assertNotNull(feed); - } - - @Test - public void createQueueWorks() throws Exception { - // Arrange - - // Act - QueueInfo queue = new QueueInfo("TestCreateQueueWorks").setMaxSizeInMegabytes(1024L); - QueueInfo saved = service.createQueue(queue).getValue(); - - // Assert - assertNotNull(saved); - assertNotSame(queue, saved); - assertEquals("TestCreateQueueWorks", saved.getPath()); - } - - @Test - public void deleteQueueWorks() throws Exception { - // Arrange - service.createQueue(new QueueInfo("TestDeleteQueueWorks")); - - // Act - service.deleteQueue("TestDeleteQueueWorks"); - - // Assert - } - - @Test - public void sendMessageWorks() throws Exception { - // Arrange - BrokeredMessage message = new BrokeredMessage("sendMessageWorks"); - - // Act - service.sendQueueMessage("TestAlpha", message); - - // Assert - } - - @Test - public void receiveMessageWorks() throws Exception { - // Arrange - String queueName = "TestReceiveMessageWorks"; - service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new BrokeredMessage("Hello World")); - - // Act - BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); - byte[] data = new byte[100]; - int size = message.getBody().read(data); - - // Assert - assertEquals(11, size); - assertArrayEquals("Hello World".getBytes(), Arrays.copyOf(data, size)); - } - - @Test - public void peekLockMessageWorks() throws Exception { - // Arrange - String queueName = "TestPeekLockMessageWorks"; - service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); - - // Act - BrokeredMessage message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); - - // Assert - byte[] data = new byte[100]; - int size = message.getBody().read(data); - assertEquals(11, size); - assertEquals("Hello Again", new String(data, 0, size)); - } - - @Test - public void peekLockedMessageCanBeCompleted() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeCompleted"; - service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); - BrokeredMessage message = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); - - // Act - String lockToken = message.getLockToken(); - Date lockedUntil = message.getLockedUntilUtc(); - String lockLocation = message.getLockLocation(); - - service.deleteMessage(message); - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNotNull(lockLocation); - } - - @Test - public void peekLockedMessageCanBeUnlocked() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeUnlocked"; - service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); - BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); - - // Act - String lockToken = peekedMessage.getLockToken(); - Date lockedUntil = peekedMessage.getLockedUntilUtc(); - - service.unlockMessage(peekedMessage); - BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS) - .getValue(); - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNull(receivedMessage.getLockToken()); - assertNull(receivedMessage.getLockedUntilUtc()); - } - - @Test - public void peekLockedMessageCanBeDeleted() throws Exception { - // Arrange - String queueName = "TestPeekLockedMessageCanBeDeleted"; - service.createQueue(new QueueInfo(queueName)); - service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again")); - BrokeredMessage peekedMessage = service.receiveQueueMessage(queueName, PEEK_LOCK_5_SECONDS).getValue(); - - // Act - String lockToken = peekedMessage.getLockToken(); - Date lockedUntil = peekedMessage.getLockedUntilUtc(); - - service.deleteMessage(peekedMessage); - BrokeredMessage receivedMessage = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS) - .getValue(); - - // Assert - assertNotNull(lockToken); - assertNotNull(lockedUntil); - assertNull(receivedMessage.getLockToken()); - assertNull(receivedMessage.getLockedUntilUtc()); - } - - @Test - public void contentTypePassesThrough() throws Exception { - // Arrange - String queueName = "TestContentTypePassesThrough"; - service.createQueue(new QueueInfo(queueName)); - - // Act - service.sendQueueMessage(queueName, new BrokeredMessage("Hello Again").setContentType("text/xml")); - - BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); - - // Assert - assertNotNull(message); - assertEquals("text/xml", message.getContentType()); - } - - @Test - public void topicCanBeCreatedListedFetchedAndDeleted() throws ServiceException { - // Arrange - String topicName = "TestTopicCanBeCreatedListedFetchedAndDeleted"; - - // Act - TopicInfo created = service.createTopic(new TopicInfo().setPath(topicName)).getValue(); - ListTopicsResult listed = service.listTopics(); - TopicInfo fetched = service.getTopic(topicName).getValue(); - service.deleteTopic(topicName); - ListTopicsResult listed2 = service.listTopics(); - - // Assert - assertNotNull(created); - assertNotNull(listed); - assertNotNull(fetched); - assertNotNull(listed2); - - assertEquals(listed.getItems().size() - 1, listed2.getItems().size()); - } - - @Test - public void filterCanSeeAndChangeRequestOrResponse() throws ServiceException { - // Arrange - final List requests = new ArrayList(); - final List responses = new ArrayList(); - - ServiceBusContract filtered = service.withFilter(new ServiceFilter() { - @Override - public Response handle(Request request, Next next) throws Exception { - requests.add(request); - Response response = next.handle(request); - responses.add(response); - return response; - } - }); - - // Act - QueueInfo created = filtered.createQueue(new QueueInfo("TestFilterCanSeeAndChangeRequestOrResponse")) - .getValue(); - - // Assert - assertNotNull(created); - assertEquals(1, requests.size()); - assertEquals(1, responses.size()); - } - - @Test - public void subscriptionsCanBeCreatedOnTopics() throws Exception { - // Arrange - String topicName = "TestSubscriptionsCanBeCreatedOnTopics"; - service.createTopic(new TopicInfo(topicName)); - - // Act - SubscriptionInfo created = service.createSubscription(topicName, new SubscriptionInfo("MySubscription")) - .getValue(); - - // Assert - assertNotNull(created); - assertEquals("MySubscription", created.getName()); - } - - @Test - public void subscriptionsCanBeListed() throws Exception { - // Arrange - String topicName = "TestSubscriptionsCanBeListed"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("MySubscription2")); - - // Act - ListSubscriptionsResult result = service.listSubscriptions(topicName); - - // Assert - assertNotNull(result); - assertEquals(1, result.getItems().size()); - assertEquals("MySubscription2", result.getItems().get(0).getName()); - } - - @Test - public void subscriptionsDetailsMayBeFetched() throws Exception { - // Arrange - String topicName = "TestSubscriptionsDetailsMayBeFetched"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("MySubscription3")); - - // Act - SubscriptionInfo result = service.getSubscription(topicName, "MySubscription3").getValue(); - - // Assert - assertNotNull(result); - assertEquals("MySubscription3", result.getName()); - } - - @Test - public void subscriptionsMayBeDeleted() throws Exception { - // Arrange - String topicName = "TestSubscriptionsMayBeDeleted"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("MySubscription4")); - service.createSubscription(topicName, new SubscriptionInfo("MySubscription5")); - - // Act - service.deleteSubscription(topicName, "MySubscription4"); - - // Assert - ListSubscriptionsResult result = service.listSubscriptions(topicName); - assertNotNull(result); - assertEquals(1, result.getItems().size()); - assertEquals("MySubscription5", result.getItems().get(0).getName()); - } - - @Test - public void subscriptionWillReceiveMessage() throws Exception { - // Arrange - String topicName = "TestSubscriptionWillReceiveMessage"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.sendTopicMessage(topicName, - new BrokeredMessage("

Testing subscription

").setContentType("text/html")); - - // Act - BrokeredMessage message = service.receiveSubscriptionMessage(topicName, "sub", RECEIVE_AND_DELETE_5_SECONDS) - .getValue(); - - // Assert - assertNotNull(message); - - byte[] data = new byte[100]; - int size = message.getBody().read(data); - assertEquals("

Testing subscription

", new String(data, 0, size)); - assertEquals("text/html", message.getContentType()); - } - - @Test - public void rulesCanBeCreatedOnSubscriptions() throws Exception { - // Arrange - String topicName = "TestrulesCanBeCreatedOnSubscriptions"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - - // Act - RuleInfo created = service.createRule(topicName, "sub", new RuleInfo("MyRule1")).getValue(); - - // Assert - assertNotNull(created); - assertEquals("MyRule1", created.getName()); - } - - @Test - public void rulesCanBeListedAndDefaultRuleIsPrecreated() throws Exception { - // Arrange - String topicName = "TestrulesCanBeListedAndDefaultRuleIsPrecreated"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.createRule(topicName, "sub", new RuleInfo("MyRule2")); - - // Act - ListRulesResult result = service.listRules(topicName, "sub"); - - // Assert - assertNotNull(result); - assertEquals(2, result.getItems().size()); - RuleInfo rule0 = result.getItems().get(0); - RuleInfo rule1 = result.getItems().get(1); - if (rule0.getName() == "MyRule2") { - RuleInfo swap = rule1; - rule1 = rule0; - rule0 = swap; - } - - assertEquals("$Default", rule0.getName()); - assertEquals("MyRule2", rule1.getName()); - assertNotNull(result.getItems().get(0).getModel()); - } - - @Test - public void ruleDetailsMayBeFetched() throws Exception { - // Arrange - String topicName = "TestruleDetailsMayBeFetched"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - - // Act - RuleInfo result = service.getRule(topicName, "sub", "$Default").getValue(); - - // Assert - assertNotNull(result); - assertEquals("$Default", result.getName()); - } - - @Test - public void rulesMayBeDeleted() throws Exception { - // Arrange - String topicName = "TestRulesMayBeDeleted"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - service.createRule(topicName, "sub", new RuleInfo("MyRule4")); - service.createRule(topicName, "sub", new RuleInfo("MyRule5")); - - // Act - service.deleteRule(topicName, "sub", "MyRule5"); - service.deleteRule(topicName, "sub", "$Default"); - - // Assert - ListRulesResult result = service.listRules(topicName, "sub"); - assertNotNull(result); - assertEquals(1, result.getItems().size()); - assertEquals("MyRule4", result.getItems().get(0).getName()); - } - - @Test - public void rulesMayHaveActionAndFilter() throws ServiceException { - // Arrange - String topicName = "TestRulesMayHaveAnActionAndFilter"; - service.createTopic(new TopicInfo(topicName)); - service.createSubscription(topicName, new SubscriptionInfo("sub")); - - // Act - RuleInfo ruleOne = service.createRule(topicName, "sub", new RuleInfo("One").withCorrelationIdFilter("my-id")) - .getValue(); - RuleInfo ruleTwo = service.createRule(topicName, "sub", new RuleInfo("Two").withTrueFilter()).getValue(); - RuleInfo ruleThree = service.createRule(topicName, "sub", new RuleInfo("Three").withFalseFilter()).getValue(); - RuleInfo ruleFour = service.createRule(topicName, "sub", new RuleInfo("Four").withEmptyRuleAction()).getValue(); - RuleInfo ruleFive = service.createRule(topicName, "sub", new RuleInfo("Five").withSqlRuleAction("SET x = 5")) - .getValue(); - RuleInfo ruleSix = service.createRule(topicName, "sub", new RuleInfo("Six").withSqlExpressionFilter("x != 5")) - .getValue(); - - // Assert - assertEquals(CorrelationFilter.class, ruleOne.getFilter().getClass()); - assertEquals(TrueFilter.class, ruleTwo.getFilter().getClass()); - assertEquals(FalseFilter.class, ruleThree.getFilter().getClass()); - assertEquals(EmptyRuleAction.class, ruleFour.getAction().getClass()); - assertEquals(SqlRuleAction.class, ruleFive.getAction().getClass()); - assertEquals(SqlFilter.class, ruleSix.getFilter().getClass()); - - } - - @Test - public void messagesMayHaveCustomProperties() throws ServiceException { - // Arrange - String queueName = "TestMessagesMayHaveCustomProperties"; - service.createQueue(new QueueInfo(queueName)); - - // Act - service.sendQueueMessage(queueName, new BrokeredMessage("").setProperty("hello", "world") - .setProperty("foo", 42)); - BrokeredMessage message = service.receiveQueueMessage(queueName, RECEIVE_AND_DELETE_5_SECONDS).getValue(); - - // Assert - assertEquals("world", message.getProperty("hello")); - assertEquals(42, message.getProperty("foo")); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java deleted file mode 100644 index 6366937c63bf9..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import static org.junit.Assert.*; - -import java.text.ParseException; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; -import java.util.UUID; - -import org.junit.Before; -import org.junit.Test; - -public class CustomPropertiesMapperTest { - private CustomPropertiesMapper mapper; - - @Before - public void init() { - mapper = new CustomPropertiesMapper(); - } - - @Test - public void stringValuesShouldComeThroughInQuotes() { - // Arrange - - // Act - String text = mapper.toString("This is a string"); - - // Assert - assertEquals("\"This is a string\"", text); - } - - @Test - public void nonStringValuesShouldNotHaveQuotes() { - // Arrange - - // Act - String text = mapper.toString(78); - - // Assert - assertEquals("78", text); - } - - @Test - public void supportedJavaTypesHaveExpectedRepresentations() { - // Arrange - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); - - // Act - - // Assert - // assertEquals("78;byte", mapper.toString((byte) 78)); - assertEquals("78", mapper.toString((byte) 78)); - assertEquals("\"a\"", mapper.toString('a')); - assertEquals("-78", mapper.toString((short) -78)); - // assertEquals("78;ushort", mapper.toString((unsigned short)78); - assertEquals("-78", mapper.toString(-78)); - // assertEquals("78;uint", mapper.toString(78)); - assertEquals("-78", mapper.toString((long) -78)); - // assertEquals("78;ulong", mapper.toString(78)); - assertEquals("78.5", mapper.toString((float) 78.5)); - assertEquals("78.5", mapper.toString(78.5)); - //assertEquals("78;decimal", mapper.toString(78)); - assertEquals("true", mapper.toString(true)); - assertEquals("false", mapper.toString(false)); - assertEquals("\"12345678-9abc-def0-9abc-def012345678\"", - mapper.toString(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L))); - assertEquals("\"Thu, 14 Oct 1971 12:34:56 GMT\"", mapper.toString(cal)); - assertEquals("\"Thu, 14 Oct 1971 12:34:56 GMT\"", mapper.toString(cal.getTime())); - //assertEquals("78;date-seconds", mapper.toString(78)); - } - - @Test - public void valuesComeBackAsStringsWhenInQuotes() throws ParseException { - // Arrange - - // Act - Object value = mapper.fromString("\"Hello world\""); - - // Assert - assertEquals("Hello world", value); - assertEquals(String.class, value.getClass()); - } - - @Test - public void nonStringTypesWillBeParsedAsNumeric() throws ParseException { - // Arrange - - // Act - Object value = mapper.fromString("5"); - - // Assert - assertEquals(5, value); - assertEquals(Integer.class, value.getClass()); - } - - @Test - public void supportedFormatsHaveExpectedJavaTypes() throws ParseException { - // Arrange - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.set(1971, Calendar.OCTOBER, 14, 12, 34, 56); - - // Act - Date dt = (Date) mapper.fromString("\"Thu, 14 Oct 1971 12:34:56 GMT\""); - - // Assert - // assertEquals("78;byte", mapper.toString((byte) 78)); - // assertEquals((byte) 78, mapper.fromString("78")); - // assertEquals('a', mapper.fromString("a;char")); - // assertEquals((short) -78, mapper.fromString("-78;short")); - // assertEquals("78;ushort", mapper.toString((unsigned short)78); - assertEquals(-78, mapper.fromString("-78")); - // assertEquals("78;uint", mapper.toString(78)); - // assertEquals((long) -78, mapper.fromString("-78;long")); - // assertEquals("78;ulong", mapper.toString(78)); - // assertEquals((float) 78.5, mapper.fromString("78.5;float")); - assertEquals(78.5, mapper.fromString("78.5")); - //assertEquals("78;decimal", mapper.toString(78)); - assertEquals(true, mapper.fromString("true")); - assertEquals(false, mapper.fromString("false")); - // assertEquals(new UUID(0x123456789abcdef0L, 0x9abcdef012345678L), - // mapper.fromString("12345678-9abc-def0-9abc-def012345678;uuid")); - - assertEquals(cal.getTime().getTime(), dt.getTime(), 1000); - //assertEquals("78;date-seconds", mapper.toString(78)); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java deleted file mode 100644 index 9e58ad475a5ae..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import static org.junit.Assert.*; - -import java.net.URI; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; -import com.sun.jersey.api.client.Client; - -public class WrapRestProxyIntegrationTest { - @Test - public void serviceCanBeCalledToCreateAccessToken() throws Exception { - // Arrange - Configuration config = Configuration.getInstance(); - WrapContract contract = new WrapRestProxy(config.create(Client.class)); - - // Act - String serviceBusUri = (String) config.getProperty(ServiceBusConfiguration.URI); - String uri = (String) config.getProperty(ServiceBusConfiguration.WRAP_URI); - String name = (String) config.getProperty(ServiceBusConfiguration.WRAP_NAME); - String password = (String) config.getProperty(ServiceBusConfiguration.WRAP_PASSWORD); - String scope = new URI("http", new URI(serviceBusUri).getAuthority(), new URI(serviceBusUri).getPath(), null, - null).toString(); - WrapAccessTokenResult result = contract.wrapAccessToken(uri, name, password, scope); - - // Assert - assertNotNull(result); - assertNotNull(result.getAccessToken()); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java deleted file mode 100644 index 40b13af6992a0..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import java.net.URI; - -import junit.framework.Assert; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; - -public class WrapTokenManagerIntegrationTest { - @Test - public void wrapClientWillAcquireAccessToken() throws Exception { - // Arrange - Configuration config = Configuration.getInstance(); - WrapTokenManager client = config.create("serviceBus", WrapTokenManager.class); - - // Act - URI serviceBusURI = new URI((String) config.getProperty(ServiceBusConfiguration.URI)); - String accessToken = client.getAccessToken(serviceBusURI); - - // Assert - Assert.assertNotNull(accessToken); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java deleted file mode 100644 index 58536f5a41a76..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.serviceBus.implementation; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.utils.DateFactory; - -public class WrapTokenManagerTest { - private WrapContract contract; - private WrapTokenManager client; - private DateFactory dateFactory; - private Calendar calendar; - - @Before - public void init() { - calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - - dateFactory = mock(DateFactory.class); - contract = mock(WrapContract.class); - client = new WrapTokenManager(contract, dateFactory, "testurl", "testname", "testpassword"); - - when(dateFactory.getDate()).thenAnswer(new Answer() { - @Override - public Date answer(InvocationOnMock invocation) throws Throwable { - return calendar.getTime(); - } - }); - } - - private void doIncrementingTokens() throws ServiceException { - doAnswer(new Answer() { - int count = 0; - - @Override - public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { - ++count; - WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); - wrapResponse.setAccessToken("testaccesstoken1-" + count); - wrapResponse.setExpiresIn(83); - return wrapResponse; - } - }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); - - doAnswer(new Answer() { - int count = 0; - - @Override - public WrapAccessTokenResult answer(InvocationOnMock invocation) throws Throwable { - ++count; - WrapAccessTokenResult wrapResponse = new WrapAccessTokenResult(); - wrapResponse.setAccessToken("testaccesstoken2-" + count); - wrapResponse.setExpiresIn(83); - return wrapResponse; - } - }).when(contract).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope2"); - } - - @Test - public void clientUsesContractToGetToken() throws ServiceException, URISyntaxException { - // Arrange - doIncrementingTokens(); - - // Act - String accessToken = client.getAccessToken(new URI("https://test/scope")); - - // Assert - assertNotNull(accessToken); - assertEquals("testaccesstoken1-1", accessToken); - } - - @Test - public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException, URISyntaxException { - // Arrange - doIncrementingTokens(); - - // Act - String accessToken1 = client.getAccessToken(new URI("https://test/scope?arg=1")); - String accessToken2 = client.getAccessToken(new URI("https://test/scope?arg=2")); - calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken(new URI("https://test/scope?arg=3")); - - // Assert - assertEquals("testaccesstoken1-1", accessToken1); - assertEquals("testaccesstoken1-1", accessToken2); - assertEquals("testaccesstoken1-1", accessToken3); - - verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); - } - - @Test - public void callsToDifferentPathsWillResultInDifferentAccessTokens() throws ServiceException, URISyntaxException { - // Arrange - doIncrementingTokens(); - - // Act - String accessToken1 = client.getAccessToken(new URI("https://test/scope?arg=1")); - String accessToken2 = client.getAccessToken(new URI("https://test/scope2?arg=2")); - calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken(new URI("https://test/scope?arg=3")); - - // Assert - assertEquals("testaccesstoken1-1", accessToken1); - assertEquals("testaccesstoken2-1", accessToken2); - assertEquals("testaccesstoken1-1", accessToken3); - - verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); - verify(contract, times(1)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope2"); - } - - @Test - public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException, URISyntaxException { - // Arrange - doIncrementingTokens(); - - // Act - String accessToken1 = client.getAccessToken(new URI("https://test/scope")); - String accessToken2 = client.getAccessToken(new URI("https://test/scope")); - calendar.add(Calendar.SECOND, 45); - String accessToken3 = client.getAccessToken(new URI("https://test/scope")); - - // Assert - assertEquals("testaccesstoken1-1", accessToken1); - assertEquals("testaccesstoken1-1", accessToken2); - assertEquals("testaccesstoken1-2", accessToken3); - - verify(contract, times(2)).wrapAccessToken("testurl", "testname", "testpassword", "http://test/scope"); - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java deleted file mode 100644 index 3cc8639eb849c..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.utils; - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; - -public class ServiceExceptionFactoryTest { - @Test - public void serviceNameAndMessageAndCauseAppearInException() { - // Arrange - ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); - - // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); - - // Assert - assertNotNull(exception); - assertEquals("testing", exception.getServiceName()); - assertEquals("this is a test", exception.getMessage()); - assertEquals(cause, exception.getCause()); - } - - @Test - public void httpStatusCodeAndReasonPhraseAppearInException() { - // Arrange - ClientResponse response = new ClientResponse(404, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException cause = new UniformInterfaceException( - response); - - // Act - ServiceException exception = ServiceExceptionFactory.process("testing", new ServiceException("this is a test", cause)); - - // Assert - assertNotNull(exception); - assertEquals(404, exception.getHttpStatusCode()); - assertEquals("Not Found", exception.getHttpReasonPhrase()); - } - - @Test - public void informationWillPassUpIfServiceExceptionIsRootCauseOfClientHandlerExceptions() { - // Arrange - ClientResponse response = new ClientResponse(503, null, new ByteArrayInputStream(new byte[0]), null); - UniformInterfaceException rootCause = new UniformInterfaceException(response); - ServiceException originalDescription = ServiceExceptionFactory.process("underlying", new ServiceException(rootCause)); - ClientHandlerException wrappingException = new ClientHandlerException(originalDescription); - - // Act - ServiceException exception = ServiceExceptionFactory.process("actual", new ServiceException(wrappingException)); - - // Assert - assertEquals(503, exception.getHttpStatusCode()); - assertEquals("underlying", exception.getServiceName()); - } - -} diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties deleted file mode 100644 index e7bf06b034de2..0000000000000 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ /dev/null @@ -1,10 +0,0 @@ -serviceBus.uri=https://%SERVICEBUS_NAMESPACE%.servicebus.windows.net/ -serviceBus.wrap.uri=https://%SERVICEBUS_NAMESPACE%-sb.accesscontrol.windows.net/WRAPv0.9 -serviceBus.wrap.name=%SERVICEBUS_SERVICEIDENTITY% -serviceBus.wrap.password=%SERVICEBUS_SHAREDSECRET% -blob.accountName=%BLOB_ACCOUNTNAME% -blob.accountKey=%BLOB_ACCOUNTKEY% -blob.uri=http://%BLOB_ACCOUNTNAME%.blob.core.windows.net -queue.accountName=%QUEUE_ACCOUNTNAME% -queue.accountKey=%QUEUE_ACCOUNTKEY% -queue.uri=http://%QUEUE_ACCOUNTNAME%.queue.core.windows.net \ No newline at end of file diff --git a/microsoft-azure-api/src/test/resources/NewFile.xml b/microsoft-azure-api/src/test/resources/NewFile.xml deleted file mode 100644 index 71989d321de16..0000000000000 --- a/microsoft-azure-api/src/test/resources/NewFile.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - From abf44603258866edf64fcf2e6859b15fd9bc7100 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 10 Aug 2012 15:03:12 -0700 Subject: [PATCH 307/664] First cut at redirect filter & tests --- .../media/implementation/RedirectFilter.java | 43 ++++++++++ .../ResourceLocationManager.java | 41 +++++++++ .../implementation/RedirectionFilterTest.java | 83 +++++++++++++++++++ .../ResourceLocationManagerTest.java | 46 ++++++++++ 4 files changed, 213 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java new file mode 100644 index 0000000000000..05ef645a73105 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -0,0 +1,43 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import java.net.URI; +import java.net.URISyntaxException; + +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; + +public class RedirectFilter extends ClientFilter { + private final ResourceLocationManager locationManager; + + public RedirectFilter(ResourceLocationManager locationManager) { + this.locationManager = locationManager; + } + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + URI originalURI = request.getURI(); + request.setURI(locationManager.getRedirectedURI(originalURI)); + + ClientResponse response = getNext().handle(request); + if (response.getStatus() == 301) { + String newLocation = response.getHeaders().getFirst("Location"); + if (newLocation == null) { + throw new ClientHandlerException("HTTP Redirect did not include location header"); + } + try { + locationManager.setRedirectedURI(newLocation); + } + catch (URISyntaxException ex) { + throw new ClientHandlerException("HTTP Redirect location is not a valid URI"); + } + + request.setURI(locationManager.getRedirectedURI(originalURI)); + return getNext().handle(request); + } + else { + return response; + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java new file mode 100644 index 0000000000000..dcf4bcf25de11 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -0,0 +1,41 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.net.URI; +import java.net.URISyntaxException; + +import javax.ws.rs.core.UriBuilder; + +public class ResourceLocationManager { + private URI baseURI; + + public ResourceLocationManager(String baseUri) throws URISyntaxException { + this.baseURI = new URI(baseUri); + } + + public URI getBaseURI() { + return baseURI; + } + + public URI getRedirectedURI(URI originalURI) { + return UriBuilder.fromUri(baseURI).path(originalURI.getPath()).build(); + } + + public void setRedirectedURI(String newURI) throws URISyntaxException, NullPointerException { + baseURI = new URI(newURI); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java new file mode 100644 index 0000000000000..9d31c059d7d6e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java @@ -0,0 +1,83 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.net.URI; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; +import org.mockito.Mockito; + +import com.sun.jersey.api.client.Client; +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; +import com.sun.jersey.core.header.InBoundHeaders; + +public class RedirectionFilterTest { + private final String originalBaseURI = "https://base.somewhere.example/API/"; + private final String redirectedBaseURI = "http://redirected.somewhere.example/Stuff/"; + + private class RequestRecordingFilter extends ClientFilter { + public ClientRequest request; + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + this.request = request; + + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getStatus()).thenReturn(200); + return response; + } + + } + + @Test + public void whenInvokedAndNotRedirected_shouldAddBaseURIToRequest() throws Exception { + RequestRecordingFilter sink = new RequestRecordingFilter(); + Client c = Client.create(); + c.addFilter(sink); + c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); + + c.resource("Files").get(ClientResponse.class); + new URI(null); + + assertEquals(originalBaseURI + "Files", sink.request.getURI().toString()); + } + + @Test + public void whenInvokedAndRedirected_shouldHaveRedirectedURIInRequest() throws Exception { + RequestRecordingFilter sink = new RequestRecordingFilter(); + + // Filter to fake the server redirecting the request. + ClientFilter redirector = new ClientFilter() { + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + + if (request.getURI().toString().startsWith(originalBaseURI)) { + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getStatus()).thenReturn(301); + MultivaluedMap headers = new InBoundHeaders(); + headers.add("location", redirectedBaseURI); + Mockito.when(response.getHeaders()).thenReturn(headers); + return response; + } + else { + return getNext().handle(request); + } + } + }; + + Client c = Client.create(); + c.addFilter(sink); + c.addFilter(redirector); + + c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); + + ClientResponse response = c.resource("Things").get(ClientResponse.class); + assertEquals(200, response.getStatus()); + assertEquals(redirectedBaseURI + "Things", sink.request.getURI().toString()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java new file mode 100644 index 0000000000000..ed9715a8a10fa --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java @@ -0,0 +1,46 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.net.URI; + +import org.junit.Test; + +public class ResourceLocationManagerTest { + + @Test + public void testCanCreateWithBaseUri() throws Exception { + String baseUri = "https://base.uri.example"; + ResourceLocationManager m = new ResourceLocationManager(baseUri); + + assertEquals(baseUri, m.getBaseURI().toString()); + } + + @Test + public void testWhenCallingGetRedirectedURI_shouldReturnURIWithBaseURIPreprended() throws Exception { + String baseURI = "http://base.uri.example/path/"; + ResourceLocationManager m = new ResourceLocationManager(baseURI); + + URI originalURI = new URI("Assets"); + + URI redirectedURI = m.getRedirectedURI(originalURI); + + assertEquals(baseURI + "Assets", redirectedURI.toString()); + } + + @Test + public void settingBaseURIAfterRedirecting_shouldReturnURIWithNewBaseURI() throws Exception { + String baseURI = "http://base.uri.example/path/"; + String redirectedBaseURI = "http://other.uri.example/API/"; + ResourceLocationManager m = new ResourceLocationManager(baseURI); + + URI targetURI = new URI("Assets"); + + URI originalURI = m.getRedirectedURI(targetURI); + m.setRedirectedURI(redirectedBaseURI); + URI redirectedURI = m.getRedirectedURI(targetURI); + + assertEquals(baseURI + "Assets", originalURI.toString()); + assertEquals(redirectedBaseURI + "Assets", redirectedURI.toString()); + } +} From 09cc8a881fe722efd9f9c79e584d70505b9cf2f1 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 10 Aug 2012 15:47:13 -0700 Subject: [PATCH 308/664] Completed test suite, now follow multiple redirects, do header error checking. --- .../media/implementation/RedirectFilter.java | 17 +-- .../implementation/RedirectionFilterTest.java | 136 +++++++++++++----- 2 files changed, 105 insertions(+), 48 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 05ef645a73105..cbda4b78fcdf3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -21,23 +21,20 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio request.setURI(locationManager.getRedirectedURI(originalURI)); ClientResponse response = getNext().handle(request); - if (response.getStatus() == 301) { - String newLocation = response.getHeaders().getFirst("Location"); - if (newLocation == null) { - throw new ClientHandlerException("HTTP Redirect did not include location header"); - } + while (response.getStatus() == 301) { try { - locationManager.setRedirectedURI(newLocation); + locationManager.setRedirectedURI(response.getHeaders().getFirst("Location")); + } + catch (NullPointerException ex) { + throw new ClientHandlerException("HTTP Redirect did not include Location header"); } catch (URISyntaxException ex) { throw new ClientHandlerException("HTTP Redirect location is not a valid URI"); } request.setURI(locationManager.getRedirectedURI(originalURI)); - return getNext().handle(request); - } - else { - return response; + response = getNext().handle(request); } + return response; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java index 9d31c059d7d6e..0374beb062c2b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java @@ -2,11 +2,11 @@ import static org.junit.Assert.*; -import java.net.URI; - import javax.ws.rs.core.MultivaluedMap; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.mockito.Mockito; import com.sun.jersey.api.client.Client; @@ -17,23 +17,12 @@ import com.sun.jersey.core.header.InBoundHeaders; public class RedirectionFilterTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + private final String originalBaseURI = "https://base.somewhere.example/API/"; private final String redirectedBaseURI = "http://redirected.somewhere.example/Stuff/"; - private class RequestRecordingFilter extends ClientFilter { - public ClientRequest request; - - @Override - public ClientResponse handle(ClientRequest request) throws ClientHandlerException { - this.request = request; - - ClientResponse response = Mockito.mock(ClientResponse.class); - Mockito.when(response.getStatus()).thenReturn(200); - return response; - } - - } - @Test public void whenInvokedAndNotRedirected_shouldAddBaseURIToRequest() throws Exception { RequestRecordingFilter sink = new RequestRecordingFilter(); @@ -42,7 +31,6 @@ public void whenInvokedAndNotRedirected_shouldAddBaseURIToRequest() throws Excep c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); c.resource("Files").get(ClientResponse.class); - new URI(null); assertEquals(originalBaseURI + "Files", sink.request.getURI().toString()); } @@ -50,29 +38,9 @@ public void whenInvokedAndNotRedirected_shouldAddBaseURIToRequest() throws Excep @Test public void whenInvokedAndRedirected_shouldHaveRedirectedURIInRequest() throws Exception { RequestRecordingFilter sink = new RequestRecordingFilter(); - - // Filter to fake the server redirecting the request. - ClientFilter redirector = new ClientFilter() { - @Override - public ClientResponse handle(ClientRequest request) throws ClientHandlerException { - - if (request.getURI().toString().startsWith(originalBaseURI)) { - ClientResponse response = Mockito.mock(ClientResponse.class); - Mockito.when(response.getStatus()).thenReturn(301); - MultivaluedMap headers = new InBoundHeaders(); - headers.add("location", redirectedBaseURI); - Mockito.when(response.getHeaders()).thenReturn(headers); - return response; - } - else { - return getNext().handle(request); - } - } - }; - Client c = Client.create(); c.addFilter(sink); - c.addFilter(redirector); + c.addFilter(new RedirectingTestFilter(originalBaseURI, redirectedBaseURI)); c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); @@ -80,4 +48,96 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio assertEquals(200, response.getStatus()); assertEquals(redirectedBaseURI + "Things", sink.request.getURI().toString()); } + + @Test + public void whenRedirectedMultipleTimes_requestEndsUpAtFinalRediret() throws Exception { + RequestRecordingFilter sink = new RequestRecordingFilter(); + Client c = Client.create(); + c.addFilter(sink); + c.addFilter(new RedirectingTestFilter("https://a.example/API/", "https://b.example/API/")); + c.addFilter(new RedirectingTestFilter("https://b.example/API/", "https://c.example/API/")); + c.addFilter(new RedirectingTestFilter("https://c.example/API/", "https://final.example/Code/")); + + c.addFilter(new RedirectFilter(new ResourceLocationManager("https://a.example/API/"))); + + ClientResponse response = c.resource("Stuff").get(ClientResponse.class); + + assertEquals(200, response.getStatus()); + + assertEquals("https://final.example/Code/Stuff", sink.request.getURI().toString()); + } + + @Test + public void whenRedirectingToNull_shouldGetClientException() throws Exception { + RequestRecordingFilter sink = new RequestRecordingFilter(); + Client c = Client.create(); + c.addFilter(sink); + c.addFilter(new RedirectingTestFilter(originalBaseURI, null)); + c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); + + thrown.expect(ClientHandlerException.class); + c.resource("Something").get(ClientResponse.class); + } + + @Test + public void whenRedirectingToBadURI_shouldGetClientException() throws Exception { + RequestRecordingFilter sink = new RequestRecordingFilter(); + Client c = Client.create(); + c.addFilter(sink); + c.addFilter(new RedirectingTestFilter(originalBaseURI, "no way this is valid!")); + c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); + + thrown.expect(ClientHandlerException.class); + c.resource("Something").get(ClientResponse.class); + } + + // Test support classes + + // + // Filter that acts as a "sink" so the request doesn't go out over + // the wire. Also holds onto the request object that went through + // the pipeline so that it can be asserted against in the test. + // + private class RequestRecordingFilter extends ClientFilter { + public ClientRequest request; + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + this.request = request; + + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getStatus()).thenReturn(200); + return response; + } + } + + // + // Filter that will 301-redirect requests depending on which URI + // the request goes to. + // + + private class RedirectingTestFilter extends ClientFilter { + private final String uriToRedirect; + private final String uriRedirectedTo; + + public RedirectingTestFilter(String uriToRedirect, String uriRedirectedTo) { + this.uriToRedirect = uriToRedirect; + this.uriRedirectedTo = uriRedirectedTo; + } + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + if (request.getURI().toString().startsWith(uriToRedirect)) { + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getStatus()).thenReturn(301); + MultivaluedMap headers = new InBoundHeaders(); + headers.add("location", uriRedirectedTo); + Mockito.when(response.getHeaders()).thenReturn(headers); + return response; + } + else { + return getNext().handle(request); + } + } + } } From 2a24adc70cb5e2af77f738706a77469c789f3345 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 10 Aug 2012 16:42:46 -0700 Subject: [PATCH 309/664] Massaging to meet coding conventions --- .../services/media/implementation/RedirectFilter.java | 4 ++-- .../media/implementation/ResourceLocationManager.java | 2 +- .../services/media/implementation/RedirectionFilterTest.java | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index cbda4b78fcdf3..fe0408070c0c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -25,10 +25,10 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio try { locationManager.setRedirectedURI(response.getHeaders().getFirst("Location")); } - catch (NullPointerException ex) { + catch (NullPointerException e) { throw new ClientHandlerException("HTTP Redirect did not include Location header"); } - catch (URISyntaxException ex) { + catch (URISyntaxException e) { throw new ClientHandlerException("HTTP Redirect location is not a valid URI"); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index dcf4bcf25de11..773b6c27847d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -35,7 +35,7 @@ public URI getRedirectedURI(URI originalURI) { return UriBuilder.fromUri(baseURI).path(originalURI.getPath()).build(); } - public void setRedirectedURI(String newURI) throws URISyntaxException, NullPointerException { + public void setRedirectedURI(String newURI) throws URISyntaxException { baseURI = new URI(newURI); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java index 0374beb062c2b..ce375aeae8bb2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java @@ -45,6 +45,7 @@ public void whenInvokedAndRedirected_shouldHaveRedirectedURIInRequest() throws E c.addFilter(new RedirectFilter(new ResourceLocationManager(originalBaseURI))); ClientResponse response = c.resource("Things").get(ClientResponse.class); + assertEquals(200, response.getStatus()); assertEquals(redirectedBaseURI + "Things", sink.request.getURI().toString()); } @@ -127,6 +128,7 @@ public RedirectingTestFilter(String uriToRedirect, String uriRedirectedTo) { @Override public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + if (request.getURI().toString().startsWith(uriToRedirect)) { ClientResponse response = Mockito.mock(ClientResponse.class); Mockito.when(response.getStatus()).thenReturn(301); From 538cf03bce6e8e182476232f3c05ffc888402d95 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 10 Aug 2012 17:42:30 -0700 Subject: [PATCH 310/664] Responding to code review. --- .../media/implementation/RedirectFilter.java | 21 ++++++++++++++++++- .../implementation/RedirectionFilterTest.java | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index fe0408070c0c2..15b283e78f922 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -1,3 +1,18 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import java.net.URI; @@ -17,11 +32,15 @@ public RedirectFilter(ResourceLocationManager locationManager) { @Override public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + if (request == null) { + throw new IllegalArgumentException("Request should not be null"); + } + URI originalURI = request.getURI(); request.setURI(locationManager.getRedirectedURI(originalURI)); ClientResponse response = getNext().handle(request); - while (response.getStatus() == 301) { + while (response.getClientResponseStatus() == ClientResponse.Status.MOVED_PERMANENTLY) { try { locationManager.setRedirectedURI(response.getHeaders().getFirst("Location")); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java index ce375aeae8bb2..d1c8fccf600da 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java @@ -131,7 +131,7 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio if (request.getURI().toString().startsWith(uriToRedirect)) { ClientResponse response = Mockito.mock(ClientResponse.class); - Mockito.when(response.getStatus()).thenReturn(301); + Mockito.when(response.getClientResponseStatus()).thenReturn(ClientResponse.Status.MOVED_PERMANENTLY); MultivaluedMap headers = new InBoundHeaders(); headers.add("location", uriRedirectedTo); Mockito.when(response.getHeaders()).thenReturn(headers); From 4ea62a251fdd6a641a86ef5629446b43941db452 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 13 Aug 2012 23:10:03 -0700 Subject: [PATCH 311/664] Implementation of Authentication for Media Service. --- .../services/media/ActiveToken.java | 67 +++++++ .../windowsazure/services/media/Exports.java | 31 ++++ .../services/media/MediaConfiguration.java | 155 ++++++++++++++++ .../services/media/OAuthContract.java | 44 +++++ .../services/media/OAuthFilter.java | 63 +++++++ .../services/media/OAuthRestProxy.java | 116 ++++++++++++ .../services/media/OAuthTokenManager.java | 110 +++++++++++ .../services/media/OAuthTokenResponse.java | 71 ++++++++ .../media/OAuthRestProxyIntegrationTest.java | 55 ++++++ .../services/media/OAuthTokenManagerTest.java | 171 ++++++++++++++++++ 10 files changed, 883 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java new file mode 100644 index 0000000000000..73e1564be1f27 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java @@ -0,0 +1,67 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.util.Date; + +/** + * A class representing active token for OAuthTokenResponse. + * + * @author azurejava@microsoft.com + * + */ +public class ActiveToken { + + private Date expiresUtc; + private OAuthTokenResponse oAuthTokenResponse; + + /** + * Gets the expiration time in UTC. + * + * @return The token expiration time in UTC. + */ + public Date getExpiresUtc() { + return expiresUtc; + } + + /** + * Sets the token expiration time in UTC. + * + * @param expiresUtc + */ + public void setExpiresUtc(Date expiresUtc) { + this.expiresUtc = expiresUtc; + } + + /** + * Gets the OAuth token response. + * + * @return The OAuth token response. + */ + public OAuthTokenResponse getOAuthTokenResponse() { + return oAuthTokenResponse; + } + + /** + * Sets the OAuth token response. + * + * @param oAuth2TokenResponse + */ + public void setOAuth2TokenResponse(OAuthTokenResponse oAuth2TokenResponse) { + this.oAuthTokenResponse = oAuth2TokenResponse; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java new file mode 100644 index 0000000000000..2a9cd99c4b38c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -0,0 +1,31 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import com.microsoft.windowsazure.services.core.Builder; + +public class Exports implements Builder.Exports { + + /** + * register the OAUTH service. + */ + @Override + public void register(Builder.Registry registry) { + registry.add(OAuthContract.class, OAuthRestProxy.class); + registry.add(OAuthTokenManager.class); + registry.add(OAuthFilter.class); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java new file mode 100644 index 0000000000000..0c4c703fb1dd7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -0,0 +1,155 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import com.microsoft.windowsazure.services.core.Configuration; + +/** + * Provides functionality to create a service bus configuration. + * + */ +public class MediaConfiguration { + + /** + * Defines the media service configuration URI constant. + * + */ + public static final String URI = "media.uri"; + + /** + * Defines the OAUTH configuration URI constant. + * + */ + public static final String OAUTH_URI = "oauth.uri"; + + /** + * Defines the OAUTH configuration client ID constant. + * + */ + public static final String OAUTH_CLIENT_ID = "oauth.client.id"; + + /** + * Defines the OAUTH configuration client secret constant. + * + */ + public static final String OAUTH_CLIENT_SECRET = "oauth.client.secret"; + + /** + * Defines the SCOPE of the media service sent to OAUTH. + */ + public static final String OAUTH_SCOPE = "oauth.scope"; + + /** + * Creates a media service configuration using the specified media service base URI, OAUTH URI, + * client ID, and client secret. + * + * @param mediaServiceBaseUri + * A String object that represents the media service base URI. + * + * @param oAuthUri + * A String object that represents the OAUTH URI. + * + * @param clientId + * A String object that represents the client ID. + * + * @param clientSecret + * A String object that represents the client secret. + * + * @return + * A Configuration object that can be used when creating an instance of the + * MediaService class. + * + */ + public static Configuration configureWithOAuthAuthentication(String mediaServiceBaseUri, String oAuthUri, + String clientId, String clientSecret) { + return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceBaseUri, oAuthUri, + clientId, clientSecret); + } + + /** + * Creates a media service configuration using the specified configuration, media service base URI, OAuth URI, + * client ID, and client secret. + * + * @param configuration + * A previously instantiated Configuration object. + * + * @param mediaServiceBaseUri + * A String object that represents the base URI of Media service. + * + * @param oAuthUri + * A String object that represents the URI of OAuth service. + * + * @param clientId + * A String object that represents the client ID. + * + * @param clientSecret + * A String object that represents the client secret. + * + * @return + * A Configuration object that can be used when creating an instance of the + * MediaService class. + * + */ + public static Configuration configureWithOAuthAuthentication(Configuration configuration, + String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret) { + return configureWithOAuthAuthentication(null, configuration, mediaServiceBaseUri, oAuthUri, clientId, + clientSecret); + } + + /** + * Creates a media service configuration using the specified profile, configuration, media service base URI, + * OAuth URI, client ID, and client secret. + * + * @param profile + * A String object that represents the profile. + * + * @param configuration + * A previously instantiated Configuration object. + * + * @param mediaServiceBaseUri + * A String object that represents the base URI of media service. + * + * @param oAuthUri + * A String object that represents the URI of OAUTH service. + * + * @param clientId + * A String object that represents the client ID. + * + * @param clientSecret + * A String object that represents the client secret. + * + * @return + * A Configuration object that can be used when creating an instance of the + * MediaService class. + * + */ + public static Configuration configureWithOAuthAuthentication(String profile, Configuration configuration, + String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret) { + + if (profile == null) { + profile = ""; + } + else if (profile.length() != 0 && !profile.endsWith(".")) { + profile = profile + "."; + } + + configuration.setProperty(profile + URI, "https://" + mediaServiceBaseUri); + configuration.setProperty(profile + OAUTH_URI, oAuthUri); + configuration.setProperty(profile + OAUTH_CLIENT_ID, clientId); + configuration.setProperty(profile + OAUTH_CLIENT_SECRET, clientSecret); + + return configuration; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java new file mode 100644 index 0000000000000..b74216823c308 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java @@ -0,0 +1,44 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.net.URI; + +import com.microsoft.windowsazure.services.core.ServiceException; + +public interface OAuthContract { + /** + * Gets an OAuth access token with specified OAUTH URI, client ID, client secret, and scope. + * + * @param oAuthUri + * A URI object which represents an OAUTH URI. + * + * @param clientId + * A String object which represents a client ID. + * + * @param clientSecret + * A String object which represents a client secret. + * + * @param scope + * A String object which represents the scope. + * + * @return OAuthTokenResponse + * @throws ServiceException + */ + public OAuthTokenResponse getAccessToken(URI oAuthUri, String clientId, String clientSecret, String scope) + throws ServiceException; + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java new file mode 100644 index 0000000000000..c38d53dc166c7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java @@ -0,0 +1,63 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import java.net.URISyntaxException; + +import com.microsoft.windowsazure.services.core.ServiceException; +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; + +public class OAuthFilter extends ClientFilter { + private final OAuthTokenManager oAuthTokenManager; + + /** + * Creates an OAuthFilter object with specfied OAuthTokenManager instance. + * + * @param oAuthTokenManager + */ + public OAuthFilter(OAuthTokenManager oAuthTokenManager) { + this.oAuthTokenManager = oAuthTokenManager; + } + + /** + * Handles response with a specified client request. + * + * @param clientRequest + * A ClientRequest object representing a client request. + */ + @Override + public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { + + String accessToken; + try { + accessToken = oAuthTokenManager.getAccessToken(clientRequest.getURI().toString()); + } + catch (ServiceException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + catch (URISyntaxException e) { + // must wrap exception because of base class signature + throw new ClientHandlerException(e); + } + + clientRequest.getHeaders().add("Authorization", "Bearer " + accessToken); + + return this.getNext().handle(clientRequest); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java new file mode 100644 index 0000000000000..cedae2640ffb7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java @@ -0,0 +1,116 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import java.io.IOException; +import java.net.URI; + +import javax.inject.Inject; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; +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.representation.Form; + +public class OAuthRestProxy implements OAuthContract { + Client channel; + + private final String _grantType = "client_credentials"; + + static Log log = LogFactory.getLog(OAuthContract.class); + + @Inject + public OAuthRestProxy(Client channel) { + this.channel = channel; + } + + /** + * Gets an OAuth access token with specified OAUTH URI, client ID, client secret, and scope. + * + * @param oAuthUri + * A URI object which represents an OAUTH URI. + * + * @param clientId + * A String object which represents a client ID. + * + * @param clientSecret + * A String object which represents a client secret. + * + * @param scope + * A String object which represents the scope. + * + * @return OAuthTokenResponse + * @throws ServiceException + */ + @Override + public OAuthTokenResponse getAccessToken(URI oAuthUri, String clientId, String clientSecret, String scope) + throws ServiceException { + OAuthTokenResponse response = null; + Form requestForm = new Form(); + ClientResponse clientResponse; + String responseJson; + + requestForm.add("grant_type", _grantType); + requestForm.add("client_id", clientId); + requestForm.add("client_secret", clientSecret); + requestForm.add("scope", scope); + + try { + clientResponse = channel.resource(oAuthUri).accept(MediaType.APPLICATION_FORM_URLENCODED) + .type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, requestForm); + } + catch (UniformInterfaceException e) { + log.warn("OAuth server returned error acquiring access_token", e); + throw ServiceExceptionFactory.process("OAuth", new ServiceException( + "OAuth server returned error acquiring access_token", e)); + } + + responseJson = clientResponse.getEntity(String.class); + + try { + ObjectMapper mapper = new ObjectMapper(); + TypeReference typeReference = new TypeReference() { + }; + response = mapper.readValue(responseJson, typeReference); + } + catch (JsonParseException e) { + log.warn("The response from OAuth server cannot be parsed correctly", e); + throw ServiceExceptionFactory.process("OAuth", new ServiceException( + "The response from OAuth server cannot be parsed correctly", e)); + } + catch (JsonMappingException e) { + log.warn("The response from OAuth server cannot be mapped to OAuthResponse object", e); + throw ServiceExceptionFactory.process("OAuth", new ServiceException( + "The response from OAuth server cannot be mapped to OAuthResponse object", e)); + } + catch (IOException e) { + log.warn("Cannot map the response from OAuth server correctly.", e); + throw ServiceExceptionFactory.process("OAuth", new ServiceException( + "Cannot map the response from OAuth server correctly.", e)); + } + + return response; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java new file mode 100644 index 0000000000000..111aba7e33d20 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java @@ -0,0 +1,110 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Date; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; + +import javax.management.timer.Timer; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.utils.DateFactory; + +public class OAuthTokenManager { + private final DateFactory dateFactory; + private final URI acsBaseUri; + private final String clientId; + private final String clientSecret; + private final OAuthContract contract; + private final ConcurrentHashMap activeTokens; + + /** + * Creates an OAuth token manager instance with specified contract, date factory, ACS base URI, client ID, + * and client secret. + * + * @param contract + * A OAuthContract object instance that represents the OAUTH contract. + * + * @param dateFactory + * A DateFactory object instance that represents the date factory. + * + * @param acsBaseUri + * A URI object instance that represents the ACS base URI. + * + * @param clientId + * A String object instance that represents the client ID. + * + * @param clientSecret + * A String object instance that represents the client secret. + * + */ + public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, URI acsBaseUri, String clientId, + String clientSecret) { + this.contract = contract; + this.dateFactory = dateFactory; + this.acsBaseUri = acsBaseUri; + this.clientId = clientId; + this.clientSecret = clientSecret; + this.activeTokens = new ConcurrentHashMap(); + } + + /** + * Gets an OAuth access token with specified media service scope. + * + * @param mediaServiceScope + * A String instance that represents the media service scope. + * + * @return String + * + * @throws ServiceException + * @throws URISyntaxException + */ + public String getAccessToken(String mediaServiceScope) throws ServiceException, URISyntaxException { + Date now = dateFactory.getDate(); + OAuthTokenResponse oAuth2TokenResponse = null; + + ActiveToken activeToken = this.activeTokens.get(mediaServiceScope); + + if (activeToken != null && now.before(activeToken.getExpiresUtc())) { + return activeToken.getOAuthTokenResponse().getAccessToken(); + } + + // sweep expired tokens out of collection + Iterator> iterator = activeTokens.entrySet().iterator(); + while (iterator.hasNext()) { + Entry entry = iterator.next(); + if (!now.before(entry.getValue().getExpiresUtc())) { + iterator.remove(); + } + } + + oAuth2TokenResponse = contract.getAccessToken(acsBaseUri, clientId, clientSecret, mediaServiceScope); + + Date expiresUtc = new Date(now.getTime() + oAuth2TokenResponse.getExpiresIn() * Timer.ONE_SECOND / 2); + + ActiveToken acquiredToken = new ActiveToken(); + acquiredToken.setOAuth2TokenResponse(oAuth2TokenResponse); + acquiredToken.setExpiresUtc(expiresUtc); + this.activeTokens.put(mediaServiceScope, acquiredToken); + + return oAuth2TokenResponse.getAccessToken(); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java new file mode 100644 index 0000000000000..7c696ea979980 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java @@ -0,0 +1,71 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import org.codehaus.jackson.annotate.JsonProperty; + +public class OAuthTokenResponse { + + private String _accessToken; + private String _scope; + private String _tokenType; + private long _expiresIn; + + /** + * Sets the token type. + * + * @param tokenType + */ + @JsonProperty("token_type") + public void setTokenType(String tokenType) { + _tokenType = tokenType; + } + + @JsonProperty("token_type") + public String getTokenType() { + return _tokenType; + } + + @JsonProperty("expires_in") + public long getExpiresIn() { + return _expiresIn; + } + + @JsonProperty("expires_in") + public void setExpiresIn(long expiresIn) { + _expiresIn = expiresIn; + } + + @JsonProperty("access_token") + public String getAccessToken() { + return _accessToken; + } + + @JsonProperty("access_token") + public void setAccessToken(String accessToken) { + _accessToken = accessToken; + } + + @JsonProperty("scope") + public String getScope() { + return _scope; + } + + @JsonProperty("scope") + public void setScope(String scope) { + _scope = scope; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java new file mode 100644 index 0000000000000..1b05d54794c3a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java @@ -0,0 +1,55 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.net.URI; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.Configuration; +import com.sun.jersey.api.client.Client; + +public class OAuthRestProxyIntegrationTest { + @Test + public void serviceCanBeCalledToCreateAccessToken() throws Exception { + // Arrange + Configuration config = Configuration.getInstance(); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + OAuthContract oAuthContract = new OAuthRestProxy(config.create(Client.class)); + + // Act + URI oAuthUri = new URI((String) config.getProperty(MediaConfiguration.OAUTH_URI)); + String clientId = (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_ID); + String clientSecret = (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET); + String scope = "urn:WindowsAzureMediaServices"; + OAuthTokenResponse result = oAuthContract.getAccessToken(oAuthUri, clientId, clientSecret, scope); + + // Assert + assertNotNull(result); + assertNotNull(result.getAccessToken()); + } + + private static void overrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java new file mode 100644 index 0000000000000..b5802a683c974 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java @@ -0,0 +1,171 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.utils.DateFactory; + +public class OAuthTokenManagerTest { + private OAuthContract contract; + private OAuthTokenManager client; + private DateFactory dateFactory; + private Calendar calendar; + + @Before + public void init() throws URISyntaxException { + calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + dateFactory = mock(DateFactory.class); + + // Client channel = new Client(); + contract = mock(OAuthRestProxy.class); + + String acsBaseUri = "testurl"; + String accountName = "testname"; + String accountPassword = "testpassword"; + + client = new OAuthTokenManager(contract, dateFactory, new URI(acsBaseUri), accountName, accountPassword); + + when(dateFactory.getDate()).thenAnswer(new Answer() { + @Override + public Date answer(InvocationOnMock invocation) throws Throwable { + return calendar.getTime(); + } + }); + } + + private void doIncrementingTokens() throws ServiceException, URISyntaxException, JsonParseException, + JsonMappingException, IOException { + doAnswer(new Answer() { + int count = 0; + + @Override + public OAuthTokenResponse answer(InvocationOnMock invocation) throws Throwable { + ++count; + OAuthTokenResponse wrapResponse = new OAuthTokenResponse(); + wrapResponse.setAccessToken("testaccesstoken1-" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + + doAnswer(new Answer() { + int count = 0; + + @Override + public OAuthTokenResponse answer(InvocationOnMock invocation) throws Throwable { + ++count; + OAuthTokenResponse wrapResponse = new OAuthTokenResponse(); + wrapResponse.setAccessToken("testaccesstoken2-" + count); + wrapResponse.setExpiresIn(83); + return wrapResponse; + } + }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope2"); + } + + @Test + public void clientUsesContractToGetToken() throws ServiceException, URISyntaxException, JsonParseException, + JsonMappingException, IOException { + // Arrange + doIncrementingTokens(); + + // Act + String accessToken = client.getAccessToken("https://test/scope"); + + // Assert + assertNotNull(accessToken); + assertEquals("testaccesstoken1-1", accessToken); + } + + @Test + public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws ServiceException, URISyntaxException, + JsonParseException, JsonMappingException, IOException { + // Arrange + doIncrementingTokens(); + + // Act + String accessToken1 = client.getAccessToken("https://test/scope"); + String accessToken2 = client.getAccessToken("https://test/scope"); + calendar.add(Calendar.SECOND, 40); + String accessToken3 = client.getAccessToken("https://test/scope"); + + // Assert + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken1-1", accessToken2); + assertEquals("testaccesstoken1-1", accessToken3); + + verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + } + + @Test + public void callsToDifferentScopeWillResultInDifferentAccessTokens() throws ServiceException, URISyntaxException, + JsonParseException, JsonMappingException, IOException { + // Arrange + doIncrementingTokens(); + + // Act + String accessToken1 = client.getAccessToken("https://test/scope"); + String accessToken2 = client.getAccessToken("https://test/scope2"); + calendar.add(Calendar.SECOND, 40); + String accessToken3 = client.getAccessToken("https://test/scope"); + + // Assert + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken2-1", accessToken2); + assertEquals("testaccesstoken1-1", accessToken3); + + verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + verify(contract, times(1)) + .getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope2"); + } + + @Test + public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceException, URISyntaxException, + JsonParseException, JsonMappingException, IOException { + // Arrange + doIncrementingTokens(); + + // Act + String accessToken1 = client.getAccessToken("https://test/scope"); + String accessToken2 = client.getAccessToken("https://test/scope"); + calendar.add(Calendar.SECOND, 45); + String accessToken3 = client.getAccessToken("https://test/scope"); + + // Assert + assertEquals("testaccesstoken1-1", accessToken1); + assertEquals("testaccesstoken1-1", accessToken2); + assertEquals("testaccesstoken1-2", accessToken3); + + verify(contract, times(2)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + } + +} From 1a2a15307c1462ae7c50edd7e40a248b20e03f1d Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 14 Aug 2012 18:12:07 -0700 Subject: [PATCH 312/664] address code review feedback for Authentication of nimbus SDK. --- .../services/media/ActiveToken.java | 21 ++++--- .../services/media/OAuthFilter.java | 10 +++- .../services/media/OAuthRestProxy.java | 6 ++ .../services/media/OAuthTokenManager.java | 44 ++++++-------- .../services/media/OAuthTokenResponse.java | 6 ++ .../services/media/OAuthTokenManagerTest.java | 60 +++++-------------- 6 files changed, 64 insertions(+), 83 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java index 73e1564be1f27..2be96a410507a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java @@ -18,7 +18,7 @@ import java.util.Date; /** - * A class representing active token for OAuthTokenResponse. + * A class representing active token. * * @author azurejava@microsoft.com * @@ -26,7 +26,7 @@ public class ActiveToken { private Date expiresUtc; - private OAuthTokenResponse oAuthTokenResponse; + private String accessToken; /** * Gets the expiration time in UTC. @@ -47,21 +47,20 @@ public void setExpiresUtc(Date expiresUtc) { } /** - * Gets the OAuth token response. + * Gets access token. * - * @return The OAuth token response. + * @return String */ - public OAuthTokenResponse getOAuthTokenResponse() { - return oAuthTokenResponse; + public String getAccessToken() { + return this.accessToken; } /** - * Sets the OAuth token response. + * Sets the access token. * - * @param oAuth2TokenResponse + * @param accessToken */ - public void setOAuth2TokenResponse(OAuthTokenResponse oAuth2TokenResponse) { - this.oAuthTokenResponse = oAuth2TokenResponse; + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java index c38d53dc166c7..3fa9f48bc74ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java @@ -22,11 +22,17 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.filter.ClientFilter; +/** + * The Jersey filter for OAuth. + * + * @author azurejava@microsoft.com + * + */ public class OAuthFilter extends ClientFilter { private final OAuthTokenManager oAuthTokenManager; /** - * Creates an OAuthFilter object with specfied OAuthTokenManager instance. + * Creates an OAuthFilter object with specified OAuthTokenManager instance. * * @param oAuthTokenManager */ @@ -45,7 +51,7 @@ public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerEx String accessToken; try { - accessToken = oAuthTokenManager.getAccessToken(clientRequest.getURI().toString()); + accessToken = oAuthTokenManager.getAccessToken(); } catch (ServiceException e) { // must wrap exception because of base class signature diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java index cedae2640ffb7..9ab60ed9115ce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java @@ -34,6 +34,12 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.representation.Form; +/** + * The OAuth rest proxy. + * + * @author azurejava@microsoft.com + * + */ public class OAuthRestProxy implements OAuthContract { Client channel; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java index 111aba7e33d20..77f2b020a2cd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java @@ -18,22 +18,26 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Date; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; import javax.management.timer.Timer; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.utils.DateFactory; +/** + * An OAuth token manager class. + * + * @author azurejava@microsoft.com + * + */ public class OAuthTokenManager { private final DateFactory dateFactory; private final URI acsBaseUri; private final String clientId; private final String clientSecret; private final OAuthContract contract; - private final ConcurrentHashMap activeTokens; + private ActiveToken activeToken; + private final String scope; /** * Creates an OAuth token manager instance with specified contract, date factory, ACS base URI, client ID, @@ -56,13 +60,14 @@ public class OAuthTokenManager { * */ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, URI acsBaseUri, String clientId, - String clientSecret) { + String clientSecret, String scope) { this.contract = contract; this.dateFactory = dateFactory; this.acsBaseUri = acsBaseUri; this.clientId = clientId; this.clientSecret = clientSecret; - this.activeTokens = new ConcurrentHashMap(); + this.scope = scope; + this.activeToken = null; } /** @@ -76,33 +81,22 @@ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, URI ac * @throws ServiceException * @throws URISyntaxException */ - public String getAccessToken(String mediaServiceScope) throws ServiceException, URISyntaxException { + public String getAccessToken() throws ServiceException, URISyntaxException { Date now = dateFactory.getDate(); OAuthTokenResponse oAuth2TokenResponse = null; - ActiveToken activeToken = this.activeTokens.get(mediaServiceScope); - - if (activeToken != null && now.before(activeToken.getExpiresUtc())) { - return activeToken.getOAuthTokenResponse().getAccessToken(); + if (this.activeToken == null) { + this.activeToken = new ActiveToken(); } - - // sweep expired tokens out of collection - Iterator> iterator = activeTokens.entrySet().iterator(); - while (iterator.hasNext()) { - Entry entry = iterator.next(); - if (!now.before(entry.getValue().getExpiresUtc())) { - iterator.remove(); - } + else if (now.before(this.activeToken.getExpiresUtc())) { + return this.activeToken.getAccessToken(); } - oAuth2TokenResponse = contract.getAccessToken(acsBaseUri, clientId, clientSecret, mediaServiceScope); - + oAuth2TokenResponse = contract.getAccessToken(acsBaseUri, clientId, clientSecret, scope); Date expiresUtc = new Date(now.getTime() + oAuth2TokenResponse.getExpiresIn() * Timer.ONE_SECOND / 2); - ActiveToken acquiredToken = new ActiveToken(); - acquiredToken.setOAuth2TokenResponse(oAuth2TokenResponse); - acquiredToken.setExpiresUtc(expiresUtc); - this.activeTokens.put(mediaServiceScope, acquiredToken); + this.activeToken.setAccessToken(oAuth2TokenResponse.getAccessToken()); + this.activeToken.setExpiresUtc(expiresUtc); return oAuth2TokenResponse.getAccessToken(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java index 7c696ea979980..95a9dae61f674 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java @@ -17,6 +17,12 @@ import org.codehaus.jackson.annotate.JsonProperty; +/** + * A class representing OAuth token response. + * + * @author azurejava@microsoft.com + * + */ public class OAuthTokenResponse { private String _accessToken; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java index b5802a683c974..241d2ecc91e57 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java @@ -52,8 +52,9 @@ public void init() throws URISyntaxException { String acsBaseUri = "testurl"; String accountName = "testname"; String accountPassword = "testpassword"; + String scope = "urn:WindowsAzureMediaServices"; - client = new OAuthTokenManager(contract, dateFactory, new URI(acsBaseUri), accountName, accountPassword); + client = new OAuthTokenManager(contract, dateFactory, new URI(acsBaseUri), accountName, accountPassword, scope); when(dateFactory.getDate()).thenAnswer(new Answer() { @Override @@ -76,20 +77,9 @@ public OAuthTokenResponse answer(InvocationOnMock invocation) throws Throwable { wrapResponse.setExpiresIn(83); return wrapResponse; } - }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", + "urn:WindowsAzureMediaServices"); - doAnswer(new Answer() { - int count = 0; - - @Override - public OAuthTokenResponse answer(InvocationOnMock invocation) throws Throwable { - ++count; - OAuthTokenResponse wrapResponse = new OAuthTokenResponse(); - wrapResponse.setAccessToken("testaccesstoken2-" + count); - wrapResponse.setExpiresIn(83); - return wrapResponse; - } - }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope2"); } @Test @@ -99,7 +89,7 @@ public void clientUsesContractToGetToken() throws ServiceException, URISyntaxExc doIncrementingTokens(); // Act - String accessToken = client.getAccessToken("https://test/scope"); + String accessToken = client.getAccessToken(); // Assert assertNotNull(accessToken); @@ -113,39 +103,18 @@ public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws Servi doIncrementingTokens(); // Act - String accessToken1 = client.getAccessToken("https://test/scope"); - String accessToken2 = client.getAccessToken("https://test/scope"); + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken("https://test/scope"); + String accessToken3 = client.getAccessToken(); // Assert assertEquals("testaccesstoken1-1", accessToken1); assertEquals("testaccesstoken1-1", accessToken2); assertEquals("testaccesstoken1-1", accessToken3); - verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); - } - - @Test - public void callsToDifferentScopeWillResultInDifferentAccessTokens() throws ServiceException, URISyntaxException, - JsonParseException, JsonMappingException, IOException { - // Arrange - doIncrementingTokens(); - - // Act - String accessToken1 = client.getAccessToken("https://test/scope"); - String accessToken2 = client.getAccessToken("https://test/scope2"); - calendar.add(Calendar.SECOND, 40); - String accessToken3 = client.getAccessToken("https://test/scope"); - - // Assert - assertEquals("testaccesstoken1-1", accessToken1); - assertEquals("testaccesstoken2-1", accessToken2); - assertEquals("testaccesstoken1-1", accessToken3); - - verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); - verify(contract, times(1)) - .getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope2"); + verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", + "urn:WindowsAzureMediaServices"); } @Test @@ -155,17 +124,18 @@ public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceExcep doIncrementingTokens(); // Act - String accessToken1 = client.getAccessToken("https://test/scope"); - String accessToken2 = client.getAccessToken("https://test/scope"); + String accessToken1 = client.getAccessToken(); + String accessToken2 = client.getAccessToken(); calendar.add(Calendar.SECOND, 45); - String accessToken3 = client.getAccessToken("https://test/scope"); + String accessToken3 = client.getAccessToken(); // Assert assertEquals("testaccesstoken1-1", accessToken1); assertEquals("testaccesstoken1-1", accessToken2); assertEquals("testaccesstoken1-2", accessToken3); - verify(contract, times(2)).getAccessToken(new URI("testurl"), "testname", "testpassword", "https://test/scope"); + verify(contract, times(2)).getAccessToken(new URI("testurl"), "testname", "testpassword", + "urn:WindowsAzureMediaServices"); } } From 3341746b5859f00e2216c589a9363e7acd651c8c Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Tue, 14 Aug 2012 22:54:27 -0700 Subject: [PATCH 313/664] Starting to sketch out contract --- .../services/media/MediaServicesContract.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java new file mode 100644 index 0000000000000..9ebd7901d3504 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -0,0 +1,48 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.serviceBus; + +import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; + +/** + * + * Defines the Media contract. + * + */ +public interface MediaServicesContract extends FilterableService { + /** + * The set of operations to support. Will uncomment as they get added + * + * CreateAssetResult createAsset(String name) throws ServiceException; + * + * CreateAccessPolicyResult createAccessPolicy(String name, + * int durationInMinutes, + * AccessPolicyPermissions permissions) + * throws ServiceException; + * + * CreateLocatorResult createLocator(AssetId asset, + * AccessPolicyId accessPolicy, + * DateTime startTime, + * LocatorType type) + * throws ServiceException; + * + * Add overload that defaults locatorType to SAS, and defaults startTime to now - 5 minutes. + * + * We need to upload blobs from here - do we go through blobservice, or do we just do it + * directly? I'm leaning towards direct - blob container is encoded in locator. + * + */ +} From 00aa5b6366f4f0b00f0ea6b290763b84a7341279 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Wed, 15 Aug 2012 12:05:01 -0700 Subject: [PATCH 314/664] Working on contract --- .../services/media/MediaServicesContract.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java index 9ebd7901d3504..19f598d9a67c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -24,7 +24,7 @@ */ public interface MediaServicesContract extends FilterableService { /** - * The set of operations to support. Will uncomment as they get added + * // The set of operations to support. Will uncomment as they get added * * CreateAssetResult createAsset(String name) throws ServiceException; * @@ -39,10 +39,23 @@ public interface MediaServicesContract extends FilterableService Date: Thu, 16 Aug 2012 22:39:20 -0700 Subject: [PATCH 315/664] Building out contract, including model classes --- .../services/media/MediaServicesContract.java | 31 +++++++++-- .../services/media/models/AssetInfo.java | 45 ++++++++++++++++ .../media/models/CreateAssetResult.java | 54 +++++++++++++++++++ 3 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java index 19f598d9a67c9..992194ba908ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.serviceBus; +package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; @@ -23,11 +23,36 @@ * */ public interface MediaServicesContract extends FilterableService { + + /** + * Creates a new media service asset + * + * @param name + * A String specifying the name of the asset to create. + * + * @return A CreateAssetResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ + CreateAssetResult createAsset(String name) throws ServiceException; + + /** + * Deletes a media service asset + * + * @param asset + * A AssetInfo object specifying the asset to delete. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ + void deleteAsset(AssetInfo asset) throws ServiceException; + /** * // The set of operations to support. Will uncomment as they get added * - * CreateAssetResult createAsset(String name) throws ServiceException; - * * CreateAccessPolicyResult createAccessPolicy(String name, * int durationInMinutes, * AccessPolicyPermissions permissions) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java new file mode 100644 index 0000000000000..800f7bf14674e --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -0,0 +1,45 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * Represents an asset + */ +public class AssetInfo { + // TODO: Turn this into a serializable class, EntryModel thing + private String id; + + /** + * Create a new AssetInfo for the given Asset Id. + */ + public AssetInfo(String id) { + this.id = id; + } + + /** + * Retrieve the id + */ + public String getId() { + return id; + } + + /** + * Set the id. Do we really need this? + */ + public AssetInfo setId(String newId) { + id = newId; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java new file mode 100644 index 0000000000000..0867c5af7b10d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java @@ -0,0 +1,54 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * Represents the result of a createAsset operation. + */ +public class GetAssetResult { + private AssetInfo value; + + /** + * Creates an instance of the GetAssetResult class. + * + * @param value + * A {@link AssetInfo} object assigned as the value of the + * result. + */ + public GetAssetResult(AssetInfo value) { + this.setValue(value); + } + + /** + * Specfies the value of the result. + * + * @param value + * A {@link AssetInfo} object assigned as the value of the + * result. + */ + public AssetInfo getValue() { + return value; + } + + /** + * Returns the value of the result. + * + * @return A {@link AssetInfo} object that represents the value of the + * result. + */ + public void setValue(AssetInfo newValue) { + value = newValue; + } +} From de259da20dfaea53fd716c5eea91f9583936f243 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 17 Aug 2012 11:28:38 -0700 Subject: [PATCH 316/664] Building out access policy contract --- .gitignore | 2 + .../services/media/MediaServicesContract.java | 141 ++++++++++-------- .../media/models/AccessPolicyInfo.java | 37 +++++ .../media/models/AccessPolicyPermission.java | 12 ++ .../models/CreateAccessPolicyResult.java | 55 +++++++ .../media/models/CreateAssetResult.java | 40 ++--- 6 files changed, 201 insertions(+), 86 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java diff --git a/.gitignore b/.gitignore index 11a721777fdd7..940d90fcccc71 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .project target node_modules +.settings + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java index 992194ba908ef..35c702de42e09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -2,85 +2,94 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.media; +import java.util.EnumSet; + import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; +import com.microsoft.windowsazure.services.media.models.CreateAssetResult; /** * - * Defines the Media contract. + * Defines the Media contract. * */ public interface MediaServicesContract extends FilterableService { - /** - * Creates a new media service asset - * - * @param name - * A String specifying the name of the asset to create. - * - * @return A CreateAssetResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - CreateAssetResult createAsset(String name) throws ServiceException; + /** + * Creates a new media service asset + * + * @param name + * A String specifying the name of the asset to create. + * + * @return A CreateAssetResult object that represents the result. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ + CreateAssetResult createAsset(String name) throws ServiceException; + + /** + * Deletes a media service asset + * + * @param asset + * A AssetInfo object specifying the asset to delete. + * + * @exception ServiceException + * If a service exception is encountered. + * + */ + void deleteAsset(AssetInfo asset) throws ServiceException; - /** - * Deletes a media service asset - * - * @param asset - * A AssetInfo object specifying the asset to delete. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - void deleteAsset(AssetInfo asset) throws ServiceException; + CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, + EnumSet permissions) throws ServiceException; - /** - * // The set of operations to support. Will uncomment as they get added - * - * CreateAccessPolicyResult createAccessPolicy(String name, - * int durationInMinutes, - * AccessPolicyPermissions permissions) - * throws ServiceException; - * - * CreateLocatorResult createLocator(AssetId asset, - * AccessPolicyId accessPolicy, - * DateTime startTime, - * LocatorType type) - * throws ServiceException; - * - * // Add overload that defaults locatorType to SAS, and defaults startTime to now - 5 minutes. - * - * // We need to upload blobs from here - do we go through blobservice, or do we just do it - * // directly? I'm leaning towards direct - blob container is encoded in locator. - * - * UploadResult uploadFile(Locator locator, string content, UploadOptions options); - * UploadResult uploadFile(Locator locator, InputStream sream, UploadOptions options); - * - * // UploadOptions - do we need this? Look at blob client for what's in this. Can we reuse? - * // Probably shouldn't, in case they diverge. - * - * DeleteLocatorResult deleteLocator(Locator locator) - * throws ServiceException; - * - * CreateFileInfosResponse createFileInfos(Asset asset) - * throws ServiceException; - * - * - */ + /** + * // The set of operations to support. Will uncomment as they get added + * + * CreateAccessPolicyResult createAccessPolicy(String name, + * int durationInMinutes, + * AccessPolicyPermissions permissions) + * throws ServiceException; + * + * CreateLocatorResult createLocator(AssetId asset, + * AccessPolicyId accessPolicy, + * DateTime startTime, + * LocatorType type) + * throws ServiceException; + * + * // Add overload that defaults locatorType to SAS, and defaults startTime to now - 5 minutes. + * + * // We need to upload blobs from here - do we go through blobservice, or do we just do it + * // directly? I'm leaning towards direct - blob container is encoded in locator. + * + * UploadResult uploadFile(Locator locator, string content, UploadOptions options); + * UploadResult uploadFile(Locator locator, InputStream sream, UploadOptions options); + * + * // UploadOptions - do we need this? Look at blob client for what's in this. Can we reuse? + * // Probably shouldn't, in case they diverge. + * + * DeleteLocatorResult deleteLocator(Locator locator) + * throws ServiceException; + * + * CreateFileInfosResponse createFileInfos(Asset asset) + * throws ServiceException; + * + * + */ } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java new file mode 100644 index 0000000000000..4874dd6cd1740 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -0,0 +1,37 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * Class representing an AccessPolicy entity + * + * + */ +public class AccessPolicyInfo { + // TODO: Rework this as needed once we have a serialization + // solution decided on. + + private String id; + private Date created; + private Date lastModified; + private String name; + private double durationInMinutes; + // TODO: Figure out best way to represent these. EnumSet? + // private AccessPolicyPermissions permissions; + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java new file mode 100644 index 0000000000000..546af4e25cc96 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -0,0 +1,12 @@ +/** + * + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * Permissions available to an access policy + * + */ +public enum AccessPolicyPermission { + NONE, READ, WRITE, DELETE, LIST +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java new file mode 100644 index 0000000000000..7889da14326d4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java @@ -0,0 +1,55 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * Class representing the result of a CreateAccessPolicy REST operation + * + */ +public class CreateAccessPolicyResult { + private AccessPolicyInfo value; + + /** + * Creates an instance of the GetAssetResult class. + * + * @param value + * A {@link AccessPolicyInfo} object assigned as the value of the + * result. + */ + public CreateAccessPolicyResult(AccessPolicyInfo value) { + this.setValue(value); + } + + /** + * Specfies the value of the result. + * + * @param value + * A {@link AccessPolicyInfo} object assigned as the value of the + * result. + */ + public AccessPolicyInfo getValue() { + return value; + } + + /** + * Returns the value of the result. + * + * @return A {@link AccessPolicyInfo} object that represents the value of the + * result. + */ + public void setValue(AccessPolicyInfo newValue) { + value = newValue; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java index 0867c5af7b10d..0411e8e18895e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java @@ -2,34 +2,34 @@ * Copyright 2011 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.media.models; /** * Represents the result of a createAsset operation. */ -public class GetAssetResult { - private AssetInfo value; +public class CreateAssetResult { + private AssetInfo value; - /** + /** * Creates an instance of the GetAssetResult class. * * @param value * A {@link AssetInfo} object assigned as the value of the * result. */ - public GetAssetResult(AssetInfo value) { - this.setValue(value); - } + public CreateAssetResult(AssetInfo value) { + this.setValue(value); + } /** * Specfies the value of the result. @@ -38,9 +38,9 @@ public GetAssetResult(AssetInfo value) { * A {@link AssetInfo} object assigned as the value of the * result. */ - public AssetInfo getValue() { - return value; - } + public AssetInfo getValue() { + return value; + } /** * Returns the value of the result. @@ -48,7 +48,7 @@ public AssetInfo getValue() { * @return A {@link AssetInfo} object that represents the value of the * result. */ - public void setValue(AssetInfo newValue) { - value = newValue; - } + public void setValue(AssetInfo newValue) { + value = newValue; + } } From 7d3fcfd9303d7a430d97004ca7277045602c947c Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 17 Aug 2012 12:18:03 -0700 Subject: [PATCH 317/664] Defining AccessPolicyPermission as an enum, plus helpful conversion functions --- .../media/models/AccessPolicyPermission.java | 69 +++++++++++++++- .../models/AccessPolicyPermissionTest.java | 79 +++++++++++++++++++ 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java index 546af4e25cc96..a1abc4a25587b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -1,12 +1,79 @@ /** + * Copyright 2011 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.media.models; +import java.util.EnumSet; + /** * Permissions available to an access policy * */ public enum AccessPolicyPermission { - NONE, READ, WRITE, DELETE, LIST + NONE(0), READ(1), WRITE(2), DELETE(4), LIST(8); + + private int flagValue; + + private AccessPolicyPermission(int value) { + flagValue = value; + } + + /** + * Get the flag bit value associated with this permission + * + * @return The integer permission value + */ + public int getFlagValue() { + return flagValue; + } + + /** + * Given an integer representing the permissions as a bit vector, + * convert it into an EnumSet<AccessPolicyPermission> object containing the correct permissions + * * + * + * @param bits + * The bit vector of permissions + * @return The set of permissions in an EnumSet object. + */ + public static EnumSet permissionsFromBits(int bits) { + EnumSet perms = EnumSet.of(AccessPolicyPermission.NONE); + + for (AccessPolicyPermission p : AccessPolicyPermission.values()) { + if ((bits & p.getFlagValue()) != 0) { + perms.remove(AccessPolicyPermission.NONE); + perms.add(p); + } + } + + return perms; + } + + /** + * Convert an EnumSet containing permissions into the + * corresponding integer bit vector to be passed to Media services. + * + * @param perms + * The permissions + * @return The bit vector to go out over the wire. + */ + public static int bitsFromPermissions(EnumSet perms) { + int result = 0; + for (AccessPolicyPermission p : perms) { + result |= p.getFlagValue(); + } + + return result; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java new file mode 100644 index 0000000000000..2ff5a68665294 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java @@ -0,0 +1,79 @@ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.EnumSet; + +import org.junit.Test; + +public class AccessPolicyPermissionTest { + + @Test + public void testGetFlagValue() { + assertEquals(0, AccessPolicyPermission.NONE.getFlagValue()); + assertEquals(1, AccessPolicyPermission.READ.getFlagValue()); + assertEquals(2, AccessPolicyPermission.WRITE.getFlagValue()); + assertEquals(4, AccessPolicyPermission.DELETE.getFlagValue()); + assertEquals(8, AccessPolicyPermission.LIST.getFlagValue()); + } + + @Test + public void testZeroResultsInNonePermission() { + EnumSet perms = AccessPolicyPermission.permissionsFromBits(0); + assertTrue(perms.contains(AccessPolicyPermission.NONE)); + } + + @Test + public void testAllBitsSetResultsInAllPermissions() { + EnumSet perms = AccessPolicyPermission.permissionsFromBits(1 + 2 + 4 + 8); + + assertFalse(perms.contains(AccessPolicyPermission.NONE)); + assertTrue(perms.contains(AccessPolicyPermission.READ)); + assertTrue(perms.contains(AccessPolicyPermission.WRITE)); + assertTrue(perms.contains(AccessPolicyPermission.DELETE)); + assertTrue(perms.contains(AccessPolicyPermission.LIST)); + } + + @Test + public void testWriteBitsResultsInOnlyWritePermissions() { + EnumSet perms = AccessPolicyPermission.permissionsFromBits(2); + + assertFalse(perms.contains(AccessPolicyPermission.NONE)); + assertFalse(perms.contains(AccessPolicyPermission.READ)); + assertTrue(perms.contains(AccessPolicyPermission.WRITE)); + assertFalse(perms.contains(AccessPolicyPermission.DELETE)); + assertFalse(perms.contains(AccessPolicyPermission.LIST)); + } + + @Test + public void testEmptyPermissionsResultsInZeroBits() { + EnumSet perms = EnumSet.noneOf(AccessPolicyPermission.class); + int bits = AccessPolicyPermission.bitsFromPermissions(perms); + + assertEquals(0, bits); + } + + @Test + public void allPermissionsInSetResultsInCorrectValue() { + EnumSet perms = EnumSet.of(AccessPolicyPermission.READ, AccessPolicyPermission.WRITE, + AccessPolicyPermission.DELETE, AccessPolicyPermission.LIST, AccessPolicyPermission.NONE); + int bits = AccessPolicyPermission.bitsFromPermissions(perms); + + assertEquals(1 + 2 + 4 + 8, bits); + } + + @Test + public void writePermissionsInSetResultsInCorrectValue() { + EnumSet perms = EnumSet.of(AccessPolicyPermission.WRITE); + int bits = AccessPolicyPermission.bitsFromPermissions(perms); + + assertEquals(2, bits); + } + + @Test + public void unknownPermissionBitsAreIgnored() { + EnumSet perms = AccessPolicyPermission.permissionsFromBits(16 + 32); + + assertTrue(perms.contains(AccessPolicyPermission.NONE)); + } +} From 84075724c878c347cb10238ec142bfef6968a49c Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 17 Aug 2012 15:13:53 -0700 Subject: [PATCH 318/664] Building out contract - access policies using permissions enum --- .../services/media/MediaServicesContract.java | 4 - .../media/models/AccessPolicyInfo.java | 96 ++++++++++++++++++- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java index 35c702de42e09..3c8c744a05064 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -62,10 +62,6 @@ CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, /** * // The set of operations to support. Will uncomment as they get added * - * CreateAccessPolicyResult createAccessPolicy(String name, - * int durationInMinutes, - * AccessPolicyPermissions permissions) - * throws ServiceException; * * CreateLocatorResult createLocator(AssetId asset, * AccessPolicyId accessPolicy, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java index 4874dd6cd1740..1728075c704b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.media.models; import java.util.Date; +import java.util.EnumSet; /** * Class representing an AccessPolicy entity @@ -31,7 +32,98 @@ public class AccessPolicyInfo { private Date lastModified; private String name; private double durationInMinutes; - // TODO: Figure out best way to represent these. EnumSet? - // private AccessPolicyPermissions permissions; + private final EnumSet permissions = EnumSet.noneOf(AccessPolicyPermission.class); + + public AccessPolicyInfo(String id, String Name, Date created, Date lastModified, double durationInMinutes, + int permissionBits) { + + this.id = id; + this.created = created; + this.lastModified = lastModified; + this.durationInMinutes = durationInMinutes; + permissions.addAll(AccessPolicyPermission.permissionsFromBits(permissionBits)); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * @param created + * the created to set + */ + public void setCreated(Date created) { + this.created = created; + } + + /** + * @return the lastModified + */ + public Date getLastModified() { + return lastModified; + } + + /** + * @param lastModified + * the lastModified to set + */ + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the durationInMinutes + */ + public double getDurationInMinutes() { + return durationInMinutes; + } + + /** + * @param durationInMinutes + * the durationInMinutes to set + */ + public void setDurationInMinutes(double durationInMinutes) { + this.durationInMinutes = durationInMinutes; + } + + /** + * @return the permissions + */ + public EnumSet getPermissions() { + return permissions; + } } From 8935523ff8f8fe1785a66de6e4b337c2b152bad2 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 17 Aug 2012 15:32:16 -0700 Subject: [PATCH 319/664] Moving oauth filters to implementation directory --- .../com/microsoft/windowsazure/services/media/Exports.java | 4 ++++ .../services/media/{ => implementation}/ActiveToken.java | 2 +- .../services/media/{ => implementation}/OAuthContract.java | 2 +- .../services/media/{ => implementation}/OAuthFilter.java | 2 +- .../services/media/{ => implementation}/OAuthRestProxy.java | 2 +- .../media/{ => implementation}/OAuthTokenManager.java | 2 +- .../media/{ => implementation}/OAuthTokenResponse.java | 2 +- .../{ => implementation}/OAuthRestProxyIntegrationTest.java | 3 ++- .../media/{ => implementation}/OAuthTokenManagerTest.java | 2 +- 9 files changed, 13 insertions(+), 8 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/ActiveToken.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthContract.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthFilter.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthRestProxy.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthTokenManager.java (98%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthTokenResponse.java (96%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthRestProxyIntegrationTest.java (93%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{ => implementation}/OAuthTokenManagerTest.java (98%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 2a9cd99c4b38c..a981bbde293b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -15,6 +15,10 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.Builder; +import com.microsoft.windowsazure.services.media.implementation.OAuthContract; +import com.microsoft.windowsazure.services.media.implementation.OAuthFilter; +import com.microsoft.windowsazure.services.media.implementation.OAuthRestProxy; +import com.microsoft.windowsazure.services.media.implementation.OAuthTokenManager; public class Exports implements Builder.Exports { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java index 2be96a410507a..e3c5561f7b77f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import java.util.Date; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java index b74216823c308..7e81549642f7e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index 3fa9f48bc74ec..3b2e45a363b67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import java.net.URISyntaxException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index 9ab60ed9115ce..a51eae7e82c3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import java.io.IOException; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java similarity index 98% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 77f2b020a2cd7..9a5ffcf59afb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import java.net.URI; import java.net.URISyntaxException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index 95a9dae61f674..42974fb52e3f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java similarity index 93% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java index 1b05d54794c3a..da1153cae4015 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import static org.junit.Assert.*; @@ -21,6 +21,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.MediaConfiguration; import com.sun.jersey.api.client.Client; public class OAuthRestProxyIntegrationTest { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java similarity index 98% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index 241d2ecc91e57..2cbbc85d50854 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.media; +package com.microsoft.windowsazure.services.media.implementation; import static org.junit.Assert.*; import static org.mockito.Mockito.*; From dc5d1301a8fb6edd1c580b6db1c743444c5bff9e Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Fri, 17 Aug 2012 17:43:12 -0700 Subject: [PATCH 320/664] Putting in initial implementation of contract, including rest proxies, MediaServicesService, etc. Hooked up exports to configuration. --- .../windowsazure/services/media/Exports.java | 9 ++ .../services/media/MediaConfiguration.java | 2 +- .../services/media/MediaServicesService.java | 67 +++++++++++ .../MediaServicesExceptionProcessor.java | 104 ++++++++++++++++++ .../MediaServicesRestProxy.java | 96 ++++++++++++++++ .../implementation/OAuthTokenManager.java | 9 +- .../ResourceLocationManager.java | 5 +- ...windowsazure.services.core.Builder$Exports | 2 + .../services/media/ExportsTest.java | 32 ++++++ .../services/media/IntegrationTestBase.java | 26 +++++ 10 files changed, 348 insertions(+), 4 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index a981bbde293b0..b28f86e89d1b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -15,10 +15,14 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.Builder; +import com.microsoft.windowsazure.services.media.implementation.MediaServicesExceptionProcessor; +import com.microsoft.windowsazure.services.media.implementation.MediaServicesRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthContract; import com.microsoft.windowsazure.services.media.implementation.OAuthFilter; import com.microsoft.windowsazure.services.media.implementation.OAuthRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthTokenManager; +import com.microsoft.windowsazure.services.media.implementation.RedirectFilter; +import com.microsoft.windowsazure.services.media.implementation.ResourceLocationManager; public class Exports implements Builder.Exports { @@ -27,9 +31,14 @@ public class Exports implements Builder.Exports { */ @Override public void register(Builder.Registry registry) { + registry.add(MediaServicesContract.class, MediaServicesExceptionProcessor.class); + registry.add(MediaServicesExceptionProcessor.class); + registry.add(MediaServicesRestProxy.class); registry.add(OAuthContract.class, OAuthRestProxy.class); registry.add(OAuthTokenManager.class); registry.add(OAuthFilter.class); + registry.add(ResourceLocationManager.class); + registry.add(RedirectFilter.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index 0c4c703fb1dd7..ac7464c570018 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.core.Configuration; /** - * Provides functionality to create a service bus configuration. + * Provides functionality to create a media services configuration. * */ public class MediaConfiguration { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java new file mode 100644 index 0000000000000..8b91c17a666ca --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java @@ -0,0 +1,67 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import com.microsoft.windowsazure.services.core.Configuration; + +/** + * + * Access media services functionality. + * + */ +public class MediaServicesService { + + private MediaServicesService() { + // class is not instantiated + } + + /** + * Creates an instance of the MediaServicesContract API. + * + */ + public static MediaServicesContract create() { + return Configuration.getInstance().create(MediaServicesContract.class); + } + + /** + * Creates an instance of the MediaServicesContract API using the specified configuration. + * + * @param config + * A Configuration object that represents the configuration for the service bus service. + * + */ + public static MediaServicesContract create(Configuration config) { + return config.create(MediaServicesContract.class); + } + + /** + * Creates an instance of the MediaServicesContract API. + * + */ + public static MediaServicesContract create(String profile) { + return Configuration.getInstance().create(profile, MediaServicesContract.class); + } + + /** + * Creates an instance of the MediaServicesContract API using the specified configuration. + * + * @param config + * A Configuration object that represents the configuration for the service bus service. + * + */ + public static MediaServicesContract create(String profile, Configuration config) { + return config.create(profile, MediaServicesContract.class); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java new file mode 100644 index 0000000000000..9b7d00f2fa4c2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java @@ -0,0 +1,104 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.util.EnumSet; + +import javax.inject.Inject; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; +import com.microsoft.windowsazure.services.media.MediaServicesContract; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; +import com.microsoft.windowsazure.services.media.models.CreateAssetResult; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; + +/** + * Wrapper implementation of MediaServicesContract that + * translates exceptions into ServiceExceptions. + * + */ +public class MediaServicesExceptionProcessor implements MediaServicesContract { + + private final MediaServicesContract next; + static Log log = LogFactory.getLog(MediaServicesContract.class); + + public MediaServicesExceptionProcessor(MediaServicesContract next) { + this.next = next; + } + + @Inject + public MediaServicesExceptionProcessor(MediaServicesRestProxy next) { + this.next = next; + } + + @Override + public MediaServicesContract withFilter(ServiceFilter filter) { + return new MediaServicesExceptionProcessor(next.withFilter(filter)); + } + + private ServiceException processCatch(ServiceException e) { + log.warn(e.getMessage(), e.getCause()); + return ServiceExceptionFactory.process("MediaServices", e); + } + + @Override + public CreateAssetResult createAsset(String name) throws ServiceException { + try { + return next.createAsset(name); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public void deleteAsset(AssetInfo asset) throws ServiceException { + try { + next.deleteAsset(asset); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, + EnumSet permissions) throws ServiceException { + try { + return next.createAccessPolicy(name, durationInMinutes, permissions); + } + 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/media/implementation/MediaServicesRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java new file mode 100644 index 0000000000000..bb298f1b701e2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java @@ -0,0 +1,96 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.util.Arrays; +import java.util.EnumSet; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.media.MediaServicesContract; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; +import com.microsoft.windowsazure.services.media.models.CreateAssetResult; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; + +public class MediaServicesRestProxy implements MediaServicesContract { + + private Client channel; + static Log log = LogFactory.getLog(MediaServicesContract.class); + + ServiceFilter[] filters; + + public MediaServicesRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { + this.channel = channel; + this.filters = new ServiceFilter[0]; + channel.addFilter(redirectFilter); + channel.addFilter(authFilter); + } + + public MediaServicesRestProxy(Client channel, ServiceFilter[] filters) { + this.channel = channel; + this.filters = filters; + } + + @Override + public MediaServicesContract withFilter(ServiceFilter filter) { + ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); + newFilters[filters.length] = filter; + return new MediaServicesRestProxy(channel, newFilters); + } + + public Client getChannel() { + return channel; + } + + public void setChannel(Client channel) { + this.channel = channel; + } + + private WebResource getResource(String entityName) { + WebResource resource = getChannel().resource(entityName); + for (ServiceFilter filter : filters) { + resource.addFilter(new ClientFilterAdapter(filter)); + } + return resource; + } + + @Override + public CreateAssetResult createAsset(String name) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void deleteAsset(AssetInfo asset) throws ServiceException { + // TODO Auto-generated method stub + + } + + @Override + public CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, + EnumSet permissions) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 9a5ffcf59afb3..473bd9d60bb60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -19,10 +19,12 @@ import java.net.URISyntaxException; import java.util.Date; +import javax.inject.Named; import javax.management.timer.Timer; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.utils.DateFactory; +import com.microsoft.windowsazure.services.media.MediaConfiguration; /** * An OAuth token manager class. @@ -59,8 +61,11 @@ public class OAuthTokenManager { * A String object instance that represents the client secret. * */ - public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, URI acsBaseUri, String clientId, - String clientSecret, String scope) { + public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, + @Named(MediaConfiguration.OAUTH_URI) URI acsBaseUri, + @Named(MediaConfiguration.OAUTH_CLIENT_ID) String clientId, + @Named(MediaConfiguration.OAUTH_CLIENT_SECRET) String clientSecret, + @Named(MediaConfiguration.OAUTH_SCOPE) String scope) { this.contract = contract; this.dateFactory = dateFactory; this.acsBaseUri = acsBaseUri; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 773b6c27847d1..75b5c12ad6dc6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -18,12 +18,15 @@ import java.net.URI; import java.net.URISyntaxException; +import javax.inject.Named; import javax.ws.rs.core.UriBuilder; +import com.microsoft.windowsazure.services.media.MediaConfiguration; + public class ResourceLocationManager { private URI baseURI; - public ResourceLocationManager(String baseUri) throws URISyntaxException { + public ResourceLocationManager(@Named(MediaConfiguration.URI) String baseUri) throws URISyntaxException { this.baseURI = new URI(baseUri); } diff --git a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports index 07fdb1c4e7b67..e49188d4c09af 100644 --- a/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports +++ b/microsoft-azure-api/src/main/resources/META-INF/services/com.microsoft.windowsazure.services.core.Builder$Exports @@ -5,3 +5,5 @@ com.microsoft.windowsazure.services.serviceBus.Exports com.microsoft.windowsazure.services.serviceBus.implementation.Exports com.microsoft.windowsazure.services.core.utils.Exports com.microsoft.windowsazure.services.core.utils.pipeline.Exports +com.microsoft.windowsazure.services.media.Exports + diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java new file mode 100644 index 0000000000000..c21063c48e261 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java @@ -0,0 +1,32 @@ +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.net.URI; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.RedirectFilter; +import com.microsoft.windowsazure.services.media.implementation.ResourceLocationManager; + +/** + * Tests to verify the items exported from media services + * can be resolved from configuration. + * + */ +public class ExportsTest extends IntegrationTestBase { + + @Test + public void canResolveLocationManagerFromConfig() throws Exception { + ResourceLocationManager rlm = config.create(ResourceLocationManager.class); + URI rootUri = new URI((String) config.getProperty(MediaConfiguration.URI)); + + assertEquals(rootUri, rlm.getBaseURI()); + } + + @Test + public void canResolveRedirectFilterFromConfig() throws Exception { + RedirectFilter filter = config.create(RedirectFilter.class); + assertNotNull(filter); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java new file mode 100644 index 0000000000000..113d1ff2b2c50 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -0,0 +1,26 @@ +package com.microsoft.windowsazure.services.media; + +import org.junit.Before; + +import com.microsoft.windowsazure.services.core.Configuration; + +public abstract class IntegrationTestBase { + protected Configuration config; + + @Before + public void beforeEachTest() { + config = Configuration.getInstance(); + overrideWithEnv(config, MediaConfiguration.URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + } + + protected static void overrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); + } +} From b2c91d1a46b2edf662dc0d88c68c1f3ff6c9ed54 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sun, 26 Aug 2012 16:58:56 -0700 Subject: [PATCH 321/664] Implement Asset, ContentKey, File and Locator classes. --- .../services/media/models/Asset.java | 132 +++++++++++ .../services/media/models/AssetState.java | 18 ++ .../services/media/models/ContentKey.java | 117 ++++++++++ .../services/media/models/ContentKeyType.java | 35 +++ .../media/models/EncryptionOption.java | 33 +++ .../services/media/models/File.java | 167 ++++++++++++++ .../services/media/models/Locator.java | 92 ++++++++ .../services/media/models/LocatorType.java | 30 +++ .../media/models/ProtectionKeyType.java | 30 +++ .../services/media/models/AssetTest.java | 170 ++++++++++++++ .../services/media/models/ContentKeyTest.java | 147 ++++++++++++ .../services/media/models/FileTest.java | 209 ++++++++++++++++++ .../services/media/models/LocatorTest.java | 117 ++++++++++ 13 files changed, 1297 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java new file mode 100644 index 0000000000000..be3b534bcb3d0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -0,0 +1,132 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +public class Asset { + private String id; + private AssetState state; + private Date created; + private Date lastModified; + private String alternateId; + private String name; + private EncryptionOption options; + private Iterable locators; + private Iterable contentKeys; + private Iterable files; + private Iterable parentAssets; + + public String getId() { + return this.id; + } + + public Asset setId(String id) { + this.id = id; + return this; + } + + public AssetState getState() { + return this.state; + } + + public Asset setState(AssetState state) { + this.state = state; + return this; + } + + public Date getCreated() { + return this.created; + } + + public Asset setCreate(Date created) { + this.created = created; + return this; + } + + public Date getLastModified() { + return this.lastModified; + } + + public Asset setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + public String getAlternateId() { + return this.alternateId; + } + + public Asset setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + public String getName() { + return this.name; + } + + public Asset setName(String name) { + this.name = name; + return this; + } + + public EncryptionOption getOptions() { + return this.options; + } + + public Asset setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + public Iterable getLocators() { + return this.locators; + } + + public Asset setLocators(Iterable locators) { + this.locators = locators; + return this; + } + + public Iterable getContentKeys() { + return this.contentKeys; + } + + public Asset setContentKeys(Iterable expectedContentKeys) { + this.contentKeys = expectedContentKeys; + return this; + } + + public Iterable getFiles() { + return this.files; + } + + public Asset setFiles(Iterable files) { + this.files = files; + return this; + } + + public Iterable getParentAssets() { + return this.parentAssets; + } + + public Asset setParentAssets(Iterable parentAssets) { + this.parentAssets = parentAssets; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java new file mode 100644 index 0000000000000..35a504b6da720 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java @@ -0,0 +1,18 @@ +package com.microsoft.windowsazure.services.media.models; + +/** + * Specifies the states of the asset. + */ +public enum AssetState { + Initialized(0), Published(1), Deleted(2); + + private int assetStateCode; + + private AssetState(int assetStateCode) { + this.assetStateCode = assetStateCode; + } + + public int getCode() { + return assetStateCode; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java new file mode 100644 index 0000000000000..8ea9b530b43f6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -0,0 +1,117 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +public class ContentKey { + private String id; + private Date created; + private Date lastModified; + private ContentKeyType contentKeyType; + private String encryptedContentKey; + private String name; + private String protectionKeyId; + private String checkSum; + private ProtectionKeyType protectionKeyType; + + public String getId() { + return this.id; + } + + public ContentKey setId(String id) { + this.id = id; + return this; + } + + public ContentKey setCreate(Date created) { + this.created = created; + return this; + } + + public Date getLastModified() { + return this.lastModified; + } + + public ContentKey setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + public String getName() { + return this.name; + } + + public ContentKey setName(String name) { + this.name = name; + return this; + } + + public ContentKey setCheckSum(String checkSum) { + this.checkSum = checkSum; + return this; + } + + public String getCheckSum() { + return this.checkSum; + } + + public ContentKey setProtectionKeyType(ProtectionKeyType protectionKeyType) { + this.protectionKeyType = protectionKeyType; + return this; + } + + public ProtectionKeyType getProtectionKeyType() { + return this.protectionKeyType; + } + + public ContentKey setProtectionKeyId(String protectionKeyId) { + this.protectionKeyId = protectionKeyId; + return this; + } + + public String getProtectionKeyId() { + return this.protectionKeyId; + } + + public ContentKey setEncryptedContentKey(String encryptedContentKey) { + this.encryptedContentKey = encryptedContentKey; + return this; + } + + public String getEncryptedContentKey() { + return this.encryptedContentKey; + } + + public ContentKey setContentKeyType(ContentKeyType contentKeyType) { + this.contentKeyType = contentKeyType; + return this; + } + + public ContentKeyType getContentKeyType() { + return this.contentKeyType; + } + + public ContentKey setCreated(Date created) { + this.created = created; + return this; + } + + public Date getCreated() { + return this.created; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java new file mode 100644 index 0000000000000..1a7bc64e9d565 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -0,0 +1,35 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +/** + * + * Specifies the type of a content key. + * + */ +public enum ContentKeyType { + CommonEncryption(0), StorageEncryption(1), ConfigurationEncryption(2); + + private int contentKeyTypeCode; + + private ContentKeyType(int contentKeyTypeCode) { + this.contentKeyTypeCode = contentKeyTypeCode; + } + + public int getCode() { + return contentKeyTypeCode; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java new file mode 100644 index 0000000000000..9e98aecb69aab --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java @@ -0,0 +1,33 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +/** + * Specifies the options for encryption. + */ +public enum EncryptionOption { + None(0), StorageEncrypted(1), CommonEncryptionProtected(2); + + private int encryptionOptionCode; + + private EncryptionOption(int encryptionOptionCode) { + this.encryptionOptionCode = encryptionOptionCode; + } + + public int getCode() { + return encryptionOptionCode; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java new file mode 100644 index 0000000000000..f171d4a1fe576 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java @@ -0,0 +1,167 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +public class File { + private String id; + private String name; + private int contentFileSize; + private String parentAssetId; + private String encryptionVersion; + private String encryptionScheme; + private Boolean isEncrypted; + private String encryptionKeyId; + private String initializationVector; + private Boolean isPrimary; + private Date lastModified; + private Date created; + private String mimeType; + private String contentChecksum; + + public String getId() { + return this.id; + } + + public File setId(String id) { + this.id = id; + return this; + } + + public String getName() { + return this.name; + } + + public File setName(String name) { + this.name = name; + return this; + } + + public int getContentFileSize() { + return this.contentFileSize; + } + + public File setContentFileSize(int contentFileSize) { + this.contentFileSize = contentFileSize; + return this; + } + + public String getParentAssetId() { + return this.parentAssetId; + } + + public File setParentAssetId(String parentAssetId) { + this.parentAssetId = parentAssetId; + return this; + } + + public Date getCreated() { + return this.created; + } + + public File setCreate(Date created) { + this.created = created; + return this; + } + + public Date getLastModified() { + return this.lastModified; + } + + public File setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + public File setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + public String getEncryptionVersion() { + return this.encryptionVersion; + } + + public File setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + public String getEncryptionScheme() { + return this.encryptionScheme; + } + + public File setIsEncrypted(Boolean isEncrypted) { + this.isEncrypted = isEncrypted; + return this; + } + + public Boolean getIsEncrypted() { + return this.isEncrypted; + } + + public File setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + public String getEncryptionKeyId() { + return this.encryptionKeyId; + } + + public File setInitializationVector(String expectedInitializationVector) { + this.initializationVector = expectedInitializationVector; + return this; + } + + public String getInitializationVector() { + return this.initializationVector; + } + + public File setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + return this; + } + + public Boolean getIsPrimary() { + return this.isPrimary; + } + + public File setCreated(Date created) { + this.created = created; + return this; + } + + public File setMimeType(String mimeType) { + this.mimeType = mimeType; + return this; + } + + public String getMimeType() { + return this.mimeType; + } + + public File setContentChecksum(String contentChecksum) { + this.contentChecksum = contentChecksum; + return this; + } + + public String getContentChecksum() { + return this.contentChecksum; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java new file mode 100644 index 0000000000000..2cfa54e1a429d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -0,0 +1,92 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +public class Locator { + private String id; + private Date expirationDatetime; + private String path; + private String accessPolicyId; + private String assetId; + private Date startTime; + private LocatorType locatorType; + + public String getId() { + return this.id; + } + + public Locator setId(String id) { + this.id = id; + return this; + } + + public Locator setExpirationDateTime(Date expirationDateTime) { + this.expirationDatetime = expirationDateTime; + return this; + } + + public Date getExpirationDateTime() { + return this.expirationDatetime; + } + + public Locator setLocatorType(LocatorType locatorType) { + this.locatorType = locatorType; + return this; + } + + public LocatorType getLocatorType() { + return this.locatorType; + } + + public Locator setPath(String path) { + this.path = path; + return this; + } + + public String getPath() { + return this.path; + } + + public Locator setAccessPolicyId(String accessPolicyId) { + this.accessPolicyId = accessPolicyId; + return this; + } + + public String getAccessPolicyId() { + return this.accessPolicyId; + } + + public Locator setAssetId(String assetId) { + this.assetId = assetId; + return this; + } + + public String getAssetId() { + return this.assetId; + } + + public Locator setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + + public Date getStartTime() { + return this.startTime; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java new file mode 100644 index 0000000000000..ef74b364fa655 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -0,0 +1,30 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +public enum LocatorType { + None(0), SAS(1), Origin(2), WindowsAzureCDN(3); + + private int locatorTypeCode; + + private LocatorType(int locatorTypeCode) { + this.locatorTypeCode = locatorTypeCode; + } + + public int getCode() { + return this.locatorTypeCode; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java new file mode 100644 index 0000000000000..88f0099e20bd9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java @@ -0,0 +1,30 @@ +/* + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +public enum ProtectionKeyType { + X509CertificateThumbprint(0); + + private int protectionKeyTypeCode; + + private ProtectionKeyType(int protectionKeyTypeCode) { + this.protectionKeyTypeCode = protectionKeyTypeCode; + } + + public int getCode() { + return protectionKeyTypeCode; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java new file mode 100644 index 0000000000000..d622d9473bb04 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java @@ -0,0 +1,170 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Date; + +import org.junit.Test; + +public class AssetTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + Asset asset = new Asset(); + + // Act + String actualId = asset.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + + } + + @Test + public void testGetSetState() { + // Arrange + AssetState expectedState = AssetState.Published; + Asset asset = new Asset(); + + // Act + AssetState actualState = asset.setState(expectedState).getState(); + + // Assert + assertEquals(expectedState, actualState); + } + + @Test + public void testGetSetCreated() { + // Arrange + Date expectedCreated = new Date(); + Asset asset = new Asset(); + + // Act + Date actualCreated = asset.setCreate(expectedCreated).getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + + } + + @Test + public void testGetSetLastModified() { + // Arrange + Date expectedLastModified = new Date(); + Asset asset = new Asset(); + + // Act + Date actualLastModified = asset.setLastModified(expectedLastModified).getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetAlternateId() { + // Arrange + String expectedAlternateId = "testAlternateId"; + Asset asset = new Asset(); + + // Act + String actualAlternateId = asset.setAlternateId(expectedAlternateId).getAlternateId(); + + // Assert + assertEquals(expectedAlternateId, actualAlternateId); + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testName"; + Asset asset = new Asset(); + + // Act + String actualName = asset.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetOptions() { + // Arrange + EncryptionOption expectedOptions = EncryptionOption.None; + Asset asset = new Asset(); + + // Act + EncryptionOption actualOptions = asset.setOptions(expectedOptions).getOptions(); + + // Assert + assertEquals(expectedOptions, actualOptions); + } + + @Test + public void testGetSetLocators() { + // Arrange + Iterable expectedLocators = new ArrayList(); + Asset asset = new Asset(); + + // Act + Iterable actualLocators = asset.setLocators(expectedLocators).getLocators(); + + // Assert + assertEquals(expectedLocators, actualLocators); + } + + @Test + public void testGetSetContentKeys() { + // Arrange + Iterable expectedContentKeys = new ArrayList(); + Asset asset = new Asset(); + + // Act + Iterable actualContentKeys = asset.setContentKeys(expectedContentKeys).getContentKeys(); + + // Assert + assertEquals(expectedContentKeys, actualContentKeys); + } + + @Test + public void testGetSetFiles() { + // Arrange + Iterable expectedFiles = new ArrayList(); + Asset asset = new Asset(); + + // Act + Iterable actualFiles = asset.setFiles(expectedFiles).getFiles(); + + // Assert + assertEquals(expectedFiles, actualFiles); + } + + @Test + public void testGetSetParentAsset() { + // Arrange + Iterable expectedParentAssets = new ArrayList(); + Asset asset = new Asset(); + + // Act + Iterable actualAssets = asset.setParentAssets(expectedParentAssets).getParentAssets(); + + // Assert + assertEquals(expectedParentAssets, actualAssets); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java new file mode 100644 index 0000000000000..a2cf7644b10db --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java @@ -0,0 +1,147 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Test; + +public class ContentKeyTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + ContentKey contentKey = new ContentKey(); + + // Act + String actualId = contentKey.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + } + + @Test + public void testGetSetCreated() { + // Arrange + Date expectedCreated = new Date(); + ContentKey contentKey = new ContentKey(); + + // Act + Date actualCreated = contentKey.setCreated(expectedCreated).getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + } + + @Test + public void testGetSetLastModified() { + // Arrange + Date expectedLastModified = new Date(); + ContentKey contentKey = new ContentKey(); + + // Act + Date actualLastModified = contentKey.setLastModified(expectedLastModified).getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetContentKeyType() { + // Arrange + ContentKeyType expectedContentKeyType = ContentKeyType.ConfigurationEncryption; + ContentKey contentKey = new ContentKey(); + + // Act + ContentKeyType actualContentKeyType = contentKey.setContentKeyType(expectedContentKeyType).getContentKeyType(); + + // Assert + assertEquals(expectedContentKeyType, actualContentKeyType); + + } + + @Test + public void testGetSetEncryptedContentKey() { + // Arrange + String expectedEncryptedContentKey = "testX509Certificate"; + ContentKey contentKey = new ContentKey(); + + // Act + String actualEncryptedContentKey = contentKey.setEncryptedContentKey(expectedEncryptedContentKey) + .getEncryptedContentKey(); + + // Assert + assertEquals(expectedEncryptedContentKey, actualEncryptedContentKey); + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "expectedName"; + ContentKey contentKey = new ContentKey(); + + // Act + String actualName = contentKey.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetProtectionKeyId() { + // Arrange + String expectedProtectionKeyId = "expectedProtectionKeyId"; + ContentKey contentKey = new ContentKey(); + + // Act + String actualProtectionKeyId = contentKey.setProtectionKeyId(expectedProtectionKeyId).getProtectionKeyId(); + + // Assert + assertEquals(expectedProtectionKeyId, actualProtectionKeyId); + + } + + @Test + public void testGetSetProtectionKeyType() { + // Arrange + ProtectionKeyType expectedProtectionKeyType = ProtectionKeyType.X509CertificateThumbprint; + ContentKey contentKey = new ContentKey(); + + // Act + ProtectionKeyType actualProtectionKeyType = contentKey.setProtectionKeyType(expectedProtectionKeyType) + .getProtectionKeyType(); + + // Assert + assertEquals(expectedProtectionKeyType, actualProtectionKeyType); + } + + @Test + public void testGetSetCheckSum() { + // Arrange + String expectedCheckSum = "testCheckSum"; + ContentKey contentKey = new ContentKey(); + + // Act + String actualCheckSum = contentKey.setCheckSum(expectedCheckSum).getCheckSum(); + + // Assert + assertEquals(expectedCheckSum, actualCheckSum); + + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java new file mode 100644 index 0000000000000..3a4a760cdbacd --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java @@ -0,0 +1,209 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Test; + +public class FileTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "testId"; + File file = new File(); + + // Act + String actualId = file.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testName"; + File file = new File(); + + // Act + String actualName = file.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetContentFileSize() { + // Arrange + int expectedContentFileSize = 1234; + File file = new File(); + + // Act + int actualContentFileSize = file.setContentFileSize(expectedContentFileSize).getContentFileSize(); + + // Assert + assertEquals(expectedContentFileSize, actualContentFileSize); + + } + + @Test + public void testGetSetParentAssetId() { + // Arrange + String expectedParentAssetId = "testParentAssetId"; + File file = new File(); + + // Act + String actualParentAssetId = file.setParentAssetId(expectedParentAssetId).getParentAssetId(); + + // Assert + assertEquals(expectedParentAssetId, actualParentAssetId); + } + + @Test + public void testGetSetEncryptionVersion() { + // Arrange + String expectedEncryptionVersion = "testEncryptionVersion"; + File file = new File(); + + // Act + String actualEncryptionVersion = file.setEncryptionVersion(expectedEncryptionVersion).getEncryptionVersion(); + + // Assert + assertEquals(expectedEncryptionVersion, actualEncryptionVersion); + } + + @Test + public void testGetSetEncryptionScheme() { + // Arrange + String expectedEncryptionScheme = "testEncryptionScheme"; + File file = new File(); + + // Act + String actualEncryptionScheme = file.setEncryptionScheme(expectedEncryptionScheme).getEncryptionScheme(); + + // Assert + assertEquals(expectedEncryptionScheme, actualEncryptionScheme); + } + + @Test + public void testGetSetIsEncrypted() { + // Arrange + Boolean expectedIsEncrypted = true; + File file = new File(); + + // Act + Boolean actualIsEncrypted = file.setIsEncrypted(expectedIsEncrypted).getIsEncrypted(); + + // Assert + assertEquals(expectedIsEncrypted, actualIsEncrypted); + } + + @Test + public void testGetSetEncryptionKeyId() { + // Arrange + String expectedEncryptionKeyId = "testEncryptionKeyId"; + File file = new File(); + + // Act + String actualEncryptionKeyId = file.setEncryptionKeyId(expectedEncryptionKeyId).getEncryptionKeyId(); + + // Assert + assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); + } + + @Test + public void testGetSetInitializationVector() { + // Arrange + String expectedInitializationVector = "testInitializationVector"; + File file = new File(); + + // Act + String actualInitializationVector = file.setInitializationVector(expectedInitializationVector) + .getInitializationVector(); + + // Assert + assertEquals(expectedInitializationVector, actualInitializationVector); + + } + + @Test + public void testGetSetIsPrimary() { + // Arrange + Boolean expectedIsPrimary = true; + File file = new File(); + + // Act + Boolean actualIsPrimary = file.setIsPrimary(expectedIsPrimary).getIsPrimary(); + + // Assert + assertEquals(expectedIsPrimary, actualIsPrimary); + } + + @Test + public void testGetSetLastModified() { + // Arrange + Date expectedLastModified = new Date(); + File file = new File(); + + // Act + Date actualLastModified = file.setLastModified(expectedLastModified).getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetCreated() { + // Arrange + Date expectedCreated = new Date(); + File file = new File(); + + // Act + Date actualCreated = file.setCreated(expectedCreated).getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + } + + @Test + public void testGetSetMimeType() { + // Arrange + String expectedMimeType = "testMimeType"; + File file = new File(); + + // Act + String actualMimeType = file.setMimeType(expectedMimeType).getMimeType(); + + // Assert + assertEquals(expectedMimeType, actualMimeType); + } + + @Test + public void testGetSetContentChecksum() { + // Arrange + String expectedContentChecksum = "testContentChecksum"; + File file = new File(); + + // Act + String actualContentChecksum = file.setContentChecksum(expectedContentChecksum).getContentChecksum(); + + // Assert + assertEquals(expectedContentChecksum, actualContentChecksum); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java new file mode 100644 index 0000000000000..c4c0da8c02f4e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java @@ -0,0 +1,117 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Test; + +public class LocatorTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "testId"; + Locator locator = new Locator(); + + // Act + String actualId = locator.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + } + + @Test + public void testGetSetExpirationDateTime() { + // Arrange + Date expectedExpirationDateTime = new Date(); + Locator locator = new Locator(); + + // Act + Date actualExpirationDateTime = locator.setExpirationDateTime(expectedExpirationDateTime) + .getExpirationDateTime(); + + // Assert + assertEquals(expectedExpirationDateTime, actualExpirationDateTime); + } + + @Test + public void testGetSetType() { + // Arrange + LocatorType expectedLocatorType = LocatorType.WindowsAzureCDN; + Locator locator = new Locator(); + + // Act + LocatorType actualLocatorType = locator.setLocatorType(expectedLocatorType).getLocatorType(); + + // Assert + assertEquals(expectedLocatorType, actualLocatorType); + } + + @Test + public void testGetSetPath() { + // Arrange + String expectedPath = "testPath"; + Locator locator = new Locator(); + + // Act + String actualPath = locator.setPath(expectedPath).getPath(); + + // Assert + assertEquals(expectedPath, actualPath); + } + + @Test + public void testGetSetAccessPolicyId() { + // Arrange + String expectedAccessPolicyId = "testAccessPolicyId"; + Locator locator = new Locator(); + + // Act + String actualAccessPolicyId = locator.setAccessPolicyId(expectedAccessPolicyId).getAccessPolicyId(); + + // Assert + assertEquals(expectedAccessPolicyId, actualAccessPolicyId); + } + + @Test + public void testGetSetAssetId() { + // Arrange + String expectedAssetId = "testAssetId"; + Locator locator = new Locator(); + + // Act + String actualAssetId = locator.setAssetId(expectedAssetId).getAssetId(); + + // Assert + assertEquals(expectedAssetId, actualAssetId); + } + + @Test + public void testGetSetStartTime() { + // Arrange + Date expectedStartTime = new Date(); + Locator locator = new Locator(); + + // Act + Date actualStartTime = locator.setStartTime(expectedStartTime).getStartTime(); + + // Assert + assertEquals(expectedStartTime, actualStartTime); + } + +} From 4cb18154309659a4b17b8115a0b47b709baab256 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 12 Sep 2012 22:50:51 -0700 Subject: [PATCH 322/664] enable emma to generate code coverage report. --- microsoft-azure-api/pom.xml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b75c6d4c1a9c1..dbc6cd094ba18 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -207,7 +207,6 @@ - @@ -249,4 +248,18 @@ + + + + org.codehaus.mojo + emma-maven-plugin + true + + + org.codehaus.mojo + surefire-report-maven-plugin + true + + + From 7e2815b3f44d7c920215d4a195d59f5294d50b1a Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Mon, 17 Sep 2012 10:19:31 -0700 Subject: [PATCH 323/664] Cleaning up media service proxy work, removed premature model objects (mostly) --- .../services/media/MediaServicesContract.java | 65 +------------------ .../MediaServicesExceptionProcessor.java | 47 -------------- .../MediaServicesRestProxy.java | 28 +------- .../services/media/models/AssetInfo.java | 45 ------------- .../models/CreateAccessPolicyResult.java | 55 ---------------- .../media/models/CreateAssetResult.java | 54 --------------- .../OAuthRestProxyIntegrationTest.java | 16 +---- 7 files changed, 6 insertions(+), 304 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java index 3c8c744a05064..e14cbc59e5757 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java @@ -14,14 +14,7 @@ */ package com.microsoft.windowsazure.services.media; -import java.util.EnumSet; - import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; -import com.microsoft.windowsazure.services.media.models.CreateAssetResult; /** * @@ -30,62 +23,6 @@ */ public interface MediaServicesContract extends FilterableService { - /** - * Creates a new media service asset - * - * @param name - * A String specifying the name of the asset to create. - * - * @return A CreateAssetResult object that represents the result. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - CreateAssetResult createAsset(String name) throws ServiceException; - - /** - * Deletes a media service asset - * - * @param asset - * A AssetInfo object specifying the asset to delete. - * - * @exception ServiceException - * If a service exception is encountered. - * - */ - void deleteAsset(AssetInfo asset) throws ServiceException; - - CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, - EnumSet permissions) throws ServiceException; + // TODO: Fill in as we define the REST operations - /** - * // The set of operations to support. Will uncomment as they get added - * - * - * CreateLocatorResult createLocator(AssetId asset, - * AccessPolicyId accessPolicy, - * DateTime startTime, - * LocatorType type) - * throws ServiceException; - * - * // Add overload that defaults locatorType to SAS, and defaults startTime to now - 5 minutes. - * - * // We need to upload blobs from here - do we go through blobservice, or do we just do it - * // directly? I'm leaning towards direct - blob container is encoded in locator. - * - * UploadResult uploadFile(Locator locator, string content, UploadOptions options); - * UploadResult uploadFile(Locator locator, InputStream sream, UploadOptions options); - * - * // UploadOptions - do we need this? Look at blob client for what's in this. Can we reuse? - * // Probably shouldn't, in case they diverge. - * - * DeleteLocatorResult deleteLocator(Locator locator) - * throws ServiceException; - * - * CreateFileInfosResponse createFileInfos(Asset asset) - * throws ServiceException; - * - * - */ } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java index 9b7d00f2fa4c2..ce7c3d56f2890 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.util.EnumSet; - import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -26,12 +24,6 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaServicesContract; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; -import com.microsoft.windowsazure.services.media.models.CreateAssetResult; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; /** * Wrapper implementation of MediaServicesContract that @@ -62,43 +54,4 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("MediaServices", e); } - @Override - public CreateAssetResult createAsset(String name) throws ServiceException { - try { - return next.createAsset(name); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public void deleteAsset(AssetInfo asset) throws ServiceException { - try { - next.deleteAsset(asset); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - @Override - public CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, - EnumSet permissions) throws ServiceException { - try { - return next.createAccessPolicy(name, durationInMinutes, permissions); - } - 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/media/implementation/MediaServicesRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java index bb298f1b701e2..4a40e8dc3929e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java @@ -16,19 +16,15 @@ package com.microsoft.windowsazure.services.media.implementation; import java.util.Arrays; -import java.util.EnumSet; + +import javax.inject.Inject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.media.MediaServicesContract; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyResult; -import com.microsoft.windowsazure.services.media.models.CreateAssetResult; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @@ -39,6 +35,7 @@ public class MediaServicesRestProxy implements MediaServicesContract { ServiceFilter[] filters; + @Inject public MediaServicesRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { this.channel = channel; this.filters = new ServiceFilter[0]; @@ -74,23 +71,4 @@ private WebResource getResource(String entityName) { return resource; } - @Override - public CreateAssetResult createAsset(String name) throws ServiceException { - // TODO Auto-generated method stub - return null; - } - - @Override - public void deleteAsset(AssetInfo asset) throws ServiceException { - // TODO Auto-generated method stub - - } - - @Override - public CreateAccessPolicyResult createAccessPolicy(String name, int durationInMinutes, - EnumSet permissions) throws ServiceException { - // TODO Auto-generated method stub - return null; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java deleted file mode 100644 index 800f7bf14674e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * Represents an asset - */ -public class AssetInfo { - // TODO: Turn this into a serializable class, EntryModel thing - private String id; - - /** - * Create a new AssetInfo for the given Asset Id. - */ - public AssetInfo(String id) { - this.id = id; - } - - /** - * Retrieve the id - */ - public String getId() { - return id; - } - - /** - * Set the id. Do we really need this? - */ - public AssetInfo setId(String newId) { - id = newId; - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java deleted file mode 100644 index 7889da14326d4..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyResult.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * Class representing the result of a CreateAccessPolicy REST operation - * - */ -public class CreateAccessPolicyResult { - private AccessPolicyInfo value; - - /** - * Creates an instance of the GetAssetResult class. - * - * @param value - * A {@link AccessPolicyInfo} object assigned as the value of the - * result. - */ - public CreateAccessPolicyResult(AccessPolicyInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link AccessPolicyInfo} object assigned as the value of the - * result. - */ - public AccessPolicyInfo getValue() { - return value; - } - - /** - * Returns the value of the result. - * - * @return A {@link AccessPolicyInfo} object that represents the value of the - * result. - */ - public void setValue(AccessPolicyInfo newValue) { - value = newValue; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java deleted file mode 100644 index 0411e8e18895e..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetResult.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * Represents the result of a createAsset operation. - */ -public class CreateAssetResult { - private AssetInfo value; - - /** - * Creates an instance of the GetAssetResult class. - * - * @param value - * A {@link AssetInfo} object assigned as the value of the - * result. - */ - public CreateAssetResult(AssetInfo value) { - this.setValue(value); - } - - /** - * Specfies the value of the result. - * - * @param value - * A {@link AssetInfo} object assigned as the value of the - * result. - */ - public AssetInfo getValue() { - return value; - } - - /** - * Returns the value of the result. - * - * @return A {@link AssetInfo} object that represents the value of the - * result. - */ - public void setValue(AssetInfo newValue) { - value = newValue; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java index da1153cae4015..13bede0a0db30 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java @@ -20,18 +20,14 @@ import org.junit.Test; -import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.IntegrationTestBase; import com.microsoft.windowsazure.services.media.MediaConfiguration; import com.sun.jersey.api.client.Client; -public class OAuthRestProxyIntegrationTest { +public class OAuthRestProxyIntegrationTest extends IntegrationTestBase { @Test public void serviceCanBeCalledToCreateAccessToken() throws Exception { // Arrange - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); OAuthContract oAuthContract = new OAuthRestProxy(config.create(Client.class)); // Act @@ -45,12 +41,4 @@ public void serviceCanBeCalledToCreateAccessToken() throws Exception { assertNotNull(result); assertNotNull(result.getAccessToken()); } - - private static void overrideWithEnv(Configuration config, String key) { - String value = System.getenv(key); - if (value == null) - return; - - config.setProperty(key, value); - } } From 17a4ca29df4e58974fe905eca273685d9577b170 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Mon, 17 Sep 2012 11:48:01 -0700 Subject: [PATCH 324/664] Responding to code review feedback. --- .../windowsazure/services/media/Exports.java | 10 +- ...rvicesContract.java => MediaContract.java} | 56 ++++---- ...ServicesService.java => MediaService.java} | 24 ++-- ...ssor.java => MediaExceptionProcessor.java} | 16 +-- ...icesRestProxy.java => MediaRestProxy.java} | 14 +- .../media/models/AccessPolicyInfo.java | 129 ------------------ 6 files changed, 60 insertions(+), 189 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{MediaServicesContract.java => MediaContract.java} (77%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{MediaServicesService.java => MediaService.java} (70%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/{MediaServicesExceptionProcessor.java => MediaExceptionProcessor.java} (71%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/{MediaServicesRestProxy.java => MediaRestProxy.java} (78%) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index b28f86e89d1b3..791ed56f87555 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -15,8 +15,8 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.Builder; -import com.microsoft.windowsazure.services.media.implementation.MediaServicesExceptionProcessor; -import com.microsoft.windowsazure.services.media.implementation.MediaServicesRestProxy; +import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; +import com.microsoft.windowsazure.services.media.implementation.MediaRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthContract; import com.microsoft.windowsazure.services.media.implementation.OAuthFilter; import com.microsoft.windowsazure.services.media.implementation.OAuthRestProxy; @@ -31,9 +31,9 @@ public class Exports implements Builder.Exports { */ @Override public void register(Builder.Registry registry) { - registry.add(MediaServicesContract.class, MediaServicesExceptionProcessor.class); - registry.add(MediaServicesExceptionProcessor.class); - registry.add(MediaServicesRestProxy.class); + registry.add(MediaContract.class, MediaExceptionProcessor.class); + registry.add(MediaExceptionProcessor.class); + registry.add(MediaRestProxy.class); registry.add(OAuthContract.class, OAuthRestProxy.class); registry.add(OAuthTokenManager.class); registry.add(OAuthFilter.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java similarity index 77% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index e14cbc59e5757..3e92ac300dae0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -1,28 +1,28 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media; - -import com.microsoft.windowsazure.services.core.FilterableService; - -/** - * - * Defines the Media contract. - * - */ -public interface MediaServicesContract extends FilterableService { - - // TODO: Fill in as we define the REST operations - -} +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import com.microsoft.windowsazure.services.core.FilterableService; + +/** + * + * Defines the methods available for Windows Azure Media Services + * + */ +public interface MediaContract extends FilterableService { + + // Will fill in as we implement the various Media Services entities + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java similarity index 70% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 8b91c17a666ca..413dae44c8d41 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaServicesService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -18,21 +18,21 @@ /** * - * Access media services functionality. + * Access media services functionality. This class cannot + * be instantiated. * */ -public class MediaServicesService { +public class MediaService { - private MediaServicesService() { - // class is not instantiated + private MediaService() { } /** * Creates an instance of the MediaServicesContract API. * */ - public static MediaServicesContract create() { - return Configuration.getInstance().create(MediaServicesContract.class); + public static MediaContract create() { + return Configuration.getInstance().create(MediaContract.class); } /** @@ -42,16 +42,16 @@ public static MediaServicesContract create() { * A Configuration object that represents the configuration for the service bus service. * */ - public static MediaServicesContract create(Configuration config) { - return config.create(MediaServicesContract.class); + public static MediaContract create(Configuration config) { + return config.create(MediaContract.class); } /** * Creates an instance of the MediaServicesContract API. * */ - public static MediaServicesContract create(String profile) { - return Configuration.getInstance().create(profile, MediaServicesContract.class); + public static MediaContract create(String profile) { + return Configuration.getInstance().create(profile, MediaContract.class); } /** @@ -61,7 +61,7 @@ public static MediaServicesContract create(String profile) { * A Configuration object that represents the configuration for the service bus service. * */ - public static MediaServicesContract create(String profile, Configuration config) { - return config.create(profile, MediaServicesContract.class); + public static MediaContract create(String profile, Configuration config) { + return config.create(profile, MediaContract.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java similarity index 71% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index ce7c3d56f2890..d9c3141d52064 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -23,30 +23,30 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; -import com.microsoft.windowsazure.services.media.MediaServicesContract; +import com.microsoft.windowsazure.services.media.MediaContract; /** * Wrapper implementation of MediaServicesContract that * translates exceptions into ServiceExceptions. * */ -public class MediaServicesExceptionProcessor implements MediaServicesContract { +public class MediaExceptionProcessor implements MediaContract { - private final MediaServicesContract next; - static Log log = LogFactory.getLog(MediaServicesContract.class); + private final MediaContract next; + static Log log = LogFactory.getLog(MediaContract.class); - public MediaServicesExceptionProcessor(MediaServicesContract next) { + public MediaExceptionProcessor(MediaContract next) { this.next = next; } @Inject - public MediaServicesExceptionProcessor(MediaServicesRestProxy next) { + public MediaExceptionProcessor(MediaRestProxy next) { this.next = next; } @Override - public MediaServicesContract withFilter(ServiceFilter filter) { - return new MediaServicesExceptionProcessor(next.withFilter(filter)); + public MediaContract withFilter(ServiceFilter filter) { + return new MediaExceptionProcessor(next.withFilter(filter)); } private ServiceException processCatch(ServiceException e) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java similarity index 78% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 4a40e8dc3929e..9b1dfc25e5a60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaServicesRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -24,35 +24,35 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.media.MediaServicesContract; +import com.microsoft.windowsazure.services.media.MediaContract; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; -public class MediaServicesRestProxy implements MediaServicesContract { +public class MediaRestProxy implements MediaContract { private Client channel; - static Log log = LogFactory.getLog(MediaServicesContract.class); + static Log log = LogFactory.getLog(MediaContract.class); ServiceFilter[] filters; @Inject - public MediaServicesRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { + public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { this.channel = channel; this.filters = new ServiceFilter[0]; channel.addFilter(redirectFilter); channel.addFilter(authFilter); } - public MediaServicesRestProxy(Client channel, ServiceFilter[] filters) { + public MediaRestProxy(Client channel, ServiceFilter[] filters) { this.channel = channel; this.filters = filters; } @Override - public MediaServicesContract withFilter(ServiceFilter filter) { + public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new MediaServicesRestProxy(channel, newFilters); + return new MediaRestProxy(channel, newFilters); } public Client getChannel() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java deleted file mode 100644 index 1728075c704b9..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; -import java.util.EnumSet; - -/** - * Class representing an AccessPolicy entity - * - * - */ -public class AccessPolicyInfo { - // TODO: Rework this as needed once we have a serialization - // solution decided on. - - private String id; - private Date created; - private Date lastModified; - private String name; - private double durationInMinutes; - private final EnumSet permissions = EnumSet.noneOf(AccessPolicyPermission.class); - - public AccessPolicyInfo(String id, String Name, Date created, Date lastModified, double durationInMinutes, - int permissionBits) { - - this.id = id; - this.created = created; - this.lastModified = lastModified; - this.durationInMinutes = durationInMinutes; - permissions.addAll(AccessPolicyPermission.permissionsFromBits(permissionBits)); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * @param created - * the created to set - */ - public void setCreated(Date created) { - this.created = created; - } - - /** - * @return the lastModified - */ - public Date getLastModified() { - return lastModified; - } - - /** - * @param lastModified - * the lastModified to set - */ - public void setLastModified(Date lastModified) { - this.lastModified = lastModified; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the durationInMinutes - */ - public double getDurationInMinutes() { - return durationInMinutes; - } - - /** - * @param durationInMinutes - * the durationInMinutes to set - */ - public void setDurationInMinutes(double durationInMinutes) { - this.durationInMinutes = durationInMinutes; - } - - /** - * @return the permissions - */ - public EnumSet getPermissions() { - return permissions; - } - -} From 1c798bac713451273847a664e31e80db36a2f18e Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Mon, 17 Sep 2012 14:41:33 -0700 Subject: [PATCH 325/664] Added xjc generated classes from Atom schema --- .../implementation/atom/CategoryType.java | 208 +++++++ .../implementation/atom/ContentType.java | 225 +++++++ .../implementation/atom/DateTimeType.java | 153 +++++ .../media/implementation/atom/EntryType.java | 206 +++++++ .../media/implementation/atom/FeedType.java | 209 +++++++ .../implementation/atom/GeneratorType.java | 210 +++++++ .../media/implementation/atom/IconType.java | 156 +++++ .../media/implementation/atom/IdType.java | 156 +++++ .../media/implementation/atom/LinkType.java | 324 ++++++++++ .../media/implementation/atom/LogoType.java | 156 +++++ .../implementation/atom/ObjectFactory.java | 556 ++++++++++++++++++ .../media/implementation/atom/PersonType.java | 179 ++++++ .../media/implementation/atom/SourceType.java | 206 +++++++ .../media/implementation/atom/TextType.java | 206 +++++++ .../media/implementation/atom/UriType.java | 152 +++++ .../implementation/atom/package-info.java | 9 + 16 files changed, 3311 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java new file mode 100644 index 0000000000000..3e0138fef82c8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java @@ -0,0 +1,208 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom cagegory construct is defined in section 4.2.2 of the format spec. + * + * + *

Java class for categoryType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="categoryType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <attribute name="term" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="scheme" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="label" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "categoryType") +public class CategoryType { + + @XmlAttribute(required = true) + protected String term; + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected String scheme; + @XmlAttribute + protected String label; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the term property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTerm() { + return term; + } + + /** + * Sets the value of the term property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTerm(String value) { + this.term = value; + } + + /** + * Gets the value of the scheme property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getScheme() { + return scheme; + } + + /** + * Sets the value of the scheme property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setScheme(String value) { + this.scheme = value; + } + + /** + * Gets the value of the label property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLabel() { + return label; + } + + /** + * Sets the value of the label property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLabel(String value) { + this.label = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java new file mode 100644 index 0000000000000..8e03e7cb2b4a8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java @@ -0,0 +1,225 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom content construct is defined in section 4.1.3 of the format spec. + * + * + *

Java class for contentType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="contentType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "contentType", propOrder = { + "content" +}) +public class ContentType { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + @XmlAttribute + protected String type; + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected String src; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * + * The Atom content construct is defined in section 4.1.3 of the format spec. + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getContent().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link String } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the src property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSrc() { + return src; + } + + /** + * Sets the value of the src property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSrc(String value) { + this.src = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java new file mode 100644 index 0000000000000..4232aee1748e1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java @@ -0,0 +1,153 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.namespace.QName; + + +/** + *

Java class for dateTimeType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="dateTimeType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>dateTime">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "dateTimeType", propOrder = { + "value" +}) +public class DateTimeType { + + @XmlValue + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar value; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setValue(XMLGregorianCalendar value) { + this.value = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java new file mode 100644 index 0000000000000..d3244af70517d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -0,0 +1,206 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom entry construct is defined in section 4.1.2 of the format spec. + * + * + *

Java class for entryType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="entryType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded">
+ *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="content" type="{http://www.w3.org/2005/Atom}contentType" minOccurs="0"/>
+ *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2005/Atom}idType"/>
+ *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="published" type="{http://www.w3.org/2005/Atom}dateTimeType" minOccurs="0"/>
+ *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="source" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="summary" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="title" type="{http://www.w3.org/2005/Atom}textType"/>
+ *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType"/>
+ *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </choice>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "entryType", propOrder = { + "entryChildren" +}) +public class EntryType { + + @XmlElementRefs({ + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) + @XmlAnyElement(lax = true) + protected List entryChildren; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the entryChildren property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the entryChildren property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getEntryChildren().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link ContentType }{@code >} + * {@link Object } + * + * + */ + public List getEntryChildren() { + if (entryChildren == null) { + entryChildren = new ArrayList(); + } + return this.entryChildren; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java new file mode 100644 index 0000000000000..435a81f20f110 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java @@ -0,0 +1,209 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom feed construct is defined in section 4.1.1 of the format spec. + * + * + *

Java class for feedType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="feedType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded" minOccurs="3">
+ *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="generator" type="{http://www.w3.org/2005/Atom}generatorType" minOccurs="0"/>
+ *         <element name="icon" type="{http://www.w3.org/2005/Atom}iconType" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2005/Atom}idType"/>
+ *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="logo" type="{http://www.w3.org/2005/Atom}logoType" minOccurs="0"/>
+ *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="subtitle" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="title" type="{http://www.w3.org/2005/Atom}textType"/>
+ *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType"/>
+ *         <element name="entry" type="{http://www.w3.org/2005/Atom}entryType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </choice>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "feedType", propOrder = { + "authorOrCategoryOrContributor" +}) +public class FeedType { + + @XmlElementRefs({ + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) + @XmlAnyElement(lax = true) + protected List authorOrCategoryOrContributor; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the authorOrCategoryOrContributor property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the authorOrCategoryOrContributor property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAuthorOrCategoryOrContributor().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IconType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link EntryType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link Object } + * + * + */ + public List getAuthorOrCategoryOrContributor() { + if (authorOrCategoryOrContributor == null) { + authorOrCategoryOrContributor = new ArrayList(); + } + return this.authorOrCategoryOrContributor; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java new file mode 100644 index 0000000000000..08f56f2f84c75 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java @@ -0,0 +1,210 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom generator element is defined in section 4.2.4 of the format spec. + * + * + *

Java class for generatorType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="generatorType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <attribute name="uri" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "generatorType", propOrder = { + "value" +}) +public class GeneratorType { + + @XmlValue + protected String value; + @XmlAttribute + @XmlSchemaType(name = "anyURI") + protected String uri; + @XmlAttribute + protected String version; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the uri property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUri() { + return uri; + } + + /** + * Sets the value of the uri property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUri(String value) { + this.uri = value; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java new file mode 100644 index 0000000000000..33675d2d588a5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java @@ -0,0 +1,156 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom icon construct is defined in section 4.2.5 of the format spec. + * + * + *

Java class for iconType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="iconType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "iconType", propOrder = { + "value" +}) +public class IconType { + + @XmlValue + @XmlSchemaType(name = "anyURI") + protected String value; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java new file mode 100644 index 0000000000000..0633ac55a4110 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java @@ -0,0 +1,156 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom id construct is defined in section 4.2.6 of the format spec. + * + * + *

Java class for idType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="idType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "idType", propOrder = { + "value" +}) +public class IdType { + + @XmlValue + @XmlSchemaType(name = "anyURI") + protected String value; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java new file mode 100644 index 0000000000000..7ea60224d7f02 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java @@ -0,0 +1,324 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom link construct is defined in section 3.4 of the format spec. + * + * + *

Java class for linkType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="linkType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <attribute name="href" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
+ *       <attribute name="rel" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="hreflang" type="{http://www.w3.org/2001/XMLSchema}NMTOKEN" />
+ *       <attribute name="title" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="length" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "linkType", propOrder = { + "content" +}) +public class LinkType { + + @XmlValue + protected String content; + @XmlAttribute(required = true) + @XmlSchemaType(name = "anyURI") + protected String href; + @XmlAttribute + protected String rel; + @XmlAttribute + protected String type; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NMTOKEN") + protected String hreflang; + @XmlAttribute + protected String title; + @XmlAttribute + @XmlSchemaType(name = "positiveInteger") + protected BigInteger length; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * + * The Atom link construct is defined in section 3.4 of the format spec. + * + * + * @return + * possible object is + * {@link String } + * + */ + public String getContent() { + return content; + } + + /** + * Sets the value of the content property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setContent(String value) { + this.content = value; + } + + /** + * Gets the value of the href property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getHref() { + return href; + } + + /** + * Sets the value of the href property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setHref(String value) { + this.href = value; + } + + /** + * Gets the value of the rel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRel() { + return rel; + } + + /** + * Sets the value of the rel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRel(String value) { + this.rel = value; + } + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the hreflang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getHreflang() { + return hreflang; + } + + /** + * Sets the value of the hreflang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setHreflang(String value) { + this.hreflang = value; + } + + /** + * Gets the value of the title property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTitle() { + return title; + } + + /** + * Sets the value of the title property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTitle(String value) { + this.title = value; + } + + /** + * Gets the value of the length property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getLength() { + return length; + } + + /** + * Sets the value of the length property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setLength(BigInteger value) { + this.length = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java new file mode 100644 index 0000000000000..443f58c771070 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java @@ -0,0 +1,156 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom logo construct is defined in section 4.2.8 of the format spec. + * + * + *

Java class for logoType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="logoType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "logoType", propOrder = { + "value" +}) +public class LogoType { + + @XmlValue + @XmlSchemaType(name = "anyURI") + protected String value; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java new file mode 100644 index 0000000000000..c620b60d57564 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java @@ -0,0 +1,556 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.microsoft.windowsazure.services.media.implementation.atom package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _Entry_QNAME = new QName("http://www.w3.org/2005/Atom", "entry"); + private final static QName _Feed_QNAME = new QName("http://www.w3.org/2005/Atom", "feed"); + private final static QName _PersonTypeName_QNAME = new QName("http://www.w3.org/2005/Atom", "name"); + private final static QName _PersonTypeEmail_QNAME = new QName("http://www.w3.org/2005/Atom", "email"); + private final static QName _PersonTypeUri_QNAME = new QName("http://www.w3.org/2005/Atom", "uri"); + private final static QName _EntryTypeTitle_QNAME = new QName("http://www.w3.org/2005/Atom", "title"); + private final static QName _EntryTypeCategory_QNAME = new QName("http://www.w3.org/2005/Atom", "category"); + private final static QName _EntryTypeAuthor_QNAME = new QName("http://www.w3.org/2005/Atom", "author"); + private final static QName _EntryTypeSummary_QNAME = new QName("http://www.w3.org/2005/Atom", "summary"); + private final static QName _EntryTypeId_QNAME = new QName("http://www.w3.org/2005/Atom", "id"); + private final static QName _EntryTypeContent_QNAME = new QName("http://www.w3.org/2005/Atom", "content"); + private final static QName _EntryTypeLink_QNAME = new QName("http://www.w3.org/2005/Atom", "link"); + private final static QName _EntryTypeContributor_QNAME = new QName("http://www.w3.org/2005/Atom", "contributor"); + private final static QName _EntryTypeUpdated_QNAME = new QName("http://www.w3.org/2005/Atom", "updated"); + private final static QName _EntryTypeSource_QNAME = new QName("http://www.w3.org/2005/Atom", "source"); + private final static QName _EntryTypeRights_QNAME = new QName("http://www.w3.org/2005/Atom", "rights"); + private final static QName _EntryTypePublished_QNAME = new QName("http://www.w3.org/2005/Atom", "published"); + private final static QName _FeedTypeGenerator_QNAME = new QName("http://www.w3.org/2005/Atom", "generator"); + private final static QName _FeedTypeSubtitle_QNAME = new QName("http://www.w3.org/2005/Atom", "subtitle"); + private final static QName _FeedTypeLogo_QNAME = new QName("http://www.w3.org/2005/Atom", "logo"); + private final static QName _FeedTypeIcon_QNAME = new QName("http://www.w3.org/2005/Atom", "icon"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.windowsazure.services.media.implementation.atom + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link PersonType } + * + */ + public PersonType createPersonType() { + return new PersonType(); + } + + /** + * Create an instance of {@link EntryType } + * + */ + public EntryType createEntryType() { + return new EntryType(); + } + + /** + * Create an instance of {@link IconType } + * + */ + public IconType createIconType() { + return new IconType(); + } + + /** + * Create an instance of {@link UriType } + * + */ + public UriType createUriType() { + return new UriType(); + } + + /** + * Create an instance of {@link TextType } + * + */ + public TextType createTextType() { + return new TextType(); + } + + /** + * Create an instance of {@link FeedType } + * + */ + public FeedType createFeedType() { + return new FeedType(); + } + + /** + * Create an instance of {@link DateTimeType } + * + */ + public DateTimeType createDateTimeType() { + return new DateTimeType(); + } + + /** + * Create an instance of {@link IdType } + * + */ + public IdType createIdType() { + return new IdType(); + } + + /** + * Create an instance of {@link SourceType } + * + */ + public SourceType createSourceType() { + return new SourceType(); + } + + /** + * Create an instance of {@link LinkType } + * + */ + public LinkType createLinkType() { + return new LinkType(); + } + + /** + * Create an instance of {@link LogoType } + * + */ + public LogoType createLogoType() { + return new LogoType(); + } + + /** + * Create an instance of {@link GeneratorType } + * + */ + public GeneratorType createGeneratorType() { + return new GeneratorType(); + } + + /** + * Create an instance of {@link ContentType } + * + */ + public ContentType createContentType() { + return new ContentType(); + } + + /** + * Create an instance of {@link CategoryType } + * + */ + public CategoryType createCategoryType() { + return new CategoryType(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry") + public JAXBElement createEntry(EntryType value) { + return new JAXBElement(_Entry_QNAME, EntryType.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "feed") + public JAXBElement createFeed(FeedType value) { + return new JAXBElement(_Feed_QNAME, FeedType.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "name", scope = PersonType.class) + public JAXBElement createPersonTypeName(String value) { + return new JAXBElement(_PersonTypeName_QNAME, String.class, PersonType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "email", scope = PersonType.class) + @XmlJavaTypeAdapter(NormalizedStringAdapter.class) + public JAXBElement createPersonTypeEmail(String value) { + return new JAXBElement(_PersonTypeEmail_QNAME, String.class, PersonType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "uri", scope = PersonType.class) + public JAXBElement createPersonTypeUri(UriType value) { + return new JAXBElement(_PersonTypeUri_QNAME, UriType.class, PersonType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = EntryType.class) + public JAXBElement createEntryTypeTitle(TextType value) { + return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = EntryType.class) + public JAXBElement createEntryTypeCategory(CategoryType value) { + return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = EntryType.class) + public JAXBElement createEntryTypeAuthor(PersonType value) { + return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "summary", scope = EntryType.class) + public JAXBElement createEntryTypeSummary(TextType value) { + return new JAXBElement(_EntryTypeSummary_QNAME, TextType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = EntryType.class) + public JAXBElement createEntryTypeId(IdType value) { + return new JAXBElement(_EntryTypeId_QNAME, IdType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "content", scope = EntryType.class) + public JAXBElement createEntryTypeContent(ContentType value) { + return new JAXBElement(_EntryTypeContent_QNAME, ContentType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = EntryType.class) + public JAXBElement createEntryTypeLink(LinkType value) { + return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = EntryType.class) + public JAXBElement createEntryTypeContributor(PersonType value) { + return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = EntryType.class) + public JAXBElement createEntryTypeUpdated(DateTimeType value) { + return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "source", scope = EntryType.class) + public JAXBElement createEntryTypeSource(TextType value) { + return new JAXBElement(_EntryTypeSource_QNAME, TextType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = EntryType.class) + public JAXBElement createEntryTypeRights(TextType value) { + return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "published", scope = EntryType.class) + public JAXBElement createEntryTypePublished(DateTimeType value) { + return new JAXBElement(_EntryTypePublished_QNAME, DateTimeType.class, EntryType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = FeedType.class) + public JAXBElement createFeedTypeCategory(CategoryType value) { + return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = FeedType.class) + public JAXBElement createFeedTypeTitle(TextType value) { + return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = FeedType.class) + public JAXBElement createFeedTypeAuthor(PersonType value) { + return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = FeedType.class) + public JAXBElement createFeedTypeId(IdType value) { + return new JAXBElement(_EntryTypeId_QNAME, IdType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry", scope = FeedType.class) + public JAXBElement createFeedTypeEntry(EntryType value) { + return new JAXBElement(_Entry_QNAME, EntryType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = FeedType.class) + public JAXBElement createFeedTypeContributor(PersonType value) { + return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = FeedType.class) + public JAXBElement createFeedTypeUpdated(DateTimeType value) { + return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = FeedType.class) + public JAXBElement createFeedTypeGenerator(GeneratorType value) { + return new JAXBElement(_FeedTypeGenerator_QNAME, GeneratorType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = FeedType.class) + public JAXBElement createFeedTypeSubtitle(TextType value) { + return new JAXBElement(_FeedTypeSubtitle_QNAME, TextType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = FeedType.class) + public JAXBElement createFeedTypeLogo(LogoType value) { + return new JAXBElement(_FeedTypeLogo_QNAME, LogoType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = FeedType.class) + public JAXBElement createFeedTypeIcon(IconType value) { + return new JAXBElement(_FeedTypeIcon_QNAME, IconType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = FeedType.class) + public JAXBElement createFeedTypeLink(LinkType value) { + return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = FeedType.class) + public JAXBElement createFeedTypeRights(TextType value) { + return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, FeedType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = SourceType.class) + public JAXBElement createSourceTypeTitle(TextType value) { + return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = SourceType.class) + public JAXBElement createSourceTypeCategory(CategoryType value) { + return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = SourceType.class) + public JAXBElement createSourceTypeIcon(IconType value) { + return new JAXBElement(_FeedTypeIcon_QNAME, IconType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = SourceType.class) + public JAXBElement createSourceTypeAuthor(PersonType value) { + return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = SourceType.class) + public JAXBElement createSourceTypeLogo(LogoType value) { + return new JAXBElement(_FeedTypeLogo_QNAME, LogoType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = SourceType.class) + public JAXBElement createSourceTypeId(IdType value) { + return new JAXBElement(_EntryTypeId_QNAME, IdType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = SourceType.class) + public JAXBElement createSourceTypeLink(LinkType value) { + return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = SourceType.class) + public JAXBElement createSourceTypeContributor(PersonType value) { + return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = SourceType.class) + public JAXBElement createSourceTypeUpdated(DateTimeType value) { + return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = SourceType.class) + public JAXBElement createSourceTypeGenerator(GeneratorType value) { + return new JAXBElement(_FeedTypeGenerator_QNAME, GeneratorType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = SourceType.class) + public JAXBElement createSourceTypeRights(TextType value) { + return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, SourceType.class, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = SourceType.class) + public JAXBElement createSourceTypeSubtitle(TextType value) { + return new JAXBElement(_FeedTypeSubtitle_QNAME, TextType.class, SourceType.class, value); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java new file mode 100644 index 0000000000000..8bd21a51d5ed6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java @@ -0,0 +1,179 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom person construct is defined in section 3.2 of the format spec. + * + * + *

Java class for personType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="personType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded">
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="uri" type="{http://www.w3.org/2005/Atom}uriType" minOccurs="0"/>
+ *         <element name="email" type="{http://www.w3.org/2005/Atom}emailType" minOccurs="0"/>
+ *         <any namespace='##other'/>
+ *       </choice>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "personType", propOrder = { + "nameOrUriOrEmail" +}) +public class PersonType { + + @XmlElementRefs({ + @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) + @XmlAnyElement(lax = true) + protected List nameOrUriOrEmail; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the nameOrUriOrEmail property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the nameOrUriOrEmail property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getNameOrUriOrEmail().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link Object } + * {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link JAXBElement }{@code <}{@link UriType }{@code >} + * + * + */ + public List getNameOrUriOrEmail() { + if (nameOrUriOrEmail == null) { + nameOrUriOrEmail = new ArrayList(); + } + return this.nameOrUriOrEmail; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java new file mode 100644 index 0000000000000..a5f20de7ae32b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java @@ -0,0 +1,206 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementRefs; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom source construct is defined in section 4.2.11 of the format spec. + * + * + *

Java class for sourceType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="sourceType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded">
+ *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="generator" type="{http://www.w3.org/2005/Atom}generatorType" minOccurs="0"/>
+ *         <element name="icon" type="{http://www.w3.org/2005/Atom}iconType" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2005/Atom}idType" minOccurs="0"/>
+ *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="logo" type="{http://www.w3.org/2005/Atom}logoType" minOccurs="0"/>
+ *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="subtitle" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="title" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
+ *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType" minOccurs="0"/>
+ *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
+ *       </choice>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "sourceType", propOrder = { + "authorOrCategoryOrContributor" +}) +public class SourceType { + + @XmlElementRefs({ + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) + @XmlAnyElement(lax = true) + protected List authorOrCategoryOrContributor; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the authorOrCategoryOrContributor property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the authorOrCategoryOrContributor property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getAuthorOrCategoryOrContributor().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link Object } + * {@link JAXBElement }{@code <}{@link IconType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * + * + */ + public List getAuthorOrCategoryOrContributor() { + if (authorOrCategoryOrContributor == null) { + authorOrCategoryOrContributor = new ArrayList(); + } + return this.authorOrCategoryOrContributor; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java new file mode 100644 index 0000000000000..6421c6ae97c96 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java @@ -0,0 +1,206 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + * + * The Atom text construct is defined in section 3.1 of the format spec. + * + * + *

Java class for textType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="textType">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <any namespace='http://www.w3.org/1999/xhtml' minOccurs="0"/>
+ *       </sequence>
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <attribute name="type">
+ *         <simpleType>
+ *           <restriction base="{http://www.w3.org/2001/XMLSchema}token">
+ *             <enumeration value="text"/>
+ *             <enumeration value="html"/>
+ *             <enumeration value="xhtml"/>
+ *           </restriction>
+ *         </simpleType>
+ *       </attribute>
+ *       <anyAttribute namespace='##other'/>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "textType", propOrder = { + "content" +}) +public class TextType { + + @XmlMixed + @XmlAnyElement(lax = true) + protected List content; + @XmlAttribute + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + protected String type; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * + * The Atom text construct is defined in section 3.1 of the format spec. + * Gets the value of the content property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the content property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getContent().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link String } + * + * + */ + public List getContent() { + if (content == null) { + content = new ArrayList(); + } + return this.content; + } + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java new file mode 100644 index 0000000000000..07c555c1dd6ee --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java @@ -0,0 +1,152 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + + +package com.microsoft.windowsazure.services.media.implementation.atom; + +import java.util.HashMap; +import java.util.Map; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAnyAttribute; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.namespace.QName; + + +/** + *

Java class for uriType complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="uriType">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
+ *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
+ *       <anyAttribute namespace='##other'/>
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "uriType", propOrder = { + "value" +}) +public class UriType { + + @XmlValue + @XmlSchemaType(name = "anyURI") + protected String value; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlSchemaType(name = "anyURI") + protected String base; + @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "language") + protected String lang; + @XmlAnyAttribute + private Map otherAttributes = new HashMap(); + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the base property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getBase() { + return base; + } + + /** + * Sets the value of the base property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setBase(String value) { + this.base = value; + } + + /** + * Gets the value of the lang property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLang() { + return lang; + } + + /** + * Sets the value of the lang property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLang(String value) { + this.lang = value; + } + + /** + * Gets a map that contains attributes that aren't bound to any typed property on this class. + * + *

+ * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. + * + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. + * + * + * @return + * always non-null + */ + public Map getOtherAttributes() { + return otherAttributes; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java new file mode 100644 index 0000000000000..5fc88fe9c0e0d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java @@ -0,0 +1,9 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/Atom", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.microsoft.windowsazure.services.media.implementation.atom; From 88ab2d77797f12ba442655f84e26986207b18034 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Mon, 17 Sep 2012 15:46:44 -0700 Subject: [PATCH 326/664] Added first cut at handrolled serialization wrapper classes along with required infrastructure. --- .../implementation/content/AssetType.java | 156 ++++++++++++++++++ .../implementation/content/Constants.java | 61 +++++++ .../content/ODataActionType.java | 5 + .../implementation/content/ObjectFactory.java | 43 +++++ 4 files changed, 265 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java new file mode 100644 index 0000000000000..9b9cfe57aec7b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -0,0 +1,156 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.datatype.XMLGregorianCalendar; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class AssetType { + + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) + protected int state; + + @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + protected XMLGregorianCalendar created; + + @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + protected XMLGregorianCalendar lastModified; + + @XmlElement(name = "AlternateId", namespace = Constants.ODATA_DATA_NS) + protected String alternateId; + + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + @XmlElement(name = "Options", namespace = Constants.ODATA_DATA_NS) + protected int options; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the state + */ + public int getState() { + return state; + } + + /** + * @param state + * the state to set + */ + public void setState(int state) { + this.state = state; + } + + /** + * @return the created + */ + public XMLGregorianCalendar getCreated() { + return created; + } + + /** + * @param created + * the created to set + */ + public void setCreated(XMLGregorianCalendar created) { + this.created = created; + } + + /** + * @return the lastModified + */ + public XMLGregorianCalendar getLastModified() { + return lastModified; + } + + /** + * @param lastModified + * the lastModified to set + */ + public void setLastModified(XMLGregorianCalendar lastModified) { + this.lastModified = lastModified; + } + + /** + * @return the alternateId + */ + public String getAlternateId() { + return alternateId; + } + + /** + * @param alternateId + * the alternateId to set + */ + public void setAlternateId(String alternateId) { + this.alternateId = alternateId; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the options + */ + public int getOptions() { + return options; + } + + /** + * @param options + * the options to set + */ + public void setOptions(int options) { + this.options = options; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java new file mode 100644 index 0000000000000..b11c4eadf4409 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java @@ -0,0 +1,61 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.namespace.QName; + +/** + * This class provides a set of constants for element names + * and namespaces used throughout the serialization of + * media services entities. + */ + +public class Constants { + /** + * XML Namespace for Atom syndication format, as defined by IETF RFC 4287 + */ + public static final String ATOM_NS = "http://www.w3.org/2005/Atom"; + + /** + * XML Namespace for OData data as serialized inside Atom syndication format. + */ + public static final String ODATA_DATA_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices"; + + /** + * XML Namespace for OData metadata as serialized inside Atom syndication format. + */ + public static final String ODATA_METADATA_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; + + /** + * EDM namespace for Azure Media Services entities, as defined in Media Services EDMX file. + */ + public static final String MEDIA_SERVICES_EDM_NAMESPACE = "Microsoft.Cloud.Media.Vod.Rest.Data.Models"; + + /** + * Element name for Atom content element, including namespace + */ + public static final QName ATOM_CONTENT_ELEMENT_NAME = new QName("content", ATOM_NS); + + /** + * Element name for OData action elements, including namespace + */ + public static final QName ODATA_ACTION_ELEMENT_NAME = new QName("action", ODATA_METADATA_NS); + + /** + * Element name for the metadata properties element, including namespace. + */ + public static final QName ODATA_PROPERTIES_ELEMENT_NAME = new QName("properties", ODATA_METADATA_NS); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java new file mode 100644 index 0000000000000..04126a27ab64b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.media.implementation.content; + +public class ODataActionType { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java new file mode 100644 index 0000000000000..e38aecbba63e9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -0,0 +1,43 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlRegistry; + +/** + * Class used by JAXB to instantiate the types in this package. + * + */ +@XmlRegistry +public class ObjectFactory { + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: + * com.microsoft.windowsazure.services.media.implementation.atom + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link AssetType } + * + * @return a new AssetType instance. + */ + public AssetType createAssetType() { + return new AssetType(); + } +} From ea38d271a2d57355d184d0bd5c9e156ceb604e81 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Mon, 17 Sep 2012 16:14:28 -0700 Subject: [PATCH 327/664] Brought in definiton for odata action element, start of test cases --- .../content/ODataActionType.java | 54 +++++++++++++++++++ .../ODataSerializationTest.java | 14 +++++ 2 files changed, 68 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index 04126a27ab64b..c64e4b68178ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -1,5 +1,59 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation.content; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; + +// XML Serialization class for odata m:action elements + +@XmlAccessorType(XmlAccessType.FIELD) public class ODataActionType { + @XmlAttribute(required = true) + protected String metadata; + + @XmlAttribute(required = true) + protected String target; + + @XmlAttribute(required = true) + protected String title; + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java new file mode 100644 index 0000000000000..f107c1dd1eb5e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -0,0 +1,14 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ODataSerializationTest { + + @Test + public void test() { + fail("Not yet implemented"); + } + +} From 29c9c476360a70e1cd7b22f209313a6c78fb4508 Mon Sep 17 00:00:00 2001 From: Chris Tavares Date: Tue, 18 Sep 2012 14:07:33 -0700 Subject: [PATCH 328/664] Deserializing sample data from string succeeded. --- .../implementation/ODataAtomUnmarshaller.java | 119 ++++++++++++++++++ .../media/implementation/ODataEntity.java | 48 +++++++ .../media/implementation/atom/FeedType.java | 52 ++++---- .../implementation/content/ObjectFactory.java | 9 ++ .../ODataSerializationTest.java | 44 ++++++- 5 files changed, 242 insertions(+), 30 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java new file mode 100644 index 0000000000000..c5666967ac4e8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -0,0 +1,119 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.InputStream; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.namespace.QName; +import javax.xml.transform.stream.StreamSource; + +import org.w3c.dom.Element; + +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.FeedType; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.ODataActionType; + +public class ODataAtomUnmarshaller { + private final JAXBContext atomContext; + private final JAXBContext mediaContentContext; + private final Unmarshaller atomUnmarshaller; + private final Unmarshaller mediaContentUnmarshaller; + + public ODataAtomUnmarshaller() throws JAXBException { + atomContext = JAXBContext.newInstance(FeedType.class.getPackage().getName()); + atomUnmarshaller = atomContext.createUnmarshaller(); + mediaContentContext = JAXBContext.newInstance(AssetType.class.getPackage().getName()); + mediaContentUnmarshaller = mediaContentContext.createUnmarshaller(); + } + + public ODataEntity unmarshal(InputStream stream, Class contentType) throws JAXBException { + JAXBElement feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); + FeedType feed = feedElement.getValue(); + EntryType firstEntry = getFirstEntry(feed); + + Object content = getEntryContent(firstEntry, contentType); + + return new ODataEntity(firstEntry, content); + } + + private Object getEntryContent(EntryType entry, Class contentType) throws JAXBException { + List entryChildren = entry.getEntryChildren(); + Object retval = null; + + for (int i = 0; i < entryChildren.size(); ++i) { + Object child = entryChildren.get(i); + if (child instanceof JAXBElement) { + // It's a parsed element, if it's content unmarshal, fixup, and store return value + JAXBElement e = (JAXBElement) child; + if (e.getDeclaredType() == ContentType.class) { + retval = unmarshalEntryContent((ContentType) e.getValue(), contentType); + } + } + else { + // It's an arbitrary XML element. If it's an action, fix up element. + Element e = (Element) child; + if (qnameFromElement(e).equals(Constants.ODATA_ACTION_ELEMENT_NAME)) { + JAXBElement actionElement = mediaContentUnmarshaller.unmarshal(e, + ODataActionType.class); + entryChildren.set(i, actionElement); + } + } + } + return retval; + } + + private EntryType getFirstEntry(FeedType feed) { + for (Object child : feed.getFeedChildren()) { + if (child instanceof JAXBElement) { + JAXBElement e = (JAXBElement) child; + + if (e.getDeclaredType() == EntryType.class) { + return (EntryType) e.getValue(); + } + } + } + return null; + } + + private Object unmarshalEntryContent(ContentType content, Class actualContentType) throws JAXBException { + List contentChildren = content.getContent(); + for (int i = 0; i < contentChildren.size(); ++i) { + Object child = contentChildren.get(i); + if (child instanceof Element) { + Element e = (Element) child; + if (qnameFromElement(e).equals(Constants.ODATA_PROPERTIES_ELEMENT_NAME)) { + JAXBElement actualContentElement = mediaContentUnmarshaller.unmarshal(e, actualContentType); + contentChildren.set(i, actualContentElement); + return actualContentElement.getValue(); + } + } + } + return null; + } + + private QName qnameFromElement(Element e) { + return new QName(e.getLocalName(), e.getNamespaceURI()); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java new file mode 100644 index 0000000000000..85a9fae74b1f8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -0,0 +1,48 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; + +/** + * Class wrapping deserialized OData entities. Allows easy + * access to entry and content types. + * + */ +public class ODataEntity { + + private final EntryType entry; + private final T content; + + public ODataEntity(EntryType entry, T content) { + this.entry = entry; + this.content = content; + } + + /** + * @return the entry + */ + public EntryType getEntry() { + return entry; + } + + /** + * @return the content + */ + public T getContent() { + return content; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java index 435a81f20f110..9c5ea3df46aef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See http://java.sun.com/xml/jaxb // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// Generated on: 2012.09.18 at 11:05:53 AM PDT // @@ -67,27 +67,27 @@ */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "feedType", propOrder = { - "authorOrCategoryOrContributor" + "feedChildren" }) public class FeedType { @XmlElementRefs({ - @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) - protected List authorOrCategoryOrContributor; + protected List feedChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @XmlSchemaType(name = "anyURI") protected String base; @@ -99,45 +99,45 @@ public class FeedType { private Map otherAttributes = new HashMap(); /** - * Gets the value of the authorOrCategoryOrContributor property. + * Gets the value of the feedChildren property. * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. - * This is why there is not a set method for the authorOrCategoryOrContributor property. + * This is why there is not a set method for the feedChildren property. * *

* For example, to add a new item, do as follows: *

-     *    getAuthorOrCategoryOrContributor().add(newItem);
+     *    getFeedChildren().add(newItem);
      * 
* * *

* Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link IconType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} * {@link JAXBElement }{@code <}{@link TextType }{@code >} * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link Object } * {@link JAXBElement }{@code <}{@link EntryType }{@code >} + * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link IconType }{@code >} * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link Object } + * {@link JAXBElement }{@code <}{@link TextType }{@code >} * * */ - public List getAuthorOrCategoryOrContributor() { - if (authorOrCategoryOrContributor == null) { - authorOrCategoryOrContributor = new ArrayList(); + public List getFeedChildren() { + if (feedChildren == null) { + feedChildren = new ArrayList(); } - return this.authorOrCategoryOrContributor; + return this.feedChildren; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index e38aecbba63e9..b9fef1eb50b22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -40,4 +40,13 @@ public ObjectFactory() { public AssetType createAssetType() { return new AssetType(); } + + /** + * Create an instance of {@link ODataActionType } + * + * @return a new ODataActionType instance. + */ + public ODataActionType createODataActionType() { + return new ODataActionType(); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index f107c1dd1eb5e..4d9e908eadd80 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -1,14 +1,50 @@ package com.microsoft.windowsazure.services.media.implementation; -import static org.junit.Assert.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import junit.framework.Assert; import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + public class ODataSerializationTest { + private final String sampleFeedOneAsset = "\n" + + "\n" + + " https://wamsbayclus001rest-hs.cloudapp.net/api/Assets\n" + + " Assets\n" + + " 2012-08-28T18:35:15Z\n" + + " \n" + + " \n" + + " https://wamsbayclus001rest-hs.cloudapp.net/api/Assets('nb%3Acid%3AUUID%3A1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6')\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " <updated>2012-08-28T18:35:15Z</updated>\n" + + " <author>\n" + + " <name />\n" + + " </author>\n" + + " <m:action metadata=\"https://wamsbayclus001rest-hs.cloudapp.net/api/$metadata#WindowsAzureMediaServices.Publish\" title=\"Publish\" target=\"https://wamsbayclus001rest-hs.cloudapp.net/api/Assets('nb%3Acid%3AUUID%3A1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6')/Publish\" />\n" + + " <content type=\"application/xml\">\n" + " <m:properties>\n" + + " <d:Id>nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6</d:Id>\n" + + " <d:State m:type=\"Edm.Int32\">0</d:State>\n" + + " <d:Created m:type=\"Edm.DateTime\">2012-08-28T18:34:06.123</d:Created>\n" + + " <d:LastModified m:type=\"Edm.DateTime\">2012-08-28T18:34:06.123</d:LastModified>\n" + + " <d:AlternateId m:null=\"true\" />\n" + " <d:Name>testAsset</d:Name>\n" + + " <d:Options m:type=\"Edm.Int32\">0</d:Options>\n" + " </m:properties>\n" + + " </content>\n" + " </entry>\n" + "</feed>"; + @Test - public void test() { - fail("Not yet implemented"); + public void canUnmarshallAssetFromFeed() throws Exception { + ODataAtomUnmarshaller um = new ODataAtomUnmarshaller(); + InputStream input = new ByteArrayInputStream(sampleFeedOneAsset.getBytes("UTF-8")); + ODataEntity<AssetType> entry = (ODataEntity<AssetType>) um.unmarshal(input, AssetType.class); + Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entry.getContent().getId()); } - } From 497ed36917ecb3fbe9179555edc508175edd2f1a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 18 Sep 2012 23:59:22 -0700 Subject: [PATCH 329/664] Initial commit for Asset CRUD operation unit test and rest proxy. --- .../windowsazure/services/media/Exports.java | 2 +- .../services/media/MediaContract.java | 14 +- .../MediaExceptionProcessor.java | 41 +++- .../media/implementation/MediaRestProxy.java | 34 +++ .../implementation/OAuthTokenManager.java | 11 +- .../media/models/ListAssetsOptions.java | 19 ++ .../services/media/IntegrationTestBase.java | 2 +- .../media/MediaServiceIntegrationTest.java | 198 ++++++++++++++++++ .../implementation/OAuthTokenManagerTest.java | 2 +- 9 files changed, 308 insertions(+), 15 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 791ed56f87555..cceb8d2377aa9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -27,7 +27,7 @@ public class Exports implements Builder.Exports { /** - * register the OAUTH service. + * register the Media services. */ @Override public void register(Builder.Registry registry) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 3e92ac300dae0..3fd0e8cee4033 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -14,7 +14,11 @@ */ package com.microsoft.windowsazure.services.media; +import java.util.List; + import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; /** * @@ -23,6 +27,14 @@ */ public interface MediaContract extends FilterableService<MediaContract> { - // Will fill in as we implement the various Media Services entities + public Asset createAsset(Asset asset); + + public Asset getAsset(Asset asset); + + public List<Asset> listAssets(ListAssetsOptions listAssetsOptions); + + public Asset updateAsset(Asset updatedAsset); + + public void deleteAsset(String assetId); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index d9c3141d52064..4db539dbde579 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.util.List; + import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -24,6 +26,8 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; /** * Wrapper implementation of <code>MediaServicesContract</code> that @@ -32,21 +36,21 @@ */ public class MediaExceptionProcessor implements MediaContract { - private final MediaContract next; + private final MediaContract service; static Log log = LogFactory.getLog(MediaContract.class); - public MediaExceptionProcessor(MediaContract next) { - this.next = next; + public MediaExceptionProcessor(MediaContract service) { + this.service = service; } @Inject - public MediaExceptionProcessor(MediaRestProxy next) { - this.next = next; + public MediaExceptionProcessor(MediaRestProxy service) { + this.service = service; } @Override public MediaContract withFilter(ServiceFilter filter) { - return new MediaExceptionProcessor(next.withFilter(filter)); + return new MediaExceptionProcessor(service.withFilter(filter)); } private ServiceException processCatch(ServiceException e) { @@ -54,4 +58,29 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("MediaServices", e); } + @Override + public Asset createAsset(Asset asset) { + return service.createAsset(asset); + } + + @Override + public Asset getAsset(Asset asset) { + return service.getAsset(asset); + } + + @Override + public List<Asset> listAssets(ListAssetsOptions listAssetsOptions) { + return service.listAssets(listAssetsOptions); + } + + @Override + public Asset updateAsset(Asset updatedAsset) { + return service.updateAsset(updatedAsset); + } + + @Override + public void deleteAsset(String assetId) { + service.deleteAsset(assetId); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 9b1dfc25e5a60..b94d8acc240c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,7 +15,9 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import javax.inject.Inject; @@ -25,6 +27,8 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @@ -71,4 +75,34 @@ private WebResource getResource(String entityName) { return resource; } + @Override + public Asset createAsset(Asset asset) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Asset getAsset(Asset asset) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List<Asset> listAssets(ListAssetsOptions listAssetsOptions) { + List<Asset> listAssetsResult = new ArrayList<Asset>(); + return listAssetsResult; + } + + @Override + public Asset updateAsset(Asset updatedAsset) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void deleteAsset(String assetId) { + // TODO Auto-generated method stub + + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 473bd9d60bb60..f9ad4cfc8550f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -51,24 +51,25 @@ public class OAuthTokenManager { * @param dateFactory * A <code>DateFactory</code> object instance that represents the date factory. * - * @param acsBaseUri - * A <code>URI</code> object instance that represents the ACS base URI. + * @param oAuthUri + * A <code>String</code> object instance that represents the ACS base URI. * * @param clientId * A <code>String</code> object instance that represents the client ID. * * @param clientSecret * A <code>String</code> object instance that represents the client secret. + * @throws URISyntaxException * */ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, - @Named(MediaConfiguration.OAUTH_URI) URI acsBaseUri, + @Named(MediaConfiguration.OAUTH_URI) String oAuthUri, @Named(MediaConfiguration.OAUTH_CLIENT_ID) String clientId, @Named(MediaConfiguration.OAUTH_CLIENT_SECRET) String clientSecret, - @Named(MediaConfiguration.OAUTH_SCOPE) String scope) { + @Named(MediaConfiguration.OAUTH_SCOPE) String scope) throws URISyntaxException { this.contract = contract; this.dateFactory = dateFactory; - this.acsBaseUri = acsBaseUri; + this.acsBaseUri = new URI(oAuthUri); this.clientId = clientId; this.clientSecret = clientSecret; this.scope = scope; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java new file mode 100644 index 0000000000000..fc1ea2d060245 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java @@ -0,0 +1,19 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +public class ListAssetsOptions { + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 113d1ff2b2c50..b7e735e55c30e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -5,7 +5,7 @@ import com.microsoft.windowsazure.services.core.Configuration; public abstract class IntegrationTestBase { - protected Configuration config; + protected static Configuration config; @Before public void beforeEachTest() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java new file mode 100644 index 0000000000000..a3e5a8ce01058 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -0,0 +1,198 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.Collection; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; + +public class MediaServiceIntegrationTest extends IntegrationTestBase { + private static MediaContract service; + + @BeforeClass + public static void setup() throws Exception { + // Create all test containers and their content + config = createConfig(); + service = MediaService.create(config); + List<Asset> listAssetsResult = service.listAssets(null); + for (Asset asset : listAssetsResult) { + service.deleteAsset(asset.getId()); + } + } + + @AfterClass + public static void cleanup() throws Exception { + // Configuration config = createConfiguration(); + // BlobContract service = BlobService.create(config); + + // deleteContainers(service, testContainersPrefix, testContainers); + // deleteContainers(service, createableContainersPrefix, creatableContainers); + } + + private static Configuration createConfig() { + Configuration config = Configuration.getInstance(); + overrideWithEnv(config, MediaConfiguration.URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); + return config; + } + + @Test + public void createAssetSuccess() throws Exception { + // Arrange + Asset expectedAsset = new Asset().setName("testAssetName"); + + // Act + Asset actualAsset = service.createAsset(expectedAsset); + + // Assert + assertEquals(expectedAsset, actualAsset); + } + + @Test + public void createAssetMissingNameFailed() { + // Arrange + Asset expectedAsset = new Asset(); + + // Act + Asset actualAsset = service.createAsset(expectedAsset); + + // Assert + assertTrue(false); + } + + @Test + public void getAssetSuccess() throws Exception { + // Arrange + Asset expectedAsset = new Asset(); + service.createAsset(expectedAsset); + + // Act + Asset actualAsset = service.getAsset(expectedAsset); + + // Assert + assertEquals(expectedAsset, actualAsset); + } + + @Test + public void getAssetFailedWithInvalidId() { + // Arrange + Asset expectedAsset = new Asset(); + service.createAsset(expectedAsset); + + // Act + Asset actualAsset = service.getAsset(expectedAsset.setName("IncorrectAssetName")); + + // Assert + assertTrue(false); + + } + + @Test + public void listAssetSuccess() { + // Arrange + Asset assetA = new Asset(); + Asset assetB = new Asset(); + service.createAsset(assetA); + service.createAsset(assetB); + ListAssetsOptions listAssetOptions = new ListAssetsOptions(); + + // Act + Collection<Asset> listAssetResult = service.listAssets(listAssetOptions); + // Assert + + assertEquals(2, listAssetResult.size()); + } + + @Test + public void listAssetFailed() { + // Arrange + ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); + + // Act + Collection<Asset> listAssetResult = service.listAssets(listAssetsOptions); + + // Assert + assertTrue(false); + } + + @Test + public void updateAssetSuccess() throws Exception { + // Arrange + Asset originalAsset = new Asset(); + service.createAsset(originalAsset); + Asset updatedAsset = new Asset(); + + // Act + service.updateAsset(updatedAsset); + Asset actualAsset = service.updateAsset(updatedAsset); + + // Assert + assertEquals(updatedAsset, actualAsset); + + } + + @Test + public void updateAssetFailedWithInvalidId() { + // Arrange + MediaContract service = MediaService.create(config); + Asset updatedAsset = new Asset(); + + // Act + service.updateAsset(updatedAsset); + + // Assert + assertTrue(false); + } + + @Test + public void deleteAssetSuccess() throws Exception { + // Arrange + Asset asset = new Asset(); + service.createAsset(asset); + List<Asset> listAssetsResult = service.listAssets(null); + assertEquals(1, listAssetsResult.size()); + + // Act + service.deleteAsset(asset.getId()); + + // Assert + listAssetsResult = service.listAssets(null); + assertEquals(0, listAssetsResult.size()); + } + + @Test + public void deleteAssetFailedWithInvalidId() { + // Arrange + + // Act + service.deleteAsset("invalidAssetId"); + + // Assert + assertTrue(false); + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index 2cbbc85d50854..8d6733e772a93 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -54,7 +54,7 @@ public void init() throws URISyntaxException { String accountPassword = "testpassword"; String scope = "urn:WindowsAzureMediaServices"; - client = new OAuthTokenManager(contract, dateFactory, new URI(acsBaseUri), accountName, accountPassword, scope); + client = new OAuthTokenManager(contract, dateFactory, acsBaseUri, accountName, accountPassword, scope); when(dateFactory.getDate()).thenAnswer(new Answer<Date>() { @Override From 9c146a5c7762e5aac31019e24af9e4ed06ed9243 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 19 Sep 2012 10:17:07 -0700 Subject: [PATCH 330/664] Successfully creating an asset and deserializing the response --- .../implementation/ODataAtomUnmarshaller.java | 83 +++++++++++++++- .../media/implementation/ODataEntity.java | 4 +- .../implementation/ODataEntityProvider.java | 96 +++++++++++++++++++ .../implementation/VersionHeadersFilter.java | 43 +++++++++ .../services/media/models/AssetInfo.java | 20 ++++ .../ODataSerializationFromJerseyTest.java | 70 ++++++++++++++ .../ODataSerializationTest.java | 2 +- 7 files changed, 313 insertions(+), 5 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index c5666967ac4e8..273fb8a13e1f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -16,6 +16,9 @@ package com.microsoft.windowsazure.services.media.implementation; import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; import java.util.List; import javax.xml.bind.JAXBContext; @@ -47,14 +50,84 @@ public ODataAtomUnmarshaller() throws JAXBException { mediaContentUnmarshaller = mediaContentContext.createUnmarshaller(); } - public ODataEntity<?> unmarshal(InputStream stream, Class<?> contentType) throws JAXBException { + public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) throws JAXBException { JAXBElement<FeedType> feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); FeedType feed = feedElement.getValue(); EntryType firstEntry = getFirstEntry(feed); - Object content = getEntryContent(firstEntry, contentType); + Class<?> serializationType = GetSerializationContentType(contentType); - return new ODataEntity(firstEntry, content); + Object content = getEntryContent(firstEntry, serializationType); + + try { + Constructor<?> resultCtor = contentType.getConstructor(EntryType.class, serializationType); + return (ODataEntity<?>) resultCtor.newInstance(firstEntry, content); + } + catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) throws JAXBException { + JAXBElement<EntryType> entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); + + EntryType entry = entryElement.getValue(); + + Class<?> serializationType = GetSerializationContentType(contentType); + + Object content = getEntryContent(entry, serializationType); + + try { + Constructor<?> resultCtor = contentType.getConstructor(EntryType.class, serializationType); + return (ODataEntity<?>) resultCtor.newInstance(entry, content); + } + catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; } private Object getEntryContent(EntryType entry, Class<?> contentType) throws JAXBException { @@ -116,4 +189,8 @@ private QName qnameFromElement(Element e) { return new QName(e.getLocalName(), e.getNamespaceURI()); } + private Class<?> GetSerializationContentType(Class<?> contentType) { + ParameterizedType pt = (ParameterizedType) contentType.getGenericSuperclass(); + return (Class<?>) pt.getActualTypeArguments()[0]; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 85a9fae74b1f8..ffea56d970b1e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -22,7 +22,7 @@ * access to entry and content types. * */ -public class ODataEntity<T> { +public abstract class ODataEntity<T> { private final EntryType entry; private final T content; @@ -45,4 +45,6 @@ public EntryType getEntry() { public T getContent() { return content; } + + public abstract Class<?> getJAXBContentClass(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java new file mode 100644 index 0000000000000..9fd506a764ec5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -0,0 +1,96 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; + +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; + +/** + * An implementation of {@link AbstractMessageReaderWriterProvider } that + * is used to marshal and unmarshal instances of the ODataEntity<T> type. + * + */ +public class ODataEntityProvider extends AbstractMessageReaderWriterProvider<ODataEntity<?>> { + private final ODataAtomUnmarshaller unmarshaller; + + public ODataEntityProvider() throws JAXBException { + unmarshaller = new ODataAtomUnmarshaller(); + } + + /* (non-Javadoc) + * @see javax.ws.rs.ext.MessageBodyReader#isReadable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType) + */ + @Override + public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return ODataEntity.class.isAssignableFrom(type); + } + + /* (non-Javadoc) + * @see javax.ws.rs.ext.MessageBodyReader#readFrom(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream) + */ + @Override + public ODataEntity<?> readFrom(Class<ODataEntity<?>> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + ODataEntity entity; + String responseType = mediaType.getParameters().get("type"); + try { + if (responseType.equals("entry")) { + entity = unmarshaller.unmarshalEntry(entityStream, type); + } + else { + entity = unmarshaller.unmarshalFeed(entityStream, type); + } + } + catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + + return entity; + } + + /* (non-Javadoc) + * @see javax.ws.rs.ext.MessageBodyWriter#isWriteable(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType) + */ + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return false; + } + + /* (non-Javadoc) + * @see javax.ws.rs.ext.MessageBodyWriter#writeTo(java.lang.Object, java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.OutputStream) + */ + @Override + public void writeTo(ODataEntity<?> t, Class<?> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { + // We do not support writing in this version. + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java new file mode 100644 index 0000000000000..3ff3e3e18cec8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -0,0 +1,43 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import javax.ws.rs.core.MultivaluedMap; + +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; + +/** + * A small filter that adds the required Media services/OData 3 + * version headers to the request as it goes through. + * + */ +public class VersionHeadersFilter extends ClientFilter { + + /* (non-Javadoc) + * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + */ + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + MultivaluedMap<String, Object> headers = cr.getHeaders(); + headers.add("DataServiceVersion", "3.0"); + headers.add("MaxDataServiceVersion", "3.0"); + headers.add("x-ms-version", "1.0"); + return getNext().handle(cr); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java new file mode 100644 index 0000000000000..3ce3285957a17 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -0,0 +1,20 @@ +package com.microsoft.windowsazure.services.media.models; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + +public class AssetInfo extends ODataEntity<AssetType> { + + public AssetInfo(EntryType entry, AssetType content) { + super(entry, content); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.ODataEntity#getJAXBContentClass() + */ + @Override + public Class<?> getJAXBContentClass() { + return AssetType.class; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java new file mode 100644 index 0000000000000..195c289d681d4 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -0,0 +1,70 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.HashMap; +import java.util.Map; + +import javax.ws.rs.core.MediaType; + +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.utils.DefaultDateFactory; +import com.microsoft.windowsazure.services.media.IntegrationTestBase; +import com.microsoft.windowsazure.services.media.MediaConfiguration; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.LoggingFilter; + +public class ODataSerializationFromJerseyTest extends IntegrationTestBase { + + @Test + public void canBuildJerseyClientToCreateAnAssetWhichIsProperlyDeserialized() throws Exception { + // Build a jersey client object by hand; this is working up to the + // full integration into the media services rest proxy, but we + // need to go step by step to begin. + + ClientConfig cc = new DefaultClientConfig(); + cc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); + cc.getSingletons().add(new ODataEntityProvider()); + Client c = Client.create(cc); + + c.addFilter(new LoggingFilter(System.out)); + c.addFilter(new RedirectFilter(createLocationManager())); + c.addFilter(new OAuthFilter(createTokenManager())); + c.addFilter(new VersionHeadersFilter()); + + WebResource assetResource = c.resource("Assets"); + String requestData = "{\"Name\":\"firstTestAsset\"}"; + + Map<String, String> mediaTypeParams = new HashMap<String, String>(); + //mediaTypeParams.put("type", "feed"); + MediaType acceptedType = new MediaType("application", "atom+xml", mediaTypeParams); + + AssetInfo newAsset = assetResource.type("application/json;odata=verbose").accept(acceptedType) + .post(AssetInfo.class, requestData); + + Assert.assertNotNull(newAsset); + Assert.assertEquals("firstTestAsset", newAsset.getContent().getName()); + } + + private OAuthContract createOAuthContract() { + return new OAuthRestProxy(Client.create()); + } + + private OAuthTokenManager createTokenManager() throws URISyntaxException { + return new OAuthTokenManager(createOAuthContract(), new DefaultDateFactory(), new URI( + (String) config.getProperty(MediaConfiguration.OAUTH_URI)), + (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_ID), + (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET), "urn:WindowsAzureMediaServices"); + } + + private ResourceLocationManager createLocationManager() throws URISyntaxException { + return new ResourceLocationManager((String) config.getProperty(MediaConfiguration.URI)); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 4d9e908eadd80..2da9ece8f3890 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -44,7 +44,7 @@ public class ODataSerializationTest { public void canUnmarshallAssetFromFeed() throws Exception { ODataAtomUnmarshaller um = new ODataAtomUnmarshaller(); InputStream input = new ByteArrayInputStream(sampleFeedOneAsset.getBytes("UTF-8")); - ODataEntity<AssetType> entry = (ODataEntity<AssetType>) um.unmarshal(input, AssetType.class); + ODataEntity<AssetType> entry = (ODataEntity<AssetType>) um.unmarshalFeed(input, AssetType.class); Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entry.getContent().getId()); } } From 2b096b1956ff2e9f21b56ea715f7f0a4ced1efa3 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 19 Sep 2012 10:33:20 -0700 Subject: [PATCH 331/664] Serializing request info via JAXB and JSON --- .../media/models/CreateAssetRequest.java | 38 +++++++++++++++++++ .../ODataSerializationFromJerseyTest.java | 12 ++---- 2 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java new file mode 100644 index 0000000000000..d6a7ea845f193 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java @@ -0,0 +1,38 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Serializable class containing the information needed to + * create an asset. + * + */ +@XmlRootElement +public class CreateAssetRequest { + public String Name; + + /** + * Empty constructor required by JaxB. + */ + public CreateAssetRequest() { + } + + public CreateAssetRequest(String name) { + Name = name; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 195c289d681d4..e1b1aa9e860e5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -2,8 +2,6 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; import javax.ws.rs.core.MediaType; @@ -14,6 +12,7 @@ import com.microsoft.windowsazure.services.media.IntegrationTestBase; import com.microsoft.windowsazure.services.media.MediaConfiguration; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetRequest; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; @@ -39,14 +38,11 @@ public void canBuildJerseyClientToCreateAnAssetWhichIsProperlyDeserialized() thr c.addFilter(new VersionHeadersFilter()); WebResource assetResource = c.resource("Assets"); - String requestData = "{\"Name\":\"firstTestAsset\"}"; - Map<String, String> mediaTypeParams = new HashMap<String, String>(); - //mediaTypeParams.put("type", "feed"); - MediaType acceptedType = new MediaType("application", "atom+xml", mediaTypeParams); + CreateAssetRequest requestData = new CreateAssetRequest("firstTestAsset"); - AssetInfo newAsset = assetResource.type("application/json;odata=verbose").accept(acceptedType) - .post(AssetInfo.class, requestData); + AssetInfo newAsset = assetResource.type("application/json;odata=verbose") + .accept(MediaType.APPLICATION_ATOM_XML).post(AssetInfo.class, requestData); Assert.assertNotNull(newAsset); Assert.assertEquals("firstTestAsset", newAsset.getContent().getName()); From e3047ccc6a978f464a76fb4fb02303ac3aed4ea6 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 19 Sep 2012 14:39:31 -0700 Subject: [PATCH 332/664] Hooked up create asset all the way through SDK stack --- .../windowsazure/services/media/Exports.java | 34 ++++- .../services/media/MediaContract.java | 4 +- .../MediaExceptionProcessor.java | 15 ++ .../media/implementation/MediaRestProxy.java | 17 ++- .../implementation/OAuthTokenManager.java | 7 +- .../media/implementation/ODataEntity.java | 2 - .../content}/CreateAssetRequest.java | 2 +- .../services/media/models/AssetInfo.java | 142 +++++++++++++++++- .../implementation/OAuthTokenManagerTest.java | 2 +- .../ODataSerializationFromJerseyTest.java | 20 ++- .../com.microsoft.windowsazure.properties | 7 +- 11 files changed, 231 insertions(+), 21 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{models => implementation/content}/CreateAssetRequest.java (93%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 791ed56f87555..6c24c6acf3c04 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -14,6 +14,10 @@ */ package com.microsoft.windowsazure.services.media; +import java.util.Map; + +import javax.xml.bind.JAXBException; + import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; import com.microsoft.windowsazure.services.media.implementation.MediaRestProxy; @@ -21,8 +25,12 @@ import com.microsoft.windowsazure.services.media.implementation.OAuthFilter; import com.microsoft.windowsazure.services.media.implementation.OAuthRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthTokenManager; +import com.microsoft.windowsazure.services.media.implementation.ODataEntityProvider; import com.microsoft.windowsazure.services.media.implementation.RedirectFilter; import com.microsoft.windowsazure.services.media.implementation.ResourceLocationManager; +import com.microsoft.windowsazure.services.media.implementation.VersionHeadersFilter; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.json.JSONConfiguration; public class Exports implements Builder.Exports { @@ -39,6 +47,30 @@ public void register(Builder.Registry registry) { registry.add(OAuthFilter.class); registry.add(ResourceLocationManager.class); registry.add(RedirectFilter.class); - } + registry.add(VersionHeadersFilter.class); + + registry.alter(ClientConfig.class, new Builder.Alteration<ClientConfig>() { + @Override + public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Object> properties) { + // enable this feature for unattributed json object serialization + instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); + + // Turn off auto-redirect following + instance.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); + + // add body reader/writer for ODataEntity<?> descendant classes + try { + instance.getSingletons().add(new ODataEntityProvider()); + } + catch (JAXBException e) { + // wrap in runtimeexception, we can't change the function signature + e.printStackTrace(); + throw new RuntimeException(e); + } + + return instance; + } + }); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 3e92ac300dae0..87edc01108989 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AssetInfo; /** * @@ -23,6 +25,6 @@ */ public interface MediaContract extends FilterableService<MediaContract> { - // Will fill in as we implement the various Media Services entities + AssetInfo createAsset(String name) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index d9c3141d52064..8c311f600f0e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -24,6 +24,9 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; /** * Wrapper implementation of <code>MediaServicesContract</code> that @@ -54,4 +57,16 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("MediaServices", e); } + @Override + public AssetInfo createAsset(String name) throws ServiceException { + try { + return next.createAsset(name); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 9b1dfc25e5a60..ed343220b4501 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -18,13 +18,17 @@ import java.util.Arrays; import javax.inject.Inject; +import javax.ws.rs.core.MediaType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.content.CreateAssetRequest; +import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @@ -32,15 +36,19 @@ public class MediaRestProxy implements MediaContract { private Client channel; static Log log = LogFactory.getLog(MediaContract.class); + private static final String jsonRequestType = "application/json; odata=verbose"; ServiceFilter[] filters; @Inject - public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { + public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, + VersionHeadersFilter versionHeadersFilter) { this.channel = channel; this.filters = new ServiceFilter[0]; + channel.addFilter(redirectFilter); channel.addFilter(authFilter); + channel.addFilter(versionHeadersFilter); } public MediaRestProxy(Client channel, ServiceFilter[] filters) { @@ -71,4 +79,11 @@ private WebResource getResource(String entityName) { return resource; } + @Override + public AssetInfo createAsset(String name) throws ServiceException { + WebResource resource = getResource("Assets"); + + CreateAssetRequest request = new CreateAssetRequest(name); + return resource.type(jsonRequestType).accept(MediaType.APPLICATION_ATOM_XML).post(AssetInfo.class, request); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 473bd9d60bb60..a023b4f523dba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -59,16 +59,17 @@ public class OAuthTokenManager { * * @param clientSecret * A <code>String</code> object instance that represents the client secret. + * @throws URISyntaxException * */ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, - @Named(MediaConfiguration.OAUTH_URI) URI acsBaseUri, + @Named(MediaConfiguration.OAUTH_URI) String acsBaseUri, @Named(MediaConfiguration.OAUTH_CLIENT_ID) String clientId, @Named(MediaConfiguration.OAUTH_CLIENT_SECRET) String clientSecret, - @Named(MediaConfiguration.OAUTH_SCOPE) String scope) { + @Named(MediaConfiguration.OAUTH_SCOPE) String scope) throws URISyntaxException { this.contract = contract; this.dateFactory = dateFactory; - this.acsBaseUri = acsBaseUri; + this.acsBaseUri = new URI(acsBaseUri); this.clientId = clientId; this.clientSecret = clientSecret; this.scope = scope; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index ffea56d970b1e..8b3ce69b03b5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -45,6 +45,4 @@ public EntryType getEntry() { public T getContent() { return content; } - - public abstract Class<?> getJAXBContentClass(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java index d6a7ea845f193..3286c7817ae40 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.models; +package com.microsoft.windowsazure.services.media.implementation.content; import javax.xml.bind.annotation.XmlRootElement; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 3ce3285957a17..c62eb7a53d8dd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -1,20 +1,152 @@ package com.microsoft.windowsazure.services.media.models; +import javax.xml.datatype.XMLGregorianCalendar; + import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +/** + * Data about a Media Services Asset entity. + * + */ public class AssetInfo extends ODataEntity<AssetType> { public AssetInfo(EntryType entry, AssetType content) { super(entry, content); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.ODataEntity#getJAXBContentClass() + /** + * Get the asset id + * + * @return the id + */ + public String getId() { + return getContent().getId(); + } + + /** + * Set the id + * + * @param id + * the id + */ + public void setId(String id) { + getContent().setId(id); + } + + /** + * Get the asset name + * + * @return the name + */ + public String getName() { + return this.getContent().getName(); + } + + /** + * set the name + * + * @param name + * the name + */ + public void setName(String name) { + this.getContent().setName(name); + } + + /** + * Get the asset state + * + * @return the state + */ + public int getState() { + return getContent().getState(); + } + + /** + * Set the state + * + * @param state + * the state + */ + public void setState(int state) { + getContent().setState(state); + } + + /** + * Get the creation date + * + * @return the date + */ + public XMLGregorianCalendar getCreated() { + return this.getContent().getCreated(); + } + + /** + * Set creation date + * + * @param created + * the date + * + */ + public void setCreated(XMLGregorianCalendar created) { + getContent().setCreated(created); + } + + /** + * Get last modified date + * + * @return the date + */ + public XMLGregorianCalendar getLastModified() { + return getContent().getLastModified(); + } + + /** + * Set last modified date + * + * @param lastModified + * the date + */ + public void setLastModified(XMLGregorianCalendar lastModified) { + getContent().setLastModified(lastModified); + } + + /** + * Get the alternate id + * + * @return the id + */ + public String getAlternateId() { + return getContent().getAlternateId(); + } + + /** + * Set the alternate id + * + * @param alternateId + * the id + */ + public void setAlternateId(String alternateId) { + getContent().setAlternateId(alternateId); + } + + /** + * Get the options + * + * @return the options + */ + public int getOptions() { + return getContent().getOptions(); + } + + /** + * Set the options + * + * @param options + * the options */ - @Override - public Class<?> getJAXBContentClass() { - return AssetType.class; + public void setOptions(int options) { + getContent().setOptions(options); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index 2cbbc85d50854..8d6733e772a93 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -54,7 +54,7 @@ public void init() throws URISyntaxException { String accountPassword = "testpassword"; String scope = "urn:WindowsAzureMediaServices"; - client = new OAuthTokenManager(contract, dateFactory, new URI(acsBaseUri), accountName, accountPassword, scope); + client = new OAuthTokenManager(contract, dateFactory, acsBaseUri, accountName, accountPassword, scope); when(dateFactory.getDate()).thenAnswer(new Answer<Date>() { @Override diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index e1b1aa9e860e5..2a2b52225429e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -1,6 +1,5 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.net.URI; import java.net.URISyntaxException; import javax.ws.rs.core.MediaType; @@ -11,13 +10,16 @@ import com.microsoft.windowsazure.services.core.utils.DefaultDateFactory; import com.microsoft.windowsazure.services.media.IntegrationTestBase; import com.microsoft.windowsazure.services.media.MediaConfiguration; +import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.MediaService; +import com.microsoft.windowsazure.services.media.implementation.content.CreateAssetRequest; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetRequest; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.sun.jersey.api.client.filter.LoggingFilter; +import com.sun.jersey.api.json.JSONConfiguration; public class ODataSerializationFromJerseyTest extends IntegrationTestBase { @@ -29,6 +31,7 @@ public void canBuildJerseyClientToCreateAnAssetWhichIsProperlyDeserialized() thr ClientConfig cc = new DefaultClientConfig(); cc.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); + cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); cc.getSingletons().add(new ODataEntityProvider()); Client c = Client.create(cc); @@ -45,7 +48,7 @@ public void canBuildJerseyClientToCreateAnAssetWhichIsProperlyDeserialized() thr .accept(MediaType.APPLICATION_ATOM_XML).post(AssetInfo.class, requestData); Assert.assertNotNull(newAsset); - Assert.assertEquals("firstTestAsset", newAsset.getContent().getName()); + Assert.assertEquals("firstTestAsset", newAsset.getName()); } private OAuthContract createOAuthContract() { @@ -53,8 +56,8 @@ private OAuthContract createOAuthContract() { } private OAuthTokenManager createTokenManager() throws URISyntaxException { - return new OAuthTokenManager(createOAuthContract(), new DefaultDateFactory(), new URI( - (String) config.getProperty(MediaConfiguration.OAUTH_URI)), + return new OAuthTokenManager(createOAuthContract(), new DefaultDateFactory(), + (String) config.getProperty(MediaConfiguration.OAUTH_URI), (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_ID), (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET), "urn:WindowsAzureMediaServices"); } @@ -63,4 +66,11 @@ private ResourceLocationManager createLocationManager() throws URISyntaxExceptio return new ResourceLocationManager((String) config.getProperty(MediaConfiguration.URI)); } + @Test + public void canCreateAssetThroughMediaServiceAPI() throws Exception { + MediaContract client = MediaService.create(config); + AssetInfo newAsset = client.createAsset("secondTestAsset"); + + Assert.assertEquals("secondTestAsset", newAsset.getName()); + } } diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index 7739acd3e7333..a06c02e2b8496 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -10,4 +10,9 @@ queue.accountKey=%QUEUE_ACCOUNTKEY% queue.uri=http://%QUEUE_ACCOUNTNAME%.queue.core.windows.net table.accountName=%TABLE_ACCOUNTNAME% table.accountKey=%TABLE_ACCOUNTKEY% -table.uri=http://%TABLE_ACCOUNTNAME%.table.core.windows.net \ No newline at end of file +table.uri=http://%TABLE_ACCOUNTNAME%.table.core.windows.net +media.uri=%MEDIA.URI% +oauth.uri=%OAUTH.URI% +oauth.client.id=%OAUTH.CLIENT.ID% +oauth.client.secret=%OAUTH.CLIENT.SECRET% +oauth.scope=urn:WindowsAzureMediaServices \ No newline at end of file From 1a41d4e2a06b12bb4dab5b89e33ba5d58541096c Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 19 Sep 2012 17:59:45 -0700 Subject: [PATCH 333/664] Responding to code review feedback --- .../windowsazure/services/media/Exports.java | 7 +- .../services/media/MediaConfiguration.java | 2 +- .../services/media/MediaContract.java | 2 +- .../services/media/MediaService.java | 2 +- .../media/implementation/ActiveToken.java | 2 +- .../MediaExceptionProcessor.java | 2 +- .../media/implementation/MediaRestProxy.java | 2 +- .../media/implementation/OAuthContract.java | 2 +- .../media/implementation/OAuthFilter.java | 2 +- .../media/implementation/OAuthRestProxy.java | 2 +- .../implementation/OAuthTokenManager.java | 6 +- .../implementation/OAuthTokenResponse.java | 2 +- .../implementation/ODataAtomUnmarshaller.java | 85 ++++++++++++++----- .../media/implementation/ODataEntity.java | 8 +- .../implementation/ODataEntityProvider.java | 17 ++-- .../media/implementation/RedirectFilter.java | 2 +- .../ResourceLocationManager.java | 2 +- .../implementation/VersionHeadersFilter.java | 2 +- .../implementation/content/AssetType.java | 2 +- .../implementation/content/Constants.java | 2 +- .../content/CreateAssetRequest.java | 2 +- .../content/ODataActionType.java | 2 +- .../implementation/content/ObjectFactory.java | 2 +- .../media/models/AccessPolicyPermission.java | 2 +- .../ODataSerializationFromJerseyTest.java | 15 ++++ .../ODataSerializationTest.java | 15 ++++ 26 files changed, 135 insertions(+), 56 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 6c24c6acf3c04..29f4946cc6ea5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,18 +53,15 @@ public void register(Builder.Registry registry) { @Override public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Object> properties) { - // enable this feature for unattributed json object serialization instance.getProperties().put(JSONConfiguration.FEATURE_POJO_MAPPING, true); - // Turn off auto-redirect following + // Turn off auto-follow redirects, because Media Services rest calls break if it's on instance.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); - // add body reader/writer for ODataEntity<?> descendant classes try { instance.getSingletons().add(new ODataEntityProvider()); } catch (JAXBException e) { - // wrap in runtimeexception, we can't change the function signature e.printStackTrace(); throw new RuntimeException(e); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index ac7464c570018..6821f7b10fafd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 87edc01108989..8060eceffe028 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 413dae44c8d41..9cf13258bab88 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java index e3c5561f7b77f..b38ee70871855 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 8c311f600f0e1..b68089352a8d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index ed343220b4501..cc33ecab7948d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java index 7e81549642f7e..54091fff05864 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index 3b2e45a363b67..326db58a005f6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index a51eae7e82c3b..6645d55eecdc9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index a023b4f523dba..913fe84830ce4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,13 +63,13 @@ public class OAuthTokenManager { * */ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, - @Named(MediaConfiguration.OAUTH_URI) String acsBaseUri, + @Named(MediaConfiguration.OAUTH_URI) String oauthUri, @Named(MediaConfiguration.OAUTH_CLIENT_ID) String clientId, @Named(MediaConfiguration.OAUTH_CLIENT_SECRET) String clientSecret, @Named(MediaConfiguration.OAUTH_SCOPE) String scope) throws URISyntaxException { this.contract = contract; this.dateFactory = dateFactory; - this.acsBaseUri = new URI(acsBaseUri); + this.acsBaseUri = new URI(oauthUri); this.clientId = clientId; this.clientSecret = clientSecret; this.scope = scope; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index 42974fb52e3f5..b8a357d739f95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 273fb8a13e1f0..c9952b7760868 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.w3c.dom.Element; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.FeedType; @@ -37,12 +38,20 @@ import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.ODataActionType; +/** + * This class implements unmarshalling from OData over Atom into Java + * classes. + * + */ public class ODataAtomUnmarshaller { private final JAXBContext atomContext; private final JAXBContext mediaContentContext; private final Unmarshaller atomUnmarshaller; private final Unmarshaller mediaContentUnmarshaller; + /** + * @throws JAXBException + */ public ODataAtomUnmarshaller() throws JAXBException { atomContext = JAXBContext.newInstance(FeedType.class.getPackage().getName()); atomUnmarshaller = atomContext.createUnmarshaller(); @@ -50,7 +59,23 @@ public ODataAtomUnmarshaller() throws JAXBException { mediaContentUnmarshaller = mediaContentContext.createUnmarshaller(); } - public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) throws JAXBException { + /** + * Given a stream that contains XML with an atom Feed element at the root, + * unmarshal it into Java objects with the given content type in the entries. + * + * @param stream + * - stream containing the XML data + * @param contentType + * - Java type to unmarshal the entry contents into + * @return an instance of contentType that contains the unmarshalled data. + * @throws JAXBException + * @throws ServiceException + */ + public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) throws JAXBException, + ServiceException { + validateNotNull(stream, "stream"); + validateNotNull(contentType, "contentType"); + JAXBElement<FeedType> feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); FeedType feed = feedElement.getValue(); EntryType firstEntry = getFirstEntry(feed); @@ -64,33 +89,48 @@ public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) th return (ODataEntity<?>) resultCtor.newInstance(firstEntry, content); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (InstantiationException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } - return null; } - public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) throws JAXBException { + /** + * Given a stream containing XML with an Atom entry element at the root, + * unmarshal it into an instance of contentType + * + * @param stream + * - stream containing XML data + * @param contentType + * - type of object to return + * @return An instance of contentType + * @throws JAXBException + * @throws ServiceException + */ + public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) throws JAXBException, + ServiceException { + validateNotNull(stream, "stream"); + validateNotNull(contentType, "contentType"); + JAXBElement<EntryType> entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); EntryType entry = entryElement.getValue(); @@ -104,35 +144,34 @@ public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) t return (ODataEntity<?>) resultCtor.newInstance(entry, content); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (InstantiationException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); + throw new ServiceException(e); } - return null; } private Object getEntryContent(EntryType entry, Class<?> contentType) throws JAXBException { List<Object> entryChildren = entry.getEntryChildren(); - Object retval = null; + Object retVal = null; for (int i = 0; i < entryChildren.size(); ++i) { Object child = entryChildren.get(i); @@ -140,7 +179,7 @@ private Object getEntryContent(EntryType entry, Class<?> contentType) throws JAX // It's a parsed element, if it's content unmarshal, fixup, and store return value JAXBElement e = (JAXBElement) child; if (e.getDeclaredType() == ContentType.class) { - retval = unmarshalEntryContent((ContentType) e.getValue(), contentType); + retVal = unmarshalEntryContent((ContentType) e.getValue(), contentType); } } else { @@ -153,7 +192,7 @@ private Object getEntryContent(EntryType entry, Class<?> contentType) throws JAX } } } - return retval; + return retVal; } private EntryType getFirstEntry(FeedType feed) { @@ -193,4 +232,10 @@ private Class<?> GetSerializationContentType(Class<?> contentType) { ParameterizedType pt = (ParameterizedType) contentType.getGenericSuperclass(); return (Class<?>) pt.getActualTypeArguments()[0]; } + + private static void validateNotNull(Object param, String paramName) { + if (param == null) { + throw new IllegalArgumentException(paramName); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 8b3ce69b03b5d..f2846162965a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ public abstract class ODataEntity<T> { private final EntryType entry; private final T content; - public ODataEntity(EntryType entry, T content) { + protected ODataEntity(EntryType entry, T content) { this.entry = entry; this.content = content; } @@ -35,14 +35,14 @@ public ODataEntity(EntryType entry, T content) { /** * @return the entry */ - public EntryType getEntry() { + protected EntryType getEntry() { return entry; } /** * @return the content */ - public T getContent() { + protected T getContent() { return content; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 9fd506a764ec5..e5f54fbac6113 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; /** @@ -59,15 +60,21 @@ public ODataEntity<?> readFrom(Class<ODataEntity<?>> type, Type genericType, Ann ODataEntity entity; String responseType = mediaType.getParameters().get("type"); try { - if (responseType.equals("entry")) { + if (responseType == null || responseType.equals("feed")) { + entity = unmarshaller.unmarshalFeed(entityStream, type); + } + else if (responseType.equals("entry")) { entity = unmarshaller.unmarshalEntry(entityStream, type); } else { - entity = unmarshaller.unmarshalFeed(entityStream, type); + throw new RuntimeException(); } } catch (JAXBException e) { - // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (ServiceException e) { e.printStackTrace(); throw new RuntimeException(e); } @@ -90,7 +97,7 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat public void writeTo(ODataEntity<?> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { - // We do not support writing in this version. + throw new UnsupportedOperationException(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 15b283e78f922..f71ea6381653b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 75b5c12ad6dc6..b030e6454196c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index 3ff3e3e18cec8..9b69c79942969 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 9b9cfe57aec7b..160a3088892b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java index b11c4eadf4409..0e004668e6ac8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java index 3286c7817ae40..e93c2e7f6844d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index c64e4b68178ee..b6cbb23a79b3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index b9fef1eb50b22..d353a7d006964 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java index a1abc4a25587b..b5f7dd0e88699 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 2a2b52225429e..960c76828ad51 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import java.net.URISyntaxException; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 2da9ece8f3890..215d3c33c31f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import java.io.ByteArrayInputStream; From 656421e4c707f375c58db83a2f692f6a56258c71 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 20 Sep 2012 15:00:03 -0700 Subject: [PATCH 334/664] Sending request data as XML now --- .../media/implementation/MediaRestProxy.java | 37 +++++++- .../implementation/ODataAtomMarshaller.java | 86 +++++++++++++++++++ .../ODataSerializationFromJerseyTest.java | 12 ++- .../ODataSerializationTest.java | 24 ++++++ 4 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index cc33ecab7948d..c22345c361348 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -19,6 +19,8 @@ import javax.inject.Inject; import javax.ws.rs.core.MediaType; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,14 +29,17 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.implementation.content.CreateAssetRequest; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; public class MediaRestProxy implements MediaContract { private Client channel; + private ODataAtomMarshaller marshaller; + static Log log = LogFactory.getLog(MediaContract.class); private static final String jsonRequestType = "application/json; odata=verbose"; @@ -49,11 +54,14 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red channel.addFilter(redirectFilter); channel.addFilter(authFilter); channel.addFilter(versionHeadersFilter); + + createMarshaller(); } public MediaRestProxy(Client channel, ServiceFilter[] filters) { this.channel = channel; this.filters = filters; + createMarshaller(); } @Override @@ -79,11 +87,32 @@ private WebResource getResource(String entityName) { return resource; } + private void createMarshaller() { + try { + this.marshaller = new ODataAtomMarshaller(); + } + catch (JAXBException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (ParserConfigurationException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + @Override - public AssetInfo createAsset(String name) throws ServiceException { + public AssetInfo createAsset(String name) throws ServiceException, UniformInterfaceException { WebResource resource = getResource("Assets"); - CreateAssetRequest request = new CreateAssetRequest(name); - return resource.type(jsonRequestType).accept(MediaType.APPLICATION_ATOM_XML).post(AssetInfo.class, request); + AssetType request = new AssetType(); + request.setName(name); + try { + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(AssetInfo.class, marshaller.marshalEntry(request)); + } + catch (JAXBException e) { + throw new ServiceException(e); + } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java new file mode 100644 index 0000000000000..f636b7b3498e3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -0,0 +1,86 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; + +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.FeedType; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; + +/** + * A class to manage marshalling of request parameters into + * ATOM entry elements for sending to the Media Services REST + * endpoints. + * + */ +public class ODataAtomMarshaller { + private final Marshaller marshaller; + private final DocumentBuilder documentBuilder; + + public ODataAtomMarshaller() throws JAXBException, ParserConfigurationException { + JAXBContext context = JAXBContext.newInstance(getMarshalledClasses(), null); + marshaller = context.createMarshaller(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + documentBuilder = dbf.newDocumentBuilder(); + } + + public Document marshalEntry(Object content) throws JAXBException { + ContentType atomContent = new ContentType(); + atomContent.setType("application/xml"); + atomContent.getContent().add( + new JAXBElement(new QName(Constants.ODATA_METADATA_NS, "properties"), content.getClass(), content)); + + EntryType atomEntry = new EntryType(); + atomEntry.getEntryChildren().add( + new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); + + JAXBElement<EntryType> entryElement = new JAXBElement<EntryType>(new QName(Constants.ATOM_NS, "entry"), + EntryType.class, atomEntry); + + Document doc = documentBuilder.newDocument(); + doc.setXmlStandalone(true); + + marshaller.marshal(entryElement, doc); + + return doc; + + } + + private static Class<?>[] getMarshalledClasses() { + List<Class<?>> classes = new ArrayList<Class<?>>(); + classes.add(FeedType.class); + classes.add(EntryType.class); + classes.add(AssetType.class); + return classes.toArray(new Class<?>[0]); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 960c76828ad51..7dbb9fdbff3b5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -27,7 +27,7 @@ import com.microsoft.windowsazure.services.media.MediaConfiguration; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaService; -import com.microsoft.windowsazure.services.media.implementation.content.CreateAssetRequest; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @@ -57,13 +57,17 @@ public void canBuildJerseyClientToCreateAnAssetWhichIsProperlyDeserialized() thr WebResource assetResource = c.resource("Assets"); - CreateAssetRequest requestData = new CreateAssetRequest("firstTestAsset"); + ODataAtomMarshaller m = new ODataAtomMarshaller(); + AssetType requestData = new AssetType(); + requestData.setName("firstTestAsset"); + requestData.setAlternateId("some external id"); - AssetInfo newAsset = assetResource.type("application/json;odata=verbose") - .accept(MediaType.APPLICATION_ATOM_XML).post(AssetInfo.class, requestData); + AssetInfo newAsset = assetResource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(AssetInfo.class, m.marshalEntry(requestData)); Assert.assertNotNull(newAsset); Assert.assertEquals("firstTestAsset", newAsset.getName()); + Assert.assertEquals("some external id", newAsset.getAlternateId()); } private OAuthContract createOAuthContract() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 215d3c33c31f1..51e27d89818b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -18,10 +18,15 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + import junit.framework.Assert; import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; public class ODataSerializationTest { @@ -62,4 +67,23 @@ public void canUnmarshallAssetFromFeed() throws Exception { ODataEntity<AssetType> entry = (ODataEntity<AssetType>) um.unmarshalFeed(input, AssetType.class); Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entry.getContent().getId()); } + + @Test + public void canMarshalEntryFromJavaObject() throws Exception { + AssetType a = new AssetType(); + a.setName("testNewAsset"); + a.setOptions(0); + a.setAlternateId("some other id"); + + JAXBContext context = JAXBContext.newInstance(EntryType.class, AssetType.class); + Marshaller m = context.createMarshaller(); + + EntryType e = new EntryType(); + ContentType c = new ContentType(); + c.getContent().add(a); + e.getEntryChildren().add(c); + + m.marshal(e, System.out); + + } } From 4f7dd5d71d5fe9d8f4e3ff6f26c3d73d398317a3 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 20 Sep 2012 15:03:06 -0700 Subject: [PATCH 335/664] Added doc comments --- .../media/implementation/ODataAtomMarshaller.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index f636b7b3498e3..2373660f9f452 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -54,6 +54,17 @@ public ODataAtomMarshaller() throws JAXBException, ParserConfigurationException documentBuilder = dbf.newDocumentBuilder(); } + /** + * Convert the given content object into an ATOM entry + * (represented as a DOM document) suitable for sending + * up to the Media Services service. + * + * @param content + * The content object to send + * @return The generated DOM + * @throws JAXBException + * if content is malformed/not serializable + */ public Document marshalEntry(Object content) throws JAXBException { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); From a97adf5ded972531eb404abdd43702c3392a6f58 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 20 Sep 2012 16:14:33 -0700 Subject: [PATCH 336/664] address code review feedback. --- .../media/models/AccessPolicyPermission.java | 2 +- .../services/media/models/Asset.java | 132 ------- .../services/media/models/AssetInfo.java | 289 ++++++++++++++ .../services/media/models/AssetState.java | 35 +- .../services/media/models/ContentKey.java | 117 ------ .../services/media/models/ContentKeyInfo.java | 253 ++++++++++++ .../services/media/models/ContentKeyType.java | 22 +- .../media/models/EncryptionOption.java | 22 +- .../services/media/models/File.java | 167 -------- .../services/media/models/FileInfo.java | 373 ++++++++++++++++++ .../services/media/models/Locator.java | 92 ----- .../services/media/models/LocatorInfo.java | 193 +++++++++ .../services/media/models/LocatorType.java | 27 +- .../media/models/ProtectionKeyType.java | 19 +- .../{AssetTest.java => AssetInfoTest.java} | 56 +-- ...ntKeyTest.java => ContentKeyInfoTest.java} | 41 +- .../{FileTest.java => FileInfoTest.java} | 59 +-- ...{LocatorTest.java => LocatorInfoTest.java} | 30 +- 18 files changed, 1320 insertions(+), 609 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/{AssetTest.java => AssetInfoTest.java} (60%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/{ContentKeyTest.java => ContentKeyInfoTest.java} (65%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/{FileTest.java => FileInfoTest.java} (66%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/{LocatorTest.java => LocatorInfoTest.java} (70%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java index a1abc4a25587b..b5f7dd0e88699 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java deleted file mode 100644 index be3b534bcb3d0..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -public class Asset { - private String id; - private AssetState state; - private Date created; - private Date lastModified; - private String alternateId; - private String name; - private EncryptionOption options; - private Iterable<Locator> locators; - private Iterable<ContentKey> contentKeys; - private Iterable<File> files; - private Iterable<Asset> parentAssets; - - public String getId() { - return this.id; - } - - public Asset setId(String id) { - this.id = id; - return this; - } - - public AssetState getState() { - return this.state; - } - - public Asset setState(AssetState state) { - this.state = state; - return this; - } - - public Date getCreated() { - return this.created; - } - - public Asset setCreate(Date created) { - this.created = created; - return this; - } - - public Date getLastModified() { - return this.lastModified; - } - - public Asset setLastModified(Date lastModified) { - this.lastModified = lastModified; - return this; - } - - public String getAlternateId() { - return this.alternateId; - } - - public Asset setAlternateId(String alternateId) { - this.alternateId = alternateId; - return this; - } - - public String getName() { - return this.name; - } - - public Asset setName(String name) { - this.name = name; - return this; - } - - public EncryptionOption getOptions() { - return this.options; - } - - public Asset setOptions(EncryptionOption options) { - this.options = options; - return this; - } - - public Iterable<Locator> getLocators() { - return this.locators; - } - - public Asset setLocators(Iterable<Locator> locators) { - this.locators = locators; - return this; - } - - public Iterable<ContentKey> getContentKeys() { - return this.contentKeys; - } - - public Asset setContentKeys(Iterable<ContentKey> expectedContentKeys) { - this.contentKeys = expectedContentKeys; - return this; - } - - public Iterable<File> getFiles() { - return this.files; - } - - public Asset setFiles(Iterable<File> files) { - this.files = files; - return this; - } - - public Iterable<Asset> getParentAssets() { - return this.parentAssets; - } - - public Asset setParentAssets(Iterable<Asset> parentAssets) { - this.parentAssets = parentAssets; - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java new file mode 100644 index 0000000000000..420b4a4bf66fb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -0,0 +1,289 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class AssetInfo. + */ +public class AssetInfo { + + /** The id. */ + private String id; + + /** The state. */ + private AssetState state; + + /** The created. */ + private Date created; + + /** The last modified. */ + private Date lastModified; + + /** The alternate id. */ + private String alternateId; + + /** The name. */ + private String name; + + /** The options. */ + private EncryptionOption options; + + /** The locator infos. */ + private Iterable<LocatorInfo> locatorInfos; + + /** The content key infos. */ + private Iterable<ContentKeyInfo> contentKeyInfos; + + /** The file infos. */ + private Iterable<FileInfo> fileInfos; + + /** The parent asset infos. */ + private Iterable<AssetInfo> parentAssetInfos; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the asset info + */ + public AssetInfo setId(String id) { + this.id = id; + return this; + } + + /** + * Gets the state. + * + * @return the state + */ + public AssetState getState() { + return this.state; + } + + /** + * Sets the state. + * + * @param state + * the state + * @return the asset info + */ + public AssetInfo setState(AssetState state) { + this.state = state; + return this; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return this.created; + } + + /** + * Sets the create. + * + * @param created + * the created + * @return the asset info + */ + public AssetInfo setCreate(Date created) { + this.created = created; + return this; + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return this.lastModified; + } + + /** + * Sets the last modified. + * + * @param lastModified + * the last modified + * @return the asset info + */ + public AssetInfo setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * Gets the alternate id. + * + * @return the alternate id + */ + public String getAlternateId() { + return this.alternateId; + } + + /** + * Sets the alternate id. + * + * @param alternateId + * the alternate id + * @return the asset info + */ + public AssetInfo setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the asset info + */ + public AssetInfo setName(String name) { + this.name = name; + return this; + } + + /** + * Gets the options. + * + * @return the options + */ + public EncryptionOption getOptions() { + return this.options; + } + + /** + * Sets the options. + * + * @param options + * the options + * @return the asset info + */ + public AssetInfo setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + /** + * Gets the locators. + * + * @return the locators + */ + public Iterable<LocatorInfo> getLocators() { + return this.locatorInfos; + } + + /** + * Sets the locators. + * + * @param locatorInfos + * the locator infos + * @return the asset info + */ + public AssetInfo setLocators(Iterable<LocatorInfo> locatorInfos) { + this.locatorInfos = locatorInfos; + return this; + } + + /** + * Gets the content keys. + * + * @return the content keys + */ + public Iterable<ContentKeyInfo> getContentKeys() { + return this.contentKeyInfos; + } + + /** + * Sets the content keys. + * + * @param expectedContentKeys + * the expected content keys + * @return the asset info + */ + public AssetInfo setContentKeys(Iterable<ContentKeyInfo> expectedContentKeys) { + this.contentKeyInfos = expectedContentKeys; + return this; + } + + /** + * Gets the files. + * + * @return the files + */ + public Iterable<FileInfo> getFiles() { + return this.fileInfos; + } + + /** + * Sets the files. + * + * @param fileInfos + * the file infos + * @return the asset info + */ + public AssetInfo setFiles(Iterable<FileInfo> fileInfos) { + this.fileInfos = fileInfos; + return this; + } + + /** + * Gets the parent assets. + * + * @return the parent assets + */ + public Iterable<AssetInfo> getParentAssets() { + return this.parentAssetInfos; + } + + /** + * Sets the parent assets. + * + * @param parentAssetInfos + * the parent asset infos + * @return the asset info + */ + public AssetInfo setParentAssets(Iterable<AssetInfo> parentAssetInfos) { + this.parentAssetInfos = parentAssetInfos; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java index 35a504b6da720..2e8dd175b7259 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java @@ -1,17 +1,50 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.models; /** * Specifies the states of the asset. */ public enum AssetState { - Initialized(0), Published(1), Deleted(2); + /** The Initialized. */ + Initialized(0), + /** The Published. */ + Published(1), + /** The Deleted. */ + Deleted(2); + + /** The asset state code. */ private int assetStateCode; + /** + * Instantiates a new asset state. + * + * @param assetStateCode + * the asset state code + */ private AssetState(int assetStateCode) { this.assetStateCode = assetStateCode; } + /** + * Gets the code. + * + * @return the code + */ public int getCode() { return assetStateCode; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java deleted file mode 100644 index 8ea9b530b43f6..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -public class ContentKey { - private String id; - private Date created; - private Date lastModified; - private ContentKeyType contentKeyType; - private String encryptedContentKey; - private String name; - private String protectionKeyId; - private String checkSum; - private ProtectionKeyType protectionKeyType; - - public String getId() { - return this.id; - } - - public ContentKey setId(String id) { - this.id = id; - return this; - } - - public ContentKey setCreate(Date created) { - this.created = created; - return this; - } - - public Date getLastModified() { - return this.lastModified; - } - - public ContentKey setLastModified(Date lastModified) { - this.lastModified = lastModified; - return this; - } - - public String getName() { - return this.name; - } - - public ContentKey setName(String name) { - this.name = name; - return this; - } - - public ContentKey setCheckSum(String checkSum) { - this.checkSum = checkSum; - return this; - } - - public String getCheckSum() { - return this.checkSum; - } - - public ContentKey setProtectionKeyType(ProtectionKeyType protectionKeyType) { - this.protectionKeyType = protectionKeyType; - return this; - } - - public ProtectionKeyType getProtectionKeyType() { - return this.protectionKeyType; - } - - public ContentKey setProtectionKeyId(String protectionKeyId) { - this.protectionKeyId = protectionKeyId; - return this; - } - - public String getProtectionKeyId() { - return this.protectionKeyId; - } - - public ContentKey setEncryptedContentKey(String encryptedContentKey) { - this.encryptedContentKey = encryptedContentKey; - return this; - } - - public String getEncryptedContentKey() { - return this.encryptedContentKey; - } - - public ContentKey setContentKeyType(ContentKeyType contentKeyType) { - this.contentKeyType = contentKeyType; - return this; - } - - public ContentKeyType getContentKeyType() { - return this.contentKeyType; - } - - public ContentKey setCreated(Date created) { - this.created = created; - return this; - } - - public Date getCreated() { - return this.created; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java new file mode 100644 index 0000000000000..3fbf2e76c1579 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -0,0 +1,253 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class ContentKeyInfo. + */ +public class ContentKeyInfo { + + /** The id. */ + private String id; + + /** The created. */ + private Date created; + + /** The last modified. */ + private Date lastModified; + + /** The content key type. */ + private ContentKeyType contentKeyType; + + /** The encrypted content key. */ + private String encryptedContentKey; + + /** The name. */ + private String name; + + /** The protection key id. */ + private String protectionKeyId; + + /** The check sum. */ + private String checkSum; + + /** The protection key type. */ + private ProtectionKeyType protectionKeyType; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the content key info + */ + public ContentKeyInfo setId(String id) { + this.id = id; + return this; + } + + /** + * Sets the create. + * + * @param created + * the created + * @return the content key info + */ + public ContentKeyInfo setCreate(Date created) { + this.created = created; + return this; + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return this.lastModified; + } + + /** + * Sets the last modified. + * + * @param lastModified + * the last modified + * @return the content key info + */ + public ContentKeyInfo setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the content key info + */ + public ContentKeyInfo setName(String name) { + this.name = name; + return this; + } + + /** + * Sets the check sum. + * + * @param checkSum + * the check sum + * @return the content key info + */ + public ContentKeyInfo setCheckSum(String checkSum) { + this.checkSum = checkSum; + return this; + } + + /** + * Gets the check sum. + * + * @return the check sum + */ + public String getCheckSum() { + return this.checkSum; + } + + /** + * Sets the protection key type. + * + * @param protectionKeyType + * the protection key type + * @return the content key info + */ + public ContentKeyInfo setProtectionKeyType(ProtectionKeyType protectionKeyType) { + this.protectionKeyType = protectionKeyType; + return this; + } + + /** + * Gets the protection key type. + * + * @return the protection key type + */ + public ProtectionKeyType getProtectionKeyType() { + return this.protectionKeyType; + } + + /** + * Sets the protection key id. + * + * @param protectionKeyId + * the protection key id + * @return the content key info + */ + public ContentKeyInfo setProtectionKeyId(String protectionKeyId) { + this.protectionKeyId = protectionKeyId; + return this; + } + + /** + * Gets the protection key id. + * + * @return the protection key id + */ + public String getProtectionKeyId() { + return this.protectionKeyId; + } + + /** + * Sets the encrypted content key. + * + * @param encryptedContentKey + * the encrypted content key + * @return the content key info + */ + public ContentKeyInfo setEncryptedContentKey(String encryptedContentKey) { + this.encryptedContentKey = encryptedContentKey; + return this; + } + + /** + * Gets the encrypted content key. + * + * @return the encrypted content key + */ + public String getEncryptedContentKey() { + return this.encryptedContentKey; + } + + /** + * Sets the content key type. + * + * @param contentKeyType + * the content key type + * @return the content key info + */ + public ContentKeyInfo setContentKeyType(ContentKeyType contentKeyType) { + this.contentKeyType = contentKeyType; + return this; + } + + /** + * Gets the content key type. + * + * @return the content key type + */ + public ContentKeyType getContentKeyType() { + return this.contentKeyType; + } + + /** + * Sets the created. + * + * @param created + * the created + * @return the content key info + */ + public ContentKeyInfo setCreated(Date created) { + this.created = created; + return this; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return this.created; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java index 1a7bc64e9d565..5bfaf65f9030e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,32 @@ * */ public enum ContentKeyType { - CommonEncryption(0), StorageEncryption(1), ConfigurationEncryption(2); + /** The Common encryption. */ + CommonEncryption(0), + /** The Storage encryption. */ + StorageEncryption(1), + /** The Configuration encryption. */ + ConfigurationEncryption(2); + + /** The content key type code. */ private int contentKeyTypeCode; + /** + * Instantiates a new content key type. + * + * @param contentKeyTypeCode + * the content key type code + */ private ContentKeyType(int contentKeyTypeCode) { this.contentKeyTypeCode = contentKeyTypeCode; } + /** + * Gets the code. + * + * @return the code + */ public int getCode() { return contentKeyTypeCode; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java index 9e98aecb69aab..7eb929ac60927 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,32 @@ * Specifies the options for encryption. */ public enum EncryptionOption { - None(0), StorageEncrypted(1), CommonEncryptionProtected(2); + /** The None. */ + None(0), + /** The Storage encrypted. */ + StorageEncrypted(1), + /** The Common encryption protected. */ + CommonEncryptionProtected(2); + + /** The encryption option code. */ private int encryptionOptionCode; + /** + * Instantiates a new encryption option. + * + * @param encryptionOptionCode + * the encryption option code + */ private EncryptionOption(int encryptionOptionCode) { this.encryptionOptionCode = encryptionOptionCode; } + /** + * Gets the code. + * + * @return the code + */ public int getCode() { return encryptionOptionCode; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java deleted file mode 100644 index f171d4a1fe576..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/File.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -public class File { - private String id; - private String name; - private int contentFileSize; - private String parentAssetId; - private String encryptionVersion; - private String encryptionScheme; - private Boolean isEncrypted; - private String encryptionKeyId; - private String initializationVector; - private Boolean isPrimary; - private Date lastModified; - private Date created; - private String mimeType; - private String contentChecksum; - - public String getId() { - return this.id; - } - - public File setId(String id) { - this.id = id; - return this; - } - - public String getName() { - return this.name; - } - - public File setName(String name) { - this.name = name; - return this; - } - - public int getContentFileSize() { - return this.contentFileSize; - } - - public File setContentFileSize(int contentFileSize) { - this.contentFileSize = contentFileSize; - return this; - } - - public String getParentAssetId() { - return this.parentAssetId; - } - - public File setParentAssetId(String parentAssetId) { - this.parentAssetId = parentAssetId; - return this; - } - - public Date getCreated() { - return this.created; - } - - public File setCreate(Date created) { - this.created = created; - return this; - } - - public Date getLastModified() { - return this.lastModified; - } - - public File setLastModified(Date lastModified) { - this.lastModified = lastModified; - return this; - } - - public File setEncryptionVersion(String encryptionVersion) { - this.encryptionVersion = encryptionVersion; - return this; - } - - public String getEncryptionVersion() { - return this.encryptionVersion; - } - - public File setEncryptionScheme(String encryptionScheme) { - this.encryptionScheme = encryptionScheme; - return this; - } - - public String getEncryptionScheme() { - return this.encryptionScheme; - } - - public File setIsEncrypted(Boolean isEncrypted) { - this.isEncrypted = isEncrypted; - return this; - } - - public Boolean getIsEncrypted() { - return this.isEncrypted; - } - - public File setEncryptionKeyId(String encryptionKeyId) { - this.encryptionKeyId = encryptionKeyId; - return this; - } - - public String getEncryptionKeyId() { - return this.encryptionKeyId; - } - - public File setInitializationVector(String expectedInitializationVector) { - this.initializationVector = expectedInitializationVector; - return this; - } - - public String getInitializationVector() { - return this.initializationVector; - } - - public File setIsPrimary(Boolean isPrimary) { - this.isPrimary = isPrimary; - return this; - } - - public Boolean getIsPrimary() { - return this.isPrimary; - } - - public File setCreated(Date created) { - this.created = created; - return this; - } - - public File setMimeType(String mimeType) { - this.mimeType = mimeType; - return this; - } - - public String getMimeType() { - return this.mimeType; - } - - public File setContentChecksum(String contentChecksum) { - this.contentChecksum = contentChecksum; - return this; - } - - public String getContentChecksum() { - return this.contentChecksum; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java new file mode 100644 index 0000000000000..9585a76233a67 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java @@ -0,0 +1,373 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class FileInfo. + */ +public class FileInfo { + + /** The id. */ + private String id; + + /** The name. */ + private String name; + + /** The content file size. */ + private int contentFileSize; + + /** The parent asset id. */ + private String parentAssetId; + + /** The encryption version. */ + private String encryptionVersion; + + /** The encryption scheme. */ + private String encryptionScheme; + + /** The is encrypted. */ + private Boolean isEncrypted; + + /** The encryption key id. */ + private String encryptionKeyId; + + /** The initialization vector. */ + private String initializationVector; + + /** The is primary. */ + private Boolean isPrimary; + + /** The last modified. */ + private Date lastModified; + + /** The created. */ + private Date created; + + /** The mime type. */ + private String mimeType; + + /** The content checksum. */ + private String contentChecksum; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the file info + */ + public FileInfo setId(String id) { + this.id = id; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the file info + */ + public FileInfo setName(String name) { + this.name = name; + return this; + } + + /** + * Gets the content file size. + * + * @return the content file size + */ + public int getContentFileSize() { + return this.contentFileSize; + } + + /** + * Sets the content file size. + * + * @param contentFileSize + * the content file size + * @return the file info + */ + public FileInfo setContentFileSize(int contentFileSize) { + this.contentFileSize = contentFileSize; + return this; + } + + /** + * Gets the parent asset id. + * + * @return the parent asset id + */ + public String getParentAssetId() { + return this.parentAssetId; + } + + /** + * Sets the parent asset id. + * + * @param parentAssetId + * the parent asset id + * @return the file info + */ + public FileInfo setParentAssetId(String parentAssetId) { + this.parentAssetId = parentAssetId; + return this; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return this.created; + } + + /** + * Sets the create. + * + * @param created + * the created + * @return the file info + */ + public FileInfo setCreate(Date created) { + this.created = created; + return this; + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return this.lastModified; + } + + /** + * Sets the last modified. + * + * @param lastModified + * the last modified + * @return the file info + */ + public FileInfo setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * Sets the encryption version. + * + * @param encryptionVersion + * the encryption version + * @return the file info + */ + public FileInfo setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + /** + * Gets the encryption version. + * + * @return the encryption version + */ + public String getEncryptionVersion() { + return this.encryptionVersion; + } + + /** + * Sets the encryption scheme. + * + * @param encryptionScheme + * the encryption scheme + * @return the file info + */ + public FileInfo setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + /** + * Gets the encryption scheme. + * + * @return the encryption scheme + */ + public String getEncryptionScheme() { + return this.encryptionScheme; + } + + /** + * Sets the is encrypted. + * + * @param isEncrypted + * the is encrypted + * @return the file info + */ + public FileInfo setIsEncrypted(Boolean isEncrypted) { + this.isEncrypted = isEncrypted; + return this; + } + + /** + * Gets the checks if is encrypted. + * + * @return the checks if is encrypted + */ + public Boolean getIsEncrypted() { + return this.isEncrypted; + } + + /** + * Sets the encryption key id. + * + * @param encryptionKeyId + * the encryption key id + * @return the file info + */ + public FileInfo setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + /** + * Gets the encryption key id. + * + * @return the encryption key id + */ + public String getEncryptionKeyId() { + return this.encryptionKeyId; + } + + /** + * Sets the initialization vector. + * + * @param expectedInitializationVector + * the expected initialization vector + * @return the file info + */ + public FileInfo setInitializationVector(String expectedInitializationVector) { + this.initializationVector = expectedInitializationVector; + return this; + } + + /** + * Gets the initialization vector. + * + * @return the initialization vector + */ + public String getInitializationVector() { + return this.initializationVector; + } + + /** + * Sets the is primary. + * + * @param isPrimary + * the is primary + * @return the file info + */ + public FileInfo setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + return this; + } + + /** + * Gets the checks if is primary. + * + * @return the checks if is primary + */ + public Boolean getIsPrimary() { + return this.isPrimary; + } + + /** + * Sets the created. + * + * @param created + * the created + * @return the file info + */ + public FileInfo setCreated(Date created) { + this.created = created; + return this; + } + + /** + * Sets the mime type. + * + * @param mimeType + * the mime type + * @return the file info + */ + public FileInfo setMimeType(String mimeType) { + this.mimeType = mimeType; + return this; + } + + /** + * Gets the mime type. + * + * @return the mime type + */ + public String getMimeType() { + return this.mimeType; + } + + /** + * Sets the content checksum. + * + * @param contentChecksum + * the content checksum + * @return the file info + */ + public FileInfo setContentChecksum(String contentChecksum) { + this.contentChecksum = contentChecksum; + return this; + } + + /** + * Gets the content checksum. + * + * @return the content checksum + */ + public String getContentChecksum() { + return this.contentChecksum; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java deleted file mode 100644 index 2cfa54e1a429d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -public class Locator { - private String id; - private Date expirationDatetime; - private String path; - private String accessPolicyId; - private String assetId; - private Date startTime; - private LocatorType locatorType; - - public String getId() { - return this.id; - } - - public Locator setId(String id) { - this.id = id; - return this; - } - - public Locator setExpirationDateTime(Date expirationDateTime) { - this.expirationDatetime = expirationDateTime; - return this; - } - - public Date getExpirationDateTime() { - return this.expirationDatetime; - } - - public Locator setLocatorType(LocatorType locatorType) { - this.locatorType = locatorType; - return this; - } - - public LocatorType getLocatorType() { - return this.locatorType; - } - - public Locator setPath(String path) { - this.path = path; - return this; - } - - public String getPath() { - return this.path; - } - - public Locator setAccessPolicyId(String accessPolicyId) { - this.accessPolicyId = accessPolicyId; - return this; - } - - public String getAccessPolicyId() { - return this.accessPolicyId; - } - - public Locator setAssetId(String assetId) { - this.assetId = assetId; - return this; - } - - public String getAssetId() { - return this.assetId; - } - - public Locator setStartTime(Date startTime) { - this.startTime = startTime; - return this; - } - - public Date getStartTime() { - return this.startTime; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java new file mode 100644 index 0000000000000..c90c38aba3e85 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -0,0 +1,193 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class LocatorInfo. + */ +public class LocatorInfo { + + /** The id. */ + private String id; + + /** The expiration datetime. */ + private Date expirationDatetime; + + /** The path. */ + private String path; + + /** The access policy id. */ + private String accessPolicyId; + + /** The asset id. */ + private String assetId; + + /** The start time. */ + private Date startTime; + + /** The locator type. */ + private LocatorType locatorType; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the locator info + */ + public LocatorInfo setId(String id) { + this.id = id; + return this; + } + + /** + * Sets the expiration date time. + * + * @param expirationDateTime + * the expiration date time + * @return the locator info + */ + public LocatorInfo setExpirationDateTime(Date expirationDateTime) { + this.expirationDatetime = expirationDateTime; + return this; + } + + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return this.expirationDatetime; + } + + /** + * Sets the locator type. + * + * @param locatorType + * the locator type + * @return the locator info + */ + public LocatorInfo setLocatorType(LocatorType locatorType) { + this.locatorType = locatorType; + return this; + } + + /** + * Gets the locator type. + * + * @return the locator type + */ + public LocatorType getLocatorType() { + return this.locatorType; + } + + /** + * Sets the path. + * + * @param path + * the path + * @return the locator info + */ + public LocatorInfo setPath(String path) { + this.path = path; + return this; + } + + /** + * Gets the path. + * + * @return the path + */ + public String getPath() { + return this.path; + } + + /** + * Sets the access policy id. + * + * @param accessPolicyId + * the access policy id + * @return the locator info + */ + public LocatorInfo setAccessPolicyId(String accessPolicyId) { + this.accessPolicyId = accessPolicyId; + return this; + } + + /** + * Gets the access policy id. + * + * @return the access policy id + */ + public String getAccessPolicyId() { + return this.accessPolicyId; + } + + /** + * Sets the asset id. + * + * @param assetId + * the asset id + * @return the locator info + */ + public LocatorInfo setAssetId(String assetId) { + this.assetId = assetId; + return this; + } + + /** + * Gets the asset id. + * + * @return the asset id + */ + public String getAssetId() { + return this.assetId; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the locator info + */ + public LocatorInfo setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return this.startTime; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index ef74b364fa655..3cc4a583b151d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,38 @@ package com.microsoft.windowsazure.services.media.models; +/** + * The Enum LocatorType. + */ public enum LocatorType { - None(0), SAS(1), Origin(2), WindowsAzureCDN(3); + /** The None. */ + None(0), + /** The sas. */ + SAS(1), + /** The Origin. */ + Origin(2), + /** The Windows azure cdn. */ + WindowsAzureCDN(3); + + /** The locator type code. */ private int locatorTypeCode; + /** + * Instantiates a new locator type. + * + * @param locatorTypeCode + * the locator type code + */ private LocatorType(int locatorTypeCode) { this.locatorTypeCode = locatorTypeCode; } + /** + * Gets the code. + * + * @return the code + */ public int getCode() { return this.locatorTypeCode; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java index 88f0099e20bd9..e0ddb7911c4d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,32 @@ package com.microsoft.windowsazure.services.media.models; +/** + * The Enum ProtectionKeyType. + */ public enum ProtectionKeyType { + + /** The X509 certificate thumbprint. */ X509CertificateThumbprint(0); + /** The protection key type code. */ private int protectionKeyTypeCode; + /** + * Instantiates a new protection key type. + * + * @param protectionKeyTypeCode + * the protection key type code + */ private ProtectionKeyType(int protectionKeyTypeCode) { this.protectionKeyTypeCode = protectionKeyTypeCode; } + /** + * Gets the code. + * + * @return the code + */ public int getCode() { return protectionKeyTypeCode; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java similarity index 60% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index d622d9473bb04..a1222e83d5234 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +21,16 @@ import org.junit.Test; -public class AssetTest { +public class AssetInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "expectedId"; - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - String actualId = asset.setId(expectedId).getId(); + String actualId = assetInfo.setId(expectedId).getId(); // Assert assertEquals(expectedId, actualId); @@ -41,10 +41,10 @@ public void testGetSetId() { public void testGetSetState() { // Arrange AssetState expectedState = AssetState.Published; - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - AssetState actualState = asset.setState(expectedState).getState(); + AssetState actualState = assetInfo.setState(expectedState).getState(); // Assert assertEquals(expectedState, actualState); @@ -54,10 +54,10 @@ public void testGetSetState() { public void testGetSetCreated() { // Arrange Date expectedCreated = new Date(); - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - Date actualCreated = asset.setCreate(expectedCreated).getCreated(); + Date actualCreated = assetInfo.setCreate(expectedCreated).getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -68,10 +68,10 @@ public void testGetSetCreated() { public void testGetSetLastModified() { // Arrange Date expectedLastModified = new Date(); - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - Date actualLastModified = asset.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = assetInfo.setLastModified(expectedLastModified).getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); @@ -81,10 +81,10 @@ public void testGetSetLastModified() { public void testGetSetAlternateId() { // Arrange String expectedAlternateId = "testAlternateId"; - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - String actualAlternateId = asset.setAlternateId(expectedAlternateId).getAlternateId(); + String actualAlternateId = assetInfo.setAlternateId(expectedAlternateId).getAlternateId(); // Assert assertEquals(expectedAlternateId, actualAlternateId); @@ -94,10 +94,10 @@ public void testGetSetAlternateId() { public void testGetSetName() { // Arrange String expectedName = "testName"; - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - String actualName = asset.setName(expectedName).getName(); + String actualName = assetInfo.setName(expectedName).getName(); // Assert assertEquals(expectedName, actualName); @@ -107,10 +107,10 @@ public void testGetSetName() { public void testGetSetOptions() { // Arrange EncryptionOption expectedOptions = EncryptionOption.None; - Asset asset = new Asset(); + AssetInfo assetInfo = new AssetInfo(); // Act - EncryptionOption actualOptions = asset.setOptions(expectedOptions).getOptions(); + EncryptionOption actualOptions = assetInfo.setOptions(expectedOptions).getOptions(); // Assert assertEquals(expectedOptions, actualOptions); @@ -119,11 +119,11 @@ public void testGetSetOptions() { @Test public void testGetSetLocators() { // Arrange - Iterable<Locator> expectedLocators = new ArrayList<Locator>(); - Asset asset = new Asset(); + Iterable<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); + AssetInfo assetInfo = new AssetInfo(); // Act - Iterable<Locator> actualLocators = asset.setLocators(expectedLocators).getLocators(); + Iterable<LocatorInfo> actualLocators = assetInfo.setLocators(expectedLocators).getLocators(); // Assert assertEquals(expectedLocators, actualLocators); @@ -132,11 +132,11 @@ public void testGetSetLocators() { @Test public void testGetSetContentKeys() { // Arrange - Iterable<ContentKey> expectedContentKeys = new ArrayList<ContentKey>(); - Asset asset = new Asset(); + Iterable<ContentKeyInfo> expectedContentKeys = new ArrayList<ContentKeyInfo>(); + AssetInfo assetInfo = new AssetInfo(); // Act - Iterable<ContentKey> actualContentKeys = asset.setContentKeys(expectedContentKeys).getContentKeys(); + Iterable<ContentKeyInfo> actualContentKeys = assetInfo.setContentKeys(expectedContentKeys).getContentKeys(); // Assert assertEquals(expectedContentKeys, actualContentKeys); @@ -145,11 +145,11 @@ public void testGetSetContentKeys() { @Test public void testGetSetFiles() { // Arrange - Iterable<File> expectedFiles = new ArrayList<File>(); - Asset asset = new Asset(); + Iterable<FileInfo> expectedFiles = new ArrayList<FileInfo>(); + AssetInfo assetInfo = new AssetInfo(); // Act - Iterable<File> actualFiles = asset.setFiles(expectedFiles).getFiles(); + Iterable<FileInfo> actualFiles = assetInfo.setFiles(expectedFiles).getFiles(); // Assert assertEquals(expectedFiles, actualFiles); @@ -158,11 +158,11 @@ public void testGetSetFiles() { @Test public void testGetSetParentAsset() { // Arrange - Iterable<Asset> expectedParentAssets = new ArrayList<Asset>(); - Asset asset = new Asset(); + Iterable<AssetInfo> expectedParentAssets = new ArrayList<AssetInfo>(); + AssetInfo asset = new AssetInfo(); // Act - Iterable<Asset> actualAssets = asset.setParentAssets(expectedParentAssets).getParentAssets(); + Iterable<AssetInfo> actualAssets = asset.setParentAssets(expectedParentAssets).getParentAssets(); // Assert assertEquals(expectedParentAssets, actualAssets); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java similarity index 65% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index a2cf7644b10db..eddd15aad4e1f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +20,16 @@ import org.junit.Test; -public class ContentKeyTest { +public class ContentKeyInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "expectedId"; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualId = contentKey.setId(expectedId).getId(); + String actualId = contentKeyInfo.setId(expectedId).getId(); // Assert assertEquals(expectedId, actualId); @@ -39,10 +39,10 @@ public void testGetSetId() { public void testGetSetCreated() { // Arrange Date expectedCreated = new Date(); - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - Date actualCreated = contentKey.setCreated(expectedCreated).getCreated(); + Date actualCreated = contentKeyInfo.setCreated(expectedCreated).getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -52,10 +52,10 @@ public void testGetSetCreated() { public void testGetSetLastModified() { // Arrange Date expectedLastModified = new Date(); - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - Date actualLastModified = contentKey.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = contentKeyInfo.setLastModified(expectedLastModified).getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); @@ -65,10 +65,11 @@ public void testGetSetLastModified() { public void testGetSetContentKeyType() { // Arrange ContentKeyType expectedContentKeyType = ContentKeyType.ConfigurationEncryption; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - ContentKeyType actualContentKeyType = contentKey.setContentKeyType(expectedContentKeyType).getContentKeyType(); + ContentKeyType actualContentKeyType = contentKeyInfo.setContentKeyType(expectedContentKeyType) + .getContentKeyType(); // Assert assertEquals(expectedContentKeyType, actualContentKeyType); @@ -79,10 +80,10 @@ public void testGetSetContentKeyType() { public void testGetSetEncryptedContentKey() { // Arrange String expectedEncryptedContentKey = "testX509Certificate"; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualEncryptedContentKey = contentKey.setEncryptedContentKey(expectedEncryptedContentKey) + String actualEncryptedContentKey = contentKeyInfo.setEncryptedContentKey(expectedEncryptedContentKey) .getEncryptedContentKey(); // Assert @@ -93,10 +94,10 @@ public void testGetSetEncryptedContentKey() { public void testGetSetName() { // Arrange String expectedName = "expectedName"; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualName = contentKey.setName(expectedName).getName(); + String actualName = contentKeyInfo.setName(expectedName).getName(); // Assert assertEquals(expectedName, actualName); @@ -106,10 +107,10 @@ public void testGetSetName() { public void testGetSetProtectionKeyId() { // Arrange String expectedProtectionKeyId = "expectedProtectionKeyId"; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualProtectionKeyId = contentKey.setProtectionKeyId(expectedProtectionKeyId).getProtectionKeyId(); + String actualProtectionKeyId = contentKeyInfo.setProtectionKeyId(expectedProtectionKeyId).getProtectionKeyId(); // Assert assertEquals(expectedProtectionKeyId, actualProtectionKeyId); @@ -120,10 +121,10 @@ public void testGetSetProtectionKeyId() { public void testGetSetProtectionKeyType() { // Arrange ProtectionKeyType expectedProtectionKeyType = ProtectionKeyType.X509CertificateThumbprint; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - ProtectionKeyType actualProtectionKeyType = contentKey.setProtectionKeyType(expectedProtectionKeyType) + ProtectionKeyType actualProtectionKeyType = contentKeyInfo.setProtectionKeyType(expectedProtectionKeyType) .getProtectionKeyType(); // Assert @@ -134,10 +135,10 @@ public void testGetSetProtectionKeyType() { public void testGetSetCheckSum() { // Arrange String expectedCheckSum = "testCheckSum"; - ContentKey contentKey = new ContentKey(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualCheckSum = contentKey.setCheckSum(expectedCheckSum).getCheckSum(); + String actualCheckSum = contentKeyInfo.setCheckSum(expectedCheckSum).getCheckSum(); // Assert assertEquals(expectedCheckSum, actualCheckSum); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java similarity index 66% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java index 3a4a760cdbacd..3e32e0626a7ab 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ import org.junit.Test; -public class FileTest { +public class FileInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "testId"; - File file = new File(); + FileInfo file = new FileInfo(); // Act String actualId = file.setId(expectedId).getId(); @@ -39,10 +39,10 @@ public void testGetSetId() { public void testGetSetName() { // Arrange String expectedName = "testName"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualName = file.setName(expectedName).getName(); + String actualName = fileInfo.setName(expectedName).getName(); // Assert assertEquals(expectedName, actualName); @@ -52,10 +52,10 @@ public void testGetSetName() { public void testGetSetContentFileSize() { // Arrange int expectedContentFileSize = 1234; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - int actualContentFileSize = file.setContentFileSize(expectedContentFileSize).getContentFileSize(); + int actualContentFileSize = fileInfo.setContentFileSize(expectedContentFileSize).getContentFileSize(); // Assert assertEquals(expectedContentFileSize, actualContentFileSize); @@ -66,10 +66,10 @@ public void testGetSetContentFileSize() { public void testGetSetParentAssetId() { // Arrange String expectedParentAssetId = "testParentAssetId"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualParentAssetId = file.setParentAssetId(expectedParentAssetId).getParentAssetId(); + String actualParentAssetId = fileInfo.setParentAssetId(expectedParentAssetId).getParentAssetId(); // Assert assertEquals(expectedParentAssetId, actualParentAssetId); @@ -79,10 +79,11 @@ public void testGetSetParentAssetId() { public void testGetSetEncryptionVersion() { // Arrange String expectedEncryptionVersion = "testEncryptionVersion"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualEncryptionVersion = file.setEncryptionVersion(expectedEncryptionVersion).getEncryptionVersion(); + String actualEncryptionVersion = fileInfo.setEncryptionVersion(expectedEncryptionVersion) + .getEncryptionVersion(); // Assert assertEquals(expectedEncryptionVersion, actualEncryptionVersion); @@ -92,10 +93,10 @@ public void testGetSetEncryptionVersion() { public void testGetSetEncryptionScheme() { // Arrange String expectedEncryptionScheme = "testEncryptionScheme"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualEncryptionScheme = file.setEncryptionScheme(expectedEncryptionScheme).getEncryptionScheme(); + String actualEncryptionScheme = fileInfo.setEncryptionScheme(expectedEncryptionScheme).getEncryptionScheme(); // Assert assertEquals(expectedEncryptionScheme, actualEncryptionScheme); @@ -105,10 +106,10 @@ public void testGetSetEncryptionScheme() { public void testGetSetIsEncrypted() { // Arrange Boolean expectedIsEncrypted = true; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - Boolean actualIsEncrypted = file.setIsEncrypted(expectedIsEncrypted).getIsEncrypted(); + Boolean actualIsEncrypted = fileInfo.setIsEncrypted(expectedIsEncrypted).getIsEncrypted(); // Assert assertEquals(expectedIsEncrypted, actualIsEncrypted); @@ -118,10 +119,10 @@ public void testGetSetIsEncrypted() { public void testGetSetEncryptionKeyId() { // Arrange String expectedEncryptionKeyId = "testEncryptionKeyId"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualEncryptionKeyId = file.setEncryptionKeyId(expectedEncryptionKeyId).getEncryptionKeyId(); + String actualEncryptionKeyId = fileInfo.setEncryptionKeyId(expectedEncryptionKeyId).getEncryptionKeyId(); // Assert assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); @@ -131,10 +132,10 @@ public void testGetSetEncryptionKeyId() { public void testGetSetInitializationVector() { // Arrange String expectedInitializationVector = "testInitializationVector"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualInitializationVector = file.setInitializationVector(expectedInitializationVector) + String actualInitializationVector = fileInfo.setInitializationVector(expectedInitializationVector) .getInitializationVector(); // Assert @@ -146,10 +147,10 @@ public void testGetSetInitializationVector() { public void testGetSetIsPrimary() { // Arrange Boolean expectedIsPrimary = true; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - Boolean actualIsPrimary = file.setIsPrimary(expectedIsPrimary).getIsPrimary(); + Boolean actualIsPrimary = fileInfo.setIsPrimary(expectedIsPrimary).getIsPrimary(); // Assert assertEquals(expectedIsPrimary, actualIsPrimary); @@ -159,10 +160,10 @@ public void testGetSetIsPrimary() { public void testGetSetLastModified() { // Arrange Date expectedLastModified = new Date(); - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - Date actualLastModified = file.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = fileInfo.setLastModified(expectedLastModified).getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); @@ -172,10 +173,10 @@ public void testGetSetLastModified() { public void testGetSetCreated() { // Arrange Date expectedCreated = new Date(); - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - Date actualCreated = file.setCreated(expectedCreated).getCreated(); + Date actualCreated = fileInfo.setCreated(expectedCreated).getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -185,10 +186,10 @@ public void testGetSetCreated() { public void testGetSetMimeType() { // Arrange String expectedMimeType = "testMimeType"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualMimeType = file.setMimeType(expectedMimeType).getMimeType(); + String actualMimeType = fileInfo.setMimeType(expectedMimeType).getMimeType(); // Assert assertEquals(expectedMimeType, actualMimeType); @@ -198,10 +199,10 @@ public void testGetSetMimeType() { public void testGetSetContentChecksum() { // Arrange String expectedContentChecksum = "testContentChecksum"; - File file = new File(); + FileInfo fileInfo = new FileInfo(); // Act - String actualContentChecksum = file.setContentChecksum(expectedContentChecksum).getContentChecksum(); + String actualContentChecksum = fileInfo.setContentChecksum(expectedContentChecksum).getContentChecksum(); // Assert assertEquals(expectedContentChecksum, actualContentChecksum); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java similarity index 70% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index c4c0da8c02f4e..c749bd1b23cb5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ import org.junit.Test; -public class LocatorTest { +public class LocatorInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "testId"; - Locator locator = new Locator(); + LocatorInfo locator = new LocatorInfo(); // Act String actualId = locator.setId(expectedId).getId(); @@ -39,10 +39,10 @@ public void testGetSetId() { public void testGetSetExpirationDateTime() { // Arrange Date expectedExpirationDateTime = new Date(); - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - Date actualExpirationDateTime = locator.setExpirationDateTime(expectedExpirationDateTime) + Date actualExpirationDateTime = locatorInfo.setExpirationDateTime(expectedExpirationDateTime) .getExpirationDateTime(); // Assert @@ -53,10 +53,10 @@ public void testGetSetExpirationDateTime() { public void testGetSetType() { // Arrange LocatorType expectedLocatorType = LocatorType.WindowsAzureCDN; - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - LocatorType actualLocatorType = locator.setLocatorType(expectedLocatorType).getLocatorType(); + LocatorType actualLocatorType = locatorInfo.setLocatorType(expectedLocatorType).getLocatorType(); // Assert assertEquals(expectedLocatorType, actualLocatorType); @@ -66,10 +66,10 @@ public void testGetSetType() { public void testGetSetPath() { // Arrange String expectedPath = "testPath"; - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - String actualPath = locator.setPath(expectedPath).getPath(); + String actualPath = locatorInfo.setPath(expectedPath).getPath(); // Assert assertEquals(expectedPath, actualPath); @@ -79,10 +79,10 @@ public void testGetSetPath() { public void testGetSetAccessPolicyId() { // Arrange String expectedAccessPolicyId = "testAccessPolicyId"; - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - String actualAccessPolicyId = locator.setAccessPolicyId(expectedAccessPolicyId).getAccessPolicyId(); + String actualAccessPolicyId = locatorInfo.setAccessPolicyId(expectedAccessPolicyId).getAccessPolicyId(); // Assert assertEquals(expectedAccessPolicyId, actualAccessPolicyId); @@ -92,10 +92,10 @@ public void testGetSetAccessPolicyId() { public void testGetSetAssetId() { // Arrange String expectedAssetId = "testAssetId"; - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - String actualAssetId = locator.setAssetId(expectedAssetId).getAssetId(); + String actualAssetId = locatorInfo.setAssetId(expectedAssetId).getAssetId(); // Assert assertEquals(expectedAssetId, actualAssetId); @@ -105,10 +105,10 @@ public void testGetSetAssetId() { public void testGetSetStartTime() { // Arrange Date expectedStartTime = new Date(); - Locator locator = new Locator(); + LocatorInfo locatorInfo = new LocatorInfo(); // Act - Date actualStartTime = locator.setStartTime(expectedStartTime).getStartTime(); + Date actualStartTime = locatorInfo.setStartTime(expectedStartTime).getStartTime(); // Assert assertEquals(expectedStartTime, actualStartTime); From f3f40b3fcc7bc6bec88e1c60ec7c5de83347e3b5 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 20 Sep 2012 15:22:44 -0700 Subject: [PATCH 337/664] Tweaked exception specs to match interface --- .../media/implementation/MediaRestProxy.java | 4 +- .../implementation/ODataAtomUnmarshaller.java | 192 +++++++++--------- .../implementation/ODataEntityProvider.java | 4 +- .../ODataSerializationTest.java | 16 +- 4 files changed, 110 insertions(+), 106 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index c22345c361348..602d46efb7723 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -32,7 +32,6 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; public class MediaRestProxy implements MediaContract { @@ -102,11 +101,12 @@ private void createMarshaller() { } @Override - public AssetInfo createAsset(String name) throws ServiceException, UniformInterfaceException { + public AssetInfo createAsset(String name) throws ServiceException { WebResource resource = getResource("Assets"); AssetType request = new AssetType(); request.setName(name); + try { return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .post(AssetInfo.class, marshaller.marshalEntry(request)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index c9952b7760868..f9e7f68bce7fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -19,6 +19,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; @@ -63,6 +64,8 @@ public ODataAtomUnmarshaller() throws JAXBException { * Given a stream that contains XML with an atom Feed element at the root, * unmarshal it into Java objects with the given content type in the entries. * + * @param <T> + * * @param stream * - stream containing the XML data * @param contentType @@ -71,47 +74,25 @@ public ODataAtomUnmarshaller() throws JAXBException { * @throws JAXBException * @throws ServiceException */ - public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) throws JAXBException, - ServiceException { + public <T extends ODataEntity> List<T> unmarshalFeed(InputStream stream, Class<T> contentType) + throws JAXBException, ServiceException { validateNotNull(stream, "stream"); validateNotNull(contentType, "contentType"); - JAXBElement<FeedType> feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); - FeedType feed = feedElement.getValue(); - EntryType firstEntry = getFirstEntry(feed); - - Class<?> serializationType = GetSerializationContentType(contentType); - - Object content = getEntryContent(firstEntry, serializationType); - - try { - Constructor<?> resultCtor = contentType.getConstructor(EntryType.class, serializationType); - return (ODataEntity<?>) resultCtor.newInstance(firstEntry, content); - } - catch (IllegalArgumentException e) { - e.printStackTrace(); - throw new ServiceException(e); - } - catch (SecurityException e) { - e.printStackTrace(); - throw new ServiceException(e); - } - catch (InstantiationException e) { - e.printStackTrace(); - throw new ServiceException(e); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - throw new ServiceException(e); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - throw new ServiceException(e); - } - catch (NoSuchMethodException e) { - e.printStackTrace(); - throw new ServiceException(e); + List<T> entries = new ArrayList<T>(); + FeedType feed = unmarshalFeed(stream); + Class<?> marshallingContentType = getMarshallingContentType(contentType); + + for (Object feedChild : feed.getFeedChildren()) { + EntryType entry = asEntry(feedChild); + if (entry != null) { + unmarshalODataContent(entry, contentType); + ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); + Object contentObject = getFirstOfType(marshallingContentType, contentElement.getContent()); + entries.add(constructResultObject(contentType, entry, contentObject)); + } } + return entries; } /** @@ -126,22 +107,84 @@ public ODataEntity<?> unmarshalFeed(InputStream stream, Class<?> contentType) th * @throws JAXBException * @throws ServiceException */ - public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) throws JAXBException, + public <T extends ODataEntity> T unmarshalEntry(InputStream stream, Class<T> contentType) throws JAXBException, ServiceException { validateNotNull(stream, "stream"); validateNotNull(contentType, "contentType"); - JAXBElement<EntryType> entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); + Class<?> marshallingContentType = getMarshallingContentType(contentType); - EntryType entry = entryElement.getValue(); + EntryType entry = unmarshalEntry(stream); + unmarshalODataContent(entry, contentType); + ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); + Object contentObject = getFirstOfType(marshallingContentType, contentElement.getContent()); + return constructResultObject(contentType, entry, contentObject); + } + + private EntryType asEntry(Object o) { + if (o instanceof JAXBElement) { + JAXBElement e = (JAXBElement) o; + if (e.getDeclaredType() == EntryType.class) { + return (EntryType) e.getValue(); + } + } + return null; + } + + private void unmarshalODataContent(EntryType entry, Class<?> contentType) throws JAXBException { + unmarshalEntryActions(entry); + unmarshalEntryContent(entry, contentType); + } + + private void unmarshalEntryActions(EntryType entry) throws JAXBException { + List<Object> children = entry.getEntryChildren(); + for (int i = 0; i < children.size(); ++i) { + Object child = children.get(i); + if (child instanceof Element) { + Element e = (Element) child; + if (qnameFromElement(e).equals(Constants.ODATA_ACTION_ELEMENT_NAME)) { + JAXBElement<ODataActionType> actionElement = mediaContentUnmarshaller.unmarshal(e, + ODataActionType.class); + children.set(i, actionElement); + } + } + } + } - Class<?> serializationType = GetSerializationContentType(contentType); + private void unmarshalEntryContent(EntryType entry, Class<?> contentType) throws JAXBException { + Class<?> marshallingContentType = getMarshallingContentType(contentType); + ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); + List<Object> contentChildren = contentElement.getContent(); + for (int i = 0; i < contentChildren.size(); ++i) { + Object child = contentChildren.get(i); + if (child instanceof Element) { + Element e = (Element) child; + if (qnameFromElement(e).equals(Constants.ODATA_PROPERTIES_ELEMENT_NAME)) { + JAXBElement actualContentElement = mediaContentUnmarshaller.unmarshal(e, marshallingContentType); + contentChildren.set(i, actualContentElement); + } + } + } + } - Object content = getEntryContent(entry, serializationType); + private <T> T getFirstOfType(Class<T> targetType, List<Object> collection) { + for (Object c : collection) { + if (c instanceof JAXBElement) { + JAXBElement e = (JAXBElement) c; + if (e.getDeclaredType() == targetType) { + return (T) e.getValue(); + } + } + } + return null; + } + private <T extends ODataEntity> T constructResultObject(Class<T> contentType, EntryType entry, Object contentObject) + throws ServiceException { + Class<?> marshallingType = getMarshallingContentType(contentType); try { - Constructor<?> resultCtor = contentType.getConstructor(EntryType.class, serializationType); - return (ODataEntity<?>) resultCtor.newInstance(entry, content); + Constructor<T> resultCtor = contentType.getConstructor(EntryType.class, marshallingType); + return resultCtor.newInstance(entry, contentObject); } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -169,66 +212,21 @@ public ODataEntity<?> unmarshalEntry(InputStream stream, Class<?> contentType) t } } - private Object getEntryContent(EntryType entry, Class<?> contentType) throws JAXBException { - List<Object> entryChildren = entry.getEntryChildren(); - Object retVal = null; - - for (int i = 0; i < entryChildren.size(); ++i) { - Object child = entryChildren.get(i); - if (child instanceof JAXBElement) { - // It's a parsed element, if it's content unmarshal, fixup, and store return value - JAXBElement e = (JAXBElement) child; - if (e.getDeclaredType() == ContentType.class) { - retVal = unmarshalEntryContent((ContentType) e.getValue(), contentType); - } - } - else { - // It's an arbitrary XML element. If it's an action, fix up element. - Element e = (Element) child; - if (qnameFromElement(e).equals(Constants.ODATA_ACTION_ELEMENT_NAME)) { - JAXBElement<ODataActionType> actionElement = mediaContentUnmarshaller.unmarshal(e, - ODataActionType.class); - entryChildren.set(i, actionElement); - } - } - } - return retVal; - } - - private EntryType getFirstEntry(FeedType feed) { - for (Object child : feed.getFeedChildren()) { - if (child instanceof JAXBElement) { - JAXBElement e = (JAXBElement) child; - - if (e.getDeclaredType() == EntryType.class) { - return (EntryType) e.getValue(); - } - } - } - return null; + private EntryType unmarshalEntry(InputStream stream) throws JAXBException { + JAXBElement<EntryType> entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); + return entryElement.getValue(); } - private Object unmarshalEntryContent(ContentType content, Class<?> actualContentType) throws JAXBException { - List<Object> contentChildren = content.getContent(); - for (int i = 0; i < contentChildren.size(); ++i) { - Object child = contentChildren.get(i); - if (child instanceof Element) { - Element e = (Element) child; - if (qnameFromElement(e).equals(Constants.ODATA_PROPERTIES_ELEMENT_NAME)) { - JAXBElement actualContentElement = mediaContentUnmarshaller.unmarshal(e, actualContentType); - contentChildren.set(i, actualContentElement); - return actualContentElement.getValue(); - } - } - } - return null; + private FeedType unmarshalFeed(InputStream stream) throws JAXBException { + JAXBElement<FeedType> feedElement = atomUnmarshaller.unmarshal(new StreamSource(stream), FeedType.class); + return feedElement.getValue(); } - private QName qnameFromElement(Element e) { + private static QName qnameFromElement(Element e) { return new QName(e.getLocalName(), e.getNamespaceURI()); } - private Class<?> GetSerializationContentType(Class<?> contentType) { + private static Class<?> getMarshallingContentType(Class<?> contentType) { ParameterizedType pt = (ParameterizedType) contentType.getGenericSuperclass(); return (Class<?>) pt.getActualTypeArguments()[0]; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index e5f54fbac6113..af0d7b0b8de3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -57,11 +57,11 @@ public ODataEntity<?> readFrom(Class<ODataEntity<?>> type, Type genericType, Ann MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { - ODataEntity entity; + ODataEntity entity = null; String responseType = mediaType.getParameters().get("type"); try { if (responseType == null || responseType.equals("feed")) { - entity = unmarshaller.unmarshalFeed(entityStream, type); + //entity = unmarshaller.unmarshalFeed(entityStream, type); } else if (responseType.equals("entry")) { entity = unmarshaller.unmarshalEntry(entityStream, type); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 51e27d89818b7..80905eb549c3e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -17,9 +17,12 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.List; import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; import junit.framework.Assert; @@ -28,6 +31,8 @@ import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.models.AssetInfo; public class ODataSerializationTest { @@ -64,8 +69,9 @@ public class ODataSerializationTest { public void canUnmarshallAssetFromFeed() throws Exception { ODataAtomUnmarshaller um = new ODataAtomUnmarshaller(); InputStream input = new ByteArrayInputStream(sampleFeedOneAsset.getBytes("UTF-8")); - ODataEntity<AssetType> entry = (ODataEntity<AssetType>) um.unmarshalFeed(input, AssetType.class); - Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entry.getContent().getId()); + List<AssetInfo> entries = um.unmarshalFeed(input, AssetInfo.class); + Assert.assertEquals(1, entries.size()); + Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entries.get(0).getId()); } @Test @@ -80,10 +86,10 @@ public void canMarshalEntryFromJavaObject() throws Exception { EntryType e = new EntryType(); ContentType c = new ContentType(); - c.getContent().add(a); - e.getEntryChildren().add(c); + c.getContent().add(new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, AssetType.class, a)); + e.getEntryChildren().add(new JAXBElement(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, c)); - m.marshal(e, System.out); + m.marshal(new JAXBElement(new QName(Constants.ATOM_NS, "entry"), EntryType.class, e), System.out); } } From 9d302b31da5648c99a26fc550c2edc437bf10bf9 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 20 Sep 2012 17:22:17 -0700 Subject: [PATCH 338/664] refactored unmarshaller --- .../media/implementation/ODataAtomUnmarshaller.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index f9e7f68bce7fc..0844faedfa171 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -86,10 +86,7 @@ public <T extends ODataEntity> List<T> unmarshalFeed(InputStream stream, Class<T for (Object feedChild : feed.getFeedChildren()) { EntryType entry = asEntry(feedChild); if (entry != null) { - unmarshalODataContent(entry, contentType); - ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); - Object contentObject = getFirstOfType(marshallingContentType, contentElement.getContent()); - entries.add(constructResultObject(contentType, entry, contentObject)); + entries.add(contentFromEntry(contentType, marshallingContentType, entry)); } } return entries; @@ -115,6 +112,11 @@ public <T extends ODataEntity> T unmarshalEntry(InputStream stream, Class<T> con Class<?> marshallingContentType = getMarshallingContentType(contentType); EntryType entry = unmarshalEntry(stream); + return contentFromEntry(contentType, marshallingContentType, entry); + } + + private <T extends ODataEntity> T contentFromEntry(Class<T> contentType, Class<?> marshallingContentType, + EntryType entry) throws JAXBException, ServiceException { unmarshalODataContent(entry, contentType); ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); Object contentObject = getFirstOfType(marshallingContentType, contentElement.getContent()); From 539c3ac00278a2cb618056bc721f9c8e3fd0b6cc Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 10:44:46 -0700 Subject: [PATCH 339/664] Successfully deserializing feeds --- .../windowsazure/services/media/Exports.java | 2 + .../services/media/MediaContract.java | 3 + .../MediaExceptionProcessor.java | 15 ++++ .../media/implementation/MediaRestProxy.java | 15 ++++ .../media/implementation/ODataEntity.java | 48 +++++++++++ .../ODataEntityCollectionProvider.java | 86 +++++++++++++++++++ .../implementation/ODataEntityProvider.java | 13 +-- .../content/ODataActionType.java | 38 +++++++- .../ODataSerializationFromJerseyTest.java | 9 ++ 9 files changed, 221 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 29f4946cc6ea5..0734dfaa933b5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -25,6 +25,7 @@ import com.microsoft.windowsazure.services.media.implementation.OAuthFilter; import com.microsoft.windowsazure.services.media.implementation.OAuthRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthTokenManager; +import com.microsoft.windowsazure.services.media.implementation.ODataEntityCollectionProvider; import com.microsoft.windowsazure.services.media.implementation.ODataEntityProvider; import com.microsoft.windowsazure.services.media.implementation.RedirectFilter; import com.microsoft.windowsazure.services.media.implementation.ResourceLocationManager; @@ -60,6 +61,7 @@ public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Ob try { instance.getSingletons().add(new ODataEntityProvider()); + instance.getSingletons().add(new ODataEntityCollectionProvider()); } catch (JAXBException e) { e.printStackTrace(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 8060eceffe028..5a5a8f2ba325b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -14,6 +14,8 @@ */ package com.microsoft.windowsazure.services.media; +import java.util.List; + import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; @@ -27,4 +29,5 @@ public interface MediaContract extends FilterableService<MediaContract> { AssetInfo createAsset(String name) throws ServiceException; + List<AssetInfo> getAssets() throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index b68089352a8d4..3cde5ec2029d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.util.List; + import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -69,4 +71,17 @@ public AssetInfo createAsset(String name) throws ServiceException { throw processCatch(new ServiceException(e)); } } + + @Override + public List<AssetInfo> getAssets() throws ServiceException { + try { + return next.getAssets(); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 602d46efb7723..c72ccbc53c4c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.media.implementation; import java.util.Arrays; +import java.util.List; import javax.inject.Inject; import javax.ws.rs.core.MediaType; @@ -32,6 +33,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.WebResource; public class MediaRestProxy implements MediaContract { @@ -115,4 +117,17 @@ public AssetInfo createAsset(String name) throws ServiceException { throw new ServiceException(e); } } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAssets() + */ + @Override + public List<AssetInfo> getAssets() throws ServiceException { + WebResource resource = getResource("Assets"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<List<AssetInfo>>() { + }); + + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index f2846162965a7..516303a1fdf30 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -15,6 +15,10 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; + import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; /** @@ -45,4 +49,48 @@ protected EntryType getEntry() { protected T getContent() { return content; } + + /** + * Is the given type inherited from ODataEntity + * + * @param type + * Type to check + * @return true if derived from ODataEntity + */ + public static boolean isODataEntityType(Class<?> type) { + return ODataEntity.class.isAssignableFrom(type); + } + + /** + * Is the given type a collection of ODataEntity + * + * @param type + * Base type + * @param genericType + * Generic type + * @return true if it's List<OEntity> or derive from. + */ + public static boolean isODataEntityCollectionType(Class<?> type, Type genericType) { + if (List.class != type) { + return false; + } + + ParameterizedType pt = (ParameterizedType) genericType; + + if (pt.getActualTypeArguments().length != 1) { + return false; + } + + Class<?> typeClass = getCollectedType(genericType); + + return isODataEntityType(typeClass); + } + + public static Class<?> getCollectedType(Type genericType) { + ParameterizedType pt = (ParameterizedType) genericType; + if (pt.getActualTypeArguments().length != 1) { + throw new IllegalArgumentException("genericType"); + } + return (Class<?>) pt.getActualTypeArguments()[0]; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java new file mode 100644 index 0000000000000..ad354b98a8c22 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -0,0 +1,86 @@ +/** + * + */ +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.util.List; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; + +/** + * Jersey provider to unmarshal lists of entities from Media Services. + * + */ +public class ODataEntityCollectionProvider extends AbstractMessageReaderWriterProvider<List<ODataEntity<?>>> { + private final ODataAtomUnmarshaller unmarshaller; + + public ODataEntityCollectionProvider() throws JAXBException { + unmarshaller = new ODataAtomUnmarshaller(); + } + + @Override + public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return ODataEntity.isODataEntityCollectionType(type, genericType); + } + + @Override + public List<ODataEntity<?>> readFrom(Class<List<ODataEntity<?>>> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) + throws IOException, WebApplicationException { + + String responseType = mediaType.getParameters().get("type"); + try { + if (responseType == null || responseType.equals("feed")) { + return unmarshaller.unmarshalFeed(entityStream, + (Class<ODataEntity<?>>) ODataEntity.getCollectedType(genericType)); + } + else { + throw new RuntimeException(); + } + } + catch (JAXBException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + catch (ServiceException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + /** + * Can this type be written by this provider? + * + * @return false - we don't support writing + */ + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return false; + } + + /** + * Write the given object to the stream. + * This method implementation throws, we don't support writing. + * + * @throws UnsupportedOperationException + */ + @Override + public void writeTo(List<ODataEntity<?>> t, Class<?> type, Type genericType, Annotation[] annotations, + MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) + throws IOException, WebApplicationException { + + throw new UnsupportedOperationException(); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index af0d7b0b8de3e..03639f5b936e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -20,6 +20,7 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.util.List; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; @@ -46,7 +47,7 @@ public ODataEntityProvider() throws JAXBException { */ @Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return ODataEntity.class.isAssignableFrom(type); + return ODataEntity.isODataEntityType(type); } /* (non-Javadoc) @@ -57,14 +58,15 @@ public ODataEntity<?> readFrom(Class<ODataEntity<?>> type, Type genericType, Ann MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { - ODataEntity entity = null; + ODataEntity<?> result = null; String responseType = mediaType.getParameters().get("type"); try { if (responseType == null || responseType.equals("feed")) { - //entity = unmarshaller.unmarshalFeed(entityStream, type); + List<ODataEntity<?>> feedContents = unmarshaller.unmarshalFeed(entityStream, type); + return feedContents.get(0); } else if (responseType.equals("entry")) { - entity = unmarshaller.unmarshalEntry(entityStream, type); + result = unmarshaller.unmarshalEntry(entityStream, type); } else { throw new RuntimeException(); @@ -79,7 +81,7 @@ else if (responseType.equals("entry")) { throw new RuntimeException(e); } - return entity; + return result; } /* (non-Javadoc) @@ -99,5 +101,4 @@ public void writeTo(ODataEntity<?> t, Class<?> type, Type genericType, Annotatio throws IOException, WebApplicationException { throw new UnsupportedOperationException(); } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index b6cbb23a79b3a..2081027c7420a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -19,8 +19,12 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; -// XML Serialization class for odata m:action elements - +/** + * XML Serialization class for odata m:action elements + * + * @author ctavares + * + */ @XmlAccessorType(XmlAccessType.FIELD) public class ODataActionType { @@ -33,26 +37,56 @@ public class ODataActionType { @XmlAttribute(required = true) protected String title; + /** + * Get metadata + * + * @return the metadata + */ public String getMetadata() { return metadata; } + /** + * Set metadata + * + * @param metadata + */ public void setMetadata(String metadata) { this.metadata = metadata; } + /** + * Get target + * + * @return the target + */ public String getTarget() { return target; } + /** + * set target + * + * @param target + */ public void setTarget(String target) { this.target = target; } + /** + * Get title + * + * @return the title + */ public String getTitle() { return title; } + /** + * set title + * + * @param title + */ public void setTitle(String title) { this.title = title; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 7dbb9fdbff3b5..2c2ac5bf05e52 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.media.implementation; import java.net.URISyntaxException; +import java.util.List; import javax.ws.rs.core.MediaType; @@ -92,4 +93,12 @@ public void canCreateAssetThroughMediaServiceAPI() throws Exception { Assert.assertEquals("secondTestAsset", newAsset.getName()); } + + @Test + public void canRetrieveListOfAssets() throws Exception { + MediaContract client = MediaService.create(config); + List<AssetInfo> assets = client.getAssets(); + + Assert.assertNotNull(assets); + } } From 0a0a5386ad99762809b51a9d9097c8d403bc83a3 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 12:09:26 -0700 Subject: [PATCH 340/664] Removed extraneous alias --- .../services/media/implementation/content/ODataActionType.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index 2081027c7420a..569cd17d4f3f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -22,8 +22,6 @@ /** * XML Serialization class for odata m:action elements * - * @author ctavares - * */ @XmlAccessorType(XmlAccessType.FIELD) public class ODataActionType { From f52aa2babd7d040535a3695e93de1a99a2836cbd Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 12:10:52 -0700 Subject: [PATCH 341/664] missing copyright header --- .../services/media/models/AssetInfo.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index c62eb7a53d8dd..86f9d9e03ff9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -1,11 +1,26 @@ -package com.microsoft.windowsazure.services.media.models; +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; import javax.xml.datatype.XMLGregorianCalendar; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + /** * Data about a Media Services Asset entity. * From 940e557ede5bba524c98cdbd1784bc8221d6ae13 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 12:16:21 -0700 Subject: [PATCH 342/664] Pulling back in stash of marshalling work --- .../windowsazure/services/media/Exports.java | 5 ++- .../implementation/MediaContentProvider.java | 14 +++++++ .../media/implementation/MediaRestProxy.java | 10 ++--- .../implementation/ODataAtomMarshaller.java | 38 +++++++++++++++---- .../implementation/ODataEntityProvider.java | 16 ++++++-- .../implementation/content/AssetType.java | 1 + .../content/MediaServiceDTO.java | 17 +++++++++ .../services/media/models/AssetInfo.java | 2 +- 8 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 0734dfaa933b5..b3dfe6b6bc6c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -17,6 +17,7 @@ import java.util.Map; import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; @@ -64,7 +65,9 @@ public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Ob instance.getSingletons().add(new ODataEntityCollectionProvider()); } catch (JAXBException e) { - e.printStackTrace(); + throw new RuntimeException(e); + } + catch (ParserConfigurationException e) { throw new RuntimeException(e); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java new file mode 100644 index 0000000000000..2af37f9e2603c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -0,0 +1,14 @@ +/** + * + */ +package com.microsoft.windowsazure.services.media.implementation; + +import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; + +/** + * @author ctavares + * + */ +public class MediaContentProvider extends AbstractMessageReaderWriterProvider<T> { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index c72ccbc53c4c3..f252234495d63 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -109,13 +109,9 @@ public AssetInfo createAsset(String name) throws ServiceException { AssetType request = new AssetType(); request.setName(name); - try { - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(AssetInfo.class, marshaller.marshalEntry(request)); - } - catch (JAXBException e) { - throw new ServiceException(e); - } + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(AssetInfo.class, request); + } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 2373660f9f452..2556c510a5ff2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; @@ -63,9 +64,36 @@ public ODataAtomMarshaller() throws JAXBException, ParserConfigurationException * The content object to send * @return The generated DOM * @throws JAXBException - * if content is malformed/not serializable + * if content is malformed/not marshallable */ public Document marshalEntry(Object content) throws JAXBException { + JAXBElement<EntryType> entryElement = createEntry(content); + + Document doc = documentBuilder.newDocument(); + doc.setXmlStandalone(true); + + marshaller.marshal(entryElement, doc); + + return doc; + + } + + /** + * Convert the given content into an ATOM entry + * and write it to the given stream. + * + * @param content + * Content object to send + * @param stream + * Stream to write to + * @throws JAXBException + * if content is malformed/not marshallable + */ + public void marshalEntry(Object content, OutputStream stream) throws JAXBException { + marshaller.marshal(createEntry(content), stream); + } + + private JAXBElement<EntryType> createEntry(Object content) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); atomContent.getContent().add( @@ -78,13 +106,7 @@ public Document marshalEntry(Object content) throws JAXBException { JAXBElement<EntryType> entryElement = new JAXBElement<EntryType>(new QName(Constants.ATOM_NS, "entry"), EntryType.class, atomEntry); - Document doc = documentBuilder.newDocument(); - doc.setXmlStandalone(true); - - marshaller.marshal(entryElement, doc); - - return doc; - + return entryElement; } private static Class<?>[] getMarshalledClasses() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 03639f5b936e5..9b432b99236b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -26,8 +26,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.content.MediaServiceDTO; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; /** @@ -37,9 +39,11 @@ */ public class ODataEntityProvider extends AbstractMessageReaderWriterProvider<ODataEntity<?>> { private final ODataAtomUnmarshaller unmarshaller; + private final ODataAtomMarshaller marshaller; - public ODataEntityProvider() throws JAXBException { + public ODataEntityProvider() throws JAXBException, ParserConfigurationException { unmarshaller = new ODataAtomUnmarshaller(); + marshaller = new ODataAtomMarshaller(); } /* (non-Javadoc) @@ -89,7 +93,8 @@ else if (responseType.equals("entry")) { */ @Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return false; + boolean result = type.isAnnotationPresent(MediaServiceDTO.class); + return result; } /* (non-Javadoc) @@ -99,6 +104,11 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat public void writeTo(ODataEntity<?> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { - throw new UnsupportedOperationException(); + try { + marshaller.marshalEntry(t, entityStream); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 160a3088892b5..d5271b9e922e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -25,6 +25,7 @@ * for Asset entities. * */ +@MediaServiceDTO @XmlAccessorType(XmlAccessType.FIELD) public class AssetType { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java new file mode 100644 index 0000000000000..9c3fdf1fad986 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java @@ -0,0 +1,17 @@ +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation marking a type as a data transfer object + * to or from Media Services. + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface MediaServiceDTO { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 86f9d9e03ff9e..7fc7a9c28306f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -14,13 +14,13 @@ */ package com.microsoft.windowsazure.services.media.models; + import javax.xml.datatype.XMLGregorianCalendar; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; - /** * Data about a Media Services Asset entity. * From 644a04c026c040d895a08af682f24e44cfbfe0dc Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 12:44:23 -0700 Subject: [PATCH 343/664] Marshalling through Jersey pipeline instead of manually --- .../windowsazure/services/media/Exports.java | 2 + .../implementation/MediaContentProvider.java | 72 ++++++++++++++++++- .../media/implementation/MediaRestProxy.java | 22 ------ .../implementation/ODataEntityProvider.java | 13 +--- .../implementation/content/AssetType.java | 3 +- .../content/MediaServiceDTO.java | 13 ++-- 6 files changed, 79 insertions(+), 46 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index b3dfe6b6bc6c3..b0ab8a4f5571c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -20,6 +20,7 @@ import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.Builder; +import com.microsoft.windowsazure.services.media.implementation.MediaContentProvider; import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; import com.microsoft.windowsazure.services.media.implementation.MediaRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthContract; @@ -63,6 +64,7 @@ public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Ob try { instance.getSingletons().add(new ODataEntityProvider()); instance.getSingletons().add(new ODataEntityCollectionProvider()); + instance.getSingletons().add(new MediaContentProvider()); } catch (JAXBException e) { throw new RuntimeException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java index 2af37f9e2603c..4ad8c880c6d4f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -1,14 +1,80 @@ /** + * Copyright 2012 Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package com.microsoft.windowsazure.services.media.implementation; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import com.microsoft.windowsazure.services.media.implementation.content.MediaServiceDTO; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; /** - * @author ctavares - * + * Class to plug into Jersey to properly serialize + * raw Media Services DTO types. + * */ -public class MediaContentProvider extends AbstractMessageReaderWriterProvider<T> { +public class MediaContentProvider<T extends MediaServiceDTO> extends AbstractMessageReaderWriterProvider<T> { + private final ODataAtomMarshaller marshaller; + + /** + * Creates the instance + * + * @throws JAXBException + * @throws ParserConfigurationException + */ + public MediaContentProvider() throws JAXBException, ParserConfigurationException { + marshaller = new ODataAtomMarshaller(); + } + + @Override + public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + // This class only does marshalling, not unmarshalling. + return false; + } + + @Override + public T readFrom(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, + WebApplicationException { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return MediaServiceDTO.class.isAssignableFrom(type); + } + @Override + public void writeTo(T t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, + MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, + WebApplicationException { + try { + marshaller.marshalEntry(t, entityStream); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index f252234495d63..a42fd68f25a4b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -20,8 +20,6 @@ import javax.inject.Inject; import javax.ws.rs.core.MediaType; -import javax.xml.bind.JAXBException; -import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,11 +37,8 @@ public class MediaRestProxy implements MediaContract { private Client channel; - private ODataAtomMarshaller marshaller; static Log log = LogFactory.getLog(MediaContract.class); - private static final String jsonRequestType = "application/json; odata=verbose"; - ServiceFilter[] filters; @Inject @@ -55,14 +50,11 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red channel.addFilter(redirectFilter); channel.addFilter(authFilter); channel.addFilter(versionHeadersFilter); - - createMarshaller(); } public MediaRestProxy(Client channel, ServiceFilter[] filters) { this.channel = channel; this.filters = filters; - createMarshaller(); } @Override @@ -88,20 +80,6 @@ private WebResource getResource(String entityName) { return resource; } - private void createMarshaller() { - try { - this.marshaller = new ODataAtomMarshaller(); - } - catch (JAXBException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - catch (ParserConfigurationException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - @Override public AssetInfo createAsset(String name) throws ServiceException { WebResource resource = getResource("Assets"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 9b432b99236b3..a7dca481e6b54 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -29,7 +29,6 @@ import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.implementation.content.MediaServiceDTO; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; /** @@ -39,11 +38,9 @@ */ public class ODataEntityProvider extends AbstractMessageReaderWriterProvider<ODataEntity<?>> { private final ODataAtomUnmarshaller unmarshaller; - private final ODataAtomMarshaller marshaller; public ODataEntityProvider() throws JAXBException, ParserConfigurationException { unmarshaller = new ODataAtomUnmarshaller(); - marshaller = new ODataAtomMarshaller(); } /* (non-Javadoc) @@ -93,8 +90,7 @@ else if (responseType.equals("entry")) { */ @Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { - boolean result = type.isAnnotationPresent(MediaServiceDTO.class); - return result; + return false; } /* (non-Javadoc) @@ -104,11 +100,6 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat public void writeTo(ODataEntity<?> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { - try { - marshaller.marshalEntry(t, entityStream); - } - catch (JAXBException e) { - throw new RuntimeException(e); - } + throw new UnsupportedOperationException(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index d5271b9e922e6..391e0c497aaa5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -25,9 +25,8 @@ * for Asset entities. * */ -@MediaServiceDTO @XmlAccessorType(XmlAccessType.FIELD) -public class AssetType { +public class AssetType implements MediaServiceDTO { @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) protected String id; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java index 9c3fdf1fad986..762cae0eed0b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java @@ -1,17 +1,14 @@ package com.microsoft.windowsazure.services.media.implementation.content; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; /** - * Annotation marking a type as a data transfer object + * Marker interface to mark types as a data transfer object * to or from Media Services. * + * This is a marker interface rather than an annotation so + * that it can be used as a generic type parameter or restriction. + * */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface MediaServiceDTO { +public interface MediaServiceDTO { } From f80e5eff428426b3958fa0d2bb88b4b22d5fd33f Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 21 Sep 2012 12:48:28 -0700 Subject: [PATCH 344/664] Removed extraneous stack trace prints --- .../media/implementation/ODataAtomUnmarshaller.java | 6 ------ .../media/implementation/ODataEntityCollectionProvider.java | 2 -- .../services/media/implementation/ODataEntityProvider.java | 2 -- 3 files changed, 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 0844faedfa171..66cecfd0a542d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -189,27 +189,21 @@ private <T extends ODataEntity> T constructResultObject(Class<T> contentType, En return resultCtor.newInstance(entry, contentObject); } catch (IllegalArgumentException e) { - e.printStackTrace(); throw new ServiceException(e); } catch (SecurityException e) { - e.printStackTrace(); throw new ServiceException(e); } catch (InstantiationException e) { - e.printStackTrace(); throw new ServiceException(e); } catch (IllegalAccessException e) { - e.printStackTrace(); throw new ServiceException(e); } catch (InvocationTargetException e) { - e.printStackTrace(); throw new ServiceException(e); } catch (NoSuchMethodException e) { - e.printStackTrace(); throw new ServiceException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java index ad354b98a8c22..b6b6eac581503 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -50,11 +50,9 @@ public List<ODataEntity<?>> readFrom(Class<List<ODataEntity<?>>> type, Type gene } } catch (JAXBException e) { - e.printStackTrace(); throw new RuntimeException(e); } catch (ServiceException e) { - e.printStackTrace(); throw new RuntimeException(e); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index a7dca481e6b54..704e0885db0e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -74,11 +74,9 @@ else if (responseType.equals("entry")) { } } catch (JAXBException e) { - e.printStackTrace(); throw new RuntimeException(e); } catch (ServiceException e) { - e.printStackTrace(); throw new RuntimeException(e); } From b6d1652aac3d51b5c1d13b4e596eba4e3e4395dd Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 21 Sep 2012 14:03:44 -0700 Subject: [PATCH 345/664] code review feedback for the initial commit of AssetCRUD --- .../services/media/MediaContract.java | 89 ++++++++++++-- .../MediaExceptionProcessor.java | 41 +++++-- .../media/implementation/MediaRestProxy.java | 115 ++++++++++++++++-- .../media/models/CreateAssetOptions.java | 19 +++ .../media/MediaServiceIntegrationTest.java | 46 +++---- 5 files changed, 256 insertions(+), 54 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 3fd0e8cee4033..3d653b53d341c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,24 +17,93 @@ import java.util.List; import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +// TODO: Auto-generated Javadoc /** - * - * Defines the methods available for Windows Azure Media Services - * + * Defines the methods available for Windows Azure Media Services. */ public interface MediaContract extends FilterableService<MediaContract> { - public Asset createAsset(Asset asset); + /** + * Creates the asset. + * + * @param asset + * the asset + * @return the asset info + */ + public AssetInfo createAsset(AssetInfo asset); - public Asset getAsset(Asset asset); + /** + * List assets. + * + * @param listAssetsOptions + * the list assets options + * @return the list + */ + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions); - public List<Asset> listAssets(ListAssetsOptions listAssetsOptions); - - public Asset updateAsset(Asset updatedAsset); + /** + * Update asset. + * + * @param updatedAsset + * the updated asset + * @return the asset info + */ + public AssetInfo updateAsset(AssetInfo updatedAsset); + /** + * Delete asset. + * + * @param assetId + * the asset id + */ public void deleteAsset(String assetId); + /** + * Creates the asset. + * + * @param assetName + * the asset name + * @return the asset info + */ + public AssetInfo createAsset(String assetName); + + /** + * Creates the asset. + * + * @param assetName + * the asset name + * @param createAssetOptions + * the create asset options + * @return the asset info + */ + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions); + + /** + * Gets the asset. + * + * @param assetId + * the asset id + * @return the asset + */ + public AssetInfo getAsset(String assetId); + + /** + * List assets. + * + * @return the list + */ + public List<AssetInfo> listAssets(); + + /** + * Delete asset. + * + * @param assetInfo + * the asset info + */ + public void deleteAsset(AssetInfo assetInfo); + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 4db539dbde579..54792e65462e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -26,7 +26,8 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; /** @@ -59,28 +60,48 @@ private ServiceException processCatch(ServiceException e) { } @Override - public Asset createAsset(Asset asset) { + public void deleteAsset(String assetId) { + service.deleteAsset(assetId); + } + + @Override + public AssetInfo createAsset(AssetInfo asset) { return service.createAsset(asset); } @Override - public Asset getAsset(Asset asset) { - return service.getAsset(asset); + public AssetInfo updateAsset(AssetInfo updatedAsset) { + return service.updateAsset(updatedAsset); } @Override - public List<Asset> listAssets(ListAssetsOptions listAssetsOptions) { - return service.listAssets(listAssetsOptions); + public AssetInfo createAsset(String assetName) { + return service.createAsset(assetName); } @Override - public Asset updateAsset(Asset updatedAsset) { - return service.updateAsset(updatedAsset); + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { + return service.createAsset(assetName, createAssetOptions); } @Override - public void deleteAsset(String assetId) { - service.deleteAsset(assetId); + public AssetInfo getAsset(String assetId) { + return service.getAsset(assetId); + } + + @Override + public List<AssetInfo> listAssets() { + return service.listAssets(); + } + + @Override + public void deleteAsset(AssetInfo assetInfo) { + service.deleteAsset(assetInfo); + } + + @Override + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { + return service.listAssets(listAssetsOptions); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index b94d8acc240c7..c25eaba9a248b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,18 +27,37 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; +// TODO: Auto-generated Javadoc +/** + * The Class MediaRestProxy. + */ public class MediaRestProxy implements MediaContract { + /** The channel. */ private Client channel; + + /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); + /** The filters. */ ServiceFilter[] filters; + /** + * Instantiates a new media rest proxy. + * + * @param channel + * the channel + * @param authFilter + * the auth filter + * @param redirectFilter + * the redirect filter + */ @Inject public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter) { this.channel = channel; @@ -47,11 +66,22 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red channel.addFilter(authFilter); } + /** + * Instantiates a new media rest proxy. + * + * @param channel + * the channel + * @param filters + * the filters + */ public MediaRestProxy(Client channel, ServiceFilter[] filters) { this.channel = channel; this.filters = filters; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ @Override public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); @@ -59,14 +89,32 @@ public MediaContract withFilter(ServiceFilter filter) { return new MediaRestProxy(channel, newFilters); } + /** + * Gets the channel. + * + * @return the channel + */ public Client getChannel() { return channel; } + /** + * Sets the channel. + * + * @param channel + * the new channel + */ public void setChannel(Client channel) { this.channel = channel; } + /** + * Gets the resource. + * + * @param entityName + * the entity name + * @return the resource + */ private WebResource getResource(String entityName) { WebResource resource = getChannel().resource(entityName); for (ServiceFilter filter : filters) { @@ -75,34 +123,79 @@ private WebResource getResource(String entityName) { return resource; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) + */ @Override - public Asset createAsset(Asset asset) { - // TODO Auto-generated method stub + public AssetInfo createAsset(String assetName) { + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + return createAsset(assetName, createAssetOptions); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) + */ + @Override + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAsset(java.lang.String) + */ @Override - public Asset getAsset(Asset asset) { - // TODO Auto-generated method stub + public AssetInfo getAsset(String assetId) { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) + */ @Override - public List<Asset> listAssets(ListAssetsOptions listAssetsOptions) { - List<Asset> listAssetsResult = new ArrayList<Asset>(); + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { + List<AssetInfo> listAssetsResult = new ArrayList<AssetInfo>(); return listAssetsResult; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() + */ @Override - public Asset updateAsset(Asset updatedAsset) { - // TODO Auto-generated method stub + public List<AssetInfo> listAssets() { + ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); + return listAssets(listAssetsOptions); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + */ + @Override + public AssetInfo updateAsset(AssetInfo updatedAssetInfo) { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) + */ @Override public void deleteAsset(String assetId) { - // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + */ + @Override + public void deleteAsset(AssetInfo assetInfo) { + this.deleteAsset(assetInfo.getId()); + } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + */ + @Override + public AssetInfo createAsset(AssetInfo assetInfo) { + // TODO Auto-generated method stub + return null; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java new file mode 100644 index 0000000000000..ecf58db9057e1 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java @@ -0,0 +1,19 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +public class CreateAssetOptions { + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index a3e5a8ce01058..a838f8cac87c1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -24,7 +24,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { @@ -35,9 +35,9 @@ public static void setup() throws Exception { // Create all test containers and their content config = createConfig(); service = MediaService.create(config); - List<Asset> listAssetsResult = service.listAssets(null); - for (Asset asset : listAssetsResult) { - service.deleteAsset(asset.getId()); + List<AssetInfo> listAssetsResult = service.listAssets(null); + for (AssetInfo assetInfo : listAssetsResult) { + service.deleteAsset(assetInfo.getId()); } } @@ -63,10 +63,10 @@ private static Configuration createConfig() { @Test public void createAssetSuccess() throws Exception { // Arrange - Asset expectedAsset = new Asset().setName("testAssetName"); + AssetInfo expectedAsset = new AssetInfo().setName("testAssetName"); // Act - Asset actualAsset = service.createAsset(expectedAsset); + AssetInfo actualAsset = service.createAsset(expectedAsset); // Assert assertEquals(expectedAsset, actualAsset); @@ -75,10 +75,10 @@ public void createAssetSuccess() throws Exception { @Test public void createAssetMissingNameFailed() { // Arrange - Asset expectedAsset = new Asset(); + AssetInfo expectedAsset = new AssetInfo(); // Act - Asset actualAsset = service.createAsset(expectedAsset); + AssetInfo actualAsset = service.createAsset(expectedAsset); // Assert assertTrue(false); @@ -87,11 +87,11 @@ public void createAssetMissingNameFailed() { @Test public void getAssetSuccess() throws Exception { // Arrange - Asset expectedAsset = new Asset(); - service.createAsset(expectedAsset); + AssetInfo expectedAsset = new AssetInfo(); + AssetInfo assetInfo = service.createAsset(expectedAsset); // Act - Asset actualAsset = service.getAsset(expectedAsset); + AssetInfo actualAsset = service.getAsset(assetInfo.getId()); // Assert assertEquals(expectedAsset, actualAsset); @@ -100,11 +100,11 @@ public void getAssetSuccess() throws Exception { @Test public void getAssetFailedWithInvalidId() { // Arrange - Asset expectedAsset = new Asset(); + AssetInfo expectedAsset = new AssetInfo(); service.createAsset(expectedAsset); // Act - Asset actualAsset = service.getAsset(expectedAsset.setName("IncorrectAssetName")); + AssetInfo actualAsset = service.getAsset(expectedAsset.setId("IncorrectAssetId").getId()); // Assert assertTrue(false); @@ -114,14 +114,14 @@ public void getAssetFailedWithInvalidId() { @Test public void listAssetSuccess() { // Arrange - Asset assetA = new Asset(); - Asset assetB = new Asset(); + AssetInfo assetA = new AssetInfo(); + AssetInfo assetB = new AssetInfo(); service.createAsset(assetA); service.createAsset(assetB); ListAssetsOptions listAssetOptions = new ListAssetsOptions(); // Act - Collection<Asset> listAssetResult = service.listAssets(listAssetOptions); + Collection<AssetInfo> listAssetResult = service.listAssets(listAssetOptions); // Assert assertEquals(2, listAssetResult.size()); @@ -133,7 +133,7 @@ public void listAssetFailed() { ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); // Act - Collection<Asset> listAssetResult = service.listAssets(listAssetsOptions); + Collection<AssetInfo> listAssetResult = service.listAssets(listAssetsOptions); // Assert assertTrue(false); @@ -142,13 +142,13 @@ public void listAssetFailed() { @Test public void updateAssetSuccess() throws Exception { // Arrange - Asset originalAsset = new Asset(); + AssetInfo originalAsset = new AssetInfo(); service.createAsset(originalAsset); - Asset updatedAsset = new Asset(); + AssetInfo updatedAsset = new AssetInfo(); // Act service.updateAsset(updatedAsset); - Asset actualAsset = service.updateAsset(updatedAsset); + AssetInfo actualAsset = service.updateAsset(updatedAsset); // Assert assertEquals(updatedAsset, actualAsset); @@ -159,7 +159,7 @@ public void updateAssetSuccess() throws Exception { public void updateAssetFailedWithInvalidId() { // Arrange MediaContract service = MediaService.create(config); - Asset updatedAsset = new Asset(); + AssetInfo updatedAsset = new AssetInfo(); // Act service.updateAsset(updatedAsset); @@ -171,9 +171,9 @@ public void updateAssetFailedWithInvalidId() { @Test public void deleteAssetSuccess() throws Exception { // Arrange - Asset asset = new Asset(); + AssetInfo asset = new AssetInfo(); service.createAsset(asset); - List<Asset> listAssetsResult = service.listAssets(null); + List<AssetInfo> listAssetsResult = service.listAssets(null); assertEquals(1, listAssetsResult.size()); // Act From 8f6f13537aa6ed7b16f29ec1a038883d3bef5fda Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 21 Sep 2012 16:32:24 -0700 Subject: [PATCH 346/664] Resolve merging conflicts. --- .../services/media/MediaContract.java | 4 +++- .../MediaExceptionProcessor.java | 17 +++++++---------- .../media/implementation/MediaRestProxy.java | 18 +++++++----------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 670cfed89507b..e5efb41eb5e98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -17,6 +17,7 @@ import java.util.List; import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; @@ -67,8 +68,9 @@ public interface MediaContract extends FilterableService<MediaContract> { * @param assetName * the asset name * @return the asset info + * @throws ServiceException */ - public AssetInfo createAsset(String assetName); + public AssetInfo createAsset(String assetName) throws ServiceException; /** * Creates the asset. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 83faae2255d61..8b53f2f9a6f0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -27,10 +27,10 @@ import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.UniformInterfaceException; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.sun.jersey.api.client.ClientHandlerException; +import com.sun.jersey.api.client.UniformInterfaceException; /** * Wrapper implementation of <code>MediaServicesContract</code> that @@ -62,9 +62,9 @@ private ServiceException processCatch(ServiceException e) { } @Override - public AssetInfo createAsset(String name) throws ServiceException { + public AssetInfo createAsset(String assetName) throws ServiceException { try { - return next.createAsset(name); + return service.createAsset(assetName); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -77,7 +77,7 @@ public AssetInfo createAsset(String name) throws ServiceException { @Override public List<AssetInfo> getAssets() throws ServiceException { try { - return next.getAssets(); + return service.getAssets(); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -86,6 +86,8 @@ public List<AssetInfo> getAssets() throws ServiceException { throw processCatch(new ServiceException(e)); } } + + @Override public void deleteAsset(String assetId) { service.deleteAsset(assetId); } @@ -100,11 +102,6 @@ public AssetInfo updateAsset(AssetInfo updatedAsset) { return service.updateAsset(updatedAsset); } - @Override - public AssetInfo createAsset(String assetName) { - return service.createAsset(assetName); - } - @Override public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { return service.createAsset(assetName, createAssetOptions); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 798b73ee562b4..a7c528729e9b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -31,7 +31,6 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.sun.jersey.api.client.Client; @@ -61,6 +60,8 @@ public class MediaRestProxy implements MediaContract { * the auth filter * @param redirectFilter * the redirect filter + * @param versionHeadersFilter + * the version headers filter */ @Inject public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, @@ -130,12 +131,15 @@ private WebResource getResource(String entityName) { return resource; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) + */ @Override - public AssetInfo createAsset(String name) throws ServiceException { + public AssetInfo createAsset(String assetName) throws ServiceException { WebResource resource = getResource("Assets"); AssetType request = new AssetType(); - request.setName(name); + request.setName(assetName); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .post(AssetInfo.class, request); @@ -154,14 +158,6 @@ public List<AssetInfo> getAssets() throws ServiceException { }); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) - */ - @Override - public AssetInfo createAsset(String assetName) { - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - return createAsset(assetName, createAssetOptions); - } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) From 38d35ae1ab6302dfcd5ce5a0078a67bb30f36eee Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 26 Sep 2012 01:06:54 -0700 Subject: [PATCH 347/664] Test driven Asset CRUD operation --- .../services/media/MediaContract.java | 50 +++---- .../MediaExceptionProcessor.java | 117 ++++++++++++--- .../media/implementation/MediaRestProxy.java | 133 +++++++++++++----- .../implementation/content/AssetType.java | 14 ++ .../media/models/CreateAssetOptions.java | 75 ++++++++++ .../media/models/UpdateAssetOptions.java | 60 ++++++++ .../media/MediaServiceIntegrationTest.java | 96 ++++++------- .../ODataSerializationFromJerseyTest.java | 2 +- 8 files changed, 407 insertions(+), 140 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index e5efb41eb5e98..49a8cb4411caa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -21,46 +21,31 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; /** * Defines the methods available for Windows Azure Media Services. */ public interface MediaContract extends FilterableService<MediaContract> { - /** - * Creates the asset. - * - * @param asset - * the asset - * @return the asset info - */ - public AssetInfo createAsset(AssetInfo asset); - /** * List assets. * * @param listAssetsOptions * the list assets options * @return the list + * @throws ServiceException */ - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions); - - /** - * Update asset. - * - * @param updatedAsset - * the updated asset - * @return the asset info - */ - public AssetInfo updateAsset(AssetInfo updatedAsset); + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; /** * Delete asset. * * @param assetId * the asset id + * @throws ServiceException */ - public void deleteAsset(String assetId); + public void deleteAsset(String assetId) throws ServiceException; /** * Creates the asset. @@ -80,8 +65,9 @@ public interface MediaContract extends FilterableService<MediaContract> { * @param createAssetOptions * the create asset options * @return the asset info + * @throws ServiceException */ - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions); + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException; /** * Gets the asset. @@ -89,23 +75,37 @@ public interface MediaContract extends FilterableService<MediaContract> { * @param assetId * the asset id * @return the asset + * @throws ServiceException */ - public AssetInfo getAsset(String assetId); + public AssetInfo getAsset(String assetId) throws ServiceException; /** * List assets. * * @return the list + * @throws ServiceException */ - public List<AssetInfo> listAssets(); + public List<AssetInfo> listAssets() throws ServiceException; /** * Delete asset. * * @param assetInfo * the asset info + * @throws ServiceException + */ + public void deleteAsset(AssetInfo assetInfo) throws ServiceException; + + /** + * Update asset. + * + * @param assetId + * the asset id + * @param updateAssetOptions + * the update asset options + * @throws ServiceException + * the service exception */ - public void deleteAsset(AssetInfo assetInfo); + public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException; - List<AssetInfo> getAssets() throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 8b53f2f9a6f0c..838068976a573 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; @@ -39,28 +40,56 @@ */ public class MediaExceptionProcessor implements MediaContract { + /** The service. */ private final MediaContract service; + + /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); + /** + * Instantiates a new media exception processor. + * + * @param service + * the service + */ public MediaExceptionProcessor(MediaContract service) { this.service = service; } + /** + * Instantiates a new media exception processor. + * + * @param service + * the service + */ @Inject public MediaExceptionProcessor(MediaRestProxy service) { this.service = service; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ @Override public MediaContract withFilter(ServiceFilter filter) { return new MediaExceptionProcessor(service.withFilter(filter)); } + /** + * Process a catch. + * + * @param e + * the e + * @return the service exception + */ private ServiceException processCatch(ServiceException e) { log.warn(e.getMessage(), e.getCause()); return ServiceExceptionFactory.process("MediaServices", e); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) + */ @Override public AssetInfo createAsset(String assetName) throws ServiceException { try { @@ -74,10 +103,13 @@ public AssetInfo createAsset(String assetName) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() + */ @Override - public List<AssetInfo> getAssets() throws ServiceException { + public List<AssetInfo> listAssets() throws ServiceException { try { - return service.getAssets(); + return service.listAssets(); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -87,44 +119,83 @@ public List<AssetInfo> getAssets() throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + */ @Override - public void deleteAsset(String assetId) { - service.deleteAsset(assetId); - } - - @Override - public AssetInfo createAsset(AssetInfo asset) { - return service.createAsset(asset); + public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { + try { + service.updateAsset(assetId, updateAssetOptions); + } + catch (UniformInterfaceException e) { + throw new ServiceException(e); + } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) + */ @Override - public AssetInfo updateAsset(AssetInfo updatedAsset) { - return service.updateAsset(updatedAsset); + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException { + try { + return service.createAsset(assetName, createAssetOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAsset(java.lang.String) + */ @Override - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { - return service.createAsset(assetName, createAssetOptions); - } + public AssetInfo getAsset(String assetId) throws ServiceException { + try { + return service.getAsset(assetId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } - @Override - public AssetInfo getAsset(String assetId) { - return service.getAsset(assetId); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) + */ @Override - public List<AssetInfo> listAssets() { - return service.listAssets(); + public void deleteAsset(String assetId) throws ServiceException { + try { + service.deleteAsset(assetId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + */ @Override - public void deleteAsset(AssetInfo assetInfo) { - service.deleteAsset(assetInfo); + public void deleteAsset(AssetInfo assetInfo) throws ServiceException { + try { + service.deleteAsset(assetInfo); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) + */ @Override - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { - return service.listAssets(listAssetsOptions); + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { + try { + return service.listAssets(listAssetsOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index a7c528729e9b0..fc03acea681f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,7 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.util.ArrayList; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Arrays; import java.util.List; @@ -28,16 +29,19 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -// TODO: Auto-generated Javadoc /** * The Class MediaRestProxy. */ @@ -136,27 +140,8 @@ private WebResource getResource(String entityName) { */ @Override public AssetInfo createAsset(String assetName) throws ServiceException { - WebResource resource = getResource("Assets"); - - AssetType request = new AssetType(); - request.setName(assetName); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(AssetInfo.class, request); - - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAssets() - */ - @Override - public List<AssetInfo> getAssets() throws ServiceException { - WebResource resource = getResource("Assets"); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<List<AssetInfo>>() { - }); - + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + return this.createAsset(assetName, createAssetOptions); } /* (non-Javadoc) @@ -164,15 +149,37 @@ public List<AssetInfo> getAssets() throws ServiceException { */ @Override public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { - return null; + WebResource resource = getResource("Assets"); + AssetType assetType = new AssetType(); + assetType.setName(assetName); + assetType.setAlternateId(createAssetOptions.getAlternateId()); + if (createAssetOptions.getOptions() != null) { + assetType.setOptions(createAssetOptions.getOptions().getCode()); + } + if (createAssetOptions.getState() != null) { + assetType.setState(createAssetOptions.getState().getCode()); + } + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(AssetInfo.class, assetType); } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#getAsset(java.lang.String) */ @Override - public AssetInfo getAsset(String assetId) { - return null; + public AssetInfo getAsset(String assetId) throws ServiceException { + String escapedAssetId = null; + try { + escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String assetPath = String.format("Assets(\'%s\')", escapedAssetId); + WebResource resource = getResource(assetPath); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<AssetInfo>() { + }); } /* (non-Javadoc) @@ -180,8 +187,10 @@ public AssetInfo getAsset(String assetId) { */ @Override public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { - List<AssetInfo> listAssetsResult = new ArrayList<AssetInfo>(); - return listAssetsResult; + WebResource resource = getResource("Assets"); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<List<AssetInfo>>() { + }); } /* (non-Javadoc) @@ -197,32 +206,78 @@ public List<AssetInfo> listAssets() { * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) */ @Override - public AssetInfo updateAsset(AssetInfo updatedAssetInfo) { - return null; + public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { + String escapedAssetId = null; + try { + escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String assetPath = String.format("Assets(\'%s\')", escapedAssetId); + WebResource resource = getResource(assetPath); + AssetType updatedAssetType = new AssetType(); + updatedAssetType.setAlternateId(updateAssetOptions.getAlternateId()); + updatedAssetType.setName(updateAssetOptions.getName()); + if (updateAssetOptions.getOptions() != null) { + updatedAssetType.setOptions(updateAssetOptions.getOptions().getCode()); + } + + if (updateAssetOptions.getState() != null) { + updatedAssetType.setState(updateAssetOptions.getState().getCode()); + } + + ClientResponse clientResponse = mergeRequest(assetPath, ClientResponse.class, updatedAssetType); + PipelineHelpers.ThrowIfNotSuccess(clientResponse); } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) */ @Override - public void deleteAsset(String assetId) { + public void deleteAsset(String assetId) throws ServiceException { + String escapedAssetId = null; + try { + escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String assetPath = String.format("Assets(\'%s\')", escapedAssetId); + WebResource resource = getResource(assetPath); + try { + resource.delete(); + } + catch (UniformInterfaceException e) { + throw new ServiceException(e); + } } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) */ @Override - public void deleteAsset(AssetInfo assetInfo) { + public void deleteAsset(AssetInfo assetInfo) throws ServiceException { this.deleteAsset(assetInfo.getId()); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) - */ - @Override - public AssetInfo createAsset(AssetInfo assetInfo) { - // TODO Auto-generated method stub - return null; + private <T> T mergeRequest(String path, GenericType<T> genericClass, java.lang.Object requestEntity) + throws ServiceException { + WebResource resource = getResource(path); + WebResource.Builder builder = resource.getRequestBuilder(); + builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .header("X-HTTP-Method", "MERGE"); + return builder.method("POST", genericClass, requestEntity); + + } + + private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { + WebResource resource = getResource(path); + WebResource.Builder builder = resource.getRequestBuilder(); + builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .header("X-HTTP-Method", "MERGE"); + return builder.method("POST", c, requestEntity); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 391e0c497aaa5..84f5b353785ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.datatype.XMLGregorianCalendar; +import com.microsoft.windowsazure.services.media.models.AssetInfo; + /** * This type maps the XML returned in the odata ATOM serialization * for Asset entities. @@ -153,4 +155,16 @@ public int getOptions() { public void setOptions(int options) { this.options = options; } + + public static AssetType create(AssetInfo assetInfo) { + AssetType assetType = new AssetType(); + assetType.setAlternateId(assetInfo.getAlternateId()); + assetType.setCreated(assetInfo.getCreated()); + assetType.setId(assetInfo.getId()); + assetType.setLastModified(assetInfo.getLastModified()); + assetType.setName(assetInfo.getName()); + assetType.setOptions(assetInfo.getOptions().getCode()); + assetType.setState(assetInfo.getState().getCode()); + return assetType; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java index ecf58db9057e1..9905e36e8ef46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java @@ -14,6 +14,81 @@ */ package com.microsoft.windowsazure.services.media.models; +/** + * The Class CreateAssetOptions. + */ public class CreateAssetOptions { + /** The alternate id. */ + private String alternateId; + + /** The options. */ + private EncryptionOption options; + + /** The state. */ + private AssetState state; + + /** + * Gets the alternate id. + * + * @return the alternate id + */ + public String getAlternateId() { + return alternateId; + } + + /** + * Sets the alternate id. + * + * @param alternateId + * the alternate id + * @return the creates the asset options + */ + public CreateAssetOptions setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + /** + * Gets the options. + * + * @return the options + */ + public EncryptionOption getOptions() { + return options; + } + + /** + * Sets the options. + * + * @param encryptionOption + * the encryption option + * @return the creates the asset options + */ + public CreateAssetOptions setOptions(EncryptionOption encryptionOption) { + this.options = encryptionOption; + return this; + } + + /** + * Gets the state. + * + * @return the state + */ + public AssetState getState() { + return state; + } + + /** + * Sets the state. + * + * @param assetState + * the asset state + * @return the creates the asset options + */ + public CreateAssetOptions setState(AssetState assetState) { + this.state = assetState; + return this; + } + } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java new file mode 100644 index 0000000000000..07390ecd2dfce --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java @@ -0,0 +1,60 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +public class UpdateAssetOptions { + + private String alternateId; + private String name; + private EncryptionOption options; + private AssetState state; + + public String getAlternateId() { + return alternateId; + } + + public UpdateAssetOptions setAlternatedId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + public String getName() { + return name; + } + + public UpdateAssetOptions setName(String name) { + this.name = name; + return this; + } + + public EncryptionOption getOptions() { + return options; + } + + public UpdateAssetOptions setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + public AssetState getState() { + return state; + } + + public UpdateAssetOptions setState(AssetState assetState) { + this.state = assetState; + return this; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index a838f8cac87c1..5b941aef9b446 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -24,8 +24,9 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { private static MediaContract service; @@ -37,7 +38,12 @@ public static void setup() throws Exception { service = MediaService.create(config); List<AssetInfo> listAssetsResult = service.listAssets(null); for (AssetInfo assetInfo : listAssetsResult) { - service.deleteAsset(assetInfo.getId()); + try { + service.deleteAsset(assetInfo.getId()); + } + catch (Exception e) { + e.printStackTrace(); + } } } @@ -66,45 +72,43 @@ public void createAssetSuccess() throws Exception { AssetInfo expectedAsset = new AssetInfo().setName("testAssetName"); // Act - AssetInfo actualAsset = service.createAsset(expectedAsset); + AssetInfo actualAsset = service.createAsset("testAssetName"); // Assert - assertEquals(expectedAsset, actualAsset); + assertEquals(expectedAsset.getName(), actualAsset.getName()); } @Test - public void createAssetMissingNameFailed() { + public void createAssetNullNameSuccess() throws ServiceException { // Arrange - AssetInfo expectedAsset = new AssetInfo(); // Act - AssetInfo actualAsset = service.createAsset(expectedAsset); + AssetInfo actualAsset = service.createAsset(null); // Assert - assertTrue(false); + assertNotNull(actualAsset); } @Test public void getAssetSuccess() throws Exception { // Arrange - AssetInfo expectedAsset = new AssetInfo(); - AssetInfo assetInfo = service.createAsset(expectedAsset); + AssetInfo expectedAsset = new AssetInfo().setName("testGetAssetSuccess"); + AssetInfo assetInfo = service.createAsset("testGetAssetSuccess"); // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); // Assert - assertEquals(expectedAsset, actualAsset); + assertEquals(expectedAsset.getName(), actualAsset.getName()); } - @Test - public void getAssetFailedWithInvalidId() { + @Test(expected = ServiceException.class) + public void getAssetFailedWithInvalidId() throws ServiceException { // Arrange - AssetInfo expectedAsset = new AssetInfo(); - service.createAsset(expectedAsset); + AssetInfo expectedAsset = new AssetInfo().setId("IncorrectAssetId"); // Act - AssetInfo actualAsset = service.getAsset(expectedAsset.setId("IncorrectAssetId").getId()); + AssetInfo actualAsset = service.getAsset(expectedAsset.getId()); // Assert assertTrue(false); @@ -112,57 +116,45 @@ public void getAssetFailedWithInvalidId() { } @Test - public void listAssetSuccess() { + public void listAssetSuccess() throws ServiceException { // Arrange + Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); AssetInfo assetA = new AssetInfo(); AssetInfo assetB = new AssetInfo(); - service.createAsset(assetA); - service.createAsset(assetB); - ListAssetsOptions listAssetOptions = new ListAssetsOptions(); + service.createAsset("assetA"); + service.createAsset("assetB"); // Act - Collection<AssetInfo> listAssetResult = service.listAssets(listAssetOptions); + Collection<AssetInfo> listAssetResult = service.listAssets(); // Assert - assertEquals(2, listAssetResult.size()); - } - - @Test - public void listAssetFailed() { - // Arrange - ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); - - // Act - Collection<AssetInfo> listAssetResult = service.listAssets(listAssetsOptions); - - // Assert - assertTrue(false); + assertEquals(listAssetResultBaseLine.size() + 2, listAssetResult.size()); } @Test public void updateAssetSuccess() throws Exception { // Arrange - AssetInfo originalAsset = new AssetInfo(); - service.createAsset(originalAsset); - AssetInfo updatedAsset = new AssetInfo(); + + AssetInfo updatedAsset = service.createAsset("updateAssetSuccess"); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName("updateAssetSuccessResult"); + updatedAsset.setName("updateAssetSuccessResult"); // Act - service.updateAsset(updatedAsset); - AssetInfo actualAsset = service.updateAsset(updatedAsset); + service.updateAsset(updatedAsset.getId(), updateAssetOptions); + AssetInfo actualAsset = service.getAsset(updatedAsset.getId()); // Assert - assertEquals(updatedAsset, actualAsset); + assertEquals(updatedAsset.getName(), actualAsset.getName()); } - @Test - public void updateAssetFailedWithInvalidId() { + @Test(expected = ServiceException.class) + public void updateAssetFailedWithInvalidId() throws ServiceException { // Arrange - MediaContract service = MediaService.create(config); - AssetInfo updatedAsset = new AssetInfo(); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); // Act - service.updateAsset(updatedAsset); + service.updateAsset("updateAssetFailedWithInvalidId", updateAssetOptions); // Assert assertTrue(false); @@ -171,21 +163,21 @@ public void updateAssetFailedWithInvalidId() { @Test public void deleteAssetSuccess() throws Exception { // Arrange - AssetInfo asset = new AssetInfo(); - service.createAsset(asset); + String assetName = "deleteAssetSuccess"; + AssetInfo assetInfo = service.createAsset(assetName); List<AssetInfo> listAssetsResult = service.listAssets(null); - assertEquals(1, listAssetsResult.size()); + int assetCountBaseline = listAssetsResult.size(); // Act - service.deleteAsset(asset.getId()); + service.deleteAsset(assetInfo.getId()); // Assert listAssetsResult = service.listAssets(null); - assertEquals(0, listAssetsResult.size()); + assertEquals(assetCountBaseline - 1, listAssetsResult.size()); } - @Test - public void deleteAssetFailedWithInvalidId() { + @Test(expected = ServiceException.class) + public void deleteAssetFailedWithInvalidId() throws ServiceException { // Arrange // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 2c2ac5bf05e52..53c67ba9798bb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -97,7 +97,7 @@ public void canCreateAssetThroughMediaServiceAPI() throws Exception { @Test public void canRetrieveListOfAssets() throws Exception { MediaContract client = MediaService.create(config); - List<AssetInfo> assets = client.getAssets(); + List<AssetInfo> assets = client.listAssets(); Assert.assertNotNull(assets); } From 0a67369c5d93e00aa7df282cf48a45df7d0d65f4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 26 Sep 2012 16:27:37 -0700 Subject: [PATCH 348/664] Code review feedback for Asset CRUD operation. --- .../services/media/MediaContract.java | 37 ++++----- .../MediaExceptionProcessor.java | 57 +++++++------- .../media/implementation/MediaRestProxy.java | 75 ++++++------------- .../services/media/models/AssetInfo.java | 1 - .../media/models/UpdateAssetOptions.java | 2 +- .../media/models/CreateAssetOptionsTest.java | 62 +++++++++++++++ .../media/models/UpdateAssetOptionsTest.java | 75 +++++++++++++++++++ 7 files changed, 204 insertions(+), 105 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 49a8cb4411caa..7dfa4844ad837 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -28,25 +28,6 @@ */ public interface MediaContract extends FilterableService<MediaContract> { - /** - * List assets. - * - * @param listAssetsOptions - * the list assets options - * @return the list - * @throws ServiceException - */ - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; - - /** - * Delete asset. - * - * @param assetId - * the asset id - * @throws ServiceException - */ - public void deleteAsset(String assetId) throws ServiceException; - /** * Creates the asset. * @@ -69,6 +50,15 @@ public interface MediaContract extends FilterableService<MediaContract> { */ public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException; + /** + * Delete asset. + * + * @param assetId + * the asset id + * @throws ServiceException + */ + public void deleteAsset(String assetId) throws ServiceException; + /** * Gets the asset. * @@ -88,13 +78,14 @@ public interface MediaContract extends FilterableService<MediaContract> { public List<AssetInfo> listAssets() throws ServiceException; /** - * Delete asset. + * List assets. * - * @param assetInfo - * the asset info + * @param listAssetsOptions + * the list assets options + * @return the list * @throws ServiceException */ - public void deleteAsset(AssetInfo assetInfo) throws ServiceException; + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; /** * Update asset. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 838068976a573..9af373b2ae08d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -104,12 +104,12 @@ public AssetInfo createAsset(String assetName) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() + * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) */ @Override - public List<AssetInfo> listAssets() throws ServiceException { + public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException { try { - return service.listAssets(); + return service.createAsset(assetName, createAssetOptions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -120,27 +120,17 @@ public List<AssetInfo> listAssets() throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) */ @Override - public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { + public void deleteAsset(String assetId) throws ServiceException { try { - service.updateAsset(assetId, updateAssetOptions); + service.deleteAsset(assetId); } catch (UniformInterfaceException e) { - throw new ServiceException(e); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) - */ - @Override - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException { - try { - return service.createAsset(assetName, createAssetOptions); + throw processCatch(new ServiceException(e)); } - catch (UniformInterfaceException e) { + catch (ClientHandlerException e) { throw processCatch(new ServiceException(e)); } } @@ -156,46 +146,57 @@ public AssetInfo getAsset(String assetId) throws ServiceException { catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } - + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() */ @Override - public void deleteAsset(String assetId) throws ServiceException { + public List<AssetInfo> listAssets() throws ServiceException { try { - service.deleteAsset(assetId); + return service.listAssets(); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) */ @Override - public void deleteAsset(AssetInfo assetInfo) throws ServiceException { + public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { try { - service.deleteAsset(assetInfo); + return service.listAssets(listAssetsOptions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) + * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) */ @Override - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { + public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { try { - return service.listAssets(listAssetsOptions); + service.updateAsset(assetId, updateAssetOptions); } 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index fc03acea681f5..eb060a973833f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -39,7 +39,6 @@ import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; /** @@ -140,8 +139,7 @@ private WebResource getResource(String entityName) { */ @Override public AssetInfo createAsset(String assetName) throws ServiceException { - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - return this.createAsset(assetName, createAssetOptions); + return this.createAsset(assetName, null); } /* (non-Javadoc) @@ -150,17 +148,19 @@ public AssetInfo createAsset(String assetName) throws ServiceException { @Override public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { WebResource resource = getResource("Assets"); - AssetType assetType = new AssetType(); - assetType.setName(assetName); - assetType.setAlternateId(createAssetOptions.getAlternateId()); - if (createAssetOptions.getOptions() != null) { - assetType.setOptions(createAssetOptions.getOptions().getCode()); - } - if (createAssetOptions.getState() != null) { - assetType.setState(createAssetOptions.getState().getCode()); + AssetType assetTypeForSubmission = new AssetType(); + assetTypeForSubmission.setName(assetName); + if (createAssetOptions != null) { + assetTypeForSubmission.setAlternateId(createAssetOptions.getAlternateId()); + if (createAssetOptions.getOptions() != null) { + assetTypeForSubmission.setOptions(createAssetOptions.getOptions().getCode()); + } + if (createAssetOptions.getState() != null) { + assetTypeForSubmission.setState(createAssetOptions.getState().getCode()); + } } return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(AssetInfo.class, assetType); + .post(AssetInfo.class, assetTypeForSubmission); } /* (non-Javadoc) @@ -168,18 +168,9 @@ public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOpt */ @Override public AssetInfo getAsset(String assetId) throws ServiceException { - String escapedAssetId = null; - try { - escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new ServiceException(e); - } - String assetPath = String.format("Assets(\'%s\')", escapedAssetId); - WebResource resource = getResource(assetPath); + WebResource resource = getResource("Assets", assetId); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<AssetInfo>() { - }); + .get(AssetInfo.class); } /* (non-Javadoc) @@ -215,7 +206,6 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t throw new ServiceException(e); } String assetPath = String.format("Assets(\'%s\')", escapedAssetId); - WebResource resource = getResource(assetPath); AssetType updatedAssetType = new AssetType(); updatedAssetType.setAlternateId(updateAssetOptions.getAlternateId()); updatedAssetType.setName(updateAssetOptions.getName()); @@ -236,39 +226,20 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t */ @Override public void deleteAsset(String assetId) throws ServiceException { - String escapedAssetId = null; + getResource("Assets", assetId).delete(); + } + + private WebResource getResource(String entityType, String entityId) throws ServiceException { + String escapedEntityId = null; try { - escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); + escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new ServiceException(e); } - String assetPath = String.format("Assets(\'%s\')", escapedAssetId); - WebResource resource = getResource(assetPath); - try { - resource.delete(); - } - catch (UniformInterfaceException e) { - throw new ServiceException(e); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) - */ - @Override - public void deleteAsset(AssetInfo assetInfo) throws ServiceException { - this.deleteAsset(assetInfo.getId()); - } - - private <T> T mergeRequest(String path, GenericType<T> genericClass, java.lang.Object requestEntity) - throws ServiceException { - WebResource resource = getResource(path); - WebResource.Builder builder = resource.getRequestBuilder(); - builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .header("X-HTTP-Method", "MERGE"); - return builder.method("POST", genericClass, requestEntity); + String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); + return getResource(entityPath); } private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { @@ -276,7 +247,7 @@ private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object r WebResource.Builder builder = resource.getRequestBuilder(); builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .header("X-HTTP-Method", "MERGE"); - return builder.method("POST", c, requestEntity); + return builder.post(c, requestEntity); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index c7e9468f9e0a3..68a1c9058cf81 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -1,5 +1,4 @@ /** - * >>>>>>> e8cf07bb1f265cdf72add1bd00ac069cb4dbaa33 * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java index 07390ecd2dfce..8e452dddc78f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java @@ -25,7 +25,7 @@ public String getAlternateId() { return alternateId; } - public UpdateAssetOptions setAlternatedId(String alternateId) { + public UpdateAssetOptions setAlternateId(String alternateId) { this.alternateId = alternateId; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java new file mode 100644 index 0000000000000..93f09cbde5e18 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java @@ -0,0 +1,62 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CreateAssetOptionsTest { + + @Test + public void testGetSetState() { + // Arrange + AssetState expectedState = AssetState.Published; + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + + // Act + AssetState actualState = createAssetOptions.setState(expectedState).getState(); + + // Assert + assertEquals(expectedState, actualState); + } + + @Test + public void testGetSetAlternateId() { + // Arrange + String expectedAlternateId = "testAlternateId"; + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + + // Act + String actualAlternateId = createAssetOptions.setAlternateId(expectedAlternateId).getAlternateId(); + + // Assert + assertEquals(expectedAlternateId, actualAlternateId); + } + + @Test + public void testGetSetOptions() { + // Arrange + EncryptionOption expectedOptions = EncryptionOption.None; + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + + // Act + EncryptionOption actualOptions = createAssetOptions.setOptions(expectedOptions).getOptions(); + + // Assert + assertEquals(expectedOptions, actualOptions); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java new file mode 100644 index 0000000000000..be47f311119b2 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java @@ -0,0 +1,75 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class UpdateAssetOptionsTest { + + @Test + public void testGetSetState() { + // Arrange + AssetState expectedState = AssetState.Published; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + AssetState actualState = updateAssetOptions.setState(expectedState).getState(); + + // Assert + assertEquals(expectedState, actualState); + } + + @Test + public void testGetSetAlternateId() { + // Arrange + String expectedAlternateId = "testAlternateId"; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + String actualAlternateId = updateAssetOptions.setAlternateId(expectedAlternateId).getAlternateId(); + + // Assert + assertEquals(expectedAlternateId, actualAlternateId); + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testName"; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + String actualName = updateAssetOptions.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetOptions() { + // Arrange + EncryptionOption expectedOptions = EncryptionOption.None; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + EncryptionOption actualOptions = updateAssetOptions.setOptions(expectedOptions).getOptions(); + + // Assert + assertEquals(expectedOptions, actualOptions); + } + +} From 927e6bb999d56014bf4ee008bf80b57d41168b7e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 26 Sep 2012 16:30:04 -0700 Subject: [PATCH 349/664] adds missing java doc skeleton for UpdateAssetOptions class. --- .../media/models/UpdateAssetOptions.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java index 8e452dddc78f3..74b4a51e4daf7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java @@ -14,44 +14,103 @@ */ package com.microsoft.windowsazure.services.media.models; +// TODO: Auto-generated Javadoc +/** + * The Class UpdateAssetOptions. + */ public class UpdateAssetOptions { + /** The alternate id. */ private String alternateId; + + /** The name. */ private String name; + + /** The options. */ private EncryptionOption options; + + /** The state. */ private AssetState state; + /** + * Gets the alternate id. + * + * @return the alternate id + */ public String getAlternateId() { return alternateId; } + /** + * Sets the alternate id. + * + * @param alternateId + * the alternate id + * @return the update asset options + */ public UpdateAssetOptions setAlternateId(String alternateId) { this.alternateId = alternateId; return this; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { return name; } + /** + * Sets the name. + * + * @param name + * the name + * @return the update asset options + */ public UpdateAssetOptions setName(String name) { this.name = name; return this; } + /** + * Gets the options. + * + * @return the options + */ public EncryptionOption getOptions() { return options; } + /** + * Sets the options. + * + * @param options + * the options + * @return the update asset options + */ public UpdateAssetOptions setOptions(EncryptionOption options) { this.options = options; return this; } + /** + * Gets the state. + * + * @return the state + */ public AssetState getState() { return state; } + /** + * Sets the state. + * + * @param assetState + * the asset state + * @return the update asset options + */ public UpdateAssetOptions setState(AssetState assetState) { this.state = assetState; return this; From 43b8223e41819368fff6a90648b5c352d348abfb Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 27 Sep 2012 11:46:52 -0700 Subject: [PATCH 350/664] Expose AssetInfo Date as Date. --- .../implementation/content/AssetType.java | 5 +++-- .../services/media/models/AssetInfo.java | 19 ++++++++++--------- .../services/media/models/AssetInfoTest.java | 17 ++++------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 84f5b353785ab..9d48dfd71a29a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.datatype.XMLGregorianCalendar; +import com.microsoft.windowsazure.services.core.utils.DateConverter; import com.microsoft.windowsazure.services.media.models.AssetInfo; /** @@ -159,9 +160,9 @@ public void setOptions(int options) { public static AssetType create(AssetInfo assetInfo) { AssetType assetType = new AssetType(); assetType.setAlternateId(assetInfo.getAlternateId()); - assetType.setCreated(assetInfo.getCreated()); + assetType.setCreated(DateConverter.DateToXMLGregorianCalendar(assetInfo.getCreated())); assetType.setId(assetInfo.getId()); - assetType.setLastModified(assetInfo.getLastModified()); + assetType.setLastModified(DateConverter.DateToXMLGregorianCalendar(assetInfo.getLastModified())); assetType.setName(assetInfo.getName()); assetType.setOptions(assetInfo.getOptions().getCode()); assetType.setState(assetInfo.getState().getCode()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 68a1c9058cf81..736c2366a7d4b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,8 +15,9 @@ package com.microsoft.windowsazure.services.media.models; -import javax.xml.datatype.XMLGregorianCalendar; +import java.util.Date; +import com.microsoft.windowsazure.services.core.utils.DateConverter; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; @@ -103,8 +104,8 @@ public AssetInfo setState(AssetState state) { * * @return the date */ - public XMLGregorianCalendar getCreated() { - return this.getContent().getCreated(); + public Date getCreated() { + return DateConverter.XMLGregorianCalendarToDate(this.getContent().getCreated()); } /** @@ -114,8 +115,8 @@ public XMLGregorianCalendar getCreated() { * the date * @return the asset info */ - public AssetInfo setCreated(XMLGregorianCalendar created) { - getContent().setCreated(created); + public AssetInfo setCreated(Date created) { + getContent().setCreated(DateConverter.DateToXMLGregorianCalendar(created)); return this; } @@ -124,8 +125,8 @@ public AssetInfo setCreated(XMLGregorianCalendar created) { * * @return the date */ - public XMLGregorianCalendar getLastModified() { - return getContent().getLastModified(); + public Date getLastModified() { + return DateConverter.XMLGregorianCalendarToDate(getContent().getLastModified()); } /** @@ -135,8 +136,8 @@ public XMLGregorianCalendar getLastModified() { * the date * @return the asset info */ - public AssetInfo setLastModified(XMLGregorianCalendar lastModified) { - getContent().setLastModified(lastModified); + public AssetInfo setLastModified(Date lastModified) { + getContent().setLastModified(DateConverter.DateToXMLGregorianCalendar(lastModified)); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index a1b33f825fa46..2e974c81773c9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -17,10 +17,6 @@ import static org.junit.Assert.*; import java.util.Date; -import java.util.GregorianCalendar; - -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; import org.junit.Test; @@ -56,14 +52,12 @@ public void testGetSetState() { @Test public void testGetSetCreated() throws Exception { // Arrange - GregorianCalendar c = new GregorianCalendar(); - c.setTime(new Date()); - XMLGregorianCalendar expectedCreated = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + Date expectedCreated = new Date(); AssetInfo assetInfo = new AssetInfo(); // Act - XMLGregorianCalendar actualCreated = assetInfo.setCreated(expectedCreated).getCreated(); + Date actualCreated = assetInfo.setCreated(expectedCreated).getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -73,14 +67,11 @@ public void testGetSetCreated() throws Exception { @Test public void testGetSetLastModified() throws Exception { // Arrange - - GregorianCalendar c = new GregorianCalendar(); - c.setTime(new Date()); - XMLGregorianCalendar expectedLastModified = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + Date expectedLastModified = new Date(); AssetInfo assetInfo = new AssetInfo(); // Act - XMLGregorianCalendar actualLastModified = assetInfo.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = assetInfo.setLastModified(expectedLastModified).getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); From b93edab6083594e88853e3fa3c5e7d5c136f61bd Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 27 Sep 2012 11:48:09 -0700 Subject: [PATCH 351/664] Add DateConverter to transform XMLGregorianCalendar back and forth. --- .../services/core/utils/DateConverter.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java new file mode 100644 index 0000000000000..60c99c6edc810 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java @@ -0,0 +1,72 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.core.utils; + +import java.util.Date; +import java.util.GregorianCalendar; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +/** + * The Class DateConverter. + */ +public class DateConverter { + + /** The datatype factory. */ + private static DatatypeFactory datatypeFactory = null; + + static { + try { + datatypeFactory = DatatypeFactory.newInstance(); + } + catch (DatatypeConfigurationException e) { + throw new IllegalStateException("Cannot create a new DatatypeFactory instance.", e); + } + } + + /** + * XML gregorian calendar to date. + * + * @param xmlGregorianCalendar + * the xml gregorian calendar + * @return the date + */ + public static Date XMLGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar) { + if (xmlGregorianCalendar == null) { + return null; + } + + return xmlGregorianCalendar.toGregorianCalendar().getTime(); + } + + /** + * Date to xml gregorian calendar. + * + * @param date + * the date + * @return the xML gregorian calendar + */ + public static XMLGregorianCalendar DateToXMLGregorianCalendar(Date date) { + if (date == null) { + return null; + } + + GregorianCalendar gregorianCalendar = new GregorianCalendar(); + gregorianCalendar.setTimeInMillis(date.getTime()); + return datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); + } +} From 22ad696828f282a691df08418ee078fb2c1c93e4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 27 Sep 2012 11:51:29 -0700 Subject: [PATCH 352/664] fix the year in the license. --- .../windowsazure/services/core/utils/DateConverter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java index 60c99c6edc810..ee00445cf6b61 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 509b321391e675b4e40007cfa2ab424c494ae20e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 27 Sep 2012 15:43:30 -0700 Subject: [PATCH 353/664] minor clean up of the code. --- .../windowsazure/services/media/models/UpdateAssetOptions.java | 1 - 1 file changed, 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java index 74b4a51e4daf7..dd0affeac070e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java @@ -14,7 +14,6 @@ */ package com.microsoft.windowsazure.services.media.models; -// TODO: Auto-generated Javadoc /** * The Class UpdateAssetOptions. */ From 9b929240adfe408946c45773940825f32b46a8d2 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 1 Oct 2012 12:22:40 -0700 Subject: [PATCH 354/664] Access policy crud implementation --- .../services/media/MediaContract.java | 66 ++++++++ .../MediaExceptionProcessor.java | 98 ++++++++++++ .../media/implementation/MediaRestProxy.java | 100 ++++++++++-- .../implementation/ODataAtomMarshaller.java | 2 + .../content/AccessPolicyType.java | 145 ++++++++++++++++++ .../implementation/content/ObjectFactory.java | 9 ++ .../media/models/AccessPolicyInfo.java | 74 +++++++++ .../models/CreateAccessPolicyOptions.java | 41 +++++ .../media/models/ListAccessPolicyOptions.java | 24 +++ .../media/AccessPolicyIntegrationTest.java | 117 ++++++++++++++ .../ODataSerializationFromJerseyTest.java | 1 + .../media/models/AccessPolicyInfoTest.java | 86 +++++++++++ 12 files changed, 747 insertions(+), 16 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 7dfa4844ad837..cd0b1c90560b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -18,8 +18,11 @@ import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -99,4 +102,67 @@ public interface MediaContract extends FilterableService<MediaContract> { */ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException; + /** + * Create the access policy + * + * @param name + * name of access policy + * @param durationInMinutes + * duration access policy is active + * @return Created access policy + * @throws ServiceException + */ + AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException; + + /** + * Create the access policy with the given options + * + * @param name + * name of access policy + * @param durationInMinutes + * duration access policy is active + * @param options + * options for creation + * @return the created access policy + * @throws ServiceException + */ + AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) + throws ServiceException; + + /** + * Delete the access policy with the given id + * + * @param id + * of access policy to delete + * @throws ServiceException + */ + void deleteAccessPolicy(String id) throws ServiceException; + + /** + * Get a single access policy + * + * @param id + * the id of the asset to retrieve + * @return the asset + * @throws ServiceException + */ + AccessPolicyInfo getAccessPolicy(String id) throws ServiceException; + + /** + * List access policies + * + * @return the list + * @throws ServiceException + */ + List<AccessPolicyInfo> listAccessPolicies() throws ServiceException; + + /** + * List access policies + * + * @param options + * the list access policy options + * @return the list + * @throws ServiceException + */ + List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 9af373b2ae08d..314111bc50b34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -26,8 +26,11 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.sun.jersey.api.client.ClientHandlerException; @@ -199,4 +202,99 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) + */ + @Override + public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { + try { + return service.createAccessPolicy(name, durationInMinutes); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) + */ + @Override + public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) + throws ServiceException { + try { + return service.createAccessPolicy(name, durationInMinutes, options); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicies() + */ + @Override + public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { + try { + return service.listAccessPolicies(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) + */ + @Override + public void deleteAccessPolicy(String id) throws ServiceException { + try { + service.deleteAccessPolicy(id); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) + */ + @Override + public AccessPolicyInfo getAccessPolicy(String id) throws ServiceException { + try { + return service.getAccessPolicy(id); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies(com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions) + */@Override + public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { + try { + return service.listAccessPolicies(); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index eb060a973833f..3ba10b301cd79 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -31,9 +31,14 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.sun.jersey.api.client.Client; @@ -134,6 +139,27 @@ private WebResource getResource(String entityName) { return resource; } + private WebResource getResource(String entityType, String entityId) throws ServiceException { + String escapedEntityId = null; + try { + escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); + + return getResource(entityPath); + } + + private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { + WebResource resource = getResource(path); + WebResource.Builder builder = resource.getRequestBuilder(); + builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .header("X-HTTP-Method", "MERGE"); + return builder.post(c, requestEntity); + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) */ @@ -229,26 +255,68 @@ public void deleteAsset(String assetId) throws ServiceException { getResource("Assets", assetId).delete(); } - private WebResource getResource(String entityType, String entityId) throws ServiceException { - String escapedEntityId = null; - try { - escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new ServiceException(e); - } - String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) + */ + @Override + public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); + options.getPermissions().add(AccessPolicyPermission.WRITE); + return createAccessPolicy(name, durationInMinutes, options); + } - return getResource(entityPath); + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) + */ + @Override + public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) + throws ServiceException { + + AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes).setName(name) + .setPermissions(AccessPolicyPermission.bitsFromPermissions(options.getPermissions())); + + WebResource resource = getResource("AccessPolicies"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(AccessPolicyInfo.class, requestData); } - private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { - WebResource resource = getResource(path); - WebResource.Builder builder = resource.getRequestBuilder(); - builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .header("X-HTTP-Method", "MERGE"); - return builder.post(c, requestEntity); + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) + */ + @Override + public AccessPolicyInfo getAccessPolicy(String id) throws ServiceException { + WebResource resource = getResource("AccessPolicies", id); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(AccessPolicyInfo.class); + } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) + */ + @Override + public void deleteAccessPolicy(String id) throws ServiceException { + getResource("AccessPolicies", id).delete(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() + */ + @Override + public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { + WebResource resource = getResource("AccessPolicies"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<List<AccessPolicyInfo>>() { + }); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() + */ + @Override + public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { + // Currently no options defined so can call zero arg overload instead + return listAccessPolicies(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 2556c510a5ff2..13edb3b00de50 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -33,6 +33,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.FeedType; +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; @@ -114,6 +115,7 @@ private static Class<?>[] getMarshalledClasses() { classes.add(FeedType.class); classes.add(EntryType.class); classes.add(AssetType.class); + classes.add(AccessPolicyType.class); return classes.toArray(new Class<?>[0]); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java new file mode 100644 index 0000000000000..219a65b668f16 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -0,0 +1,145 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * Wrapper DTO for Media Services access policies. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class AccessPolicyType implements MediaServiceDTO { + + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + protected Date created; + + @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + protected Date lastModified; + + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + @XmlElement(name = "DurationInMinutes", namespace = Constants.ODATA_DATA_NS) + protected double durationInMinutes; + + @XmlElement(name = "Permissions", namespace = Constants.ODATA_DATA_NS) + protected int permissions; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public AccessPolicyType setId(String id) { + this.id = id; + return this; + } + + /** + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * @param created + * the created to set + */ + public AccessPolicyType setCreated(Date created) { + this.created = created; + return this; + } + + /** + * @return the lastModified + */ + public Date getLastModified() { + return lastModified; + } + + /** + * @param lastModified + * the lastModified to set + */ + public AccessPolicyType setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public AccessPolicyType setName(String name) { + this.name = name; + return this; + } + + /** + * @return the durationInMinutes + */ + public double getDurationInMinutes() { + return durationInMinutes; + } + + /** + * @param durationInMinutes + * the durationInMinutes to set + */ + public AccessPolicyType setDurationInMinutes(double durationInMinutes) { + this.durationInMinutes = durationInMinutes; + return this; + } + + /** + * @return the permissions + */ + public int getPermissions() { + return permissions; + } + + /** + * @param permissions + * the permissions to set + */ + public AccessPolicyType setPermissions(int permissions) { + this.permissions = permissions; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index d353a7d006964..09cc9f513adba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -49,4 +49,13 @@ public AssetType createAssetType() { public ODataActionType createODataActionType() { return new ODataActionType(); } + + /** + * Create an instance of {@link AccessPolicyType } + * + * @return a new AccessPolicyType instance. + */ + public AccessPolicyType createAccessPolicyType() { + return new AccessPolicyType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java new file mode 100644 index 0000000000000..50213d4503654 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -0,0 +1,74 @@ +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; +import java.util.EnumSet; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; + +public class AccessPolicyInfo extends ODataEntity<AccessPolicyType> { + + public AccessPolicyInfo(EntryType entry, AccessPolicyType content) { + super(entry, content); + // TODO Auto-generated constructor stub + } + + public AccessPolicyInfo() { + super(new AccessPolicyType()); + } + + public String getId() { + return getContent().getId(); + } + + public AccessPolicyInfo setId(String id) { + getContent().setId(id); + return this; + } + + public Date getCreated() { + return getContent().getCreated(); + } + + public AccessPolicyInfo setCreated(Date created) { + getContent().setCreated(created); + return this; + } + + public Date getLastModified() { + return getContent().getLastModified(); + } + + public AccessPolicyInfo setLastModified(Date lastModified) { + getContent().setLastModified(lastModified); + return this; + } + + public String getName() { + return getContent().getName(); + } + + public AccessPolicyInfo setName(String name) { + getContent().setName(name); + return this; + } + + public double getDurationInMinutes() { + return getContent().getDurationInMinutes(); + } + + public AccessPolicyInfo setDurationInMinutes(double durationInMinutes) { + getContent().setDurationInMinutes(durationInMinutes); + return this; + } + + public EnumSet<AccessPolicyPermission> getPermissions() { + return AccessPolicyPermission.permissionsFromBits(getContent().getPermissions()); + } + + public AccessPolicyInfo setPermissions(EnumSet<AccessPolicyPermission> permissions) { + getContent().setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java new file mode 100644 index 0000000000000..d5e4cb87ee0c6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java @@ -0,0 +1,41 @@ +package com.microsoft.windowsazure.services.media.models; + +import java.util.EnumSet; + +public class CreateAccessPolicyOptions { + private final EnumSet<AccessPolicyPermission> permissions = EnumSet.noneOf(AccessPolicyPermission.class); + + public CreateAccessPolicyOptions() { + } + + /** + * Returns a live pointer to the underlying permissions set. + * + * @return the permissions + */ + public EnumSet<AccessPolicyPermission> getPermissions() { + return permissions; + } + + /** + * Add the given permissions to this creation request + * + * @param permissionsToAdd + * @return the CreateAccessPolicyOptions object + */ + public CreateAccessPolicyOptions addPermissions(EnumSet<AccessPolicyPermission> permissionsToAdd) { + permissions.addAll(permissionsToAdd); + return this; + } + + /** + * Remove the given permissions from this creation request + * + * @param permissionsToRemove + * @return the CreateAccessPolicyOptions object + */ + public CreateAccessPolicyOptions removePermissions(EnumSet<AccessPolicyPermission> permissionsToRemove) { + permissions.removeAll(permissionsToRemove); + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java new file mode 100644 index 0000000000000..2327574c985bc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java @@ -0,0 +1,24 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +/** + * Options class for listing access policies + * No options available at this time. + */ +public class ListAccessPolicyOptions { + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java new file mode 100644 index 0000000000000..2dea4f4e4d86b --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -0,0 +1,117 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.EnumSet; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; + +public class AccessPolicyIntegrationTest extends IntegrationTestBase { + private static MediaContract service; + + @BeforeClass + public static void setup() throws Exception { + service = MediaService.create(createConfig()); + } + + private static Configuration createConfig() { + Configuration config = Configuration.getInstance(); + overrideWithEnv(config, MediaConfiguration.URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); + return config; + } + + @AfterClass + public static void cleanup() throws Exception { + for (AccessPolicyInfo policy : service.listAccessPolicies()) { + if (policy.getName().startsWith("testPolicy")) { + service.deleteAccessPolicy(policy.getId()); + } + } + } + + @Test + public void canCreateAccessPolicy() throws Exception { + AccessPolicyInfo policy = service.createAccessPolicy("testPolicy", 5, + new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE))); + + assertTrue(policy.getPermissions().contains(AccessPolicyPermission.WRITE)); + } + + @Test + public void canGetSinglePolicyById() throws Exception { + String expectedName = "testPolicyGetOne"; + AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, 1); + + AccessPolicyInfo retrievedPolicy = service.getAccessPolicy(policyToGet.getId()); + + assertEquals(expectedName, retrievedPolicy.getName()); + assertEquals(policyToGet.getId(), retrievedPolicy.getId()); + } + + @Test + public void canRetrieveListOfAccessPolicies() throws Exception { + String[] policyNames = new String[] { "testPolicy1", "testPolicy2" }; + for (String name : policyNames) { + service.createAccessPolicy(name, 3, new CreateAccessPolicyOptions().addPermissions(EnumSet.of( + AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); + } + + List<AccessPolicyInfo> policies = service.listAccessPolicies(); + + assertNotNull(policies); + assertTrue(policies.size() >= 2); + + AccessPolicyInfo policy1 = null; + AccessPolicyInfo policy2 = null; + + for (AccessPolicyInfo policy : policies) { + if (policy.getName().equals("testPolicy1")) { + policy1 = policy; + } + if (policy.getName().equals("testPolicy2")) { + policy2 = policy; + } + } + + assertNotNull(policy1); + assertNotNull(policy2); + } + + @Test + public void canDeleteAccessPolicyById() throws Exception { + AccessPolicyInfo policyToDelete = service.createAccessPolicy("testPolicyToDelete", 1); + + service.deleteAccessPolicy(policyToDelete.getId()); + + for (AccessPolicyInfo policy : service.listAccessPolicies()) { + assertFalse(policyToDelete.getId().equals(policy.getId())); + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 53c67ba9798bb..84a8d66b47d20 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -101,4 +101,5 @@ public void canRetrieveListOfAssets() throws Exception { Assert.assertNotNull(assets); } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java new file mode 100644 index 0000000000000..c18e9a5297c56 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java @@ -0,0 +1,86 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; +import java.util.EnumSet; + +import org.junit.Assert; +import org.junit.Test; + +public class AccessPolicyInfoTest { + + @Test + public void getSetId() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + String expected = "expectedId"; + + String actual = policy.setId(expected).getId(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getSetCreated() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + Date expected = new Date(); + + Date actual = policy.setCreated(expected).getCreated(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getSetLastModified() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + Date expected = new Date(); + + Date actual = policy.setLastModified(expected).getLastModified(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getSetName() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + String expected = "policy name goes here"; + + String actual = policy.setName(expected).getName(); + + Assert.assertEquals(expected, actual); + } + + @Test + public void getSetDurationInMinutes() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + double expected = 60; // arbitrary value + + double actual = policy.setDurationInMinutes(expected).getDurationInMinutes(); + + Assert.assertEquals(expected, actual, 0.0); + } + + @Test + public void getSetPermissions() { + AccessPolicyInfo policy = new AccessPolicyInfo(); + EnumSet<AccessPolicyPermission> expected = EnumSet + .of(AccessPolicyPermission.LIST, AccessPolicyPermission.WRITE); + + EnumSet<AccessPolicyPermission> actual = policy.setPermissions(expected).getPermissions(); + + Assert.assertEquals(expected, actual); + } +} From fc42caf090e754e9e5f5642a1f45e57ac2392af1 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 1 Oct 2012 14:31:14 -0700 Subject: [PATCH 355/664] Updated for code review feedback --- .../services/media/MediaContract.java | 4 +- .../media/implementation/MediaRestProxy.java | 22 +++---- .../media/models/AccessPolicyInfo.java | 16 ++++- .../media/AccessPolicyIntegrationTest.java | 60 ++++++++++++++++--- 4 files changed, 81 insertions(+), 21 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index cd0b1c90560b0..aac6354b6947c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -108,7 +108,7 @@ public interface MediaContract extends FilterableService<MediaContract> { * @param name * name of access policy * @param durationInMinutes - * duration access policy is active + * Duration in minutes that blob access will be granted when using this access policy * @return Created access policy * @throws ServiceException */ @@ -120,7 +120,7 @@ public interface MediaContract extends FilterableService<MediaContract> { * @param name * name of access policy * @param durationInMinutes - * duration access policy is active + * Duration in minutes that blob access will be granted when using this access policy * @param options * options for creation * @return the created access policy diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 3ba10b301cd79..c27f83ff48ff0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -18,6 +18,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; +import java.util.EnumSet; import java.util.List; import javax.inject.Inject; @@ -260,9 +261,7 @@ public void deleteAsset(String assetId) throws ServiceException { */ @Override public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); - options.getPermissions().add(AccessPolicyPermission.WRITE); - return createAccessPolicy(name, durationInMinutes, options); + return createAccessPolicy(name, durationInMinutes, null); } /* (non-Javadoc) @@ -272,6 +271,10 @@ public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) throws ServiceException { + if (options == null) { + options = new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE)); + } + AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes).setName(name) .setPermissions(AccessPolicyPermission.bitsFromPermissions(options.getPermissions())); @@ -304,11 +307,7 @@ public void deleteAccessPolicy(String id) throws ServiceException { */ @Override public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { - WebResource resource = getResource("AccessPolicies"); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<List<AccessPolicyInfo>>() { - }); + return listAccessPolicies(null); } /* (non-Javadoc) @@ -316,7 +315,10 @@ public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { */ @Override public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { - // Currently no options defined so can call zero arg overload instead - return listAccessPolicies(); + WebResource resource = getResource("AccessPolicies"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<List<AccessPolicyInfo>>() { + }); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java index 50213d4503654..f4d608dd712a5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.models; import java.util.Date; @@ -11,7 +26,6 @@ public class AccessPolicyInfo extends ODataEntity<AccessPolicyType> { public AccessPolicyInfo(EntryType entry, AccessPolicyType content) { super(entry, content); - // TODO Auto-generated constructor stub } public AccessPolicyInfo() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 2dea4f4e4d86b..f91f09eb06b0a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,16 @@ import java.util.EnumSet; import java.util.List; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; @@ -32,6 +37,8 @@ public class AccessPolicyIntegrationTest extends IntegrationTestBase { private static MediaContract service; + private static final String testPrefix = "testPolicy"; + @BeforeClass public static void setup() throws Exception { service = MediaService.create(createConfig()); @@ -50,7 +57,7 @@ private static Configuration createConfig() { @AfterClass public static void cleanup() throws Exception { for (AccessPolicyInfo policy : service.listAccessPolicies()) { - if (policy.getName().startsWith("testPolicy")) { + if (policy.getName().startsWith(testPrefix)) { service.deleteAccessPolicy(policy.getId()); } } @@ -58,7 +65,7 @@ public static void cleanup() throws Exception { @Test public void canCreateAccessPolicy() throws Exception { - AccessPolicyInfo policy = service.createAccessPolicy("testPolicy", 5, + AccessPolicyInfo policy = service.createAccessPolicy(testPrefix + "CanCreate", 5, new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE))); assertTrue(policy.getPermissions().contains(AccessPolicyPermission.WRITE)); @@ -66,7 +73,7 @@ public void canCreateAccessPolicy() throws Exception { @Test public void canGetSinglePolicyById() throws Exception { - String expectedName = "testPolicyGetOne"; + String expectedName = testPrefix + "GetOne"; AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, 1); AccessPolicyInfo retrievedPolicy = service.getAccessPolicy(policyToGet.getId()); @@ -77,7 +84,7 @@ public void canGetSinglePolicyById() throws Exception { @Test public void canRetrieveListOfAccessPolicies() throws Exception { - String[] policyNames = new String[] { "testPolicy1", "testPolicy2" }; + String[] policyNames = new String[] { testPrefix + "ListOne", testPrefix + "ListTwo" }; for (String name : policyNames) { service.createAccessPolicy(name, 3, new CreateAccessPolicyOptions().addPermissions(EnumSet.of( AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); @@ -92,21 +99,58 @@ public void canRetrieveListOfAccessPolicies() throws Exception { AccessPolicyInfo policy2 = null; for (AccessPolicyInfo policy : policies) { - if (policy.getName().equals("testPolicy1")) { + if (policy.getName().equals(policyNames[0])) { policy1 = policy; } - if (policy.getName().equals("testPolicy2")) { + if (policy.getName().equals(policyNames[1])) { policy2 = policy; } } assertNotNull(policy1); assertNotNull(policy2); + + assertTrue(policy1.getPermissions().containsAll( + EnumSet.of(AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); + } + + @Rule + public ExpectedException expected = ExpectedException.none(); + + @Test + public void getWithBadIdThrowsServiceException() throws Exception { + expected.expect(ServiceException.class); + AccessPolicyInfo policy = service.getAccessPolicy("notAValidId"); + } + + @Test + public void getWithValidButNonExistentPolicyIdThrows404ServiceException() throws Exception { + expected.expect(new BaseMatcher<ServiceException>() { + + @Override + public boolean matches(Object item) { + if (item.getClass() != ServiceException.class) { + return false; + } + + if (((ServiceException) item).getHttpStatusCode() != 404) { + return false; + } + + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("Must be ServiceException with a 404 status code"); + } + }); + service.getAccessPolicy("nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"); } @Test public void canDeleteAccessPolicyById() throws Exception { - AccessPolicyInfo policyToDelete = service.createAccessPolicy("testPolicyToDelete", 1); + AccessPolicyInfo policyToDelete = service.createAccessPolicy(testPrefix + "ToDelete", 1); service.deleteAccessPolicy(policyToDelete.getId()); From 384a73583f375a8368a6090a555ad3612a68f7e2 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 3 Oct 2012 14:22:58 -0700 Subject: [PATCH 356/664] Added more convenient overloads for getting / setting permissions, issue #340 --- .../models/CreateAccessPolicyOptions.java | 43 ++++++++ .../models/CreateAccessPolicyOptionsTest.java | 97 +++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java index d5e4cb87ee0c6..7c003d2e0cd02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.models; import java.util.EnumSet; @@ -28,6 +43,20 @@ public CreateAccessPolicyOptions addPermissions(EnumSet<AccessPolicyPermission> return this; } + /** + * Add the given permissions to this creation request + * + * @param permissionsToAdd + * varargs - permissions to add + * @return the CreateAccessPolicyOptions object + */ + public CreateAccessPolicyOptions addPermissions(AccessPolicyPermission... permissionsToAdd) { + for (AccessPolicyPermission permission : permissionsToAdd) { + permissions.add(permission); + } + return this; + } + /** * Remove the given permissions from this creation request * @@ -38,4 +67,18 @@ public CreateAccessPolicyOptions removePermissions(EnumSet<AccessPolicyPermissio permissions.removeAll(permissionsToRemove); return this; } + + /** + * Remove the given permissions from this creation request + * + * @param permissionsToRemove + * vararg - permissions to remove + * @return the CreateAccessPolicyOptions object + */ + public CreateAccessPolicyOptions removePermissions(AccessPolicyPermission... permissionsToRemove) { + for (AccessPolicyPermission permission : permissionsToRemove) { + permissions.remove(permission); + } + return this; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java new file mode 100644 index 0000000000000..f5b578d40e789 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java @@ -0,0 +1,97 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.EnumSet; + +import org.junit.Test; + +public class CreateAccessPolicyOptionsTest { + + private static void assertPermissions(EnumSet<AccessPolicyPermission> expected, + EnumSet<AccessPolicyPermission> actual) { + assertTrue(actual.containsAll(expected)); + assertTrue(EnumSet.complementOf(actual).containsAll(EnumSet.complementOf(expected))); + } + + @Test + public void optionsCreatedWithNoPermissions() throws Exception { + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); + + assertPermissions(EnumSet.noneOf(AccessPolicyPermission.class), options.getPermissions()); + } + + @Test + public void canGetSetPermissionsAsEnumSet() throws Exception { + EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.LIST, + AccessPolicyPermission.DELETE); + + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); + + options.addPermissions(expectedPermissions); + + EnumSet<AccessPolicyPermission> permissions = options.getPermissions(); + + assertPermissions(expectedPermissions, permissions); + } + + @Test + public void canGetSetPermissionsAsVarargs() throws Exception { + EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.READ, + AccessPolicyPermission.WRITE); + + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ, + AccessPolicyPermission.WRITE); + + EnumSet<AccessPolicyPermission> permissions = options.getPermissions(); + + assertPermissions(expectedPermissions, permissions); + } + + @Test + public void canRemovePermissionsAsEnumSet() throws Exception { + EnumSet<AccessPolicyPermission> originalPermissions = EnumSet.of(AccessPolicyPermission.READ, + AccessPolicyPermission.WRITE, AccessPolicyPermission.DELETE); + EnumSet<AccessPolicyPermission> permissionsToRemove = EnumSet.of(AccessPolicyPermission.READ, + AccessPolicyPermission.DELETE); + EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.WRITE); + + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(originalPermissions); + + options.removePermissions(permissionsToRemove); + + EnumSet<AccessPolicyPermission> actualPermissions = options.getPermissions(); + + assertPermissions(expectedPermissions, actualPermissions); + } + + @Test + public void canRemovePermissionsAsVarargs() throws Exception { + EnumSet<AccessPolicyPermission> originalPermissions = EnumSet.of(AccessPolicyPermission.READ, + AccessPolicyPermission.WRITE, AccessPolicyPermission.DELETE); + EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.WRITE); + + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(originalPermissions); + + options.removePermissions(AccessPolicyPermission.READ, AccessPolicyPermission.DELETE); + + EnumSet<AccessPolicyPermission> actualPermissions = options.getPermissions(); + + assertPermissions(expectedPermissions, actualPermissions); + } +} From dd0c6c58f2f09545b650c9881cb4dc4b7a012501 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 4 Oct 2012 14:19:28 -0700 Subject: [PATCH 357/664] Refactored blob operations into base class --- .../BlobOperationRestProxy.java | 1000 +++++++++++++++++ .../blob/implementation/BlobRestProxy.java | 959 +--------------- 2 files changed, 1009 insertions(+), 950 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java new file mode 100644 index 0000000000000..08863ccefdb03 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -0,0 +1,1000 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.blob.implementation; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import com.microsoft.windowsazure.services.blob.BlobContract; +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; +import com.microsoft.windowsazure.services.blob.models.ContainerACL; +import com.microsoft.windowsazure.services.blob.models.ContainerACL.PublicAccessType; +import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CopyBlobResult; +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.CreateBlobResult; +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; +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.GetBlobPropertiesResult; +import com.microsoft.windowsazure.services.blob.models.GetBlobResult; +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; +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.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; +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.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.CommaStringBuilder; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +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 abstract class BlobOperationRestProxy implements BlobContract { + + 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; + + protected BlobOperationRestProxy(Client channel, String accountName, String url) { + this(channel, new ServiceFilter[0], accountName, url, new RFC1123DateConverter()); + } + + protected BlobOperationRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, + RFC1123DateConverter dateMapper) { + this.channel = channel; + this.accountName = accountName; + this.url = url; + this.filters = filters; + this.dateMapper = dateMapper; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ + @Override + public abstract BlobContract withFilter(ServiceFilter filter); + + protected Client getChannel() { + return channel; + } + + protected String getAccountName() { + return accountName; + } + + protected String getUrl() { + return url; + } + + protected RFC1123DateConverter getDateMapper() { + return dateMapper; + } + + protected ServiceFilter[] getFilters() { + return filters; + } + + private void ThrowIfError(ClientResponse r) { + PipelineHelpers.ThrowIfError(r); + } + + private void ThrowIfNotSuccess(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + } + + private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { + return PipelineHelpers.addOptionalQueryParam(webResource, key, value); + } + + private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { + return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); + } + + private Builder addOptionalHeader(Builder builder, String name, Object value) { + return PipelineHelpers.addOptionalHeader(builder, name, value); + } + + private Builder addOptionalMetadataHeader(Builder builder, Map<String, String> metadata) { + return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); + } + + private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { + return PipelineHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); + } + + private Builder addOptionalAccessConditionHeader(Builder builder, AccessCondition accessCondition) { + return PipelineHelpers.addOptionalAccessConditionHeader(builder, accessCondition); + } + + private Builder addOptionalSourceAccessConditionHeader(Builder builder, AccessCondition accessCondition) { + return PipelineHelpers.addOptionalSourceAccessConditionHeader(builder, accessCondition); + } + + private HashMap<String, String> getMetadataFromHeaders(ClientResponse response) { + return PipelineHelpers.getMetadataFromHeaders(response); + } + + private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { + CommaStringBuilder sb = new CommaStringBuilder(); + 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) { + CommaStringBuilder sb = new CommaStringBuilder(); + 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) { + // Note: Add content type here to enable proper HMAC signing + builder = builder.type("application/octet-stream"); + } + builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + return builder; + } + + private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { + // Properties + BlobProperties properties = new BlobProperties(); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); + properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); + + properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); + properties.setContentType(response.getHeaders().getFirst("Content-Type")); + properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); + properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); + properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); + + 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"))); + } + + // Metadata + HashMap<String, String> metadata = getMetadataFromHeaders(response); + + // Result + GetBlobPropertiesResult result = new GetBlobPropertiesResult(); + result.setMetadata(metadata); + result.setProperties(properties); + return result; + } + + private WebResource getResource(BlobServiceOptions 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 String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { + // Specifies the name of the source blob, in one of the following + // formats: + // Blob in named container: /accountName/containerName/blobName + // + // Snapshot in named container: + // /accountName/containerName/blobName?snapshot=<DateTime> + // + // Blob in root container: /accountName/blobName + // + // Snapshot in root container: /accountName/blobName?snapshot=<DateTime> + String sourceName = "/" + this.accountName; + if (sourceContainer != null) { + sourceName += "/" + sourceContainer; + } + sourceName += "/" + sourceBlob; + if (options.getSourceSnapshot() != null) { + sourceName += "?snapshot=" + options.getSourceSnapshot(); + } + return sourceName; + } + + @Override + public GetServicePropertiesResult getServiceProperties() throws ServiceException { + return getServiceProperties(new BlobServiceOptions()); + } + + @Override + public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + GetServicePropertiesResult result = new GetServicePropertiesResult(); + result.setValue(builder.get(ServiceProperties.class)); + return result; + } + + @Override + public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { + setServiceProperties(serviceProperties, new BlobServiceOptions()); + } + + @Override + public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) + throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("resType", "service") + .queryParam("comp", "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + + builder.put(serviceProperties); + } + + @Override + public void createContainer(String container) throws ServiceException { + createContainer(container, new CreateContainerOptions()); + } + + @Override + public void createContainer(String container, CreateContainerOptions options) throws ServiceException { + if (container == null || container.isEmpty()) { + throw new IllegalArgumentException("The container cannot be null or empty."); + } + WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); + + builder.put(); + } + + @Override + public void deleteContainer(String container) throws ServiceException { + deleteContainer(container, new DeleteContainerOptions()); + } + + @Override + public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { + if ((container == null) || (container.isEmpty())) { + throw new IllegalArgumentException("The root container has already been created."); + } + WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + builder.delete(); + } + + @Override + public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { + return getContainerProperties(container, new BlobServiceOptions()); + } + + @Override + public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) + throws ServiceException { + return getContainerPropertiesImpl(container, options, null); + } + + @Override + public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { + return getContainerMetadata(container, new BlobServiceOptions()); + } + + @Override + public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) + throws ServiceException { + return getContainerPropertiesImpl(container, options, "metadata"); + } + + private GetContainerPropertiesResult getContainerPropertiesImpl(String container, BlobServiceOptions options, + String operation) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).queryParam("resType", "container"); + webResource = addOptionalQueryParam(webResource, "comp", operation); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + GetContainerPropertiesResult properties = new GetContainerPropertiesResult(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); + + return properties; + } + + @Override + public GetContainerACLResult getContainerACL(String container) throws ServiceException { + return getContainerACL(container, new BlobServiceOptions()); + } + + @Override + public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).queryParam("resType", "container") + .queryParam("comp", "acl"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); + ContainerACL acl = new ContainerACL(); + acl.setSignedIdentifiers(si.getSignedIdentifiers()); + if ("container".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { + acl.setPublicAccess(PublicAccessType.CONTAINER_AND_BLOBS); + } + else if ("blob".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { + acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); + } + else { + acl.setPublicAccess(PublicAccessType.NONE); + } + acl.setEtag(response.getHeaders().getFirst("ETag")); + acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + + GetContainerACLResult result = new GetContainerACLResult(); + result.setValue(acl); + return result; + } + + @Override + public void setContainerACL(String container, ContainerACL acl) throws ServiceException { + setContainerACL(container, acl, new BlobServiceOptions()); + } + + @Override + public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).queryParam("resType", "container") + .queryParam("comp", "acl"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + if (acl.getPublicAccess() == PublicAccessType.BLOBS_ONLY) { + builder = addOptionalHeader(builder, "x-ms-blob-public-access", "blob"); + } + else if (acl.getPublicAccess() == PublicAccessType.CONTAINER_AND_BLOBS) { + builder = addOptionalHeader(builder, "x-ms-blob-public-access", "container"); + } + + ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); + si.setSignedIdentifiers(acl.getSignedIdentifiers()); + + builder.put(si); + } + + @Override + public void setContainerMetadata(String container, HashMap<String, String> metadata) throws ServiceException { + setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); + } + + @Override + public void setContainerMetadata(String container, HashMap<String, String> metadata, + SetContainerMetadataOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).queryParam("resType", "container") + .queryParam("comp", "metadata"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + builder.put(); + } + + @Override + public ListContainersResult listContainers() throws ServiceException { + return listContainers(new ListContainersOptions()); + } + + @Override + public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { + WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); + webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); + webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); + webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); + webResource = addOptionalContainerIncludeQueryParam(options, webResource); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + return builder.get(ListContainersResult.class); + } + + @Override + public ListBlobsResult listBlobs(String container) throws ServiceException { + return listBlobs(container, new ListBlobsOptions()); + } + + @Override + public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).queryParam("comp", "list") + .queryParam("resType", "container"); + 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); + + return builder.get(ListBlobsResult.class); + } + + @Override + public CreateBlobResult createPageBlob(String container, String blob, long length) throws ServiceException { + return createPageBlob(container, blob, length, new CreateBlobOptions()); + } + + @Override + public CreateBlobResult createPageBlob(String container, String blob, long length, CreateBlobOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); + builder = addOptionalHeader(builder, "Content-Length", 0); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + builder = addPutBlobHeaders(options, builder); + + ClientResponse clientResponse = builder.put(ClientResponse.class); + ThrowIfError(clientResponse); + + CreateBlobResult createBlobResult = new CreateBlobResult(); + createBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); + createBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); + + return createBlobResult; + } + + @Override + public CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream) + throws ServiceException { + return createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); + } + + @Override + public CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream, + CreateBlobOptions options) throws ServiceException { + String path = createPathFromContainer(container); + System.out.println(path); + WebResource webResource = getResource(options).path(path).path(blob); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + + builder = builder.header("x-ms-blob-type", "BlockBlob"); + builder = addPutBlobHeaders(options, builder); + + Object contentObject = (contentStream == null ? new byte[0] : contentStream); + ClientResponse clientResponse = builder.put(ClientResponse.class, contentObject); + ThrowIfError(clientResponse); + + CreateBlobResult createBlobResult = new CreateBlobResult(); + createBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); + createBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); + + return createBlobResult; + } + + @Override + public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { + return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); + } + + @Override + public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.method("HEAD", ClientResponse.class); + ThrowIfNotSuccess(response); + + return getBlobPropertiesResultFromResponse(response); + } + + @Override + public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { + return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); + } + + @Override + public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "metadata"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + GetBlobMetadataResult properties = new GetBlobMetadataResult(); + properties.setEtag(response.getHeaders().getFirst("ETag")); + properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + properties.setMetadata(getMetadataFromHeaders(response)); + + return properties; + } + + @Override + public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "properties"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); + builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); + builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.put(ClientResponse.class); + ThrowIfError(response); + + SetBlobPropertiesResult result = new SetBlobPropertiesResult(); + + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + } + + return result; + } + + @Override + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap<String, String> metadata) + throws ServiceException { + return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); + } + + @Override + public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap<String, String> metadata, + SetBlobMetadataOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "metadata"); + + WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, metadata); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.put(ClientResponse.class); + ThrowIfError(response); + + SetBlobMetadataResult result = new SetBlobMetadataResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + return result; + } + + @Override + public GetBlobResult getBlob(String container, String blob) throws ServiceException { + return getBlob(container, blob, new GetBlobOptions()); + } + + @Override + public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + if (options.isComputeRangeMD5()) { + builder = addOptionalHeader(builder, "x-ms-range-get-content-md5", "true"); + } + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfNotSuccess(response); + + GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response); + GetBlobResult blobResult = new GetBlobResult(); + blobResult.setProperties(properties.getProperties()); + blobResult.setMetadata(properties.getMetadata()); + blobResult.setContentStream(response.getEntityInputStream()); + return blobResult; + } + + @Override + public void deleteBlob(String container, String blob) throws ServiceException { + deleteBlob(container, blob, new DeleteBlobOptions()); + } + + @Override + public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + if (options.getDeleteSnaphotsOnly() != null) { + builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" + : "include"); + } + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + builder.delete(); + } + + @Override + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { + return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); + } + + @Override + public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "snapshot"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.put(ClientResponse.class); + ThrowIfError(response); + + CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); + blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); + blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); + blobSnapshot.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + + return blobSnapshot; + } + + @Override + public CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, + String sourceBlob) throws ServiceException { + return copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); + } + + @Override + public CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, + String sourceBlob, CopyBlobOptions options) { + String path = createPathFromContainer(destinationContainer); + WebResource webResource = getResource(options).path(path).path(destinationBlob); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); + builder = addOptionalHeader(builder, "x-ms-copy-source", + getCopyBlobSourceName(sourceContainer, sourceBlob, options)); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + builder = addOptionalSourceAccessConditionHeader(builder, options.getSourceAccessCondition()); + + ClientResponse clientResponse = builder.put(ClientResponse.class); + ThrowIfError(clientResponse); + + CopyBlobResult copyBlobResult = new CopyBlobResult(); + copyBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); + copyBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); + + return copyBlobResult; + } + + @Override + public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { + return acquireLease(container, blob, new AcquireLeaseOptions()); + } + + @Override + public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) + throws ServiceException { + return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); + } + + @Override + public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { + return renewLease(container, blob, leaseId, new BlobServiceOptions()); + } + + @Override + public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { + return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); + } + + @Override + public void releaseLease(String container, String blob, String leaseId) throws ServiceException { + releaseLease(container, blob, leaseId, new BlobServiceOptions()); + } + + @Override + public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { + putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); + } + + @Override + public void breakLease(String container, String blob, String leaseId) throws ServiceException { + breakLease(container, blob, leaseId, new BlobServiceOptions()); + } + + @Override + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { + putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); + } + + private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, + BlobServiceOptions options, AccessCondition accessCondition) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); + builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); + builder = addOptionalAccessConditionHeader(builder, accessCondition); + + // Note: Add content type here to enable proper HMAC signing + ClientResponse response = builder.put(ClientResponse.class); + ThrowIfError(response); + + AcquireLeaseResult result = new AcquireLeaseResult(); + result.setLeaseId(response.getHeaders().getFirst("x-ms-lease-id")); + return result; + } + + @Override + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { + return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); + } + + @Override + public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, + CreateBlobPagesOptions options) throws ServiceException { + return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); + } + + @Override + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream) throws ServiceException { + return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); + } + + @Override + public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, + InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { + return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); + } + + private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, + PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "page"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + 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()); + builder = addOptionalHeader(builder, "x-ms-page-write", action); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.put(ClientResponse.class, contentStream); + ThrowIfError(response); + + CreateBlobPagesResult result = new CreateBlobPagesResult(); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); + result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); + + return result; + } + + @Override + public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { + return listBlobRegions(container, blob, new ListBlobRegionsOptions()); + } + + @Override + public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "pagelist"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + + return result; + } + + @Override + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) + throws ServiceException { + createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); + } + + @Override + public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, + CreateBlobBlockOptions options) throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block"); + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); + + builder.put(contentStream); + } + + @Override + public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { + commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); + } + + @Override + public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "blocklist"); + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); + builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); + builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); + builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); + builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); + builder = addOptionalMetadataHeader(builder, options.getMetadata()); + builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); + + builder.put(blockList); + } + + @Override + public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { + return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); + } + + @Override + public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) + throws ServiceException { + String path = createPathFromContainer(container); + WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "blocklist"); + webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); + if (options.isCommittedList() && options.isUncommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "all"); + } + else if (options.isCommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "committed"); + } + else if (options.isUncommittedList()) { + webResource = addOptionalQueryParam(webResource, "blocklisttype", "uncommitted"); + } + + Builder builder = webResource.header("x-ms-version", API_VERSION); + builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); + + ClientResponse response = builder.get(ClientResponse.class); + ThrowIfError(response); + + ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); + result.setEtag(response.getHeaders().getFirst("ETag")); + result.setContentType(response.getHeaders().getFirst("Content-Type")); + result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); + result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); + + return result; + } + + private String createPathFromContainer(String containerName) { + String path; + if (containerName == null || containerName.isEmpty()) { + path = "$root"; + } + else { + path = containerName; + } + return path; + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 1366704cf2d81..8bd98f0f850da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -14,982 +14,41 @@ */ package com.microsoft.windowsazure.services.blob.implementation; -import java.io.InputStream; import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; import javax.inject.Inject; import javax.inject.Named; import com.microsoft.windowsazure.services.blob.BlobConfiguration; import com.microsoft.windowsazure.services.blob.BlobContract; -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; -import com.microsoft.windowsazure.services.blob.models.ContainerACL; -import com.microsoft.windowsazure.services.blob.models.ContainerACL.PublicAccessType; -import com.microsoft.windowsazure.services.blob.models.CopyBlobOptions; -import com.microsoft.windowsazure.services.blob.models.CopyBlobResult; -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.CreateBlobResult; -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; -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.GetBlobPropertiesResult; -import com.microsoft.windowsazure.services.blob.models.GetBlobResult; -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; -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.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; -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.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.CommaStringBuilder; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.HttpURLConnectionClient; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; -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; +import com.sun.jersey.api.client.Client; -public class BlobRestProxy implements BlobContract { - private static final String API_VERSION = "2011-08-18"; - private final HttpURLConnectionClient channel; - private final String accountName; - private final String url; - private final RFC1123DateConverter dateMapper; - private final ServiceFilter[] filters; +public class BlobRestProxy extends BlobOperationRestProxy implements BlobContract { private final SharedKeyFilter filter; @Inject public BlobRestProxy(HttpURLConnectionClient channel, @Named(BlobConfiguration.ACCOUNT_NAME) String accountName, @Named(BlobConfiguration.URI) String url, SharedKeyFilter filter) { + super(channel, accountName, url); - 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 BlobRestProxy(HttpURLConnectionClient client, ServiceFilter[] filters, String accountName, String url, + public BlobRestProxy(Client client, ServiceFilter[] filters, String accountName, String url, SharedKeyFilter filter, RFC1123DateConverter dateMapper) { + super(client, filters, accountName, url, dateMapper); - this.channel = client; - this.filters = filters; - this.accountName = accountName; - this.url = url; this.filter = filter; - this.dateMapper = dateMapper; } @Override public BlobContract withFilter(ServiceFilter filter) { - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new BlobRestProxy(this.channel, newFilters, this.accountName, this.url, this.filter, this.dateMapper); - } - - private void ThrowIfError(ClientResponse r) { - PipelineHelpers.ThrowIfError(r); - } - - private void ThrowIfNotSuccess(ClientResponse clientResponse) { - PipelineHelpers.ThrowIfNotSuccess(clientResponse); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, Object value) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value); - } - - private WebResource addOptionalQueryParam(WebResource webResource, String key, int value, int defaultValue) { - return PipelineHelpers.addOptionalQueryParam(webResource, key, value, defaultValue); - } - - private Builder addOptionalHeader(Builder builder, String name, Object value) { - return PipelineHelpers.addOptionalHeader(builder, name, value); - } - - private Builder addOptionalMetadataHeader(Builder builder, Map<String, String> metadata) { - return PipelineHelpers.addOptionalMetadataHeader(builder, metadata); - } - - private Builder addOptionalRangeHeader(Builder builder, Long rangeStart, Long rangeEnd) { - return PipelineHelpers.addOptionalRangeHeader(builder, rangeStart, rangeEnd); - } - - private Builder addOptionalAccessConditionHeader(Builder builder, AccessCondition accessCondition) { - return PipelineHelpers.addOptionalAccessConditionHeader(builder, accessCondition); - } - - private Builder addOptionalSourceAccessConditionHeader(Builder builder, AccessCondition accessCondition) { - return PipelineHelpers.addOptionalSourceAccessConditionHeader(builder, accessCondition); - } - - private HashMap<String, String> getMetadataFromHeaders(ClientResponse response) { - return PipelineHelpers.getMetadataFromHeaders(response); - } - - private WebResource addOptionalBlobListingIncludeQueryParam(ListBlobsOptions options, WebResource webResource) { - CommaStringBuilder sb = new CommaStringBuilder(); - 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) { - CommaStringBuilder sb = new CommaStringBuilder(); - 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) { - // Note: Add content type here to enable proper HMAC signing - builder = builder.type("application/octet-stream"); - } - builder = addOptionalHeader(builder, "Content-Encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "Content-Language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - builder = addOptionalHeader(builder, "Cache-Control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - return builder; - } - - private GetBlobPropertiesResult getBlobPropertiesResultFromResponse(ClientResponse response) { - // Properties - BlobProperties properties = new BlobProperties(); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setBlobType(response.getHeaders().getFirst("x-ms-blob-type")); - properties.setLeaseStatus(response.getHeaders().getFirst("x-ms-lease-status")); - - properties.setContentLength(Long.parseLong(response.getHeaders().getFirst("Content-Length"))); - properties.setContentType(response.getHeaders().getFirst("Content-Type")); - properties.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - properties.setContentEncoding(response.getHeaders().getFirst("Content-Encoding")); - properties.setContentLanguage(response.getHeaders().getFirst("Content-Language")); - properties.setCacheControl(response.getHeaders().getFirst("Cache-Control")); - - 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"))); - } - - // Metadata - HashMap<String, String> metadata = getMetadataFromHeaders(response); - - // Result - GetBlobPropertiesResult result = new GetBlobPropertiesResult(); - result.setMetadata(metadata); - result.setProperties(properties); - return result; - } - - private WebResource getResource(BlobServiceOptions 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 String getCopyBlobSourceName(String sourceContainer, String sourceBlob, CopyBlobOptions options) { - // Specifies the name of the source blob, in one of the following - // formats: - // Blob in named container: /accountName/containerName/blobName - // - // Snapshot in named container: - // /accountName/containerName/blobName?snapshot=<DateTime> - // - // Blob in root container: /accountName/blobName - // - // Snapshot in root container: /accountName/blobName?snapshot=<DateTime> - String sourceName = "/" + this.accountName; - if (sourceContainer != null) { - sourceName += "/" + sourceContainer; - } - sourceName += "/" + sourceBlob; - if (options.getSourceSnapshot() != null) { - sourceName += "?snapshot=" + options.getSourceSnapshot(); - } - return sourceName; - } - - @Override - public GetServicePropertiesResult getServiceProperties() throws ServiceException { - return getServiceProperties(new BlobServiceOptions()); - } - - @Override - public GetServicePropertiesResult getServiceProperties(BlobServiceOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - GetServicePropertiesResult result = new GetServicePropertiesResult(); - result.setValue(builder.get(ServiceProperties.class)); - return result; - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties) throws ServiceException { - setServiceProperties(serviceProperties, new BlobServiceOptions()); - } - - @Override - public void setServiceProperties(ServiceProperties serviceProperties, BlobServiceOptions options) - throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("resType", "service") - .queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder.put(serviceProperties); - } - - @Override - public void createContainer(String container) throws ServiceException { - createContainer(container, new CreateContainerOptions()); - } - - @Override - public void createContainer(String container, CreateContainerOptions options) throws ServiceException { - if (container == null || container.isEmpty()) { - throw new IllegalArgumentException("The container cannot be null or empty."); - } - WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalHeader(builder, "x-ms-blob-public-access", options.getPublicAccess()); - - builder.put(); - } - - @Override - public void deleteContainer(String container) throws ServiceException { - deleteContainer(container, new DeleteContainerOptions()); - } - - @Override - public void deleteContainer(String container, DeleteContainerOptions options) throws ServiceException { - if ((container == null) || (container.isEmpty())) { - throw new IllegalArgumentException("The root container has already been created."); - } - WebResource webResource = getResource(options).path(container).queryParam("resType", "container"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - builder.delete(); - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container) throws ServiceException { - return getContainerProperties(container, new BlobServiceOptions()); - } - - @Override - public GetContainerPropertiesResult getContainerProperties(String container, BlobServiceOptions options) - throws ServiceException { - return getContainerPropertiesImpl(container, options, null); - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container) throws ServiceException { - return getContainerMetadata(container, new BlobServiceOptions()); - } - - @Override - public GetContainerPropertiesResult getContainerMetadata(String container, BlobServiceOptions options) - throws ServiceException { - return getContainerPropertiesImpl(container, options, "metadata"); - } - - private GetContainerPropertiesResult getContainerPropertiesImpl(String container, BlobServiceOptions options, - String operation) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).queryParam("resType", "container"); - webResource = addOptionalQueryParam(webResource, "comp", operation); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetContainerPropertiesResult properties = new GetContainerPropertiesResult(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; - } - - @Override - public GetContainerACLResult getContainerACL(String container) throws ServiceException { - return getContainerACL(container, new BlobServiceOptions()); - } - - @Override - public GetContainerACLResult getContainerACL(String container, BlobServiceOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).queryParam("resType", "container") - .queryParam("comp", "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ContainerACL.SignedIdentifiers si = response.getEntity(ContainerACL.SignedIdentifiers.class); - ContainerACL acl = new ContainerACL(); - acl.setSignedIdentifiers(si.getSignedIdentifiers()); - if ("container".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { - acl.setPublicAccess(PublicAccessType.CONTAINER_AND_BLOBS); - } - else if ("blob".equals(response.getHeaders().getFirst("x-ms-blob-public-access"))) { - acl.setPublicAccess(PublicAccessType.BLOBS_ONLY); - } - else { - acl.setPublicAccess(PublicAccessType.NONE); - } - acl.setEtag(response.getHeaders().getFirst("ETag")); - acl.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - GetContainerACLResult result = new GetContainerACLResult(); - result.setValue(acl); - return result; - } - - @Override - public void setContainerACL(String container, ContainerACL acl) throws ServiceException { - setContainerACL(container, acl, new BlobServiceOptions()); - } - - @Override - public void setContainerACL(String container, ContainerACL acl, BlobServiceOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).queryParam("resType", "container") - .queryParam("comp", "acl"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - if (acl.getPublicAccess() == PublicAccessType.BLOBS_ONLY) { - builder = addOptionalHeader(builder, "x-ms-blob-public-access", "blob"); - } - else if (acl.getPublicAccess() == PublicAccessType.CONTAINER_AND_BLOBS) { - builder = addOptionalHeader(builder, "x-ms-blob-public-access", "container"); - } - - ContainerACL.SignedIdentifiers si = new ContainerACL.SignedIdentifiers(); - si.setSignedIdentifiers(acl.getSignedIdentifiers()); - - builder.put(si); - } - - @Override - public void setContainerMetadata(String container, HashMap<String, String> metadata) throws ServiceException { - setContainerMetadata(container, metadata, new SetContainerMetadataOptions()); - } - - @Override - public void setContainerMetadata(String container, HashMap<String, String> metadata, - SetContainerMetadataOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).queryParam("resType", "container") - .queryParam("comp", "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - builder.put(); - } - - @Override - public ListContainersResult listContainers() throws ServiceException { - return listContainers(new ListContainersOptions()); - } - - @Override - public ListContainersResult listContainers(ListContainersOptions options) throws ServiceException { - WebResource webResource = getResource(options).path("/").queryParam("comp", "list"); - webResource = addOptionalQueryParam(webResource, "prefix", options.getPrefix()); - webResource = addOptionalQueryParam(webResource, "marker", options.getMarker()); - webResource = addOptionalQueryParam(webResource, "maxresults", options.getMaxResults(), 0); - webResource = addOptionalContainerIncludeQueryParam(options, webResource); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - return builder.get(ListContainersResult.class); - } - - @Override - public ListBlobsResult listBlobs(String container) throws ServiceException { - return listBlobs(container, new ListBlobsOptions()); - } - - @Override - public ListBlobsResult listBlobs(String container, ListBlobsOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).queryParam("comp", "list") - .queryParam("resType", "container"); - 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); - - return builder.get(ListBlobsResult.class); - } - - @Override - public CreateBlobResult createPageBlob(String container, String blob, long length) throws ServiceException { - return createPageBlob(container, blob, length, new CreateBlobOptions()); - } - - @Override - public CreateBlobResult createPageBlob(String container, String blob, long length, CreateBlobOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-type", "PageBlob"); - builder = addOptionalHeader(builder, "Content-Length", 0); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", length); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addPutBlobHeaders(options, builder); - - ClientResponse clientResponse = builder.put(ClientResponse.class); - ThrowIfError(clientResponse); - - CreateBlobResult createBlobResult = new CreateBlobResult(); - createBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); - createBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); - - return createBlobResult; - } - - @Override - public CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream) - throws ServiceException { - return createBlockBlob(container, blob, contentStream, new CreateBlobOptions()); - } - - @Override - public CreateBlobResult createBlockBlob(String container, String blob, InputStream contentStream, - CreateBlobOptions options) throws ServiceException { - String path = createPathFromContainer(container); - System.out.println(path); - WebResource webResource = getResource(options).path(path).path(blob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - - builder = builder.header("x-ms-blob-type", "BlockBlob"); - builder = addPutBlobHeaders(options, builder); - - Object contentObject = (contentStream == null ? new byte[0] : contentStream); - ClientResponse clientResponse = builder.put(ClientResponse.class, contentObject); - ThrowIfError(clientResponse); - - CreateBlobResult createBlobResult = new CreateBlobResult(); - createBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); - createBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); - - return createBlobResult; - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob) throws ServiceException { - return getBlobProperties(container, blob, new GetBlobPropertiesOptions()); - } - - @Override - public GetBlobPropertiesResult getBlobProperties(String container, String blob, GetBlobPropertiesOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.method("HEAD", ClientResponse.class); - ThrowIfNotSuccess(response); - - return getBlobPropertiesResultFromResponse(response); - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob) throws ServiceException { - return getBlobMetadata(container, blob, new GetBlobMetadataOptions()); - } - - @Override - public GetBlobMetadataResult getBlobMetadata(String container, String blob, GetBlobMetadataOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "metadata"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - GetBlobMetadataResult properties = new GetBlobMetadataResult(); - properties.setEtag(response.getHeaders().getFirst("ETag")); - properties.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - properties.setMetadata(getMetadataFromHeaders(response)); - - return properties; - } - - @Override - public SetBlobPropertiesResult setBlobProperties(String container, String blob, SetBlobPropertiesOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "properties"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getContentMD5()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-length", options.getContentLength()); - builder = addOptionalHeader(builder, "x-ms-sequence-number-action", options.getSequenceNumberAction()); - builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - SetBlobPropertiesResult result = new SetBlobPropertiesResult(); - - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - if (response.getHeaders().getFirst("x-ms-blob-sequence-number") != null) { - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); - } - - return result; - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap<String, String> metadata) - throws ServiceException { - return setBlobMetadata(container, blob, metadata, new SetBlobMetadataOptions()); - } - - @Override - public SetBlobMetadataResult setBlobMetadata(String container, String blob, HashMap<String, String> metadata, - SetBlobMetadataOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "metadata"); - - WebResource.Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, metadata); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - SetBlobMetadataResult result = new SetBlobMetadataResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - return result; - } - - @Override - public GetBlobResult getBlob(String container, String blob) throws ServiceException { - return getBlob(container, blob, new GetBlobOptions()); - } - - @Override - public GetBlobResult getBlob(String container, String blob, GetBlobOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - if (options.isComputeRangeMD5()) { - builder = addOptionalHeader(builder, "x-ms-range-get-content-md5", "true"); - } - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfNotSuccess(response); - - GetBlobPropertiesResult properties = getBlobPropertiesResultFromResponse(response); - GetBlobResult blobResult = new GetBlobResult(); - blobResult.setProperties(properties.getProperties()); - blobResult.setMetadata(properties.getMetadata()); - blobResult.setContentStream(response.getEntityInputStream()); - return blobResult; - } - - @Override - public void deleteBlob(String container, String blob) throws ServiceException { - deleteBlob(container, blob, new DeleteBlobOptions()); - } - - @Override - public void deleteBlob(String container, String blob, DeleteBlobOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - if (options.getDeleteSnaphotsOnly() != null) { - builder = addOptionalHeader(builder, "x-ms-delete-snapshots", options.getDeleteSnaphotsOnly() ? "only" - : "include"); - } - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - builder.delete(); - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob) throws ServiceException { - return createBlobSnapshot(container, blob, new CreateBlobSnapshotOptions()); - } - - @Override - public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob, CreateBlobSnapshotOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "snapshot"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); - blobSnapshot.setEtag(response.getHeaders().getFirst("ETag")); - blobSnapshot.setSnapshot(response.getHeaders().getFirst("x-ms-snapshot")); - blobSnapshot.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return blobSnapshot; - } - - @Override - public CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, - String sourceBlob) throws ServiceException { - return copyBlob(destinationContainer, destinationBlob, sourceContainer, sourceBlob, new CopyBlobOptions()); - } - - @Override - public CopyBlobResult copyBlob(String destinationContainer, String destinationBlob, String sourceContainer, - String sourceBlob, CopyBlobOptions options) { - String path = createPathFromContainer(destinationContainer); - WebResource webResource = getResource(options).path(path).path(destinationBlob); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-source-lease-id", options.getSourceLeaseId()); - builder = addOptionalHeader(builder, "x-ms-copy-source", - getCopyBlobSourceName(sourceContainer, sourceBlob, options)); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - builder = addOptionalSourceAccessConditionHeader(builder, options.getSourceAccessCondition()); - - ClientResponse clientResponse = builder.put(ClientResponse.class); - ThrowIfError(clientResponse); - - CopyBlobResult copyBlobResult = new CopyBlobResult(); - copyBlobResult.setEtag(clientResponse.getHeaders().getFirst("ETag")); - copyBlobResult.setLastModified(dateMapper.parse(clientResponse.getHeaders().getFirst("Last-Modified"))); - - return copyBlobResult; - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob) throws ServiceException { - return acquireLease(container, blob, new AcquireLeaseOptions()); - } - - @Override - public AcquireLeaseResult acquireLease(String container, String blob, AcquireLeaseOptions options) - throws ServiceException { - return putLeaseImpl("acquire", container, blob, null/* leaseId */, options, options.getAccessCondition()); - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId) throws ServiceException { - return renewLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public AcquireLeaseResult renewLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - return putLeaseImpl("renew", container, blob, leaseId, options, null/* accessCondition */); - } - - @Override - public void releaseLease(String container, String blob, String leaseId) throws ServiceException { - releaseLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public void releaseLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - putLeaseImpl("release", container, blob, leaseId, options, null/* accessCondition */); - } - - @Override - public void breakLease(String container, String blob, String leaseId) throws ServiceException { - breakLease(container, blob, leaseId, new BlobServiceOptions()); - } - - @Override - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) - throws ServiceException { - putLeaseImpl("break", container, blob, leaseId, options, null/* accessCondition */); - } - - private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, String blob, String leaseId, - BlobServiceOptions options, AccessCondition accessCondition) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", leaseId); - builder = addOptionalHeader(builder, "x-ms-lease-action", leaseAction); - builder = addOptionalAccessConditionHeader(builder, accessCondition); - - // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.put(ClientResponse.class); - ThrowIfError(response); - - AcquireLeaseResult result = new AcquireLeaseResult(); - result.setLeaseId(response.getHeaders().getFirst("x-ms-lease-id")); - return result; - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range) throws ServiceException { - return clearBlobPages(container, blob, range, new CreateBlobPagesOptions()); - } - - @Override - public CreateBlobPagesResult clearBlobPages(String container, String blob, PageRange range, - CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("clear", container, blob, range, 0, null, options); - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream) throws ServiceException { - return createBlobPages(container, blob, range, length, contentStream, new CreateBlobPagesOptions()); - } - - @Override - public CreateBlobPagesResult createBlobPages(String container, String blob, PageRange range, long length, - InputStream contentStream, CreateBlobPagesOptions options) throws ServiceException { - return updatePageBlobPagesImpl("update", container, blob, range, length, contentStream, options); - } - - private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String container, String blob, - PageRange range, long length, InputStream contentStream, CreateBlobPagesOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "page"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - 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()); - builder = addOptionalHeader(builder, "x-ms-page-write", action); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.put(ClientResponse.class, contentStream); - ThrowIfError(response); - - CreateBlobPagesResult result = new CreateBlobPagesResult(); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - result.setContentMD5(response.getHeaders().getFirst("Content-MD5")); - result.setSequenceNumber(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-sequence-number"))); - - return result; - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob) throws ServiceException { - return listBlobRegions(container, blob, new ListBlobRegionsOptions()); - } - - @Override - public ListBlobRegionsResult listBlobRegions(String container, String blob, ListBlobRegionsOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "pagelist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalRangeHeader(builder, options.getRangeStart(), options.getRangeEnd()); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobRegionsResult result = response.getEntity(ListBlobRegionsResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return result; - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream) - throws ServiceException { - createBlobBlock(container, blob, blockId, contentStream, new CreateBlobBlockOptions()); - } - - @Override - public void createBlobBlock(String container, String blob, String blockId, InputStream contentStream, - CreateBlobBlockOptions options) throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "Content-MD5", options.getContentMD5()); - - builder.put(contentStream); - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList) throws ServiceException { - commitBlobBlocks(container, blob, blockList, new CommitBlobBlocksOptions()); - } - - @Override - public void commitBlobBlocks(String container, String blob, BlockList blockList, CommitBlobBlocksOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "blocklist"); - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - builder = addOptionalHeader(builder, "x-ms-blob-cache-control", options.getBlobCacheControl()); - builder = addOptionalHeader(builder, "x-ms-blob-content-type", options.getBlobContentType()); - builder = addOptionalHeader(builder, "x-ms-blob-content-encoding", options.getBlobContentEncoding()); - builder = addOptionalHeader(builder, "x-ms-blob-content-language", options.getBlobContentLanguage()); - builder = addOptionalHeader(builder, "x-ms-blob-content-md5", options.getBlobContentMD5()); - builder = addOptionalMetadataHeader(builder, options.getMetadata()); - builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - - builder.put(blockList); - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob) throws ServiceException { - return listBlobBlocks(container, blob, new ListBlobBlocksOptions()); - } - - @Override - public ListBlobBlocksResult listBlobBlocks(String container, String blob, ListBlobBlocksOptions options) - throws ServiceException { - String path = createPathFromContainer(container); - WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "blocklist"); - webResource = addOptionalQueryParam(webResource, "snapshot", options.getSnapshot()); - if (options.isCommittedList() && options.isUncommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "all"); - } - else if (options.isCommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "committed"); - } - else if (options.isUncommittedList()) { - webResource = addOptionalQueryParam(webResource, "blocklisttype", "uncommitted"); - } - - Builder builder = webResource.header("x-ms-version", API_VERSION); - builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); - - ClientResponse response = builder.get(ClientResponse.class); - ThrowIfError(response); - - ListBlobBlocksResult result = response.getEntity(ListBlobBlocksResult.class); - result.setEtag(response.getHeaders().getFirst("ETag")); - result.setContentType(response.getHeaders().getFirst("Content-Type")); - result.setContentLength(Long.parseLong(response.getHeaders().getFirst("x-ms-blob-content-length"))); - result.setLastModified(dateMapper.parse(response.getHeaders().getFirst("Last-Modified"))); - - return result; - } - - private String createPathFromContainer(String containerName) { - String path; - if (containerName == null || containerName.isEmpty()) { - path = "$root"; - } - else { - path = containerName; - } - return path; + ServiceFilter[] currentFilters = getFilters(); + ServiceFilter[] newFilters = Arrays.copyOf(currentFilters, currentFilters.length + 1); + newFilters[currentFilters.length] = filter; + return new BlobRestProxy(getChannel(), newFilters, getAccountName(), getUrl(), this.filter, getDateMapper()); } } From 79047e247dae0538890157a3a8916b5c1b0cd6a5 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 5 Oct 2012 12:53:33 -0700 Subject: [PATCH 358/664] Cleanup Asset CRUD tests --- .../media/MediaServiceIntegrationTest.java | 137 +++++++++++------- 1 file changed, 85 insertions(+), 52 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 5b941aef9b446..e94c27d925921 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -20,40 +20,46 @@ import java.util.List; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { - private static MediaContract service; + private MediaContract service; + private static String testAssetPrefix = "testAsset"; + private static String fakeAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; @BeforeClass public static void setup() throws Exception { - // Create all test containers and their content - config = createConfig(); - service = MediaService.create(config); - List<AssetInfo> listAssetsResult = service.listAssets(null); - for (AssetInfo assetInfo : listAssetsResult) { - try { - service.deleteAsset(assetInfo.getId()); - } - catch (Exception e) { - e.printStackTrace(); - } - } + cleanupEnvironment(); } @AfterClass public static void cleanup() throws Exception { - // Configuration config = createConfiguration(); - // BlobContract service = BlobService.create(config); + cleanupEnvironment(); + } - // deleteContainers(service, testContainersPrefix, testContainers); - // deleteContainers(service, createableContainersPrefix, creatableContainers); + private static void cleanupEnvironment() { + config = createConfig(); + MediaContract service = MediaService.create(config); + try { + List<AssetInfo> listAssetsResult = service.listAssets(); + for (AssetInfo assetInfo : listAssetsResult) { + if (assetInfo.getName().startsWith(testAssetPrefix)) { + service.deleteAsset(assetInfo.getId()); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } } private static Configuration createConfig() { @@ -66,98 +72,119 @@ private static Configuration createConfig() { return config; } + @Before + public void setupInstance() throws Exception { + service = MediaService.create(config); + } + @Test public void createAssetSuccess() throws Exception { // Arrange - AssetInfo expectedAsset = new AssetInfo().setName("testAssetName"); + String testName = testAssetPrefix + "Name"; // Act - AssetInfo actualAsset = service.createAsset("testAssetName"); + AssetInfo actualAsset = service.createAsset(testName); // Assert - assertEquals(expectedAsset.getName(), actualAsset.getName()); + assertEquals("testName and actualAsset name", testName, actualAsset.getName()); } @Test public void createAssetNullNameSuccess() throws ServiceException { // Arrange + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + CreateAssetOptions options = new CreateAssetOptions().setOptions(encryptionOption); // Act - AssetInfo actualAsset = service.createAsset(null); + AssetInfo actualAsset = service.createAsset(null, options); // Assert - assertNotNull(actualAsset); + assertNotNull("actualAsset", actualAsset); + assertEquals("actualAsset.getName() should be the service default value, the empty string", "", + actualAsset.getName()); } @Test public void getAssetSuccess() throws Exception { // Arrange - AssetInfo expectedAsset = new AssetInfo().setName("testGetAssetSuccess"); - AssetInfo assetInfo = service.createAsset("testGetAssetSuccess"); + String testName = testAssetPrefix + "GetAssetSuccess"; + AssetInfo assetInfo = service.createAsset(testName); // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); // Assert - assertEquals(expectedAsset.getName(), actualAsset.getName()); + assertEquals(testName, actualAsset.getName()); } - @Test(expected = ServiceException.class) + @Test public void getAssetFailedWithInvalidId() throws ServiceException { // Arrange - AssetInfo expectedAsset = new AssetInfo().setId("IncorrectAssetId"); // Act - AssetInfo actualAsset = service.getAsset(expectedAsset.getId()); - - // Assert - assertTrue(false); + try { + service.getAsset(fakeAssetId); + // Should not get here + // Assert + fail(); + } + catch (ServiceException ex) { + // Assert + assertEquals("Error code should be not found, because asset does not exist to update", 404, + ex.getHttpStatusCode()); + } } @Test public void listAssetSuccess() throws ServiceException { // Arrange Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); - AssetInfo assetA = new AssetInfo(); - AssetInfo assetB = new AssetInfo(); - service.createAsset("assetA"); - service.createAsset("assetB"); + service.createAsset(testAssetPrefix + "assetA"); + service.createAsset(testAssetPrefix + "assetB"); // Act Collection<AssetInfo> listAssetResult = service.listAssets(); - // Assert + // Assert assertEquals(listAssetResultBaseLine.size() + 2, listAssetResult.size()); } @Test public void updateAssetSuccess() throws Exception { // Arrange + String originalTestName = testAssetPrefix + "UpdateAssetSuccess"; + String updatedTestName = testAssetPrefix + "UpdateAssetSuccess"; - AssetInfo updatedAsset = service.createAsset("updateAssetSuccess"); - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName("updateAssetSuccessResult"); - updatedAsset.setName("updateAssetSuccessResult"); + AssetInfo originalAsset = service.createAsset(originalTestName); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName); // Act - service.updateAsset(updatedAsset.getId(), updateAssetOptions); - AssetInfo actualAsset = service.getAsset(updatedAsset.getId()); + service.updateAsset(originalAsset.getId(), updateAssetOptions); + AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - assertEquals(updatedAsset.getName(), actualAsset.getName()); - + assertEquals(updatedTestName, updatedAsset.getName()); } - @Test(expected = ServiceException.class) + @Test public void updateAssetFailedWithInvalidId() throws ServiceException { // Arrange UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); // Act - service.updateAsset("updateAssetFailedWithInvalidId", updateAssetOptions); - // Assert - assertTrue(false); + try { + service.updateAsset(fakeAssetId, updateAssetOptions); + + // Assert + fail(); + } + catch (ServiceException ex) { + // Assert + assertEquals("Error code should be not found, because asset does not exist to update", 404, + ex.getHttpStatusCode()); + } } @Test @@ -176,15 +203,21 @@ public void deleteAssetSuccess() throws Exception { assertEquals(assetCountBaseline - 1, listAssetsResult.size()); } - @Test(expected = ServiceException.class) + @Test public void deleteAssetFailedWithInvalidId() throws ServiceException { // Arrange // Act - service.deleteAsset("invalidAssetId"); + try { + service.deleteAsset(fakeAssetId); - // Assert - assertTrue(false); + // Assert + fail(); + } + catch (ServiceException ex) { + // Assert + assertEquals("Error code should be not found, because asset does not exist to update", 404, + ex.getHttpStatusCode()); + } } - } \ No newline at end of file From 3fa1e272f353765a32131dde3f528dae1bdebcb3 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 5 Oct 2012 13:04:29 -0700 Subject: [PATCH 359/664] Revert code checked in by accident --- .../services/media/MediaServiceIntegrationTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index e94c27d925921..8235ebfad1dca 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -27,8 +27,6 @@ import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { @@ -93,10 +91,8 @@ public void createAssetSuccess() throws Exception { public void createAssetNullNameSuccess() throws ServiceException { // Arrange - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - CreateAssetOptions options = new CreateAssetOptions().setOptions(encryptionOption); // Act - AssetInfo actualAsset = service.createAsset(null, options); + AssetInfo actualAsset = service.createAsset(null); // Assert assertNotNull("actualAsset", actualAsset); From 747978240ce96ccdbd442f082856a05020578238 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 5 Oct 2012 14:02:19 -0700 Subject: [PATCH 360/664] Removing dead code --- .../content/CreateAssetRequest.java | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java deleted file mode 100644 index e93c2e7f6844d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/CreateAssetRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.implementation.content; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Serializable class containing the information needed to - * create an asset. - * - */ -@XmlRootElement -public class CreateAssetRequest { - public String Name; - - /** - * Empty constructor required by JaxB. - */ - public CreateAssetRequest() { - } - - public CreateAssetRequest(String name) { - Name = name; - } -} From bbf23b8ec79f6e63a41b7a25338622ec544c5a52 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 5 Oct 2012 14:26:26 -0700 Subject: [PATCH 361/664] Refactor BaseMatcher<ServiceException> into reusable class Refactor tests that had try...catch to use the ServiceExceptionMatcher. --- .../media/AccessPolicyIntegrationTest.java | 29 ++-------- .../media/MediaServiceIntegrationTest.java | 55 +++++-------------- .../media/ServiceExceptionMatcher.java | 47 ++++++++++++++++ 3 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index f91f09eb06b0a..f001cc1d47548 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -20,8 +20,6 @@ import java.util.EnumSet; import java.util.List; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; @@ -39,6 +37,9 @@ public class AccessPolicyIntegrationTest extends IntegrationTestBase { private static final String testPrefix = "testPolicy"; + @Rule + public ExpectedException expected = ExpectedException.none(); + @BeforeClass public static void setup() throws Exception { service = MediaService.create(createConfig()); @@ -114,9 +115,6 @@ public void canRetrieveListOfAccessPolicies() throws Exception { EnumSet.of(AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); } - @Rule - public ExpectedException expected = ExpectedException.none(); - @Test public void getWithBadIdThrowsServiceException() throws Exception { expected.expect(ServiceException.class); @@ -125,26 +123,7 @@ public void getWithBadIdThrowsServiceException() throws Exception { @Test public void getWithValidButNonExistentPolicyIdThrows404ServiceException() throws Exception { - expected.expect(new BaseMatcher<ServiceException>() { - - @Override - public boolean matches(Object item) { - if (item.getClass() != ServiceException.class) { - return false; - } - - if (((ServiceException) item).getHttpStatusCode() != 404) { - return false; - } - - return true; - } - - @Override - public void describeTo(Description description) { - description.appendText("Must be ServiceException with a 404 status code"); - } - }); + expected.expect(new ServiceExceptionMatcher(404)); service.getAccessPolicy("nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 8235ebfad1dca..6716412ed8e7d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -22,7 +22,9 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; @@ -34,6 +36,9 @@ public class MediaServiceIntegrationTest extends IntegrationTestBase { private static String testAssetPrefix = "testAsset"; private static String fakeAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; + @Rule + public ExpectedException thrown = ExpectedException.none(); + @BeforeClass public static void setup() throws Exception { cleanupEnvironment(); @@ -115,21 +120,9 @@ public void getAssetSuccess() throws Exception { @Test public void getAssetFailedWithInvalidId() throws ServiceException { - // Arrange - - // Act - try { - service.getAsset(fakeAssetId); - // Should not get here - - // Assert - fail(); - } - catch (ServiceException ex) { - // Assert - assertEquals("Error code should be not found, because asset does not exist to update", 404, - ex.getHttpStatusCode()); - } + thrown.expect(ServiceException.class); + thrown.expect(new ServiceExceptionMatcher(404)); + service.getAsset(fakeAssetId); } @Test @@ -169,18 +162,9 @@ public void updateAssetFailedWithInvalidId() throws ServiceException { UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); // Act - - try { - service.updateAsset(fakeAssetId, updateAssetOptions); - - // Assert - fail(); - } - catch (ServiceException ex) { - // Assert - assertEquals("Error code should be not found, because asset does not exist to update", 404, - ex.getHttpStatusCode()); - } + thrown.expect(ServiceException.class); + thrown.expect(new ServiceExceptionMatcher(404)); + service.updateAsset(fakeAssetId, updateAssetOptions); } @Test @@ -201,19 +185,8 @@ public void deleteAssetSuccess() throws Exception { @Test public void deleteAssetFailedWithInvalidId() throws ServiceException { - // Arrange - - // Act - try { - service.deleteAsset(fakeAssetId); - - // Assert - fail(); - } - catch (ServiceException ex) { - // Assert - assertEquals("Error code should be not found, because asset does not exist to update", 404, - ex.getHttpStatusCode()); - } + thrown.expect(ServiceException.class); + thrown.expect(new ServiceExceptionMatcher(404)); + service.deleteAsset(fakeAssetId); } } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java new file mode 100644 index 0000000000000..ea4135fcb9076 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java @@ -0,0 +1,47 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + +import com.microsoft.windowsazure.services.core.ServiceException; + +public class ServiceExceptionMatcher extends BaseMatcher<ServiceException> { + private final int httpStatusCode; + + public ServiceExceptionMatcher(int httpStatusCode) { + this.httpStatusCode = httpStatusCode; + } + + @Override + public boolean matches(Object item) { + if (item == null || item.getClass() != ServiceException.class) { + return false; + } + + if (((ServiceException) item).getHttpStatusCode() != this.httpStatusCode) { + return false; + } + + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("Must be ServiceException with status code" + this.httpStatusCode); + } +} From 859446fdd0baf5012f897cc7d95c46584433d364 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 5 Oct 2012 17:04:37 -0700 Subject: [PATCH 362/664] Added SAS filter implementation, issue #348 --- .../media/implementation/SASTokenFilter.java | 67 +++++++++ .../implementation/SASTokenFilterTest.java | 127 ++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java new file mode 100644 index 0000000000000..ddc1461da5dfe --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -0,0 +1,67 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.net.URISyntaxException; + +import javax.ws.rs.core.UriBuilder; + +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; + +/** + * Filter responsible for adding SAS tokens to outgoing requests. + * + */ +public class SASTokenFilter extends ClientFilter { + private final String sasToken; + + /** + * Construct a SASTokenFilter that will insert the tokens given + * in the provided sasUrl. + * + * @param sasUrl + * URL containing authentication information + * @throws URISyntaxException + */ + public SASTokenFilter(String sasToken) throws URISyntaxException { + this.sasToken = sasToken; + } + + /* (non-Javadoc) + * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + */ + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + UriBuilder newUri = UriBuilder.fromUri(cr.getURI()); + String currentQuery = cr.getURI().getRawQuery(); + if (currentQuery == null) { + currentQuery = ""; + } + else if (currentQuery.length() > 0) { + currentQuery += "&"; + } + currentQuery += sasToken; + + newUri.replaceQuery(currentQuery); + cr.setURI(newUri.build()); + + return getNext().handle(cr); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java new file mode 100644 index 0000000000000..714dc794eafba --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java @@ -0,0 +1,127 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import com.sun.jersey.api.client.Client; +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.WebResource; +import com.sun.jersey.api.client.filter.ClientFilter; + +public class SASTokenFilterTest { + + private final String sampleSASToken = "st=2012-10-05T21%3A10%3A25Z&se=2012-10-05T21%3A15%3A25Z&sr=c&si=89fa57b4-293f-40df-a0cb-9d84ee493b8c&sig=iMDPr8V%2FIJrYG8t2GeSqBh5tTUdM7ykOObFVICa%2F%2F1Q%3D"; + private RequestRecordingFilter sink; + private Client client; + + @Before + public void setup() throws Exception { + sink = new RequestRecordingFilter(); + client = Client.create(); + client.addFilter(sink); + client.addFilter(new SASTokenFilter(sampleSASToken)); + } + + @Test + public void filterAddsQueryParameterToRequestUrl() throws Exception { + + WebResource r = client.resource("http://astorageaccount.blob.something.example/asset-abcd"); + + r.get(ClientResponse.class); + + assertContainsSASToken(sink.request.getURI()); + } + + @Test + public void filterPreservesQueryParameters() throws Exception { + client.resource("http://storage.service.example/asset-efgh").queryParam("param0", "first") + .queryParam("param1", "second").get(ClientResponse.class); + + assertContainsSASToken(sink.request.getURI()); + + Map<String, String> queryParams = parseQueryParameters(sink.request.getURI()); + assertTrue(queryParams.containsKey("param0")); + assertTrue(queryParams.containsKey("param1")); + assertEquals("first", queryParams.get("param0")); + assertEquals("second", queryParams.get("param1")); + } + + // Test support code + + // + // Filter that acts as a "sink" so the request doesn't go out over + // the wire. Also holds onto the request object that went through + // the pipeline so that it can be asserted against in the test. + // + private class RequestRecordingFilter extends ClientFilter { + public ClientRequest request; + + @Override + public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + this.request = request; + + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getStatus()).thenReturn(200); + return response; + } + } + + // Assertion helpers + + private void assertContainsSASToken(URI uri) { + Map<String, String> queryParams = parseQueryParameters(uri); + + assertTrue(queryParams.containsKey("st")); + assertTrue(queryParams.containsKey("se")); + assertTrue(queryParams.containsKey("sr")); + assertTrue(queryParams.containsKey("si")); + assertTrue(queryParams.containsKey("sig")); + + assertEquals("iMDPr8V%2FIJrYG8t2GeSqBh5tTUdM7ykOObFVICa%2F%2F1Q%3D", queryParams.get("sig")); + } + + // I am shocked this isn't already in the core library! + private Map<String, String> parseQueryParameters(URI uri) { + HashMap<String, String> queryParameters = new HashMap<String, String>(); + String queryString = uri.getRawQuery(); + if (queryString.startsWith("?")) { + queryString = queryString.substring(1); + } + + String[] parameters = queryString.split("&"); + + for (String param : parameters) { + int firstEqualIndex = param.indexOf('='); + String paramName = param.substring(0, firstEqualIndex); + String value = param.substring(firstEqualIndex + 1); + + queryParameters.put(paramName, value); + } + return queryParameters; + } + +} From 5a339e396dd91f029466e0b1c42a18d96ba544f1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 5 Oct 2012 18:19:03 -0700 Subject: [PATCH 363/664] Added new unit test to cover more scenarios. Have one unit test failue now due to #364. --- .../media/MediaServiceIntegrationTest.java | 107 ++++++++++++++++-- 1 file changed, 97 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 6716412ed8e7d..e29905b55eaef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -29,6 +29,9 @@ import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetState; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { @@ -55,7 +58,7 @@ private static void cleanupEnvironment() { try { List<AssetInfo> listAssetsResult = service.listAssets(); for (AssetInfo assetInfo : listAssetsResult) { - if (assetInfo.getName().startsWith(testAssetPrefix)) { + if (assetInfo.getName().startsWith(testAssetPrefix) || assetInfo.getName().equals("")) { service.deleteAsset(assetInfo.getId()); } } @@ -89,7 +92,46 @@ public void createAssetSuccess() throws Exception { AssetInfo actualAsset = service.createAsset(testName); // Assert - assertEquals("testName and actualAsset name", testName, actualAsset.getName()); + assertEquals("actualAsset Name", testName, actualAsset.getName()); + assertEquals("actualAsset AlternateId", "", actualAsset.getAlternateId()); + assertEquals("actualAsset Options", EncryptionOption.None, actualAsset.getOptions()); + assertEquals("actualAsset State", AssetState.Initialized, actualAsset.getState()); + } + + @Test + public void createAssetOptionsSuccess() throws Exception { + // Arrange + String testName = testAssetPrefix + "createAssetOptionsSuccess"; + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState); + + // Act + AssetInfo actualAsset = service.createAsset(testName, options); + + // Assert + assertEquals("actualAsset Name", testName, actualAsset.getName()); + assertEquals("actualAsset AlternateId", altId, actualAsset.getAlternateId()); + assertEquals("actualAsset Options", encryptionOption, actualAsset.getOptions()); + assertEquals("actualAsset State", assetState, actualAsset.getState()); + } + + @Test + public void createAssetMeanString() throws Exception { + // Arrange + String meanString = "'\"(?++\\+&==/&?''$@:// +ne <some><XML></stuff>" + + "{\"jsonLike\":\"Created\":\"\\/Date(1336368841597)\\/\",\"Name\":null,cksum value\"}}" + + "Some unicode: \uB2E4\uB974\uB2E4\uB294\u0625 \u064A\u062F\u064A\u0648\u0009\r\n"; + + String testName = testAssetPrefix + "createAssetMeanString" + meanString; + + // Act + AssetInfo actualAsset = service.createAsset(testName); + + // Assert + assertEquals("actualAsset Name", testName, actualAsset.getName()); } @Test @@ -109,13 +151,21 @@ public void createAssetNullNameSuccess() throws ServiceException { public void getAssetSuccess() throws Exception { // Arrange String testName = testAssetPrefix + "GetAssetSuccess"; - AssetInfo assetInfo = service.createAsset(testName); + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState); + AssetInfo assetInfo = service.createAsset(testName, options); // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); // Assert - assertEquals(testName, actualAsset.getName()); + assertEquals("actualAsset Name", testName, actualAsset.getName()); + assertEquals("actualAsset AlternateId", altId, actualAsset.getAlternateId()); + assertEquals("actualAsset Options", encryptionOption, actualAsset.getOptions()); + assertEquals("actualAsset State", assetState, actualAsset.getState()); } @Test @@ -142,18 +192,51 @@ public void listAssetSuccess() throws ServiceException { @Test public void updateAssetSuccess() throws Exception { // Arrange - String originalTestName = testAssetPrefix + "UpdateAssetSuccess"; - String updatedTestName = testAssetPrefix + "UpdateAssetSuccess"; + String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; + CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") + .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published); + AssetInfo originalAsset = service.createAsset(originalTestName, originalOptions); + + String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; + String altId = "otherAltId"; + EncryptionOption encryptionOption = EncryptionOption.None; + AssetState assetState = AssetState.Initialized; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState); + + // Act + service.updateAsset(originalAsset.getId(), updateAssetOptions); + AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); + + // Assert + assertEquals("updatedAsset Name", updatedTestName, updatedAsset.getName()); + assertEquals("updatedAsset AlternateId", altId, updatedAsset.getAlternateId()); + assertEquals("updatedAsset Options", encryptionOption, updatedAsset.getOptions()); + assertEquals("updatedAsset State", assetState, updatedAsset.getState()); + } + + @Test + public void updateAssetNoChangesSuccess() throws Exception { + // Arrange + String originalTestName = testAssetPrefix + "updateAssetNoChangesSuccess"; + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState); + AssetInfo originalAsset = service.createAsset(originalTestName, options); - AssetInfo originalAsset = service.createAsset(originalTestName); - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); // Act service.updateAsset(originalAsset.getId(), updateAssetOptions); AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - assertEquals(updatedTestName, updatedAsset.getName()); + assertEquals("updatedAsset Name", originalTestName, updatedAsset.getName()); + assertEquals("updatedAsset AlternateId", altId, updatedAsset.getAlternateId()); + assertEquals("updatedAsset Options", encryptionOption, updatedAsset.getOptions()); + assertEquals("updatedAsset State", assetState, updatedAsset.getState()); } @Test @@ -179,8 +262,12 @@ public void deleteAssetSuccess() throws Exception { service.deleteAsset(assetInfo.getId()); // Assert - listAssetsResult = service.listAssets(null); + listAssetsResult = service.listAssets(); assertEquals(assetCountBaseline - 1, listAssetsResult.size()); + + thrown.expect(ServiceException.class); + thrown.expect(new ServiceExceptionMatcher(404)); + service.getAsset(assetInfo.getId()); } @Test From 45eb01b0d3fe9546f56a6ba3c4c9eceacc353e0c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 8 Oct 2012 11:21:58 -0700 Subject: [PATCH 364/664] Refactor AssetInfo verification into a helper method. Removed aggresive deletes of assets with empty names. Added cleanup of asset in the "createAssetNullNameSuccess" test. --- .../media/MediaServiceIntegrationTest.java | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index e29905b55eaef..70a9d8b564a1a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -22,6 +22,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -58,7 +59,7 @@ private static void cleanupEnvironment() { try { List<AssetInfo> listAssetsResult = service.listAssets(); for (AssetInfo assetInfo : listAssetsResult) { - if (assetInfo.getName().startsWith(testAssetPrefix) || assetInfo.getName().equals("")) { + if (assetInfo.getName().startsWith(testAssetPrefix)) { service.deleteAsset(assetInfo.getId()); } } @@ -78,6 +79,15 @@ private static Configuration createConfig() { return config; } + private void verifyAssetProperties(String message, String testName, String altId, + EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + assertNotNull(message, actualAsset); + assertEquals(message + " Name", testName, actualAsset.getName()); + assertEquals(message + " AlternateId", altId, actualAsset.getAlternateId()); + assertEquals(message + " Options", encryptionOption, actualAsset.getOptions()); + assertEquals(message + " State", assetState, actualAsset.getState()); + } + @Before public void setupInstance() throws Exception { service = MediaService.create(config); @@ -92,10 +102,7 @@ public void createAssetSuccess() throws Exception { AssetInfo actualAsset = service.createAsset(testName); // Assert - assertEquals("actualAsset Name", testName, actualAsset.getName()); - assertEquals("actualAsset AlternateId", "", actualAsset.getAlternateId()); - assertEquals("actualAsset Options", EncryptionOption.None, actualAsset.getOptions()); - assertEquals("actualAsset State", AssetState.Initialized, actualAsset.getState()); + verifyAssetProperties("actualAsset", testName, "", EncryptionOption.None, AssetState.Initialized, actualAsset); } @Test @@ -112,10 +119,7 @@ public void createAssetOptionsSuccess() throws Exception { AssetInfo actualAsset = service.createAsset(testName, options); // Assert - assertEquals("actualAsset Name", testName, actualAsset.getName()); - assertEquals("actualAsset AlternateId", altId, actualAsset.getAlternateId()); - assertEquals("actualAsset Options", encryptionOption, actualAsset.getOptions()); - assertEquals("actualAsset State", assetState, actualAsset.getState()); + verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); } @Test @@ -135,16 +139,28 @@ public void createAssetMeanString() throws Exception { } @Test - public void createAssetNullNameSuccess() throws ServiceException { + public void createAssetNullNameSuccess() throws Exception { // Arrange // Act - AssetInfo actualAsset = service.createAsset(null); - - // Assert - assertNotNull("actualAsset", actualAsset); - assertEquals("actualAsset.getName() should be the service default value, the empty string", "", - actualAsset.getName()); + AssetInfo actualAsset = null; + try { + actualAsset = service.createAsset(null); + // Assert + assertNotNull("actualAsset", actualAsset); + assertEquals("actualAsset.getName() should be the service default value, the empty string", "", + actualAsset.getName()); + } + catch (Exception ex) { + try { + if (actualAsset != null) + service.deleteAsset(actualAsset.getId()); + } + catch (ServiceException ex2) { + ex.printStackTrace(); + } + throw ex; + } } @Test @@ -161,11 +177,7 @@ public void getAssetSuccess() throws Exception { // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); - // Assert - assertEquals("actualAsset Name", testName, actualAsset.getName()); - assertEquals("actualAsset AlternateId", altId, actualAsset.getAlternateId()); - assertEquals("actualAsset Options", encryptionOption, actualAsset.getOptions()); - assertEquals("actualAsset State", assetState, actualAsset.getState()); + verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); } @Test @@ -189,6 +201,8 @@ public void listAssetSuccess() throws ServiceException { assertEquals(listAssetResultBaseLine.size() + 2, listAssetResult.size()); } + @Ignore + // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 @Test public void updateAssetSuccess() throws Exception { // Arrange @@ -209,10 +223,7 @@ public void updateAssetSuccess() throws Exception { AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - assertEquals("updatedAsset Name", updatedTestName, updatedAsset.getName()); - assertEquals("updatedAsset AlternateId", altId, updatedAsset.getAlternateId()); - assertEquals("updatedAsset Options", encryptionOption, updatedAsset.getOptions()); - assertEquals("updatedAsset State", assetState, updatedAsset.getState()); + verifyAssetProperties("updatedAsset", updatedTestName, altId, encryptionOption, assetState, updatedAsset); } @Test @@ -233,10 +244,7 @@ public void updateAssetNoChangesSuccess() throws Exception { AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - assertEquals("updatedAsset Name", originalTestName, updatedAsset.getName()); - assertEquals("updatedAsset AlternateId", altId, updatedAsset.getAlternateId()); - assertEquals("updatedAsset Options", encryptionOption, updatedAsset.getOptions()); - assertEquals("updatedAsset State", assetState, updatedAsset.getState()); + verifyAssetProperties("updatedAsset", originalTestName, altId, encryptionOption, assetState, updatedAsset); } @Test From 600aae40f4b1b072e0cf9589a1b043f133a9e5da Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 8 Oct 2012 11:40:03 -0700 Subject: [PATCH 365/664] Responded to code review feedback --- .../services/media/implementation/SASTokenFilter.java | 2 +- .../services/media/implementation/SASTokenFilterTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index ddc1461da5dfe..86742178acd0a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -39,7 +39,7 @@ public class SASTokenFilter extends ClientFilter { * URL containing authentication information * @throws URISyntaxException */ - public SASTokenFilter(String sasToken) throws URISyntaxException { + public SASTokenFilter(String sasToken) { this.sasToken = sasToken; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java index 714dc794eafba..b4197bbaabedd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java @@ -104,7 +104,8 @@ private void assertContainsSASToken(URI uri) { assertEquals("iMDPr8V%2FIJrYG8t2GeSqBh5tTUdM7ykOObFVICa%2F%2F1Q%3D", queryParams.get("sig")); } - // I am shocked this isn't already in the core library! + // Simplistic parsing of query parameters into map so we can assert against contents + // easily. private Map<String, String> parseQueryParameters(URI uri) { HashMap<String, String> queryParameters = new HashMap<String, String>(); String queryString = uri.getRawQuery(); From 86fb1473c71c5420de1a21ecb44f21f69044910b Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 8 Oct 2012 12:07:49 -0700 Subject: [PATCH 366/664] Change catch to finally --- .../services/media/MediaServiceIntegrationTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 70a9d8b564a1a..c732f7ff72925 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -151,15 +151,17 @@ public void createAssetNullNameSuccess() throws Exception { assertEquals("actualAsset.getName() should be the service default value, the empty string", "", actualAsset.getName()); } - catch (Exception ex) { + finally { + // Clean up the anonymous asset now while we have the id, because we + // do not want to delete all anonymous assets in the bulk-cleanup code. try { - if (actualAsset != null) + if (actualAsset != null) { service.deleteAsset(actualAsset.getId()); + } } - catch (ServiceException ex2) { + catch (ServiceException ex) { ex.printStackTrace(); } - throw ex; } } From a13dad3b4c75bce0ef2aa462be6f3c7f0b7d7802 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 9 Oct 2012 12:12:48 -0700 Subject: [PATCH 367/664] Adding more tests to AccessPolicyIntegrationTest - Move createConfig() to base class - Adding more validation to Access Policy tests - Adding more validation to Asset tests --- .../media/AccessPolicyIntegrationTest.java | 173 +++++++++++++----- .../services/media/IntegrationTestBase.java | 10 + .../media/MediaServiceIntegrationTest.java | 51 ++++-- 3 files changed, 169 insertions(+), 65 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index f001cc1d47548..705558766f2e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -21,19 +21,22 @@ import java.util.List; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; public class AccessPolicyIntegrationTest extends IntegrationTestBase { - private static MediaContract service; + private MediaContract service; + + private final String invalidId = "notAValidId"; + private final String validButNonexistId = "nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"; private static final String testPrefix = "testPolicy"; @@ -42,53 +45,118 @@ public class AccessPolicyIntegrationTest extends IntegrationTestBase { @BeforeClass public static void setup() throws Exception { - service = MediaService.create(createConfig()); - } - - private static Configuration createConfig() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); - overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - return config; + cleanupEnvironment(); } @AfterClass public static void cleanup() throws Exception { - for (AccessPolicyInfo policy : service.listAccessPolicies()) { - if (policy.getName().startsWith(testPrefix)) { - service.deleteAccessPolicy(policy.getId()); + cleanupEnvironment(); + } + + private static void cleanupEnvironment() { + config = createConfig(); + MediaContract service = MediaService.create(config); + try { + List<AccessPolicyInfo> policies = service.listAccessPolicies(); + for (AccessPolicyInfo policy : policies) { + if (policy.getName().startsWith(testPrefix)) { + service.deleteAccessPolicy(policy.getId()); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + private void verifyPolicyProperties(String message, String testName, double duration, + AccessPolicyPermission permission, AccessPolicyInfo policy) { + verifyPolicyProperties(message, testName, duration, EnumSet.of(permission), policy); + } + + private void verifyPolicyProperties(String message, String testName, double duration, + EnumSet<AccessPolicyPermission> permissions, AccessPolicyInfo policy) { + assertNotNull(message, policy); + assertEquals(message + " Name", testName, policy.getName()); + assertEquals(message + " DurationInMinutes", duration, policy.getDurationInMinutes(), 0.00001); + for (AccessPolicyPermission permission : permissions) { + if (permission != AccessPolicyPermission.NONE) { + assertTrue(message + "permissions should contain " + permission, + policy.getPermissions().contains(permission)); } } + assertEquals(message + " Permissions", permissions, policy.getPermissions()); + + assertNotNull(message + " Id", policy.getId()); + assertNotNull(message + " Created", policy.getCreated()); + assertNotNull(message + " LastModified", policy.getLastModified()); + assertEquals(message + " Created & LastModified", policy.getCreated(), policy.getLastModified()); + } + + @Before + public void setupInstance() throws Exception { + service = MediaService.create(config); } @Test public void canCreateAccessPolicy() throws Exception { - AccessPolicyInfo policy = service.createAccessPolicy(testPrefix + "CanCreate", 5, - new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE))); + String testName = testPrefix + "CanCreate"; + double duration = 5; + + AccessPolicyInfo policy = service.createAccessPolicy(testName, duration); + + verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.WRITE, policy); + } + + @Test + public void canCreateAccessPolicyOptions() throws Exception { + String testName = testPrefix + "CanCreateOptions"; + double duration = 5; + AccessPolicyPermission permission = AccessPolicyPermission.WRITE; + CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(permission); - assertTrue(policy.getPermissions().contains(AccessPolicyPermission.WRITE)); + AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, options); + + verifyPolicyProperties("policy", testName, duration, permission, policy); } + // TODO: Null name or duration? + @Test public void canGetSinglePolicyById() throws Exception { String expectedName = testPrefix + "GetOne"; - AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, 1); + double duration = 1; + AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, duration); AccessPolicyInfo retrievedPolicy = service.getAccessPolicy(policyToGet.getId()); - assertEquals(expectedName, retrievedPolicy.getName()); assertEquals(policyToGet.getId(), retrievedPolicy.getId()); + verifyPolicyProperties("retrievedPolicy", expectedName, duration, AccessPolicyPermission.WRITE, retrievedPolicy); + } + + @Test + public void canGetSinglePolicyByInvalidId() throws Exception { + expected.expect(ServiceException.class); + expected.expect(new ServiceExceptionMatcher(500)); + service.getAccessPolicy(invalidId); + } + + @Test + public void canGetSinglePolicyByNonexistId() throws Exception { + expected.expect(ServiceException.class); + expected.expect(new ServiceExceptionMatcher(404)); + service.getAccessPolicy(validButNonexistId); } @Test public void canRetrieveListOfAccessPolicies() throws Exception { String[] policyNames = new String[] { testPrefix + "ListOne", testPrefix + "ListTwo" }; + double duration = 3; + EnumSet<AccessPolicyPermission> permissions = EnumSet.of(AccessPolicyPermission.WRITE, + AccessPolicyPermission.LIST); + for (String name : policyNames) { - service.createAccessPolicy(name, 3, new CreateAccessPolicyOptions().addPermissions(EnumSet.of( - AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); + service.createAccessPolicy(name, duration, new CreateAccessPolicyOptions().addPermissions(permissions)); } List<AccessPolicyInfo> policies = service.listAccessPolicies(); @@ -96,45 +164,56 @@ public void canRetrieveListOfAccessPolicies() throws Exception { assertNotNull(policies); assertTrue(policies.size() >= 2); - AccessPolicyInfo policy1 = null; - AccessPolicyInfo policy2 = null; + AccessPolicyInfo[] orderedPolicies = new AccessPolicyInfo[policyNames.length]; for (AccessPolicyInfo policy : policies) { - if (policy.getName().equals(policyNames[0])) { - policy1 = policy; - } - if (policy.getName().equals(policyNames[1])) { - policy2 = policy; + for (int i = 0; i < policyNames.length; i++) { + if (policy.getName().equals(policyNames[i])) { + orderedPolicies[i] = policy; + } } } - assertNotNull(policy1); - assertNotNull(policy2); - - assertTrue(policy1.getPermissions().containsAll( - EnumSet.of(AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST))); - } - - @Test - public void getWithBadIdThrowsServiceException() throws Exception { - expected.expect(ServiceException.class); - AccessPolicyInfo policy = service.getAccessPolicy("notAValidId"); + for (int i = 0; i < policyNames.length; i++) { + verifyPolicyProperties("orderedPolicies " + i, policyNames[i], duration, permissions, orderedPolicies[i]); + } } - @Test - public void getWithValidButNonExistentPolicyIdThrows404ServiceException() throws Exception { - expected.expect(new ServiceExceptionMatcher(404)); - service.getAccessPolicy("nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"); - } + // Note: Access Policy cannot be updated. @Test public void canDeleteAccessPolicyById() throws Exception { - AccessPolicyInfo policyToDelete = service.createAccessPolicy(testPrefix + "ToDelete", 1); + String policyName = testPrefix + "ToDelete"; + double duration = 1; + AccessPolicyInfo policyToDelete = service.createAccessPolicy(policyName, duration); + List<AccessPolicyInfo> listPoliciesResult = service.listAccessPolicies(); + int policyCountBaseline = listPoliciesResult.size(); service.deleteAccessPolicy(policyToDelete.getId()); + listPoliciesResult = service.listAccessPolicies(); + assertEquals("listPoliciesResult.size", policyCountBaseline - 1, listPoliciesResult.size()); + for (AccessPolicyInfo policy : service.listAccessPolicies()) { assertFalse(policyToDelete.getId().equals(policy.getId())); } + + expected.expect(ServiceException.class); + expected.expect(new ServiceExceptionMatcher(404)); + service.getAccessPolicy(policyToDelete.getId()); + } + + @Test + public void canDeleteAccessPolicyByInvalidId() throws Exception { + expected.expect(ServiceException.class); + expected.expect(new ServiceExceptionMatcher(500)); + service.deleteAccessPolicy(invalidId); + } + + @Test + public void canDeleteAccessPolicyByNonexistId() throws Exception { + expected.expect(ServiceException.class); + expected.expect(new ServiceExceptionMatcher(404)); + service.deleteAccessPolicy(validButNonexistId); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index b7e735e55c30e..d268e7ecf575a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -16,6 +16,16 @@ public void beforeEachTest() { overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); } + protected static Configuration createConfig() { + Configuration config = Configuration.getInstance(); + overrideWithEnv(config, MediaConfiguration.URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); + return config; + } + protected static void overrideWithEnv(Configuration config, String key) { String value = System.getenv(key); if (value == null) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index c732f7ff72925..64108fc87ebe5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.microsoft.windowsazure.services.media; import static org.junit.Assert.*; @@ -27,7 +28,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; @@ -37,7 +37,8 @@ public class MediaServiceIntegrationTest extends IntegrationTestBase { private MediaContract service; - private static String testAssetPrefix = "testAsset"; + + private static final String testAssetPrefix = "testAsset"; private static String fakeAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; @Rule @@ -69,16 +70,6 @@ private static void cleanupEnvironment() { } } - private static Configuration createConfig() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); - overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - return config; - } - private void verifyAssetProperties(String message, String testName, String altId, EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { assertNotNull(message, actualAsset); @@ -179,6 +170,7 @@ public void getAssetSuccess() throws Exception { // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); + assertEquals("Id", assetInfo.getId(), actualAsset.getId()); verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); } @@ -193,14 +185,37 @@ public void getAssetFailedWithInvalidId() throws ServiceException { public void listAssetSuccess() throws ServiceException { // Arrange Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); - service.createAsset(testAssetPrefix + "assetA"); - service.createAsset(testAssetPrefix + "assetB"); + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState); + + String[] assetNames = new String[] { testAssetPrefix + "assetA", testAssetPrefix + "assetB" }; + for (String name : assetNames) { + service.createAsset(name, options); + } // Act Collection<AssetInfo> listAssetResult = service.listAssets(); // Assert - assertEquals(listAssetResultBaseLine.size() + 2, listAssetResult.size()); + assertNotNull("listAssetResult", listAssetResult); + assertEquals("listAssetResult.size", listAssetResultBaseLine.size() + 2, listAssetResult.size()); + + AssetInfo[] assets = new AssetInfo[assetNames.length]; + + for (AssetInfo asset : listAssetResult) { + for (int i = 0; i < assetNames.length; i++) { + if (asset.getName().equals(assetNames[i])) { + assets[i] = asset; + } + } + } + + for (int i = 0; i < assetNames.length; i++) { + verifyAssetProperties("asset " + i, assetNames[i], altId, encryptionOption, assetState, assets[i]); + } } @Ignore @@ -265,7 +280,7 @@ public void deleteAssetSuccess() throws Exception { // Arrange String assetName = "deleteAssetSuccess"; AssetInfo assetInfo = service.createAsset(assetName); - List<AssetInfo> listAssetsResult = service.listAssets(null); + List<AssetInfo> listAssetsResult = service.listAssets(); int assetCountBaseline = listAssetsResult.size(); // Act @@ -273,7 +288,7 @@ public void deleteAssetSuccess() throws Exception { // Assert listAssetsResult = service.listAssets(); - assertEquals(assetCountBaseline - 1, listAssetsResult.size()); + assertEquals("listAssetsResult.size", assetCountBaseline - 1, listAssetsResult.size()); thrown.expect(ServiceException.class); thrown.expect(new ServiceExceptionMatcher(404)); From f1ddf9a2f662eee700b892612b56bd2771c8c0ea Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 15:23:48 -0700 Subject: [PATCH 368/664] initial commit for Locator CRUD operation. --- .../services/media/MediaContract.java | 20 ++ .../MediaExceptionProcessor.java | 86 +++++++ .../media/implementation/MediaRestProxy.java | 91 ++++++++ .../implementation/ODataAtomMarshaller.java | 2 + .../content/LocatorRestType.java | 205 +++++++++++++++++ .../implementation/content/ObjectFactory.java | 9 + .../media/models/CreateLocatorOptions.java | 168 ++++++++++++++ .../services/media/models/LocatorInfo.java | 75 +++--- .../services/media/models/LocatorType.java | 25 ++ .../media/models/UpdateLocatorOptions.java | 168 ++++++++++++++ .../media/MediaServiceIntegrationTest.java | 217 +++++++++++++++++- 11 files changed, 1017 insertions(+), 49 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index aac6354b6947c..fa221e91fce5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -22,9 +22,16 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; +import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; +import com.sun.jersey.api.client.UniformInterfaceException; /** * Defines the methods available for Windows Azure Media Services. @@ -165,4 +172,17 @@ AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, Creat * @throws ServiceException */ List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; + + public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, + CreateLocatorOptions createLocatorOptions) throws ServiceException; + + public LocatorInfo getLocator(String locatorId) throws ServiceException; + + public ListLocatorsResult listLocators() throws ServiceException; + + public void deleteLocator(String id) throws UniformInterfaceException, ServiceException; + + public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) throws ServiceException; + + void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 314111bc50b34..e1b5d0f078775 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -30,9 +30,15 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; +import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; @@ -297,4 +303,84 @@ public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options throw processCatch(new ServiceException(e)); } } + + @Override + public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, + CreateLocatorOptions createLocatorOptions) throws ServiceException { + try { + return service.createLocator(accessPolicyId, assetId, locatorType, createLocatorOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public LocatorInfo getLocator(String locatorId) throws ServiceException { + try { + return service.getLocator(locatorId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListLocatorsResult listLocators() throws ServiceException { + try { + return service.listLocators(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public void deleteLocator(String locatorId) throws ServiceException { + try { + service.deleteLocator(locatorId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException { + try { + service.updateLocator(locatorId, updateLocatorOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + + } + + @Override + public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorsOptions) throws ServiceException { + try { + return service.listLocators(listLocatorsOptions); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index c27f83ff48ff0..5d1dcf3c4e73c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -34,17 +34,25 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; +import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; /** @@ -321,4 +329,87 @@ public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options .get(new GenericType<List<AccessPolicyInfo>>() { }); } + + @Override + public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, + CreateLocatorOptions createLocatorOptions) { + if (createLocatorOptions == null) { + createLocatorOptions = new CreateLocatorOptions(); + } + + LocatorRestType locatorRestType = new LocatorRestType(); + locatorRestType.setAccessPolicyId(accessPolicyId); + locatorRestType.setAssetId(assetId); + locatorRestType.setType(locatorType.getCode()); + if (createLocatorOptions != null) { + if (createLocatorOptions.getExpirationDateTime() != null) { + locatorRestType.setExpirationDateTime(createLocatorOptions.getExpirationDateTime()); + } + + if (createLocatorOptions.getStartTime() != null) { + locatorRestType.setStartTime(createLocatorOptions.getStartTime()); + } + } + + WebResource resource = getResource("Locators"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(LocatorInfo.class, locatorRestType); + } + + @Override + public LocatorInfo getLocator(String locatorId) throws ServiceException { + WebResource resource = getResource("Locators", locatorId); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(LocatorInfo.class); + } + + @Override + public ListLocatorsResult listLocators() { + return listLocators(null); + } + + @Override + public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) { + WebResource resource = getResource("Locators"); + + List<LocatorInfo> locatorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<LocatorInfo>>() { + }); + ListLocatorsResult listLocatorsResult = new ListLocatorsResult(); + listLocatorsResult.setLocatorInfos(locatorInfoList); + return listLocatorsResult; + + } + + @Override + public void deleteLocator(String locatorId) throws UniformInterfaceException, ServiceException { + getResource("Locators", locatorId).delete(); + } + + @Override + public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException { + String escapedLocatorId = null; + try { + escapedLocatorId = URLEncoder.encode(locatorId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + + String assetPath = String.format("Locators(\'%s\')", escapedLocatorId); + LocatorRestType updatedLocatorRestType = new LocatorRestType(); + + updatedLocatorRestType.setId(locatorId); + updatedLocatorRestType.setAccessPolicyId(updateLocatorOptions.getAccessPolicyId()); + updatedLocatorRestType.setAssetId(updateLocatorOptions.getAssetId()); + updatedLocatorRestType.setExpirationDateTime(updateLocatorOptions.getExpirationDateTime()); + updatedLocatorRestType.setStartTime(updateLocatorOptions.getStartTime()); + if (updateLocatorOptions.getType() != null) { + updatedLocatorRestType.setType(updateLocatorOptions.getType().getCode()); + } + + ClientResponse clientResponse = mergeRequest(assetPath, ClientResponse.class, updatedLocatorRestType); + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 13edb3b00de50..d13efc0f2fa51 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -36,6 +36,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; /** * A class to manage marshalling of request parameters into @@ -116,6 +117,7 @@ private static Class<?>[] getMarshalledClasses() { classes.add(EntryType.class); classes.add(AssetType.class); classes.add(AccessPolicyType.class); + classes.add(LocatorRestType.class); return classes.toArray(new Class<?>[0]); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java new file mode 100644 index 0000000000000..f498cc765474b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -0,0 +1,205 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * Wrapper DTO for Media Services Locator. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class LocatorRestType implements MediaServiceDTO { + + /** The id. */ + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + /** The expiration date time. */ + @XmlElement(name = "ExpirationDateTime", namespace = Constants.ODATA_DATA_NS) + protected Date expirationDateTime; + + /** The type. */ + @XmlElement(name = "Type", namespace = Constants.ODATA_DATA_NS) + protected int type; + + /** The path. */ + @XmlElement(name = "Path", namespace = Constants.ODATA_DATA_NS) + protected String path; + + /** The access policy id. */ + @XmlElement(name = "AccessPolicyId", namespace = Constants.ODATA_DATA_NS) + protected String accessPolicyId; + + /** The asset id. */ + @XmlElement(name = "AssetId", namespace = Constants.ODATA_DATA_NS) + protected String assetId; + + /** The start time. */ + @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + protected Date startTime; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id + * the id to set + * @return the locator rest type + */ + public LocatorRestType setId(String id) { + this.id = id; + return this; + } + + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return expirationDateTime; + } + + /** + * Sets the expiration date time. + * + * @param expirationDateTime + * the expiration date time + * @return the locator rest type + */ + public LocatorRestType setExpirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + /** + * Gets the type. + * + * @return the type + */ + public int getType() { + return this.type; + } + + /** + * Sets the type. + * + * @param type + * the type + * @return the locator rest type + */ + public LocatorRestType setType(int type) { + this.type = type; + return this; + } + + /** + * Gets the path. + * + * @return the path + */ + public String getPath() { + return this.path; + } + + /** + * Gets the access policy id. + * + * @return the access policy id + */ + public String getAccessPolicyId() { + return this.accessPolicyId; + } + + /** + * Sets the access policy id. + * + * @param accessPolicyId + * the access policy id + * @return the locator rest type + */ + public LocatorRestType setAccessPolicyId(String accessPolicyId) { + this.accessPolicyId = accessPolicyId; + return this; + } + + /** + * Gets the asset id. + * + * @return the asset id + */ + public String getAssetId() { + return this.assetId; + } + + /** + * Sets the asset id. + * + * @param assetId + * the asset id + * @return the locator rest type + */ + public LocatorRestType setAssetId(String assetId) { + this.assetId = assetId; + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return this.startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the locator rest type + */ + public LocatorRestType setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Sets the path. + * + * @param path + * the path + * @return the locator rest type + */ + public LocatorRestType setPath(String path) { + this.path = path; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index 09cc9f513adba..3ad821b63e1cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -58,4 +58,13 @@ public ODataActionType createODataActionType() { public AccessPolicyType createAccessPolicyType() { return new AccessPolicyType(); } + + /** + * Create an instance of {@link LocatorRestType } + * + * @return a new LocatorRestType instance. + */ + public LocatorRestType createLocatorRestType() { + return new LocatorRestType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java new file mode 100644 index 0000000000000..4af3be252ddd6 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java @@ -0,0 +1,168 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class CreateLocatorOptions. + */ +public class CreateLocatorOptions { + + /** The expiration date time. */ + private Date expirationDateTime; + + /** The type. */ + private LocatorType type; + + /** The path. */ + private String path; + + /** The access policy id. */ + private String accessPolicyId; + + /** The asset id. */ + private String assetId; + + /** The start time. */ + private Date startTime; + + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return expirationDateTime; + } + + /** + * Sets the expiration date time. + * + * @param expirationDateTime + * the expiration date time + * @return the creates the locator options + */ + public CreateLocatorOptions setExpirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + /** + * Gets the type. + * + * @return the type + */ + public LocatorType getType() { + return type; + } + + /** + * Sets the type. + * + * @param type + * the type + * @return the creates the locator options + */ + public CreateLocatorOptions setType(LocatorType type) { + this.type = type; + return this; + } + + /** + * Gets the path. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Sets the path. + * + * @param path + * the path + * @return the creates the locator options + */ + public CreateLocatorOptions setPath(String path) { + this.path = path; + return this; + } + + /** + * Gets the access policy id. + * + * @return the access policy id + */ + public String getAccessPolicyId() { + return accessPolicyId; + } + + /** + * Sets the access policy id. + * + * @param accessPolicyId + * the access policy id + * @return the creates the locator options + */ + public CreateLocatorOptions setAccessPolicyId(String accessPolicyId) { + this.accessPolicyId = accessPolicyId; + return this; + } + + /** + * Gets the asset id. + * + * @return the asset id + */ + public String getAssetId() { + return assetId; + } + + /** + * Sets the asset id. + * + * @param assetId + * the asset id + * @return the creates the locator options + */ + public CreateLocatorOptions setAssetId(String assetId) { + this.assetId = assetId; + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the creates the locator options + */ + public CreateLocatorOptions setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index c90c38aba3e85..308783c3a7f68 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -17,31 +17,22 @@ import java.util.Date; +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; + /** * The Class LocatorInfo. */ -public class LocatorInfo { - - /** The id. */ - private String id; - - /** The expiration datetime. */ - private Date expirationDatetime; - - /** The path. */ - private String path; - - /** The access policy id. */ - private String accessPolicyId; - - /** The asset id. */ - private String assetId; +public class LocatorInfo extends ODataEntity<LocatorRestType> { - /** The start time. */ - private Date startTime; + public LocatorInfo(EntryType entry, LocatorRestType content) { + super(entry, content); + } - /** The locator type. */ - private LocatorType locatorType; + public LocatorInfo() { + super(new LocatorRestType()); + } /** * Gets the id. @@ -49,7 +40,7 @@ public class LocatorInfo { * @return the id */ public String getId() { - return this.id; + return getContent().getId(); } /** @@ -60,10 +51,19 @@ public String getId() { * @return the locator info */ public LocatorInfo setId(String id) { - this.id = id; + getContent().setId(id); return this; } + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return getContent().getExpirationDateTime(); + } + /** * Sets the expiration date time. * @@ -72,19 +72,10 @@ public LocatorInfo setId(String id) { * @return the locator info */ public LocatorInfo setExpirationDateTime(Date expirationDateTime) { - this.expirationDatetime = expirationDateTime; + getContent().setExpirationDateTime(expirationDateTime); return this; } - /** - * Gets the expiration date time. - * - * @return the expiration date time - */ - public Date getExpirationDateTime() { - return this.expirationDatetime; - } - /** * Sets the locator type. * @@ -93,7 +84,7 @@ public Date getExpirationDateTime() { * @return the locator info */ public LocatorInfo setLocatorType(LocatorType locatorType) { - this.locatorType = locatorType; + getContent().setType(locatorType.getCode()); return this; } @@ -103,7 +94,7 @@ public LocatorInfo setLocatorType(LocatorType locatorType) { * @return the locator type */ public LocatorType getLocatorType() { - return this.locatorType; + return LocatorType.fromCode(getContent().getType()); } /** @@ -114,7 +105,7 @@ public LocatorType getLocatorType() { * @return the locator info */ public LocatorInfo setPath(String path) { - this.path = path; + getContent().setPath(path); return this; } @@ -124,7 +115,7 @@ public LocatorInfo setPath(String path) { * @return the path */ public String getPath() { - return this.path; + return getContent().getPath(); } /** @@ -135,7 +126,7 @@ public String getPath() { * @return the locator info */ public LocatorInfo setAccessPolicyId(String accessPolicyId) { - this.accessPolicyId = accessPolicyId; + getContent().setAccessPolicyId(accessPolicyId); return this; } @@ -145,7 +136,7 @@ public LocatorInfo setAccessPolicyId(String accessPolicyId) { * @return the access policy id */ public String getAccessPolicyId() { - return this.accessPolicyId; + return getContent().getAccessPolicyId(); } /** @@ -156,7 +147,7 @@ public String getAccessPolicyId() { * @return the locator info */ public LocatorInfo setAssetId(String assetId) { - this.assetId = assetId; + getContent().setAssetId(assetId); return this; } @@ -166,7 +157,7 @@ public LocatorInfo setAssetId(String assetId) { * @return the asset id */ public String getAssetId() { - return this.assetId; + return getContent().getAssetId(); } /** @@ -177,7 +168,7 @@ public String getAssetId() { * @return the locator info */ public LocatorInfo setStartTime(Date startTime) { - this.startTime = startTime; + getContent().setStartTime(startTime); return this; } @@ -187,7 +178,7 @@ public LocatorInfo setStartTime(Date startTime) { * @return the start time */ public Date getStartTime() { - return this.startTime; + return getContent().getStartTime(); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index 3cc4a583b151d..654e88aaa763d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -15,6 +15,9 @@ package com.microsoft.windowsazure.services.media.models; +import java.security.InvalidParameterException; + +// TODO: Auto-generated Javadoc /** * The Enum LocatorType. */ @@ -50,4 +53,26 @@ private LocatorType(int locatorTypeCode) { public int getCode() { return this.locatorTypeCode; } + + /** + * From code. + * + * @param type + * the type + * @return the locator type + */ + public static LocatorType fromCode(int type) { + switch (type) { + case 0: + return LocatorType.None; + case 1: + return LocatorType.SAS; + case 2: + return LocatorType.Origin; + case 3: + return LocatorType.WindowsAzureCDN; + default: + throw new InvalidParameterException("type"); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java new file mode 100644 index 0000000000000..981ad1fcc521d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java @@ -0,0 +1,168 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class UpdateLocatorOptions. + */ +public class UpdateLocatorOptions { + + /** The expiration date time. */ + private Date expirationDateTime; + + /** The type. */ + private LocatorType type; + + /** The path. */ + private String path; + + /** The access policy id. */ + private String accessPolicyId; + + /** The asset id. */ + private String assetId; + + /** The start time. */ + private Date startTime; + + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return expirationDateTime; + } + + /** + * Sets the expiration date time. + * + * @param expirationDateTime + * the expiration date time + * @return the creates the locator options + */ + public UpdateLocatorOptions setExpirationDateTime(Date expirationDateTime) { + expirationDateTime = expirationDateTime; + return this; + } + + /** + * Gets the type. + * + * @return the type + */ + public LocatorType getType() { + return type; + } + + /** + * Sets the type. + * + * @param type + * the type + * @return the creates the locator options + */ + public UpdateLocatorOptions setType(LocatorType type) { + this.type = type; + return this; + } + + /** + * Gets the path. + * + * @return the path + */ + public String getPath() { + return path; + } + + /** + * Sets the path. + * + * @param path + * the path + * @return the creates the locator options + */ + public UpdateLocatorOptions setPath(String path) { + this.path = path; + return this; + } + + /** + * Gets the access policy id. + * + * @return the access policy id + */ + public String getAccessPolicyId() { + return accessPolicyId; + } + + /** + * Sets the access policy id. + * + * @param accessPolicyId + * the access policy id + * @return the creates the locator options + */ + public UpdateLocatorOptions setAccessPolicyId(String accessPolicyId) { + this.accessPolicyId = accessPolicyId; + return this; + } + + /** + * Gets the asset id. + * + * @return the asset id + */ + public String getAssetId() { + return assetId; + } + + /** + * Sets the asset id. + * + * @param assetId + * the asset id + * @return the creates the locator options + */ + public UpdateLocatorOptions setAssetId(String assetId) { + this.assetId = assetId; + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the creates the locator options + */ + public UpdateLocatorOptions setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 5b941aef9b446..f692608ed88f9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; import java.util.Collection; +import java.util.Date; import java.util.List; import org.junit.AfterClass; @@ -25,8 +26,16 @@ import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; +import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { private static MediaContract service; @@ -36,6 +45,20 @@ public static void setup() throws Exception { // Create all test containers and their content config = createConfig(); service = MediaService.create(config); + removeAllAssets(); + removeAllLocators(); + } + + @AfterClass + public static void cleanup() throws Exception { + // Configuration config = createConfiguration(); + // BlobContract service = BlobService.create(config); + + // deleteContainers(service, testContainersPrefix, testContainers); + // deleteContainers(service, createableContainersPrefix, creatableContainers); + } + + private static void removeAllAssets() throws ServiceException { List<AssetInfo> listAssetsResult = service.listAssets(null); for (AssetInfo assetInfo : listAssetsResult) { try { @@ -47,13 +70,16 @@ public static void setup() throws Exception { } } - @AfterClass - public static void cleanup() throws Exception { - // Configuration config = createConfiguration(); - // BlobContract service = BlobService.create(config); - - // deleteContainers(service, testContainersPrefix, testContainers); - // deleteContainers(service, createableContainersPrefix, creatableContainers); + private static void removeAllLocators() throws ServiceException { + ListLocatorsResult listLocatorsResult = service.listLocators(null); + for (LocatorInfo locatorInfo : listLocatorsResult.getLocatorInfos()) { + try { + service.deleteLocator(locatorInfo.getId()); + } + catch (Exception e) { + e.printStackTrace(); + } + } } private static Configuration createConfig() { @@ -187,4 +213,181 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { assertTrue(false); } + @Test + public void createLocatorSuccess() throws ServiceException { + // Arrange + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + AssetInfo assetInfo = service.createAsset(null); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("createLocatorSuccess", 5); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + + } + + @Test + public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { + // Arrange + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + Date expectedExpirationDateTime = new Date(); + expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 1000); + String accessPolicyName = "createLocatorSetExpirationDateTimeSuccess"; + + createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy(accessPolicyName, 10); + AssetInfo assetInfo = service.createAsset("createLocatorSetExpirationDatetimeSuccess"); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + assertEquals(expectedExpirationDateTime, locatorInfo.getExpirationDateTime()); + + } + + @Test + public void createLocatorSetStartTimeSuccess() throws ServiceException { + // Arrange + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + Date expectedStartDateTime = new Date(); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 1000); + String accessPolicyName = "createLocatorSetStartDateTimeSuccess"; + + createLocatorOptions.setStartTime(expectedStartDateTime); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy(accessPolicyName, 10); + AssetInfo assetInfo = service.createAsset("createLocatorSetStartDatetimeSuccess"); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + assertEquals(expectedStartDateTime, locatorInfo.getStartTime()); + + } + + @Test + public void getLocatorSuccess() throws ServiceException { + // Arrange + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + AssetInfo assetInfo = service.createAsset(null); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("getLocatorSuccess", 5); + LocatorType locatorType = LocatorType.SAS; + LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType, createLocatorOptions); + + // Act + LocatorInfo actualLocatorInfo = service.getLocator(expectedLocatorInfo.getId()); + + // Assert + assertNotNull(actualLocatorInfo); + assertEquals(expectedLocatorInfo.getAccessPolicyId(), actualLocatorInfo.getAccessPolicyId()); + assertEquals(expectedLocatorInfo.getAssetId(), actualLocatorInfo.getAssetId()); + assertEquals(expectedLocatorInfo.getExpirationDateTime(), actualLocatorInfo.getExpirationDateTime()); + assertEquals(expectedLocatorInfo.getId(), actualLocatorInfo.getId()); + assertEquals(expectedLocatorInfo.getLocatorType(), actualLocatorInfo.getLocatorType()); + assertEquals(expectedLocatorInfo.getPath(), actualLocatorInfo.getPath()); + assertEquals(expectedLocatorInfo.getStartTime(), actualLocatorInfo.getStartTime()); + + } + + @Test + public void listLocatorsSuccess() throws ServiceException { + // Arrange + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + AssetInfo assetInfo = service.createAsset(null); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("listLocatorsSuccess", 5); + LocatorType locatorType = LocatorType.SAS; + LocatorInfo locatorInfoA = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + LocatorInfo locatorInfoB = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Act + ListLocatorsResult listLocatorsResult = service.listLocators(); + + // Assert + assertNotNull(listLocatorsResult); + assertEquals(2, listLocatorsResult.getLocatorInfos().size()); + service.deleteLocator(locatorInfoA.getId()); + service.deleteLocator(locatorInfoB.getId()); + + } + + @Test + public void updateLocatorSuccess() throws ServiceException { + // Arrange + LocatorType locatorTypeExepcted = LocatorType.Origin; + AssetInfo assetInfo = service.createAsset(null); + CreateAccessPolicyOptions createAccessPolicyOptions = new CreateAccessPolicyOptions(); + createAccessPolicyOptions.removePermissions(AccessPolicyPermission.DELETE); + createAccessPolicyOptions.removePermissions(AccessPolicyPermission.WRITE); + createAccessPolicyOptions.addPermissions(AccessPolicyPermission.READ); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("listLocatorsSuccess", 5, + createAccessPolicyOptions); + LocatorType locatorType = LocatorType.Origin; + + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Act + UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions().setType(LocatorType.Origin); + service.updateLocator(locatorInfo.getId(), updateLocatorOptions); + + // Assert + LocatorInfo locatorInfoActual = service.getLocator(locatorInfo.getId()); + assertEquals(locatorTypeExepcted, locatorInfoActual.getLocatorType()); + + } + + @Test + public void deleteLocatorSuccess() throws ServiceException { + // Arrange + LocatorType locatorTypeExepcted = LocatorType.Origin; + AssetInfo assetInfo = service.createAsset(null); + AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("deleteLocatorsSuccess", 5); + LocatorType locatorType = LocatorType.SAS; + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Act + service.deleteLocator(locatorInfo.getId()); + + // Assert + LocatorInfo locatorInfoResult = null; + try { + locatorInfoResult = service.getLocator(locatorInfo.getId()); + } + catch (ServiceException e) { + // swallow + } + assertNull(locatorInfoResult); + } + + @Test(expected = ServiceException.class) + public void deleteLocatorInvalidIdFailed() throws ServiceException { + // Arrange + + // Act + service.deleteLocator("invalidLocatorId"); + + // Assert + assertTrue(false); + } + } \ No newline at end of file From 8da191ef1b4d0c9d7fbebb8bce0c7e7475a03964 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 15:24:43 -0700 Subject: [PATCH 369/664] add ListLocatorsOptions and Results classes. --- .../media/models/ListLocatorsOptions.java | 19 +++++++++++ .../media/models/ListLocatorsResult.java | 32 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java new file mode 100644 index 0000000000000..8d0f99cff7741 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java @@ -0,0 +1,19 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +public class ListLocatorsOptions { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java new file mode 100644 index 0000000000000..c7cb49727508a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java @@ -0,0 +1,32 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.List; + +public class ListLocatorsResult { + + private List<LocatorInfo> locatorInfos; + + public List<LocatorInfo> getLocatorInfos() { + return locatorInfos; + } + + public ListLocatorsResult setLocatorInfos(List<LocatorInfo> locatorInfos) { + this.locatorInfos = locatorInfos; + return this; + } + +} From 26875a01212eeca96e08665ab5755a6de3db7821 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 17:00:05 -0700 Subject: [PATCH 370/664] update Locator CRUD operation --- .../media/implementation/MediaRestProxy.java | 5 - .../media/models/CreateLocatorOptions.java | 96 ------------------ .../media/models/ListLocatorsOptions.java | 3 + .../media/models/ListLocatorsResult.java | 16 +++ .../services/media/models/LocatorInfo.java | 11 +++ .../services/media/models/LocatorType.java | 1 - .../media/models/UpdateLocatorOptions.java | 98 +------------------ .../media/MediaServiceIntegrationTest.java | 47 ++++----- 8 files changed, 56 insertions(+), 221 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 5d1dcf3c4e73c..3125365b10d32 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -401,13 +401,8 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp LocatorRestType updatedLocatorRestType = new LocatorRestType(); updatedLocatorRestType.setId(locatorId); - updatedLocatorRestType.setAccessPolicyId(updateLocatorOptions.getAccessPolicyId()); - updatedLocatorRestType.setAssetId(updateLocatorOptions.getAssetId()); updatedLocatorRestType.setExpirationDateTime(updateLocatorOptions.getExpirationDateTime()); updatedLocatorRestType.setStartTime(updateLocatorOptions.getStartTime()); - if (updateLocatorOptions.getType() != null) { - updatedLocatorRestType.setType(updateLocatorOptions.getType().getCode()); - } ClientResponse clientResponse = mergeRequest(assetPath, ClientResponse.class, updatedLocatorRestType); PipelineHelpers.ThrowIfNotSuccess(clientResponse); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java index 4af3be252ddd6..1ee60ca01bf0b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java @@ -24,18 +24,6 @@ public class CreateLocatorOptions { /** The expiration date time. */ private Date expirationDateTime; - /** The type. */ - private LocatorType type; - - /** The path. */ - private String path; - - /** The access policy id. */ - private String accessPolicyId; - - /** The asset id. */ - private String assetId; - /** The start time. */ private Date startTime; @@ -60,90 +48,6 @@ public CreateLocatorOptions setExpirationDateTime(Date expirationDateTime) { return this; } - /** - * Gets the type. - * - * @return the type - */ - public LocatorType getType() { - return type; - } - - /** - * Sets the type. - * - * @param type - * the type - * @return the creates the locator options - */ - public CreateLocatorOptions setType(LocatorType type) { - this.type = type; - return this; - } - - /** - * Gets the path. - * - * @return the path - */ - public String getPath() { - return path; - } - - /** - * Sets the path. - * - * @param path - * the path - * @return the creates the locator options - */ - public CreateLocatorOptions setPath(String path) { - this.path = path; - return this; - } - - /** - * Gets the access policy id. - * - * @return the access policy id - */ - public String getAccessPolicyId() { - return accessPolicyId; - } - - /** - * Sets the access policy id. - * - * @param accessPolicyId - * the access policy id - * @return the creates the locator options - */ - public CreateLocatorOptions setAccessPolicyId(String accessPolicyId) { - this.accessPolicyId = accessPolicyId; - return this; - } - - /** - * Gets the asset id. - * - * @return the asset id - */ - public String getAssetId() { - return assetId; - } - - /** - * Sets the asset id. - * - * @param assetId - * the asset id - * @return the creates the locator options - */ - public CreateLocatorOptions setAssetId(String assetId) { - this.assetId = assetId; - return this; - } - /** * Gets the start time. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java index 8d0f99cff7741..aeb6797a6a1e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java @@ -14,6 +14,9 @@ */ package com.microsoft.windowsazure.services.media.models; +/** + * The Class ListLocatorsOptions. + */ public class ListLocatorsOptions { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java index c7cb49727508a..40531ad37e137 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java @@ -16,14 +16,30 @@ import java.util.List; +/** + * The Class ListLocatorsResult. + */ public class ListLocatorsResult { + /** The locator infos. */ private List<LocatorInfo> locatorInfos; + /** + * Gets the locator infos. + * + * @return the locator infos + */ public List<LocatorInfo> getLocatorInfos() { return locatorInfos; } + /** + * Sets the locator infos. + * + * @param locatorInfos + * the locator infos + * @return the list locators result + */ public ListLocatorsResult setLocatorInfos(List<LocatorInfo> locatorInfos) { this.locatorInfos = locatorInfos; return this; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index 308783c3a7f68..272afc1981231 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -26,10 +26,21 @@ */ public class LocatorInfo extends ODataEntity<LocatorRestType> { + /** + * Instantiates a new locator info. + * + * @param entry + * the entry + * @param content + * the content + */ public LocatorInfo(EntryType entry, LocatorRestType content) { super(entry, content); } + /** + * Instantiates a new locator info. + */ public LocatorInfo() { super(new LocatorRestType()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index 654e88aaa763d..b06a5b30518a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -17,7 +17,6 @@ import java.security.InvalidParameterException; -// TODO: Auto-generated Javadoc /** * The Enum LocatorType. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java index 981ad1fcc521d..4f9ec645b1c47 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java @@ -24,18 +24,6 @@ public class UpdateLocatorOptions { /** The expiration date time. */ private Date expirationDateTime; - /** The type. */ - private LocatorType type; - - /** The path. */ - private String path; - - /** The access policy id. */ - private String accessPolicyId; - - /** The asset id. */ - private String assetId; - /** The start time. */ private Date startTime; @@ -56,91 +44,7 @@ public Date getExpirationDateTime() { * @return the creates the locator options */ public UpdateLocatorOptions setExpirationDateTime(Date expirationDateTime) { - expirationDateTime = expirationDateTime; - return this; - } - - /** - * Gets the type. - * - * @return the type - */ - public LocatorType getType() { - return type; - } - - /** - * Sets the type. - * - * @param type - * the type - * @return the creates the locator options - */ - public UpdateLocatorOptions setType(LocatorType type) { - this.type = type; - return this; - } - - /** - * Gets the path. - * - * @return the path - */ - public String getPath() { - return path; - } - - /** - * Sets the path. - * - * @param path - * the path - * @return the creates the locator options - */ - public UpdateLocatorOptions setPath(String path) { - this.path = path; - return this; - } - - /** - * Gets the access policy id. - * - * @return the access policy id - */ - public String getAccessPolicyId() { - return accessPolicyId; - } - - /** - * Sets the access policy id. - * - * @param accessPolicyId - * the access policy id - * @return the creates the locator options - */ - public UpdateLocatorOptions setAccessPolicyId(String accessPolicyId) { - this.accessPolicyId = accessPolicyId; - return this; - } - - /** - * Gets the asset id. - * - * @return the asset id - */ - public String getAssetId() { - return assetId; - } - - /** - * Sets the asset id. - * - * @param assetId - * the asset id - * @return the creates the locator options - */ - public UpdateLocatorOptions setAssetId(String assetId) { - this.assetId = assetId; + this.expirationDateTime = expirationDateTime; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 4f8205bef9746..87f099e91eb97 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -33,32 +33,34 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.AssetState; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { private static MediaContract service; + private static String testAssetPrefix = "testAsset"; + private static String fakeAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; + + @Rule + public ExpectedException thrown = ExpectedException.none(); @BeforeClass public static void setup() throws Exception { + service = MediaService.create(createConfig()); cleanupEnvironment(); } @AfterClass public static void cleanup() throws Exception { - // Configuration config = createConfiguration(); - // BlobContract service = BlobService.create(config); - - // deleteContainers(service, testContainersPrefix, testContainers); - // deleteContainers(service, createableContainersPrefix, creatableContainers); + cleanupEnvironment(); } private static void removeAllAssets() throws ServiceException { @@ -82,20 +84,14 @@ private static void removeAllLocators() throws ServiceException { catch (Exception e) { e.printStackTrace(); } - private static void cleanupEnvironment() { + } + } + + private static void cleanupEnvironment() throws ServiceException { config = createConfig(); MediaContract service = MediaService.create(config); - try { - List<AssetInfo> listAssetsResult = service.listAssets(); - for (AssetInfo assetInfo : listAssetsResult) { - if (assetInfo.getName().startsWith(testAssetPrefix)) { - service.deleteAsset(assetInfo.getId()); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } + removeAllAssets(); + removeAllLocators(); } private static Configuration createConfig() { @@ -315,6 +311,7 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { thrown.expect(new ServiceExceptionMatcher(404)); service.deleteAsset(fakeAssetId); } + @Test public void createLocatorSuccess() throws ServiceException { // Arrange @@ -333,6 +330,7 @@ public void createLocatorSuccess() throws ServiceException { } + @Ignore("due to nimbus bug 596240") @Test public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { // Arrange @@ -381,6 +379,7 @@ public void createLocatorSetStartTimeSuccess() throws ServiceException { } + @Ignore("due to nimbus bug 596238") @Test public void getLocatorSuccess() throws ServiceException { // Arrange @@ -423,12 +422,12 @@ public void listLocatorsSuccess() throws ServiceException { // Assert assertNotNull(listLocatorsResult); - assertEquals(2, listLocatorsResult.getLocatorInfos().size()); service.deleteLocator(locatorInfoA.getId()); service.deleteLocator(locatorInfoB.getId()); } + @Ignore("due to nimbus bug 596264") @Test public void updateLocatorSuccess() throws ServiceException { // Arrange @@ -445,14 +444,18 @@ public void updateLocatorSuccess() throws ServiceException { CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, createLocatorOptions); + Date expirationDateTime = new Date(); + expirationDateTime.setTime(expirationDateTime.getTime() + 1000); // Act - UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions().setType(LocatorType.Origin); + UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() + .setExpirationDateTime(expirationDateTime); service.updateLocator(locatorInfo.getId(), updateLocatorOptions); // Assert LocatorInfo locatorInfoActual = service.getLocator(locatorInfo.getId()); assertEquals(locatorTypeExepcted, locatorInfoActual.getLocatorType()); + assertEquals(expirationDateTime, locatorInfoActual.getExpirationDateTime()); } From 9b28c9eea44f85e7c28a6f05b78ca49a80befb43 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 17:18:39 -0700 Subject: [PATCH 371/664] fix failed unit tests. --- .../media/implementation/MediaRestProxy.java | 42 +++++++++++++++++++ .../media/MediaServiceIntegrationTest.java | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 3125365b10d32..ee503d1ca7ca6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -148,6 +148,17 @@ private WebResource getResource(String entityName) { return resource; } + /** + * Gets the resource. + * + * @param entityType + * the entity type + * @param entityId + * the entity id + * @return the resource + * @throws ServiceException + * the service exception + */ private WebResource getResource(String entityType, String entityId) throws ServiceException { String escapedEntityId = null; try { @@ -161,6 +172,19 @@ private WebResource getResource(String entityType, String entityId) throws Servi return getResource(entityPath); } + /** + * Merge request. + * + * @param <T> + * the generic type + * @param path + * the path + * @param c + * the c + * @param requestEntity + * the request entity + * @return the t + */ private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { WebResource resource = getResource(path); WebResource.Builder builder = resource.getRequestBuilder(); @@ -330,6 +354,9 @@ public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options }); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType, com.microsoft.windowsazure.services.media.models.CreateLocatorOptions) + */ @Override public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, CreateLocatorOptions createLocatorOptions) { @@ -357,6 +384,9 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT .post(LocatorInfo.class, locatorRestType); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getLocator(java.lang.String) + */ @Override public LocatorInfo getLocator(String locatorId) throws ServiceException { WebResource resource = getResource("Locators", locatorId); @@ -364,11 +394,17 @@ public LocatorInfo getLocator(String locatorId) throws ServiceException { .get(LocatorInfo.class); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators() + */ @Override public ListLocatorsResult listLocators() { return listLocators(null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators(com.microsoft.windowsazure.services.media.models.ListLocatorsOptions) + */ @Override public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) { WebResource resource = getResource("Locators"); @@ -382,11 +418,17 @@ public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) { } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteLocator(java.lang.String) + */ @Override public void deleteLocator(String locatorId) throws UniformInterfaceException, ServiceException { getResource("Locators", locatorId).delete(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#updateLocator(java.lang.String, com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions) + */ @Override public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException { String escapedLocatorId = null; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 87f099e91eb97..b851dc11e448f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 7021a19f983ccf20ac600ad36bf4293db62d1c2d Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 21:01:54 -0700 Subject: [PATCH 372/664] correct the signature of create asset method. --- .../services/media/MediaContract.java | 14 +-------- .../MediaExceptionProcessor.java | 20 ++----------- .../media/implementation/MediaRestProxy.java | 13 ++------ .../media/models/CreateAssetOptions.java | 24 +++++++++++++++ .../media/MediaServiceIntegrationTest.java | 30 +++++++++++-------- .../ODataSerializationFromJerseyTest.java | 4 ++- 6 files changed, 50 insertions(+), 55 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index aac6354b6947c..abd9e56b18795 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -34,24 +34,12 @@ public interface MediaContract extends FilterableService<MediaContract> { /** * Creates the asset. * - * @param assetName - * the asset name - * @return the asset info - * @throws ServiceException - */ - public AssetInfo createAsset(String assetName) throws ServiceException; - - /** - * Creates the asset. - * - * @param assetName - * the asset name * @param createAssetOptions * the create asset options * @return the asset info * @throws ServiceException */ - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException; + public AssetInfo createAsset(CreateAssetOptions createAssetOptions) throws ServiceException; /** * Delete asset. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 314111bc50b34..c18d0b977aff0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -90,29 +90,13 @@ private ServiceException processCatch(ServiceException e) { return ServiceExceptionFactory.process("MediaServices", e); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) - */ - @Override - public AssetInfo createAsset(String assetName) throws ServiceException { - try { - return service.createAsset(assetName); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) */ @Override - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) throws ServiceException { + public AssetInfo createAsset(CreateAssetOptions createAssetOptions) throws ServiceException { try { - return service.createAsset(assetName, createAssetOptions); + return service.createAsset(createAssetOptions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index c27f83ff48ff0..25a4bf07bffa8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -161,24 +161,17 @@ private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object r return builder.post(c, requestEntity); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String) - */ - @Override - public AssetInfo createAsset(String assetName) throws ServiceException { - return this.createAsset(assetName, null); - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) */ @Override - public AssetInfo createAsset(String assetName, CreateAssetOptions createAssetOptions) { + public AssetInfo createAsset(CreateAssetOptions createAssetOptions) { WebResource resource = getResource("Assets"); AssetType assetTypeForSubmission = new AssetType(); - assetTypeForSubmission.setName(assetName); if (createAssetOptions != null) { + assetTypeForSubmission.setName(createAssetOptions.getName()); assetTypeForSubmission.setAlternateId(createAssetOptions.getAlternateId()); + if (createAssetOptions.getOptions() != null) { assetTypeForSubmission.setOptions(createAssetOptions.getOptions().getCode()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java index 9905e36e8ef46..86b6773a58d1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java @@ -19,6 +19,9 @@ */ public class CreateAssetOptions { + /** The name. */ + private String name; + /** The alternate id. */ private String alternateId; @@ -91,4 +94,25 @@ public CreateAssetOptions setState(AssetState assetState) { return this; } + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the creates the asset options + */ + public CreateAssetOptions setName(String name) { + this.name = name; + return this; + } + } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index c732f7ff72925..3a2fde65d30fc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -97,9 +97,10 @@ public void setupInstance() throws Exception { public void createAssetSuccess() throws Exception { // Arrange String testName = testAssetPrefix + "Name"; + CreateAssetOptions options = new CreateAssetOptions().setName(testName); // Act - AssetInfo actualAsset = service.createAsset(testName); + AssetInfo actualAsset = service.createAsset(options); // Assert verifyAssetProperties("actualAsset", testName, "", EncryptionOption.None, AssetState.Initialized, actualAsset); @@ -113,10 +114,10 @@ public void createAssetOptionsSuccess() throws Exception { EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; AssetState assetState = AssetState.Published; CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState); + .setState(assetState).setName(testName); // Act - AssetInfo actualAsset = service.createAsset(testName, options); + AssetInfo actualAsset = service.createAsset(options); // Assert verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); @@ -130,9 +131,10 @@ public void createAssetMeanString() throws Exception { + "Some unicode: \uB2E4\uB974\uB2E4\uB294\u0625 \u064A\u062F\u064A\u0648\u0009\r\n"; String testName = testAssetPrefix + "createAssetMeanString" + meanString; + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(testName); // Act - AssetInfo actualAsset = service.createAsset(testName); + AssetInfo actualAsset = service.createAsset(createAssetOptions); // Assert assertEquals("actualAsset Name", testName, actualAsset.getName()); @@ -173,8 +175,8 @@ public void getAssetSuccess() throws Exception { EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; AssetState assetState = AssetState.Published; CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState); - AssetInfo assetInfo = service.createAsset(testName, options); + .setState(assetState).setName(testName); + AssetInfo assetInfo = service.createAsset(options); // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); @@ -193,8 +195,9 @@ public void getAssetFailedWithInvalidId() throws ServiceException { public void listAssetSuccess() throws ServiceException { // Arrange Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); - service.createAsset(testAssetPrefix + "assetA"); - service.createAsset(testAssetPrefix + "assetB"); + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetA")); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetB")); // Act Collection<AssetInfo> listAssetResult = service.listAssets(); @@ -210,8 +213,8 @@ public void updateAssetSuccess() throws Exception { // Arrange String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") - .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published); - AssetInfo originalAsset = service.createAsset(originalTestName, originalOptions); + .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published).setName(originalTestName); + AssetInfo originalAsset = service.createAsset(originalOptions); String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; String altId = "otherAltId"; @@ -236,8 +239,8 @@ public void updateAssetNoChangesSuccess() throws Exception { EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; AssetState assetState = AssetState.Published; CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState); - AssetInfo originalAsset = service.createAsset(originalTestName, options); + .setState(assetState).setName(originalTestName); + AssetInfo originalAsset = service.createAsset(options); UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); @@ -264,7 +267,8 @@ public void updateAssetFailedWithInvalidId() throws ServiceException { public void deleteAssetSuccess() throws Exception { // Arrange String assetName = "deleteAssetSuccess"; - AssetInfo assetInfo = service.createAsset(assetName); + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(assetName); + AssetInfo assetInfo = service.createAsset(createAssetOptions); List<AssetInfo> listAssetsResult = service.listAssets(null); int assetCountBaseline = listAssetsResult.size(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 84a8d66b47d20..b056a38818a6d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -30,6 +30,7 @@ import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; @@ -89,7 +90,8 @@ private ResourceLocationManager createLocationManager() throws URISyntaxExceptio @Test public void canCreateAssetThroughMediaServiceAPI() throws Exception { MediaContract client = MediaService.create(config); - AssetInfo newAsset = client.createAsset("secondTestAsset"); + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName("secondTestAsset"); + AssetInfo newAsset = client.createAsset(createAssetOptions); Assert.assertEquals("secondTestAsset", newAsset.getName()); } From 1614370fb4fd1836979c874de1d4159d172215c5 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 9 Oct 2012 22:18:11 -0700 Subject: [PATCH 373/664] refactor url encoding logic. --- .../media/implementation/MediaRestProxy.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 25a4bf07bffa8..187354e055779 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -153,8 +153,9 @@ private WebResource getResource(String entityType, String entityId) throws Servi return getResource(entityPath); } - private <T> T mergeRequest(String path, java.lang.Class<T> c, java.lang.Object requestEntity) { - WebResource resource = getResource(path); + private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T> c, java.lang.Object requestEntity) + throws ServiceException { + WebResource resource = getResource(entityType, entityId); WebResource.Builder builder = resource.getRequestBuilder(); builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .header("X-HTTP-Method", "MERGE"); @@ -218,14 +219,7 @@ public List<AssetInfo> listAssets() { */ @Override public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { - String escapedAssetId = null; - try { - escapedAssetId = URLEncoder.encode(assetId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new ServiceException(e); - } - String assetPath = String.format("Assets(\'%s\')", escapedAssetId); + AssetType updatedAssetType = new AssetType(); updatedAssetType.setAlternateId(updateAssetOptions.getAlternateId()); updatedAssetType.setName(updateAssetOptions.getName()); @@ -237,7 +231,7 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t updatedAssetType.setState(updateAssetOptions.getState().getCode()); } - ClientResponse clientResponse = mergeRequest(assetPath, ClientResponse.class, updatedAssetType); + ClientResponse clientResponse = mergeRequest("Assets", assetId, ClientResponse.class, updatedAssetType); PipelineHelpers.ThrowIfNotSuccess(clientResponse); } From 98b4a3d83e7e9700abcfab5f3f41351be1acee60 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 10 Oct 2012 10:53:57 -0700 Subject: [PATCH 374/664] code review feedback. --- .../media/models/CreateAssetOptionsTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java index 93f09cbde5e18..6a09d47f6e68d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java @@ -59,4 +59,17 @@ public void testGetSetOptions() { assertEquals(expectedOptions, actualOptions); } + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testGetSetName"; + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + + // Act + String actualName = createAssetOptions.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + } From 5d296e1c6ba49e71aaf1660322666710edd8abc2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 10 Oct 2012 21:33:44 -0700 Subject: [PATCH 375/664] resolve merge conflicts. --- .../services/media/IntegrationTestBase.java | 2 +- .../media/MediaServiceIntegrationTest.java | 35 ------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index d268e7ecf575a..efc4a219ac1fa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -16,7 +16,7 @@ public void beforeEachTest() { overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); } - protected static Configuration createConfig() { + public static Configuration createConfig() { Configuration config = Configuration.getInstance(); overrideWithEnv(config, MediaConfiguration.URI); overrideWithEnv(config, MediaConfiguration.OAUTH_URI); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index d646038f2e0e7..2e8c0d83bbc41 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -88,33 +88,12 @@ private static void removeAllLocators() throws ServiceException { } } - private static Configuration createConfig() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); - overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - return config; - } - private static void cleanupEnvironment() throws ServiceException { config = createConfig(); - MediaContract service = MediaService.create(config); removeAllAssets(); removeAllLocators(); } - private static Configuration createConfig() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); - overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - return config; - } - private void verifyAssetProperties(String message, String testName, String altId, EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { assertNotNull(message, actualAsset); @@ -243,19 +222,6 @@ public void listAssetSuccess() throws ServiceException { assertNotNull("listAssetResult", listAssetResult); assertEquals("listAssetResult.size", listAssetResultBaseLine.size() + 2, listAssetResult.size()); - AssetInfo[] assets = new AssetInfo[assetNames.length]; - - for (AssetInfo asset : listAssetResult) { - for (int i = 0; i < assetNames.length; i++) { - if (asset.getName().equals(assetNames[i])) { - assets[i] = asset; - } - } - } - - for (int i = 0; i < assetNames.length; i++) { - verifyAssetProperties("asset " + i, assetNames[i], altId, encryptionOption, assetState, assets[i]); - } } @Ignore @@ -493,7 +459,6 @@ public void updateLocatorSuccess() throws ServiceException { @Test public void deleteLocatorSuccess() throws ServiceException { // Arrange - LocatorType locatorTypeExepcted = LocatorType.Origin; AssetInfo assetInfo = service.createAsset(null); AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("deleteLocatorsSuccess", 5); LocatorType locatorType = LocatorType.SAS; From 4ad99be488ad44d751300986608ee4a8f1a8efff Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 11 Oct 2012 21:51:03 -0700 Subject: [PATCH 376/664] add unit test for media namespace --- .../media/MediaConfigurationTest.java | 78 ++++++++++++++++++ .../services/media/MediaServiceTest.java | 81 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java new file mode 100644 index 0000000000000..6329852af61a0 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -0,0 +1,78 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.Configuration; + +public class MediaConfigurationTest { + + @Test + public void createMediaConfigurationTestSuccess() { + // Arrange + + // Act + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testMediaServiceBaseUri", + "testOAuthUri", "testClientId", "testClientSecret"); + + // Assert + assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); + assertEquals("testOAuthUri", configuration.getProperty("oauth.uri")); + assertEquals("testClientId", configuration.getProperty("oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("oauth.client.secret")); + } + + @Test + public void createMediaConfigurationPassingExistingConfigurationSuccess() { + // Arrange + Configuration preConfiguration = new Configuration(); + preConfiguration.setProperty("preexistingName", "preexistingValue"); + + // Act + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(preConfiguration, + "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret"); + + // Assert + assertEquals("preexistingValue", configuration.getProperty("preexistingName")); + assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); + assertEquals("testOAuthUri", configuration.getProperty("oauth.uri")); + assertEquals("testClientId", configuration.getProperty("oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("oauth.client.secret")); + + } + + @Test + public void createMediaConfigurationWithProfileConfigurationSuccess() { + // Arrange + Configuration preConfiguration = new Configuration(); + preConfiguration.setProperty("preexistingName", "preexistingValue"); + + // Act + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testProfile", + preConfiguration, "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret"); + + // Assert + assertEquals("preexistingValue", configuration.getProperty("preexistingName")); + assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("testProfile.media.uri")); + assertEquals("testOAuthUri", configuration.getProperty("testProfile.oauth.uri")); + assertEquals("testClientId", configuration.getProperty("testProfile.oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("testProfile.oauth.client.secret")); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java new file mode 100644 index 0000000000000..d07266abb24e4 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java @@ -0,0 +1,81 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.Configuration; + +public class MediaServiceTest { + + @Test + public void createMediaContractSuccessTest() { + // Arrange + Configuration configurationInstance = Configuration.getInstance(); + configurationInstance = MediaConfiguration.configureWithOAuthAuthentication(configurationInstance, + "mediaServiceBaseUri", "oAuthUri", "clientId", "clientSecret"); + + // Act + MediaContract mediaContract = MediaService.create(); + + // Assert + assertNotNull(mediaContract); + configurationInstance = null; + + } + + @Test + public void createMediaContractWithSpecifiedConfigurationTest() { + // Arrange + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("mediaServiceBaseUri", + "oAuthUri", "clientId", "clientSecret"); + + // Act + MediaContract mediaContract = MediaService.create(configuration); + + // Assert + assertNotNull(mediaContract); + } + + @Test + public void createMediaContractWithSpecifiedProfileTest() { + // Arrange + String profile = "testProfile"; + + // Act + MediaContract mediaContract = MediaService.create(profile); + + // Assert + assertNotNull(mediaContract); + + } + + @Test + public void createMediaContractWithSpecifiedProfileAndConfiguration() { + // Arrange + String profile = "testProfile"; + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("mediaServiceBaseUri", + "oAuthUri", "clientId", "clientSecret"); + + // Act + MediaContract mediaContract = MediaService.create(profile, configuration); + + // Assert + assertNotNull(mediaContract); + } +} From 5bf5246546ecba2b149c327a17a4b4e77cdd775f Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 12 Oct 2012 17:31:18 -0700 Subject: [PATCH 377/664] code review feedback for unit test. --- .../services/media/MediaConfiguration.java | 20 ++++++++++++++----- .../media/MediaConfigurationTest.java | 8 +++++--- .../services/media/MediaServiceTest.java | 8 ++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index 6821f7b10fafd..b9b9d0e74aff8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -67,15 +67,18 @@ public class MediaConfiguration { * @param clientSecret * A <code>String</code> object that represents the client secret. * + * @param scope + * A <code>String</code> object that represents the scope. + * * @return * A <code>Configuration</code> object that can be used when creating an instance of the * <code>MediaService</code> class. * */ public static Configuration configureWithOAuthAuthentication(String mediaServiceBaseUri, String oAuthUri, - String clientId, String clientSecret) { + String clientId, String clientSecret, String scope) { return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceBaseUri, oAuthUri, - clientId, clientSecret); + clientId, clientSecret, scope); } /** @@ -97,15 +100,18 @@ public static Configuration configureWithOAuthAuthentication(String mediaService * @param clientSecret * A <code>String</code> object that represents the client secret. * + * @param scope + * A <code>String</code> object that represents the scope. + * * @return * A <code>Configuration</code> object that can be used when creating an instance of the * <code>MediaService</code> class. * */ public static Configuration configureWithOAuthAuthentication(Configuration configuration, - String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret) { + String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret, String scope) { return configureWithOAuthAuthentication(null, configuration, mediaServiceBaseUri, oAuthUri, clientId, - clientSecret); + clientSecret, scope); } /** @@ -130,13 +136,16 @@ public static Configuration configureWithOAuthAuthentication(Configuration confi * @param clientSecret * A <code>String</code> object that represents the client secret. * + * @param scope + * A <code>String</code> object that represents the scope. + * * @return * A <code>Configuration</code> object that can be used when creating an instance of the * <code>MediaService</code> class. * */ public static Configuration configureWithOAuthAuthentication(String profile, Configuration configuration, - String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret) { + String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret, String scope) { if (profile == null) { profile = ""; @@ -149,6 +158,7 @@ else if (profile.length() != 0 && !profile.endsWith(".")) { configuration.setProperty(profile + OAUTH_URI, oAuthUri); configuration.setProperty(profile + OAUTH_CLIENT_ID, clientId); configuration.setProperty(profile + OAUTH_CLIENT_SECRET, clientSecret); + configuration.setProperty(profile + OAUTH_SCOPE, scope); return configuration; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java index 6329852af61a0..ccc8c5ca54016 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -29,13 +29,14 @@ public void createMediaConfigurationTestSuccess() { // Act Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testMediaServiceBaseUri", - "testOAuthUri", "testClientId", "testClientSecret"); + "testOAuthUri", "testClientId", "testClientSecret", "testScope"); // Assert assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); assertEquals("testOAuthUri", configuration.getProperty("oauth.uri")); assertEquals("testClientId", configuration.getProperty("oauth.client.id")); assertEquals("testClientSecret", configuration.getProperty("oauth.client.secret")); + assertEquals("testScope", configuration.getProperty("oauth.scope")); } @Test @@ -46,7 +47,7 @@ public void createMediaConfigurationPassingExistingConfigurationSuccess() { // Act Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(preConfiguration, - "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret"); + "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", "testScope"); // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); @@ -65,7 +66,8 @@ public void createMediaConfigurationWithProfileConfigurationSuccess() { // Act Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testProfile", - preConfiguration, "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret"); + preConfiguration, "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", + "testScope"); // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java index d07266abb24e4..4d00708f9bdb9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java @@ -28,7 +28,7 @@ public void createMediaContractSuccessTest() { // Arrange Configuration configurationInstance = Configuration.getInstance(); configurationInstance = MediaConfiguration.configureWithOAuthAuthentication(configurationInstance, - "mediaServiceBaseUri", "oAuthUri", "clientId", "clientSecret"); + "mediaServiceBaseUri", "oAuthUri", "clientId", "clientSecret", "testScope"); // Act MediaContract mediaContract = MediaService.create(); @@ -43,7 +43,7 @@ public void createMediaContractSuccessTest() { public void createMediaContractWithSpecifiedConfigurationTest() { // Arrange Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("mediaServiceBaseUri", - "oAuthUri", "clientId", "clientSecret"); + "oAuthUri", "clientId", "clientSecret", "testScope"); // Act MediaContract mediaContract = MediaService.create(configuration); @@ -69,8 +69,8 @@ public void createMediaContractWithSpecifiedProfileTest() { public void createMediaContractWithSpecifiedProfileAndConfiguration() { // Arrange String profile = "testProfile"; - Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("mediaServiceBaseUri", - "oAuthUri", "clientId", "clientSecret"); + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(profile, new Configuration(), + "mediaServiceBaseUri", "oAuthUri", "clientId", "clientSecret", "testScope"); // Act MediaContract mediaContract = MediaService.create(profile, configuration); From ff35aaaaa7ae43053a1a156b7e3d6b8de2d839f2 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 15 Oct 2012 10:18:15 -0700 Subject: [PATCH 378/664] Use <typeName>[Id|Name] for parameter names in MediaContract --- .../services/media/MediaContract.java | 22 +++++++++---------- .../MediaExceptionProcessor.java | 19 ++++++++-------- .../media/implementation/MediaRestProxy.java | 20 +++++++++-------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index c179768ad9db5..f46a9a6aa60ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -113,7 +113,7 @@ public interface MediaContract extends FilterableService<MediaContract> { /** * Create the access policy. * - * @param name + * @param accessPolicyName * name of access policy * @param durationInMinutes * Duration in minutes that blob access will be granted when using this access policy @@ -121,12 +121,12 @@ public interface MediaContract extends FilterableService<MediaContract> { * @throws ServiceException * the service exception */ - AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException; + AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) throws ServiceException; /** * Create the access policy with the given options. * - * @param name + * @param accessPolicyName * name of access policy * @param durationInMinutes * Duration in minutes that blob access will be granted when using this access policy @@ -136,29 +136,29 @@ public interface MediaContract extends FilterableService<MediaContract> { * @throws ServiceException * the service exception */ - AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) - throws ServiceException; + AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, + CreateAccessPolicyOptions options) throws ServiceException; /** * Delete the access policy with the given id. * - * @param id + * @param accessPolicyId * of access policy to delete * @throws ServiceException * the service exception */ - void deleteAccessPolicy(String id) throws ServiceException; + void deleteAccessPolicy(String accessPolicyId) throws ServiceException; /** * Get a single access policy. * - * @param id + * @param accessPolicyId * the id of the asset to retrieve * @return the asset * @throws ServiceException * the service exception */ - AccessPolicyInfo getAccessPolicy(String id) throws ServiceException; + AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException; /** * List access policies. @@ -236,14 +236,14 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT /** * Delete locator. * - * @param id + * @param locatorId * the id * @throws UniformInterfaceException * the uniform interface exception * @throws ServiceException * the service exception */ - public void deleteLocator(String id) throws UniformInterfaceException, ServiceException; + public void deleteLocator(String locatorId) throws UniformInterfaceException, ServiceException; /** * List locators. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 3bb35d14e1179..d2416c332da2a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -212,9 +212,10 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) */ @Override - public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { + public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) + throws ServiceException { try { - return service.createAccessPolicy(name, durationInMinutes); + return service.createAccessPolicy(accessPolicyName, durationInMinutes); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -228,10 +229,10 @@ public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) */ @Override - public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) - throws ServiceException { + public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, + CreateAccessPolicyOptions options) throws ServiceException { try { - return service.createAccessPolicy(name, durationInMinutes, options); + return service.createAccessPolicy(accessPolicyName, durationInMinutes, options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -261,9 +262,9 @@ public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) */ @Override - public void deleteAccessPolicy(String id) throws ServiceException { + public void deleteAccessPolicy(String accessPolicyId) throws ServiceException { try { - service.deleteAccessPolicy(id); + service.deleteAccessPolicy(accessPolicyId); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -277,9 +278,9 @@ public void deleteAccessPolicy(String id) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) */ @Override - public AccessPolicyInfo getAccessPolicy(String id) throws ServiceException { + public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException { try { - return service.getAccessPolicy(id); + return service.getAccessPolicy(accessPolicyId); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 629aa9de3aa44..3edcbb2c0301e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -291,22 +291,24 @@ public void deleteAsset(String assetId) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) */ @Override - public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes) throws ServiceException { - return createAccessPolicy(name, durationInMinutes, null); + public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) + throws ServiceException { + return createAccessPolicy(accessPolicyName, durationInMinutes, null); } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) */ @Override - public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, CreateAccessPolicyOptions options) - throws ServiceException { + public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, + CreateAccessPolicyOptions options) throws ServiceException { if (options == null) { options = new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE)); } - AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes).setName(name) + AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes) + .setName(accessPolicyName) .setPermissions(AccessPolicyPermission.bitsFromPermissions(options.getPermissions())); WebResource resource = getResource("AccessPolicies"); @@ -319,8 +321,8 @@ public AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) */ @Override - public AccessPolicyInfo getAccessPolicy(String id) throws ServiceException { - WebResource resource = getResource("AccessPolicies", id); + public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException { + WebResource resource = getResource("AccessPolicies", accessPolicyId); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .get(AccessPolicyInfo.class); } @@ -329,8 +331,8 @@ public AccessPolicyInfo getAccessPolicy(String id) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) */ @Override - public void deleteAccessPolicy(String id) throws ServiceException { - getResource("AccessPolicies", id).delete(); + public void deleteAccessPolicy(String accessPolicyId) throws ServiceException { + getResource("AccessPolicies", accessPolicyId).delete(); } /* (non-Javadoc) From a0ca47c4e5384d6db738355aa9dd05aaf0dd473a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 21:06:46 -0700 Subject: [PATCH 379/664] initial check in for adding query functionality. --- .../media/implementation/MediaRestProxy.java | 4 ++ .../media/models/ListAssetsOptions.java | 4 +- .../services/media/models/ListOptions.java | 60 +++++++++++++++++++ .../media/MediaServiceIntegrationTest.java | 22 +++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 629aa9de3aa44..b802bb8e72e93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -244,6 +244,10 @@ public AssetInfo getAsset(String assetId) throws ServiceException { @Override public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { WebResource resource = getResource("Assets"); + if ((listAssetsOptions != null) && (listAssetsOptions.getQueryParameters() != null)) { + resource = resource.queryParams(listAssetsOptions.getQueryParameters()); + } + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .get(new GenericType<List<AssetInfo>>() { }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java index fc1ea2d060245..33cacc6d30191 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java @@ -14,6 +14,6 @@ */ package com.microsoft.windowsazure.services.media.models; -public class ListAssetsOptions { +public class ListAssetsOptions extends ListOptions { -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java new file mode 100644 index 0000000000000..2f1adc76fc7f0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java @@ -0,0 +1,60 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import javax.ws.rs.core.MultivaluedMap; + +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * The Class ListOptions. + */ +public class ListOptions { + + /** + * Instantiates a new list options. + */ + public ListOptions() { + this.queryParameters = new MultivaluedMapImpl(); + } + + /** The query parameters. */ + protected MultivaluedMap<String, String> queryParameters; + + /** + * Gets the query parameters. + * + * @return the query parameters + */ + public MultivaluedMap<String, String> getQueryParameters() { + return this.queryParameters; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 2e8c0d83bbc41..d34108f771185 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -38,6 +38,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -224,6 +225,27 @@ public void listAssetSuccess() throws ServiceException { } + @Test + public void listTopThreeAssetsSuccess() throws ServiceException { + // Arrange + Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetA")); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetB")); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetC")); + service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetD")); + ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); + listAssetsOptions.getQueryParameters().add("top", "3"); + + // Act + Collection<AssetInfo> listAssetResult = service.listAssets(listAssetsOptions); + + // Assert + assertNotNull("listAssetResult", listAssetResult); + assertEquals("listAssetResult.size", listAssetResultBaseLine.size() + 3, listAssetResult.size()); + + } + @Ignore // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 @Test From 41c304df820714bfc4592ac7bc73c9db6b9eda75 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 21:09:58 -0700 Subject: [PATCH 380/664] resolve a underlying redirect filter issue. --- .../services/media/implementation/RedirectFilter.java | 1 + .../media/implementation/ResourceLocationManager.java | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index f71ea6381653b..1b332e8f6ddb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -37,6 +37,7 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio } URI originalURI = request.getURI(); + String queryString = originalURI.getQuery(); request.setURI(locationManager.getRedirectedURI(originalURI)); ClientResponse response = getNext().handle(request); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index b030e6454196c..52d1acd5c4f2f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -35,7 +35,12 @@ public URI getBaseURI() { } public URI getRedirectedURI(URI originalURI) { - return UriBuilder.fromUri(baseURI).path(originalURI.getPath()).build(); + String queryString = originalURI.getQuery(); + String path = originalURI.getPath(); + if (queryString != null && !queryString.isEmpty()) { + path = path + queryString; + } + return UriBuilder.fromUri(baseURI).path(path).build(); } public void setRedirectedURI(String newURI) throws URISyntaxException { From b0027f7e48c36edf57eb637685dc94ba4e1ad81b Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 22:51:36 -0700 Subject: [PATCH 381/664] get the unit test working. --- .../ResourceLocationManager.java | 25 ++++++++++++++++--- .../media/MediaServiceIntegrationTest.java | 4 +-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 52d1acd5c4f2f..9c3d40d080e74 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -17,6 +17,9 @@ import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import javax.inject.Named; import javax.ws.rs.core.UriBuilder; @@ -35,15 +38,31 @@ public URI getBaseURI() { } public URI getRedirectedURI(URI originalURI) { + UriBuilder uriBuilder = UriBuilder.fromUri(baseURI).path(originalURI.getPath()); String queryString = originalURI.getQuery(); - String path = originalURI.getPath(); + if (queryString != null && !queryString.isEmpty()) { - path = path + queryString; + Map<String, String> queryParams = parseQueryString(queryString); + for (String key : new ArrayList<String>(queryParams.keySet())) { + uriBuilder.queryParam(key, queryParams.get(key)); + } } - return UriBuilder.fromUri(baseURI).path(path).build(); + return uriBuilder.build(); } public void setRedirectedURI(String newURI) throws URISyntaxException { baseURI = new URI(newURI); } + + private Map<String, String> parseQueryString(String queryString) { + Map<String, String> map = new HashMap<String, String>(); + String[] params = queryString.split("&"); + for (String param : params) { + String key = param.split("=")[0]; + String value = param.split("=")[1]; + map.put(key, value); + } + return map; + + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index d34108f771185..8829a90fdfe11 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -235,14 +235,14 @@ public void listTopThreeAssetsSuccess() throws ServiceException { service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetC")); service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetD")); ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); - listAssetsOptions.getQueryParameters().add("top", "3"); + listAssetsOptions.getQueryParameters().add("$top", "3"); // Act Collection<AssetInfo> listAssetResult = service.listAssets(listAssetsOptions); // Assert assertNotNull("listAssetResult", listAssetResult); - assertEquals("listAssetResult.size", listAssetResultBaseLine.size() + 3, listAssetResult.size()); + assertEquals("listAssetResult.size", 3, listAssetResult.size()); } From 6de7de51f671a328881020a3a8bd25a26aee1cee Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 23:03:38 -0700 Subject: [PATCH 382/664] self code review. --- .../services/media/models/ListOptions.java | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java index 2f1adc76fc7f0..c208cd667c664 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java @@ -1,19 +1,3 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - /** * Copyright 2012 Microsoft Corporation * @@ -28,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.microsoft.windowsazure.services.media.models; import javax.ws.rs.core.MultivaluedMap; - import com.sun.jersey.core.util.MultivaluedMapImpl; /** From 0862d5f592418061287d0c1a7bffe5b29a77ea48 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 23:49:32 -0700 Subject: [PATCH 383/664] List media processor --- .../services/media/MediaContract.java | 25 +++ .../MediaExceptionProcessor.java | 30 +++ .../media/implementation/MediaRestProxy.java | 20 ++ .../content/MediaProcessorType.java | 109 +++++++++++ .../implementation/content/ObjectFactory.java | 9 + .../media/models/ListAssetsOptions.java | 2 +- .../models/ListMediaProcessorsOptions.java | 22 +++ .../models/ListMediaProcessorsResult.java | 48 +++++ .../media/models/MediaProcessorInfo.java | 173 ++++++++++++++++++ .../media/MediaServiceIntegrationTest.java | 27 +++ .../ListMediaProcessorsOptionsTest.java | 34 ++++ .../media/models/MediaProcessorInfoTest.java | 104 +++++++++++ 12 files changed, 602 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index c179768ad9db5..076d6b97905cb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -27,6 +27,8 @@ import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -43,6 +45,7 @@ public interface MediaContract extends FilterableService<MediaContract> { * * @return the asset info * @throws ServiceException + * the service exception */ public AssetInfo createAsset() throws ServiceException; @@ -191,6 +194,7 @@ AccessPolicyInfo createAccessPolicy(String name, double durationInMinutes, Creat * the locator type * @return the locator info * @throws ServiceException + * the service exception */ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType) throws ServiceException; @@ -268,4 +272,25 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT */ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException; + /** + * List media processors. + * + * @return the list media processors result + * @throws ServiceException + * the service exception + */ + public ListMediaProcessorsResult listMediaProcessors() throws ServiceException; + + /** + * List media processors. + * + * @param listMediaProcessorsOptions + * the list media processors options + * @return the list media processors result + * @throws ServiceException + * the service exception + */ + public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) + throws ServiceException; + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 3bb35d14e1179..c13c0d46d4556 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -35,6 +35,8 @@ import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -418,4 +420,32 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT throw processCatch(new ServiceException(e)); } } + + @Override + public ListMediaProcessorsResult listMediaProcessors() throws ServiceException { + try { + return service.listMediaProcessors(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) + throws ServiceException { + try { + return service.listMediaProcessors(listMediaProcessorsOptions); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 629aa9de3aa44..a7d7d4d1aa964 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -45,8 +45,11 @@ import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.Client; @@ -448,4 +451,21 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp PipelineHelpers.ThrowIfNotSuccess(clientResponse); } + @Override + public ListMediaProcessorsResult listMediaProcessors() { + return this.listMediaProcessors(null); + } + + @Override + public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { + WebResource resource = getResource("MediaProcessors"); + + List<MediaProcessorInfo> mediaProcessorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<MediaProcessorInfo>>() { + }); + ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); + listMediaProcessorsResult.setMediaProcessorInfos(mediaProcessorInfoList); + return listMediaProcessorsResult; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java new file mode 100644 index 0000000000000..f76d61e200192 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -0,0 +1,109 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class MediaProcessorType implements MediaServiceDTO { + + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + @XmlElement(name = "Description", namespace = Constants.ODATA_DATA_NS) + protected String description; + + @XmlElement(name = "Sku", namespace = Constants.ODATA_DATA_NS) + protected String sku; + + @XmlElement(name = "Vendor", namespace = Constants.ODATA_DATA_NS) + protected String vendor; + + @XmlElement(name = "Version", namespace = Constants.ODATA_DATA_NS) + protected String version; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSku() { + return this.sku; + } + + public void setSku(String sku) { + this.sku = sku; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getVersion() { + return null; + } + + public void setVersion(String version) { + this.version = version; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index 3ad821b63e1cf..b23fcdbd34c68 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -67,4 +67,13 @@ public AccessPolicyType createAccessPolicyType() { public LocatorRestType createLocatorRestType() { return new LocatorRestType(); } + + /** + * Create an instance of {@link MediaProcessorType } + * + * @return a new MediaProcessorType instance. + */ + public MediaProcessorType createMediaProcessorType() { + return new MediaProcessorType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java index fc1ea2d060245..2342cb76728b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java @@ -16,4 +16,4 @@ public class ListAssetsOptions { -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java new file mode 100644 index 0000000000000..129bf5f4ae195 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java @@ -0,0 +1,22 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * The Class ListLocatorsOptions. + */ +public class ListMediaProcessorsOptions { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java new file mode 100644 index 0000000000000..102b411ae3e3b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java @@ -0,0 +1,48 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.List; + +/** + * The Class ListMediaProcessorsResult. + */ +public class ListMediaProcessorsResult { + + /** The media processor infos. */ + private List<MediaProcessorInfo> mediaProcessorInfos; + + /** + * Gets the media processor infos. + * + * @return the media processor infos + */ + public List<MediaProcessorInfo> getMediaProcessorInfos() { + return mediaProcessorInfos; + } + + /** + * Sets the media processor infos. + * + * @param mediaProcessorInfos + * the media processor infos + * @return the list media processor result + */ + public ListMediaProcessorsResult setMediaProcessorInfos(List<MediaProcessorInfo> mediaProcessorInfos) { + this.mediaProcessorInfos = mediaProcessorInfos; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java new file mode 100644 index 0000000000000..3fedc21bca39c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java @@ -0,0 +1,173 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType; + +// TODO: Auto-generated Javadoc +/** + * Data about a Media Processor entity. + * + */ +public class MediaProcessorInfo extends ODataEntity<MediaProcessorType> { + + /** + * Instantiates a new media processor info. + * + * @param entry + * the entry + * @param content + * the content + */ + public MediaProcessorInfo(EntryType entry, MediaProcessorType content) { + super(entry, content); + } + + /** + * Instantiates a new media processor info. + */ + public MediaProcessorInfo() { + super(new MediaProcessorType()); + } + + /** + * Get the asset id. + * + * @return the id + */ + public String getId() { + return getContent().getId(); + } + + /** + * Set the id. + * + * @param id + * the id + * @return the asset info + */ + public MediaProcessorInfo setId(String id) { + getContent().setId(id); + return this; + } + + /** + * Get the asset name. + * + * @return the name + */ + public String getName() { + return this.getContent().getName(); + } + + /** + * set the name. + * + * @param name + * the name + * @return the asset info + */ + public MediaProcessorInfo setName(String name) { + this.getContent().setName(name); + return this; + } + + /** + * Gets the description. + * + * @return the description + */ + public String getDescription() { + return this.getContent().getDescription(); + } + + /** + * Sets the description. + * + * @param description + * the description + * @return the media processor info + */ + public MediaProcessorInfo setDescription(String description) { + this.getContent().setDescription(description); + return this; + } + + /** + * Gets the sku. + * + * @return the sku + */ + public String getSku() { + return this.getContent().getSku(); + } + + /** + * Sets the sku. + * + * @param sku + * the sku + * @return the media processor info + */ + public MediaProcessorInfo setSku(String sku) { + this.getContent().setSku(sku); + return this; + } + + /** + * Gets the vendor. + * + * @return the vendor + */ + public String getVendor() { + return this.getContent().getVendor(); + } + + /** + * Sets the vendor. + * + * @param vendor + * the vendor + * @return the media processor info + */ + public MediaProcessorInfo setVendor(String vendor) { + this.getContent().setVendor(vendor); + return this; + } + + /** + * Gets the version. + * + * @return the version + */ + public String getVersion() { + return this.getContent().getVersion(); + } + + /** + * Sets the version. + * + * @param version + * the version + * @return the media processor info + */ + public MediaProcessorInfo setVersion(String version) { + this.getContent().setVersion(version); + return this; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 2e8c0d83bbc41..ade255c6767e0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -39,6 +39,8 @@ import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -491,4 +493,29 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException { assertTrue(false); } + @Test + public void listMediaProcessorsSuccess() throws ServiceException { + // Arrange + + // Act + ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(); + + // Assert + assertNotNull(listMediaProcessorsResult); + assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); + } + + @Test + public void listMediaProcessorWithOptionSuccess() throws ServiceException { + // Arrange + ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); + + // Act + ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(listMediaProcessorsOptions); + + // Assert + assertNotNull(listMediaProcessorsResult); + assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java new file mode 100644 index 0000000000000..994cbccee1401 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class ListMediaProcessorsOptionsTest { + + @Test + public void createListMediaProcessorsOptionsSuccess() { + // Arrange + + // Act + ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); + + // Assert + assertNotNull(listMediaProcessorsOptions); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java new file mode 100644 index 0000000000000..c681bf4cfbaf1 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -0,0 +1,104 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class MediaProcessorInfoTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualId = mediaProcessorInfo.setId(expectedId).getId(); + + // Assert + assertEquals(expectedId, actualId); + + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testName"; + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualName = mediaProcessorInfo.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetDescription() throws Exception { + // Arrange + String expectedDescription = "testDescription"; + + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualDescription = mediaProcessorInfo.setDescription(expectedDescription).getDescription(); + + // Assert + assertEquals(expectedDescription, actualDescription); + + } + + @Test + public void testGetSetSku() throws Exception { + // Arrange + String expectedSku = "testSku"; + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualSku = mediaProcessorInfo.setSku(expectedSku).getSku(); + + // Assert + assertEquals(expectedSku, actualSku); + } + + @Test + public void testGetSetVendor() { + // Arrange + String expectedVendor = "testVendor"; + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualVendor = mediaProcessorInfo.setVendor(expectedVendor).getVendor(); + + // Assert + assertEquals(expectedVendor, actualVendor); + } + + @Test + public void testGetSetVersion() { + // Arrange + String expectedVersion = "testVersion"; + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + + // Act + String actualVersion = mediaProcessorInfo.setName(expectedVersion).getVersion(); + + // Assert + assertEquals(expectedVersion, actualVersion); + } + +} From 8c965a45f4362275a08a4d141aa3fe0f6f54feaf Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 15 Oct 2012 23:59:09 -0700 Subject: [PATCH 384/664] fix the missing file and a few comments for list media processor. --- .../MediaExceptionProcessor.java | 6 +++ .../media/implementation/MediaRestProxy.java | 10 ++++ .../models/ListMediaProcessorsResultTest.java | 54 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index c13c0d46d4556..145c5be49fdd4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -421,6 +421,9 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() + */ @Override public ListMediaProcessorsResult listMediaProcessors() throws ServiceException { try { @@ -434,6 +437,9 @@ public ListMediaProcessorsResult listMediaProcessors() throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) + */ @Override public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index a7d7d4d1aa964..a8286376f54e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -58,6 +58,7 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; +// TODO: Auto-generated Javadoc /** * The Class MediaRestProxy. */ @@ -356,6 +357,9 @@ public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options }); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType) + */ @Override public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType) { return this.createLocator(accessPolicyId, assetId, locatorType, null); @@ -451,11 +455,17 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp PipelineHelpers.ThrowIfNotSuccess(clientResponse); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() + */ @Override public ListMediaProcessorsResult listMediaProcessors() { return this.listMediaProcessors(null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) + */ @Override public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { WebResource resource = getResource("MediaProcessors"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java new file mode 100644 index 0000000000000..fdf6f06fa28b8 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java @@ -0,0 +1,54 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class ListMediaProcessorsResultTest { + + @Test + public void createListMediaProcessorsResultSuccess() { + // Arrange + + // Act + ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); + + // Assert + assertNotNull(listMediaProcessorsResult); + + } + + @Test + public void getSetMediaProcessorInfos() { + // Arrange + ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); + List<MediaProcessorInfo> expectedMediaProcessorInfos = new ArrayList<MediaProcessorInfo>(); + + // Act + List<MediaProcessorInfo> actualMediaProcessorInfos = listMediaProcessorsResult.setMediaProcessorInfos( + expectedMediaProcessorInfos).getMediaProcessorInfos(); + + // Assert + assertEquals(expectedMediaProcessorInfos, actualMediaProcessorInfos); + + } + +} From 65fc7d39782e447189ff20da0dd814bff47ea1a6 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 16 Oct 2012 10:19:44 -0700 Subject: [PATCH 385/664] Implementation of blobWriter object, including responding to code review feedback. --- .../services/media/MediaService.java | 59 ++++++ .../media/WritableBlobContainerContract.java | 173 ++++++++++++++++++ .../MediaBlobContainerWriter.java | 118 ++++++++++++ .../implementation/MediaBlobRestProxy.java | 85 +++++++++ .../services/media/IntegrationTestBase.java | 1 + .../media/UploadingIntegrationTest.java | 113 ++++++++++++ 6 files changed, 549 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 9cf13258bab88..6a62bbb965bc4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -14,7 +14,14 @@ */ package com.microsoft.windowsazure.services.media; +import java.net.URI; + import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.MediaBlobContainerWriter; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.sun.jersey.api.client.Client; /** * @@ -64,4 +71,56 @@ public static MediaContract create(String profile) { public static MediaContract create(String profile, Configuration config) { return config.create(profile, MediaContract.class); } + + /** + * Creates an instance of the <code>WritableBlobContainerContract</code> API that will + * write to the blob container given by the provided locator. + * + * @param locator + * locator specifying where to upload to + * @return the implementation of <code>WritableBlobContainerContract</code> + * @throws ServiceException + */ + public static WritableBlobContainerContract createBlobWriter(LocatorInfo locator) throws ServiceException { + if (locator.getLocatorType() != LocatorType.SAS) { + throw new ServiceException("Can only upload to SAS locators"); + } + + LocatorParser p = new LocatorParser(locator); + + return new MediaBlobContainerWriter(createUploaderClient(), p.getAccountName(), p.getStorageUri(), + p.getContainer(), p.getSASToken()); + } + + /** + * Helper class to encapsulate pulling information out of the locator. + */ + private static class LocatorParser { + URI locatorPath; + + LocatorParser(LocatorInfo locator) { + locatorPath = URI.create(locator.getPath()); + } + + String getAccountName() { + return locatorPath.getHost().split("\\.")[0]; + } + + String getStorageUri() { + return locatorPath.getScheme() + "://" + locatorPath.getAuthority(); + } + + String getContainer() { + return locatorPath.getPath().substring(1); + } + + String getSASToken() { + return locatorPath.getRawQuery(); + } + } + + private static Client createUploaderClient() { + Client client = Client.create(); + return client; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java new file mode 100644 index 0000000000000..808e5c0460ece --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java @@ -0,0 +1,173 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.io.InputStream; + +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobResult; +import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.core.ServiceException; + +/** + * Contract for uploading media files to blob storage managed + * by Media Services. + * + */ +public interface WritableBlobContainerContract extends FilterableService<WritableBlobContainerContract> { + + /** + * Creates a block blob from a content stream. + * + * @param container + * A {@link String} containing the name of the container to create the blob in. + * @param blob + * A {@link String} containing the name of the blob to create. A blob name can contain any combination of + * characters, but reserved URL characters must be properly escaped. A blob name must be at least one + * character long and cannot be more than 1,024 characters long, and must be unique within the container. + * @param contentStream + * An {@link InputStream} reference to the content stream to upload to the new blob. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + CreateBlobResult createBlockBlob(String blob, InputStream contentStream) throws ServiceException; + + /** + * Creates a block blob from a content stream, using the specified options. + * <p> + * Use the {@link CreateBlobOptions options} parameter to optionally specify the server timeout for the operation, + * the MIME content type and content encoding for the blob, the content language, the MD5 hash, a cache control + * value, and blob metadata. + * + * @param blob + * A {@link String} containing the name of the blob to create. A blob name can contain any combination of + * characters, but reserved URL characters must be properly escaped. A blob name must be at least one + * character long and cannot be more than 1,024 characters long, and must be unique within the container. + * @param contentStream + * An {@link InputStream} reference to the content to upload to the new blob. + * @param options + * A {@link CreateBlobOptions} instance containing options for the request. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + CreateBlobResult createBlockBlob(String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException; + + /** + * Creates a new uncommited block from a content stream. + * <p> + * This method creates an uncommitted block for a block blob specified by the <em>blob</em> and <em>container</em> + * parameters. The <em>blockId</em> parameter is a client-specified ID for the block, which must be less than or + * equal to 64 bytes in size. For a given blob, the length of the value specified for the <em>blockId</em> parameter + * must be the same size for each block. The <em>contentStream</em> parameter specifies the content to be copied to + * the block. The content for the block must be less than or equal to 4 MB in size. + * <p> + * To create or update a block blob, the blocks that have been successfully written to the server with this method + * must be committed using a call to {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList)} or + * {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList, CommitBlobBlocksOptions)}. + * + * @param blob + * A {@link String} containing the name of the blob to create the block for. + * @param blockId + * A {@link String} containing a client-specified ID for the block. + * @param contentStream + * An {@link InputStream} reference to the content to copy to the block. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + void createBlobBlock(String blob, String blockId, InputStream contentStream) throws ServiceException; + + /** + * Creates a new uncommitted block from a content stream, using the specified options. + * <p> + * This method creates an uncommitted block for a block blob specified by the <em>blob</em> and <em>container</em> + * parameters. The <em>blockId</em> parameter is a client-specified ID for the block, which must be less than or + * equal to 64 bytes in size. For a given blob, the length of the value specified for the <em>blockId</em> parameter + * must be the same size for each block. The <em>contentStream</em> parameter specifies the content to be copied to + * the block. The content for the block must be less than or equal to 4 MB in size. Use the + * {@link CreateBlobBlockOptions options} parameter to optionally specify the server timeout for the operation, the + * lease ID if the blob has an active lease, and the MD5 hash value for the block content. + * <p> + * To create or update a block blob, the blocks that have been successfully written to the server with this method + * must be committed using a call to {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList)} or + * {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList, CommitBlobBlocksOptions)}. + * + * @param blob + * A {@link String} containing the name of the blob to create the block for. + * @param blockId + * A {@link String} containing a client-specified ID for the block. + * @param contentStream + * An {@link InputStream} reference to the content to copy to the block. + * @param options + * A {@link CreateBlobBlockOptions} instance containing options for the request. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + void createBlobBlock(String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) + throws ServiceException; + + /** + * Commits a list of blocks to a block blob. + * <p> + * This method creates or updates the block blob specified by the <em>blob</em> and <em>container</em> parameters. + * You can call this method to update a blob by uploading only those blocks that have changed, then committing the + * new and existing blocks together. You can do this with the <em>blockList</em> parameter by specifying whether to + * commit a block from the committed block list or from the uncommitted block list, or to commit the most recently + * uploaded version of the block, whichever list it may belong to. + * <p> + * In order to be written as part of a blob, each block in the list must have been successfully written to the + * server with a call to {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream)} or + * {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream, CreateBlobBlockOptions)}. + * + * @param blob + * A {@link String} containing the name of the block blob to create or update. + * @param blockList + * A {@link BlockList} containing the list of blocks to commit to the block blob. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + void commitBlobBlocks(String blob, BlockList blockList) throws ServiceException; + + /** + * Commits a block list to a block blob, using the specified options. + * <p> + * This method creates or updates the block blob specified by the <em>blob</em> and <em>container</em> parameters. + * You can call this method to update a blob by uploading only those blocks that have changed, then committing the + * new and existing blocks together. You can do this with the <em>blockList</em> parameter by specifying whether to + * commit a block from the committed block list or from the uncommitted block list, or to commit the most recently + * uploaded version of the block, whichever list it may belong to. Use the {@link CommitBlobBlocksOptions options} + * parameter to optionally specify the server timeout for the operation, the MIME content type and content encoding + * for the blob, the content language, the MD5 hash, a cache control value, blob metadata, the lease ID if the blob + * has an active lease, and any access conditions for the operation. + * <p> + * In order to be written as part of a blob, each block in the list must have been successfully written to the + * server with a call to {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream)} or + * {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream, CreateBlobBlockOptions)}. + * + * @param blob + * A {@link String} containing the name of the block blob to create or update. + * @param blockList + * A {@link BlockList} containing the list of blocks to commit to the block blob. + * @param options + * A {@link CommitBlobBlocksOptions} instance containing options for the request. + * @throws ServiceException + * if an error occurs accessing the storage service. + */ + void commitBlobBlocks(String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java new file mode 100644 index 0000000000000..d6831a3dc11cf --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java @@ -0,0 +1,118 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.InputStream; + +import com.microsoft.windowsazure.services.blob.BlobContract; +import com.microsoft.windowsazure.services.blob.implementation.BlobExceptionProcessor; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobResult; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.sun.jersey.api.client.Client; + +/** + * Implementation of WritableBlobContainerContract, used to upload blobs to the + * Media Services storage. + * + */ +public class MediaBlobContainerWriter implements WritableBlobContainerContract { + + private final BlobContract blobService; + private final BlobContract restProxy; + private final String containerName; + + /** + * + */ + public MediaBlobContainerWriter(Client client, String accountName, String blobServiceUri, String containerName, + String sasToken) { + this.containerName = containerName; + this.restProxy = new MediaBlobRestProxy(client, accountName, blobServiceUri, new SASTokenFilter(sasToken)); + this.blobService = new BlobExceptionProcessor(this.restProxy); + } + + private MediaBlobContainerWriter(MediaBlobContainerWriter baseWriter, ServiceFilter filter) { + this.containerName = baseWriter.containerName; + this.restProxy = baseWriter.restProxy.withFilter(filter); + this.blobService = new BlobExceptionProcessor(this.restProxy); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ + @Override + public WritableBlobContainerContract withFilter(ServiceFilter filter) { + return new MediaBlobContainerWriter(this, filter); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#createBlockBlob(java.lang.String, java.io.InputStream) + */ + @Override + public CreateBlobResult createBlockBlob(String blob, InputStream contentStream) throws ServiceException { + return blobService.createBlockBlob(containerName, blob, contentStream); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#createBlockBlob(java.lang.String, java.io.InputStream, com.microsoft.windowsazure.services.blob.models.CreateBlobOptions) + */ + @Override + public CreateBlobResult createBlockBlob(String blob, InputStream contentStream, CreateBlobOptions options) + throws ServiceException { + return blobService.createBlockBlob(containerName, blob, contentStream, options); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#createBlobBlock(java.lang.String, java.lang.String, java.io.InputStream) + */ + @Override + public void createBlobBlock(String blob, String blockId, InputStream contentStream) throws ServiceException { + blobService.createBlobBlock(containerName, blob, blockId, contentStream); + + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#createBlobBlock(java.lang.String, java.lang.String, java.io.InputStream, com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions) + */ + @Override + public void createBlobBlock(String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) + throws ServiceException { + blobService.createBlobBlock(containerName, blob, blockId, contentStream, options); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#commitBlobBlocks(java.lang.String, com.microsoft.windowsazure.services.blob.models.BlockList) + */ + @Override + public void commitBlobBlocks(String blob, BlockList blockList) throws ServiceException { + blobService.commitBlobBlocks(containerName, blob, blockList); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.WritableBlobContainerContract#commitBlobBlocks(java.lang.String, com.microsoft.windowsazure.services.blob.models.BlockList, com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions) + */ + @Override + public void commitBlobBlocks(String blob, BlockList blockList, CommitBlobBlocksOptions options) + throws ServiceException { + blobService.commitBlobBlocks(containerName, blob, blockList, options); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java new file mode 100644 index 0000000000000..3f799b69cd601 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java @@ -0,0 +1,85 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.util.Arrays; + +import com.microsoft.windowsazure.services.blob.BlobContract; +import com.microsoft.windowsazure.services.blob.implementation.BlobOperationRestProxy; +import com.microsoft.windowsazure.services.blob.implementation.RFC1123DateConverter; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.sun.jersey.api.client.Client; + +/** + * Rest proxy for blob operations that's specialized for working + * with the blobs created by and for Media Services storage. + * + */ +class MediaBlobRestProxy extends BlobOperationRestProxy { + private final SASTokenFilter tokenFilter; + + /** + * Construct instance of MediaBlobRestProxy with given parameters. + * + * @param channel + * Jersey Client object used to communicate with blob service + * @param accountName + * Account name for blob storage + * @param url + * URL for blob storage + * @param tokenFilter + * filter used to add SAS tokens to requests. + */ + public MediaBlobRestProxy(Client channel, String accountName, String url, SASTokenFilter tokenFilter) { + super(channel, accountName, url); + + this.tokenFilter = tokenFilter; + channel.addFilter(tokenFilter); + } + + /** + * Construct instance of MediaBlobRestProxy with given parameters. + * + * @param channel + * Jersey Client object used to communicate with blob service + * @param filters + * Additional ServiceFilters to manipulate requests and responses + * @param accountName + * Account name for blob storage + * @param url + * URL for blob storage + * @param dateMapper + * date conversion helper object + */ + public MediaBlobRestProxy(Client channel, ServiceFilter[] filters, String accountName, String url, + SASTokenFilter tokenFilter, RFC1123DateConverter dateMapper) { + super(channel, filters, accountName, url, dateMapper); + + this.tokenFilter = tokenFilter; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.blob.implementation.BlobOperationRestProxy#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ + @Override + public BlobContract withFilter(ServiceFilter filter) { + ServiceFilter[] currentFilters = getFilters(); + ServiceFilter[] newFilters = Arrays.copyOf(currentFilters, currentFilters.length + 1); + newFilters[currentFilters.length] = filter; + return new MediaBlobRestProxy(getChannel(), newFilters, getAccountName(), getUrl(), this.tokenFilter, + getDateMapper()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index efc4a219ac1fa..0b88485694e21 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -14,6 +14,7 @@ public void beforeEachTest() { overrideWithEnv(config, MediaConfiguration.OAUTH_URI); overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); } public static Configuration createConfig() { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java new file mode 100644 index 0000000000000..11162a491ebff --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -0,0 +1,113 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; +import com.microsoft.windowsazure.services.core.RetryPolicyFilter; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; + +/** + * Testing uploading in various permutations. + * + */ +public class UploadingIntegrationTest extends IntegrationTestBase { + private static ArrayList<String> locatorIds; + + @BeforeClass + public static void init() { + locatorIds = new ArrayList<String>(); + } + + @AfterClass + public static void cleanup() throws Exception { + MediaContract service = MediaService.create(config); + deleteLocators(service); + deleteAccessPolicies(service, "upload"); + deleteAssets(service, "upload"); + } + + private static void deleteLocators(MediaContract service) throws Exception { + for (String locatorId : locatorIds) { + service.deleteLocator(locatorId); + } + } + + private static void deleteAccessPolicies(MediaContract service, String prefix) throws Exception { + List<AccessPolicyInfo> policies = service.listAccessPolicies(); + for (AccessPolicyInfo policy : policies) { + if (policy.getName().startsWith(prefix)) { + service.deleteAccessPolicy(policy.getId()); + } + } + } + + private static void deleteAssets(MediaContract service, String prefix) throws Exception { + List<AssetInfo> assets = service.listAssets(); + for (AssetInfo asset : assets) { + if (asset.getName().startsWith(prefix)) { + service.deleteAsset(asset.getId()); + } + } + } + + @Test + public void canUploadBlockBlob() throws Exception { + MediaContract service = MediaService.create(config); + + AssetInfo asset = service.createAsset(new CreateAssetOptions().setName("uploadBlockBlobAsset")); + + AccessPolicyInfo policy = service.createAccessPolicy("uploadWritePolicy", 10, + new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.WRITE)); + + Date now = new Date(); + Date fiveMinutesAgo = new Date(); + Date tenMinutesFromNow = new Date(); + + fiveMinutesAgo.setTime(now.getTime() - (5 * 60 * 1000)); + tenMinutesFromNow.setTime(now.getTime() + (10 * 60 * 1000)); + + LocatorInfo locator = service.createLocator(policy.getId(), asset.getId(), LocatorType.SAS, + new CreateLocatorOptions().setStartTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); + + locatorIds.add(locator.getId()); + + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(5000, 5, new int[] { 400, 404 }); + blobWriter = blobWriter.withFilter(new RetryPolicyFilter(retryPolicy)); + + InputStream blobContent = new ByteArrayInputStream(new byte[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }); + + blobWriter.createBlockBlob("uploadBlockBlobTest", blobContent); + } +} From 00bb3a60baa2dab94588d1323739bd701f939f58 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 16 Oct 2012 10:42:37 -0700 Subject: [PATCH 386/664] Address the code review feedback. --- .../services/media/implementation/RedirectFilter.java | 1 - .../media/implementation/ResourceLocationManager.java | 6 +----- .../services/media/models/ListAccessPolicyOptions.java | 2 +- .../services/media/models/ListLocatorsOptions.java | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 1b332e8f6ddb4..f71ea6381653b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -37,7 +37,6 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio } URI originalURI = request.getURI(); - String queryString = originalURI.getQuery(); request.setURI(locationManager.getRedirectedURI(originalURI)); ClientResponse response = getNext().handle(request); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 9c3d40d080e74..83e7e5586b65b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -17,7 +17,6 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -42,10 +41,7 @@ public URI getRedirectedURI(URI originalURI) { String queryString = originalURI.getQuery(); if (queryString != null && !queryString.isEmpty()) { - Map<String, String> queryParams = parseQueryString(queryString); - for (String key : new ArrayList<String>(queryParams.keySet())) { - uriBuilder.queryParam(key, queryParams.get(key)); - } + uriBuilder.replaceQuery(queryString); } return uriBuilder.build(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java index 2327574c985bc..ca8bd29ab984a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java @@ -19,6 +19,6 @@ * Options class for listing access policies * No options available at this time. */ -public class ListAccessPolicyOptions { +public class ListAccessPolicyOptions extends ListOptions { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java index aeb6797a6a1e3..c5129f9cd0695 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java @@ -17,6 +17,6 @@ /** * The Class ListLocatorsOptions. */ -public class ListLocatorsOptions { +public class ListLocatorsOptions extends ListOptions { } From d24bf5e80a977a93bd6e7371b2f37de38ca218c9 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 16 Oct 2012 11:54:08 -0700 Subject: [PATCH 387/664] Updated exception type when passed bad locator --- .../microsoft/windowsazure/services/media/MediaService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 6a62bbb965bc4..bc2d5d54e2a19 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -17,7 +17,6 @@ import java.net.URI; import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.MediaBlobContainerWriter; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -79,11 +78,10 @@ public static MediaContract create(String profile, Configuration config) { * @param locator * locator specifying where to upload to * @return the implementation of <code>WritableBlobContainerContract</code> - * @throws ServiceException */ - public static WritableBlobContainerContract createBlobWriter(LocatorInfo locator) throws ServiceException { + public static WritableBlobContainerContract createBlobWriter(LocatorInfo locator) { if (locator.getLocatorType() != LocatorType.SAS) { - throw new ServiceException("Can only upload to SAS locators"); + throw new IllegalArgumentException("Can only write to SAS locators"); } LocatorParser p = new LocatorParser(locator); From 5007a754e74519143eb7b2dc27b3bf7cc76afa62 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 15 Oct 2012 16:13:34 -0700 Subject: [PATCH 388/664] Clean up IntegrationTestBase vs. integration test suite (#372) --- .../media/AccessPolicyIntegrationTest.java | 110 ++++------- .../services/media/IntegrationTestBase.java | 138 +++++++++++-- .../media/MediaServiceIntegrationTest.java | 185 ++++++++---------- 3 files changed, 240 insertions(+), 193 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 705558766f2e1..22ee42d3743a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -17,15 +17,12 @@ import static org.junit.Assert.*; +import java.util.ArrayList; import java.util.EnumSet; import java.util.List; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; @@ -33,40 +30,9 @@ import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; public class AccessPolicyIntegrationTest extends IntegrationTestBase { - private MediaContract service; - - private final String invalidId = "notAValidId"; - private final String validButNonexistId = "nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"; - - private static final String testPrefix = "testPolicy"; - - @Rule - public ExpectedException expected = ExpectedException.none(); - - @BeforeClass - public static void setup() throws Exception { - cleanupEnvironment(); - } - - @AfterClass - public static void cleanup() throws Exception { - cleanupEnvironment(); - } - - private static void cleanupEnvironment() { - config = createConfig(); - MediaContract service = MediaService.create(config); - try { - List<AccessPolicyInfo> policies = service.listAccessPolicies(); - for (AccessPolicyInfo policy : policies) { - if (policy.getName().startsWith(testPrefix)) { - service.deleteAccessPolicy(policy.getId()); - } - } - } - catch (Exception e) { - e.printStackTrace(); - } + private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) { + verifyPolicyProperties(message, expected.getName(), expected.getDurationInMinutes(), expected.getPermissions(), + actual); } private void verifyPolicyProperties(String message, String testName, double duration, @@ -100,7 +66,7 @@ public void setupInstance() throws Exception { @Test public void canCreateAccessPolicy() throws Exception { - String testName = testPrefix + "CanCreate"; + String testName = testPolicyPrefix + "CanCreate"; double duration = 5; AccessPolicyInfo policy = service.createAccessPolicy(testName, duration); @@ -110,9 +76,9 @@ public void canCreateAccessPolicy() throws Exception { @Test public void canCreateAccessPolicyOptions() throws Exception { - String testName = testPrefix + "CanCreateOptions"; + String testName = testPolicyPrefix + "CanCreateOptions"; double duration = 5; - AccessPolicyPermission permission = AccessPolicyPermission.WRITE; + AccessPolicyPermission permission = AccessPolicyPermission.READ; CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(permission); AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, options); @@ -124,7 +90,7 @@ public void canCreateAccessPolicyOptions() throws Exception { @Test public void canGetSinglePolicyById() throws Exception { - String expectedName = testPrefix + "GetOne"; + String expectedName = testPolicyPrefix + "GetOne"; double duration = 1; AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, duration); @@ -136,54 +102,48 @@ public void canGetSinglePolicyById() throws Exception { @Test public void canGetSinglePolicyByInvalidId() throws Exception { - expected.expect(ServiceException.class); - expected.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); service.getAccessPolicy(invalidId); } @Test public void canGetSinglePolicyByNonexistId() throws Exception { - expected.expect(ServiceException.class); - expected.expect(new ServiceExceptionMatcher(404)); - service.getAccessPolicy(validButNonexistId); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAccessPolicy(validButNonexistAccessPolicyId); } @Test public void canRetrieveListOfAccessPolicies() throws Exception { - String[] policyNames = new String[] { testPrefix + "ListOne", testPrefix + "ListTwo" }; + String[] policyNames = new String[] { testPolicyPrefix + "ListOne", testPolicyPrefix + "ListTwo" }; double duration = 3; EnumSet<AccessPolicyPermission> permissions = EnumSet.of(AccessPolicyPermission.WRITE, AccessPolicyPermission.LIST); - for (String name : policyNames) { - service.createAccessPolicy(name, duration, new CreateAccessPolicyOptions().addPermissions(permissions)); + List<AccessPolicyInfo> expectedAccessPolicies = new ArrayList<AccessPolicyInfo>(); + for (int i = 0; i < policyNames.length; i++) { + AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, + new CreateAccessPolicyOptions().addPermissions(permissions)); + expectedAccessPolicies.add(policy); } - List<AccessPolicyInfo> policies = service.listAccessPolicies(); - - assertNotNull(policies); - assertTrue(policies.size() >= 2); + List<AccessPolicyInfo> actualAccessPolicies = service.listAccessPolicies(); - AccessPolicyInfo[] orderedPolicies = new AccessPolicyInfo[policyNames.length]; - - for (AccessPolicyInfo policy : policies) { - for (int i = 0; i < policyNames.length; i++) { - if (policy.getName().equals(policyNames[i])) { - orderedPolicies[i] = policy; - } - } - } - - for (int i = 0; i < policyNames.length; i++) { - verifyPolicyProperties("orderedPolicies " + i, policyNames[i], duration, permissions, orderedPolicies[i]); - } + verifyListResultContains("listAccessPolicies", expectedAccessPolicies, actualAccessPolicies, + new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyInfosEqual(message, (AccessPolicyInfo) expected, (AccessPolicyInfo) actual); + } + }); } // Note: Access Policy cannot be updated. @Test public void canDeleteAccessPolicyById() throws Exception { - String policyName = testPrefix + "ToDelete"; + String policyName = testPolicyPrefix + "ToDelete"; double duration = 1; AccessPolicyInfo policyToDelete = service.createAccessPolicy(policyName, duration); List<AccessPolicyInfo> listPoliciesResult = service.listAccessPolicies(); @@ -198,22 +158,22 @@ public void canDeleteAccessPolicyById() throws Exception { assertFalse(policyToDelete.getId().equals(policy.getId())); } - expected.expect(ServiceException.class); - expected.expect(new ServiceExceptionMatcher(404)); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); service.getAccessPolicy(policyToDelete.getId()); } @Test public void canDeleteAccessPolicyByInvalidId() throws Exception { - expected.expect(ServiceException.class); - expected.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); service.deleteAccessPolicy(invalidId); } @Test public void canDeleteAccessPolicyByNonexistId() throws Exception { - expected.expect(ServiceException.class); - expected.expect(new ServiceExceptionMatcher(404)); - service.deleteAccessPolicy(validButNonexistId); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.deleteAccessPolicy(validButNonexistAccessPolicyId); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 0b88485694e21..983b98f411b41 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -1,30 +1,50 @@ package com.microsoft.windowsazure.services.media; -import org.junit.Before; +import static org.junit.Assert.*; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; public abstract class IntegrationTestBase { + protected static MediaContract service; protected static Configuration config; - @Before - public void beforeEachTest() { + protected static final String testAssetPrefix = "testAsset"; + protected static final String testPolicyPrefix = "testPolicy"; + + protected static final String validButNonexistAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; + protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"; + + protected static final String invalidId = "notAValidId"; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @BeforeClass + public static void setup() throws Exception { config = Configuration.getInstance(); overrideWithEnv(config, MediaConfiguration.URI); overrideWithEnv(config, MediaConfiguration.OAUTH_URI); overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - } - public static Configuration createConfig() { - Configuration config = Configuration.getInstance(); - overrideWithEnv(config, MediaConfiguration.URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_URI); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); - overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); - overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - return config; + service = MediaService.create(config); + + cleanupEnvironment(); } protected static void overrideWithEnv(Configuration config, String key) { @@ -34,4 +54,98 @@ protected static void overrideWithEnv(Configuration config, String key) { config.setProperty(key, value); } + + @AfterClass + public static void cleanup() throws Exception { + cleanupEnvironment(); + } + + private static void cleanupEnvironment() { + // TODO: This should be removed once cascade delete is implemented for Assets. + // But for now, trying to delete an asset with fail if there are any + // existing Locators associated with it. + removeAllTestLocators(); + removeAllTestAssets(); + removeAllTestAccessPolicies(); + } + + private static void removeAllTestAccessPolicies() { + try { + List<AccessPolicyInfo> policies = service.listAccessPolicies(); + for (AccessPolicyInfo policy : policies) { + if (policy.getName().startsWith(testPolicyPrefix)) { + service.deleteAccessPolicy(policy.getId()); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + private static void removeAllTestAssets() { + try { + List<AssetInfo> listAssetsResult = service.listAssets(); + for (AssetInfo assetInfo : listAssetsResult) { + if (assetInfo.getName().startsWith(testAssetPrefix)) { + service.deleteAsset(assetInfo.getId()); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + private static void removeAllTestLocators() { + try { + ListLocatorsResult listLocatorsResult = service.listLocators(); + for (LocatorInfo locatorInfo : listLocatorsResult.getLocatorInfos()) { + AssetInfo ai = service.getAsset(locatorInfo.getAssetId()); + if (ai.getName().startsWith(testAssetPrefix)) { + service.deleteLocator(locatorInfo.getId()); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + + interface ComponentDelegate { + void verifyEquals(String message, Object expected, Object actual); + } + + protected <T> void verifyListResultContains(String message, List<T> expectedInfos, Collection<T> actualInfos, + ComponentDelegate delegate) { + assertNotNull(message + ": actualInfos", actualInfos); + assertTrue(message + ": actual size should be same size or larger than expected size", + actualInfos.size() >= expectedInfos.size()); + + List<T> orderedAndFilteredActualInfo = new ArrayList<T>(); + try { + for (T actualInfo : actualInfos) { + Method getId = null; + getId = actualInfo.getClass().getMethod("getId"); + for (T expectedInfo : expectedInfos) { + if (((String) getId.invoke(actualInfo)).equals(getId.invoke(expectedInfo))) { + orderedAndFilteredActualInfo.add(actualInfo); + } + } + } + } + catch (Exception e) { + // Don't worry about problems here. + e.printStackTrace(); + } + + assertEquals(message + ": actual filtered size should be same as expected size", expectedInfos.size(), + orderedAndFilteredActualInfo.size()); + + if (delegate != null) { + for (int i = 0; i < expectedInfos.size(); i++) { + delegate.verifyEquals("orderedPolicies " + i, expectedInfos.get(i), orderedAndFilteredActualInfo.get(i)); + } + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 2e8c0d83bbc41..ec786fc337272 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -17,17 +17,13 @@ import static org.junit.Assert.*; +import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; @@ -45,67 +41,34 @@ import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; public class MediaServiceIntegrationTest extends IntegrationTestBase { - private static MediaContract service; - private static final String testAssetPrefix = "testAsset"; - private static String fakeAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @BeforeClass - public static void setup() throws Exception { - service = MediaService.create(createConfig()); - cleanupEnvironment(); - } - - @AfterClass - public static void cleanup() throws Exception { - cleanupEnvironment(); - } - - private static void removeAllAssets() throws ServiceException { - List<AssetInfo> listAssetsResult = service.listAssets(null); - for (AssetInfo assetInfo : listAssetsResult) { - try { - service.deleteAsset(assetInfo.getId()); - } - catch (Exception e) { - e.printStackTrace(); - } - } - } - - private static void removeAllLocators() throws ServiceException { - ListLocatorsResult listLocatorsResult = service.listLocators(null); - for (LocatorInfo locatorInfo : listLocatorsResult.getLocatorInfos()) { - try { - service.deleteLocator(locatorInfo.getId()); - } - catch (Exception e) { - e.printStackTrace(); - } - } + private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actual) { + verifyAssetProperties(message, expected.getName(), expected.getAlternateId(), expected.getOptions(), + expected.getState(), expected.getId(), expected.getCreated(), expected.getLastModified(), actual); } - private static void cleanupEnvironment() throws ServiceException { - config = createConfig(); - removeAllAssets(); - removeAllLocators(); + private void verifyAssetProperties(String message, String testName, String altId, + EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + verifyAssetProperties(message, testName, altId, encryptionOption, assetState, null, null, null, actualAsset); } private void verifyAssetProperties(String message, String testName, String altId, - EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + EncryptionOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, + AssetInfo actualAsset) { assertNotNull(message, actualAsset); assertEquals(message + " Name", testName, actualAsset.getName()); assertEquals(message + " AlternateId", altId, actualAsset.getAlternateId()); assertEquals(message + " Options", encryptionOption, actualAsset.getOptions()); assertEquals(message + " State", assetState, actualAsset.getState()); - } - - @Before - public void setupInstance() throws Exception { - service = MediaService.create(config); + if (id != null) { + assertEquals(message + " Id", id, actualAsset.getId()); + } + if (created != null) { + assertEquals(message + " Created", created, actualAsset.getCreated()); + } + if (lastModified != null) { + assertEquals(message + " LastModified", lastModified, actualAsset.getLastModified()); + } } @Test @@ -162,7 +125,7 @@ public void createAssetNullNameSuccess() throws Exception { // Act AssetInfo actualAsset = null; try { - actualAsset = service.createAsset(null); + actualAsset = service.createAsset(); // Assert assertNotNull("actualAsset", actualAsset); assertEquals("actualAsset.getName() should be the service default value, the empty string", "", @@ -202,26 +165,38 @@ public void getAssetSuccess() throws Exception { @Test public void getAssetFailedWithInvalidId() throws ServiceException { - thrown.expect(ServiceException.class); - thrown.expect(new ServiceExceptionMatcher(404)); - service.getAsset(fakeAssetId); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAsset(validButNonexistAssetId); } @Test public void listAssetSuccess() throws ServiceException { // Arrange - Collection<AssetInfo> listAssetResultBaseLine = service.listAssets(); - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetA")); - service.createAsset(createAssetOptions.setName(testAssetPrefix + "assetB")); + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + + String[] assetNames = new String[] { testAssetPrefix + "assetA", testAssetPrefix + "assetB" }; + List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); + for (int i = 0; i < assetNames.length; i++) { + String name = assetNames[i]; + CreateAssetOptions options = new CreateAssetOptions().setName(name).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState); + expectedAssets.add(service.createAsset(options)); + } // Act Collection<AssetInfo> listAssetResult = service.listAssets(); // Assert - assertNotNull("listAssetResult", listAssetResult); - assertEquals("listAssetResult.size", listAssetResultBaseLine.size() + 2, listAssetResult.size()); + verifyListResultContains("listAssets", expectedAssets, listAssetResult, new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyInfosEqual(message, (AssetInfo) expected, (AssetInfo) actual); + } + }); } @Ignore @@ -276,9 +251,9 @@ public void updateAssetFailedWithInvalidId() throws ServiceException { UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); // Act - thrown.expect(ServiceException.class); - thrown.expect(new ServiceExceptionMatcher(404)); - service.updateAsset(fakeAssetId, updateAssetOptions); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.updateAsset(validButNonexistAssetId, updateAssetOptions); } @Test @@ -297,24 +272,38 @@ public void deleteAssetSuccess() throws Exception { listAssetsResult = service.listAssets(); assertEquals("listAssetsResult.size", assetCountBaseline - 1, listAssetsResult.size()); - thrown.expect(ServiceException.class); - thrown.expect(new ServiceExceptionMatcher(404)); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); service.getAsset(assetInfo.getId()); } @Test public void deleteAssetFailedWithInvalidId() throws ServiceException { - thrown.expect(ServiceException.class); - thrown.expect(new ServiceExceptionMatcher(404)); - service.deleteAsset(fakeAssetId); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.deleteAsset(validButNonexistAssetId); + } + + // End of Asset tests + + // Start of Locator tests + + private AssetInfo assetInfo; + private AccessPolicyInfo accessPolicyInfo; + private AccessPolicyInfo accessPolicyInfoRead; + + private void setupForLocatorTest() throws ServiceException { + assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); + accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5); + accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, + new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ)); } @Test public void createLocatorSuccess() throws ServiceException { // Arrange + setupForLocatorTest(); CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - AssetInfo assetInfo = service.createAsset(null); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("createLocatorSuccess", 5); LocatorType locatorType = LocatorType.SAS; // Act @@ -331,14 +320,12 @@ public void createLocatorSuccess() throws ServiceException { @Test public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { // Arrange + setupForLocatorTest(); + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedExpirationDateTime = new Date(); expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 1000); - String accessPolicyName = "createLocatorSetExpirationDateTimeSuccess"; - createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy(accessPolicyName, 10); - AssetInfo assetInfo = service.createAsset(null); LocatorType locatorType = LocatorType.SAS; // Act @@ -355,14 +342,12 @@ public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException @Test public void createLocatorSetStartTimeSuccess() throws ServiceException { // Arrange + setupForLocatorTest(); + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 1000); - String accessPolicyName = "createLocatorSetStartDateTimeSuccess"; - createLocatorOptions.setStartTime(expectedStartDateTime); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy(accessPolicyName, 10); - AssetInfo assetInfo = service.createAsset(null); LocatorType locatorType = LocatorType.SAS; // Act @@ -380,9 +365,8 @@ public void createLocatorSetStartTimeSuccess() throws ServiceException { @Test public void getLocatorSuccess() throws ServiceException { // Arrange + setupForLocatorTest(); CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - AssetInfo assetInfo = service.createAsset(null); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("getLocatorSuccess", 5); LocatorType locatorType = LocatorType.SAS; LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, createLocatorOptions); @@ -405,41 +389,32 @@ public void getLocatorSuccess() throws ServiceException { @Test public void listLocatorsSuccess() throws ServiceException { // Arrange - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - AssetInfo assetInfo = service.createAsset(null); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("listLocatorsSuccess", 5); + setupForLocatorTest(); LocatorType locatorType = LocatorType.SAS; - LocatorInfo locatorInfoA = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - LocatorInfo locatorInfoB = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); + List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); + for (int i = 0; i < 2; i++) { + expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType)); + } // Act ListLocatorsResult listLocatorsResult = service.listLocators(); // Assert assertNotNull(listLocatorsResult); - service.deleteLocator(locatorInfoA.getId()); - service.deleteLocator(locatorInfoB.getId()); - + verifyListResultContains("listLocators", expectedLocators, listLocatorsResult.getLocatorInfos(), null); } @Ignore("due to media service bug 596264") @Test public void updateLocatorSuccess() throws ServiceException { // Arrange + setupForLocatorTest(); + LocatorType locatorTypeExepcted = LocatorType.Origin; - AssetInfo assetInfo = service.createAsset(null); - CreateAccessPolicyOptions createAccessPolicyOptions = new CreateAccessPolicyOptions(); - createAccessPolicyOptions.removePermissions(AccessPolicyPermission.DELETE); - createAccessPolicyOptions.removePermissions(AccessPolicyPermission.WRITE); - createAccessPolicyOptions.addPermissions(AccessPolicyPermission.READ); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("listLocatorsSuccess", 5, - createAccessPolicyOptions); LocatorType locatorType = LocatorType.Origin; CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, createLocatorOptions); Date expirationDateTime = new Date(); expirationDateTime.setTime(expirationDateTime.getTime() + 1000); @@ -459,8 +434,7 @@ public void updateLocatorSuccess() throws ServiceException { @Test public void deleteLocatorSuccess() throws ServiceException { // Arrange - AssetInfo assetInfo = service.createAsset(null); - AccessPolicyInfo accessPolicyInfo = service.createAccessPolicy("deleteLocatorsSuccess", 5); + setupForLocatorTest(); LocatorType locatorType = LocatorType.SAS; CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, @@ -490,5 +464,4 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException { // Assert assertTrue(false); } - } From 1131546b2a84ffdcf765a077fa5e2ccb72f61055 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 15 Oct 2012 16:19:11 -0700 Subject: [PATCH 389/664] Relax test of Asset equality to avoid media service bug 596240 --- .../services/media/MediaServiceIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index ec786fc337272..df2dc70e76dc0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -44,7 +44,7 @@ public class MediaServiceIntegrationTest extends IntegrationTestBase { private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actual) { verifyAssetProperties(message, expected.getName(), expected.getAlternateId(), expected.getOptions(), - expected.getState(), expected.getId(), expected.getCreated(), expected.getLastModified(), actual); + expected.getState(), actual); } private void verifyAssetProperties(String message, String testName, String altId, From 8878010ce992bd636f846f939ad3da10f3f83b55 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 16 Oct 2012 17:44:48 -0700 Subject: [PATCH 390/664] Adding verify method overload without message parameter. --- .../windowsazure/services/media/IntegrationTestBase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 983b98f411b41..c807c06fe3ba2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -116,6 +116,11 @@ interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } + protected <T> void verifyListResultContains(List<T> expectedInfos, Collection<T> actualInfos, + ComponentDelegate delegate) { + verifyListResultContains("", expectedInfos, actualInfos, delegate); + } + protected <T> void verifyListResultContains(String message, List<T> expectedInfos, Collection<T> actualInfos, ComponentDelegate delegate) { assertNotNull(message + ": actualInfos", actualInfos); From 40ce94d0909bdbe81252daaf3c9a2834227a4aee Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 17 Oct 2012 08:47:35 -0700 Subject: [PATCH 391/664] Remove code from UIT that duplicated base class code --- .../media/UploadingIntegrationTest.java | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 11162a491ebff..daad8339c1a78 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -17,12 +17,8 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.ArrayList; import java.util.Date; -import java.util.List; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; @@ -41,44 +37,6 @@ * */ public class UploadingIntegrationTest extends IntegrationTestBase { - private static ArrayList<String> locatorIds; - - @BeforeClass - public static void init() { - locatorIds = new ArrayList<String>(); - } - - @AfterClass - public static void cleanup() throws Exception { - MediaContract service = MediaService.create(config); - deleteLocators(service); - deleteAccessPolicies(service, "upload"); - deleteAssets(service, "upload"); - } - - private static void deleteLocators(MediaContract service) throws Exception { - for (String locatorId : locatorIds) { - service.deleteLocator(locatorId); - } - } - - private static void deleteAccessPolicies(MediaContract service, String prefix) throws Exception { - List<AccessPolicyInfo> policies = service.listAccessPolicies(); - for (AccessPolicyInfo policy : policies) { - if (policy.getName().startsWith(prefix)) { - service.deleteAccessPolicy(policy.getId()); - } - } - } - - private static void deleteAssets(MediaContract service, String prefix) throws Exception { - List<AssetInfo> assets = service.listAssets(); - for (AssetInfo asset : assets) { - if (asset.getName().startsWith(prefix)) { - service.deleteAsset(asset.getId()); - } - } - } @Test public void canUploadBlockBlob() throws Exception { @@ -99,8 +57,6 @@ public void canUploadBlockBlob() throws Exception { LocatorInfo locator = service.createLocator(policy.getId(), asset.getId(), LocatorType.SAS, new CreateLocatorOptions().setStartTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); - locatorIds.add(locator.getId()); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(5000, 5, new int[] { 400, 404 }); From 847dcc832778c6a28d910635cf982489900f27a2 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 17 Oct 2012 09:09:54 -0700 Subject: [PATCH 392/664] Fixing loop order so items get sorted. --- .../services/media/IntegrationTestBase.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index c807c06fe3ba2..b878f83fbd7b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -129,12 +129,12 @@ protected <T> void verifyListResultContains(String message, List<T> expectedInfo List<T> orderedAndFilteredActualInfo = new ArrayList<T>(); try { - for (T actualInfo : actualInfos) { - Method getId = null; - getId = actualInfo.getClass().getMethod("getId"); - for (T expectedInfo : expectedInfos) { + for (T expectedInfo : expectedInfos) { + Method getId = expectedInfo.getClass().getMethod("getId"); + for (T actualInfo : actualInfos) { if (((String) getId.invoke(actualInfo)).equals(getId.invoke(expectedInfo))) { orderedAndFilteredActualInfo.add(actualInfo); + break; } } } @@ -149,7 +149,8 @@ protected <T> void verifyListResultContains(String message, List<T> expectedInfo if (delegate != null) { for (int i = 0; i < expectedInfos.size(); i++) { - delegate.verifyEquals("orderedPolicies " + i, expectedInfos.get(i), orderedAndFilteredActualInfo.get(i)); + delegate.verifyEquals(message + ": orderedAndFilteredActualInfo " + i, expectedInfos.get(i), + orderedAndFilteredActualInfo.get(i)); } } } From 224b2b093956c8abbcbc525d0793b8b0bffb0620 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 17 Oct 2012 12:30:29 -0700 Subject: [PATCH 393/664] Refactor Locator tests into their own file, for better encapsulation. --- .../services/media/AssetIntegrationTest.java | 278 +++++++++++ .../media/LocatorIntegrationTests.java | 217 +++++++++ .../media/MediaServiceIntegrationTest.java | 448 ------------------ 3 files changed, 495 insertions(+), 448 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java new file mode 100644 index 0000000000000..9fbf820a17d5e --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -0,0 +1,278 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetState; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; + +public class AssetIntegrationTest extends IntegrationTestBase { + + private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actual) { + verifyAssetProperties(message, expected.getName(), expected.getAlternateId(), expected.getOptions(), + expected.getState(), actual); + } + + private void verifyAssetProperties(String message, String testName, String altId, + EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + verifyAssetProperties(message, testName, altId, encryptionOption, assetState, null, null, null, actualAsset); + } + + private void verifyAssetProperties(String message, String testName, String altId, + EncryptionOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, + AssetInfo actualAsset) { + assertNotNull(message, actualAsset); + assertEquals(message + " Name", testName, actualAsset.getName()); + assertEquals(message + " AlternateId", altId, actualAsset.getAlternateId()); + assertEquals(message + " Options", encryptionOption, actualAsset.getOptions()); + assertEquals(message + " State", assetState, actualAsset.getState()); + if (id != null) { + assertEquals(message + " Id", id, actualAsset.getId()); + } + if (created != null) { + assertEquals(message + " Created", created, actualAsset.getCreated()); + } + if (lastModified != null) { + assertEquals(message + " LastModified", lastModified, actualAsset.getLastModified()); + } + } + + @Test + public void createAssetSuccess() throws Exception { + // Arrange + String testName = testAssetPrefix + "Name"; + CreateAssetOptions options = new CreateAssetOptions().setName(testName); + + // Act + AssetInfo actualAsset = service.createAsset(options); + + // Assert + verifyAssetProperties("actualAsset", testName, "", EncryptionOption.None, AssetState.Initialized, actualAsset); + } + + @Test + public void createAssetOptionsSuccess() throws Exception { + // Arrange + String testName = testAssetPrefix + "createAssetOptionsSuccess"; + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState).setName(testName); + + // Act + AssetInfo actualAsset = service.createAsset(options); + + // Assert + verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); + } + + @Test + public void createAssetMeanString() throws Exception { + // Arrange + String meanString = "'\"(?++\\+&==/&?''$@:// +ne <some><XML></stuff>" + + "{\"jsonLike\":\"Created\":\"\\/Date(1336368841597)\\/\",\"Name\":null,cksum value\"}}" + + "Some unicode: \uB2E4\uB974\uB2E4\uB294\u0625 \u064A\u062F\u064A\u0648\u0009\r\n"; + + String testName = testAssetPrefix + "createAssetMeanString" + meanString; + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(testName); + + // Act + AssetInfo actualAsset = service.createAsset(createAssetOptions); + + // Assert + assertEquals("actualAsset Name", testName, actualAsset.getName()); + } + + @Test + public void createAssetNullNameSuccess() throws Exception { + // Arrange + + // Act + AssetInfo actualAsset = null; + try { + actualAsset = service.createAsset(); + // Assert + assertNotNull("actualAsset", actualAsset); + assertEquals("actualAsset.getName() should be the service default value, the empty string", "", + actualAsset.getName()); + } + finally { + // Clean up the anonymous asset now while we have the id, because we + // do not want to delete all anonymous assets in the bulk-cleanup code. + try { + if (actualAsset != null) { + service.deleteAsset(actualAsset.getId()); + } + } + catch (ServiceException ex) { + ex.printStackTrace(); + } + } + } + + @Test + public void getAssetSuccess() throws Exception { + // Arrange + String testName = testAssetPrefix + "GetAssetSuccess"; + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState).setName(testName); + AssetInfo assetInfo = service.createAsset(options); + + // Act + AssetInfo actualAsset = service.getAsset(assetInfo.getId()); + + assertEquals("Id", assetInfo.getId(), actualAsset.getId()); + verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); + } + + @Test + public void getAssetFailedWithInvalidId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAsset(validButNonexistAssetId); + } + + @Test + public void listAssetSuccess() throws ServiceException { + // Arrange + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + + String[] assetNames = new String[] { testAssetPrefix + "assetA", testAssetPrefix + "assetB" }; + List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); + for (int i = 0; i < assetNames.length; i++) { + String name = assetNames[i]; + CreateAssetOptions options = new CreateAssetOptions().setName(name).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState); + expectedAssets.add(service.createAsset(options)); + } + + // Act + Collection<AssetInfo> listAssetResult = service.listAssets(); + + // Assert + + verifyListResultContains("listAssets", expectedAssets, listAssetResult, new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyInfosEqual(message, (AssetInfo) expected, (AssetInfo) actual); + } + }); + } + + @Ignore + // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 + @Test + public void updateAssetSuccess() throws Exception { + // Arrange + String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; + CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") + .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published).setName(originalTestName); + AssetInfo originalAsset = service.createAsset(originalOptions); + + String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; + String altId = "otherAltId"; + EncryptionOption encryptionOption = EncryptionOption.None; + AssetState assetState = AssetState.Initialized; + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState); + + // Act + service.updateAsset(originalAsset.getId(), updateAssetOptions); + AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); + + // Assert + verifyAssetProperties("updatedAsset", updatedTestName, altId, encryptionOption, assetState, updatedAsset); + } + + @Test + public void updateAssetNoChangesSuccess() throws Exception { + // Arrange + String originalTestName = testAssetPrefix + "updateAssetNoChangesSuccess"; + String altId = "altId"; + EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetState assetState = AssetState.Published; + CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState).setName(originalTestName); + AssetInfo originalAsset = service.createAsset(options); + + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + service.updateAsset(originalAsset.getId(), updateAssetOptions); + AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); + + // Assert + verifyAssetProperties("updatedAsset", originalTestName, altId, encryptionOption, assetState, updatedAsset); + } + + @Test + public void updateAssetFailedWithInvalidId() throws ServiceException { + // Arrange + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + + // Act + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.updateAsset(validButNonexistAssetId, updateAssetOptions); + } + + @Test + public void deleteAssetSuccess() throws Exception { + // Arrange + String assetName = "deleteAssetSuccess"; + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(assetName); + AssetInfo assetInfo = service.createAsset(createAssetOptions); + List<AssetInfo> listAssetsResult = service.listAssets(); + int assetCountBaseline = listAssetsResult.size(); + + // Act + service.deleteAsset(assetInfo.getId()); + + // Assert + listAssetsResult = service.listAssets(); + assertEquals("listAssetsResult.size", assetCountBaseline - 1, listAssetsResult.size()); + + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAsset(assetInfo.getId()); + } + + @Test + public void deleteAssetFailedWithInvalidId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.deleteAsset(validButNonexistAssetId); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java new file mode 100644 index 0000000000000..501e35c96a2c5 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -0,0 +1,217 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; + +public class LocatorIntegrationTests extends IntegrationTestBase { + + private AssetInfo assetInfo; + private AccessPolicyInfo accessPolicyInfo; + private AccessPolicyInfo accessPolicyInfoRead; + + private void setupForLocatorTest() throws ServiceException { + assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); + accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5); + accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, + new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ)); + } + + @Test + public void createLocatorSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + + } + + @Ignore("due to media service bug 596240") + @Test + public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + Date expectedExpirationDateTime = new Date(); + expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 1000); + createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + assertEquals(expectedExpirationDateTime, locatorInfo.getExpirationDateTime()); + + } + + @Test + public void createLocatorSetStartTimeSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + Date expectedStartDateTime = new Date(); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 1000); + createLocatorOptions.setStartTime(expectedStartDateTime); + LocatorType locatorType = LocatorType.SAS; + + // Act + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Assert + assertNotNull(locatorInfo); + assertNotNull(locatorInfo.getId()); + assertEquals(expectedStartDateTime, locatorInfo.getStartTime()); + + } + + @Ignore("due to media service bug 596238") + @Test + public void getLocatorSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorType locatorType = LocatorType.SAS; + LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType, createLocatorOptions); + + // Act + LocatorInfo actualLocatorInfo = service.getLocator(expectedLocatorInfo.getId()); + + // Assert + assertNotNull(actualLocatorInfo); + assertEquals(expectedLocatorInfo.getAccessPolicyId(), actualLocatorInfo.getAccessPolicyId()); + assertEquals(expectedLocatorInfo.getAssetId(), actualLocatorInfo.getAssetId()); + assertEquals(expectedLocatorInfo.getExpirationDateTime(), actualLocatorInfo.getExpirationDateTime()); + assertEquals(expectedLocatorInfo.getId(), actualLocatorInfo.getId()); + assertEquals(expectedLocatorInfo.getLocatorType(), actualLocatorInfo.getLocatorType()); + assertEquals(expectedLocatorInfo.getPath(), actualLocatorInfo.getPath()); + assertEquals(expectedLocatorInfo.getStartTime(), actualLocatorInfo.getStartTime()); + + } + + @Test + public void listLocatorsSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + LocatorType locatorType = LocatorType.SAS; + List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); + for (int i = 0; i < 2; i++) { + expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType)); + } + + // Act + ListLocatorsResult listLocatorsResult = service.listLocators(); + + // Assert + assertNotNull(listLocatorsResult); + verifyListResultContains("listLocators", expectedLocators, listLocatorsResult.getLocatorInfos(), null); + } + + @Ignore("due to media service bug 596264") + @Test + public void updateLocatorSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + + LocatorType locatorTypeExepcted = LocatorType.Origin; + LocatorType locatorType = LocatorType.Origin; + + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + Date expirationDateTime = new Date(); + expirationDateTime.setTime(expirationDateTime.getTime() + 1000); + + // Act + UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() + .setExpirationDateTime(expirationDateTime); + service.updateLocator(locatorInfo.getId(), updateLocatorOptions); + + // Assert + LocatorInfo locatorInfoActual = service.getLocator(locatorInfo.getId()); + assertEquals(locatorTypeExepcted, locatorInfoActual.getLocatorType()); + assertEquals(expirationDateTime, locatorInfoActual.getExpirationDateTime()); + + } + + @Test + public void deleteLocatorSuccess() throws ServiceException { + // Arrange + setupForLocatorTest(); + LocatorType locatorType = LocatorType.SAS; + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + createLocatorOptions); + + // Act + service.deleteLocator(locatorInfo.getId()); + + // Assert + LocatorInfo locatorInfoResult = null; + try { + locatorInfoResult = service.getLocator(locatorInfo.getId()); + } + catch (ServiceException e) { + // swallow + } + assertNull(locatorInfoResult); + } + + @Test(expected = ServiceException.class) + public void deleteLocatorInvalidIdFailed() throws ServiceException { + // Arrange + + // Act + service.deleteLocator("invalidLocatorId"); + + // Assert + assertTrue(false); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index df2dc70e76dc0..12ff145aa7f1a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -15,453 +15,5 @@ package com.microsoft.windowsazure.services.media; -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import org.junit.Ignore; -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.AssetState; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; -import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; - public class MediaServiceIntegrationTest extends IntegrationTestBase { - - private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actual) { - verifyAssetProperties(message, expected.getName(), expected.getAlternateId(), expected.getOptions(), - expected.getState(), actual); - } - - private void verifyAssetProperties(String message, String testName, String altId, - EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { - verifyAssetProperties(message, testName, altId, encryptionOption, assetState, null, null, null, actualAsset); - } - - private void verifyAssetProperties(String message, String testName, String altId, - EncryptionOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, - AssetInfo actualAsset) { - assertNotNull(message, actualAsset); - assertEquals(message + " Name", testName, actualAsset.getName()); - assertEquals(message + " AlternateId", altId, actualAsset.getAlternateId()); - assertEquals(message + " Options", encryptionOption, actualAsset.getOptions()); - assertEquals(message + " State", assetState, actualAsset.getState()); - if (id != null) { - assertEquals(message + " Id", id, actualAsset.getId()); - } - if (created != null) { - assertEquals(message + " Created", created, actualAsset.getCreated()); - } - if (lastModified != null) { - assertEquals(message + " LastModified", lastModified, actualAsset.getLastModified()); - } - } - - @Test - public void createAssetSuccess() throws Exception { - // Arrange - String testName = testAssetPrefix + "Name"; - CreateAssetOptions options = new CreateAssetOptions().setName(testName); - - // Act - AssetInfo actualAsset = service.createAsset(options); - - // Assert - verifyAssetProperties("actualAsset", testName, "", EncryptionOption.None, AssetState.Initialized, actualAsset); - } - - @Test - public void createAssetOptionsSuccess() throws Exception { - // Arrange - String testName = testAssetPrefix + "createAssetOptionsSuccess"; - String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(testName); - - // Act - AssetInfo actualAsset = service.createAsset(options); - - // Assert - verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); - } - - @Test - public void createAssetMeanString() throws Exception { - // Arrange - String meanString = "'\"(?++\\+&==/&?''$@:// +ne <some><XML></stuff>" - + "{\"jsonLike\":\"Created\":\"\\/Date(1336368841597)\\/\",\"Name\":null,cksum value\"}}" - + "Some unicode: \uB2E4\uB974\uB2E4\uB294\u0625 \u064A\u062F\u064A\u0648\u0009\r\n"; - - String testName = testAssetPrefix + "createAssetMeanString" + meanString; - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(testName); - - // Act - AssetInfo actualAsset = service.createAsset(createAssetOptions); - - // Assert - assertEquals("actualAsset Name", testName, actualAsset.getName()); - } - - @Test - public void createAssetNullNameSuccess() throws Exception { - // Arrange - - // Act - AssetInfo actualAsset = null; - try { - actualAsset = service.createAsset(); - // Assert - assertNotNull("actualAsset", actualAsset); - assertEquals("actualAsset.getName() should be the service default value, the empty string", "", - actualAsset.getName()); - } - finally { - // Clean up the anonymous asset now while we have the id, because we - // do not want to delete all anonymous assets in the bulk-cleanup code. - try { - if (actualAsset != null) { - service.deleteAsset(actualAsset.getId()); - } - } - catch (ServiceException ex) { - ex.printStackTrace(); - } - } - } - - @Test - public void getAssetSuccess() throws Exception { - // Arrange - String testName = testAssetPrefix + "GetAssetSuccess"; - String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(testName); - AssetInfo assetInfo = service.createAsset(options); - - // Act - AssetInfo actualAsset = service.getAsset(assetInfo.getId()); - - assertEquals("Id", assetInfo.getId(), actualAsset.getId()); - verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); - } - - @Test - public void getAssetFailedWithInvalidId() throws ServiceException { - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(validButNonexistAssetId); - } - - @Test - public void listAssetSuccess() throws ServiceException { - // Arrange - String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - AssetState assetState = AssetState.Published; - - String[] assetNames = new String[] { testAssetPrefix + "assetA", testAssetPrefix + "assetB" }; - List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); - for (int i = 0; i < assetNames.length; i++) { - String name = assetNames[i]; - CreateAssetOptions options = new CreateAssetOptions().setName(name).setAlternateId(altId) - .setOptions(encryptionOption).setState(assetState); - expectedAssets.add(service.createAsset(options)); - } - - // Act - Collection<AssetInfo> listAssetResult = service.listAssets(); - - // Assert - - verifyListResultContains("listAssets", expectedAssets, listAssetResult, new ComponentDelegate() { - @Override - public void verifyEquals(String message, Object expected, Object actual) { - verifyInfosEqual(message, (AssetInfo) expected, (AssetInfo) actual); - } - }); - } - - @Ignore - // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 - @Test - public void updateAssetSuccess() throws Exception { - // Arrange - String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; - CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") - .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published).setName(originalTestName); - AssetInfo originalAsset = service.createAsset(originalOptions); - - String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; - String altId = "otherAltId"; - EncryptionOption encryptionOption = EncryptionOption.None; - AssetState assetState = AssetState.Initialized; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId) - .setOptions(encryptionOption).setState(assetState); - - // Act - service.updateAsset(originalAsset.getId(), updateAssetOptions); - AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); - - // Assert - verifyAssetProperties("updatedAsset", updatedTestName, altId, encryptionOption, assetState, updatedAsset); - } - - @Test - public void updateAssetNoChangesSuccess() throws Exception { - // Arrange - String originalTestName = testAssetPrefix + "updateAssetNoChangesSuccess"; - String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(originalTestName); - AssetInfo originalAsset = service.createAsset(options); - - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - service.updateAsset(originalAsset.getId(), updateAssetOptions); - AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); - - // Assert - verifyAssetProperties("updatedAsset", originalTestName, altId, encryptionOption, assetState, updatedAsset); - } - - @Test - public void updateAssetFailedWithInvalidId() throws ServiceException { - // Arrange - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.updateAsset(validButNonexistAssetId, updateAssetOptions); - } - - @Test - public void deleteAssetSuccess() throws Exception { - // Arrange - String assetName = "deleteAssetSuccess"; - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(assetName); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - List<AssetInfo> listAssetsResult = service.listAssets(); - int assetCountBaseline = listAssetsResult.size(); - - // Act - service.deleteAsset(assetInfo.getId()); - - // Assert - listAssetsResult = service.listAssets(); - assertEquals("listAssetsResult.size", assetCountBaseline - 1, listAssetsResult.size()); - - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(assetInfo.getId()); - } - - @Test - public void deleteAssetFailedWithInvalidId() throws ServiceException { - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.deleteAsset(validButNonexistAssetId); - } - - // End of Asset tests - - // Start of Locator tests - - private AssetInfo assetInfo; - private AccessPolicyInfo accessPolicyInfo; - private AccessPolicyInfo accessPolicyInfoRead; - - private void setupForLocatorTest() throws ServiceException { - assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); - accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5); - accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, - new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ)); - } - - @Test - public void createLocatorSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorType locatorType = LocatorType.SAS; - - // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - - // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); - - } - - @Ignore("due to media service bug 596240") - @Test - public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - Date expectedExpirationDateTime = new Date(); - expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 1000); - createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); - LocatorType locatorType = LocatorType.SAS; - - // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - - // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); - assertEquals(expectedExpirationDateTime, locatorInfo.getExpirationDateTime()); - - } - - @Test - public void createLocatorSetStartTimeSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - Date expectedStartDateTime = new Date(); - expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 1000); - createLocatorOptions.setStartTime(expectedStartDateTime); - LocatorType locatorType = LocatorType.SAS; - - // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - - // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); - assertEquals(expectedStartDateTime, locatorInfo.getStartTime()); - - } - - @Ignore("due to media service bug 596238") - @Test - public void getLocatorSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorType locatorType = LocatorType.SAS; - LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), - locatorType, createLocatorOptions); - - // Act - LocatorInfo actualLocatorInfo = service.getLocator(expectedLocatorInfo.getId()); - - // Assert - assertNotNull(actualLocatorInfo); - assertEquals(expectedLocatorInfo.getAccessPolicyId(), actualLocatorInfo.getAccessPolicyId()); - assertEquals(expectedLocatorInfo.getAssetId(), actualLocatorInfo.getAssetId()); - assertEquals(expectedLocatorInfo.getExpirationDateTime(), actualLocatorInfo.getExpirationDateTime()); - assertEquals(expectedLocatorInfo.getId(), actualLocatorInfo.getId()); - assertEquals(expectedLocatorInfo.getLocatorType(), actualLocatorInfo.getLocatorType()); - assertEquals(expectedLocatorInfo.getPath(), actualLocatorInfo.getPath()); - assertEquals(expectedLocatorInfo.getStartTime(), actualLocatorInfo.getStartTime()); - - } - - @Test - public void listLocatorsSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - LocatorType locatorType = LocatorType.SAS; - List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); - for (int i = 0; i < 2; i++) { - expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType)); - } - - // Act - ListLocatorsResult listLocatorsResult = service.listLocators(); - - // Assert - assertNotNull(listLocatorsResult); - verifyListResultContains("listLocators", expectedLocators, listLocatorsResult.getLocatorInfos(), null); - } - - @Ignore("due to media service bug 596264") - @Test - public void updateLocatorSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - - LocatorType locatorTypeExepcted = LocatorType.Origin; - LocatorType locatorType = LocatorType.Origin; - - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - Date expirationDateTime = new Date(); - expirationDateTime.setTime(expirationDateTime.getTime() + 1000); - - // Act - UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() - .setExpirationDateTime(expirationDateTime); - service.updateLocator(locatorInfo.getId(), updateLocatorOptions); - - // Assert - LocatorInfo locatorInfoActual = service.getLocator(locatorInfo.getId()); - assertEquals(locatorTypeExepcted, locatorInfoActual.getLocatorType()); - assertEquals(expirationDateTime, locatorInfoActual.getExpirationDateTime()); - - } - - @Test - public void deleteLocatorSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - LocatorType locatorType = LocatorType.SAS; - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - - // Act - service.deleteLocator(locatorInfo.getId()); - - // Assert - LocatorInfo locatorInfoResult = null; - try { - locatorInfoResult = service.getLocator(locatorInfo.getId()); - } - catch (ServiceException e) { - // swallow - } - assertNull(locatorInfoResult); - } - - @Test(expected = ServiceException.class) - public void deleteLocatorInvalidIdFailed() throws ServiceException { - // Arrange - - // Act - service.deleteLocator("invalidLocatorId"); - - // Assert - assertTrue(false); - } } From 475eefb69856f83417b224ef70eacb6831b80a12 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 17 Oct 2012 16:36:13 -0700 Subject: [PATCH 394/664] address code review feedback. --- .../services/media/implementation/MediaRestProxy.java | 4 ++++ .../services/media/models/ListMediaProcessorsOptions.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index a76124b9c8745..7f0cdba89fbda 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -474,6 +474,10 @@ public ListMediaProcessorsResult listMediaProcessors() { public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { WebResource resource = getResource("MediaProcessors"); + if ((listMediaProcessorsOptions != null) && (listMediaProcessorsOptions.getQueryParameters() != null)) { + resource = resource.queryParams(listMediaProcessorsOptions.getQueryParameters()); + } + List<MediaProcessorInfo> mediaProcessorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<MediaProcessorInfo>>() { }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java index 129bf5f4ae195..1e580ab757945 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java @@ -17,6 +17,6 @@ /** * The Class ListLocatorsOptions. */ -public class ListMediaProcessorsOptions { +public class ListMediaProcessorsOptions extends ListOptions { } From fe6690c1e4f8c7d73c577f27178a4977b1265ac4 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 17 Oct 2012 17:54:28 -0700 Subject: [PATCH 395/664] Made access policy permissions mandatory, not optional with default to write. Fix for issue #370 --- .../services/media/MediaContract.java | 22 +---- .../MediaExceptionProcessor.java | 24 +---- .../media/implementation/MediaRestProxy.java | 19 +--- .../models/CreateAccessPolicyOptions.java | 84 ---------------- .../media/AccessPolicyIntegrationTest.java | 25 ++--- .../media/MediaServiceIntegrationTest.java | 8 +- .../media/UploadingIntegrationTest.java | 4 +- .../models/CreateAccessPolicyOptionsTest.java | 97 ------------------- 8 files changed, 25 insertions(+), 258 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 7737f99b5b145..ea88db2db838a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -14,13 +14,14 @@ */ package com.microsoft.windowsazure.services.media; +import java.util.EnumSet; import java.util.List; import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; @@ -120,27 +121,14 @@ public interface MediaContract extends FilterableService<MediaContract> { * name of access policy * @param durationInMinutes * Duration in minutes that blob access will be granted when using this access policy + * @param permissions + * Permissions that the access policy should grant. * @return Created access policy * @throws ServiceException * the service exception */ - AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) throws ServiceException; - - /** - * Create the access policy with the given options. - * - * @param accessPolicyName - * name of access policy - * @param durationInMinutes - * Duration in minutes that blob access will be granted when using this access policy - * @param options - * options for creation - * @return the created access policy - * @throws ServiceException - * the service exception - */ AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - CreateAccessPolicyOptions options) throws ServiceException; + EnumSet<AccessPolicyPermission> permissions) throws ServiceException; /** * Delete the access policy with the given id. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 0a89ea0ae8c42..411746d7b3599 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.util.EnumSet; import java.util.List; import javax.inject.Inject; @@ -27,8 +28,8 @@ import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; @@ -214,27 +215,10 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) */ @Override - public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) - throws ServiceException { - try { - return service.createAccessPolicy(accessPolicyName, durationInMinutes); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) - */ - @Override public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - CreateAccessPolicyOptions options) throws ServiceException { + EnumSet<AccessPolicyPermission> permissions) throws ServiceException { try { - return service.createAccessPolicy(accessPolicyName, durationInMinutes, options); + return service.createAccessPolicy(accessPolicyName, durationInMinutes, permissions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 656f1e70d4a05..76e29b846a378 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -38,7 +38,6 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; @@ -295,29 +294,15 @@ public void deleteAsset(String assetId) throws ServiceException { getResource("Assets", assetId).delete(); } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) - */ - @Override - public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes) - throws ServiceException { - return createAccessPolicy(accessPolicyName, durationInMinutes, null); - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) */ @Override public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - CreateAccessPolicyOptions options) throws ServiceException { - - if (options == null) { - options = new CreateAccessPolicyOptions().addPermissions(EnumSet.of(AccessPolicyPermission.WRITE)); - } + EnumSet<AccessPolicyPermission> permissions) throws ServiceException { AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes) - .setName(accessPolicyName) - .setPermissions(AccessPolicyPermission.bitsFromPermissions(options.getPermissions())); + .setName(accessPolicyName).setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); WebResource resource = getResource("AccessPolicies"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java deleted file mode 100644 index 7c003d2e0cd02..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.EnumSet; - -public class CreateAccessPolicyOptions { - private final EnumSet<AccessPolicyPermission> permissions = EnumSet.noneOf(AccessPolicyPermission.class); - - public CreateAccessPolicyOptions() { - } - - /** - * Returns a live pointer to the underlying permissions set. - * - * @return the permissions - */ - public EnumSet<AccessPolicyPermission> getPermissions() { - return permissions; - } - - /** - * Add the given permissions to this creation request - * - * @param permissionsToAdd - * @return the CreateAccessPolicyOptions object - */ - public CreateAccessPolicyOptions addPermissions(EnumSet<AccessPolicyPermission> permissionsToAdd) { - permissions.addAll(permissionsToAdd); - return this; - } - - /** - * Add the given permissions to this creation request - * - * @param permissionsToAdd - * varargs - permissions to add - * @return the CreateAccessPolicyOptions object - */ - public CreateAccessPolicyOptions addPermissions(AccessPolicyPermission... permissionsToAdd) { - for (AccessPolicyPermission permission : permissionsToAdd) { - permissions.add(permission); - } - return this; - } - - /** - * Remove the given permissions from this creation request - * - * @param permissionsToRemove - * @return the CreateAccessPolicyOptions object - */ - public CreateAccessPolicyOptions removePermissions(EnumSet<AccessPolicyPermission> permissionsToRemove) { - permissions.removeAll(permissionsToRemove); - return this; - } - - /** - * Remove the given permissions from this creation request - * - * @param permissionsToRemove - * vararg - permissions to remove - * @return the CreateAccessPolicyOptions object - */ - public CreateAccessPolicyOptions removePermissions(AccessPolicyPermission... permissionsToRemove) { - for (AccessPolicyPermission permission : permissionsToRemove) { - permissions.remove(permission); - } - return this; - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 22ee42d3743a3..0407e08c8a44c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -27,7 +27,6 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; public class AccessPolicyIntegrationTest extends IntegrationTestBase { private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) { @@ -69,30 +68,20 @@ public void canCreateAccessPolicy() throws Exception { String testName = testPolicyPrefix + "CanCreate"; double duration = 5; - AccessPolicyInfo policy = service.createAccessPolicy(testName, duration); + AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, + EnumSet.of(AccessPolicyPermission.WRITE)); verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.WRITE, policy); } - @Test - public void canCreateAccessPolicyOptions() throws Exception { - String testName = testPolicyPrefix + "CanCreateOptions"; - double duration = 5; - AccessPolicyPermission permission = AccessPolicyPermission.READ; - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(permission); - - AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, options); - - verifyPolicyProperties("policy", testName, duration, permission, policy); - } - // TODO: Null name or duration? @Test public void canGetSinglePolicyById() throws Exception { String expectedName = testPolicyPrefix + "GetOne"; double duration = 1; - AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, duration); + AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, duration, + EnumSet.of(AccessPolicyPermission.WRITE)); AccessPolicyInfo retrievedPolicy = service.getAccessPolicy(policyToGet.getId()); @@ -123,8 +112,7 @@ public void canRetrieveListOfAccessPolicies() throws Exception { List<AccessPolicyInfo> expectedAccessPolicies = new ArrayList<AccessPolicyInfo>(); for (int i = 0; i < policyNames.length; i++) { - AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, - new CreateAccessPolicyOptions().addPermissions(permissions)); + AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, permissions); expectedAccessPolicies.add(policy); } @@ -145,7 +133,8 @@ public void verifyEquals(String message, Object expected, Object actual) { public void canDeleteAccessPolicyById() throws Exception { String policyName = testPolicyPrefix + "ToDelete"; double duration = 1; - AccessPolicyInfo policyToDelete = service.createAccessPolicy(policyName, duration); + AccessPolicyInfo policyToDelete = service.createAccessPolicy(policyName, duration, + EnumSet.of(AccessPolicyPermission.WRITE)); List<AccessPolicyInfo> listPoliciesResult = service.listAccessPolicies(); int policyCountBaseline = listPoliciesResult.size(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index bc5dce4cd103b..22eb4369ad3dc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.EnumSet; import java.util.List; import org.junit.Ignore; @@ -30,7 +31,6 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; @@ -318,9 +318,10 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { private void setupForLocatorTest() throws ServiceException { assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); - accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5); + accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5, + EnumSet.of(AccessPolicyPermission.WRITE)); accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, - new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ)); + EnumSet.of(AccessPolicyPermission.READ)); } @Test @@ -488,6 +489,7 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException { // Assert assertTrue(false); } + @Test public void listMediaProcessorsSuccess() throws ServiceException { // Arrange diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index daad8339c1a78..a76f081ff94ab 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -18,6 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Date; +import java.util.EnumSet; import org.junit.Test; @@ -26,7 +27,6 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -45,7 +45,7 @@ public void canUploadBlockBlob() throws Exception { AssetInfo asset = service.createAsset(new CreateAssetOptions().setName("uploadBlockBlobAsset")); AccessPolicyInfo policy = service.createAccessPolicy("uploadWritePolicy", 10, - new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.WRITE)); + EnumSet.of(AccessPolicyPermission.WRITE)); Date now = new Date(); Date fiveMinutesAgo = new Date(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java deleted file mode 100644 index f5b578d40e789..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAccessPolicyOptionsTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import java.util.EnumSet; - -import org.junit.Test; - -public class CreateAccessPolicyOptionsTest { - - private static void assertPermissions(EnumSet<AccessPolicyPermission> expected, - EnumSet<AccessPolicyPermission> actual) { - assertTrue(actual.containsAll(expected)); - assertTrue(EnumSet.complementOf(actual).containsAll(EnumSet.complementOf(expected))); - } - - @Test - public void optionsCreatedWithNoPermissions() throws Exception { - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); - - assertPermissions(EnumSet.noneOf(AccessPolicyPermission.class), options.getPermissions()); - } - - @Test - public void canGetSetPermissionsAsEnumSet() throws Exception { - EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.LIST, - AccessPolicyPermission.DELETE); - - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions(); - - options.addPermissions(expectedPermissions); - - EnumSet<AccessPolicyPermission> permissions = options.getPermissions(); - - assertPermissions(expectedPermissions, permissions); - } - - @Test - public void canGetSetPermissionsAsVarargs() throws Exception { - EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.READ, - AccessPolicyPermission.WRITE); - - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(AccessPolicyPermission.READ, - AccessPolicyPermission.WRITE); - - EnumSet<AccessPolicyPermission> permissions = options.getPermissions(); - - assertPermissions(expectedPermissions, permissions); - } - - @Test - public void canRemovePermissionsAsEnumSet() throws Exception { - EnumSet<AccessPolicyPermission> originalPermissions = EnumSet.of(AccessPolicyPermission.READ, - AccessPolicyPermission.WRITE, AccessPolicyPermission.DELETE); - EnumSet<AccessPolicyPermission> permissionsToRemove = EnumSet.of(AccessPolicyPermission.READ, - AccessPolicyPermission.DELETE); - EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.WRITE); - - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(originalPermissions); - - options.removePermissions(permissionsToRemove); - - EnumSet<AccessPolicyPermission> actualPermissions = options.getPermissions(); - - assertPermissions(expectedPermissions, actualPermissions); - } - - @Test - public void canRemovePermissionsAsVarargs() throws Exception { - EnumSet<AccessPolicyPermission> originalPermissions = EnumSet.of(AccessPolicyPermission.READ, - AccessPolicyPermission.WRITE, AccessPolicyPermission.DELETE); - EnumSet<AccessPolicyPermission> expectedPermissions = EnumSet.of(AccessPolicyPermission.WRITE); - - CreateAccessPolicyOptions options = new CreateAccessPolicyOptions().addPermissions(originalPermissions); - - options.removePermissions(AccessPolicyPermission.READ, AccessPolicyPermission.DELETE); - - EnumSet<AccessPolicyPermission> actualPermissions = options.getPermissions(); - - assertPermissions(expectedPermissions, actualPermissions); - } -} From 737f754010bc799c5b109165496cc65b880c1ee1 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 18 Oct 2012 09:59:23 -0700 Subject: [PATCH 396/664] Added a test of read permissions at tester's request --- .../services/media/AccessPolicyIntegrationTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 0407e08c8a44c..a01c98174e99b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -74,6 +74,17 @@ public void canCreateAccessPolicy() throws Exception { verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.WRITE, policy); } + @Test + public void canCreateAccessPolicyWithReadPermissions() throws Exception { + String testName = testPolicyPrefix + "CanCreateRead"; + double duration = 5; + + AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, + EnumSet.of(AccessPolicyPermission.READ)); + + verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.READ, policy); + } + // TODO: Null name or duration? @Test From 62b6b502c987ad494f0c7a40ceb31a3275ea6c08 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 18 Oct 2012 10:51:36 -0700 Subject: [PATCH 397/664] fix the failing unit test --- .../media/implementation/content/MediaProcessorType.java | 2 +- .../services/media/models/MediaProcessorInfoTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java index f76d61e200192..de8338173a9b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -100,7 +100,7 @@ public void setVendor(String vendor) { } public String getVersion() { - return null; + return this.version; } public void setVersion(String version) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java index c681bf4cfbaf1..c247486b1c482 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -95,7 +95,7 @@ public void testGetSetVersion() { MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); // Act - String actualVersion = mediaProcessorInfo.setName(expectedVersion).getVersion(); + String actualVersion = mediaProcessorInfo.setVersion(expectedVersion).getVersion(); // Assert assertEquals(expectedVersion, actualVersion); From 6670f821c0e39c408d2cb61a09837b4708746847 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 18 Oct 2012 11:12:41 -0700 Subject: [PATCH 398/664] Removed use of XMLGregorianCalendar --- .../services/core/utils/DateConverter.java | 72 ------------------- .../implementation/content/AssetType.java | 20 +++--- .../services/media/models/AssetInfo.java | 9 ++- 3 files changed, 14 insertions(+), 87 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java deleted file mode 100644 index ee00445cf6b61..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateConverter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.core.utils; - -import java.util.Date; -import java.util.GregorianCalendar; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; - -/** - * The Class DateConverter. - */ -public class DateConverter { - - /** The datatype factory. */ - private static DatatypeFactory datatypeFactory = null; - - static { - try { - datatypeFactory = DatatypeFactory.newInstance(); - } - catch (DatatypeConfigurationException e) { - throw new IllegalStateException("Cannot create a new DatatypeFactory instance.", e); - } - } - - /** - * XML gregorian calendar to date. - * - * @param xmlGregorianCalendar - * the xml gregorian calendar - * @return the date - */ - public static Date XMLGregorianCalendarToDate(XMLGregorianCalendar xmlGregorianCalendar) { - if (xmlGregorianCalendar == null) { - return null; - } - - return xmlGregorianCalendar.toGregorianCalendar().getTime(); - } - - /** - * Date to xml gregorian calendar. - * - * @param date - * the date - * @return the xML gregorian calendar - */ - public static XMLGregorianCalendar DateToXMLGregorianCalendar(Date date) { - if (date == null) { - return null; - } - - GregorianCalendar gregorianCalendar = new GregorianCalendar(); - gregorianCalendar.setTimeInMillis(date.getTime()); - return datatypeFactory.newXMLGregorianCalendar(gregorianCalendar); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 9d48dfd71a29a..1ba35bb91d954 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -15,12 +15,12 @@ package com.microsoft.windowsazure.services.media.implementation.content; +import java.util.Date; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.datatype.XMLGregorianCalendar; -import com.microsoft.windowsazure.services.core.utils.DateConverter; import com.microsoft.windowsazure.services.media.models.AssetInfo; /** @@ -38,10 +38,10 @@ public class AssetType implements MediaServiceDTO { protected int state; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - protected XMLGregorianCalendar created; + protected Date created; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - protected XMLGregorianCalendar lastModified; + protected Date lastModified; @XmlElement(name = "AlternateId", namespace = Constants.ODATA_DATA_NS) protected String alternateId; @@ -85,7 +85,7 @@ public void setState(int state) { /** * @return the created */ - public XMLGregorianCalendar getCreated() { + public Date getCreated() { return created; } @@ -93,14 +93,14 @@ public XMLGregorianCalendar getCreated() { * @param created * the created to set */ - public void setCreated(XMLGregorianCalendar created) { + public void setCreated(Date created) { this.created = created; } /** * @return the lastModified */ - public XMLGregorianCalendar getLastModified() { + public Date getLastModified() { return lastModified; } @@ -108,7 +108,7 @@ public XMLGregorianCalendar getLastModified() { * @param lastModified * the lastModified to set */ - public void setLastModified(XMLGregorianCalendar lastModified) { + public void setLastModified(Date lastModified) { this.lastModified = lastModified; } @@ -160,9 +160,9 @@ public void setOptions(int options) { public static AssetType create(AssetInfo assetInfo) { AssetType assetType = new AssetType(); assetType.setAlternateId(assetInfo.getAlternateId()); - assetType.setCreated(DateConverter.DateToXMLGregorianCalendar(assetInfo.getCreated())); + assetType.setCreated(assetInfo.getCreated()); assetType.setId(assetInfo.getId()); - assetType.setLastModified(DateConverter.DateToXMLGregorianCalendar(assetInfo.getLastModified())); + assetType.setLastModified(assetInfo.getLastModified()); assetType.setName(assetInfo.getName()); assetType.setOptions(assetInfo.getOptions().getCode()); assetType.setState(assetInfo.getState().getCode()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 736c2366a7d4b..fbc7862061fec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -17,7 +17,6 @@ import java.util.Date; -import com.microsoft.windowsazure.services.core.utils.DateConverter; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; @@ -105,7 +104,7 @@ public AssetInfo setState(AssetState state) { * @return the date */ public Date getCreated() { - return DateConverter.XMLGregorianCalendarToDate(this.getContent().getCreated()); + return this.getContent().getCreated(); } /** @@ -116,7 +115,7 @@ public Date getCreated() { * @return the asset info */ public AssetInfo setCreated(Date created) { - getContent().setCreated(DateConverter.DateToXMLGregorianCalendar(created)); + getContent().setCreated(created); return this; } @@ -126,7 +125,7 @@ public AssetInfo setCreated(Date created) { * @return the date */ public Date getLastModified() { - return DateConverter.XMLGregorianCalendarToDate(getContent().getLastModified()); + return getContent().getLastModified(); } /** @@ -137,7 +136,7 @@ public Date getLastModified() { * @return the asset info */ public AssetInfo setLastModified(Date lastModified) { - getContent().setLastModified(DateConverter.DateToXMLGregorianCalendar(lastModified)); + getContent().setLastModified(lastModified); return this; } From b4fcb0717f3b65cfbc7ac528911aec77654a65e0 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 10:20:32 -0700 Subject: [PATCH 399/664] Locator test cleanup, for workitem #279. - Add assert methods to test that dates are approximate equal, for verifying that dates are "close enough". Exact matching can be problematic because of clock skew and precision loss in serialization. - Replace one-off verification code with calls to more complete verification methods - Add more tests for verifying exception cases. --- .../services/media/IntegrationTestBase.java | 28 +- .../media/LocatorIntegrationTests.java | 241 ++++++++++++------ 2 files changed, 195 insertions(+), 74 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index b878f83fbd7b7..a90a8e428feb5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -5,6 +5,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.List; import org.junit.AfterClass; @@ -12,6 +13,7 @@ import org.junit.Rule; import org.junit.rules.ExpectedException; +import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; @@ -26,7 +28,8 @@ public abstract class IntegrationTestBase { protected static final String testPolicyPrefix = "testPolicy"; protected static final String validButNonexistAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; - protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:bce3863e-830b-49f5-9199-7cfaff52935f"; + protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:00000000-0000-4a00-0000-000000000000"; + protected static final String validButNonexistLocatorId = "nb:lid:UUID:00000000-0000-4a00-0000-000000000000"; protected static final String invalidId = "notAValidId"; @@ -154,4 +157,27 @@ protected <T> void verifyListResultContains(String message, List<T> expectedInfo } } } + + protected void assertDateApproxEquals(Date expected, Date actual) { + assertDateApproxEquals("", expected, actual); + } + + protected void assertDateApproxEquals(String message, Date expected, Date actual) { + // Default allows for a 30 seconds difference in dates. + long deltaInMilliseconds = 30000; + if (expected == null || actual == null) { + assertEquals(message, expected, actual); + } + else { + long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + if (diffInMilliseconds > deltaInMilliseconds) { + // Out of the range. Need to assert + // Use strings so the messages make more sense. + ISO8601DateConverter converter = new ISO8601DateConverter(); + String expectedString = converter.format(expected); + String actualString = converter.format(actual); + assertEquals(message, expectedString, actualString); + } + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 3256a9d2f798c..b593fc3c3ca7b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -22,6 +22,8 @@ import java.util.EnumSet; import java.util.List; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -31,6 +33,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -38,44 +41,87 @@ public class LocatorIntegrationTests extends IntegrationTestBase { - private AssetInfo assetInfo; - private AccessPolicyInfo accessPolicyInfo; - private AccessPolicyInfo accessPolicyInfoRead; + private static AssetInfo assetInfo; + private static AccessPolicyInfo accessPolicyInfo; + private static AccessPolicyInfo accessPolicyInfoRead; - private void setupForLocatorTest() throws ServiceException { - assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); + private Date calculateDefaultExpectedExpDate(AccessPolicyInfo accessPolicy, AssetInfo asset) { + return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * 60 * 1000); + } + + private void verifyLocatorInfosEqual(String message, LocatorInfo expected, LocatorInfo actual) { + verifyLocatorProperties(message, expected.getAccessPolicyId(), expected.getAssetId(), + expected.getLocatorType(), expected.getStartTime(), expected.getExpirationDateTime(), expected.getId(), + expected.getPath(), actual); + } + + private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, + LocatorType locatorType, Date startTime, Date expirationDateTime, LocatorInfo actualLocator) { + verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, expirationDateTime, null, + null, actualLocator); + } + + private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, + LocatorType locatorType, Date startTime, Date expirationDateTime, String id, String path, + LocatorInfo actualLocator) { + assertNotNull(message, actualLocator); + assertEquals(message + " accessPolicyId", accessPolicyId, actualLocator.getAccessPolicyId()); + assertEquals(message + " assetId", assetId, actualLocator.getAssetId()); + assertEquals(message + " locatorType", locatorType, actualLocator.getLocatorType()); + + assertDateApproxEquals(message + " startTime", startTime, actualLocator.getStartTime()); + assertDateApproxEquals(message + " expirationDateTime", expirationDateTime, + actualLocator.getExpirationDateTime()); + + if (id == null) { + assertNotNull(message + " Id", actualLocator.getId()); + } + else { + assertEquals(message + " Id", id, actualLocator.getId()); + } + if (path == null) { + assertNotNull(message + " path", actualLocator.getPath()); + } + else { + assertEquals(message + " path", path, actualLocator.getPath()); + } + } + + @BeforeClass + public static void setup() throws Exception { + IntegrationTestBase.setup(); accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5, EnumSet.of(AccessPolicyPermission.WRITE)); accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, EnumSet.of(AccessPolicyPermission.READ)); } + @Before + public void instanceSetup() throws Exception { + assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); + } + @Test public void createLocatorSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorType locatorType = LocatorType.SAS; + // Arrange + LocatorType locatorType = LocatorType.Origin; + Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfo, assetInfo); // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - - // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType); + // Assert + verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, null, + expectedExpirationDateTime, locatorInfo); } @Ignore("due to media service bug 596240") @Test - public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - + public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceException { + // Arrange CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedExpirationDateTime = new Date(); - expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 1000); + expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 10000); createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); LocatorType locatorType = LocatorType.SAS; @@ -84,20 +130,16 @@ public void createLocatorSetExpirationDateTimeSuccess() throws ServiceException createLocatorOptions); // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); - assertEquals(expectedExpirationDateTime, locatorInfo.getExpirationDateTime()); - + verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, null, + expectedExpirationDateTime, locatorInfo); } @Test - public void createLocatorSetStartTimeSuccess() throws ServiceException { - // Arrange - setupForLocatorTest(); - + public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { + // Arrange CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedStartDateTime = new Date(); - expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 1000); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 10000); createLocatorOptions.setStartTime(expectedStartDateTime); LocatorType locatorType = LocatorType.SAS; @@ -106,19 +148,22 @@ public void createLocatorSetStartTimeSuccess() throws ServiceException { createLocatorOptions); // Assert - assertNotNull(locatorInfo); - assertNotNull(locatorInfo.getId()); - assertEquals(expectedStartDateTime, locatorInfo.getStartTime()); - + verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, + expectedStartDateTime, null, locatorInfo); } @Ignore("due to media service bug 596238") @Test public void getLocatorSuccess() throws ServiceException { // Arrange - setupForLocatorTest(); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); LocatorType locatorType = LocatorType.SAS; + Date expectedStartDateTime = new Date(); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 10000); + Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + 10000); + + CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); + createLocatorOptions.setStartTime(expectedStartDateTime); + createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, createLocatorOptions); @@ -126,21 +171,26 @@ public void getLocatorSuccess() throws ServiceException { LocatorInfo actualLocatorInfo = service.getLocator(expectedLocatorInfo.getId()); // Assert - assertNotNull(actualLocatorInfo); - assertEquals(expectedLocatorInfo.getAccessPolicyId(), actualLocatorInfo.getAccessPolicyId()); - assertEquals(expectedLocatorInfo.getAssetId(), actualLocatorInfo.getAssetId()); - assertEquals(expectedLocatorInfo.getExpirationDateTime(), actualLocatorInfo.getExpirationDateTime()); - assertEquals(expectedLocatorInfo.getId(), actualLocatorInfo.getId()); - assertEquals(expectedLocatorInfo.getLocatorType(), actualLocatorInfo.getLocatorType()); - assertEquals(expectedLocatorInfo.getPath(), actualLocatorInfo.getPath()); - assertEquals(expectedLocatorInfo.getStartTime(), actualLocatorInfo.getStartTime()); + verifyLocatorInfosEqual("actualLocatorInfo", expectedLocatorInfo, actualLocatorInfo); + } + @Test + public void getLocatorInvalidId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAsset(invalidId); + } + + @Test + public void getLocatorNonexistId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getAsset(validButNonexistLocatorId); } @Test public void listLocatorsSuccess() throws ServiceException { // Arrange - setupForLocatorTest(); LocatorType locatorType = LocatorType.SAS; List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); for (int i = 0; i < 2; i++) { @@ -152,67 +202,112 @@ public void listLocatorsSuccess() throws ServiceException { // Assert assertNotNull(listLocatorsResult); - verifyListResultContains("listLocators", expectedLocators, listLocatorsResult.getLocatorInfos(), null); + verifyListResultContains("listLocatorsResult", expectedLocators, listLocatorsResult.getLocatorInfos(), + new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyLocatorInfosEqual(message, (LocatorInfo) expected, (LocatorInfo) actual); + } + }); + } + + @Test + public void listLocatorsQuerySuccess() throws ServiceException { + // Arrange + LocatorType locatorType = LocatorType.SAS; + List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); + for (int i = 0; i < 2; i++) { + expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType)); + } + ListLocatorsOptions options = new ListLocatorsOptions(); + options.getQueryParameters().add("$query", "id eq " + expectedLocators.get(0).getId()); + + // Act + ListLocatorsResult listLocatorsResult = service.listLocators(options); + + // Assert + assertNotNull(listLocatorsResult); + verifyListResultContains("listLocatorsResult", expectedLocators, listLocatorsResult.getLocatorInfos(), + new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyLocatorInfosEqual(message, (LocatorInfo) expected, (LocatorInfo) actual); + } + }); } @Ignore("due to media service bug 596264") @Test public void updateLocatorSuccess() throws ServiceException { // Arrange - setupForLocatorTest(); - - LocatorType locatorTypeExepcted = LocatorType.Origin; LocatorType locatorType = LocatorType.Origin; + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); Date expirationDateTime = new Date(); expirationDateTime.setTime(expirationDateTime.getTime() + 1000); + Date startTime = new Date(); + startTime.setTime(startTime.getTime() - 1000); + UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() + .setExpirationDateTime(expirationDateTime).setStartTime(startTime); // Act - UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() - .setExpirationDateTime(expirationDateTime); service.updateLocator(locatorInfo.getId(), updateLocatorOptions); + LocatorInfo updatedLocatorInfo = service.getLocator(locatorInfo.getId()); // Assert - LocatorInfo locatorInfoActual = service.getLocator(locatorInfo.getId()); - assertEquals(locatorTypeExepcted, locatorInfoActual.getLocatorType()); - assertEquals(expirationDateTime, locatorInfoActual.getExpirationDateTime()); + verifyLocatorProperties("updatedLocatorInfo", locatorInfo.getAccessPolicyId(), locatorInfo.getAssetId(), + locatorInfo.getLocatorType(), startTime, expirationDateTime, locatorInfo.getId(), + locatorInfo.getPath(), updatedLocatorInfo); + } + + @Test + public void updateLocatorNoChangesSuccess() throws ServiceException { + // Arrange + LocatorType locatorType = LocatorType.Origin; + Date expirationDateTime = new Date(); + expirationDateTime.setTime(expirationDateTime.getTime() + 1000); + Date startTime = new Date(); + startTime.setTime(startTime.getTime() - 1000); + CreateLocatorOptions options = new CreateLocatorOptions().setExpirationDateTime(expirationDateTime) + .setStartTime(startTime); + + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, + options); + + // Act + service.updateLocator(locatorInfo.getId(), null); + LocatorInfo updatedLocatorInfo = service.getLocator(locatorInfo.getId()); + // Assert + verifyLocatorInfosEqual("updatedLocatorInfo", locatorInfo, updatedLocatorInfo); } @Test public void deleteLocatorSuccess() throws ServiceException { // Arrange - setupForLocatorTest(); LocatorType locatorType = LocatorType.SAS; CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, createLocatorOptions); + ListLocatorsResult listLocatorsResult = service.listLocators(); + int assetCountBaseline = listLocatorsResult.getLocatorInfos().size(); // Act service.deleteLocator(locatorInfo.getId()); // Assert - LocatorInfo locatorInfoResult = null; - try { - locatorInfoResult = service.getLocator(locatorInfo.getId()); - } - catch (ServiceException e) { - // swallow - } - assertNull(locatorInfoResult); + listLocatorsResult = service.listLocators(); + assertEquals("listLocatorsResult.size", assetCountBaseline - 1, listLocatorsResult.getLocatorInfos().size()); + + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getLocator(locatorInfo.getId()); } - @Test(expected = ServiceException.class) + @Test public void deleteLocatorInvalidIdFailed() throws ServiceException { - // Arrange - - // Act - service.deleteLocator("invalidLocatorId"); - - // Assert - assertTrue(false); + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.deleteLocator(invalidId); } } From e31cb1320e3293b344aed4decc82fa0adbcfa6bb Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 19 Oct 2012 10:36:52 -0700 Subject: [PATCH 400/664] Removing dead code, fix for #391 --- .../implementation/ResourceLocationManager.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 83e7e5586b65b..b06051aadebf1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -17,8 +17,6 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; import javax.inject.Named; import javax.ws.rs.core.UriBuilder; @@ -49,16 +47,4 @@ public URI getRedirectedURI(URI originalURI) { public void setRedirectedURI(String newURI) throws URISyntaxException { baseURI = new URI(newURI); } - - private Map<String, String> parseQueryString(String queryString) { - Map<String, String> map = new HashMap<String, String>(); - String[] params = queryString.split("&"); - for (String param : params) { - String key = param.split("=")[0]; - String value = param.split("=")[1]; - map.put(key, value); - } - return map; - - } } From d16a9cd6115b9936990b3653f42f3ac652f60a33 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 19 Oct 2012 10:45:23 -0700 Subject: [PATCH 401/664] Removing extra exception spec --- .../windowsazure/services/media/MediaContract.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index ea88db2db838a..754a049451815 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -34,7 +34,6 @@ import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; -import com.sun.jersey.api.client.UniformInterfaceException; /** * Defines the methods available for Windows Azure Media Services. @@ -230,12 +229,11 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * * @param locatorId * the id - * @throws UniformInterfaceException - * the uniform interface exception + * * @throws ServiceException * the service exception */ - public void deleteLocator(String locatorId) throws UniformInterfaceException, ServiceException; + public void deleteLocator(String locatorId) throws ServiceException; /** * List locators. From bc7c593ddf566f31d8032c344d08c1aef649f2da Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 19 Oct 2012 12:30:12 -0700 Subject: [PATCH 402/664] Supporting list options in all current list<Entity> methods. Fleshed out testing. Refactored adding query strings to request to simply the code. --- .../MediaExceptionProcessor.java | 2 +- .../media/implementation/MediaRestProxy.java | 24 ++++++++++--------- .../services/media/models/ListOptions.java | 3 ++- .../media/AccessPolicyIntegrationTest.java | 24 +++++++++++++++++++ .../services/media/AssetIntegrationTest.java | 22 +++++++++++++++++ .../media/LocatorIntegrationTests.java | 17 +++++++++++++ .../media/MediaServiceIntegrationTest.java | 3 ++- 7 files changed, 81 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 411746d7b3599..c2a69ea95af43 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -281,7 +281,7 @@ public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceExc */@Override public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { try { - return service.listAccessPolicies(); + return service.listAccessPolicies(options); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 76e29b846a378..27c358034e202 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -46,6 +46,7 @@ import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListOptions; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; @@ -151,6 +152,14 @@ private WebResource getResource(String entityName) { return resource; } + private WebResource getResource(String entityName, ListOptions options) { + WebResource resource = getResource(entityName); + if (options != null) { + resource = resource.queryParams(options.getQueryParameters()); + } + return resource; + } + /** * Gets the resource. * @@ -246,10 +255,7 @@ public AssetInfo getAsset(String assetId) throws ServiceException { */ @Override public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { - WebResource resource = getResource("Assets"); - if ((listAssetsOptions != null) && (listAssetsOptions.getQueryParameters() != null)) { - resource = resource.queryParams(listAssetsOptions.getQueryParameters()); - } + WebResource resource = getResource("Assets", listAssetsOptions); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .get(new GenericType<List<AssetInfo>>() { @@ -341,7 +347,7 @@ public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { */ @Override public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { - WebResource resource = getResource("AccessPolicies"); + WebResource resource = getResource("AccessPolicies", options); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) .get(new GenericType<List<AccessPolicyInfo>>() { @@ -406,7 +412,7 @@ public ListLocatorsResult listLocators() { */ @Override public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) { - WebResource resource = getResource("Locators"); + WebResource resource = getResource("Locators", listLocatorOptions); List<LocatorInfo> locatorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<LocatorInfo>>() { @@ -459,11 +465,7 @@ public ListMediaProcessorsResult listMediaProcessors() { */ @Override public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { - WebResource resource = getResource("MediaProcessors"); - - if ((listMediaProcessorsOptions != null) && (listMediaProcessorsOptions.getQueryParameters() != null)) { - resource = resource.queryParams(listMediaProcessorsOptions.getQueryParameters()); - } + WebResource resource = getResource("MediaProcessors", listMediaProcessorsOptions); List<MediaProcessorInfo> mediaProcessorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<MediaProcessorInfo>>() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java index c208cd667c664..57143bfc179d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.models; import javax.ws.rs.core.MultivaluedMap; + import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -30,7 +31,7 @@ public ListOptions() { } /** The query parameters. */ - protected MultivaluedMap<String, String> queryParameters; + private final MultivaluedMap<String, String> queryParameters; /** * Gets the query parameters. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index a01c98174e99b..e0e11c0b55881 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; public class AccessPolicyIntegrationTest extends IntegrationTestBase { private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) { @@ -138,6 +139,29 @@ public void verifyEquals(String message, Object expected, Object actual) { }); } + @Test + public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { + String[] policyNames = new String[] { testPolicyPrefix + "ListThree", testPolicyPrefix + "ListFour", + testPolicyPrefix + "ListFive", testPolicyPrefix + "ListSix", testPolicyPrefix + "ListSeven" }; + + double duration = 3; + EnumSet<AccessPolicyPermission> permissions = EnumSet.of(AccessPolicyPermission.WRITE, + AccessPolicyPermission.LIST); + + List<AccessPolicyInfo> expectedAccessPolicies = new ArrayList<AccessPolicyInfo>(); + for (int i = 0; i < policyNames.length; i++) { + AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, permissions); + expectedAccessPolicies.add(policy); + } + + ListAccessPolicyOptions options = new ListAccessPolicyOptions(); + options.getQueryParameters().add("$top", "2"); + + List<AccessPolicyInfo> actualAccessPolicies = service.listAccessPolicies(options); + + assertEquals(2, actualAccessPolicies.size()); + } + // Note: Access Policy cannot be updated. @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 9fbf820a17d5e..f10057240d0a8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -30,6 +30,7 @@ import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; public class AssetIntegrationTest extends IntegrationTestBase { @@ -191,6 +192,27 @@ public void verifyEquals(String message, Object expected, Object actual) { }); } + @Test + public void canListAssetsWithOptions() throws ServiceException { + String[] assetNames = new String[] { testAssetPrefix + "assetListOptionsA", + testAssetPrefix + "assetListOptionsB", testAssetPrefix + "assetListOptionsC", + testAssetPrefix + "assetListOptionsD" }; + List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); + for (int i = 0; i < assetNames.length; i++) { + String name = assetNames[i]; + CreateAssetOptions options = new CreateAssetOptions().setName(name); + expectedAssets.add(service.createAsset(options)); + } + + ListAssetsOptions options = new ListAssetsOptions(); + options.getQueryParameters().add("$top", "2"); + Collection<AssetInfo> listAssetResult = service.listAssets(options); + + // Assert + + assertEquals(2, listAssetResult.size()); + } + @Ignore // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 3256a9d2f798c..bf26fa93a8772 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -31,6 +31,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -155,6 +156,22 @@ public void listLocatorsSuccess() throws ServiceException { verifyListResultContains("listLocators", expectedLocators, listLocatorsResult.getLocatorInfos(), null); } + @Test + public void canListLocatorsWithOptions() throws ServiceException { + setupForLocatorTest(); + + for (int i = 0; i < 5; i++) { + service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), LocatorType.SAS); + } + + ListLocatorsOptions options = new ListLocatorsOptions(); + options.getQueryParameters().add("$top", "2"); + + ListLocatorsResult result = service.listLocators(options); + + assertEquals(2, result.getLocatorInfos().size()); + } + @Ignore("due to media service bug 596264") @Test public void updateLocatorSuccess() throws ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 91eef6023458f..d6c06b349aa0b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -41,13 +41,14 @@ public void listMediaProcessorsSuccess() throws ServiceException { public void listMediaProcessorWithOptionSuccess() throws ServiceException { // Arrange ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); + listMediaProcessorsOptions.getQueryParameters().add("$top", "2"); // Act ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(listMediaProcessorsOptions); // Assert assertNotNull(listMediaProcessorsResult); - assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); + assertEquals(2, listMediaProcessorsResult.getMediaProcessorInfos().size()); } } From 14a77b6b70c1f1e29ec5d596412c181758b90030 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 14:17:59 -0700 Subject: [PATCH 403/664] Fine-tune approximate date equality tests --- .../services/media/IntegrationTestBase.java | 19 +++++---- .../media/LocatorIntegrationTests.java | 40 ++++++++++--------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index a90a8e428feb5..b308c4268f9be 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -13,7 +13,6 @@ import org.junit.Rule; import org.junit.rules.ExpectedException; -import com.microsoft.windowsazure.services.blob.implementation.ISO8601DateConverter; import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; @@ -163,20 +162,24 @@ protected void assertDateApproxEquals(Date expected, Date actual) { } protected void assertDateApproxEquals(String message, Date expected, Date actual) { - // Default allows for a 30 seconds difference in dates. + // Default allows for a 30 seconds difference in dates, for clock skew, network delays, etc. long deltaInMilliseconds = 30000; + if (expected == null || actual == null) { assertEquals(message, expected, actual); } else { long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + + // TODO: Remove this time-zone workaround when fixed: + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/413 + if (diffInMilliseconds > deltaInMilliseconds) { + // Just hard-code time-zone offset of 7 hours for now. + diffInMilliseconds = Math.abs(diffInMilliseconds - 7 * 60 * 60 * 1000); + } + if (diffInMilliseconds > deltaInMilliseconds) { - // Out of the range. Need to assert - // Use strings so the messages make more sense. - ISO8601DateConverter converter = new ISO8601DateConverter(); - String expectedString = converter.format(expected); - String actualString = converter.format(actual); - assertEquals(message, expectedString, actualString); + assertEquals(message, expected, actual); } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index b593fc3c3ca7b..7ff27391f3a90 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -44,9 +44,11 @@ public class LocatorIntegrationTests extends IntegrationTestBase { private static AssetInfo assetInfo; private static AccessPolicyInfo accessPolicyInfo; private static AccessPolicyInfo accessPolicyInfoRead; + private static int minuteInMS = 60 * 1000; + private static int tenMinutesInMS = 10 * 60 * 1000; private Date calculateDefaultExpectedExpDate(AccessPolicyInfo accessPolicy, AssetInfo asset) { - return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * 60 * 1000); + return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * minuteInMS); } private void verifyLocatorInfosEqual(String message, LocatorInfo expected, LocatorInfo actual) { @@ -92,7 +94,7 @@ public static void setup() throws Exception { IntegrationTestBase.setup(); accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5, EnumSet.of(AccessPolicyPermission.WRITE)); - accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 5, + accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 15, EnumSet.of(AccessPolicyPermission.READ)); } @@ -105,13 +107,13 @@ public void instanceSetup() throws Exception { public void createLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.Origin; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfo, assetInfo); + Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType); + LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType); // Assert - verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, null, + verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, expectedExpirationDateTime, locatorInfo); } @@ -121,7 +123,7 @@ public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceExc // Arrange CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedExpirationDateTime = new Date(); - expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + 10000); + expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + tenMinutesInMS); createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); LocatorType locatorType = LocatorType.SAS; @@ -134,14 +136,16 @@ public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceExc expectedExpirationDateTime, locatorInfo); } + @Ignore("due to media service bug 596240") @Test public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Arrange CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedStartDateTime = new Date(); - expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 10000); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); createLocatorOptions.setStartTime(expectedStartDateTime); LocatorType locatorType = LocatorType.SAS; + Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfo, assetInfo); // Act LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, @@ -149,17 +153,16 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - expectedStartDateTime, null, locatorInfo); + expectedStartDateTime, expectedExpirationDateTime, locatorInfo); } - @Ignore("due to media service bug 596238") @Test public void getLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; Date expectedStartDateTime = new Date(); - expectedStartDateTime.setTime(expectedStartDateTime.getTime() + 10000); - Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + 10000); + expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); + Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + tenMinutesInMS); CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); createLocatorOptions.setStartTime(expectedStartDateTime); @@ -177,15 +180,15 @@ public void getLocatorSuccess() throws ServiceException { @Test public void getLocatorInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(invalidId); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.getLocator(invalidId); } @Test public void getLocatorNonexistId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(validButNonexistLocatorId); + service.getLocator(validButNonexistLocatorId); } @Test @@ -236,7 +239,6 @@ public void verifyEquals(String message, Object expected, Object actual) { }); } - @Ignore("due to media service bug 596264") @Test public void updateLocatorSuccess() throws ServiceException { // Arrange @@ -244,9 +246,9 @@ public void updateLocatorSuccess() throws ServiceException { LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType); Date expirationDateTime = new Date(); - expirationDateTime.setTime(expirationDateTime.getTime() + 1000); + expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); - startTime.setTime(startTime.getTime() - 1000); + startTime.setTime(startTime.getTime() - tenMinutesInMS); UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() .setExpirationDateTime(expirationDateTime).setStartTime(startTime); @@ -265,9 +267,9 @@ public void updateLocatorNoChangesSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.Origin; Date expirationDateTime = new Date(); - expirationDateTime.setTime(expirationDateTime.getTime() + 1000); + expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); - startTime.setTime(startTime.getTime() - 1000); + startTime.setTime(startTime.getTime() - tenMinutesInMS); CreateLocatorOptions options = new CreateLocatorOptions().setExpirationDateTime(expirationDateTime) .setStartTime(startTime); From 702ddca7368cb9b31b9975dfc9e5616430abb4c6 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 15:38:46 -0700 Subject: [PATCH 404/664] Replacing "zero" GUIDs with fresh GUIDs. --- .../windowsazure/services/media/IntegrationTestBase.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index b308c4268f9be..647e0cd17a1af 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -26,9 +26,9 @@ public abstract class IntegrationTestBase { protected static final String testAssetPrefix = "testAsset"; protected static final String testPolicyPrefix = "testPolicy"; - protected static final String validButNonexistAssetId = "nb:cid:UUID:00000000-0000-4a00-0000-000000000000"; - protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:00000000-0000-4a00-0000-000000000000"; - protected static final String validButNonexistLocatorId = "nb:lid:UUID:00000000-0000-4a00-0000-000000000000"; + protected static final String validButNonexistAssetId = "nb:cid:UUID:0239f11f-2d36-4e5f-aa35-44d58ccc0973"; + protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:38dcb3a0-ef64-4ad0-bbb5-67a14c6df2f7"; + protected static final String validButNonexistLocatorId = "nb:lid:UUID:92a70402-fca9-4aa3-80d7-d4de3792a27a"; protected static final String invalidId = "notAValidId"; From 5090b92947346c1e6e31f93c3236f9c17a493a6c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 16:09:55 -0700 Subject: [PATCH 405/664] Adding more validation in MediaProcessor tests Opportunistic cleanup of some Asset tests --- .../media/MediaServiceIntegrationTest.java | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index d6c06b349aa0b..043ea8e659a3c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -17,38 +17,69 @@ import static org.junit.Assert.*; +import java.util.List; + import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; public class MediaServiceIntegrationTest extends IntegrationTestBase { + private void verifyMediaProcessorInfo(String message, MediaProcessorInfo mediaProcessorInfo) { + assertEquals(message + " id length", 49, mediaProcessorInfo.getId().length()); + assertTrue(message + " name length > 0", mediaProcessorInfo.getName().length() > 0); + assertNotNull(message + " description", mediaProcessorInfo.getDescription()); + assertNotNull(message + " sku", mediaProcessorInfo.getSku()); + assertTrue(message + " vendor length > 0", mediaProcessorInfo.getVendor().length() > 0); + assertTrue(message + " version length > 0", mediaProcessorInfo.getVersion().length() > 0); + } + + private void verifyMediaProcessorInfo(String message, String id, String name, String description, String sku, + String vendor, String version, MediaProcessorInfo mediaProcessorInfo) { + assertEquals(message + " id", id, mediaProcessorInfo.getId()); + assertEquals(message + " name", name, mediaProcessorInfo.getName()); + assertEquals(message + " description", description, mediaProcessorInfo.getDescription()); + assertEquals(message + " sku", sku, mediaProcessorInfo.getSku()); + assertEquals(message + " vendor", vendor, mediaProcessorInfo.getVendor()); + assertEquals(message + " version", version, mediaProcessorInfo.getVersion()); + } + @Test public void listMediaProcessorsSuccess() throws ServiceException { - // Arrange + // Arrange // Act ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(); // Assert - assertNotNull(listMediaProcessorsResult); - assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); + assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); + assertTrue("listMediaProcessorsResult size > 0", listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); + List<MediaProcessorInfo> ps = listMediaProcessorsResult.getMediaProcessorInfos(); + for (int i = 0; i < ps.size(); i++) { + MediaProcessorInfo mediaProcessorInfo = ps.get(i); + verifyMediaProcessorInfo("mediaProcessorInfo:" + i, mediaProcessorInfo); + } } @Test public void listMediaProcessorWithOptionSuccess() throws ServiceException { // Arrange ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); + listMediaProcessorsOptions.getQueryParameters().add("$filter", + "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"); listMediaProcessorsOptions.getQueryParameters().add("$top", "2"); // Act ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(listMediaProcessorsOptions); // Assert - assertNotNull(listMediaProcessorsResult); - assertEquals(2, listMediaProcessorsResult.getMediaProcessorInfos().size()); + assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); + assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.getMediaProcessorInfos().size()); + MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.getMediaProcessorInfos().get(0); + verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", + "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3", mediaProcessorInfo); } - } From 73a476b33e3b2f5ba5b04f3221803f83f0bda826 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 16:10:35 -0700 Subject: [PATCH 406/664] Opportunistic cleanup of some Asset tests --- .../services/media/AssetIntegrationTest.java | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index f10057240d0a8..2bacc4e14c860 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -64,19 +64,6 @@ private void verifyAssetProperties(String message, String testName, String altId } } - @Test - public void createAssetSuccess() throws Exception { - // Arrange - String testName = testAssetPrefix + "Name"; - CreateAssetOptions options = new CreateAssetOptions().setName(testName); - - // Act - AssetInfo actualAsset = service.createAsset(options); - - // Assert - verifyAssetProperties("actualAsset", testName, "", EncryptionOption.None, AssetState.Initialized, actualAsset); - } - @Test public void createAssetOptionsSuccess() throws Exception { // Arrange @@ -120,9 +107,7 @@ public void createAssetNullNameSuccess() throws Exception { try { actualAsset = service.createAsset(); // Assert - assertNotNull("actualAsset", actualAsset); - assertEquals("actualAsset.getName() should be the service default value, the empty string", "", - actualAsset.getName()); + verifyAssetProperties("actualAsset", "", "", EncryptionOption.None, AssetState.Initialized, actualAsset); } finally { // Clean up the anonymous asset now while we have the id, because we @@ -152,12 +137,19 @@ public void getAssetSuccess() throws Exception { // Act AssetInfo actualAsset = service.getAsset(assetInfo.getId()); - assertEquals("Id", assetInfo.getId(), actualAsset.getId()); - verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); + // Assert + verifyInfosEqual("actualAsset", assetInfo, actualAsset); + } + + @Test + public void getAssetInvalidId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.getAsset(invalidId); } @Test - public void getAssetFailedWithInvalidId() throws ServiceException { + public void getAssetNonexistId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); service.getAsset(validButNonexistAssetId); @@ -213,8 +205,7 @@ public void canListAssetsWithOptions() throws ServiceException { assertEquals(2, listAssetResult.size()); } - @Ignore - // Bug https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364 + @Ignore("https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364") @Test public void updateAssetSuccess() throws Exception { // Arrange @@ -256,7 +247,7 @@ public void updateAssetNoChangesSuccess() throws Exception { AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - verifyAssetProperties("updatedAsset", originalTestName, altId, encryptionOption, assetState, updatedAsset); + verifyInfosEqual("updatedAsset", originalAsset, updatedAsset); } @Test @@ -273,7 +264,7 @@ public void updateAssetFailedWithInvalidId() throws ServiceException { @Test public void deleteAssetSuccess() throws Exception { // Arrange - String assetName = "deleteAssetSuccess"; + String assetName = testAssetPrefix + "deleteAssetSuccess"; CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(assetName); AssetInfo assetInfo = service.createAsset(createAssetOptions); List<AssetInfo> listAssetsResult = service.listAssets(); From bf32f73528df032b8732eda9796aead5352b8a3b Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 19 Oct 2012 16:42:23 -0700 Subject: [PATCH 407/664] Rename MSIT to MPIT, as the file only contains MediaProcessor tests. --- ...eIntegrationTest.java => MediaProcessorIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{MediaServiceIntegrationTest.java => MediaProcessorIntegrationTest.java} (98%) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java similarity index 98% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 043ea8e659a3c..52559f8dbe2f3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -26,7 +26,7 @@ import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -public class MediaServiceIntegrationTest extends IntegrationTestBase { +public class MediaProcessorIntegrationTest extends IntegrationTestBase { private void verifyMediaProcessorInfo(String message, MediaProcessorInfo mediaProcessorInfo) { assertEquals(message + " id length", 49, mediaProcessorInfo.getId().length()); From 63abbc5c3d33d66569b7c63a7ff0ff44ece39440 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 21 Oct 2012 23:40:59 -0700 Subject: [PATCH 408/664] initial commit for jobs and tasks. --- .../services/media/MediaContract.java | 24 + .../MediaExceptionProcessor.java | 124 +++++ .../media/implementation/MediaRestProxy.java | 103 ++++- .../media/implementation/content/JobType.java | 331 ++++++++++++++ .../implementation/content/TaskType.java | 251 +++++++++++ .../media/models/CreateJobOptions.java | 72 +++ .../services/media/models/JobInfo.java | 320 +++++++++++++ .../media/models/ListJobsOptions.java | 22 + .../services/media/models/ListJobsResult.java | 48 ++ .../media/models/ListTasksOptions.java | 22 + .../media/models/ListTasksResult.java | 48 ++ .../services/media/models/TaskInfo.java | 426 ++++++++++++++++++ .../media/MediaServiceIntegrationTest.java | 132 ++++++ 13 files changed, 1922 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 7737f99b5b145..7d36d56449d3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -22,13 +22,19 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsResult; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListTasksOptions; +import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -293,4 +299,22 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) throws ServiceException; + public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceException; + + public JobInfo getJob(String jobId) throws ServiceException; + + public ListJobsResult listJobs() throws ServiceException; + + public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException; + + public void cancelJob(String jobId) throws ServiceException; + + public ListTasksResult listTasks() throws ServiceException; + + public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException; + + public ListTasksResult listJobTasks(String jobId) throws ServiceException; + + public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException; + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 0a89ea0ae8c42..e20103bc5aefe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -30,13 +30,19 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsResult; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListTasksOptions; +import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -455,4 +461,122 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions } } + + @Override + public ListJobsResult listJobs() throws ServiceException { + try { + return service.listJobs(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + + } + + @Override + public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceException { + try { + return service.createJob(createJobOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public void cancelJob(String jobId) throws ServiceException { + try { + service.cancelJob(jobId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListTasksResult listTasks() throws ServiceException { + try { + return service.listTasks(); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListTasksResult listJobTasks(String jobId) throws ServiceException { + try { + return service.listJobTasks(jobId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public JobInfo getJob(String jobId) throws ServiceException { + try { + return service.getJob(jobId); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException { + try { + return service.listJobs(listJobsOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException { + try { + return service.listTasks(listTasksOptions); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + @Override + public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { + try { + return service.listJobTasks(jobId, listTasksOptions); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 656f1e70d4a05..8c3f3283f172b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -34,22 +34,30 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsResult; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListTasksOptions; +import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.Client; @@ -58,7 +66,6 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -// TODO: Auto-generated Javadoc /** * The Class MediaRestProxy. */ @@ -488,4 +495,98 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions return listMediaProcessorsResult; } + @Override + public ListJobsResult listJobs() throws ServiceException { + return listJobs(null); + } + + @Override + public JobInfo createJob(CreateJobOptions createJobOptions) { + JobType jobType = new JobType(); + + if (createJobOptions != null) { + } + + WebResource resource = getResource("Jobs"); + + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(JobInfo.class, jobType); + } + + @Override + public void cancelJob(String jobId) throws ServiceException { + try { + getResource("Jobs", jobId).delete(); + } + catch (UniformInterfaceException e) { + throw new ServiceException(e); + } + } + + @Override + public JobInfo getJob(String jobId) throws ServiceException { + WebResource resource = getResource("Jobs", jobId); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML).get(JobInfo.class); + } + + @Override + public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException { + WebResource resource = getResource("Jobs"); + + if ((listJobsOptions != null) && (listJobsOptions.getQueryParameters() != null)) { + resource = resource.queryParams(listJobsOptions.getQueryParameters()); + } + + List<JobInfo> jobInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<JobInfo>>() { + }); + ListJobsResult listJobsResult = new ListJobsResult(); + listJobsResult.setJobInfos(jobInfoList); + return listJobsResult; + } + + @Override + public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException { + WebResource resource = getResource("Tasks"); + + if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { + resource = resource.queryParams(listTasksOptions.getQueryParameters()); + } + + List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() { + }); + ListTasksResult listTasksResult = new ListTasksResult(); + listTasksResult.setTaskInfos(taskInfoList); + return listTasksResult; + + } + + @Override + public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { + WebResource resource = getResource("Jobs('')/Tasks", jobId); + + if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { + resource = resource.queryParams(listTasksOptions.getQueryParameters()); + } + + List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() { + }); + ListTasksResult listTasksResult = new ListTasksResult(); + listTasksResult.setTaskInfos(taskInfoList); + return listTasksResult; + + } + + @Override + public ListTasksResult listTasks() throws ServiceException { + return listTasks(null); + } + + @Override + public ListTasksResult listJobTasks(String jobId) throws ServiceException { + return this.listJobTasks(jobId, null); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java new file mode 100644 index 0000000000000..cf02d83ab9666 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -0,0 +1,331 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Job entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class JobType implements MediaServiceDTO { + + /** The id. */ + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + /** The name. */ + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + /** The created. */ + @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + protected Date created; + + /** The last modified. */ + @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + protected Date lastModified; + + /** The end time. */ + @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) + protected Date endTime; + + /** The priority. */ + @XmlElement(name = "Priority", namespace = Constants.ODATA_DATA_NS) + protected int priority; + + /** The running duration. */ + @XmlElement(name = "RunningDuration", namespace = Constants.ODATA_DATA_NS) + protected double runningDuration; + + /** The start time. */ + @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + protected Date startTime; + + /** The state. */ + @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) + protected int state; + + /** The template id. */ + @XmlElement(name = "TemplateId", namespace = Constants.ODATA_DATA_NS) + protected String templateId; + + /** The output media assets. */ + @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) + protected String outputMediaAssets; + + /** The input media assets. */ + @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) + protected String inputMediaAssets; + + /** The tasks. */ + @XmlElement(name = "Tasks", namespace = Constants.ODATA_DATA_NS) + protected String tasks; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id + * the new id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name + * the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Sets the created. + * + * @param created + * the new created + */ + public void setCreated(Date created) { + this.created = created; + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return lastModified; + } + + /** + * Sets the last modified. + * + * @param lastModified + * the new last modified + */ + public void setLastModified(Date lastModified) { + this.lastModified = lastModified; + } + + /** + * Gets the end time. + * + * @return the end time + */ + public Date getEndTime() { + return endTime; + } + + /** + * Sets the end time. + * + * @param endTime + * the new end time + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * Gets the priority. + * + * @return the priority + */ + public int getPriority() { + return priority; + } + + /** + * Sets the priority. + * + * @param priority + * the new priority + */ + public void setPriority(int priority) { + this.priority = priority; + } + + /** + * Gets the running duration. + * + * @return the running duration + */ + public double getRunningDuration() { + return runningDuration; + } + + /** + * Sets the running duration. + * + * @param runningDuration + * the new running duration + */ + public void setRunningDuration(double runningDuration) { + this.runningDuration = runningDuration; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the new start time + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * Gets the state. + * + * @return the state + */ + public int getState() { + return state; + } + + /** + * Sets the state. + * + * @param state + * the new state + */ + public void setState(int state) { + this.state = state; + } + + /** + * Gets the template id. + * + * @return the template id + */ + public String getTemplateId() { + return templateId; + } + + /** + * Sets the template id. + * + * @param templateId + * the new template id + */ + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + * Gets the output media assets. + * + * @return the output media assets + */ + public String getOutputMediaAssets() { + return outputMediaAssets; + } + + /** + * Sets the output media assets. + * + * @param outputMediaAssets + * the new output media assets + */ + public void setOutputMediaAssets(String outputMediaAssets) { + this.outputMediaAssets = outputMediaAssets; + } + + /** + * Gets the input media assets. + * + * @return the input media assets + */ + public String getInputMediaAssets() { + return inputMediaAssets; + } + + /** + * Sets the input media assets. + * + * @param inputMediaAssets + * the new input media assets + */ + public void setInputMediaAssets(String inputMediaAssets) { + this.inputMediaAssets = inputMediaAssets; + } + + /** + * Gets the tasks. + * + * @return the tasks + */ + public String getTasks() { + return tasks; + } + + /** + * Sets the tasks. + * + * @param tasks + * the new tasks + */ + public void setTasks(String tasks) { + this.tasks = tasks; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java new file mode 100644 index 0000000000000..aa205aee185f7 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -0,0 +1,251 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Task entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class TaskType implements MediaServiceDTO { + + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + @XmlElement(name = "Configuration", namespace = Constants.ODATA_DATA_NS) + protected String configuration; + + @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) + protected Date endTime; + + @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) + protected String errorDetails; + + @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) + protected String mediaProcessorId; + + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + @XmlElement(name = "PerfMessage", namespace = Constants.ODATA_DATA_NS) + protected String perfMessage; + + @XmlElement(name = "Priority", namespace = Constants.ODATA_DATA_NS) + protected int priority; + + @XmlElement(name = "Progress", namespace = Constants.ODATA_DATA_NS) + protected double progress; + + @XmlElement(name = "RunningDuration", namespace = Constants.ODATA_DATA_NS) + protected double runningDuration; + + @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + protected Date startTime; + + @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) + protected int state; + + @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) + protected String taskBody; + + @XmlElement(name = "Options", namespace = Constants.ODATA_DATA_NS) + protected int options; + + @XmlElement(name = "EncryptionKeyId", namespace = Constants.ODATA_DATA_NS) + protected String encryptionKeyId; + + @XmlElement(name = "EncryptionScheme", namespace = Constants.ODATA_DATA_NS) + protected String encryptionScheme; + + @XmlElement(name = "EncryptionVersion", namespace = Constants.ODATA_DATA_NS) + protected String encryptionVersion; + + @XmlElement(name = "InitializationVector", namespace = Constants.ODATA_DATA_NS) + protected String initializationVector; + + @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) + protected String outputMediaAssets; + + @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) + protected String inputMediaAssets; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getConfiguration() { + return configuration; + } + + public void setConfiguration(String configuration) { + this.configuration = configuration; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public String getErrorDetails() { + return errorDetails; + } + + public void setErrorDetails(String errorDetails) { + this.errorDetails = errorDetails; + } + + public String getMediaProcessorId() { + return mediaProcessorId; + } + + public void setMediaProcessorId(String mediaProcessorId) { + this.mediaProcessorId = mediaProcessorId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPerfMessage() { + return perfMessage; + } + + public void setPerfMessage(String perfMessage) { + this.perfMessage = perfMessage; + } + + public int getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + + public double getProgress() { + return progress; + } + + public void setProgress(double progress) { + this.progress = progress; + } + + public double getRunningDuration() { + return runningDuration; + } + + public void setRunningDuration(double runningDuration) { + this.runningDuration = runningDuration; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public int getState() { + return state; + } + + public void setState(int state) { + this.state = state; + } + + public String getTaskBody() { + return taskBody; + } + + public void setTaskBody(String taskBody) { + this.taskBody = taskBody; + } + + public int getOptions() { + return options; + } + + public void setOptions(int options) { + this.options = options; + } + + public String getEncryptionKeyId() { + return encryptionKeyId; + } + + public void setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + } + + public String getEncryptionScheme() { + return encryptionScheme; + } + + public void setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + } + + public String getEncryptionVersion() { + return encryptionVersion; + } + + public void setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + } + + public String getInitializationVector() { + return initializationVector; + } + + public void setInitializationVector(String initializationVector) { + this.initializationVector = initializationVector; + } + + public String getOutputMediaAssets() { + return outputMediaAssets; + } + + public void setOutputMediaAssets(String outputMediaAssets) { + this.outputMediaAssets = outputMediaAssets; + } + + public String getInputMediaAssets() { + return inputMediaAssets; + } + + public void setInputMediaAssets(String inputMediaAssets) { + this.inputMediaAssets = inputMediaAssets; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java new file mode 100644 index 0000000000000..a49e94921e517 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -0,0 +1,72 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class CreateJobOptions. + */ +public class CreateJobOptions { + + /** The expiration date time. */ + private Date expirationDateTime; + + /** The start time. */ + private Date startTime; + + /** + * Gets the expiration date time. + * + * @return the expiration date time + */ + public Date getExpirationDateTime() { + return expirationDateTime; + } + + /** + * Sets the expiration date time. + * + * @param expirationDateTime + * the expiration date time + * @return the creates the locator options + */ + public CreateJobOptions setExpirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the creates the locator options + */ + public CreateJobOptions setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java new file mode 100644 index 0000000000000..4206393aeb8f8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -0,0 +1,320 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; + +/** + * The Class JobInfo. + */ +public class JobInfo extends ODataEntity<JobType> { + + /** + * Instantiates a new job info. + * + * @param entry + * the entry + * @param content + * the content + */ + public JobInfo(EntryType entry, JobType content) { + super(entry, content); + } + + /** + * Instantiates a new job info. + */ + public JobInfo() { + super(new JobType()); + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return getContent().getId(); + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the job info + */ + public JobInfo setId(String id) { + getContent().setId(id); + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return getContent().getName(); + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the job info + */ + public JobInfo setName(String name) { + getContent().setName(name); + return this; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return getContent().getCreated(); + } + + /** + * Sets the created. + * + * @param created + * the created + * @return the job info + */ + public JobInfo setCreated(Date created) { + getContent().setCreated(created); + return this; + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return getContent().getLastModified(); + } + + /** + * Sets the last modified. + * + * @param lastModified + * the last modified + * @return the job info + */ + public JobInfo setLastModified(Date lastModified) { + getContent().setLastModified(lastModified); + return this; + } + + /** + * Gets the end time. + * + * @return the end time + */ + public Date getEndTime() { + return getContent().getEndTime(); + } + + /** + * Sets the end time. + * + * @param endTime + * the end time + * @return the job info + */ + public JobInfo setEndTime(Date endTime) { + getContent().setEndTime(endTime); + return this; + } + + /** + * Gets the priority. + * + * @return the priority + */ + public int getPriority() { + return getContent().getPriority(); + } + + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the job info + */ + public JobInfo setPriority(int priority) { + getContent().setPriority(priority); + return this; + } + + /** + * Gets the running duration. + * + * @return the running duration + */ + public double getRunningDuration() { + return getContent().getRunningDuration(); + } + + /** + * Sets the running duration. + * + * @param runningDuration + * the running duration + * @return the job info + */ + public JobInfo setRunningDuration(double runningDuration) { + getContent().setRunningDuration(runningDuration); + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return getContent().getStartTime(); + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the job info + */ + public JobInfo setStartTime(Date startTime) { + getContent().setStartTime(startTime); + return this; + } + + /** + * Gets the state. + * + * @return the state + */ + public int getState() { + return getContent().getState(); + } + + /** + * Sets the state. + * + * @param state + * the state + * @return the job info + */ + public JobInfo setState(int state) { + getContent().setState(state); + return this; + } + + /** + * Gets the template id. + * + * @return the template id + */ + public String getTemplateId() { + return getContent().getTemplateId(); + } + + /** + * Sets the template id. + * + * @param templateId + * the template id + * @return the job info + */ + public JobInfo setTemplateId(String templateId) { + getContent().setTemplateId(templateId); + return this; + } + + /** + * Gets the input media assets. + * + * @return the input media assets + */ + public String getInputMediaAssets() { + return getContent().getInputMediaAssets(); + } + + /** + * Sets the input media assets. + * + * @param inputMediaAssets + * the input media assets + * @return the job info + */ + public JobInfo setInputMediaAssets(String inputMediaAssets) { + getContent().setInputMediaAssets(inputMediaAssets); + return this; + } + + /** + * Gets the output media assets. + * + * @return the output media assets + */ + public String getOutputMediaAssets() { + return getContent().getOutputMediaAssets(); + } + + /** + * Sets the output media assets. + * + * @param outputMediaAssets + * the output media assets + * @return the job info + */ + public JobInfo setOutputMediaAssets(String outputMediaAssets) { + getContent().setOutputMediaAssets(outputMediaAssets); + return this; + } + + /** + * Gets the tasks. + * + * @return the tasks + */ + public String getTasks() { + return getContent().getTasks(); + } + + /** + * Sets the tasks. + * + * @param tasks + * the tasks + * @return the job info + */ + public JobInfo setTasks(String tasks) { + getContent().setTasks(tasks); + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java new file mode 100644 index 0000000000000..9280d8ecdd726 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java @@ -0,0 +1,22 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * The Class ListJobsOptions. + */ +public class ListJobsOptions extends ListOptions { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java new file mode 100644 index 0000000000000..b436acb898784 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java @@ -0,0 +1,48 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.List; + +/** + * The Class ListJobsResult. + */ +public class ListJobsResult { + + /** The job infos. */ + private List<JobInfo> jobInfos; + + /** + * Gets the job infos. + * + * @return the job infos + */ + public List<JobInfo> getJobInfos() { + return jobInfos; + } + + /** + * Sets the job infos. + * + * @param jobInfos + * the job infos + * @return the list jobs result + */ + public ListJobsResult setJobInfos(List<JobInfo> jobInfos) { + this.jobInfos = jobInfos; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java new file mode 100644 index 0000000000000..394c1ad79c45b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java @@ -0,0 +1,22 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +/** + * The Class ListTasksOptions. + */ +public class ListTasksOptions extends ListOptions { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java new file mode 100644 index 0000000000000..55f4360a27910 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java @@ -0,0 +1,48 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.List; + +/** + * The Class ListTasksResult. + */ +public class ListTasksResult { + + /** The task infos. */ + private List<TaskInfo> taskInfos; + + /** + * Gets the task infos. + * + * @return the task infos + */ + public List<TaskInfo> getTaskInfos() { + return taskInfos; + } + + /** + * Sets the task infos. + * + * @param taskInfos + * the task infos + * @return the list tasks result + */ + public ListTasksResult setTaskInfos(List<TaskInfo> taskInfos) { + this.taskInfos = taskInfos; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java new file mode 100644 index 0000000000000..ca62a76504405 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -0,0 +1,426 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; + +/** + * The Class TaskInfo. + */ +public class TaskInfo extends ODataEntity<TaskType> { + + /** + * Instantiates a new task info. + * + * @param entry + * the entry + * @param content + * the content + */ + public TaskInfo(EntryType entry, TaskType content) { + super(entry, content); + } + + /** + * Instantiates a new task info. + */ + public TaskInfo() { + super(new TaskType()); + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return getContent().getId(); + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the task info + */ + public TaskInfo setId(String id) { + getContent().setId(id); + return this; + } + + /** + * Gets the configuration. + * + * @return the configuration + */ + public String getConfiguration() { + return getContent().getConfiguration(); + } + + /** + * Sets the configuration. + * + * @param configuration + * the configuration + * @return the task info + */ + public TaskInfo setConfiguration(String configuration) { + getContent().setConfiguration(configuration); + return this; + } + + /** + * Gets the end time. + * + * @return the end time + */ + public Date getEndTime() { + return getContent().getEndTime(); + } + + /** + * Sets the end time. + * + * @param endTime + * the end time + * @return the task info + */ + public TaskInfo setEndTime(Date endTime) { + getContent().setEndTime(endTime); + return this; + } + + /** + * Gets the error details. + * + * @return the error details + */ + public String getErrorDetails() { + return getContent().getErrorDetails(); + } + + /** + * Sets the error details. + * + * @param errorDetails + * the error details + * @return the task info + */ + public TaskInfo setErrorDetails(String errorDetails) { + getContent().setErrorDetails(errorDetails); + return this; + } + + /** + * Gets the media processor id. + * + * @return the media processor id + */ + public String getMediaProcessorId() { + return getContent().getMediaProcessorId(); + } + + /** + * Sets the media processor id. + * + * @param mediaProcessorId + * the media processor id + * @return the task info + */ + public TaskInfo setMediaProcessorId(String mediaProcessorId) { + getContent().setMediaProcessorId(mediaProcessorId); + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return getContent().getName(); + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the task info + */ + public TaskInfo setName(String name) { + getContent().setName(name); + return this; + } + + /** + * Gets the perf message. + * + * @return the perf message + */ + public String getPerfMessage() { + return getContent().getPerfMessage(); + } + + /** + * Sets the perf message. + * + * @param perfMessage + * the perf message + * @return the task info + */ + public TaskInfo setPerfMessage(String perfMessage) { + getContent().setPerfMessage(perfMessage); + return this; + } + + /** + * Gets the priority. + * + * @return the priority + */ + public int getPriority() { + return getContent().getPriority(); + } + + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the task info + */ + public TaskInfo setPriority(int priority) { + getContent().setPriority(priority); + return this; + } + + /** + * Gets the progress. + * + * @return the progress + */ + public double getProgress() { + return getContent().getProgress(); + } + + /** + * Sets the progress. + * + * @param progress + * the progress + * @return the task info + */ + public TaskInfo setProgress(int progress) { + getContent().setProgress(progress); + return this; + } + + /** + * Gets the running duration. + * + * @return the running duration + */ + public double getRunningDuration() { + return getContent().getRunningDuration(); + } + + /** + * Sets the running duration. + * + * @param runningDuration + * the running duration + * @return the task info + */ + public TaskInfo setRunningDuration(double runningDuration) { + getContent().setRunningDuration(runningDuration); + return this; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return getContent().getStartTime(); + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the task info + */ + public TaskInfo setStartTime(Date startTime) { + getContent().setStartTime(startTime); + return this; + } + + /** + * Gets the state. + * + * @return the state + */ + public int getState() { + return getContent().getState(); + } + + /** + * Sets the state. + * + * @param state + * the state + * @return the task info + */ + public TaskInfo setState(int state) { + getContent().setState(state); + return this; + } + + /** + * Gets the task body. + * + * @return the task body + */ + public String getTaskBody() { + return getContent().getTaskBody(); + } + + /** + * Sets the task body. + * + * @param taskBody + * the task body + * @return the task info + */ + public TaskInfo setTaskBody(String taskBody) { + getContent().setTaskBody(taskBody); + return this; + } + + /** + * Gets the options. + * + * @return the options + */ + public int getOptions() { + return getContent().getOptions(); + } + + /** + * Sets the options. + * + * @param options + * the options + * @return the task info + */ + public TaskInfo setOptions(int options) { + getContent().setOptions(options); + return this; + } + + /** + * Gets the encryption key id. + * + * @return the encryption key id + */ + public String getEncryptionKeyId() { + return getContent().getEncryptionKeyId(); + } + + /** + * Sets the encryption key id. + * + * @param encryptionKeyId + * the encryption key id + * @return the task info + */ + public TaskInfo setEncryptionKeyId(String encryptionKeyId) { + getContent().setEncryptionKeyId(encryptionKeyId); + return this; + } + + /** + * Gets the encryption scheme. + * + * @return the encryption scheme + */ + public String getEncryptionScheme() { + return getContent().getEncryptionScheme(); + } + + /** + * Sets the encryption scheme. + * + * @param encryptionScheme + * the encryption scheme + * @return the task info + */ + public TaskInfo setEncryptionScheme(String encryptionScheme) { + getContent().setEncryptionScheme(encryptionScheme); + return this; + } + + /** + * Gets the encryption version. + * + * @return the encryption version + */ + public String getEncryptionVersion() { + return getContent().getEncryptionVersion(); + } + + /** + * Sets the encryption version. + * + * @param encryptionVersion + * the encryption version + * @return the task info + */ + public TaskInfo setEncryptionVersion(String encryptionVersion) { + getContent().setEncryptionVersion(encryptionVersion); + return this; + } + + /** + * Gets the initialization vector. + * + * @return the initialization vector + */ + public String getInitializationVector() { + return getContent().getInitializationVector(); + } + + /** + * Sets the initialization vector. + * + * @param initializationVector + * the initialization vector + * @return the task info + */ + public TaskInfo setInitializationVector(String initializationVector) { + getContent().setInitializationVector(initializationVector); + return this; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index bc5dce4cd103b..b7010e2a48f26 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -32,12 +32,17 @@ import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsResult; import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListTasksOptions; +import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; @@ -488,6 +493,7 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException { // Assert assertTrue(false); } + @Test public void listMediaProcessorsSuccess() throws ServiceException { // Arrange @@ -513,4 +519,130 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); } + @Test + public void createJobSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + JobInfo jobInfo = service.createJob(createJobOptions); + + // Assert + assertNotNull(jobInfo); + } + + @Test + public void listJobsSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + JobInfo jobInfoA = service.createJob(createJobOptions); + JobInfo jobInfoB = service.createJob(createJobOptions); + + // Act + ListJobsResult listJobsResult = service.listJobs(); + + // Assert + assertNotNull(listJobsResult); + } + + @Test + public void listTopJobsSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + JobInfo jobInfoA = service.createJob(createJobOptions); + JobInfo jobInfoB = service.createJob(createJobOptions); + + // Act + ListJobsResult listJobsResult = service.listJobs(); + + // Assert + assertNotNull(listJobsResult); + + } + + @Test + public void cancelJobSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + JobInfo jobInfo = service.createJob(createJobOptions); + + // Act + service.cancelJob(jobInfo.getId()); + + // Assert + + } + + @Test(expected = ServiceException.class) + public void cancelInvalidFailed() throws ServiceException { + // Arrange + + // Act + service.cancelJob("invalidJobId"); + + // Assert + } + + @Test + public void listTasksSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + ListTasksResult listTasksResult = service.listTasks(); + + // Assert + assertNotNull(listTasksResult); + assertEquals(1, listTasksResult.getTaskInfos().size()); + + } + + @Test + public void listTasksWithOptionsSuccess() { + // Arrange + + // Act + + // Assert + } + + @Test + public void listJobTasksSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + JobInfo jobInfo = service.createJob(createJobOptions); + + // Act + ListTasksResult listTasksResult = service.listJobTasks(jobInfo.getId()); + + // Assert + assertNotNull(listTasksResult); + } + + @Test + public void listJobTasksInvalidIdFailed() throws ServiceException { + // Arrange + + // Act + ListTasksResult listTasksResult = service.listJobTasks("InvalidJobId"); + + // Assert + assertNull(listTasksResult); + + } + + @Test + public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + JobInfo jobInfo = service.createJob(createJobOptions); + ListTasksOptions listTasksOptions = new ListTasksOptions(); + + // Act + ListTasksResult listTasksResult = service.listJobTasks(jobInfo.getId()); + + // Assert + assertNotNull(listTasksResult); + } + } From 806180adf18a36d728f395e303e9366ee50adef1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 22 Oct 2012 22:57:24 -0700 Subject: [PATCH 409/664] Adding explicit empty strings to PUT calls, to make sure the Content-Length header gets added, so the calls can be used with SAS tokens. See #384. --- .../implementation/BlobOperationRestProxy.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index dda7239362456..53dd40f5ed7ea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -451,7 +451,7 @@ public void setContainerMetadata(String container, HashMap<String, String> metad builder = addOptionalMetadataHeader(builder, metadata); builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - builder.put(); + builder.put(""); } @Override @@ -511,7 +511,7 @@ public CreateBlobResult createPageBlob(String container, String blob, long lengt builder = addOptionalHeader(builder, "x-ms-blob-sequence-number", options.getSequenceNumber()); builder = addPutBlobHeaders(options, builder); - ClientResponse clientResponse = builder.put(ClientResponse.class); + ClientResponse clientResponse = builder.put(ClientResponse.class, ""); ThrowIfError(clientResponse); CreateBlobResult createBlobResult = new CreateBlobResult(); @@ -617,7 +617,7 @@ public SetBlobPropertiesResult setBlobProperties(String container, String blob, builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - ClientResponse response = builder.put(ClientResponse.class); + ClientResponse response = builder.put(ClientResponse.class, ""); ThrowIfError(response); SetBlobPropertiesResult result = new SetBlobPropertiesResult(); @@ -648,7 +648,7 @@ public SetBlobMetadataResult setBlobMetadata(String container, String blob, Hash builder = addOptionalMetadataHeader(builder, metadata); builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - ClientResponse response = builder.put(ClientResponse.class); + ClientResponse response = builder.put(ClientResponse.class, ""); ThrowIfError(response); SetBlobMetadataResult result = new SetBlobMetadataResult(); @@ -725,7 +725,7 @@ public CreateBlobSnapshotResult createBlobSnapshot(String container, String blob builder = addOptionalMetadataHeader(builder, options.getMetadata()); builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - ClientResponse response = builder.put(ClientResponse.class); + ClientResponse response = builder.put(ClientResponse.class, ""); ThrowIfError(response); CreateBlobSnapshotResult blobSnapshot = new CreateBlobSnapshotResult(); @@ -757,7 +757,7 @@ public CopyBlobResult copyBlob(String destinationContainer, String destinationBl builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); builder = addOptionalSourceAccessConditionHeader(builder, options.getSourceAccessCondition()); - ClientResponse clientResponse = builder.put(ClientResponse.class); + ClientResponse clientResponse = builder.put(ClientResponse.class, ""); ThrowIfError(clientResponse); CopyBlobResult copyBlobResult = new CopyBlobResult(); @@ -822,7 +822,7 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St builder = addOptionalAccessConditionHeader(builder, accessCondition); // Note: Add content type here to enable proper HMAC signing - ClientResponse response = builder.put(ClientResponse.class); + ClientResponse response = builder.put(ClientResponse.class, ""); ThrowIfError(response); AcquireLeaseResult result = new AcquireLeaseResult(); @@ -867,7 +867,8 @@ private CreateBlobPagesResult updatePageBlobPagesImpl(String action, String cont builder = addOptionalHeader(builder, "x-ms-page-write", action); builder = addOptionalAccessConditionHeader(builder, options.getAccessCondition()); - ClientResponse response = builder.put(ClientResponse.class, contentStream); + Object contentObject = (contentStream == null ? new byte[0] : contentStream); + ClientResponse response = builder.put(ClientResponse.class, contentObject); ThrowIfError(response); CreateBlobPagesResult result = new CreateBlobPagesResult(); From 23dd82cac488339fb534bb1ed329fe144202d81a Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 23 Oct 2012 08:36:15 -0700 Subject: [PATCH 410/664] Refactor Replace hard-coded "urn:WindowsAzureMediaServices" in tests with OAUTH_SCOPE Fix #419 --- .../implementation/OAuthRestProxyIntegrationTest.java | 2 +- .../media/implementation/OAuthTokenManagerTest.java | 11 ++++------- .../ODataSerializationFromJerseyTest.java | 3 ++- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java index 13bede0a0db30..230bcfc1fa6c3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java @@ -34,7 +34,7 @@ public void serviceCanBeCalledToCreateAccessToken() throws Exception { URI oAuthUri = new URI((String) config.getProperty(MediaConfiguration.OAUTH_URI)); String clientId = (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_ID); String clientSecret = (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET); - String scope = "urn:WindowsAzureMediaServices"; + String scope = (String) config.getProperty(MediaConfiguration.OAUTH_SCOPE); OAuthTokenResponse result = oAuthContract.getAccessToken(oAuthUri, clientId, clientSecret, scope); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index 8d6733e772a93..98bd6beeab977 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -52,7 +52,7 @@ public void init() throws URISyntaxException { String acsBaseUri = "testurl"; String accountName = "testname"; String accountPassword = "testpassword"; - String scope = "urn:WindowsAzureMediaServices"; + String scope = "testscope"; client = new OAuthTokenManager(contract, dateFactory, acsBaseUri, accountName, accountPassword, scope); @@ -77,8 +77,7 @@ public OAuthTokenResponse answer(InvocationOnMock invocation) throws Throwable { wrapResponse.setExpiresIn(83); return wrapResponse; } - }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", - "urn:WindowsAzureMediaServices"); + }).when(contract).getAccessToken(new URI("testurl"), "testname", "testpassword", "testscope"); } @@ -113,8 +112,7 @@ public void clientWillNotCallMultipleTimesWhileAccessTokenIsValid() throws Servi assertEquals("testaccesstoken1-1", accessToken2); assertEquals("testaccesstoken1-1", accessToken3); - verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", - "urn:WindowsAzureMediaServices"); + verify(contract, times(1)).getAccessToken(new URI("testurl"), "testname", "testpassword", "testscope"); } @Test @@ -134,8 +132,7 @@ public void clientWillBeCalledWhenTokenIsHalfwayToExpiring() throws ServiceExcep assertEquals("testaccesstoken1-1", accessToken2); assertEquals("testaccesstoken1-2", accessToken3); - verify(contract, times(2)).getAccessToken(new URI("testurl"), "testname", "testpassword", - "urn:WindowsAzureMediaServices"); + verify(contract, times(2)).getAccessToken(new URI("testurl"), "testname", "testpassword", "testscope"); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index b056a38818a6d..6ee6d7d77b4e3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -80,7 +80,8 @@ private OAuthTokenManager createTokenManager() throws URISyntaxException { return new OAuthTokenManager(createOAuthContract(), new DefaultDateFactory(), (String) config.getProperty(MediaConfiguration.OAUTH_URI), (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_ID), - (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET), "urn:WindowsAzureMediaServices"); + (String) config.getProperty(MediaConfiguration.OAUTH_CLIENT_SECRET), + (String) config.getProperty(MediaConfiguration.OAUTH_SCOPE)); } private ResourceLocationManager createLocationManager() throws URISyntaxException { From 70c8a21cabf36688f7f1a0ace5dc771298758f1e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 23 Oct 2012 14:49:03 -0700 Subject: [PATCH 411/664] adds unit tests for Create Job Options --- .../services/media/MediaContract.java | 78 ++++++++ .../media/implementation/MediaRestProxy.java | 31 +++ .../implementation/ODataAtomMarshaller.java | 10 +- .../implementation/content/ObjectFactory.java | 18 ++ .../media/models/CreateJobOptions.java | 177 ++++++++++++++++++ .../media/MediaServiceIntegrationTest.java | 2 +- .../media/models/CreateJobOptionsTest.java | 147 +++++++++++++++ 7 files changed, 459 insertions(+), 4 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 7d36d56449d3a..8a66970cb9ad8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -299,22 +299,100 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) throws ServiceException; + /** + * Creates the job. + * + * @param createJobOptions + * the create job options + * @return the job info + * @throws ServiceException + * the service exception + */ public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceException; + /** + * Gets the job. + * + * @param jobId + * the job id + * @return the job + * @throws ServiceException + * the service exception + */ public JobInfo getJob(String jobId) throws ServiceException; + /** + * List jobs. + * + * @return the list jobs result + * @throws ServiceException + * the service exception + */ public ListJobsResult listJobs() throws ServiceException; + /** + * List jobs. + * + * @param listJobsOptions + * the list jobs options + * @return the list jobs result + * @throws ServiceException + * the service exception + */ public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException; + /** + * Cancel job. + * + * @param jobId + * the job id + * @throws ServiceException + * the service exception + */ public void cancelJob(String jobId) throws ServiceException; + /** + * List tasks. + * + * @return the list tasks result + * @throws ServiceException + * the service exception + */ public ListTasksResult listTasks() throws ServiceException; + /** + * List tasks. + * + * @param listTasksOptions + * the list tasks options + * @return the list tasks result + * @throws ServiceException + * the service exception + */ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException; + /** + * List job tasks. + * + * @param jobId + * the job id + * @return the list tasks result + * @throws ServiceException + * the service exception + */ public ListTasksResult listJobTasks(String jobId) throws ServiceException; + /** + * List job tasks. + * + * @param jobId + * the job id + * @param listTasksOptions + * the list tasks options + * @return the list tasks result + * @throws ServiceException + * the service exception + */ public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 8c3f3283f172b..32eb7a534c085 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -495,16 +495,26 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions return listMediaProcessorsResult; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobs() + */ @Override public ListJobsResult listJobs() throws ServiceException { return listJobs(null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(com.microsoft.windowsazure.services.media.models.CreateJobOptions) + */ @Override public JobInfo createJob(CreateJobOptions createJobOptions) { JobType jobType = new JobType(); if (createJobOptions != null) { + if (createJobOptions.getTaskInfos().size() > 0) { + String taskString = ""; + jobType.setTasks(taskString); + } } WebResource resource = getResource("Jobs"); @@ -513,6 +523,9 @@ public JobInfo createJob(CreateJobOptions createJobOptions) { .post(JobInfo.class, jobType); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) + */ @Override public void cancelJob(String jobId) throws ServiceException { try { @@ -523,12 +536,18 @@ public void cancelJob(String jobId) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getJob(java.lang.String) + */ @Override public JobInfo getJob(String jobId) throws ServiceException { WebResource resource = getResource("Jobs", jobId); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML).get(JobInfo.class); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobs(com.microsoft.windowsazure.services.media.models.ListJobsOptions) + */ @Override public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException { WebResource resource = getResource("Jobs"); @@ -545,6 +564,9 @@ public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceEx return listJobsResult; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listTasks(com.microsoft.windowsazure.services.media.models.ListTasksOptions) + */ @Override public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException { WebResource resource = getResource("Tasks"); @@ -562,6 +584,9 @@ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws Servi } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobTasks(java.lang.String, com.microsoft.windowsazure.services.media.models.ListTasksOptions) + */ @Override public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { WebResource resource = getResource("Jobs('')/Tasks", jobId); @@ -579,11 +604,17 @@ public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOpti } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listTasks() + */ @Override public ListTasksResult listTasks() throws ServiceException { return listTasks(null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobTasks(java.lang.String) + */ @Override public ListTasksResult listJobTasks(String jobId) throws ServiceException { return this.listJobTasks(jobId, null); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index d13efc0f2fa51..1ca5d0912c0af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -36,7 +36,9 @@ import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; /** * A class to manage marshalling of request parameters into @@ -113,11 +115,13 @@ private JAXBElement<EntryType> createEntry(Object content) { private static Class<?>[] getMarshalledClasses() { List<Class<?>> classes = new ArrayList<Class<?>>(); - classes.add(FeedType.class); - classes.add(EntryType.class); - classes.add(AssetType.class); classes.add(AccessPolicyType.class); + classes.add(AssetType.class); + classes.add(EntryType.class); + classes.add(FeedType.class); + classes.add(JobType.class); classes.add(LocatorRestType.class); + classes.add(TaskType.class); return classes.toArray(new Class<?>[0]); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index b23fcdbd34c68..b08fb967170e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -76,4 +76,22 @@ public LocatorRestType createLocatorRestType() { public MediaProcessorType createMediaProcessorType() { return new MediaProcessorType(); } + + /** + * Create an instance of {@link JobType} + * + * @return a new JobType instance. + */ + public JobType createJobType() { + return new JobType(); + } + + /** + * Create an instance of {@link TaskType} + * + * @return a new TaskType instance. + */ + public TaskType createTaskType() { + return new TaskType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java index a49e94921e517..7772e03f916f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -14,19 +14,49 @@ */ package com.microsoft.windowsazure.services.media.models; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * The Class CreateJobOptions. */ public class CreateJobOptions { + /** + * Instantiates a new creates the job options. + */ + public CreateJobOptions() { + this.taskInfos = new ArrayList<TaskInfo>(); + } + /** The expiration date time. */ private Date expirationDateTime; /** The start time. */ private Date startTime; + /** The task infos. */ + private List<TaskInfo> taskInfos; + + /** The name. */ + private String name; + + /** The priority. */ + private Integer priority; + + /** The running duration. */ + private double runningDuration; + + /** The template id. */ + private String templateId; + + /** The input media assets. */ + private String inputMediaAssets; + + /** The output media assets. */ + private String outputMediaAssets; + /** * Gets the expiration date time. * @@ -69,4 +99,151 @@ public CreateJobOptions setStartTime(Date startTime) { return this; } + /** + * Gets the task infos. + * + * @return the task infos + */ + public List<TaskInfo> getTaskInfos() { + return taskInfos; + } + + /** + * Sets the task infos. + * + * @param taskInfos + * the task infos + * @return the creates the job options + */ + public CreateJobOptions setTaskInfos(List<TaskInfo> taskInfos) { + this.taskInfos = taskInfos; + return this; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the creates the job options + */ + public CreateJobOptions setName(String name) { + this.name = name; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the creates the job options + */ + public CreateJobOptions setPriority(Integer priority) { + this.priority = priority; + return this; + } + + /** + * Gets the priority. + * + * @return the priority + */ + public Integer getPriority() { + return this.priority; + } + + /** + * Sets the running duration. + * + * @param runningDuration + * the running duration + * @return the creates the job options + */ + public CreateJobOptions setRunningDuration(double runningDuration) { + this.runningDuration = runningDuration; + return this; + } + + /** + * Gets the running duration. + * + * @return the running duration + */ + public double getRunningDuration() { + return this.runningDuration; + } + + /** + * Sets the template id. + * + * @param templateId + * the template id + * @return the creates the job options + */ + public CreateJobOptions setTemplateId(String templateId) { + this.templateId = templateId; + return this; + } + + /** + * Gets the template id. + * + * @return the template id + */ + public String getTemplateId() { + return this.templateId; + } + + /** + * Sets the input media assets. + * + * @param inputMediaAssets + * the input media assets + * @return the creates the job options + */ + public CreateJobOptions setInputMediaAssets(String inputMediaAssets) { + this.inputMediaAssets = inputMediaAssets; + return this; + } + + /** + * Gets the input media assets. + * + * @return the input media assets + */ + public String getInputMediaAssets() { + return this.inputMediaAssets; + } + + /** + * Sets the output media assets. + * + * @param outputMediaAssets + * the output media assets + * @return the creates the job options + */ + public CreateJobOptions setOutputMediaAssets(String outputMediaAssets) { + this.outputMediaAssets = outputMediaAssets; + return this; + } + + /** + * Gets the output media assets. + * + * @return the output media assets + */ + public String getOutputMediaAssets() { + return this.outputMediaAssets; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index b7010e2a48f26..5b5cf83bd377d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -574,7 +574,7 @@ public void cancelJobSuccess() throws ServiceException { } @Test(expected = ServiceException.class) - public void cancelInvalidFailed() throws ServiceException { + public void cancelInvalidJobFailed() throws ServiceException { // Arrange // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java new file mode 100644 index 0000000000000..567e43aa5ade5 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java @@ -0,0 +1,147 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.junit.Test; + +public class CreateJobOptionsTest { + + @Test + public void testGetSetName() { + // Arrange + String expectedJobName = "testGetSetNameJobName"; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + String actualJobName = createJobOptions.setName(expectedJobName).getName(); + + // Assert + assertEquals(expectedJobName, actualJobName); + } + + @Test + public void testGetSetEndTime() { + // Arrange + String expectedJobName = "testGetSetNameJobName"; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + String actualJobName = createJobOptions.setName(expectedJobName).getName(); + + // Assert + assertEquals(expectedJobName, actualJobName); + } + + @Test + public void testGetSetPriority() { + // Arrange + Integer expectedPriority = 3; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + Integer actualPriority = createJobOptions.setPriority(expectedPriority).getPriority(); + + // Assert + assertEquals(expectedPriority, actualPriority); + } + + @Test + public void testGetSetRunningDuration() { + // Arrange + double expectedRunningDuration = 2342.32; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + double actualRunningDuration = createJobOptions.setRunningDuration(expectedRunningDuration) + .getRunningDuration(); + + // Assert + assertTrue(expectedRunningDuration == actualRunningDuration); + } + + @Test + public void testGetSetStartTime() { + // Arrange + Date expectedStartTime = new Date(); + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + Date actualStartTime = createJobOptions.setStartTime(expectedStartTime).getStartTime(); + + // Assert + assertEquals(expectedStartTime, actualStartTime); + } + + @Test + public void testGetSetTemplateId() { + // Arrange + String expectedTemplateId = "testGetSetTemplateId"; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + String actualTemplateId = createJobOptions.setTemplateId(expectedTemplateId).getTemplateId(); + + // Assert + assertEquals(expectedTemplateId, actualTemplateId); + } + + @Test + public void testGetSetInputMediaAssets() { + // Arrange + String expectedInputMediaAssets = "testGetSetInputMediaAssets"; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + String actualInputMediaAssets = createJobOptions.setInputMediaAssets(expectedInputMediaAssets) + .getInputMediaAssets(); + + // Assert + assertEquals(expectedInputMediaAssets, actualInputMediaAssets); + } + + @Test + public void testGetSetOutputMediaAssets() { + // Arrange + String expectedOutputMediaAssets = "testGetSetOutputMediaAssets"; + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + String actualOutputMediaAssets = createJobOptions.setOutputMediaAssets(expectedOutputMediaAssets) + .getOutputMediaAssets(); + + // Assert + assertEquals(expectedOutputMediaAssets, actualOutputMediaAssets); + } + + @Test + public void testGetSetTasks() { + // Arrange + List<TaskInfo> expectedTaskInfos = new ArrayList<TaskInfo>(); + CreateJobOptions createJobOptions = new CreateJobOptions(); + + // Act + List<TaskInfo> actualTaskInfos = createJobOptions.setTaskInfos(expectedTaskInfos).getTaskInfos(); + + // Assert + assertEquals(expectedTaskInfos, actualTaskInfos); + } + +} From f028f42035a9d4a805e8d8bb44a49f6332ebed12 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 23 Oct 2012 15:14:44 -0700 Subject: [PATCH 412/664] Adding more unit tests for WritableBlobContainerContract, to cover all APIs. --- .../media/UploadingIntegrationTest.java | 68 +++++++++++++++---- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index a76f081ff94ab..2a89d4fe1a7b0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -20,8 +20,13 @@ import java.util.Date; import java.util.EnumSet; +import org.junit.BeforeClass; import org.junit.Test; +import com.microsoft.windowsazure.services.blob.models.BlockList; +import com.microsoft.windowsazure.services.blob.models.CommitBlobBlocksOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobBlockOptions; +import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; import com.microsoft.windowsazure.services.core.RetryPolicyFilter; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; @@ -37,33 +42,70 @@ * */ public class UploadingIntegrationTest extends IntegrationTestBase { + private static WritableBlobContainerContract blobWriter; + private static byte[] firstPrimes = new byte[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }; - @Test - public void canUploadBlockBlob() throws Exception { - MediaContract service = MediaService.create(config); + @BeforeClass + public static void setup() throws Exception { + IntegrationTestBase.setup(); - AssetInfo asset = service.createAsset(new CreateAssetOptions().setName("uploadBlockBlobAsset")); + AssetInfo asset = service.createAsset(new CreateAssetOptions() + .setName(testAssetPrefix + "uploadBlockBlobAsset")); - AccessPolicyInfo policy = service.createAccessPolicy("uploadWritePolicy", 10, + AccessPolicyInfo policy = service.createAccessPolicy(testPolicyPrefix + "uploadWritePolicy", 10, EnumSet.of(AccessPolicyPermission.WRITE)); Date now = new Date(); - Date fiveMinutesAgo = new Date(); - Date tenMinutesFromNow = new Date(); - - fiveMinutesAgo.setTime(now.getTime() - (5 * 60 * 1000)); - tenMinutesFromNow.setTime(now.getTime() + (10 * 60 * 1000)); + Date fiveMinutesAgo = new Date(now.getTime() - (5 * 60 * 1000)); + Date tenMinutesFromNow = new Date(now.getTime() + (10 * 60 * 1000)); LocatorInfo locator = service.createLocator(policy.getId(), asset.getId(), LocatorType.SAS, new CreateLocatorOptions().setStartTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + blobWriter = MediaService.createBlobWriter(locator); ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(5000, 5, new int[] { 400, 404 }); blobWriter = blobWriter.withFilter(new RetryPolicyFilter(retryPolicy)); + } - InputStream blobContent = new ByteArrayInputStream(new byte[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }); - + @Test + public void canUploadBlockBlob() throws Exception { + InputStream blobContent = new ByteArrayInputStream(firstPrimes); blobWriter.createBlockBlob("uploadBlockBlobTest", blobContent); } + + @Test + public void canUploadBlockBlobWithOptions() throws Exception { + InputStream blobContent = new ByteArrayInputStream(firstPrimes); + CreateBlobOptions options = new CreateBlobOptions().addMetadata("testMetadataKey", "testMetadataValue"); + blobWriter.createBlockBlob("canUploadBlockBlobWithOptions", blobContent, options); + } + + @Test + public void canCreateBlobBlock() throws Exception { + InputStream blobContent = new ByteArrayInputStream(firstPrimes); + blobWriter.createBlobBlock("canCreateBlobBlock", "123", blobContent); + } + + @Test + public void canCreateBlobBlockWithOptions() throws Exception { + InputStream blobContent = new ByteArrayInputStream(firstPrimes); + CreateBlobBlockOptions options = new CreateBlobBlockOptions().setTimeout(100); + blobWriter.createBlobBlock("canCreateBlobBlockWithOptions", "123", blobContent, options); + } + + @Test + public void canCommitBlobBlocks() throws Exception { + BlockList blockList = new BlockList(); + blobWriter.commitBlobBlocks("canCommitBlobBlocks", blockList); + } + + @Test + public void canCommitBlobBlocksWithOptions() throws Exception { + BlockList blockList = new BlockList(); + CommitBlobBlocksOptions options = new CommitBlobBlocksOptions() + .setBlobContentType("text/html;charset=ISO-8859-1"); + blobWriter.commitBlobBlocks("canCommitBlobBlocksWithOptions", blockList, options); + } + } From a4d026f863eff75a11cc7535053f10e55b7fa944 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 23 Oct 2012 22:47:08 -0700 Subject: [PATCH 413/664] clean up the CreateJobOptions, add two overloads for the createJob method. --- .../services/media/MediaContract.java | 19 +++- .../MediaExceptionProcessor.java | 48 +++++++- .../media/implementation/MediaRestProxy.java | 59 +++++++++- .../media/implementation/content/JobType.java | 59 ++++++---- .../media/models/CreateJobOptions.java | 105 ------------------ .../services/media/models/JobInfo.java | 4 +- .../media/MediaServiceIntegrationTest.java | 27 +++-- .../media/models/CreateJobOptionsTest.java | 42 ------- 8 files changed, 173 insertions(+), 190 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 8a66970cb9ad8..3ee3040fd88da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -37,10 +37,12 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.UniformInterfaceException; +// TODO: Auto-generated Javadoc /** * Defines the methods available for Windows Azure Media Services. */ @@ -302,13 +304,28 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions /** * Creates the job. * + * @param taskInfos + * the task infos * @param createJobOptions * the create job options * @return the job info * @throws ServiceException * the service exception */ - public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceException; + public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) throws ServiceException; + + /** + * Creates the job. + * + * @param templateId + * the template id + * @param createJobOptions + * the create job options + * @return the job info + * @throws ServiceException + * the service exception + */ + public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) throws ServiceException; /** * Gets the job. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index e20103bc5aefe..1df491bca80c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -45,6 +45,7 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.ClientHandlerException; @@ -462,6 +463,9 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobs() + */ @Override public ListJobsResult listJobs() throws ServiceException { try { @@ -476,10 +480,13 @@ public ListJobsResult listJobs() throws ServiceException { } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(java.util.List, com.microsoft.windowsazure.services.media.models.CreateJobOptions) + */ @Override - public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceException { + public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) throws ServiceException { try { - return service.createJob(createJobOptions); + return service.createJob(taskInfos, createJobOptions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -489,6 +496,9 @@ public JobInfo createJob(CreateJobOptions createJobOptions) throws ServiceExcept } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) + */ @Override public void cancelJob(String jobId) throws ServiceException { try { @@ -502,6 +512,9 @@ public void cancelJob(String jobId) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listTasks() + */ @Override public ListTasksResult listTasks() throws ServiceException { try { @@ -515,6 +528,9 @@ public ListTasksResult listTasks() throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobTasks(java.lang.String) + */ @Override public ListTasksResult listJobTasks(String jobId) throws ServiceException { try { @@ -528,6 +544,9 @@ public ListTasksResult listJobTasks(String jobId) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getJob(java.lang.String) + */ @Override public JobInfo getJob(String jobId) throws ServiceException { try { @@ -541,6 +560,9 @@ public JobInfo getJob(String jobId) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobs(com.microsoft.windowsazure.services.media.models.ListJobsOptions) + */ @Override public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceException { try { @@ -554,6 +576,9 @@ public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceEx } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listTasks(com.microsoft.windowsazure.services.media.models.ListTasksOptions) + */ @Override public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException { try { @@ -567,6 +592,9 @@ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws Servi } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#listJobTasks(java.lang.String, com.microsoft.windowsazure.services.media.models.ListTasksOptions) + */ @Override public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { try { @@ -579,4 +607,20 @@ public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOpti throw processCatch(new ServiceException(e)); } } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateJobOptions) + */ + @Override + public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) throws ServiceException { + try { + return service.createJob(templateId, createJobOptions); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 32eb7a534c085..d2549027d190c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -183,6 +183,31 @@ private WebResource getResource(String entityType, String entityId) throws Servi return getResource(entityPath); } + /** + * Gets the resource. + * + * @param entityType + * the entity type + * @param entityId + * the entity id + * @return the resource + * @throws ServiceException + * the service exception + */ + private WebResource getResource(String parentEntityType, String childEntityType, String entityId) + throws ServiceException { + String escapedEntityId = null; + try { + escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String entityPath = String.format("%s(\'%s\')/%s", parentEntityType, escapedEntityId, childEntityType); + + return getResource(entityPath); + } + /** * Merge request. * @@ -503,18 +528,40 @@ public ListJobsResult listJobs() throws ServiceException { return listJobs(null); } + @Override + public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) throws ServiceException { + JobType jobType = new JobType(); + jobType.setTemplateId(templateId); + + if (createJobOptions != null) { + jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); + jobType.setName(createJobOptions.getName()); + jobType.setOutputMediaAssets(createJobOptions.getOutputMediaAssets()); + jobType.setPriority(createJobOptions.getPriority()); + jobType.setStartTime(createJobOptions.getStartTime()); + } + + WebResource resource = getResource("Jobs"); + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .post(JobInfo.class, jobType); + + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(com.microsoft.windowsazure.services.media.models.CreateJobOptions) */ @Override - public JobInfo createJob(CreateJobOptions createJobOptions) { + public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) { JobType jobType = new JobType(); + String taskString = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"; + jobType.setTaskBody(taskString); if (createJobOptions != null) { - if (createJobOptions.getTaskInfos().size() > 0) { - String taskString = ""; - jobType.setTasks(taskString); - } + jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); + jobType.setName(createJobOptions.getName()); + jobType.setOutputMediaAssets(createJobOptions.getOutputMediaAssets()); + jobType.setPriority(createJobOptions.getPriority()); + jobType.setStartTime(createJobOptions.getStartTime()); } WebResource resource = getResource("Jobs"); @@ -589,7 +636,7 @@ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws Servi */ @Override public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { - WebResource resource = getResource("Jobs('')/Tasks", jobId); + WebResource resource = getResource("Jobs", "Tasks", jobId); if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { resource = resource.queryParams(listTasksOptions.getQueryParameters()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index cf02d83ab9666..5f04c03184eda 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -51,11 +51,11 @@ public class JobType implements MediaServiceDTO { /** The priority. */ @XmlElement(name = "Priority", namespace = Constants.ODATA_DATA_NS) - protected int priority; + protected Integer priority; /** The running duration. */ @XmlElement(name = "RunningDuration", namespace = Constants.ODATA_DATA_NS) - protected double runningDuration; + protected Double runningDuration; /** The start time. */ @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) @@ -63,7 +63,7 @@ public class JobType implements MediaServiceDTO { /** The state. */ @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) - protected int state; + protected Integer state; /** The template id. */ @XmlElement(name = "TemplateId", namespace = Constants.ODATA_DATA_NS) @@ -78,8 +78,8 @@ public class JobType implements MediaServiceDTO { protected String inputMediaAssets; /** The tasks. */ - @XmlElement(name = "Tasks", namespace = Constants.ODATA_DATA_NS) - protected String tasks; + @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) + protected String taskBody; /** * Gets the id. @@ -96,8 +96,9 @@ public String getId() { * @param id * the new id */ - public void setId(String id) { + public JobType setId(String id) { this.id = id; + return this; } /** @@ -115,8 +116,9 @@ public String getName() { * @param name * the new name */ - public void setName(String name) { + public JobType setName(String name) { this.name = name; + return this; } /** @@ -134,8 +136,9 @@ public Date getCreated() { * @param created * the new created */ - public void setCreated(Date created) { + public JobType setCreated(Date created) { this.created = created; + return this; } /** @@ -153,8 +156,9 @@ public Date getLastModified() { * @param lastModified * the new last modified */ - public void setLastModified(Date lastModified) { + public JobType setLastModified(Date lastModified) { this.lastModified = lastModified; + return this; } /** @@ -172,8 +176,9 @@ public Date getEndTime() { * @param endTime * the new end time */ - public void setEndTime(Date endTime) { + public JobType setEndTime(Date endTime) { this.endTime = endTime; + return this; } /** @@ -181,7 +186,7 @@ public void setEndTime(Date endTime) { * * @return the priority */ - public int getPriority() { + public Integer getPriority() { return priority; } @@ -191,8 +196,9 @@ public int getPriority() { * @param priority * the new priority */ - public void setPriority(int priority) { + public JobType setPriority(Integer priority) { this.priority = priority; + return this; } /** @@ -210,8 +216,9 @@ public double getRunningDuration() { * @param runningDuration * the new running duration */ - public void setRunningDuration(double runningDuration) { + public JobType setRunningDuration(double runningDuration) { this.runningDuration = runningDuration; + return this; } /** @@ -229,8 +236,9 @@ public Date getStartTime() { * @param startTime * the new start time */ - public void setStartTime(Date startTime) { + public JobType setStartTime(Date startTime) { this.startTime = startTime; + return this; } /** @@ -238,7 +246,7 @@ public void setStartTime(Date startTime) { * * @return the state */ - public int getState() { + public Integer getState() { return state; } @@ -248,8 +256,9 @@ public int getState() { * @param state * the new state */ - public void setState(int state) { + public JobType setState(Integer state) { this.state = state; + return this; } /** @@ -267,8 +276,9 @@ public String getTemplateId() { * @param templateId * the new template id */ - public void setTemplateId(String templateId) { + public JobType setTemplateId(String templateId) { this.templateId = templateId; + return this; } /** @@ -286,8 +296,9 @@ public String getOutputMediaAssets() { * @param outputMediaAssets * the new output media assets */ - public void setOutputMediaAssets(String outputMediaAssets) { + public JobType setOutputMediaAssets(String outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; + return this; } /** @@ -305,8 +316,9 @@ public String getInputMediaAssets() { * @param inputMediaAssets * the new input media assets */ - public void setInputMediaAssets(String inputMediaAssets) { + public JobType setInputMediaAssets(String inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; + return this; } /** @@ -314,8 +326,8 @@ public void setInputMediaAssets(String inputMediaAssets) { * * @return the tasks */ - public String getTasks() { - return tasks; + public String getTaskBody() { + return taskBody; } /** @@ -324,8 +336,9 @@ public String getTasks() { * @param tasks * the new tasks */ - public void setTasks(String tasks) { - this.tasks = tasks; + public JobType setTaskBody(String taskBody) { + this.taskBody = taskBody; + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java index 7772e03f916f3..bbeaace9626d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -14,70 +14,28 @@ */ package com.microsoft.windowsazure.services.media.models; -import java.util.ArrayList; import java.util.Date; -import java.util.List; /** * The Class CreateJobOptions. */ public class CreateJobOptions { - /** - * Instantiates a new creates the job options. - */ - public CreateJobOptions() { - this.taskInfos = new ArrayList<TaskInfo>(); - } - - /** The expiration date time. */ - private Date expirationDateTime; - /** The start time. */ private Date startTime; - /** The task infos. */ - private List<TaskInfo> taskInfos; - /** The name. */ private String name; /** The priority. */ private Integer priority; - /** The running duration. */ - private double runningDuration; - - /** The template id. */ - private String templateId; - /** The input media assets. */ private String inputMediaAssets; /** The output media assets. */ private String outputMediaAssets; - /** - * Gets the expiration date time. - * - * @return the expiration date time - */ - public Date getExpirationDateTime() { - return expirationDateTime; - } - - /** - * Sets the expiration date time. - * - * @param expirationDateTime - * the expiration date time - * @return the creates the locator options - */ - public CreateJobOptions setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - /** * Gets the start time. * @@ -99,27 +57,6 @@ public CreateJobOptions setStartTime(Date startTime) { return this; } - /** - * Gets the task infos. - * - * @return the task infos - */ - public List<TaskInfo> getTaskInfos() { - return taskInfos; - } - - /** - * Sets the task infos. - * - * @param taskInfos - * the task infos - * @return the creates the job options - */ - public CreateJobOptions setTaskInfos(List<TaskInfo> taskInfos) { - this.taskInfos = taskInfos; - return this; - } - /** * Sets the name. * @@ -162,48 +99,6 @@ public Integer getPriority() { return this.priority; } - /** - * Sets the running duration. - * - * @param runningDuration - * the running duration - * @return the creates the job options - */ - public CreateJobOptions setRunningDuration(double runningDuration) { - this.runningDuration = runningDuration; - return this; - } - - /** - * Gets the running duration. - * - * @return the running duration - */ - public double getRunningDuration() { - return this.runningDuration; - } - - /** - * Sets the template id. - * - * @param templateId - * the template id - * @return the creates the job options - */ - public CreateJobOptions setTemplateId(String templateId) { - this.templateId = templateId; - return this; - } - - /** - * Gets the template id. - * - * @return the template id - */ - public String getTemplateId() { - return this.templateId; - } - /** * Sets the input media assets. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 4206393aeb8f8..f23fc4f7eeb2e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -303,7 +303,7 @@ public JobInfo setOutputMediaAssets(String outputMediaAssets) { * @return the tasks */ public String getTasks() { - return getContent().getTasks(); + return getContent().getTaskBody(); } /** @@ -314,7 +314,7 @@ public String getTasks() { * @return the job info */ public JobInfo setTasks(String tasks) { - getContent().setTasks(tasks); + getContent().setTaskBody(tasks); return this; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index 5b5cf83bd377d..abbff8f367665 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -45,6 +45,7 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; @@ -520,12 +521,14 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { } @Test - public void createJobSuccess() throws ServiceException { + public void createJobWithTaskInfoSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); + TaskInfo taskInfo = new TaskInfo(); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); // Act - JobInfo jobInfo = service.createJob(createJobOptions); + JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); // Assert assertNotNull(jobInfo); @@ -535,8 +538,10 @@ public void createJobSuccess() throws ServiceException { public void listJobsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - JobInfo jobInfoA = service.createJob(createJobOptions); - JobInfo jobInfoB = service.createJob(createJobOptions); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + + JobInfo jobInfoA = service.createJob(taskInfos, createJobOptions); + JobInfo jobInfoB = service.createJob(taskInfos, createJobOptions); // Act ListJobsResult listJobsResult = service.listJobs(); @@ -549,8 +554,9 @@ public void listJobsSuccess() throws ServiceException { public void listTopJobsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - JobInfo jobInfoA = service.createJob(createJobOptions); - JobInfo jobInfoB = service.createJob(createJobOptions); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + JobInfo jobInfoA = service.createJob(taskInfos, createJobOptions); + JobInfo jobInfoB = service.createJob(taskInfos, createJobOptions); // Act ListJobsResult listJobsResult = service.listJobs(); @@ -564,7 +570,8 @@ public void listTopJobsSuccess() throws ServiceException { public void cancelJobSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - JobInfo jobInfo = service.createJob(createJobOptions); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); // Act service.cancelJob(jobInfo.getId()); @@ -610,7 +617,8 @@ public void listTasksWithOptionsSuccess() { public void listJobTasksSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - JobInfo jobInfo = service.createJob(createJobOptions); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); // Act ListTasksResult listTasksResult = service.listJobTasks(jobInfo.getId()); @@ -635,7 +643,8 @@ public void listJobTasksInvalidIdFailed() throws ServiceException { public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - JobInfo jobInfo = service.createJob(createJobOptions); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); ListTasksOptions listTasksOptions = new ListTasksOptions(); // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java index 567e43aa5ade5..ff83a1d950480 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java @@ -16,9 +16,7 @@ import static org.junit.Assert.*; -import java.util.ArrayList; import java.util.Date; -import java.util.List; import org.junit.Test; @@ -63,20 +61,6 @@ public void testGetSetPriority() { assertEquals(expectedPriority, actualPriority); } - @Test - public void testGetSetRunningDuration() { - // Arrange - double expectedRunningDuration = 2342.32; - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - double actualRunningDuration = createJobOptions.setRunningDuration(expectedRunningDuration) - .getRunningDuration(); - - // Assert - assertTrue(expectedRunningDuration == actualRunningDuration); - } - @Test public void testGetSetStartTime() { // Arrange @@ -90,19 +74,6 @@ public void testGetSetStartTime() { assertEquals(expectedStartTime, actualStartTime); } - @Test - public void testGetSetTemplateId() { - // Arrange - String expectedTemplateId = "testGetSetTemplateId"; - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - String actualTemplateId = createJobOptions.setTemplateId(expectedTemplateId).getTemplateId(); - - // Assert - assertEquals(expectedTemplateId, actualTemplateId); - } - @Test public void testGetSetInputMediaAssets() { // Arrange @@ -131,17 +102,4 @@ public void testGetSetOutputMediaAssets() { assertEquals(expectedOutputMediaAssets, actualOutputMediaAssets); } - @Test - public void testGetSetTasks() { - // Arrange - List<TaskInfo> expectedTaskInfos = new ArrayList<TaskInfo>(); - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - List<TaskInfo> actualTaskInfos = createJobOptions.setTaskInfos(expectedTaskInfos).getTaskInfos(); - - // Assert - assertEquals(expectedTaskInfos, actualTaskInfos); - } - } From b71feafad90ff481d59e41e49d6af9a2daa68173 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 23 Oct 2012 23:15:02 -0700 Subject: [PATCH 414/664] fix for list tasks. --- .../media/implementation/MediaRestProxy.java | 10 ++++++++-- .../media/MediaServiceIntegrationTest.java | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index d2549027d190c..ae354c688a80d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -66,6 +66,7 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; +// TODO: Auto-generated Javadoc /** * The Class MediaRestProxy. */ @@ -186,8 +187,10 @@ private WebResource getResource(String entityType, String entityId) throws Servi /** * Gets the resource. * - * @param entityType - * the entity type + * @param parentEntityType + * the parent entity type + * @param childEntityType + * the child entity type * @param entityId * the entity id * @return the resource @@ -528,6 +531,9 @@ public ListJobsResult listJobs() throws ServiceException { return listJobs(null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateJobOptions) + */ @Override public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) throws ServiceException { JobType jobType = new JobType(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index abbff8f367665..e80337f7dec70 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -594,6 +594,8 @@ public void cancelInvalidJobFailed() throws ServiceException { public void listTasksSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + service.createJob(taskInfos, createJobOptions); // Act ListTasksResult listTasksResult = service.listTasks(); @@ -605,12 +607,20 @@ public void listTasksSuccess() throws ServiceException { } @Test - public void listTasksWithOptionsSuccess() { - // Arrange + public void listTasksWithOptionsSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + service.createJob(taskInfos, createJobOptions); + ListTasksOptions listTasksOptions = new ListTasksOptions(); + listTasksOptions.getQueryParameters().add("$top", "1"); // Act + ListTasksResult listTasksResult = service.listTasks(listTasksOptions); - // Assert + // Assert + assertNotNull(listTasksResult); + assertEquals(1, listTasksResult.getTaskInfos().size()); } @Test From 8f9664cbb730657b414ce0844c232c67562bfbd1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 24 Oct 2012 15:03:41 -0700 Subject: [PATCH 415/664] Update the Surefire config in the POM to include the default test files with a custom one (*Test.java) because we have 18 test files with that suffix. --- microsoft-azure-api/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 213d1c5ab7059..3e6f4750c2222 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -244,6 +244,14 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12</version> + <configuration> + <includes> + <include>**/Test*.java</include> + <include>**/*Test.java</include> + <include>**/*Tests.java</include> + <include>**/*TestCase.java</include> + </includes> + </configuration> </plugin> </plugins> </pluginManagement> From f04cd6367d16b6aca73a30c77a532f9f478d3936 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 25 Oct 2012 17:00:38 -0700 Subject: [PATCH 416/664] Idempotency for SAS Token auth filter, OAuth filter, and Redirect filter. Without this the ExponentialRetryFilter fails when used with Media Services pipeline. --- .../services/media/implementation/OAuthFilter.java | 5 +++++ .../services/media/implementation/RedirectFilter.java | 7 +++++++ .../services/media/implementation/SASTokenFilter.java | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index 326db58a005f6..e28c5805b3edd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -48,6 +48,11 @@ public OAuthFilter(OAuthTokenManager oAuthTokenManager) { */ @Override public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { + // Only do oauth process once + if (clientRequest.getProperties().containsKey("MediaServicesOAuthFilter")) { + return this.getNext().handle(clientRequest); + } + clientRequest.getProperties().put("MediaServicesOAuthFilter", this); String accessToken; try { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index f71ea6381653b..81d2cb2142c24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -36,6 +36,13 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio throw new IllegalArgumentException("Request should not be null"); } + // Only redirect once + if (request.getProperties().containsKey("MediaServicesRedirectFilter")) { + return this.getNext().handle(request); + } + + request.getProperties().put("MediaServicesRedirectFilter", this); + URI originalURI = request.getURI(); request.setURI(locationManager.getRedirectedURI(originalURI)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index 86742178acd0a..c5ba6254d9630 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -48,6 +48,11 @@ public SASTokenFilter(String sasToken) { */ @Override public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + if (cr.getProperties().containsKey("MediaServicesSASFilter")) { + return this.getNext().handle(cr); + } + cr.getProperties().put("MediaServicesSASFilter", this); + UriBuilder newUri = UriBuilder.fromUri(cr.getURI()); String currentQuery = cr.getURI().getRawQuery(); if (currentQuery == null) { From 3e3fff398129fc76e486c69489eabde12fa4fb6c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 25 Oct 2012 17:03:35 -0700 Subject: [PATCH 417/664] Removed unsettable members from options class. Fix #364 --- .../media/implementation/MediaRestProxy.java | 7 --- .../media/models/UpdateAssetOptions.java | 48 ------------------- .../services/media/AssetIntegrationTest.java | 14 +++--- .../media/models/UpdateAssetOptionsTest.java | 26 ---------- 4 files changed, 6 insertions(+), 89 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 27c358034e202..1bdb3dee18b7f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -280,13 +280,6 @@ public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) t AssetType updatedAssetType = new AssetType(); updatedAssetType.setAlternateId(updateAssetOptions.getAlternateId()); updatedAssetType.setName(updateAssetOptions.getName()); - if (updateAssetOptions.getOptions() != null) { - updatedAssetType.setOptions(updateAssetOptions.getOptions().getCode()); - } - - if (updateAssetOptions.getState() != null) { - updatedAssetType.setState(updateAssetOptions.getState().getCode()); - } ClientResponse clientResponse = mergeRequest("Assets", assetId, ClientResponse.class, updatedAssetType); PipelineHelpers.ThrowIfNotSuccess(clientResponse); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java index dd0affeac070e..559a01d2eebdb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java @@ -25,12 +25,6 @@ public class UpdateAssetOptions { /** The name. */ private String name; - /** The options. */ - private EncryptionOption options; - - /** The state. */ - private AssetState state; - /** * Gets the alternate id. * @@ -73,46 +67,4 @@ public UpdateAssetOptions setName(String name) { return this; } - /** - * Gets the options. - * - * @return the options - */ - public EncryptionOption getOptions() { - return options; - } - - /** - * Sets the options. - * - * @param options - * the options - * @return the update asset options - */ - public UpdateAssetOptions setOptions(EncryptionOption options) { - this.options = options; - return this; - } - - /** - * Gets the state. - * - * @return the state - */ - public AssetState getState() { - return state; - } - - /** - * Sets the state. - * - * @param assetState - * the asset state - * @return the update asset options - */ - public UpdateAssetOptions setState(AssetState assetState) { - this.state = assetState; - return this; - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 2bacc4e14c860..e0d0f304557ee 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -22,7 +22,6 @@ import java.util.Date; import java.util.List; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -205,28 +204,27 @@ public void canListAssetsWithOptions() throws ServiceException { assertEquals(2, listAssetResult.size()); } - @Ignore("https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/364") @Test public void updateAssetSuccess() throws Exception { // Arrange String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; + EncryptionOption originalEncryptionOption = EncryptionOption.StorageEncrypted; + AssetState originalAssetState = AssetState.Published; CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") - .setOptions(EncryptionOption.StorageEncrypted).setState(AssetState.Published).setName(originalTestName); + .setOptions(originalEncryptionOption).setState(originalAssetState).setName(originalTestName); AssetInfo originalAsset = service.createAsset(originalOptions); String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; String altId = "otherAltId"; - EncryptionOption encryptionOption = EncryptionOption.None; - AssetState assetState = AssetState.Initialized; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId) - .setOptions(encryptionOption).setState(assetState); + UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId); // Act service.updateAsset(originalAsset.getId(), updateAssetOptions); AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); // Assert - verifyAssetProperties("updatedAsset", updatedTestName, altId, encryptionOption, assetState, updatedAsset); + verifyAssetProperties("updatedAsset", updatedTestName, altId, originalEncryptionOption, originalAssetState, + updatedAsset); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java index be47f311119b2..624c3baaa11f1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java @@ -20,19 +20,6 @@ public class UpdateAssetOptionsTest { - @Test - public void testGetSetState() { - // Arrange - AssetState expectedState = AssetState.Published; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - AssetState actualState = updateAssetOptions.setState(expectedState).getState(); - - // Assert - assertEquals(expectedState, actualState); - } - @Test public void testGetSetAlternateId() { // Arrange @@ -59,17 +46,4 @@ public void testGetSetName() { assertEquals(expectedName, actualName); } - @Test - public void testGetSetOptions() { - // Arrange - EncryptionOption expectedOptions = EncryptionOption.None; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - EncryptionOption actualOptions = updateAssetOptions.setOptions(expectedOptions).getOptions(); - - // Assert - assertEquals(expectedOptions, actualOptions); - } - } From a08f46cdd0a0f1a69da8cecdf20b9f2f6b4f9c93 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 26 Oct 2012 11:46:31 -0700 Subject: [PATCH 418/664] address code review feedback. --- .../services/media/MediaContract.java | 3 +- .../MediaExceptionProcessor.java | 4 +- .../media/implementation/MediaRestProxy.java | 43 ++++++++----------- .../content/MediaProcessorType.java | 2 +- .../implementation/content/TaskType.java | 28 ++++++------ .../services/media/models/TaskInfo.java | 17 ++++---- .../media/MediaServiceIntegrationTest.java | 9 ++++ .../media/models/CreateJobOptionsTest.java | 13 ------ .../media/models/MediaProcessorInfoTest.java | 2 +- 9 files changed, 54 insertions(+), 67 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 3ee3040fd88da..c376c8ce7c2c0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -363,10 +363,11 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions * * @param jobId * the job id + * @return * @throws ServiceException * the service exception */ - public void cancelJob(String jobId) throws ServiceException; + public JobInfo cancelJob(String jobId) throws ServiceException; /** * List tasks. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 1df491bca80c9..ec64f2a17393f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -500,9 +500,9 @@ public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOpt * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) */ @Override - public void cancelJob(String jobId) throws ServiceException { + public JobInfo cancelJob(String jobId) throws ServiceException { try { - service.cancelJob(jobId); + return service.cancelJob(jobId); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index ae354c688a80d..26f410dcfa43c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -66,7 +66,6 @@ import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -// TODO: Auto-generated Javadoc /** * The Class MediaRestProxy. */ @@ -237,6 +236,19 @@ private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T return builder.post(c, requestEntity); } + private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksOptions listTasksOptions) { + if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { + webResource = webResource.queryParams(listTasksOptions.getQueryParameters()); + } + + List<TaskInfo> taskInfoList = webResource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() { + }); + ListTasksResult listTasksResult = new ListTasksResult(); + listTasksResult.setTaskInfos(taskInfoList); + return listTasksResult; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() */ @@ -580,9 +592,9 @@ public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOpt * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) */ @Override - public void cancelJob(String jobId) throws ServiceException { + public JobInfo cancelJob(String jobId) throws ServiceException { try { - getResource("Jobs", jobId).delete(); + return getResource("CancelJob").queryParam("jobId", jobId).get(JobInfo.class); } catch (UniformInterfaceException e) { throw new ServiceException(e); @@ -623,18 +635,7 @@ public ListJobsResult listJobs(ListJobsOptions listJobsOptions) throws ServiceEx @Override public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws ServiceException { WebResource resource = getResource("Tasks"); - - if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { - resource = resource.queryParams(listTasksOptions.getQueryParameters()); - } - - List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) - .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() { - }); - ListTasksResult listTasksResult = new ListTasksResult(); - listTasksResult.setTaskInfos(taskInfoList); - return listTasksResult; - + return listWebResourceTasks(resource, listTasksOptions); } /* (non-Javadoc) @@ -643,17 +644,7 @@ public ListTasksResult listTasks(ListTasksOptions listTasksOptions) throws Servi @Override public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException { WebResource resource = getResource("Jobs", "Tasks", jobId); - - if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { - resource = resource.queryParams(listTasksOptions.getQueryParameters()); - } - - List<TaskInfo> taskInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) - .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<TaskInfo>>() { - }); - ListTasksResult listTasksResult = new ListTasksResult(); - listTasksResult.setTaskInfos(taskInfoList); - return listTasksResult; + return listWebResourceTasks(resource, listTasksOptions); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java index f76d61e200192..de8338173a9b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -100,7 +100,7 @@ public void setVendor(String vendor) { } public String getVersion() { - return null; + return this.version; } public void setVersion(String version) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index aa205aee185f7..c032b1c6c359c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -51,19 +51,19 @@ public class TaskType implements MediaServiceDTO { protected String perfMessage; @XmlElement(name = "Priority", namespace = Constants.ODATA_DATA_NS) - protected int priority; + protected Integer priority; @XmlElement(name = "Progress", namespace = Constants.ODATA_DATA_NS) - protected double progress; + protected Double progress; @XmlElement(name = "RunningDuration", namespace = Constants.ODATA_DATA_NS) - protected double runningDuration; + protected Double runningDuration; @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) protected Date startTime; @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) - protected int state; + protected Integer state; @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) protected String taskBody; @@ -145,27 +145,27 @@ public void setPerfMessage(String perfMessage) { this.perfMessage = perfMessage; } - public int getPriority() { + public Integer getPriority() { return priority; } - public void setPriority(int priority) { + public void setPriority(Integer priority) { this.priority = priority; } - public double getProgress() { + public Double getProgress() { return progress; } - public void setProgress(double progress) { + public void setProgress(Double progress) { this.progress = progress; } - public double getRunningDuration() { + public Double getRunningDuration() { return runningDuration; } - public void setRunningDuration(double runningDuration) { + public void setRunningDuration(Double runningDuration) { this.runningDuration = runningDuration; } @@ -177,11 +177,11 @@ public void setStartTime(Date startTime) { this.startTime = startTime; } - public int getState() { + public Integer getState() { return state; } - public void setState(int state) { + public void setState(Integer state) { this.state = state; } @@ -193,11 +193,11 @@ public void setTaskBody(String taskBody) { this.taskBody = taskBody; } - public int getOptions() { + public Integer getOptions() { return options; } - public void setOptions(int options) { + public void setOptions(Integer options) { this.options = options; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index ca62a76504405..dda71ca5e6ea2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -197,7 +197,7 @@ public TaskInfo setPerfMessage(String perfMessage) { * * @return the priority */ - public int getPriority() { + public Integer getPriority() { return getContent().getPriority(); } @@ -208,7 +208,7 @@ public int getPriority() { * the priority * @return the task info */ - public TaskInfo setPriority(int priority) { + public TaskInfo setPriority(Integer priority) { getContent().setPriority(priority); return this; } @@ -218,18 +218,17 @@ public TaskInfo setPriority(int priority) { * * @return the progress */ - public double getProgress() { + public Double getProgress() { return getContent().getProgress(); } /** - * Sets the progress. * * @param progress * the progress * @return the task info */ - public TaskInfo setProgress(int progress) { + public TaskInfo setProgress(Double progress) { getContent().setProgress(progress); return this; } @@ -281,7 +280,7 @@ public TaskInfo setStartTime(Date startTime) { * * @return the state */ - public int getState() { + public Integer getState() { return getContent().getState(); } @@ -292,7 +291,7 @@ public int getState() { * the state * @return the task info */ - public TaskInfo setState(int state) { + public TaskInfo setState(Integer state) { getContent().setState(state); return this; } @@ -323,7 +322,7 @@ public TaskInfo setTaskBody(String taskBody) { * * @return the options */ - public int getOptions() { + public Integer getOptions() { return getContent().getOptions(); } @@ -334,7 +333,7 @@ public int getOptions() { * the options * @return the task info */ - public TaskInfo setOptions(int options) { + public TaskInfo setOptions(Integer options) { getContent().setOptions(options); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index e80337f7dec70..93aa12c6ef90b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -520,6 +520,7 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); } + @Ignore @Test public void createJobWithTaskInfoSuccess() throws ServiceException { // Arrange @@ -534,6 +535,7 @@ public void createJobWithTaskInfoSuccess() throws ServiceException { assertNotNull(jobInfo); } + @Ignore @Test public void listJobsSuccess() throws ServiceException { // Arrange @@ -550,6 +552,7 @@ public void listJobsSuccess() throws ServiceException { assertNotNull(listJobsResult); } + @Ignore @Test public void listTopJobsSuccess() throws ServiceException { // Arrange @@ -566,6 +569,7 @@ public void listTopJobsSuccess() throws ServiceException { } + @Ignore @Test public void cancelJobSuccess() throws ServiceException { // Arrange @@ -590,6 +594,7 @@ public void cancelInvalidJobFailed() throws ServiceException { // Assert } + @Ignore @Test public void listTasksSuccess() throws ServiceException { // Arrange @@ -606,6 +611,7 @@ public void listTasksSuccess() throws ServiceException { } + @Ignore @Test public void listTasksWithOptionsSuccess() throws ServiceException { // Arrange @@ -623,6 +629,7 @@ public void listTasksWithOptionsSuccess() throws ServiceException { assertEquals(1, listTasksResult.getTaskInfos().size()); } + @Ignore @Test public void listJobTasksSuccess() throws ServiceException { // Arrange @@ -637,6 +644,7 @@ public void listJobTasksSuccess() throws ServiceException { assertNotNull(listTasksResult); } + @Ignore @Test public void listJobTasksInvalidIdFailed() throws ServiceException { // Arrange @@ -649,6 +657,7 @@ public void listJobTasksInvalidIdFailed() throws ServiceException { } + @Ignore @Test public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException { // Arrange diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java index ff83a1d950480..7190b2aca62fd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java @@ -35,19 +35,6 @@ public void testGetSetName() { assertEquals(expectedJobName, actualJobName); } - @Test - public void testGetSetEndTime() { - // Arrange - String expectedJobName = "testGetSetNameJobName"; - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - String actualJobName = createJobOptions.setName(expectedJobName).getName(); - - // Assert - assertEquals(expectedJobName, actualJobName); - } - @Test public void testGetSetPriority() { // Arrange diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java index c681bf4cfbaf1..c247486b1c482 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -95,7 +95,7 @@ public void testGetSetVersion() { MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); // Act - String actualVersion = mediaProcessorInfo.setName(expectedVersion).getVersion(); + String actualVersion = mediaProcessorInfo.setVersion(expectedVersion).getVersion(); // Assert assertEquals(expectedVersion, actualVersion); From c01d1da0648c8501d0e4aa24c617c7961d2771b1 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 29 Oct 2012 14:30:19 -0700 Subject: [PATCH 419/664] initial commit for media service batch operation. --- .../services/media/MediaContract.java | 9 +- .../implementation/CreateJobOperation.java | 18 + .../implementation/CreateTaskOperation.java | 18 + .../implementation/MediaBatchOperations.java | 341 ++++++++++++++++++ .../MediaExceptionProcessor.java | 7 +- .../media/implementation/MediaRestProxy.java | 86 ++++- .../implementation/ODataAtomMarshaller.java | 1 + .../media/implementation/Operation.java | 5 + .../SetBoundaryMultipartDataSource.java | 48 +++ .../media/models/CreateTaskOptions.java | 306 ++++++++++++++++ .../media/models/ListTasksOptions.java | 1 + .../media/MediaServiceIntegrationTest.java | 54 +-- 12 files changed, 859 insertions(+), 35 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 3ee3040fd88da..33b60d6da0cd0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; @@ -37,7 +38,6 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.UniformInterfaceException; @@ -304,15 +304,16 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions /** * Creates the job. * - * @param taskInfos - * the task infos + * @param createTaskOptions + * the create task options * @param createJobOptions * the create job options * @return the job info * @throws ServiceException * the service exception */ - public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) throws ServiceException; + public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptions> createTaskOptions) + throws ServiceException; /** * Creates the job. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java new file mode 100644 index 0000000000000..9abd8e46b5025 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java @@ -0,0 +1,18 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import com.microsoft.windowsazure.services.media.implementation.content.JobType; + +public class CreateJobOperation implements Operation { + + private JobType jobType; + + public CreateJobOperation setJob(JobType jobType) { + this.jobType = jobType; + return this; + } + + public JobType getJob() { + return this.jobType; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java new file mode 100644 index 0000000000000..5e16e7d0ef0d2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java @@ -0,0 +1,18 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; + +public class CreateTaskOperation implements Operation { + + private TaskType taskType; + + public CreateTaskOperation setTask(TaskType taskType) { + this.taskType = taskType; + return this; + } + + public TaskType getTask() { + return this.taskType; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java new file mode 100644 index 0000000000000..7b6bc6447be04 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -0,0 +1,341 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.UUID; + +import javax.activation.DataHandler; +import javax.activation.DataSource; +import javax.mail.Header; +import javax.mail.MessagingException; +import javax.mail.internet.InternetHeaders; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMultipart; +import javax.ws.rs.core.UriBuilder; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; + +/** + * The Class MediaBatchOperations. + */ +public class MediaBatchOperations { + + /** The operations. */ + private final List<Operation> operations; + + /** The service uri. */ + private final URI serviceURI; + + /** The Odata atom marshaller. */ + private final ODataAtomMarshaller oDataAtomMarshaller; + + /** + * Instantiates a new media batch operations. + * + * @param serviceURI + * the service uri + * @throws JAXBException + * the jAXB exception + * @throws ParserConfigurationException + * the parser configuration exception + */ + public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigurationException { + this.serviceURI = serviceURI; + this.oDataAtomMarshaller = new ODataAtomMarshaller(); + this.operations = new ArrayList<Operation>(); + } + + /** + * Gets the mime multipart. + * + * @return the mime multipart + * @throws MessagingException + * the messaging exception + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws JAXBException + * the jAXB exception + */ + public MimeMultipart getMimeMultipart() throws MessagingException, IOException, JAXBException { + List<DataSource> bodyPartContents = new ArrayList<DataSource>(); + int contentId = 1; + + int jobContentId = addJobPart(bodyPartContents, contentId); + URI taskURI = UriBuilder.fromUri(serviceURI).path(String.format("$%d", jobContentId)).path("Tasks").build(); + addTaskPart(bodyPartContents, taskURI, contentId); + + return toMimeMultipart(bodyPartContents); + + } + + /** + * Adds the job part. + * + * @param bodyPartContents + * the body part contents + * @param contentId + * the content id + * @return the int + * @throws JAXBException + * the jAXB exception + */ + private int addJobPart(List<DataSource> bodyPartContents, int contentId) throws JAXBException { + int jobContentId = contentId; + ValidateJobOperation(); + + for (Operation operation : operations) { + DataSource bodyPartContent = null; + if (operation instanceof CreateJobOperation) { + CreateJobOperation createJobOperation = (CreateJobOperation) operation; + jobContentId = contentId; + URI jobUri = null; + bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getJob(), jobUri, contentId); + contentId++; + if (bodyPartContent != null) { + bodyPartContents.add(bodyPartContent); + break; + } + } + } + return jobContentId; + } + + private void ValidateJobOperation() { + int jobCount = 0; + for (Operation operation : operations) { + if (operation instanceof CreateJobOperation) { + jobCount++; + } + } + + if (jobCount != 1) { + throw new IllegalArgumentException(String.format( + "The Job operation is invalid, expect 1 but get %s job(s). ", jobCount)); + } + } + + /** + * Adds the task part. + * + * @param bodyPartContents + * the body part contents + * @param taskURI + * the task uri + * @param contentId + * the content id + * @throws JAXBException + * the jAXB exception + */ + private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int contentId) throws JAXBException { + for (Operation operation : operations) { + DataSource bodyPartContent = null; + if (operation instanceof CreateTaskOperation) { + CreateTaskOperation createTaskOperation = (CreateTaskOperation) operation; + bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation, taskURI, contentId); + contentId++; + } + + if (bodyPartContent != null) { + bodyPartContents.add(bodyPartContent); + } + } + } + + /** + * To mime multipart. + * + * @param bodyPartContents + * the body part contents + * @return the mime multipart + * @throws MessagingException + * the messaging exception + * @throws IOException + * Signals that an I/O exception has occurred. + */ + private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws MessagingException, IOException { + // Create unique part boundary strings + String batchId = String.format("batch_%s", UUID.randomUUID().toString()); + String changeSet = String.format("changeset_%s", UUID.randomUUID().toString()); + + // + // Build inner list of change sets containing the list of body part content + // + MimeMultipart changeSets = new MimeMultipart(new SetBoundaryMultipartDataSource(changeSet)); + + for (DataSource bodyPart : bodyPartContents) { + MimeBodyPart mimeBodyPart = new MimeBodyPart(); + + mimeBodyPart.setDataHandler(new DataHandler(bodyPart)); + mimeBodyPart.setHeader("Content-Type", bodyPart.getContentType()); + mimeBodyPart.setHeader("Content-Transfer-Encoding", "binary"); + + changeSets.addBodyPart(mimeBodyPart); + } + + // + // Build outer "batch" body part + // + MimeBodyPart batchbody = new MimeBodyPart(); + batchbody.setContent(changeSets); + //Note: Both content type and encoding need to be set *after* setting content, because + // MimeBodyPart implementation replaces them when calling "setContent". + batchbody.setHeader("Content-Type", changeSets.getContentType()); + + // + // Build outer "batch" multipart + // + MimeMultipart batch = new MimeMultipart(new SetBoundaryMultipartDataSource(batchId)); + batch.addBodyPart(batchbody); + return batch; + + } + + /** + * Creates the batch create entity part. + * + * @param entityName + * the entity name + * @param entity + * the entity + * @param uri + * the uri + * @param contentId + * the content id + * @return the data source + * @throws JAXBException + * the jAXB exception + */ + private DataSource createBatchCreateEntityPart(String entityName, Object entity, URI uri, int contentId) + throws JAXBException { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + this.oDataAtomMarshaller.marshalEntry(entity, stream); + byte[] bytes = stream.toByteArray(); + + // adds header + InternetHeaders headers = new InternetHeaders(); + headers.addHeader("Content-ID", Integer.toString(contentId)); + headers.addHeader("Content-Type", "application/atom+xml;type=entry"); + headers.addHeader("Content-Length", Integer.toString(bytes.length)); + + // adds body + ByteArrayOutputStream httpRequest = new ByteArrayOutputStream(); + addHttpMethod(httpRequest, "POST", uri); + appendHeaders(httpRequest, headers); + appendEntity(httpRequest, new ByteArrayInputStream(bytes)); + + DataSource bodyPartContent = new InputStreamDataSource(new ByteArrayInputStream(httpRequest.toByteArray()), + "application/http"); + return bodyPartContent; + } + + /** + * Adds the operation. + * + * @param operation + * the operation + */ + public void addOperation(Operation operation) { + this.operations.add(operation); + } + + /** + * Adds the http method. + * + * @param outputStream + * the output stream + * @param verb + * the verb + * @param uri + * the uri + */ + private void addHttpMethod(ByteArrayOutputStream outputStream, String verb, URI uri) { + try { + String method = String.format("%s %s HTTP/1.1\r\n", verb, uri); + outputStream.write(method.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Append headers. + * + * @param outputStream + * the output stream + * @param internetHeaders + * the internet headers + */ + private void appendHeaders(OutputStream outputStream, InternetHeaders internetHeaders) { + try { + // Headers + @SuppressWarnings("unchecked") + Enumeration<Header> headers = internetHeaders.getAllHeaders(); + while (headers.hasMoreElements()) { + Header header = headers.nextElement(); + String headerLine = String.format("%s: %s\r\n", header.getName(), header.getValue()); + outputStream.write(headerLine.getBytes("UTF-8")); + } + + // Empty line + outputStream.write("\r\n".getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Append entity. + * + * @param outputStream + * the output stream + * @param byteArrayInputStream + * the byte array input stream + */ + private void appendEntity(OutputStream outputStream, ByteArrayInputStream byteArrayInputStream) { + try { + byte[] buffer = new byte[1024]; + while (true) { + int bytesRead = byteArrayInputStream.read(buffer); + if (bytesRead <= 0) + break; + outputStream.write(buffer, 0, bytesRead); + } + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 1df491bca80c9..298ddc991d1df 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -32,6 +32,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; @@ -45,7 +46,6 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.ClientHandlerException; @@ -484,9 +484,10 @@ public ListJobsResult listJobs() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(java.util.List, com.microsoft.windowsazure.services.media.models.CreateJobOptions) */ @Override - public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) throws ServiceException { + public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptions> createTaskOptions) + throws ServiceException { try { - return service.createJob(taskInfos, createJobOptions); + return service.createJob(createJobOptions, createTaskOptions); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index ae354c688a80d..ffb4bc4826696 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; @@ -22,7 +23,11 @@ import java.util.List; import javax.inject.Inject; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMultipart; import javax.ws.rs.core.MediaType; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,6 +41,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; @@ -43,6 +49,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; @@ -557,11 +564,10 @@ public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) t * @see com.microsoft.windowsazure.services.media.MediaContract#createJob(com.microsoft.windowsazure.services.media.models.CreateJobOptions) */ @Override - public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOptions) { - JobType jobType = new JobType(); - String taskString = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody><inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"; - jobType.setTaskBody(taskString); + public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptions> createTaskOptions) + throws ServiceException { + JobType jobType = new JobType(); if (createJobOptions != null) { jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); jobType.setName(createJobOptions.getName()); @@ -570,10 +576,76 @@ public JobInfo createJob(List<TaskInfo> taskInfos, CreateJobOptions createJobOpt jobType.setStartTime(createJobOptions.getStartTime()); } - WebResource resource = getResource("Jobs"); + WebResource resource = getResource("$batch"); + MediaBatchOperations mediaBatchOperations = null; + try { + mediaBatchOperations = new MediaBatchOperations(channel.resource("").getURI()); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + catch (ParserConfigurationException e) { + throw new ServiceException(e); + } + CreateJobOperation createJobOperation = new CreateJobOperation(); + createJobOperation.setJob(jobType); + mediaBatchOperations.addOperation(createJobOperation); + for (CreateTaskOptions createTaskOptionsInstance : createTaskOptions) { + CreateTaskOperation createTaskOperation = new CreateTaskOperation(); + TaskType taskType = createTaskType(createTaskOptionsInstance); + createTaskOperation.setTask(taskType); + mediaBatchOperations.addOperation(createTaskOperation); + } - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(JobInfo.class, jobType); + MimeMultipart mimeMultipart; + try { + mimeMultipart = mediaBatchOperations.getMimeMultipart(); + } + catch (MessagingException e) { + throw new ServiceException(e); + } + catch (IOException e) { + throw new ServiceException(e); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + + ClientResponse clientResponse = resource.type(MediaType.APPLICATION_ATOM_XML) + .accept(MediaType.APPLICATION_ATOM_XML).post(ClientResponse.class, mimeMultipart); + + JobInfo jobInfo = new JobInfo(); + return jobInfo; + + } + + /** + * Creates the task type. + * + * @param createTaskOptions + * the create task options + * @return the task type + */ + private TaskType createTaskType(CreateTaskOptions createTaskOptions) { + if (createTaskOptions == null) { + throw new IllegalArgumentException("The create task options cannot be null."); + } + + TaskType taskType = new TaskType(); + taskType.setConfiguration(createTaskOptions.getConfiguration()); + taskType.setMediaProcessorId(createTaskOptions.getMediaProcessorId()); + taskType.setName(createTaskOptions.getName()); + taskType.setPriority(createTaskOptions.getPriority()); + taskType.setStartTime(createTaskOptions.getStartTime()); + taskType.setTaskBody(createTaskOptions.getTaskBody()); + taskType.setEncryptionKeyId(createTaskOptions.getEncryptionKeyId()); + taskType.setEncryptionScheme(createTaskOptions.getEncryptionScheme()); + taskType.setEncryptionVersion(createTaskOptions.getEncryptionVersion()); + taskType.setInitializationVector(createTaskOptions.getInitializationVector()); + taskType.setInputMediaAssets(createTaskOptions.getInputMediaAssets()); + taskType.setOutputMediaAssets(createTaskOptions.getOutputMediaAssets()); + + return taskType; } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 1ca5d0912c0af..5e443d3e9dbab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -97,6 +97,7 @@ public void marshalEntry(Object content, OutputStream stream) throws JAXBExcepti marshaller.marshal(createEntry(content), stream); } + @SuppressWarnings("unchecked") private JAXBElement<EntryType> createEntry(Object content) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java new file mode 100644 index 0000000000000..85fed639af49a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java @@ -0,0 +1,5 @@ +package com.microsoft.windowsazure.services.media.implementation; + +public interface Operation { + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java new file mode 100644 index 0000000000000..7f6b453a7d8e0 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java @@ -0,0 +1,48 @@ +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import javax.mail.BodyPart; +import javax.mail.MessagingException; +import javax.mail.MultipartDataSource; + +public class SetBoundaryMultipartDataSource implements MultipartDataSource { + + private final String boundary; + + public SetBoundaryMultipartDataSource(String boundary) { + this.boundary = boundary; + } + + @Override + public String getContentType() { + return "multipart/mixed; boundary=" + boundary; + } + + @Override + public InputStream getInputStream() throws IOException { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public OutputStream getOutputStream() throws IOException { + return null; + } + + @Override + public int getCount() { + return 0; + } + + @Override + public BodyPart getBodyPart(int index) throws MessagingException { + return null; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java new file mode 100644 index 0000000000000..656751593d151 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java @@ -0,0 +1,306 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +/** + * The Class CreateTaskOptions. + */ +public class CreateTaskOptions { + + /** The configuration. */ + private String configuration; + + /** The media processor id. */ + private String mediaProcessorId; + + /** The name. */ + private String name; + + /** The priority. */ + private Integer priority; + + /** The start time. */ + private Date startTime; + + /** The task body. */ + private String taskBody; + + /** The encryption key id. */ + private String encryptionKeyId; + + /** The encryption scheme. */ + private String encryptionScheme; + + /** The encryption version. */ + private String encryptionVersion; + + /** The initialization vector. */ + private String initializationVector; + + /** The input media assets. */ + private String inputMediaAssets; + + /** The output media assets. */ + private String outputMediaAssets; + + /** + * Gets the start time. + * + * @return the start time + */ + public Date getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the creates the locator options + */ + public CreateTaskOptions setStartTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the creates the job options + */ + public CreateTaskOptions setName(String name) { + this.name = name; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the creates the job options + */ + public CreateTaskOptions setPriority(Integer priority) { + this.priority = priority; + return this; + } + + /** + * Gets the priority. + * + * @return the priority + */ + public Integer getPriority() { + return this.priority; + } + + /** + * Sets the input media assets. + * + * @param inputMediaAssets + * the input media assets + * @return the creates the job options + */ + public CreateTaskOptions setInputMediaAssets(String inputMediaAssets) { + this.inputMediaAssets = inputMediaAssets; + return this; + } + + /** + * Gets the input media assets. + * + * @return the input media assets + */ + public String getInputMediaAssets() { + return this.inputMediaAssets; + } + + /** + * Sets the output media assets. + * + * @param outputMediaAssets + * the output media assets + * @return the creates the job options + */ + public CreateTaskOptions setOutputMediaAssets(String outputMediaAssets) { + this.outputMediaAssets = outputMediaAssets; + return this; + } + + /** + * Gets the output media assets. + * + * @return the output media assets + */ + public String getOutputMediaAssets() { + return this.outputMediaAssets; + } + + /** + * Gets the configuration. + * + * @return the configuration + */ + public String getConfiguration() { + return configuration; + } + + /** + * Sets the configuration. + * + * @param configuration + * the new configuration + */ + public CreateTaskOptions setConfiguration(String configuration) { + this.configuration = configuration; + return this; + } + + /** + * Gets the media processor id. + * + * @return the media processor id + */ + public String getMediaProcessorId() { + return mediaProcessorId; + } + + /** + * Sets the media processor id. + * + * @param mediaProcessorId + * the new media processor id + */ + public CreateTaskOptions setMediaProcessorId(String mediaProcessorId) { + this.mediaProcessorId = mediaProcessorId; + return this; + } + + /** + * Gets the task body. + * + * @return the task body + */ + public String getTaskBody() { + return taskBody; + } + + /** + * Sets the task body. + * + * @param taskBody + * the new task body + */ + public CreateTaskOptions setTaskBody(String taskBody) { + this.taskBody = taskBody; + return this; + } + + /** + * Gets the encryption key id. + * + * @return the encryption key id + */ + public String getEncryptionKeyId() { + return encryptionKeyId; + } + + /** + * Sets the encryption key id. + * + * @param encryptionKeyId + * the new encryption key id + */ + public CreateTaskOptions setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + /** + * Gets the encryption scheme. + * + * @return the encryption scheme + */ + public String getEncryptionScheme() { + return encryptionScheme; + } + + /** + * Sets the encryption scheme. + * + * @param encryptionScheme + * the new encryption scheme + */ + public CreateTaskOptions setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + /** + * Gets the encryption version. + * + * @return the encryption version + */ + public String getEncryptionVersion() { + return encryptionVersion; + } + + /** + * Sets the encryption version. + * + * @param encryptionVersion + * the new encryption version + */ + public CreateTaskOptions setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + /** + * Gets the initialization vector. + * + * @return the initialization vector + */ + public String getInitializationVector() { + return initializationVector; + } + + /** + * Sets the initialization vector. + * + * @param initializationVector + * the new initialization vector + */ + public CreateTaskOptions setInitializationVector(String initializationVector) { + this.initializationVector = initializationVector; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java index 394c1ad79c45b..956e501a55280 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.microsoft.windowsazure.services.media.models; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index e80337f7dec70..e8b8ca79b8406 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -34,6 +34,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateJobOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; @@ -45,7 +46,6 @@ import com.microsoft.windowsazure.services.media.models.ListTasksResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; @@ -521,14 +521,26 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { } @Test - public void createJobWithTaskInfoSuccess() throws ServiceException { + public void createJobWithTaskSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - TaskInfo taskInfo = new TaskInfo(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); // Act - JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); + + // Assert + assertNotNull(jobInfo); + } + + @Test(expected = ServiceException.class) + public void createJobWithoutTaskFailed() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + + // Act + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); // Assert assertNotNull(jobInfo); @@ -538,10 +550,10 @@ public void createJobWithTaskInfoSuccess() throws ServiceException { public void listJobsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); - JobInfo jobInfoA = service.createJob(taskInfos, createJobOptions); - JobInfo jobInfoB = service.createJob(taskInfos, createJobOptions); + JobInfo jobInfoA = service.createJob(createJobOptions, createTaskOptions); + JobInfo jobInfoB = service.createJob(createJobOptions, createTaskOptions); // Act ListJobsResult listJobsResult = service.listJobs(); @@ -554,9 +566,9 @@ public void listJobsSuccess() throws ServiceException { public void listTopJobsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - JobInfo jobInfoA = service.createJob(taskInfos, createJobOptions); - JobInfo jobInfoB = service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + JobInfo jobInfoA = service.createJob(createJobOptions, createTaskOptions); + JobInfo jobInfoB = service.createJob(createJobOptions, createTaskOptions); // Act ListJobsResult listJobsResult = service.listJobs(); @@ -570,8 +582,8 @@ public void listTopJobsSuccess() throws ServiceException { public void cancelJobSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); // Act service.cancelJob(jobInfo.getId()); @@ -594,8 +606,8 @@ public void cancelInvalidJobFailed() throws ServiceException { public void listTasksSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + service.createJob(createJobOptions, createTaskOptions); // Act ListTasksResult listTasksResult = service.listTasks(); @@ -610,8 +622,8 @@ public void listTasksSuccess() throws ServiceException { public void listTasksWithOptionsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + service.createJob(createJobOptions, createTaskOptions); ListTasksOptions listTasksOptions = new ListTasksOptions(); listTasksOptions.getQueryParameters().add("$top", "1"); @@ -627,8 +639,8 @@ public void listTasksWithOptionsSuccess() throws ServiceException { public void listJobTasksSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); // Act ListTasksResult listTasksResult = service.listJobTasks(jobInfo.getId()); @@ -653,8 +665,8 @@ public void listJobTasksInvalidIdFailed() throws ServiceException { public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException { // Arrange CreateJobOptions createJobOptions = new CreateJobOptions(); - List<TaskInfo> taskInfos = new ArrayList<TaskInfo>(); - JobInfo jobInfo = service.createJob(taskInfos, createJobOptions); + List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); ListTasksOptions listTasksOptions = new ListTasksOptions(); // Act From a20cd7bacb94f47ec91014ebfda15948ca0e985f Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 29 Oct 2012 15:49:06 -0700 Subject: [PATCH 420/664] Extracted idempotency logic into base class. --- .../services/core/IdempotentClientFilter.java | 72 +++++++++++++++++++ .../media/implementation/OAuthFilter.java | 22 ++---- .../media/implementation/RedirectFilter.java | 9 ++- .../media/implementation/SASTokenFilter.java | 14 ++-- 4 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java new file mode 100644 index 0000000000000..1c7d4af726b28 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java @@ -0,0 +1,72 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.core; + +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; + +/** + * Base class for filters that enforces idempotency - the filter + * will only be applied once for a particular request, even + * if the request passes through this filter more than once. + * + */ +public abstract class IdempotentClientFilter extends ClientFilter { + + /** + * + */ + public IdempotentClientFilter() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + */ + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + String key = getKey(); + + if (cr.getProperties().containsKey(key)) { + return this.getNext().handle(cr); + } + cr.getProperties().put(key, this); + return doHandle(cr); + } + + /** + * Implemented by derived classes to provide the actual implementation for filtering. + * + * @param cr + * The ClientRequest being processed + * @return The returned ClientResponse + * @throws ClientHandlerException + */ + protected abstract ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException; + + /** + * Get the key value used to detect multiple runs. By default, + * defaults to the class name for the filter. + * + * @return Key name as a string + */ + protected String getKey() { + return this.getClass().getName(); + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index e28c5805b3edd..addd226b4cd10 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -16,11 +16,11 @@ import java.net.URISyntaxException; +import com.microsoft.windowsazure.services.core.IdempotentClientFilter; import com.microsoft.windowsazure.services.core.ServiceException; 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; /** * The Jersey filter for OAuth. @@ -28,7 +28,7 @@ * @author azurejava@microsoft.com * */ -public class OAuthFilter extends ClientFilter { +public class OAuthFilter extends IdempotentClientFilter { private final OAuthTokenManager oAuthTokenManager; /** @@ -40,20 +40,10 @@ public OAuthFilter(OAuthTokenManager oAuthTokenManager) { this.oAuthTokenManager = oAuthTokenManager; } - /** - * Handles response with a specified client request. - * - * @param clientRequest - * A <code>ClientRequest</code> object representing a client request. - */ - @Override - public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { - // Only do oauth process once - if (clientRequest.getProperties().containsKey("MediaServicesOAuthFilter")) { - return this.getNext().handle(clientRequest); - } - clientRequest.getProperties().put("MediaServicesOAuthFilter", this); - + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) + */@Override + public ClientResponse doHandle(ClientRequest clientRequest) throws ClientHandlerException { String accessToken; try { accessToken = oAuthTokenManager.getAccessToken(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 81d2cb2142c24..c6a604db5f6a5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -18,20 +18,23 @@ import java.net.URI; import java.net.URISyntaxException; +import com.microsoft.windowsazure.services.core.IdempotentClientFilter; 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; -public class RedirectFilter extends ClientFilter { +public class RedirectFilter extends IdempotentClientFilter { private final ResourceLocationManager locationManager; public RedirectFilter(ResourceLocationManager locationManager) { this.locationManager = locationManager; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) + */ @Override - public ClientResponse handle(ClientRequest request) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest request) throws ClientHandlerException { if (request == null) { throw new IllegalArgumentException("Request should not be null"); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index c5ba6254d9630..79936ed8f6bf4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -19,16 +19,16 @@ import javax.ws.rs.core.UriBuilder; +import com.microsoft.windowsazure.services.core.IdempotentClientFilter; 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; /** * Filter responsible for adding SAS tokens to outgoing requests. * */ -public class SASTokenFilter extends ClientFilter { +public class SASTokenFilter extends IdempotentClientFilter { private final String sasToken; /** @@ -44,15 +44,10 @@ public SASTokenFilter(String sasToken) { } /* (non-Javadoc) - * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */ @Override - public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { - if (cr.getProperties().containsKey("MediaServicesSASFilter")) { - return this.getNext().handle(cr); - } - cr.getProperties().put("MediaServicesSASFilter", this); - + public ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { UriBuilder newUri = UriBuilder.fromUri(cr.getURI()); String currentQuery = cr.getURI().getRawQuery(); if (currentQuery == null) { @@ -68,5 +63,4 @@ else if (currentQuery.length() > 0) { return getNext().handle(cr); } - } From fbf88fe2795698c47666de90492331ae30ac0c73 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 30 Oct 2012 11:06:21 -0700 Subject: [PATCH 421/664] Building out tests for idempotent filter base class --- .../core/IdempotentClientFilterTest.java | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java new file mode 100644 index 0000000000000..5aa378eec3787 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java @@ -0,0 +1,181 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.core; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.mockito.Mockito; + +import com.sun.jersey.api.client.Client; +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.WebResource; +import com.sun.jersey.api.client.filter.ClientFilter; + +/** + * Test fixture for IdempotentClientFilter class + * + */ +public class IdempotentClientFilterTest { + + @Test + public void filterRunsFirstTime() throws Exception { + CountingFilter filterInTest = new CountingFilter(); + + Client client = getClient(); + client.addFilter(filterInTest); + + WebResource r = client.resource("http://test.example"); + ClientResponse response = r.get(ClientResponse.class); + + assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); + + assertEquals(1, filterInTest.count); + } + + @Test + public void filterRunsOnlyOnceWhenRequestIsRetried() throws Exception { + RetryFilter retry = new RetryFilter(); + retry.triesLeft = 3; + CountingFilter filterInTest = new CountingFilter(); + + Client client = getClient(); + client.addFilter(filterInTest); + client.addFilter(retry); + + WebResource r = client.resource("http://test.example"); + ClientResponse response = r.get(ClientResponse.class); + + assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); + assertEquals(1, filterInTest.count); + } + + @Test + public void multipleIdempotentFiltersRunFirstTime() throws Exception { + CountingFilter filter1 = new CountingFilter(); + CountingFilter filter2 = new CountingFilter(); + filter2.key = "secondfilter"; + + Client client = getClient(); + client.addFilter(filter1); + client.addFilter(filter2); + + WebResource r = client.resource("http://test.example"); + ClientResponse response = r.get(ClientResponse.class); + + assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); + + assertEquals(1, filter1.count); + assertEquals(1, filter2.count); + + } + + @Test + public void multipleIdempotentFiltersRunOnceWhenRetried() throws Exception { + CountingFilter filter1 = new CountingFilter(); + CountingFilter filter2 = new CountingFilter(); + filter2.key = "secondfilter"; + + RetryFilter retry = new RetryFilter(); + retry.triesLeft = 4; + + Client client = getClient(); + client.addFilter(filter1); + client.addFilter(filter2); + client.addFilter(retry); + + WebResource r = client.resource("http://test.example"); + ClientResponse response = r.get(ClientResponse.class); + + assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); + + assertEquals(1, filter1.count); + assertEquals(1, filter2.count); + } + + @Test + public void idempotentFilterRunsAgainOnSecondRequest() throws Exception { + CountingFilter filterInTest = new CountingFilter(); + + Client client = getClient(); + client.addFilter(filterInTest); + + WebResource r = client.resource("http://test.example"); + r.get(ClientResponse.class); + + r = client.resource("http://test.example"); + r.get(ClientResponse.class); + + assertEquals(2, filterInTest.count); + } + + private Client getClient() { + Client client = Client.create(); + client.addFilter(new MockSinkFilter()); + return client; + } + + private class RetryFilter extends ClientFilter { + int triesLeft = 1; + + /* (non-Javadoc) + * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + */ + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + ClientResponse response = null; + while (triesLeft > 0) { + --triesLeft; + response = getNext().handle(cr); + } + return response; + } + } + + private class CountingFilter extends IdempotentClientFilter { + public int count; + private String key = null; + + @Override + protected ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { + ++count; + return getNext().handle(cr); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#getKey() + */ + @Override + protected String getKey() { + if (key != null) { + return key; + } + return super.getKey(); + } + } + + private class MockSinkFilter extends ClientFilter { + + @Override + public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + ClientResponse response = Mockito.mock(ClientResponse.class); + Mockito.when(response.getClientResponseStatus()).thenReturn(ClientResponse.Status.ACCEPTED); + return response; + } + } +} From 107a4e2111744fa3d119c0e1fcc8dc7a91ce8b52 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 30 Oct 2012 11:11:31 -0700 Subject: [PATCH 422/664] Cleanup --- .../services/core/IdempotentClientFilter.java | 8 --- .../core/IdempotentClientFilterTest.java | 56 ++++++++----------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java index 1c7d4af726b28..3a178302f7a27 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java @@ -27,14 +27,6 @@ * */ public abstract class IdempotentClientFilter extends ClientFilter { - - /** - * - */ - public IdempotentClientFilter() { - // TODO Auto-generated constructor stub - } - /* (non-Javadoc) * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java index 5aa378eec3787..b81a19e8d27ff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; +import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -32,46 +33,49 @@ * */ public class IdempotentClientFilterTest { + Client client; + RetryFilter retry; + CountingFilter filter1; + CountingFilter filter2; + + @Before + public void setup() { + client = Client.create(); + client.addFilter(new MockSinkFilter()); + + retry = new RetryFilter(); + filter1 = new CountingFilter(); + filter2 = new CountingFilter(); + filter2.key = "secondfilter"; + } @Test public void filterRunsFirstTime() throws Exception { - CountingFilter filterInTest = new CountingFilter(); - - Client client = getClient(); - client.addFilter(filterInTest); + client.addFilter(filter1); WebResource r = client.resource("http://test.example"); ClientResponse response = r.get(ClientResponse.class); assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); - assertEquals(1, filterInTest.count); + assertEquals(1, filter1.count); } @Test public void filterRunsOnlyOnceWhenRequestIsRetried() throws Exception { - RetryFilter retry = new RetryFilter(); retry.triesLeft = 3; - CountingFilter filterInTest = new CountingFilter(); - - Client client = getClient(); - client.addFilter(filterInTest); + client.addFilter(filter1); client.addFilter(retry); WebResource r = client.resource("http://test.example"); ClientResponse response = r.get(ClientResponse.class); assertEquals(ClientResponse.Status.ACCEPTED, response.getClientResponseStatus()); - assertEquals(1, filterInTest.count); + assertEquals(1, filter1.count); } @Test public void multipleIdempotentFiltersRunFirstTime() throws Exception { - CountingFilter filter1 = new CountingFilter(); - CountingFilter filter2 = new CountingFilter(); - filter2.key = "secondfilter"; - - Client client = getClient(); client.addFilter(filter1); client.addFilter(filter2); @@ -82,19 +86,12 @@ public void multipleIdempotentFiltersRunFirstTime() throws Exception { assertEquals(1, filter1.count); assertEquals(1, filter2.count); - } @Test public void multipleIdempotentFiltersRunOnceWhenRetried() throws Exception { - CountingFilter filter1 = new CountingFilter(); - CountingFilter filter2 = new CountingFilter(); - filter2.key = "secondfilter"; - - RetryFilter retry = new RetryFilter(); retry.triesLeft = 4; - Client client = getClient(); client.addFilter(filter1); client.addFilter(filter2); client.addFilter(retry); @@ -110,10 +107,7 @@ public void multipleIdempotentFiltersRunOnceWhenRetried() throws Exception { @Test public void idempotentFilterRunsAgainOnSecondRequest() throws Exception { - CountingFilter filterInTest = new CountingFilter(); - - Client client = getClient(); - client.addFilter(filterInTest); + client.addFilter(filter1); WebResource r = client.resource("http://test.example"); r.get(ClientResponse.class); @@ -121,13 +115,7 @@ public void idempotentFilterRunsAgainOnSecondRequest() throws Exception { r = client.resource("http://test.example"); r.get(ClientResponse.class); - assertEquals(2, filterInTest.count); - } - - private Client getClient() { - Client client = Client.create(); - client.addFilter(new MockSinkFilter()); - return client; + assertEquals(2, filter1.count); } private class RetryFilter extends ClientFilter { From 292412a783d22a5e07b5a57717f64b45b0b578e1 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 30 Oct 2012 12:11:55 -0700 Subject: [PATCH 423/664] Removed leftover idempotency check in redirect filter --- .../services/media/implementation/RedirectFilter.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index c6a604db5f6a5..34b12527c852d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -39,13 +39,6 @@ public ClientResponse doHandle(ClientRequest request) throws ClientHandlerExcept throw new IllegalArgumentException("Request should not be null"); } - // Only redirect once - if (request.getProperties().containsKey("MediaServicesRedirectFilter")) { - return this.getNext().handle(request); - } - - request.getProperties().put("MediaServicesRedirectFilter", this); - URI originalURI = request.getURI(); request.setURI(locationManager.getRedirectedURI(originalURI)); From 2d5b06cda183dc5d3278fffe6607d67dedf23d8e Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 30 Oct 2012 12:13:25 -0700 Subject: [PATCH 424/664] Fixed leftover merge tag --- microsoft-azure-api/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index ed65f6900b894..6d8a3d780dc6f 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -1,4 +1,3 @@ -<<<<<<< HEAD <!-- Copyright 2011 Microsoft Corporation From d2eafaa291e7eb8bc09749e5cf592cf458881e3f Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 30 Oct 2012 23:03:50 -0700 Subject: [PATCH 425/664] partial checkin for Windows Azure Media Service Batch Operation. --- .../implementation/MediaBatchOperations.java | 13 +- .../media/implementation/MediaRestProxy.java | 11 +- .../implementation/ODataAtomMarshaller.java | 3 +- .../media/implementation/RedirectFilter.java | 4 + .../media/implementation/atom/EntryType.java | 124 +++++++++--------- .../media/implementation/content/JobType.java | 22 ++-- .../services/media/models/AssetInfo.java | 10 ++ .../media/models/CreateJobOptions.java | 18 +-- .../services/media/models/JobInfo.java | 10 +- .../media/MediaServiceIntegrationTest.java | 13 +- .../media/models/CreateJobOptionsTest.java | 17 ++- 11 files changed, 140 insertions(+), 105 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 7b6bc6447be04..8035eca1f9f5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -84,7 +84,10 @@ public MimeMultipart getMimeMultipart() throws MessagingException, IOException, List<DataSource> bodyPartContents = new ArrayList<DataSource>(); int contentId = 1; - int jobContentId = addJobPart(bodyPartContents, contentId); + URI jobURI = UriBuilder.fromUri(serviceURI).path("Jobs").build(); + int jobContentId = addJobPart(bodyPartContents, jobURI, contentId); + contentId++; + URI taskURI = UriBuilder.fromUri(serviceURI).path(String.format("$%d", jobContentId)).path("Tasks").build(); addTaskPart(bodyPartContents, taskURI, contentId); @@ -103,7 +106,7 @@ public MimeMultipart getMimeMultipart() throws MessagingException, IOException, * @throws JAXBException * the jAXB exception */ - private int addJobPart(List<DataSource> bodyPartContents, int contentId) throws JAXBException { + private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int contentId) throws JAXBException { int jobContentId = contentId; ValidateJobOperation(); @@ -112,8 +115,7 @@ private int addJobPart(List<DataSource> bodyPartContents, int contentId) throws if (operation instanceof CreateJobOperation) { CreateJobOperation createJobOperation = (CreateJobOperation) operation; jobContentId = contentId; - URI jobUri = null; - bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getJob(), jobUri, contentId); + bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getJob(), jobURI, contentId); contentId++; if (bodyPartContent != null) { bodyPartContents.add(bodyPartContent); @@ -155,7 +157,8 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con DataSource bodyPartContent = null; if (operation instanceof CreateTaskOperation) { CreateTaskOperation createTaskOperation = (CreateTaskOperation) operation; - bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation, taskURI, contentId); + bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation.getTask(), taskURI, + contentId); contentId++; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 93e1c959d43db..489ecbf4c0878 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.net.URI; import java.net.URLEncoder; import java.util.Arrays; import java.util.EnumSet; @@ -80,6 +81,7 @@ public class MediaRestProxy implements MediaContract { /** The channel. */ private Client channel; + private RedirectFilter redirectFilter; /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); @@ -91,6 +93,8 @@ public class MediaRestProxy implements MediaContract { * * @param channel * the channel + * @param uri + * the uri * @param authFilter * the auth filter * @param redirectFilter @@ -103,6 +107,7 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red VersionHeadersFilter versionHeadersFilter) { this.channel = channel; this.filters = new ServiceFilter[0]; + this.redirectFilter = redirectFilter; channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -217,6 +222,10 @@ private WebResource getResource(String parentEntityType, String childEntityType, return getResource(entityPath); } + private URI getBaseURI() { + return this.redirectFilter.getBaseURI(); + } + /** * Merge request. * @@ -591,7 +600,7 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio WebResource resource = getResource("$batch"); MediaBatchOperations mediaBatchOperations = null; try { - mediaBatchOperations = new MediaBatchOperations(channel.resource("").getURI()); + mediaBatchOperations = new MediaBatchOperations(getBaseURI()); } catch (JAXBException e) { throw new ServiceException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 5e443d3e9dbab..57482a4fb4729 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -100,11 +100,12 @@ public void marshalEntry(Object content, OutputStream stream) throws JAXBExcepti @SuppressWarnings("unchecked") private JAXBElement<EntryType> createEntry(Object content) { ContentType atomContent = new ContentType(); + EntryType atomEntry = new EntryType(); + atomContent.setType("application/xml"); atomContent.getContent().add( new JAXBElement(new QName(Constants.ODATA_METADATA_NS, "properties"), content.getClass(), content)); - EntryType atomEntry = new EntryType(); atomEntry.getEntryChildren().add( new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index f71ea6381653b..778c12dfceb3c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -56,4 +56,8 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio } return response; } + + public URI getBaseURI() { + return this.locationManager.getBaseURI(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index d3244af70517d..e0e0b19370247 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -1,17 +1,19 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // - package com.microsoft.windowsazure.services.media.implementation.atom; +import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,15 +28,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom entry construct is defined in section 4.1.2 of the format spec. - * + * The Atom entry construct is defined in section 4.1.2 of the format spec. + * * - * <p>Java class for entryType complex type. + * <p> + * Java class for entryType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="entryType"> @@ -65,25 +68,22 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "entryType", propOrder = { - "entryChildren" -}) +@XmlType(name = "entryType", propOrder = { "entryChildren" }) public class EntryType { @XmlElementRefs({ - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) - }) + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) protected List<Object> entryChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -94,39 +94,32 @@ public class EntryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the entryChildren property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the entryChildren property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the entryChildren property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getEntryChildren().add(newItem); + * getEntryChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link ContentType }{@code >} - * {@link Object } + * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link ContentType }{@code >} {@link Object } * * */ @@ -141,9 +134,8 @@ public List<Object> getEntryChildren() { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -153,9 +145,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -165,9 +156,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -177,9 +167,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -189,18 +178,27 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; } + public URI getLink() { + // TODO Auto-generated method stub + return null; + } + + public void setLink(URI uri) { + // TODO Auto-generated method stub + + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 5f04c03184eda..68313111e2543 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -15,7 +15,9 @@ package com.microsoft.windowsazure.services.media.implementation.content; +import java.net.URI; import java.util.Date; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -71,11 +73,11 @@ public class JobType implements MediaServiceDTO { /** The output media assets. */ @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected String outputMediaAssets; + protected List<URI> outputMediaAssets; /** The input media assets. */ @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected String inputMediaAssets; + protected List<URI> inputMediaAssets; /** The tasks. */ @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) @@ -286,18 +288,18 @@ public JobType setTemplateId(String templateId) { * * @return the output media assets */ - public String getOutputMediaAssets() { + public List<URI> getOutputMediaAssets() { return outputMediaAssets; } /** * Sets the output media assets. * - * @param outputMediaAssets + * @param uriList * the new output media assets */ - public JobType setOutputMediaAssets(String outputMediaAssets) { - this.outputMediaAssets = outputMediaAssets; + public JobType setOutputMediaAssets(List<URI> uriList) { + this.outputMediaAssets = uriList; return this; } @@ -306,18 +308,18 @@ public JobType setOutputMediaAssets(String outputMediaAssets) { * * @return the input media assets */ - public String getInputMediaAssets() { + public List<URI> getInputMediaAssets() { return inputMediaAssets; } /** * Sets the input media assets. * - * @param inputMediaAssets + * @param uriList * the new input media assets */ - public JobType setInputMediaAssets(String inputMediaAssets) { - this.inputMediaAssets = inputMediaAssets; + public JobType setInputMediaAssets(List<URI> uriList) { + this.inputMediaAssets = uriList; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 736c2366a7d4b..5e8f8acc7d0f5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; import java.util.Date; import com.microsoft.windowsazure.services.core.utils.DateConverter; @@ -182,4 +183,13 @@ public AssetInfo setOptions(EncryptionOption options) { getContent().setOptions(options.getCode()); return this; } + + public URI getUri() { + return getEntry().getLink(); + } + + public AssetInfo setUri(URI uri) { + getEntry().setLink(uri); + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java index bbeaace9626d8..2dc3b7dc8e95c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -14,7 +14,9 @@ */ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; import java.util.Date; +import java.util.List; /** * The Class CreateJobOptions. @@ -31,10 +33,10 @@ public class CreateJobOptions { private Integer priority; /** The input media assets. */ - private String inputMediaAssets; + private List<URI> inputMediaAssets; /** The output media assets. */ - private String outputMediaAssets; + private List<URI> outputMediaAssets; /** * Gets the start time. @@ -106,8 +108,8 @@ public Integer getPriority() { * the input media assets * @return the creates the job options */ - public CreateJobOptions setInputMediaAssets(String inputMediaAssets) { - this.inputMediaAssets = inputMediaAssets; + public CreateJobOptions addInputMediaAsset(URI inputMediaAsset) { + this.inputMediaAssets.add(inputMediaAsset); return this; } @@ -116,7 +118,7 @@ public CreateJobOptions setInputMediaAssets(String inputMediaAssets) { * * @return the input media assets */ - public String getInputMediaAssets() { + public List<URI> getInputMediaAssets() { return this.inputMediaAssets; } @@ -127,8 +129,8 @@ public String getInputMediaAssets() { * the output media assets * @return the creates the job options */ - public CreateJobOptions setOutputMediaAssets(String outputMediaAssets) { - this.outputMediaAssets = outputMediaAssets; + public CreateJobOptions addOutputMediaAsset(URI outputMediaAsset) { + this.outputMediaAssets.add(outputMediaAsset); return this; } @@ -137,7 +139,7 @@ public CreateJobOptions setOutputMediaAssets(String outputMediaAssets) { * * @return the output media assets */ - public String getOutputMediaAssets() { + public List<URI> getOutputMediaAssets() { return this.outputMediaAssets; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index f23fc4f7eeb2e..109e5b5d711eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -15,7 +15,9 @@ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; import java.util.Date; +import java.util.List; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; @@ -260,7 +262,7 @@ public JobInfo setTemplateId(String templateId) { * * @return the input media assets */ - public String getInputMediaAssets() { + public List<URI> getInputMediaAssets() { return getContent().getInputMediaAssets(); } @@ -271,7 +273,7 @@ public String getInputMediaAssets() { * the input media assets * @return the job info */ - public JobInfo setInputMediaAssets(String inputMediaAssets) { + public JobInfo setInputMediaAssets(List<URI> inputMediaAssets) { getContent().setInputMediaAssets(inputMediaAssets); return this; } @@ -281,7 +283,7 @@ public JobInfo setInputMediaAssets(String inputMediaAssets) { * * @return the output media assets */ - public String getOutputMediaAssets() { + public List<URI> getOutputMediaAssets() { return getContent().getOutputMediaAssets(); } @@ -292,7 +294,7 @@ public String getOutputMediaAssets() { * the output media assets * @return the job info */ - public JobInfo setOutputMediaAssets(String outputMediaAssets) { + public JobInfo setOutputMediaAssets(List<URI> outputMediaAssets) { getContent().setOutputMediaAssets(outputMediaAssets); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index b7bf7a6953854..f6c6d57e5afc4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -520,12 +520,15 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { assertTrue(listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); } - @Ignore @Test public void createJobWithTaskSuccess() throws ServiceException { // Arrange + AssetInfo assetInfo = service.createAsset(); CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.addInputMediaAsset(assetInfo.getUri()); List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); + CreateTaskOptions createTaskOptionsInstance = new CreateTaskOptions(); + createTaskOptions.add(createTaskOptionsInstance); // Act JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptions); @@ -547,7 +550,6 @@ public void createJobWithoutTaskFailed() throws ServiceException { assertNotNull(jobInfo); } - @Ignore @Test public void listJobsSuccess() throws ServiceException { // Arrange @@ -564,7 +566,6 @@ public void listJobsSuccess() throws ServiceException { assertNotNull(listJobsResult); } - @Ignore @Test public void listTopJobsSuccess() throws ServiceException { // Arrange @@ -581,7 +582,6 @@ public void listTopJobsSuccess() throws ServiceException { } - @Ignore @Test public void cancelJobSuccess() throws ServiceException { // Arrange @@ -606,7 +606,6 @@ public void cancelInvalidJobFailed() throws ServiceException { // Assert } - @Ignore @Test public void listTasksSuccess() throws ServiceException { // Arrange @@ -623,7 +622,6 @@ public void listTasksSuccess() throws ServiceException { } - @Ignore @Test public void listTasksWithOptionsSuccess() throws ServiceException { // Arrange @@ -641,7 +639,6 @@ public void listTasksWithOptionsSuccess() throws ServiceException { assertEquals(1, listTasksResult.getTaskInfos().size()); } - @Ignore @Test public void listJobTasksSuccess() throws ServiceException { // Arrange @@ -656,7 +653,6 @@ public void listJobTasksSuccess() throws ServiceException { assertNotNull(listTasksResult); } - @Ignore @Test public void listJobTasksInvalidIdFailed() throws ServiceException { // Arrange @@ -669,7 +665,6 @@ public void listJobTasksInvalidIdFailed() throws ServiceException { } - @Ignore @Test public void listJobTasksSuccessWithOptionsSuccess() throws ServiceException { // Arrange diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java index 7190b2aca62fd..9796103dbc0fa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java @@ -16,7 +16,12 @@ import static org.junit.Assert.*; +import java.net.URI; +import java.util.ArrayList; import java.util.Date; +import java.util.List; + +import javax.ws.rs.core.UriBuilder; import org.junit.Test; @@ -64,11 +69,13 @@ public void testGetSetStartTime() { @Test public void testGetSetInputMediaAssets() { // Arrange - String expectedInputMediaAssets = "testGetSetInputMediaAssets"; + URI expectedInputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); + List<URI> expectedInputMediaAssets = new ArrayList<URI>(); + expectedInputMediaAssets.add(expectedInputMediaAsset); CreateJobOptions createJobOptions = new CreateJobOptions(); // Act - String actualInputMediaAssets = createJobOptions.setInputMediaAssets(expectedInputMediaAssets) + List<URI> actualInputMediaAssets = createJobOptions.addInputMediaAsset(expectedInputMediaAsset) .getInputMediaAssets(); // Assert @@ -78,11 +85,13 @@ public void testGetSetInputMediaAssets() { @Test public void testGetSetOutputMediaAssets() { // Arrange - String expectedOutputMediaAssets = "testGetSetOutputMediaAssets"; + URI expectedOutputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); + List<URI> expectedOutputMediaAssets = new ArrayList<URI>(); + expectedOutputMediaAssets.add(expectedOutputMediaAsset); CreateJobOptions createJobOptions = new CreateJobOptions(); // Act - String actualOutputMediaAssets = createJobOptions.setOutputMediaAssets(expectedOutputMediaAssets) + List<URI> actualOutputMediaAssets = createJobOptions.addOutputMediaAsset(expectedOutputMediaAsset) .getOutputMediaAssets(); // Assert From 5783e86fc6943b885a4e37b5370f10bab063f04c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 25 Oct 2012 11:28:28 -0700 Subject: [PATCH 426/664] Upgrading the dependencies --- microsoft-azure-api/pom.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 6d8a3d780dc6f..a2647f0cb7fdb 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -53,31 +53,31 @@ <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> - <version>1.10-b02</version> + <version>1.13</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> - <version>2.1</version> + <version>2.2.7</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.8</version> + <version>4.10</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> - <version>1.1</version> + <version>1.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> + <version>1.9.0</version> <scope>test</scope> - <version>1.9.0-rc1</version> </dependency> <dependency> <groupId>javax.inject</groupId> @@ -87,7 +87,7 @@ <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> - <version>1.10-b02</version> + <version>1.13</version> </dependency> <dependency> <groupId>commons-logging</groupId> @@ -97,7 +97,7 @@ <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> - <version>1.4</version> + <version>1.4.5</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> From cafa56a882ca4b95675ac0152b1c84a771a747fb Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 31 Oct 2012 10:32:36 -0700 Subject: [PATCH 427/664] Add test to make sure the blob uploader work with a retry filter. See #368 --- .../services/media/UploadingIntegrationTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 2a89d4fe1a7b0..cca9799c59e26 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -108,4 +108,16 @@ public void canCommitBlobBlocksWithOptions() throws Exception { blobWriter.commitBlobBlocks("canCommitBlobBlocksWithOptions", blockList, options); } + @Test + public void canUploadBlockBlobWithExplicitRetry() throws Exception { + InputStream blobContent = new ByteArrayInputStream(firstPrimes); + blobWriter.createBlockBlob("canUploadBlockBlobWithExplicitRetry1", blobContent); + + ExponentialRetryPolicy forceRetryPolicy = new ExponentialRetryPolicy(1, 1, new int[] { 201 }); + WritableBlobContainerContract forceRetryBlobWriter = blobWriter.withFilter(new RetryPolicyFilter( + forceRetryPolicy)); + + blobContent.reset(); + forceRetryBlobWriter.createBlockBlob("canUploadBlockBlobWithExplicitRetry2", blobContent); + } } From 735ffbe671b4a3c95aa332f3ced4cf737db56356 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 31 Oct 2012 11:38:40 -0700 Subject: [PATCH 428/664] Fix for #445 Housekeeping: Remove redundant setupInstance method. --- .../implementation/VersionHeadersFilter.java | 8 +++---- .../media/AccessPolicyIntegrationTest.java | 21 +++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index 9b69c79942969..6dea13fc4f30d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -17,23 +17,23 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.core.IdempotentClientFilter; 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; /** * A small filter that adds the required Media services/OData 3 * version headers to the request as it goes through. * */ -public class VersionHeadersFilter extends ClientFilter { +public class VersionHeadersFilter extends IdempotentClientFilter { /* (non-Javadoc) - * @see com.sun.jersey.api.client.filter.ClientFilter#handle(com.sun.jersey.api.client.ClientRequest) + * @see com.microsoft.windowsazure.services.core.IdempotentClientFilter#doHandle(com.sun.jersey.api.client.ClientRequest) */ @Override - public ClientResponse handle(ClientRequest cr) throws ClientHandlerException { + public ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { MultivaluedMap<String, Object> headers = cr.getHeaders(); headers.add("DataServiceVersion", "3.0"); headers.add("MaxDataServiceVersion", "3.0"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index e0e11c0b55881..39cab7588d2fd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -21,9 +21,10 @@ import java.util.EnumSet; import java.util.List; -import org.junit.Before; import org.junit.Test; +import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; +import com.microsoft.windowsazure.services.core.RetryPolicyFilter; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; @@ -59,11 +60,6 @@ private void verifyPolicyProperties(String message, String testName, double dura assertEquals(message + " Created & LastModified", policy.getCreated(), policy.getLastModified()); } - @Before - public void setupInstance() throws Exception { - service = MediaService.create(config); - } - @Test public void canCreateAccessPolicy() throws Exception { String testName = testPolicyPrefix + "CanCreate"; @@ -200,4 +196,17 @@ public void canDeleteAccessPolicyByNonexistId() throws Exception { expectedException.expect(new ServiceExceptionMatcher(404)); service.deleteAccessPolicy(validButNonexistAccessPolicyId); } + + @Test + public void canUploadBlockBlobWithExplicitRetry() throws Exception { + String name = testPolicyPrefix + "canUploadBlockBlobWithExplicitRetry"; + double duration = 1; + EnumSet<AccessPolicyPermission> write = EnumSet.of(AccessPolicyPermission.WRITE); + service.createAccessPolicy(name + "1", duration, write); + + ExponentialRetryPolicy forceRetryPolicy = new ExponentialRetryPolicy(1, 1, new int[] { 201 }); + MediaContract forceRetryService = service.withFilter(new RetryPolicyFilter(forceRetryPolicy)); + + forceRetryService.createAccessPolicy(name + "2", duration, write); + } } From 03696ef6e3ac0663116f7eb83bd79ef8a7ff54bd Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 31 Oct 2012 15:36:45 -0700 Subject: [PATCH 429/664] Fix #447 --- microsoft-azure-api/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index a2647f0cb7fdb..b2a77405955dd 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -261,11 +261,13 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>emma-maven-plugin</artifactId> + <version>1.0-alpha-3</version> <inherited>true</inherited> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>surefire-report-maven-plugin</artifactId> + <version>2.0-beta-1</version> <inherited>true</inherited> </plugin> </plugins> From 7c2039df9e2cea363652a948e9b23649fbc6a163 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 31 Oct 2012 16:43:21 -0700 Subject: [PATCH 430/664] Using generic ListResult<T> as return type for all list<Entity> operations --- .../services/media/MediaContract.java | 21 +- .../MediaExceptionProcessor.java | 21 +- .../media/implementation/MediaRestProxy.java | 39 +- .../implementation/ODataAtomUnmarshaller.java | 5 +- .../media/implementation/ODataEntity.java | 4 +- .../ODataEntityCollectionProvider.java | 12 +- .../media/models/ListLocatorsResult.java | 48 -- .../models/ListMediaProcessorsResult.java | 48 -- .../services/media/models/ListResult.java | 153 +++++++ .../media/AccessPolicyIntegrationTest.java | 2 +- .../services/media/IntegrationTestBase.java | 6 +- .../media/LocatorIntegrationTests.java | 27 +- .../media/MediaProcessorIntegrationTest.java | 15 +- .../media/models/GenericListResultTest.java | 431 ++++++++++++++++++ .../models/ListMediaProcessorsResultTest.java | 54 --- 15 files changed, 655 insertions(+), 231 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 754a049451815..8a9244ccb35ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media; import java.util.EnumSet; -import java.util.List; import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; @@ -27,11 +26,11 @@ import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; @@ -88,7 +87,7 @@ public interface MediaContract extends FilterableService<MediaContract> { * @throws ServiceException * the service exception */ - public List<AssetInfo> listAssets() throws ServiceException; + public ListResult<AssetInfo> listAssets() throws ServiceException; /** * List assets. @@ -99,7 +98,7 @@ public interface MediaContract extends FilterableService<MediaContract> { * @throws ServiceException * the service exception */ - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; + public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; /** * Update asset. @@ -157,7 +156,7 @@ AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMi * @throws ServiceException * the service exception */ - List<AccessPolicyInfo> listAccessPolicies() throws ServiceException; + ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException; /** * List access policies. @@ -168,7 +167,7 @@ AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMi * @throws ServiceException * the service exception */ - List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; + ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; /** * Creates the locator. @@ -222,7 +221,7 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * @throws ServiceException * the service exception */ - public ListLocatorsResult listLocators() throws ServiceException; + public ListResult<LocatorInfo> listLocators() throws ServiceException; /** * Delete locator. @@ -244,7 +243,7 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * @throws ServiceException * the service exception */ - public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) throws ServiceException; + public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorOptions) throws ServiceException; /** * Update locator. @@ -265,7 +264,7 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * @throws ServiceException * the service exception */ - public ListMediaProcessorsResult listMediaProcessors() throws ServiceException; + public ListResult<MediaProcessorInfo> listMediaProcessors() throws ServiceException; /** * List media processors. @@ -276,7 +275,7 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * @throws ServiceException * the service exception */ - public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) + public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index c2a69ea95af43..0a7253cc4162c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -16,7 +16,6 @@ package com.microsoft.windowsazure.services.media.implementation; import java.util.EnumSet; -import java.util.List; import javax.inject.Inject; @@ -35,11 +34,11 @@ import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.ClientHandlerException; @@ -167,7 +166,7 @@ public AssetInfo getAsset(String assetId) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() */ @Override - public List<AssetInfo> listAssets() throws ServiceException { + public ListResult<AssetInfo> listAssets() throws ServiceException { try { return service.listAssets(); } @@ -183,7 +182,7 @@ public List<AssetInfo> listAssets() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) */ @Override - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { + public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { try { return service.listAssets(listAssetsOptions); } @@ -232,7 +231,7 @@ public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durat * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicies() */ @Override - public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { + public ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException { try { return service.listAccessPolicies(); } @@ -279,7 +278,7 @@ public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceExc /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies(com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions) */@Override - public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { + public ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { try { return service.listAccessPolicies(options); } @@ -361,7 +360,7 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators() */ @Override - public ListLocatorsResult listLocators() throws ServiceException { + public ListResult<LocatorInfo> listLocators() throws ServiceException { try { return service.listLocators(); } @@ -377,7 +376,7 @@ public ListLocatorsResult listLocators() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators(com.microsoft.windowsazure.services.media.models.ListLocatorsOptions) */ @Override - public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorsOptions) throws ServiceException { + public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorsOptions) throws ServiceException { try { return service.listLocators(listLocatorsOptions); } @@ -410,7 +409,7 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() */ @Override - public ListMediaProcessorsResult listMediaProcessors() throws ServiceException { + public ListResult<MediaProcessorInfo> listMediaProcessors() throws ServiceException { try { return service.listMediaProcessors(); } @@ -426,7 +425,7 @@ public ListMediaProcessorsResult listMediaProcessors() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) */ @Override - public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) + public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) throws ServiceException { try { return service.listMediaProcessors(listMediaProcessorsOptions); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 1bdb3dee18b7f..883c7fbc0e1af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -19,7 +19,6 @@ import java.net.URLEncoder; import java.util.Arrays; import java.util.EnumSet; -import java.util.List; import javax.inject.Inject; import javax.ws.rs.core.MediaType; @@ -43,10 +42,9 @@ import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; import com.microsoft.windowsazure.services.media.models.ListOptions; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; @@ -254,11 +252,11 @@ public AssetInfo getAsset(String assetId) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) */ @Override - public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { + public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { WebResource resource = getResource("Assets", listAssetsOptions); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<List<AssetInfo>>() { + .get(new GenericType<ListResult<AssetInfo>>() { }); } @@ -266,7 +264,7 @@ public List<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() */ @Override - public List<AssetInfo> listAssets() { + public ListResult<AssetInfo> listAssets() { ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); return listAssets(listAssetsOptions); } @@ -331,7 +329,7 @@ public void deleteAccessPolicy(String accessPolicyId) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() */ @Override - public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { + public ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException { return listAccessPolicies(null); } @@ -339,11 +337,11 @@ public List<AccessPolicyInfo> listAccessPolicies() throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() */ @Override - public List<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { + public ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { WebResource resource = getResource("AccessPolicies", options); return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<List<AccessPolicyInfo>>() { + .get(new GenericType<ListResult<AccessPolicyInfo>>() { }); } @@ -396,7 +394,7 @@ public LocatorInfo getLocator(String locatorId) throws ServiceException { * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators() */ @Override - public ListLocatorsResult listLocators() { + public ListResult<LocatorInfo> listLocators() { return listLocators(null); } @@ -404,16 +402,12 @@ public ListLocatorsResult listLocators() { * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators(com.microsoft.windowsazure.services.media.models.ListLocatorsOptions) */ @Override - public ListLocatorsResult listLocators(ListLocatorsOptions listLocatorOptions) { + public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorOptions) { WebResource resource = getResource("Locators", listLocatorOptions); - List<LocatorInfo> locatorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) - .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<LocatorInfo>>() { + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<ListResult<LocatorInfo>>() { }); - ListLocatorsResult listLocatorsResult = new ListLocatorsResult(); - listLocatorsResult.setLocatorInfos(locatorInfoList); - return listLocatorsResult; - } /* (non-Javadoc) @@ -449,7 +443,7 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() */ @Override - public ListMediaProcessorsResult listMediaProcessors() { + public ListResult<MediaProcessorInfo> listMediaProcessors() { return this.listMediaProcessors(null); } @@ -457,15 +451,12 @@ public ListMediaProcessorsResult listMediaProcessors() { * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) */ @Override - public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { + public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { WebResource resource = getResource("MediaProcessors", listMediaProcessorsOptions); - List<MediaProcessorInfo> mediaProcessorInfoList = resource.type(MediaType.APPLICATION_ATOM_XML) - .accept(MediaType.APPLICATION_ATOM_XML).get(new GenericType<List<MediaProcessorInfo>>() { + return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .get(new GenericType<ListResult<MediaProcessorInfo>>() { }); - ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); - listMediaProcessorsResult.setMediaProcessorInfos(mediaProcessorInfoList); - return listMediaProcessorsResult; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 66cecfd0a542d..f761047176cd5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -38,6 +38,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.ODataActionType; +import com.microsoft.windowsazure.services.media.models.ListResult; /** * This class implements unmarshalling from OData over Atom into Java @@ -74,7 +75,7 @@ public ODataAtomUnmarshaller() throws JAXBException { * @throws JAXBException * @throws ServiceException */ - public <T extends ODataEntity> List<T> unmarshalFeed(InputStream stream, Class<T> contentType) + public <T extends ODataEntity> ListResult<T> unmarshalFeed(InputStream stream, Class<T> contentType) throws JAXBException, ServiceException { validateNotNull(stream, "stream"); validateNotNull(contentType, "contentType"); @@ -89,7 +90,7 @@ public <T extends ODataEntity> List<T> unmarshalFeed(InputStream stream, Class<T entries.add(contentFromEntry(contentType, marshallingContentType, entry)); } } - return entries; + return new ListResult<T>(entries); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index dae9e70cd471c..4d3ce09d1dc96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -17,13 +17,13 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.util.List; import javax.xml.bind.JAXBElement; import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.models.ListResult; /** * Class wrapping deserialized OData entities. Allows easy @@ -86,7 +86,7 @@ public static boolean isODataEntityType(Class<?> type) { * @return true if it's List<OEntity> or derive from. */ public static boolean isODataEntityCollectionType(Class<?> type, Type genericType) { - if (List.class != type) { + if (ListResult.class != type) { return false; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java index b6b6eac581503..403295b7843ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -8,7 +8,6 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import java.util.List; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; @@ -16,13 +15,14 @@ import javax.xml.bind.JAXBException; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider; /** * Jersey provider to unmarshal lists of entities from Media Services. * */ -public class ODataEntityCollectionProvider extends AbstractMessageReaderWriterProvider<List<ODataEntity<?>>> { +public class ODataEntityCollectionProvider extends AbstractMessageReaderWriterProvider<ListResult<ODataEntity<?>>> { private final ODataAtomUnmarshaller unmarshaller; public ODataEntityCollectionProvider() throws JAXBException { @@ -35,9 +35,9 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati } @Override - public List<ODataEntity<?>> readFrom(Class<List<ODataEntity<?>>> type, Type genericType, Annotation[] annotations, - MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { + public ListResult<ODataEntity<?>> readFrom(Class<ListResult<ODataEntity<?>>> type, Type genericType, + Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, + InputStream entityStream) throws IOException, WebApplicationException { String responseType = mediaType.getParameters().get("type"); try { @@ -74,7 +74,7 @@ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotat * @throws UnsupportedOperationException */ @Override - public void writeTo(List<ODataEntity<?>> t, Class<?> type, Type genericType, Annotation[] annotations, + public void writeTo(ListResult<ODataEntity<?>> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java deleted file mode 100644 index 40531ad37e137..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.List; - -/** - * The Class ListLocatorsResult. - */ -public class ListLocatorsResult { - - /** The locator infos. */ - private List<LocatorInfo> locatorInfos; - - /** - * Gets the locator infos. - * - * @return the locator infos - */ - public List<LocatorInfo> getLocatorInfos() { - return locatorInfos; - } - - /** - * Sets the locator infos. - * - * @param locatorInfos - * the locator infos - * @return the list locators result - */ - public ListLocatorsResult setLocatorInfos(List<LocatorInfo> locatorInfos) { - this.locatorInfos = locatorInfos; - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java deleted file mode 100644 index 102b411ae3e3b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.List; - -/** - * The Class ListMediaProcessorsResult. - */ -public class ListMediaProcessorsResult { - - /** The media processor infos. */ - private List<MediaProcessorInfo> mediaProcessorInfos; - - /** - * Gets the media processor infos. - * - * @return the media processor infos - */ - public List<MediaProcessorInfo> getMediaProcessorInfos() { - return mediaProcessorInfos; - } - - /** - * Sets the media processor infos. - * - * @param mediaProcessorInfos - * the media processor infos - * @return the list media processor result - */ - public ListMediaProcessorsResult setMediaProcessorInfos(List<MediaProcessorInfo> mediaProcessorInfos) { - this.mediaProcessorInfos = mediaProcessorInfos; - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java new file mode 100644 index 0000000000000..fd470092b57f2 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java @@ -0,0 +1,153 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + * Wrapper class for all returned lists from Media Services + * + */ +public class ListResult<T> implements List<T> { + + private final List<T> contents; + + public ListResult(Collection<T> contentList) { + contents = Collections.unmodifiableList(new ArrayList<T>(contentList)); + } + + @Override + public boolean add(T element) { + return contents.add(element); + } + + @Override + public void add(int index, T element) { + contents.add(index, element); + } + + @Override + public boolean addAll(Collection<? extends T> c) { + return contents.addAll(c); + } + + @Override + public boolean addAll(int index, Collection<? extends T> c) { + return contents.addAll(index, c); + } + + @Override + public void clear() { + contents.clear(); + } + + @Override + public boolean contains(Object object) { + return contents.contains(object); + } + + @Override + public boolean containsAll(Collection<?> c) { + return contents.containsAll(c); + } + + @Override + public T get(int index) { + return contents.get(index); + } + + @Override + public int indexOf(Object object) { + return contents.indexOf(object); + } + + @Override + public boolean isEmpty() { + return contents.isEmpty(); + } + + @Override + public Iterator<T> iterator() { + return contents.iterator(); + } + + @Override + public int lastIndexOf(Object object) { + return contents.lastIndexOf(object); + } + + @Override + public ListIterator<T> listIterator() { + return listIterator(0); + } + + @Override + public ListIterator<T> listIterator(int index) { + List<T> l = Collections.unmodifiableList(contents); + return l.listIterator(index); + + } + + @Override + public boolean remove(Object o) { + return contents.remove(o); + } + + @Override + public T remove(int index) { + return contents.remove(index); + } + + @Override + public boolean removeAll(Collection<?> c) { + return contents.removeAll(c); + } + + @Override + public boolean retainAll(Collection<?> c) { + return contents.retainAll(c); + } + + @Override + public T set(int index, T element) { + return contents.set(index, element); + } + + @Override + public int size() { + return contents.size(); + } + + @Override + public List<T> subList(int fromIndex, int toIndex) { + return contents.subList(fromIndex, toIndex); + } + + @Override + public Object[] toArray() { + return contents.toArray(); + } + + @Override + public <U> U[] toArray(U[] a) { + return contents.toArray(a); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 39cab7588d2fd..53cb2b2c39403 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -198,7 +198,7 @@ public void canDeleteAccessPolicyByNonexistId() throws Exception { } @Test - public void canUploadBlockBlobWithExplicitRetry() throws Exception { + public void canRetryAccessPolicyCreation() throws Exception { String name = testPolicyPrefix + "canUploadBlockBlobWithExplicitRetry"; double duration = 1; EnumSet<AccessPolicyPermission> write = EnumSet.of(AccessPolicyPermission.WRITE); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 647e0cd17a1af..b648959504868 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -16,7 +16,7 @@ import com.microsoft.windowsazure.services.core.Configuration; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; public abstract class IntegrationTestBase { @@ -101,8 +101,8 @@ private static void removeAllTestAssets() { private static void removeAllTestLocators() { try { - ListLocatorsResult listLocatorsResult = service.listLocators(); - for (LocatorInfo locatorInfo : listLocatorsResult.getLocatorInfos()) { + ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); + for (LocatorInfo locatorInfo : listLocatorsResult) { AssetInfo ai = service.getAsset(locatorInfo.getAssetId()); if (ai.getName().startsWith(testAssetPrefix)) { service.deleteLocator(locatorInfo.getId()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index af92eb02dc5df..7c336c8f02798 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -34,7 +34,7 @@ import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; @@ -201,17 +201,16 @@ public void listLocatorsSuccess() throws ServiceException { } // Act - ListLocatorsResult listLocatorsResult = service.listLocators(); + ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); // Assert assertNotNull(listLocatorsResult); - verifyListResultContains("listLocatorsResult", expectedLocators, listLocatorsResult.getLocatorInfos(), - new ComponentDelegate() { - @Override - public void verifyEquals(String message, Object expected, Object actual) { - verifyLocatorInfosEqual(message, (LocatorInfo) expected, (LocatorInfo) actual); - } - }); + verifyListResultContains("listLocatorsResult", expectedLocators, listLocatorsResult, new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyLocatorInfosEqual(message, (LocatorInfo) expected, (LocatorInfo) actual); + } + }); } @Test @@ -228,9 +227,9 @@ public void listLocatorsWithOptions() throws ServiceException { + "')"); options.getQueryParameters().add("$top", "3"); - ListLocatorsResult result = service.listLocators(options); + ListResult<LocatorInfo> result = service.listLocators(options); - assertEquals(2, result.getLocatorInfos().size()); + assertEquals(2, result.size()); } @Test @@ -285,15 +284,15 @@ public void deleteLocatorSuccess() throws ServiceException { CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, createLocatorOptions); - ListLocatorsResult listLocatorsResult = service.listLocators(); - int assetCountBaseline = listLocatorsResult.getLocatorInfos().size(); + ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); + int assetCountBaseline = listLocatorsResult.size(); // Act service.deleteLocator(locatorInfo.getId()); // Assert listLocatorsResult = service.listLocators(); - assertEquals("listLocatorsResult.size", assetCountBaseline - 1, listLocatorsResult.getLocatorInfos().size()); + assertEquals("listLocatorsResult.size", assetCountBaseline - 1, listLocatorsResult.size()); expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 52559f8dbe2f3..574ba057e655a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -23,7 +23,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; public class MediaProcessorIntegrationTest extends IntegrationTestBase { @@ -52,12 +52,12 @@ public void listMediaProcessorsSuccess() throws ServiceException { // Arrange // Act - ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(); + ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.listMediaProcessors(); // Assert assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); - assertTrue("listMediaProcessorsResult size > 0", listMediaProcessorsResult.getMediaProcessorInfos().size() > 0); - List<MediaProcessorInfo> ps = listMediaProcessorsResult.getMediaProcessorInfos(); + assertTrue("listMediaProcessorsResult size > 0", listMediaProcessorsResult.size() > 0); + List<MediaProcessorInfo> ps = listMediaProcessorsResult; for (int i = 0; i < ps.size(); i++) { MediaProcessorInfo mediaProcessorInfo = ps.get(i); verifyMediaProcessorInfo("mediaProcessorInfo:" + i, mediaProcessorInfo); @@ -73,12 +73,13 @@ public void listMediaProcessorWithOptionSuccess() throws ServiceException { listMediaProcessorsOptions.getQueryParameters().add("$top", "2"); // Act - ListMediaProcessorsResult listMediaProcessorsResult = service.listMediaProcessors(listMediaProcessorsOptions); + ListResult<MediaProcessorInfo> listMediaProcessorsResult = service + .listMediaProcessors(listMediaProcessorsOptions); // Assert assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); - assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.getMediaProcessorInfos().size()); - MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.getMediaProcessorInfos().get(0); + assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); + MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); verifyMediaProcessorInfo("mediaProcessorInfo", "nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10", "Storage Decryption", "Storage Decryption", "", "Microsoft", "1.5.3", mediaProcessorInfo); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java new file mode 100644 index 0000000000000..35db51830c553 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java @@ -0,0 +1,431 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; + +import org.junit.Test; + +/** + * Test for the {link ListResult<T>} type. + * + */ +public class GenericListResultTest { + private final String[] expectedStrings = { "One", "Two", "Three" }; + + @Test + public void emptyListResultIsEmpty() throws Exception { + assertTrue(new ListResult<String>(new ArrayList<String>()).isEmpty()); + } + + @Test + public void listWithContentsIsNotEmpty() throws Exception { + ListResult<String> result = createStringListResult(); + + assertFalse(result.isEmpty()); + } + + @Test + public void createWithEmptyCollectionGivesNoResults() throws Exception { + List<AssetInfo> result = new ListResult<AssetInfo>(new ArrayList<AssetInfo>()); + + assertEquals(0, result.size()); + } + + @Test + public void createWithCollectionContentsContainsContents() throws Exception { + List<String> result = createStringListResult(); + + assertEquals(expectedStrings.length, result.size()); + } + + @Test + public void createWithCollectionContentsCanRetrieveContents() throws Exception { + List<String> result = createStringListResult(); + + for (int i = 0; i < expectedStrings.length; ++i) { + assertEquals(expectedStrings[i], result.get(i)); + } + } + + @Test + public void canIterateThroughResults() throws Exception { + List<String> result = createStringListResult(); + + int i = 0; + for (String s : result) { + assertEquals(expectedStrings[i], s); + ++i; + } + } + + @Test + public void canCheckContainsForObjectInList() throws Exception { + ListResult<String> result = createStringListResult(); + + assertTrue(result.contains(expectedStrings[1])); + } + + @Test + public void canCheckContainsForObjectNotInList() throws Exception { + ListResult<String> result = createStringListResult(); + + assertFalse(result.contains("This is not a string in the list")); + } + + @Test + public void canCheckContainsAllForObjectsInList() throws Exception { + ListResult<String> result = createStringListResult(); + List<String> contains = new ArrayList<String>(); + contains.add(expectedStrings[2]); + contains.add(expectedStrings[1]); + + assertTrue(result.containsAll(contains)); + } + + @Test + public void canCheckContainsAllForObjectsNotInList() throws Exception { + ListResult<String> result = createStringListResult(); + List<String> contains = new ArrayList<String>(); + contains.add(expectedStrings[2]); + contains.add("This is not in the list"); + + assertFalse(result.containsAll(contains)); + } + + @Test + public void canGetIndexOfItemInList() throws Exception { + ListResult<String> result = createStringListResult(); + + assertEquals(1, result.indexOf(expectedStrings[1])); + } + + @Test + public void indexOfItemNotInListIsMinusOne() throws Exception { + ListResult<String> result = createStringListResult(); + + assertEquals(-1, result.indexOf("Not in collection")); + } + + @Test + public void lastIndexOfItemInCollectionIsCorrect() throws Exception { + ListResult<String> result = new ListResult<String>(Arrays.asList("c", "b", "c", "a")); + + assertEquals(2, result.lastIndexOf("c")); + } + + @Test + public void lastIndexOfItemNotInCollectionIsMinusOne() throws Exception { + ListResult<String> result = createStringListResult(); + + assertEquals(-1, result.lastIndexOf("Not in collection")); + } + + @Test + public void optionalListMethodsAreUnsupported() throws Exception { + final ListResult<String> result = createStringListResult(); + + assertListIsImmutable(result); + } + + @Test + public void canGetWorkingListIteratorFromResult() throws Exception { + ListResult<String> result = createStringListResult(); + + ListIterator<String> iterator = result.listIterator(); + int i = 0; + for (i = 0; i < expectedStrings.length; ++i) { + assertIteratorAtPositionMovingForward(i, iterator); + } + + for (; i >= 0; --i) { + assertIteratorAtPositionMovingBackward(i, iterator); + } + } + + @Test + public void canGetWorkingListIteratorAtIndexFromResult() throws Exception { + ListResult<String> result = createStringListResult(); + + ListIterator<String> iterator = result.listIterator(1); + int i = 1; + for (; i < expectedStrings.length; ++i) { + assertIteratorAtPositionMovingForward(i, iterator); + } + + for (; i >= 0; --i) { + assertIteratorAtPositionMovingBackward(i, iterator); + } + } + + @Test + public void listIteratorIsImmutable() throws Exception { + ListResult<String> result = createStringListResult(); + final ListIterator<String> iterator = result.listIterator(); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.add("new string"); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.remove(); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.set("replace string"); + } + }); + } + + @Test + public void listIteratorIsImmutableWhenCreatedWithIndex() throws Exception { + ListResult<String> result = createStringListResult(); + final ListIterator<String> iterator = result.listIterator(1); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.add("new string"); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.remove(); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + iterator.set("replace string"); + } + }); + } + + @Test + public void canGetObjectArrayFromResult() throws Exception { + ListResult<String> result = createStringListResult(); + Object[] array = result.toArray(); + + assertNotNull(array); + assertEquals(result.size(), array.length); + for (int i = 0; i < result.size(); ++i) { + assertEquals(result.get(i), array[i]); + } + } + + @Test + public void canGetTypedArrayFromResult() throws Exception { + ListResult<String> result = createStringListResult(); + String[] array = result.toArray(new String[0]); + + assertNotNull(array); + assertEquals(result.size(), array.length); + for (int i = 0; i < result.size(); ++i) { + assertEquals(result.get(i), array[i]); + } + } + + @Test + public void canGetExpectedSublistFromResult() throws Exception { + ListResult<String> result = createStringListResult(); + List<String> sublist = result.subList(1, 3); + + assertEquals(2, sublist.size()); + assertEquals(result.get(1), sublist.get(0)); + assertEquals(result.get(2), sublist.get(1)); + } + + @Test + public void sublistIsImmutable() throws Exception { + ListResult<String> result = createStringListResult(); + final List<String> sublist = result.subList(1, 3); + + assertListIsImmutable(sublist); + } + + private ListResult<String> createStringListResult() { + ListResult<String> result = new ListResult<String>(Arrays.asList(expectedStrings)); + + return result; + } + + /// Assertion helpers /// + + private void assertIteratorState(int position, ListIterator<String> iterator) { + boolean expectHasNext = position < expectedStrings.length; + boolean expectHasPrevious = position != 0; + + assertNotNull("Iterator is null", iterator); + assertEquals(String.format("HasNext at position %d", position), expectHasNext, iterator.hasNext()); + assertEquals(String.format("HasPrevious at position %d", position), expectHasPrevious, iterator.hasPrevious()); + + if (expectHasNext) { + assertEquals(String.format("NextIndex at position %d", position), position, iterator.nextIndex()); + } + + if (expectHasPrevious) { + assertEquals(String.format("PreviousIndex at position %d", position), position - 1, + iterator.previousIndex()); + } + + } + + private void assertIteratorAtPositionMovingForward(int position, ListIterator<String> iterator) { + assertIteratorState(position, iterator); + + if (iterator.hasNext()) { + assertEquals(expectedStrings[position], iterator.next()); + } + else { + try { + iterator.next(); + fail("Exception should have been thrown"); + } + catch (NoSuchElementException ex) { + // Ok, we expected this + } + catch (Exception ex) { + fail("Unexpected exception was thrown"); + } + } + } + + private void assertIteratorAtPositionMovingBackward(int position, ListIterator<String> iterator) { + assertIteratorState(position, iterator); + + if (iterator.hasPrevious()) { + assertEquals(expectedStrings[position - 1], iterator.previous()); + } + else { + try { + iterator.previous(); + fail("Exception should have been thrown"); + } + catch (NoSuchElementException ex) { + // Ok, we expected this + } + catch (Exception ex) { + fail("Unexpected exception was thrown"); + } + } + } + + private interface Action { + void Do(); + } + + private void assertUnsupported(Action action) { + try { + action.Do(); + fail("Expected UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // This is ok + } + catch (Exception ex) { + fail("Expected UnsupportedOperationException, got something else"); + } + } + + private void assertListIsImmutable(final List<String> list) { + assertUnsupported(new Action() { + @Override + public void Do() { + list.add("new string"); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.add(2, "new string"); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.addAll(Arrays.asList("a", "b")); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.addAll(2, Arrays.asList("a", "b")); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.clear(); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.remove(1); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.remove(list.get(1)); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.removeAll(Arrays.asList(list.get(0), list.get(1))); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.retainAll(Arrays.asList(list.get(1))); + } + }); + + assertUnsupported(new Action() { + @Override + public void Do() { + list.set(1, "new string"); + } + }); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java deleted file mode 100644 index fdf6f06fa28b8..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsResultTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class ListMediaProcessorsResultTest { - - @Test - public void createListMediaProcessorsResultSuccess() { - // Arrange - - // Act - ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); - - // Assert - assertNotNull(listMediaProcessorsResult); - - } - - @Test - public void getSetMediaProcessorInfos() { - // Arrange - ListMediaProcessorsResult listMediaProcessorsResult = new ListMediaProcessorsResult(); - List<MediaProcessorInfo> expectedMediaProcessorInfos = new ArrayList<MediaProcessorInfo>(); - - // Act - List<MediaProcessorInfo> actualMediaProcessorInfos = listMediaProcessorsResult.setMediaProcessorInfos( - expectedMediaProcessorInfos).getMediaProcessorInfos(); - - // Assert - assertEquals(expectedMediaProcessorInfos, actualMediaProcessorInfos); - - } - -} From 79dab9cb69a731c214535653dc1ed56a9c1f8ee9 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 31 Oct 2012 17:23:22 -0700 Subject: [PATCH 431/664] partial check in to support batching. --- .../implementation/MediaBatchOperations.java | 39 ++++++++++--------- .../media/implementation/MediaRestProxy.java | 2 +- .../media/implementation/atom/EntryType.java | 2 +- .../services/media/models/AssetInfo.java | 12 +++++- .../media/models/CreateJobOptions.java | 10 ++++- .../media/MediaServiceIntegrationTest.java | 33 +++++++++++++++- 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 8035eca1f9f5c..018761afa89a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -182,11 +182,27 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws MessagingException, IOException { // Create unique part boundary strings String batchId = String.format("batch_%s", UUID.randomUUID().toString()); + + MimeMultipart changeSets = createChangeSets(bodyPartContents); + MimeBodyPart mimeBodyPart = createMimeBodyPart(batchId, changeSets); + + MimeMultipart mimeMultipart = new MimeMultipart(new SetBoundaryMultipartDataSource(batchId)); + mimeMultipart.addBodyPart(mimeBodyPart); + return mimeMultipart; + + } + + private MimeBodyPart createMimeBodyPart(String batchId, MimeMultipart changeSets) throws MessagingException { + MimeBodyPart mimeBodyPart = new MimeBodyPart(); + mimeBodyPart.setContent(changeSets); + String contentType = String.format("multipart/mixed; boundary=%s", batchId); + mimeBodyPart.setHeader("Content-Type", contentType); + return mimeBodyPart; + } + + private MimeMultipart createChangeSets(List<DataSource> bodyPartContents) throws MessagingException { String changeSet = String.format("changeset_%s", UUID.randomUUID().toString()); - // - // Build inner list of change sets containing the list of body part content - // MimeMultipart changeSets = new MimeMultipart(new SetBoundaryMultipartDataSource(changeSet)); for (DataSource bodyPart : bodyPartContents) { @@ -199,22 +215,7 @@ private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws changeSets.addBodyPart(mimeBodyPart); } - // - // Build outer "batch" body part - // - MimeBodyPart batchbody = new MimeBodyPart(); - batchbody.setContent(changeSets); - //Note: Both content type and encoding need to be set *after* setting content, because - // MimeBodyPart implementation replaces them when calling "setContent". - batchbody.setHeader("Content-Type", changeSets.getContentType()); - - // - // Build outer "batch" multipart - // - MimeMultipart batch = new MimeMultipart(new SetBoundaryMultipartDataSource(batchId)); - batch.addBodyPart(batchbody); - return batch; - + return changeSets; } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 489ecbf4c0878..d5a2278cb79d3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -632,7 +632,7 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio throw new ServiceException(e); } - ClientResponse clientResponse = resource.type(MediaType.APPLICATION_ATOM_XML) + ClientResponse clientResponse = resource.type(mimeMultipart.getContentType()) .accept(MediaType.APPLICATION_ATOM_XML).post(ClientResponse.class, mimeMultipart); JobInfo jobInfo = new JobInfo(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index e0e0b19370247..db365e0a5adfe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -192,7 +192,7 @@ public Map<QName, String> getOtherAttributes() { } public URI getLink() { - // TODO Auto-generated method stub + return null; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 5e8f8acc7d0f5..cc7c4cbb61e7f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -17,6 +17,7 @@ import java.net.URI; import java.util.Date; +import java.util.List; import com.microsoft.windowsazure.services.core.utils.DateConverter; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; @@ -29,6 +30,8 @@ */ public class AssetInfo extends ODataEntity<AssetType> { + private URI uri; + public AssetInfo(EntryType entry, AssetType content) { super(entry, content); } @@ -185,11 +188,16 @@ public AssetInfo setOptions(EncryptionOption options) { } public URI getUri() { - return getEntry().getLink(); + return this.getEntry().getLink(); } public AssetInfo setUri(URI uri) { - getEntry().setLink(uri); + this.uri = uri; return this; } + + public List<Object> getChildren() { + return this.getEntry().getEntryChildren(); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java index 2dc3b7dc8e95c..cd79457835697 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.models; import java.net.URI; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -33,10 +34,15 @@ public class CreateJobOptions { private Integer priority; /** The input media assets. */ - private List<URI> inputMediaAssets; + private final List<URI> inputMediaAssets; /** The output media assets. */ - private List<URI> outputMediaAssets; + private final List<URI> outputMediaAssets; + + public CreateJobOptions() { + this.inputMediaAssets = new ArrayList<URI>(); + this.outputMediaAssets = new ArrayList<URI>(); + } /** * Gets the start time. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index f6c6d57e5afc4..cd9fe26f1280c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -17,15 +17,20 @@ import static org.junit.Assert.*; +import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; +import javax.ws.rs.core.UriBuilder; +import javax.xml.bind.JAXBElement; + import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.atom.IdType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.AssetInfo; @@ -525,7 +530,33 @@ public void createJobWithTaskSuccess() throws ServiceException { // Arrange AssetInfo assetInfo = service.createAsset(); CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.addInputMediaAsset(assetInfo.getUri()); + List<Object> children = assetInfo.getChildren(); + String uri = ""; + for (Object object : children) { + + JAXBElement<IdType> jaxbIdType = null; + + try { + jaxbIdType = (JAXBElement<IdType>) object; + } + catch (ClassCastException e) { + + } + if (jaxbIdType != null) { + IdType idtype = null; + try { + idtype = jaxbIdType.getValue(); + } + catch (ClassCastException e) { + + } + if (idtype != null) { + uri = idtype.getValue(); + } + } + } + URI inputMediaAsset = UriBuilder.fromPath(uri).build(); + createJobOptions.addInputMediaAsset(inputMediaAsset); List<CreateTaskOptions> createTaskOptions = new ArrayList<CreateTaskOptions>(); CreateTaskOptions createTaskOptionsInstance = new CreateTaskOptions(); createTaskOptions.add(createTaskOptionsInstance); From 259013a9254c8eb17efdeb1d478fe01385adf83a Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 1 Nov 2012 10:54:34 -0700 Subject: [PATCH 432/664] Code review feedback --- .../windowsazure/services/media/models/ListResult.java | 5 ++--- .../services/media/AccessPolicyIntegrationTest.java | 2 +- .../services/media/models/GenericListResultTest.java | 9 --------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java index fd470092b57f2..b941db3945a95 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java @@ -96,13 +96,12 @@ public int lastIndexOf(Object object) { @Override public ListIterator<T> listIterator() { - return listIterator(0); + return contents.listIterator(); } @Override public ListIterator<T> listIterator(int index) { - List<T> l = Collections.unmodifiableList(contents); - return l.listIterator(index); + return contents.listIterator(index); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 53cb2b2c39403..2510f26976702 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -199,7 +199,7 @@ public void canDeleteAccessPolicyByNonexistId() throws Exception { @Test public void canRetryAccessPolicyCreation() throws Exception { - String name = testPolicyPrefix + "canUploadBlockBlobWithExplicitRetry"; + String name = testPolicyPrefix + "canRetryAccessPolicyCreationPolicy"; double duration = 1; EnumSet<AccessPolicyPermission> write = EnumSet.of(AccessPolicyPermission.WRITE); service.createAccessPolicy(name + "1", duration, write); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java index 35db51830c553..b6235a5c17a6d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java @@ -314,9 +314,6 @@ private void assertIteratorAtPositionMovingForward(int position, ListIterator<St catch (NoSuchElementException ex) { // Ok, we expected this } - catch (Exception ex) { - fail("Unexpected exception was thrown"); - } } } @@ -334,9 +331,6 @@ private void assertIteratorAtPositionMovingBackward(int position, ListIterator<S catch (NoSuchElementException ex) { // Ok, we expected this } - catch (Exception ex) { - fail("Unexpected exception was thrown"); - } } } @@ -352,9 +346,6 @@ private void assertUnsupported(Action action) { catch (UnsupportedOperationException ex) { // This is ok } - catch (Exception ex) { - fail("Expected UnsupportedOperationException, got something else"); - } } private void assertListIsImmutable(final List<String> list) { From 66d3af2c962506a24ce33d50138b2182f2faf549 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 2 Nov 2012 14:36:08 -0700 Subject: [PATCH 433/664] Remove `NewlineAtEndOfFile`: Justification: The rule incorrectly flags all files as violating this rule, regardless of what they end with. Remove `Javadoc*`: Justification: Many methods that could be documented are intentionally undocumented because they are not part of the public surface SDK area. Remove `LineLength`: Justification: The project properties automatically breaks lines longer than 120 characters. Any lines that are longer cannot be broken. Remove `RightCurly`: Justification: The Azure SDK coding guidelines are to have the right curly on a separate line. Remove `HiddenField`: Justification: The Azure SDK coding guidelines are that the setter and constructor parameter names match the names of the fields that are being set. Remove `DesignForExtension`: Justification: None of the SDK classes are intended to be subclassed by end-users, but at the same time we don't want to mark them final and prevent derivation for scenarios like mocking, etc. Remove `FinalParameters`: Justification: The cost to implement and verify the changes outweighs the benefit here. Remove `RegexpSingleline`: Justification: Over 5000 hits in generated boilerplate comments. Use Eclipse preference file to auto-remove EOL whitespace in code. Update preferences to automatically remove trailing whitespace characters in code lines. Remove the .settings to the .gitignore file, so the preferences can be shared across the team. Fix the single instance of EOL whitespace in code. --- .gitignore | 2 - .../.settings/org.eclipse.jdt.ui.prefs | 2 +- microsoft-azure-api/src/config/checkstyle.xml | 49 ++++++++++++++++++- .../serviceruntime/RoleEnvironment.java | 2 +- 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 940d90fcccc71..11a721777fdd7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ .project target node_modules -.settings - diff --git a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs index 0f7349dc40641..1192a0c8bae03 100644 --- a/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs +++ b/microsoft-azure-api/.settings/org.eclipse.jdt.ui.prefs @@ -30,7 +30,7 @@ cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=tru cleanup.qualify_static_member_accesses_with_declaring_class=true cleanup.qualify_static_method_accesses_with_declaring_class=false cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=false +cleanup.remove_trailing_whitespaces=true cleanup.remove_trailing_whitespaces_all=true cleanup.remove_trailing_whitespaces_ignore_empty=false cleanup.remove_unnecessary_casts=true diff --git a/microsoft-azure-api/src/config/checkstyle.xml b/microsoft-azure-api/src/config/checkstyle.xml index 0f628e43c5c52..287b61490dd39 100644 --- a/microsoft-azure-api/src/config/checkstyle.xml +++ b/microsoft-azure-api/src/config/checkstyle.xml @@ -47,7 +47,12 @@ <!-- Checks whether files end with a new line. --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + + <!-- Removed on 11/02/2012 + Justification: The rule incorrectly flags all files as violating + this rule, regardless of what they end with. <module name="NewlineAtEndOfFile"/> + --> <!-- Checks that property files contain the same keys. --> <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> @@ -62,11 +67,15 @@ <property name="eachLine" value="true"/> </module> + <!-- Removed on 11/02/2012: + Justification: Over 5000 hits in generated boilerplate comments. + Use Eclipse preference file to auto-remove EOL whitespace in code. + <module name="RegexpSingleline"> - <!-- \s matches whitespace character, $ matches end of line. --> <property name="format" value="\s+$"/> <property name="message" value="Line has trailing spaces."/> </module> + --> <module name="TreeWalker"> @@ -74,10 +83,17 @@ <!-- Checks for Javadoc comments. --> <!-- See http://checkstyle.sf.net/config_javadoc.html --> + + <!-- Removed on 11/02/2012 + Justification: Many methods that could be documented are + intentionally undocumented because they are not part of + the public surface SDK area. + <module name="JavadocMethod"/> <module name="JavadocType"/> <module name="JavadocVariable"/> <module name="JavadocStyle"/> + --> <!-- Checks for Naming Conventions. --> @@ -118,9 +134,15 @@ <!-- Checks for Size Violations. --> <!-- See http://checkstyle.sf.net/config_sizes.html --> + + <!-- Removed on 11/02/2012: + Justification: The project properties automatically breaks + lines longer than 120 characters. Any lines that are longer + cannot be broken. <module name="LineLength"> <property name="max" value="160" /> </module> + --> <module name="MethodLength"/> <module name="ParameterNumber"/> @@ -150,7 +172,12 @@ <module name="EmptyBlock"/> <module name="LeftCurly"/> <module name="NeedBraces"/> + + <!-- Removed on 11/02/2012: + Justification: The Azure SDK coding guidelines + are to have the right curly on a separate line. <module name="RightCurly"/> + --> <!-- Checks for common coding problems --> @@ -159,7 +186,13 @@ <module name="DoubleCheckedLocking"/> <!-- MY FAVOURITE --> <module name="EmptyStatement"/> <module name="EqualsHashCode"/> + <!-- Removed on 11/02/2012: + Justification: The Azure SDK coding guidelines + are that the setter and constructor parameter names match + the names of the fields that are being set. <module name="HiddenField"/> + --> + <module name="IllegalInstantiation"/> <module name="InnerAssignment"/> <module name="MagicNumber"/> @@ -170,7 +203,15 @@ <!-- Checks for class design --> <!-- See http://checkstyle.sf.net/config_design.html --> + + <!-- Removed on 11/02/2012: + Justification: None of the SDK classes are intended + to be subclassed by end-users, but at the same time we don't + want to mark them final and prevent derivation for scenarios + like mocking, etc. <module name="DesignForExtension"/> + --> + <module name="FinalClass"/> <module name="HideUtilityClassConstructor"/> <module name="InterfaceIsType"/> @@ -180,7 +221,13 @@ <!-- Miscellaneous other checks. --> <!-- See http://checkstyle.sf.net/config_misc.html --> <module name="ArrayTypeStyle"/> + + <!-- Removed on 11/02/2012: + Justification: The cost to implement and verify the changes + outweighs the benefit here. <module name="FinalParameters"/> + --> + <module name="TodoComment"/> <module name="UpperEll"/> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index f0bc096b8a1e8..d34d5bcef11fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -468,7 +468,7 @@ public static void setStatus(RoleInstanceStatus status, Date expiration_utc) { Calendar expiration = Calendar.getInstance(); expiration.setTime(expiration_utc); - + CurrentState newState = new AcquireCurrentState(clientId, currentGoalState.get().getIncarnation(), currentStatus, expiration); From 5ed118436e371251c16187a976537aab9fc92353 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 2 Nov 2012 15:17:27 -0700 Subject: [PATCH 434/664] partial check in to harmonize the batching operation. --- .../media/implementation/MediaRestProxy.java | 30 ++++++++++++------- .../media/MediaServiceIntegrationTest.java | 3 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index d5a2278cb79d3..8a812dc7c0cca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -265,6 +265,22 @@ private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksO return listTasksResult; } + private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOptions) { + JobType jobType = new JobType(); + if (createJobOptions != null) { + jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); + jobType.setName(createJobOptions.getName()); + jobType.setOutputMediaAssets(createJobOptions.getOutputMediaAssets()); + jobType.setPriority(createJobOptions.getPriority()); + jobType.setStartTime(createJobOptions.getStartTime()); + } + + CreateJobOperation createJobOperation = new CreateJobOperation(); + createJobOperation.setJob(jobType); + + return createJobOperation; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() */ @@ -588,15 +604,6 @@ public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) t public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptions> createTaskOptions) throws ServiceException { - JobType jobType = new JobType(); - if (createJobOptions != null) { - jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); - jobType.setName(createJobOptions.getName()); - jobType.setOutputMediaAssets(createJobOptions.getOutputMediaAssets()); - jobType.setPriority(createJobOptions.getPriority()); - jobType.setStartTime(createJobOptions.getStartTime()); - } - WebResource resource = getResource("$batch"); MediaBatchOperations mediaBatchOperations = null; try { @@ -608,8 +615,9 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio catch (ParserConfigurationException e) { throw new ServiceException(e); } - CreateJobOperation createJobOperation = new CreateJobOperation(); - createJobOperation.setJob(jobType); + + CreateJobOperation createJobOperation = createCreateJobOperation(createJobOptions); + mediaBatchOperations.addOperation(createJobOperation); for (CreateTaskOptions createTaskOptionsInstance : createTaskOptions) { CreateTaskOperation createTaskOperation = new CreateTaskOperation(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java index cd9fe26f1280c..bb4df9aaa51e0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceIntegrationTest.java @@ -595,6 +595,7 @@ public void listJobsSuccess() throws ServiceException { // Assert assertNotNull(listJobsResult); + assertEquals(2, listJobsResult.getJobInfos().size()); } @Test @@ -684,7 +685,7 @@ public void listJobTasksSuccess() throws ServiceException { assertNotNull(listTasksResult); } - @Test + @Test(expected = ServiceException.class) public void listJobTasksInvalidIdFailed() throws ServiceException { // Arrange From de8144574d563733362844c873903cf25f42f6d9 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 4 Nov 2012 22:54:37 -0800 Subject: [PATCH 435/664] add unit tests for media batch operations. --- .../implementation/CreateJobOperation.java | 15 ++ .../implementation/CreateTaskOperation.java | 15 ++ .../implementation/MediaBatchOperations.java | 11 +- .../media/implementation/Operation.java | 15 ++ .../SetBoundaryMultipartDataSource.java | 15 ++ .../implementation/content/TaskType.java | 14 +- .../media/models/CreateTaskOptions.java | 24 ++- .../MediaBatchOperationsTest.java | 116 +++++++++++ .../media/models/CreateTaskOptionsTest.java | 197 ++++++++++++++++++ 9 files changed, 407 insertions(+), 15 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java index 9abd8e46b5025..3e75e6ef5341a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import com.microsoft.windowsazure.services.media.implementation.content.JobType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java index 5e16e7d0ef0d2..1a90a4e6f5f86 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 018761afa89a6..1c4968f98759b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -58,12 +58,13 @@ public class MediaBatchOperations { * * @param serviceURI * the service uri - * @throws JAXBException - * the jAXB exception * @throws ParserConfigurationException - * the parser configuration exception + * @throws JAXBException */ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigurationException { + if (serviceURI == null) { + throw new IllegalArgumentException("The service URI cannot be null."); + } this.serviceURI = serviceURI; this.oDataAtomMarshaller = new ODataAtomMarshaller(); this.operations = new ArrayList<Operation>(); @@ -342,4 +343,8 @@ private void appendEntity(OutputStream outputStream, ByteArrayInputStream byteAr } } + public List<Operation> getOperations() { + return operations; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java index 85fed639af49a..00d3c129b7e5a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java @@ -1,3 +1,18 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; public interface Operation { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java index 7f6b453a7d8e0..01d7d1129701b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index c032b1c6c359c..a675e5e3e6520 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -15,7 +15,9 @@ package com.microsoft.windowsazure.services.media.implementation.content; +import java.net.URI; import java.util.Date; +import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -84,10 +86,10 @@ public class TaskType implements MediaServiceDTO { protected String initializationVector; @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected String outputMediaAssets; + protected List<URI> outputMediaAssets; @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected String inputMediaAssets; + protected List<URI> inputMediaAssets; public String getId() { return id; @@ -233,19 +235,19 @@ public void setInitializationVector(String initializationVector) { this.initializationVector = initializationVector; } - public String getOutputMediaAssets() { + public List<URI> getOutputMediaAssets() { return outputMediaAssets; } - public void setOutputMediaAssets(String outputMediaAssets) { + public void setOutputMediaAssets(List<URI> outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; } - public String getInputMediaAssets() { + public List<URI> getInputMediaAssets() { return inputMediaAssets; } - public void setInputMediaAssets(String inputMediaAssets) { + public void setInputMediaAssets(List<URI> inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java index 656751593d151..3b2b2c214b5ea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java @@ -15,7 +15,9 @@ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; import java.util.Date; +import java.util.List; /** * The Class CreateTaskOptions. @@ -53,10 +55,10 @@ public class CreateTaskOptions { private String initializationVector; /** The input media assets. */ - private String inputMediaAssets; + private List<URI> inputMediaAssets; /** The output media assets. */ - private String outputMediaAssets; + private List<URI> outputMediaAssets; /** * Gets the start time. @@ -128,7 +130,7 @@ public Integer getPriority() { * the input media assets * @return the creates the job options */ - public CreateTaskOptions setInputMediaAssets(String inputMediaAssets) { + public CreateTaskOptions setInputMediaAssets(List<URI> inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; return this; } @@ -138,7 +140,7 @@ public CreateTaskOptions setInputMediaAssets(String inputMediaAssets) { * * @return the input media assets */ - public String getInputMediaAssets() { + public List<URI> getInputMediaAssets() { return this.inputMediaAssets; } @@ -149,7 +151,7 @@ public String getInputMediaAssets() { * the output media assets * @return the creates the job options */ - public CreateTaskOptions setOutputMediaAssets(String outputMediaAssets) { + public CreateTaskOptions setOutputMediaAssets(List<URI> outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; return this; } @@ -159,7 +161,7 @@ public CreateTaskOptions setOutputMediaAssets(String outputMediaAssets) { * * @return the output media assets */ - public String getOutputMediaAssets() { + public List<URI> getOutputMediaAssets() { return this.outputMediaAssets; } @@ -303,4 +305,14 @@ public CreateTaskOptions setInitializationVector(String initializationVector) { return this; } + public CreateTaskOptions addInputMediaAsset(URI inputMediaAsset) { + this.inputMediaAssets.add(inputMediaAsset); + return this; + } + + public CreateTaskOptions addOutputMediaAsset(URI outputMediaAsset) { + this.outputMediaAssets.add(outputMediaAsset); + return this; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java new file mode 100644 index 0000000000000..e6781b18c5e27 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -0,0 +1,116 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.net.URI; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMultipart; +import javax.ws.rs.core.UriBuilder; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.JobType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; + +public class MediaBatchOperationsTest { + + @Test + public void createMediaBatchOperationSuccess() throws JAXBException, ParserConfigurationException { + // Arrange + URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); + + // Act + MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); + + // Assert + assertNotNull(mediaBatchOperations); + + } + + @Test(expected = IllegalArgumentException.class) + public void createMediaBatchOperationFailedWithNullUri() throws JAXBException, ParserConfigurationException { + // Arrange + URI serviceUri = null; + + // Act + MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); + + // Assert + assertTrue(false); + + } + + @Test + public void addCreateJobOperationToMediaBatchOperationsSuccess() throws JAXBException, ParserConfigurationException { + // Arrange + URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); + CreateJobOperation createJobOperation = new CreateJobOperation(); + + // Act + MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); + mediaBatchOperations.addOperation(createJobOperation); + + // Assert + assertNotNull(mediaBatchOperations); + assertEquals(1, mediaBatchOperations.getOperations().size()); + + } + + @Test + public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBException, + ParserConfigurationException { + // Arrange + URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); + CreateTaskOperation createTaskOperation = new CreateTaskOperation(); + + // Act + MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); + mediaBatchOperations.addOperation(createTaskOperation); + + // Assert + assertNotNull(mediaBatchOperations); + assertEquals(1, mediaBatchOperations.getOperations().size()); + } + + @Test + public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationException, MessagingException, + IOException { + // Arrange + URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); + JobType jobType = new JobType(); + TaskType taskType = new TaskType(); + CreateTaskOperation createTaskOperation = new CreateTaskOperation().setTask(taskType); + CreateJobOperation createJobOperation = new CreateJobOperation().setJob(jobType); + + // Act + MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); + mediaBatchOperations.addOperation(createJobOperation); + mediaBatchOperations.addOperation(createTaskOperation); + MimeMultipart mimeMultipart = mediaBatchOperations.getMimeMultipart(); + + // Assert + assertNotNull(mediaBatchOperations); + assertEquals(2, mediaBatchOperations.getOperations().size()); + assertNotNull(mimeMultipart); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java new file mode 100644 index 0000000000000..4f958f52a216d --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java @@ -0,0 +1,197 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.ws.rs.core.UriBuilder; + +import org.junit.Test; + +public class CreateTaskOptionsTest { + + @Test + public void testGetSetConfiguration() { + // Arrange + String expectedTaskConfiguration = "testGetSetConfiguration"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualTaskConfiguration = createTaskOptions.setName(expectedTaskConfiguration).getConfiguration(); + + // Assert + assertEquals(expectedTaskConfiguration, actualTaskConfiguration); + } + + @Test + public void testGetSetMediaProcessorId() { + // Arrange + String expectedMediaProcessorId = "testGetSetMediaProcessorId"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualMediaProcessorId = createTaskOptions.setMediaProcessorId(expectedMediaProcessorId) + .getMediaProcessorId(); + + // Assert + assertEquals(expectedMediaProcessorId, actualMediaProcessorId); + + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testGetSetName"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualName = createTaskOptions.setName(expectedName).getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetPriority() { + // Arrange + Integer expectedPriority = 3; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + Integer actualPriority = createTaskOptions.setPriority(expectedPriority).getPriority(); + + // Assert + assertEquals(expectedPriority, actualPriority); + } + + @Test + public void testGetSetStartTime() { + // Arrange + Date expectedStartTime = new Date(); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + Date actualStartTime = createTaskOptions.setStartTime(expectedStartTime).getStartTime(); + + // Assert + assertEquals(expectedStartTime, actualStartTime); + } + + @Test + public void testGetSetTaskBody() { + // Arrange + String expectedTaskBody = "testExpectedTaskBody"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualTaskBody = createTaskOptions.setTaskBody(expectedTaskBody).getTaskBody(); + + // Assert + assertEquals(expectedTaskBody, actualTaskBody); + } + + @Test + public void testGetSetEncryptionKeyId() { + // Arrange + String expectedEncryptionKeyId = "testGetSetEncryptionKeyId"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualEncryptionKeyId = createTaskOptions.setEncryptionKeyId(expectedEncryptionKeyId) + .getEncryptionKeyId(); + + // Assert + assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); + } + + @Test + public void testGetSetEncryptionScheme() { + // Arrange + String expectedEncryptionScheme = "testEncryptionScheme"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualEncryptionScheme = createTaskOptions.setEncryptionScheme(expectedEncryptionScheme) + .getEncryptionScheme(); + + // Assert + assertEquals(expectedEncryptionScheme, actualEncryptionScheme); + } + + @Test + public void testGetSetEncryptionVersion() { + // Arrange + String expectedEncryptionVersion = "testEncryptionVersion"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualEncryptionVersion = createTaskOptions.setEncryptionVersion(expectedEncryptionVersion) + .getEncryptionVersion(); + + // Assert + assertEquals(expectedEncryptionVersion, actualEncryptionVersion); + } + + @Test + public void testGetSetInitializationVector() { + // Arrange + String expectedInitializationVector = "testInitializatonVector"; + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + String actualInitializationVector = createTaskOptions.setInitializationVector(expectedInitializationVector) + .getInitializationVector(); + + // Assert + assertEquals(expectedInitializationVector, actualInitializationVector); + } + + @Test + public void testGetSetInputMediaAssets() { + // Arrange + URI expectedInputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); + List<URI> expectedInputMediaAssets = new ArrayList<URI>(); + expectedInputMediaAssets.add(expectedInputMediaAsset); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + List<URI> actualInputMediaAssets = createTaskOptions.addInputMediaAsset(expectedInputMediaAsset) + .getInputMediaAssets(); + + // Assert + assertEquals(expectedInputMediaAssets, actualInputMediaAssets); + } + + @Test + public void testGetSetOutputMediaAssets() { + // Arrange + URI expectedOutputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); + List<URI> expectedOutputMediaAssets = new ArrayList<URI>(); + expectedOutputMediaAssets.add(expectedOutputMediaAsset); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + + // Act + List<URI> actualOutputMediaAssets = createTaskOptions.addOutputMediaAsset(expectedOutputMediaAsset) + .getOutputMediaAssets(); + + // Assert + assertEquals(expectedOutputMediaAssets, actualOutputMediaAssets); + } +} From 45a2aa3c134e2f8deda493368e3b7c5ef30630c1 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 12:38:42 -0800 Subject: [PATCH 436/664] Initial sketching out, building up implmentations via TDD --- .../windowsazure/services/media/Exports.java | 3 ++ .../services/media/MediaEntityContract.java | 38 +++++++++++++++ .../services/media/entities/Asset.java | 46 +++++++++++++++++++ .../entities/EntityCreationOperation.java | 30 ++++++++++++ .../implementation/MediaEntityRestProxy.java | 44 ++++++++++++++++++ .../services/media/EntityProxyTest.java | 27 +++++++++++ .../media/entities/AssetEntityTest.java | 42 +++++++++++++++++ 7 files changed, 230 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 2487fd162e08a..0338244010bc9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -21,6 +21,7 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.media.implementation.MediaContentProvider; +import com.microsoft.windowsazure.services.media.implementation.MediaEntityRestProxy; import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; import com.microsoft.windowsazure.services.media.implementation.MediaRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthContract; @@ -52,6 +53,8 @@ public void register(Builder.Registry registry) { registry.add(RedirectFilter.class); registry.add(VersionHeadersFilter.class); + registry.add(MediaEntityContract.class, MediaEntityRestProxy.class); + registry.alter(ClientConfig.class, new Builder.Alteration<ClientConfig>() { @Override public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Object> properties) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java new file mode 100644 index 0000000000000..2b3ddeee8215d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; + +/** + * Contract for interacting with the back end service + * providing various odata entities. + * + */ +public interface MediaEntityContract { + + /** + * Create a new instance of an entity + * + * @param creator + * Object providing the details of the entity to be + * created + * @return + * The created entity + */ + <T> T create(EntityCreationOperation<T> creator) throws ServiceException; +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java new file mode 100644 index 0000000000000..5282b4b9e2736 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -0,0 +1,46 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + +/** + * + */ +public class Asset { + + // Prevent instantiation + private Asset() { + } + + public class Info { + public String getId() { + return "a"; + } + } + + public static EntityCreationOperation<Asset.Info> create() { + return new Creator(); + } + + private static class Creator implements EntityCreationOperation<Info> { + + @Override + public Object getRequestContents() { + return new AssetType(); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java new file mode 100644 index 0000000000000..df01d5d277bfb --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +/** + * + * + */ +public interface EntityCreationOperation<T> { + /** + * Get the object to be sent to the server containing + * the request data for entity creation. + * + * @return The payload to be marshalled and sent to the server. + */ + Object getRequestContents(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java new file mode 100644 index 0000000000000..d267e0a3b778c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -0,0 +1,44 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.MediaEntityContract; +import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; + +/** + * + * + */ +public class MediaEntityRestProxy implements MediaEntityContract { + + /** + * + */ + public MediaEntityRestProxy() { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaEntityContract#create(com.microsoft.windowsazure.services.media.entities.EntityCreationOperation) + */ + @Override + public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java new file mode 100644 index 0000000000000..29a117316847d --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -0,0 +1,27 @@ +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.entities.Asset; + +public class EntityProxyTest extends IntegrationTestBase { + + @Test + public void canCreateEntityProxy() { + MediaEntityContract proxy = config.create(MediaEntityContract.class); + + assertNotNull(proxy); + } + + @Test + public void canCreateDefaultAssetEntity() throws Exception { + + MediaEntityContract proxy = config.create(MediaEntityContract.class); + + Asset.Info asset = proxy.create(Asset.create()); + + assertNotNull(asset.getId()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java new file mode 100644 index 0000000000000..1960f6a73e089 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -0,0 +1,42 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + +/** + * Tests for the methods and factories of the Asset entity. + */ +public class AssetEntityTest { + + @Test + public void assetCreateReturnsDefaultCreatePayload() { + AssetType payload = (AssetType) Asset.create().getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertEquals(0, payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertNull(payload.getName()); + assertEquals(0, payload.getOptions()); + } +} From dc4ace6a5d5de4ac645524adcd367988f7942677 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 14:54:14 -0800 Subject: [PATCH 437/664] Creating and getting --- .../services/media/MediaEntityContract.java | 14 +- .../services/media/entities/Asset.java | 130 ++++++++++++- .../entities/EntityCreationOperation.java | 30 +++ .../media/entities/EntityGetOperation.java | 53 ++++++ .../implementation/MediaEntityRestProxy.java | 177 +++++++++++++++++- .../services/media/EntityProxyTest.java | 37 +++- .../media/entities/AssetEntityTest.java | 29 +++ 7 files changed, 454 insertions(+), 16 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index 2b3ddeee8215d..6ff4f47618d39 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -15,15 +15,17 @@ package com.microsoft.windowsazure.services.media; +import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; /** * Contract for interacting with the back end service * providing various odata entities. * */ -public interface MediaEntityContract { +public interface MediaEntityContract extends FilterableService<MediaEntityContract> { /** * Create a new instance of an entity @@ -35,4 +37,14 @@ public interface MediaEntityContract { * The created entity */ <T> T create(EntityCreationOperation<T> creator) throws ServiceException; + + /** + * Retrieve an existing entity by id + * + * @param getter + * object providing the details of the entity to be retrieved + * @return The retrieved entity + * @throws ServiceException + */ + <T> T get(EntityGetOperation<T> getter) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 5282b4b9e2736..828b239fdd557 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -15,7 +15,14 @@ package com.microsoft.windowsazure.services.media.entities; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.InvalidParameterException; + +import javax.ws.rs.core.MediaType; + import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.models.AssetInfo; /** * @@ -26,21 +33,128 @@ public class Asset { private Asset() { } - public class Info { - public String getId() { - return "a"; - } + public static Creator create() { + return new CreatorImpl(); } - public static EntityCreationOperation<Asset.Info> create() { - return new Creator(); + public interface Creator extends EntityCreationOperation<AssetInfo> { + /** + * Set the name of the asset to be created + * + * @param name + * The name + * @return The creator object (for call chaining) + */ + Creator name(String name); + + /** + * Sets the alternate id of the asset to be created. + * + * @param alternateId + * The id + * + * @return The creator object (for call chaining) + */ + Creator alternateId(String alternateId); } - private static class Creator implements EntityCreationOperation<Info> { + private static class CreatorImpl implements Creator { + private String name; + private String alternateId; + + @Override + public String getUri() { + return "Assets"; + } + + @Override + public MediaType getContentType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + @Override + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + @Override + public Class<AssetInfo> getResponseClass() { + return AssetInfo.class; + } @Override public Object getRequestContents() { - return new AssetType(); + AssetType assetType = new AssetType(); + assetType.setName(name); + assetType.setAlternateId(alternateId); + return assetType; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.Asset.Creator#name(java.lang.String) + */ + @Override + public Creator name(String name) { + this.name = name; + return this; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.Asset.Creator#alternateId(java.lang.String) + */ + @Override + public Creator alternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + } + + public static EntityGetOperation<AssetInfo> get(String assetId) { + return new GetterImpl(assetId); + } + + private static class GetterImpl implements EntityGetOperation<AssetInfo> { + private final String assetId; + + public GetterImpl(String assetId) { + super(); + this.assetId = assetId; + } + + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(assetId); + } + return String.format("Assets('%s')", escapedEntityId); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getContentType() + */ + @Override + public MediaType getContentType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getAcceptType() + */ + @Override + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getResponseClass() + */ + @Override + public Class<AssetInfo> getResponseClass() { + return AssetInfo.class; } } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java index df01d5d277bfb..e9e051414843a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java @@ -15,11 +15,21 @@ package com.microsoft.windowsazure.services.media.entities; +import javax.ws.rs.core.MediaType; + /** * * */ public interface EntityCreationOperation<T> { + + /** + * Get the URI the creation request should be sent to. + * + * @return The uri + */ + public String getUri(); + /** * Get the object to be sent to the server containing * the request data for entity creation. @@ -27,4 +37,24 @@ public interface EntityCreationOperation<T> { * @return The payload to be marshalled and sent to the server. */ Object getRequestContents(); + + /** + * Get the MIME type for the content that's being sent to the server. + * + * @return The MIME type + */ + MediaType getContentType(); + + /** + * Get the MIME type that we're expecting the server to send back. + */ + MediaType getAcceptType(); + + /** + * Get the Java class object for the type that the response should + * be unmarshalled into. + * + * @return Class object for response. + */ + Class<T> getResponseClass(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java new file mode 100644 index 0000000000000..bc740c6748259 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java @@ -0,0 +1,53 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MediaType; + +/** + * + * + */ +public interface EntityGetOperation<T> { + /** + * Get the URI required to retrieve an entity + * + * @return The URI + */ + String getUri(); + + /** + * Get the media type for content sent to the server + * + * @return media type + */ + MediaType getContentType(); + + /** + * Get the media type for the response back from the server + * + * @return media type + */ + MediaType getAcceptType(); + + /** + * Get the Java class that the returned data + * will be unmarshalled into + * + * @return Class object + */ + Class<T> getResponseClass(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index d267e0a3b778c..986e6a8035e18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -15,15 +15,177 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Arrays; + +import javax.inject.Inject; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaEntityContract; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.models.ListOptions; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.WebResource; /** * * */ public class MediaEntityRestProxy implements MediaEntityContract { + /** The channel. */ + private Client channel; + + /** The log. */ + static Log log = LogFactory.getLog(MediaContract.class); + /** The filters. */ + ServiceFilter[] filters; + + /** + * Instantiates a new media rest proxy. + * + * @param channel + * the channel + * @param authFilter + * the auth filter + * @param redirectFilter + * the redirect filter + * @param versionHeadersFilter + * the version headers filter + */ + @Inject + public MediaEntityRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, + VersionHeadersFilter versionHeadersFilter) { + this.channel = channel; + this.filters = new ServiceFilter[0]; + + channel.addFilter(redirectFilter); + channel.addFilter(authFilter); + channel.addFilter(versionHeadersFilter); + } + + /** + * Instantiates a new media rest proxy. + * + * @param channel + * the channel + * @param filters + * the filters + */ + public MediaEntityRestProxy(Client channel, ServiceFilter[] filters) { + this.channel = channel; + this.filters = filters; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) + */ + @Override + public MediaEntityContract withFilter(ServiceFilter filter) { + ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); + newFilters[filters.length] = filter; + return new MediaEntityRestProxy(channel, newFilters); + } + + /** + * Gets the channel. + * + * @return the channel + */ + public Client getChannel() { + return channel; + } + + /** + * Sets the channel. + * + * @param channel + * the new channel + */ + public void setChannel(Client channel) { + this.channel = channel; + } + + /** + * Gets the resource. + * + * @param entityName + * the entity name + * @return the resource + */ + private WebResource getResource(String entityName) { + WebResource resource = getChannel().resource(entityName); + for (ServiceFilter filter : filters) { + resource.addFilter(new ClientFilterAdapter(filter)); + } + return resource; + } + + private WebResource getResource(String entityName, ListOptions options) { + WebResource resource = getResource(entityName); + if (options != null) { + resource = resource.queryParams(options.getQueryParameters()); + } + return resource; + } + + /** + * Gets the resource. + * + * @param entityType + * the entity type + * @param entityId + * the entity id + * @return the resource + * @throws ServiceException + * the service exception + */ + private WebResource getResource(String entityType, String entityId) throws ServiceException { + String escapedEntityId = null; + try { + escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new ServiceException(e); + } + String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); + + return getResource(entityPath); + } + + /** + * Merge request. + * + * @param <T> + * the generic type + * @param entityType + * the entity type + * @param entityId + * the entity id + * @param c + * the c + * @param requestEntity + * the request entity + * @return the t + * @throws ServiceException + * the service exception + */ + private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T> c, java.lang.Object requestEntity) + throws ServiceException { + WebResource resource = getResource(entityType, entityId); + WebResource.Builder builder = resource.getRequestBuilder(); + builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) + .header("X-HTTP-Method", "MERGE"); + return builder.post(c, requestEntity); + } /** * @@ -37,8 +199,19 @@ public MediaEntityRestProxy() { */ @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { - // TODO Auto-generated method stub - return null; + WebResource resource = getResource(creator.getUri()); + + return resource.type(creator.getContentType()).accept(creator.getAcceptType()) + .post(creator.getResponseClass(), creator.getRequestContents()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaEntityContract#get(com.microsoft.windowsazure.services.media.entities.EntityGetOperation) + */ + @Override + public <T> T get(EntityGetOperation<T> getter) throws ServiceException { + WebResource resource = getResource(getter.getUri()); + + return resource.type(getter.getContentType()).accept(getter.getAcceptType()).get(getter.getResponseClass()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 29a117316847d..6aa04c090c7d0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -2,26 +2,53 @@ import static org.junit.Assert.*; +import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.media.entities.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; public class EntityProxyTest extends IntegrationTestBase { + private static MediaEntityContract entityService; + + @BeforeClass + public static void entityProxyTestSetup() { + entityService = config.create(MediaEntityContract.class); + } @Test public void canCreateEntityProxy() { - MediaEntityContract proxy = config.create(MediaEntityContract.class); - - assertNotNull(proxy); + assertNotNull(entityService); } @Test public void canCreateDefaultAssetEntity() throws Exception { - MediaEntityContract proxy = config.create(MediaEntityContract.class); + AssetInfo asset = entityService.create(Asset.create()); + + assertNotNull(asset.getId()); + } + + @Test + public void canCreateAssetOnServerWithNameAndAltId() throws Exception { + String name = testAssetPrefix + "AName"; + String altId = "unit test alt id"; - Asset.Info asset = proxy.create(Asset.create()); + AssetInfo asset = entityService.create(Asset.create().name(name).alternateId(altId)); assertNotNull(asset.getId()); + assertEquals(name, asset.getName()); + assertEquals(altId, asset.getAlternateId()); + } + + @Test + public void canRetrieveAssetById() throws Exception { + AssetInfo createdAsset = entityService.create(Asset.create().name(testAssetPrefix + "canRetrieveAssetById")); + + AssetInfo retrieved = entityService.get(Asset.get(createdAsset.getId())); + + assertEquals(createdAsset.getId(), retrieved.getId()); + assertEquals(createdAsset.getName(), retrieved.getName()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java index 1960f6a73e089..461a6706f87f2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.models.AssetInfo; /** * Tests for the methods and factories of the Asset entity. @@ -39,4 +40,32 @@ public void assetCreateReturnsDefaultCreatePayload() { assertNull(payload.getName()); assertEquals(0, payload.getOptions()); } + + @Test + public void assetCreateCanSetAssetName() { + String name = "assetCreateCanSetAssetName"; + + Asset.Creator creator = Asset.create().name("assetCreateCanSetAssetName"); + + AssetType payload = (AssetType) creator.getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertEquals(0, payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertEquals(name, payload.getName()); + assertEquals(0, payload.getOptions()); + } + + @Test + public void assetGetReturnsExpectedUri() { + String sampleAssetId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; + String expectedUri = String.format("Assets('%s')", sampleAssetId); + + EntityGetOperation<AssetInfo> getter = Asset.get(sampleAssetId); + + assertEquals(expectedUri, getter.getUri()); + } } From 0858deeb291e40287cc66af5dc613283f92a82dc Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 14:57:04 -0800 Subject: [PATCH 438/664] Refactoring out commonality in interfaces --- .../entities/EntityCreationOperation.java | 30 +--------------- .../media/entities/EntityGetOperation.java | 34 ++----------------- .../media/entities/EntityOperation.java | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+), 61 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java index e9e051414843a..e4abaed106670 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java @@ -15,20 +15,12 @@ package com.microsoft.windowsazure.services.media.entities; -import javax.ws.rs.core.MediaType; /** * * */ -public interface EntityCreationOperation<T> { - - /** - * Get the URI the creation request should be sent to. - * - * @return The uri - */ - public String getUri(); +public interface EntityCreationOperation<T> extends EntityOperation<T> { /** * Get the object to be sent to the server containing @@ -37,24 +29,4 @@ public interface EntityCreationOperation<T> { * @return The payload to be marshalled and sent to the server. */ Object getRequestContents(); - - /** - * Get the MIME type for the content that's being sent to the server. - * - * @return The MIME type - */ - MediaType getContentType(); - - /** - * Get the MIME type that we're expecting the server to send back. - */ - MediaType getAcceptType(); - - /** - * Get the Java class object for the type that the response should - * be unmarshalled into. - * - * @return Class object for response. - */ - Class<T> getResponseClass(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java index bc740c6748259..ac0485c79198a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java @@ -15,39 +15,9 @@ package com.microsoft.windowsazure.services.media.entities; -import javax.ws.rs.core.MediaType; - /** + * Get operation for Entities * - * */ -public interface EntityGetOperation<T> { - /** - * Get the URI required to retrieve an entity - * - * @return The URI - */ - String getUri(); - - /** - * Get the media type for content sent to the server - * - * @return media type - */ - MediaType getContentType(); - - /** - * Get the media type for the response back from the server - * - * @return media type - */ - MediaType getAcceptType(); - - /** - * Get the Java class that the returned data - * will be unmarshalled into - * - * @return Class object - */ - Class<T> getResponseClass(); +public interface EntityGetOperation<T> extends EntityOperation<T> { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java new file mode 100644 index 0000000000000..d493a1a759000 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java @@ -0,0 +1,34 @@ +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MediaType; + +public interface EntityOperation<T> { + + /** + * Get the URI the creation request should be sent to. + * + * @return The uri + */ + public abstract String getUri(); + + /** + * Get the MIME type for the content that's being sent to the server. + * + * @return The MIME type + */ + public abstract MediaType getContentType(); + + /** + * Get the MIME type that we're expecting the server to send back. + */ + public abstract MediaType getAcceptType(); + + /** + * Get the Java class object for the type that the response should + * be unmarshalled into. + * + * @return Class object for response. + */ + public abstract Class<T> getResponseClass(); + +} \ No newline at end of file From 2e6d749a6696f74a26efc31d996915d90536aa25 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 15:27:06 -0800 Subject: [PATCH 439/664] Listing - in the entity at least --- .../services/media/entities/Asset.java | 52 +++++++++++++++++++ .../entities/EntityCreationOperation.java | 3 +- .../media/entities/EntityGetOperation.java | 2 +- .../media/entities/EntityListOperation.java | 40 ++++++++++++++ .../media/entities/EntityOperation.java | 24 +++++---- .../entities/EntityOperationSingleResult.java | 26 ++++++++++ .../media/entities/AssetEntityTest.java | 14 ++++- 7 files changed, 147 insertions(+), 14 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 828b239fdd557..1c56c7f82d8ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -20,9 +20,12 @@ import java.security.InvalidParameterException; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.sun.jersey.api.client.GenericType; /** * @@ -114,6 +117,7 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { } private static class GetterImpl implements EntityGetOperation<AssetInfo> { + private final String assetId; public GetterImpl(String assetId) { @@ -157,4 +161,52 @@ public Class<AssetInfo> getResponseClass() { return AssetInfo.class; } } + + public static EntityListOperation<AssetInfo> list() { + return new ListerImpl(); + } + + private static class ListerImpl implements EntityListOperation<AssetInfo> { + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() + */ + @Override + public MultivaluedMap<String, String> getQueryParameters() { + return null; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getUri() + */ + @Override + public String getUri() { + return "Assets"; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getContentType() + */ + @Override + public MediaType getContentType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getAcceptType() + */ + @Override + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getResponseGenericType() + */ + @Override + public GenericType<ListResult<AssetInfo>> getResponseGenericType() { + return new GenericType<ListResult<AssetInfo>>() { + }; + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java index e4abaed106670..ffda9a16cffce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java @@ -15,12 +15,11 @@ package com.microsoft.windowsazure.services.media.entities; - /** * * */ -public interface EntityCreationOperation<T> extends EntityOperation<T> { +public interface EntityCreationOperation<T> extends EntityOperationSingleResult<T> { /** * Get the object to be sent to the server containing diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java index ac0485c79198a..d4c9ed00def33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java @@ -19,5 +19,5 @@ * Get operation for Entities * */ -public interface EntityGetOperation<T> extends EntityOperation<T> { +public interface EntityGetOperation<T> extends EntityOperationSingleResult<T> { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java new file mode 100644 index 0000000000000..1db074cde7d12 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java @@ -0,0 +1,40 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.sun.jersey.api.client.GenericType; + +/** + * Operation class to retrieve a list of entities + * + */ +public interface EntityListOperation<T> extends EntityOperation<T> { + + /** + * Get query parameters to add to the uri + * + * @return The query parameters collection + */ + MultivaluedMap<String, String> getQueryParameters(); + + /** + * Get a GenericType object representing the result list type + */ + GenericType<ListResult<T>> getResponseGenericType(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java index d493a1a759000..5a3fe7c7297ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.entities; import javax.ws.rs.core.MediaType; @@ -22,13 +37,4 @@ public interface EntityOperation<T> { * Get the MIME type that we're expecting the server to send back. */ public abstract MediaType getAcceptType(); - - /** - * Get the Java class object for the type that the response should - * be unmarshalled into. - * - * @return Class object for response. - */ - public abstract Class<T> getResponseClass(); - } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java new file mode 100644 index 0000000000000..98f8978536ce4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java @@ -0,0 +1,26 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +public interface EntityOperationSingleResult<T> extends EntityOperation<T> { + /** + * Get the Java class object for the type that the response should + * be unmarshalled into. + * + * @return Class object for response. + */ + public abstract Class<T> getResponseClass(); +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java index 461a6706f87f2..579a87c4e021a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -17,6 +17,8 @@ import static org.junit.Assert.*; +import java.net.URLEncoder; + import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; @@ -60,12 +62,20 @@ public void assetCreateCanSetAssetName() { } @Test - public void assetGetReturnsExpectedUri() { + public void assetGetReturnsExpectedUri() throws Exception { String sampleAssetId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; - String expectedUri = String.format("Assets('%s')", sampleAssetId); + String expectedUri = String.format("Assets('%s')", URLEncoder.encode(sampleAssetId, "UTF-8")); EntityGetOperation<AssetInfo> getter = Asset.get(sampleAssetId); assertEquals(expectedUri, getter.getUri()); } + + @Test + public void assetListReturnsExpectedUri() { + EntityListOperation<AssetInfo> lister = Asset.list(); + + assertEquals("Assets", lister.getUri()); + assertNull(lister.getQueryParameters()); + } } From 3af637d5151e674eaf25271ad78b5fd32f943c35 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 15:47:39 -0800 Subject: [PATCH 440/664] Listing assets on the server --- .../services/media/MediaEntityContract.java | 13 +++++++++ .../implementation/MediaEntityRestProxy.java | 14 ++++++++++ .../services/media/EntityProxyTest.java | 27 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index 6ff4f47618d39..1f4b74a93f4e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -19,6 +19,8 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.models.ListResult; /** * Contract for interacting with the back end service @@ -47,4 +49,15 @@ public interface MediaEntityContract extends FilterableService<MediaEntityContra * @throws ServiceException */ <T> T get(EntityGetOperation<T> getter) throws ServiceException; + + /** + * Retrieve a list of entities + * + * @param lister + * object providing details of entities to list + * @return The resulting list + * @throws ServiceException + */ + <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index 986e6a8035e18..f21a9289f3edd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -32,7 +32,9 @@ import com.microsoft.windowsazure.services.media.MediaEntityContract; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.models.ListOptions; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; @@ -214,4 +216,16 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { return resource.type(getter.getContentType()).accept(getter.getAcceptType()).get(getter.getResponseClass()); } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaEntityContract#list(com.microsoft.windowsazure.services.media.entities.EntityListOperation) + */ + @Override + public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { + WebResource resource = getResource(lister.getUri()); + + return resource.type(lister.getContentType()).accept(lister.getAcceptType()) + .get(lister.getResponseGenericType()); + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 6aa04c090c7d0..946c4453e8bcf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -2,11 +2,15 @@ import static org.junit.Assert.*; +import java.util.HashSet; +import java.util.Set; + import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.media.entities.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; public class EntityProxyTest extends IntegrationTestBase { private static MediaEntityContract entityService; @@ -51,4 +55,27 @@ public void canRetrieveAssetById() throws Exception { assertEquals(createdAsset.getName(), retrieved.getName()); } + + @Test + public void canListAllAssets() throws Exception { + int numAssetsToCreate = 4; + Set<String> expectedAssets = new HashSet<String>(); + + for (int i = 0; i < numAssetsToCreate; ++i) { + AssetInfo asset = entityService.create(Asset.create().name( + testAssetPrefix + "canList" + Integer.toString(i))); + expectedAssets.add(asset.getId()); + } + + ListResult<AssetInfo> assets = entityService.list(Asset.list()); + + assertTrue(assets.size() >= numAssetsToCreate); + + for (AssetInfo asset : assets) { + if (expectedAssets.contains(asset.getId())) { + expectedAssets.remove(asset.getId()); + } + } + assertEquals(0, expectedAssets.size()); + } } From a1d68c6fdf07507ff34527ef33d25f305c7bf41b Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 16:00:32 -0800 Subject: [PATCH 441/664] Refactoring to remove duplication in operation implementations. --- .../services/media/entities/Asset.java | 80 +++---------------- .../media/entities/EntityListOperation.java | 2 +- .../media/entities/EntityOperation.java | 2 +- .../media/entities/EntityOperationBase.java | 58 ++++++++++++++ .../entities/EntityOperationSingleResult.java | 2 +- .../EntityOperationSingleResultBase.java | 40 ++++++++++ 6 files changed, 111 insertions(+), 73 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 1c56c7f82d8ca..93341a774c473 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -19,7 +19,6 @@ import java.net.URLEncoder; import java.security.InvalidParameterException; -import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; @@ -61,28 +60,12 @@ public interface Creator extends EntityCreationOperation<AssetInfo> { Creator alternateId(String alternateId); } - private static class CreatorImpl implements Creator { + private static class CreatorImpl extends EntityOperationSingleResultBase<AssetInfo> implements Creator { private String name; private String alternateId; - @Override - public String getUri() { - return "Assets"; - } - - @Override - public MediaType getContentType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; - } - - @Override - public MediaType getAcceptType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; - } - - @Override - public Class<AssetInfo> getResponseClass() { - return AssetInfo.class; + public CreatorImpl() { + super("Assets", AssetInfo.class); } @Override @@ -116,12 +99,13 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { return new GetterImpl(assetId); } - private static class GetterImpl implements EntityGetOperation<AssetInfo> { + private static class GetterImpl extends EntityOperationSingleResultBase<AssetInfo> implements + EntityGetOperation<AssetInfo> { private final String assetId; public GetterImpl(String assetId) { - super(); + super("Assets", AssetInfo.class); this.assetId = assetId; } @@ -134,31 +118,7 @@ public String getUri() { catch (UnsupportedEncodingException e) { throw new InvalidParameterException(assetId); } - return String.format("Assets('%s')", escapedEntityId); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getContentType() - */ - @Override - public MediaType getContentType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getAcceptType() - */ - @Override - public MediaType getAcceptType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityGetOperation#getResponseClass() - */ - @Override - public Class<AssetInfo> getResponseClass() { - return AssetInfo.class; + return String.format("%s('%s')", super.getUri(), escapedEntityId); } } @@ -166,7 +126,7 @@ public static EntityListOperation<AssetInfo> list() { return new ListerImpl(); } - private static class ListerImpl implements EntityListOperation<AssetInfo> { + private static class ListerImpl extends EntityOperationBase implements EntityListOperation<AssetInfo> { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() @@ -176,28 +136,8 @@ public MultivaluedMap<String, String> getQueryParameters() { return null; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getUri() - */ - @Override - public String getUri() { - return "Assets"; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getContentType() - */ - @Override - public MediaType getContentType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getAcceptType() - */ - @Override - public MediaType getAcceptType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; + public ListerImpl() { + super("Assets"); } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java index 1db074cde7d12..430a15c5659a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java @@ -24,7 +24,7 @@ * Operation class to retrieve a list of entities * */ -public interface EntityListOperation<T> extends EntityOperation<T> { +public interface EntityListOperation<T> extends EntityOperation { /** * Get query parameters to add to the uri diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java index 5a3fe7c7297ff..21377a0b38967 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java @@ -17,7 +17,7 @@ import javax.ws.rs.core.MediaType; -public interface EntityOperation<T> { +public interface EntityOperation { /** * Get the URI the creation request should be sent to. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java new file mode 100644 index 0000000000000..9d463b4498a16 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java @@ -0,0 +1,58 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MediaType; + +/** + * Default implementation of EntityOperation<T> to provide + * default values for common methods. + * + */ +public abstract class EntityOperationBase implements EntityOperation { + private final String uri; + + /** + * + */ + protected EntityOperationBase(String uri) { + this.uri = uri; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getUri() + */ + @Override + public String getUri() { + return uri; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getContentType() + */ + @Override + public MediaType getContentType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getAcceptType() + */ + @Override + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java index 98f8978536ce4..6bedba3a63bab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java @@ -15,7 +15,7 @@ package com.microsoft.windowsazure.services.media.entities; -public interface EntityOperationSingleResult<T> extends EntityOperation<T> { +public interface EntityOperationSingleResult<T> extends EntityOperation { /** * Get the Java class object for the type that the response should * be unmarshalled into. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java new file mode 100644 index 0000000000000..f591982303da5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java @@ -0,0 +1,40 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +/** + * + * + */ +public class EntityOperationSingleResultBase<T> extends EntityOperationBase implements EntityOperationSingleResult<T> { + private final Class<T> responseClass; + + /** + * + */ + public EntityOperationSingleResultBase(String uri, Class<T> responseClass) { + super(uri); + this.responseClass = responseClass; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperationSingleResult#getResponseClass() + */ + @Override + public Class<T> getResponseClass() { + return responseClass; + } +} From 2790e7ac354b9b495f017f0c2ef62b898a08d2fa Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 5 Nov 2012 16:01:16 -0800 Subject: [PATCH 442/664] address code review feedback. --- .../implementation/MediaBatchOperations.java | 9 ++- .../media/implementation/MediaRestProxy.java | 61 +++++++++---------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 1c4968f98759b..09111dfad70f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -82,6 +82,12 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur * the jAXB exception */ public MimeMultipart getMimeMultipart() throws MessagingException, IOException, JAXBException { + List<DataSource> bodyPartContents = createRequestBody(); + return toMimeMultipart(bodyPartContents); + + } + + private List<DataSource> createRequestBody() throws JAXBException { List<DataSource> bodyPartContents = new ArrayList<DataSource>(); int contentId = 1; @@ -91,8 +97,7 @@ public MimeMultipart getMimeMultipart() throws MessagingException, IOException, URI taskURI = UriBuilder.fromUri(serviceURI).path(String.format("$%d", jobContentId)).path("Tasks").build(); addTaskPart(bodyPartContents, taskURI, contentId); - - return toMimeMultipart(bodyPartContents); + return bodyPartContents; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index bf58523c3efa7..96b2149c4cc54 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -59,9 +59,9 @@ import com.microsoft.windowsazure.services.media.models.ListLocatorsResult; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsResult; +import com.microsoft.windowsazure.services.media.models.ListOptions; import com.microsoft.windowsazure.services.media.models.ListTasksOptions; import com.microsoft.windowsazure.services.media.models.ListTasksResult; -import com.microsoft.windowsazure.services.media.models.ListOptions; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; @@ -289,6 +289,32 @@ private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOp return createJobOperation; } + private CreateTaskOperation createTaskOperation(CreateTaskOptions createTaskOptions) { + CreateTaskOperation createTaskOperation = new CreateTaskOperation(); + + if (createTaskOptions == null) { + throw new IllegalArgumentException("The create task options cannot be null."); + } + + TaskType taskType = new TaskType(); + taskType.setConfiguration(createTaskOptions.getConfiguration()); + taskType.setMediaProcessorId(createTaskOptions.getMediaProcessorId()); + taskType.setName(createTaskOptions.getName()); + taskType.setPriority(createTaskOptions.getPriority()); + taskType.setStartTime(createTaskOptions.getStartTime()); + taskType.setTaskBody(createTaskOptions.getTaskBody()); + taskType.setEncryptionKeyId(createTaskOptions.getEncryptionKeyId()); + taskType.setEncryptionScheme(createTaskOptions.getEncryptionScheme()); + taskType.setEncryptionVersion(createTaskOptions.getEncryptionVersion()); + taskType.setInitializationVector(createTaskOptions.getInitializationVector()); + taskType.setInputMediaAssets(createTaskOptions.getInputMediaAssets()); + taskType.setOutputMediaAssets(createTaskOptions.getOutputMediaAssets()); + + createTaskOperation.setTask(taskType); + + return createTaskOperation; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() */ @@ -600,9 +626,7 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio mediaBatchOperations.addOperation(createJobOperation); for (CreateTaskOptions createTaskOptionsInstance : createTaskOptions) { - CreateTaskOperation createTaskOperation = new CreateTaskOperation(); - TaskType taskType = createTaskType(createTaskOptionsInstance); - createTaskOperation.setTask(taskType); + CreateTaskOperation createTaskOperation = createTaskOperation(createTaskOptionsInstance); mediaBatchOperations.addOperation(createTaskOperation); } @@ -628,35 +652,6 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio } - /** - * Creates the task type. - * - * @param createTaskOptions - * the create task options - * @return the task type - */ - private TaskType createTaskType(CreateTaskOptions createTaskOptions) { - if (createTaskOptions == null) { - throw new IllegalArgumentException("The create task options cannot be null."); - } - - TaskType taskType = new TaskType(); - taskType.setConfiguration(createTaskOptions.getConfiguration()); - taskType.setMediaProcessorId(createTaskOptions.getMediaProcessorId()); - taskType.setName(createTaskOptions.getName()); - taskType.setPriority(createTaskOptions.getPriority()); - taskType.setStartTime(createTaskOptions.getStartTime()); - taskType.setTaskBody(createTaskOptions.getTaskBody()); - taskType.setEncryptionKeyId(createTaskOptions.getEncryptionKeyId()); - taskType.setEncryptionScheme(createTaskOptions.getEncryptionScheme()); - taskType.setEncryptionVersion(createTaskOptions.getEncryptionVersion()); - taskType.setInitializationVector(createTaskOptions.getInitializationVector()); - taskType.setInputMediaAssets(createTaskOptions.getInputMediaAssets()); - taskType.setOutputMediaAssets(createTaskOptions.getOutputMediaAssets()); - - return taskType; - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) */ From 4e6945a227490d9e88d411b9f5d88bda043760c0 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 16:21:38 -0800 Subject: [PATCH 443/664] Listing with query parameters --- .../services/media/entities/Asset.java | 22 ++++++++++++++----- .../implementation/MediaEntityRestProxy.java | 4 ++-- .../services/media/EntityProxyTest.java | 22 +++++++++++++++++++ .../media/entities/AssetEntityTest.java | 19 +++++++++++++++- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 93341a774c473..8bdd0dc720dfb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -25,6 +25,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * @@ -126,18 +127,29 @@ public static EntityListOperation<AssetInfo> list() { return new ListerImpl(); } + public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { + return new ListerImpl(queryParameters); + } + private static class ListerImpl extends EntityOperationBase implements EntityListOperation<AssetInfo> { + private final MultivaluedMap<String, String> queryParameters; + + public ListerImpl() { + super("Assets"); + queryParameters = new MultivaluedMapImpl(); + } + + public ListerImpl(MultivaluedMap<String, String> queryParameters) { + this(); + this.queryParameters.putAll(queryParameters); + } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() */ @Override public MultivaluedMap<String, String> getQueryParameters() { - return null; - } - - public ListerImpl() { - super("Assets"); + return queryParameters; } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index f21a9289f3edd..1ec19772ce413 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -224,8 +224,8 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { WebResource resource = getResource(lister.getUri()); - return resource.type(lister.getContentType()).accept(lister.getAcceptType()) - .get(lister.getResponseGenericType()); + return resource.queryParams(lister.getQueryParameters()).type(lister.getContentType()) + .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 946c4453e8bcf..807d54c74580d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -5,12 +5,15 @@ import java.util.HashSet; import java.util.Set; +import javax.ws.rs.core.MultivaluedMap; + import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.media.entities.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.sun.jersey.core.util.MultivaluedMapImpl; public class EntityProxyTest extends IntegrationTestBase { private static MediaEntityContract entityService; @@ -78,4 +81,23 @@ public void canListAllAssets() throws Exception { } assertEquals(0, expectedAssets.size()); } + + @Test + public void canListAssetsWithQueryParameters() throws Exception { + int numAssetsToCreate = 4; + Set<String> expectedAssets = new HashSet<String>(); + + for (int i = 0; i < numAssetsToCreate; ++i) { + AssetInfo asset = entityService.create(Asset.create().name( + testAssetPrefix + "withQuery" + Integer.toString(i))); + expectedAssets.add(asset.getId()); + } + + MultivaluedMap<String, String> params = new MultivaluedMapImpl(); + params.add("$top", "2"); + + ListResult<AssetInfo> assets = entityService.list(Asset.list(params)); + + assertEquals(2, assets.size()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java index 579a87c4e021a..ada9fb8c2e572 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -19,10 +19,13 @@ import java.net.URLEncoder; +import javax.ws.rs.core.MultivaluedMap; + import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the methods and factories of the Asset entity. @@ -76,6 +79,20 @@ public void assetListReturnsExpectedUri() { EntityListOperation<AssetInfo> lister = Asset.list(); assertEquals("Assets", lister.getUri()); - assertNull(lister.getQueryParameters()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void assetListCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<AssetInfo> lister = Asset.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); } } From 3c6f403cddc047da483992a77f6b089a110410ef Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 16:54:44 -0800 Subject: [PATCH 444/664] Updating assets back to the server. --- .../services/media/MediaEntityContract.java | 9 ++++ .../services/media/entities/Asset.java | 53 +++++++++++++++++++ .../media/entities/EntityUpdateOperation.java | 30 +++++++++++ .../implementation/MediaEntityRestProxy.java | 15 ++++++ .../services/media/EntityProxyTest.java | 16 ++++++ .../media/entities/AssetEntityTest.java | 24 ++++++++- 6 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index 1f4b74a93f4e0..59efa333f7547 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -20,6 +20,7 @@ import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListResult; /** @@ -60,4 +61,12 @@ public interface MediaEntityContract extends FilterableService<MediaEntityContra */ <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; + /** + * Update an existing asset + * + * @param updater + * Object providing details of the update + * @throws ServiceException + */ + void update(EntityUpdateOperation updater) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 8bdd0dc720dfb..91672720fd42f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -161,4 +161,57 @@ public GenericType<ListResult<AssetInfo>> getResponseGenericType() { }; } } + + public static Updater update(String assetId) { + return new UpdaterImpl(assetId); + } + + public interface Updater extends EntityUpdateOperation { + Updater name(String name); + + Updater alternateId(String alternateId); + } + + private static class UpdaterImpl extends EntityOperationBase implements Updater { + private final String assetId; + private String name; + private String alternateId; + + protected UpdaterImpl(String assetId) { + super("Assets"); + this.assetId = assetId; + } + + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(assetId); + } + return String.format("%s('%s')", super.getUri(), escapedEntityId); + } + + @Override + public Object getRequestContents() { + AssetType assetType = new AssetType(); + assetType.setName(name); + assetType.setAlternateId(alternateId); + return assetType; + } + + @Override + public Updater name(String name) { + this.name = name; + return this; + } + + @Override + public Updater alternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java new file mode 100644 index 0000000000000..33feab73a8862 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java @@ -0,0 +1,30 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +/** + * + * + */ +public interface EntityUpdateOperation extends EntityOperation { + /** + * Get the contents of the merge request that will + * be sent to the server. + * + * @return The payload object + */ + Object getRequestContents(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index 1ec19772ce413..7ee89be1bc59b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -28,14 +28,17 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaEntityContract; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListOptions; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; /** @@ -228,4 +231,16 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaEntityContract#update(com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation) + */ + @Override + public void update(EntityUpdateOperation updater) throws ServiceException { + WebResource resource = getResource(updater.getUri()); + + ClientResponse response = resource.type(updater.getContentType()).accept(updater.getAcceptType()) + .header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, updater.getRequestContents()); + + PipelineHelpers.ThrowIfNotSuccess(response); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 807d54c74580d..b6d4197c06443 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -100,4 +100,20 @@ public void canListAssetsWithQueryParameters() throws Exception { assertEquals(2, assets.size()); } + + @Test + public void canUpdateAssetNameAndAltId() throws Exception { + String newName = testAssetPrefix + "newName"; + String newAltId = "updated alt id"; + + AssetInfo initialAsset = entityService.create(Asset.create().name(testAssetPrefix + "originalName")); + + entityService.update(Asset.update(initialAsset.getId()).name(newName).alternateId(newAltId)); + + AssetInfo updatedAsset = entityService.get(Asset.get(initialAsset.getId())); + + assertEquals(initialAsset.getId(), updatedAsset.getId()); + assertEquals(newName, updatedAsset.getName()); + assertEquals(newAltId, updatedAsset.getAlternateId()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java index ada9fb8c2e572..0dc2307e6befb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -31,6 +31,7 @@ * Tests for the methods and factories of the Asset entity. */ public class AssetEntityTest { + static final String sampleAssetId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; @Test public void assetCreateReturnsDefaultCreatePayload() { @@ -66,7 +67,6 @@ public void assetCreateCanSetAssetName() { @Test public void assetGetReturnsExpectedUri() throws Exception { - String sampleAssetId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; String expectedUri = String.format("Assets('%s')", URLEncoder.encode(sampleAssetId, "UTF-8")); EntityGetOperation<AssetInfo> getter = Asset.get(sampleAssetId); @@ -95,4 +95,26 @@ public void assetListCanTakeQueryParameters() { assertEquals("2", lister.getQueryParameters().getFirst("$skip")); assertEquals(2, lister.getQueryParameters().size()); } + + @Test + public void assetUpdateReturnsExpectedUri() throws Exception { + EntityUpdateOperation updater = Asset.update(sampleAssetId); + String expectedUri = String.format("Assets('%s')", URLEncoder.encode(sampleAssetId, "UTF-8")); + + assertEquals(expectedUri, updater.getUri()); + } + + @Test + public void assetUpdateCanSetNameAndAltId() throws Exception { + + String expectedName = "newAssetName"; + String expectedAltId = "newAltId"; + + EntityUpdateOperation updater = Asset.update(sampleAssetId).name(expectedName).alternateId(expectedAltId); + + AssetType payload = (AssetType) updater.getRequestContents(); + + assertEquals(expectedName, payload.getName()); + assertEquals(expectedAltId, payload.getAlternateId()); + } } From 3ee0319fde6de0c0855703e87646a37f5e1b4d0f Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 17:02:00 -0800 Subject: [PATCH 445/664] Refactoring to remove duplication inside proxy --- .../implementation/MediaEntityRestProxy.java | 86 ++----------------- 1 file changed, 8 insertions(+), 78 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index 7ee89be1bc59b..62c3343b4c975 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -15,12 +15,9 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.Arrays; import javax.inject.Inject; -import javax.ws.rs.core.MediaType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,12 +31,13 @@ import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.entities.EntityOperation; import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; -import com.microsoft.windowsazure.services.media.models.ListOptions; import com.microsoft.windowsazure.services.media.models.ListResult; 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; /** * @@ -134,69 +132,8 @@ private WebResource getResource(String entityName) { return resource; } - private WebResource getResource(String entityName, ListOptions options) { - WebResource resource = getResource(entityName); - if (options != null) { - resource = resource.queryParams(options.getQueryParameters()); - } - return resource; - } - - /** - * Gets the resource. - * - * @param entityType - * the entity type - * @param entityId - * the entity id - * @return the resource - * @throws ServiceException - * the service exception - */ - private WebResource getResource(String entityType, String entityId) throws ServiceException { - String escapedEntityId = null; - try { - escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new ServiceException(e); - } - String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); - - return getResource(entityPath); - } - - /** - * Merge request. - * - * @param <T> - * the generic type - * @param entityType - * the entity type - * @param entityId - * the entity id - * @param c - * the c - * @param requestEntity - * the request entity - * @return the t - * @throws ServiceException - * the service exception - */ - private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T> c, java.lang.Object requestEntity) - throws ServiceException { - WebResource resource = getResource(entityType, entityId); - WebResource.Builder builder = resource.getRequestBuilder(); - builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .header("X-HTTP-Method", "MERGE"); - return builder.post(c, requestEntity); - } - - /** - * - */ - public MediaEntityRestProxy() { - // TODO Auto-generated constructor stub + private Builder getResource(EntityOperation operation) { + return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); } /* (non-Javadoc) @@ -204,10 +141,7 @@ public MediaEntityRestProxy() { */ @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { - WebResource resource = getResource(creator.getUri()); - - return resource.type(creator.getContentType()).accept(creator.getAcceptType()) - .post(creator.getResponseClass(), creator.getRequestContents()); + return getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); } /* (non-Javadoc) @@ -215,9 +149,7 @@ public <T> T create(EntityCreationOperation<T> creator) throws ServiceException */ @Override public <T> T get(EntityGetOperation<T> getter) throws ServiceException { - WebResource resource = getResource(getter.getUri()); - - return resource.type(getter.getContentType()).accept(getter.getAcceptType()).get(getter.getResponseClass()); + return getResource(getter).get(getter.getResponseClass()); } /* (non-Javadoc) @@ -236,10 +168,8 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep */ @Override public void update(EntityUpdateOperation updater) throws ServiceException { - WebResource resource = getResource(updater.getUri()); - - ClientResponse response = resource.type(updater.getContentType()).accept(updater.getAcceptType()) - .header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, updater.getRequestContents()); + ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, + updater.getRequestContents()); PipelineHelpers.ThrowIfNotSuccess(response); } From b2f684e0d8b2979b6ab1735438bd067ae894bc49 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 17:24:48 -0800 Subject: [PATCH 446/664] Deleting assets - CRUD operations are all implemented --- .../services/media/MediaEntityContract.java | 10 ++++ .../services/media/entities/Asset.java | 24 +++++++++ .../media/entities/EntityDeleteOperation.java | 10 ++++ .../implementation/MediaEntityRestProxy.java | 10 ++++ .../services/media/EntityProxyTest.java | 50 +++++++++++++------ .../media/entities/AssetEntityTest.java | 14 +++++- 6 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index 59efa333f7547..ca7d61984f736 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -18,6 +18,7 @@ import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; @@ -69,4 +70,13 @@ public interface MediaEntityContract extends FilterableService<MediaEntityContra * @throws ServiceException */ void update(EntityUpdateOperation updater) throws ServiceException; + + /** + * Delete an asset + * + * @param deleter + * Object providing details of the delete + * @throws ServiceException + */ + void delete(EntityDeleteOperation deleter) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 91672720fd42f..409169c17556c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -214,4 +214,28 @@ public Updater alternateId(String alternateId) { return this; } } + + public static EntityDeleteOperation delete(String id) { + return new DeleteImpl(id); + } + + private static class DeleteImpl implements EntityDeleteOperation { + private final String assetId; + + public DeleteImpl(String id) { + this.assetId = id; + } + + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(assetId); + } + return String.format("%s('%s')", "Assets", escapedEntityId); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java new file mode 100644 index 0000000000000..44736e7c4ca72 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java @@ -0,0 +1,10 @@ +package com.microsoft.windowsazure.services.media.entities; + +public interface EntityDeleteOperation { + /** + * Get the URI to use to delete an entity + * + * @return The uri + */ + String getUri(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index 62c3343b4c975..83fce1ad169e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -29,6 +29,7 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaEntityContract; import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.entities.EntityOperation; @@ -173,4 +174,13 @@ public void update(EntityUpdateOperation updater) throws ServiceException { PipelineHelpers.ThrowIfNotSuccess(response); } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaEntityContract#delete(com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation) + */ + @Override + public void delete(EntityDeleteOperation deleter) throws ServiceException { + getResource(deleter.getUri()).delete(); + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index b6d4197c06443..afcf0ab88a08c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -62,13 +62,7 @@ public void canRetrieveAssetById() throws Exception { @Test public void canListAllAssets() throws Exception { int numAssetsToCreate = 4; - Set<String> expectedAssets = new HashSet<String>(); - - for (int i = 0; i < numAssetsToCreate; ++i) { - AssetInfo asset = entityService.create(Asset.create().name( - testAssetPrefix + "canList" + Integer.toString(i))); - expectedAssets.add(asset.getId()); - } + Set<String> expectedAssets = createTestAssets(numAssetsToCreate, "canList"); ListResult<AssetInfo> assets = entityService.list(Asset.list()); @@ -84,14 +78,7 @@ public void canListAllAssets() throws Exception { @Test public void canListAssetsWithQueryParameters() throws Exception { - int numAssetsToCreate = 4; - Set<String> expectedAssets = new HashSet<String>(); - - for (int i = 0; i < numAssetsToCreate; ++i) { - AssetInfo asset = entityService.create(Asset.create().name( - testAssetPrefix + "withQuery" + Integer.toString(i))); - expectedAssets.add(asset.getId()); - } + createTestAssets(4, "withQuery"); MultivaluedMap<String, String> params = new MultivaluedMapImpl(); params.add("$top", "2"); @@ -116,4 +103,37 @@ public void canUpdateAssetNameAndAltId() throws Exception { assertEquals(newName, updatedAsset.getName()); assertEquals(newAltId, updatedAsset.getAlternateId()); } + + @Test + public void canDeleteAssetsById() throws Exception { + int numToDelete = 3; + Set<String> assetsToDelete = createTestAssets(numToDelete, "toDelete"); + + ListResult<AssetInfo> currentAssets = entityService.list(Asset.list()); + + for (String id : assetsToDelete) { + entityService.delete(Asset.delete(id)); + } + + ListResult<AssetInfo> afterDeleteAssets = entityService.list(Asset.list()); + + assertEquals(currentAssets.size() - numToDelete, afterDeleteAssets.size()); + + for (AssetInfo asset : afterDeleteAssets) { + assetsToDelete.remove(asset.getId()); + } + + assertEquals(numToDelete, assetsToDelete.size()); + } + + private Set<String> createTestAssets(int numAssets, String namePart) throws Exception { + Set<String> expectedAssets = new HashSet<String>(); + + for (int i = 0; i < numAssets; ++i) { + AssetInfo asset = entityService.create(Asset.create() + .name(testAssetPrefix + namePart + Integer.toString(i))); + expectedAssets.add(asset.getId()); + } + return expectedAssets; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java index 0dc2307e6befb..c09437f03f456 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java @@ -32,6 +32,10 @@ */ public class AssetEntityTest { static final String sampleAssetId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; + private final String expectedUri = String.format("Assets('%s')", URLEncoder.encode(sampleAssetId, "UTF-8")); + + public AssetEntityTest() throws Exception { + } @Test public void assetCreateReturnsDefaultCreatePayload() { @@ -99,8 +103,6 @@ public void assetListCanTakeQueryParameters() { @Test public void assetUpdateReturnsExpectedUri() throws Exception { EntityUpdateOperation updater = Asset.update(sampleAssetId); - String expectedUri = String.format("Assets('%s')", URLEncoder.encode(sampleAssetId, "UTF-8")); - assertEquals(expectedUri, updater.getUri()); } @@ -117,4 +119,12 @@ public void assetUpdateCanSetNameAndAltId() throws Exception { assertEquals(expectedName, payload.getName()); assertEquals(expectedAltId, payload.getAlternateId()); } + + @Test + public void assetDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = Asset.delete(sampleAssetId); + + assertEquals(expectedUri, deleter.getUri()); + } + } From 2b1e859fed61132736f6e04e7f955409fef47624 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 17:35:50 -0800 Subject: [PATCH 447/664] Refactored duplication around building uris for individual entities into a helper class. --- .../services/media/entities/Asset.java | 33 +----------- .../media/entities/EntityOperationBase.java | 51 +++++++++++++++++-- .../EntityOperationSingleResultBase.java | 5 ++ 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 409169c17556c..8d2420342900c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -103,23 +103,8 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { private static class GetterImpl extends EntityOperationSingleResultBase<AssetInfo> implements EntityGetOperation<AssetInfo> { - private final String assetId; - public GetterImpl(String assetId) { - super("Assets", AssetInfo.class); - this.assetId = assetId; - } - - @Override - public String getUri() { - String escapedEntityId; - try { - escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(assetId); - } - return String.format("%s('%s')", super.getUri(), escapedEntityId); + super(new EntityOperationBase.EntityIdUriBuilder("Assets", assetId), AssetInfo.class); } } @@ -173,25 +158,11 @@ public interface Updater extends EntityUpdateOperation { } private static class UpdaterImpl extends EntityOperationBase implements Updater { - private final String assetId; private String name; private String alternateId; protected UpdaterImpl(String assetId) { - super("Assets"); - this.assetId = assetId; - } - - @Override - public String getUri() { - String escapedEntityId; - try { - escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(assetId); - } - return String.format("%s('%s')", super.getUri(), escapedEntityId); + super(new EntityOperationBase.EntityIdUriBuilder("Assets", assetId)); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java index 9d463b4498a16..94beafff6aaad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java @@ -15,6 +15,10 @@ package com.microsoft.windowsazure.services.media.entities; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.InvalidParameterException; + import javax.ws.rs.core.MediaType; /** @@ -23,13 +27,22 @@ * */ public abstract class EntityOperationBase implements EntityOperation { - private final String uri; + private final EntityUriBuilder uriBuilder; /** * */ - protected EntityOperationBase(String uri) { - this.uri = uri; + protected EntityOperationBase(final String uri) { + this.uriBuilder = new EntityUriBuilder() { + @Override + public String getUri() { + return uri; + } + }; + } + + protected EntityOperationBase(EntityUriBuilder uriBuilder) { + this.uriBuilder = uriBuilder; } /* (non-Javadoc) @@ -37,7 +50,7 @@ protected EntityOperationBase(String uri) { */ @Override public String getUri() { - return uri; + return uriBuilder.getUri(); } /* (non-Javadoc) @@ -55,4 +68,34 @@ public MediaType getContentType() { public MediaType getAcceptType() { return MediaType.APPLICATION_ATOM_XML_TYPE; } + + public interface EntityUriBuilder { + String getUri(); + } + + public static class EntityIdUriBuilder implements EntityUriBuilder { + private final String entityType; + private final String entityId; + + public EntityIdUriBuilder(String entityName, String entityId) { + super(); + this.entityType = entityName; + this.entityId = entityId; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityOperationBase.EntityUriBuilder#getUri() + */ + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(entityId); + } + return String.format("%s('%s')", entityType, escapedEntityId); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java index f591982303da5..6913ad466296f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java @@ -30,6 +30,11 @@ public EntityOperationSingleResultBase(String uri, Class<T> responseClass) { this.responseClass = responseClass; } + public EntityOperationSingleResultBase(EntityOperationBase.EntityUriBuilder uriBuilder, Class<T> responseClass) { + super(uriBuilder); + this.responseClass = responseClass; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityOperationSingleResult#getResponseClass() */ From 2506db15ef80eded721118c5f180cc94382d9adb Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 17:51:46 -0800 Subject: [PATCH 448/664] Adding creation of access policies --- .../services/media/entities/AccessPolicy.java | 61 +++++++++++++++++++ .../entities/AccessPolicyEntityTest.java | 51 ++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java new file mode 100644 index 0000000000000..c51f0025f53c3 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -0,0 +1,61 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import java.util.EnumSet; + +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; + +/** + * + * + */ +public class AccessPolicy { + + private AccessPolicy() { + } + + public static EntityCreationOperation<AccessPolicyInfo> create(String name, double durationInMinutes, + EnumSet<AccessPolicyPermission> permissions) { + return new CreatorImpl(name, durationInMinutes, permissions); + } + + private static class CreatorImpl extends EntityOperationSingleResultBase<AccessPolicyInfo> implements + EntityCreationOperation<AccessPolicyInfo> { + private final String policyName; + private final double durationInMinutes; + private final EnumSet<AccessPolicyPermission> permissions; + + public CreatorImpl(String policyName, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { + + super("AccessPolicies", AccessPolicyInfo.class); + + this.policyName = policyName; + this.durationInMinutes = durationInMinutes; + this.permissions = permissions; + } + + @Override + public Object getRequestContents() { + return new AccessPolicyType().setName(policyName).setDurationInMinutes(durationInMinutes) + .setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); + } + + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java new file mode 100644 index 0000000000000..a42886c1726fe --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java @@ -0,0 +1,51 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import static org.junit.Assert.*; + +import java.util.EnumSet; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; + +/** + * Tests for access policy entity + * + */ +public class AccessPolicyEntityTest { + + @Test + public void createAccessPolicyProvidesExpectedPayload() throws Exception { + String name = "some Access Policy"; + double duration = 10; + EnumSet<AccessPolicyPermission> permissions = EnumSet.of(AccessPolicyPermission.READ, + AccessPolicyPermission.LIST); + + EntityCreationOperation<AccessPolicyInfo> creator = AccessPolicy.create(name, duration, permissions); + + AccessPolicyType payload = (AccessPolicyType) creator.getRequestContents(); + + assertEquals(name, payload.getName()); + assertEquals(duration, payload.getDurationInMinutes(), 0.0); + assertEquals(AccessPolicyPermission.bitsFromPermissions(permissions), payload.getPermissions()); + + } + +} From dbcacaa5c546618b9f59eb383fa0387a33d4f305 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 18:00:11 -0800 Subject: [PATCH 449/664] Getting access policies --- .../services/media/entities/AccessPolicy.java | 10 ++++++++++ .../media/entities/AccessPolicyEntityTest.java | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index c51f0025f53c3..fe8f88cbcb9ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -58,4 +58,14 @@ public Object getRequestContents() { } + public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { + return new GetterImpl(accessPolicyId); + } + + private static class GetterImpl extends EntityOperationSingleResultBase<AccessPolicyInfo> implements + EntityGetOperation<AccessPolicyInfo> { + public GetterImpl(String accessPolicyId) { + super(new EntityOperationBase.EntityIdUriBuilder("AccessPolicies", accessPolicyId), AccessPolicyInfo.class); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java index a42886c1726fe..c7d41158a844b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; +import java.net.URLEncoder; import java.util.EnumSet; import org.junit.Test; @@ -30,6 +31,12 @@ * */ public class AccessPolicyEntityTest { + private static final String examplePolicyId = "nb:pid:UUID:c577052a-6c0a-45b0-bf15-3ff3a2a41802"; + private final String expectedUri; + + public AccessPolicyEntityTest() throws Exception { + expectedUri = String.format("AccessPolicies('%s')", URLEncoder.encode(examplePolicyId, "UTF-8")); + } @Test public void createAccessPolicyProvidesExpectedPayload() throws Exception { @@ -45,7 +52,12 @@ public void createAccessPolicyProvidesExpectedPayload() throws Exception { assertEquals(name, payload.getName()); assertEquals(duration, payload.getDurationInMinutes(), 0.0); assertEquals(AccessPolicyPermission.bitsFromPermissions(permissions), payload.getPermissions()); - } + @Test + public void getReturnsExpectedUri() throws Exception { + EntityGetOperation<AccessPolicyInfo> getter = AccessPolicy.get(examplePolicyId); + + assertEquals(expectedUri, getter.getUri()); + } } From 2f4dfdccab238810caa21b8faa83e55eb2ff8aa7 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 18:05:22 -0800 Subject: [PATCH 450/664] Listing access policies --- .../services/media/entities/AccessPolicy.java | 44 +++++++++++++++++++ .../entities/AccessPolicyEntityTest.java | 23 ++++++++++ 2 files changed, 67 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index fe8f88cbcb9ef..94eb62baa17e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -17,9 +17,14 @@ import java.util.EnumSet; +import javax.ws.rs.core.MultivaluedMap; + import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * @@ -68,4 +73,43 @@ public GetterImpl(String accessPolicyId) { super(new EntityOperationBase.EntityIdUriBuilder("AccessPolicies", accessPolicyId), AccessPolicyInfo.class); } } + + public static EntityListOperation<AccessPolicyInfo> list() { + return new ListerImpl(); + } + + public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { + return new ListerImpl(queryParameters); + } + + private static class ListerImpl extends EntityOperationBase implements EntityListOperation<AccessPolicyInfo> { + private final MultivaluedMap<String, String> queryParameters; + + public ListerImpl() { + super("AccessPolicies"); + queryParameters = new MultivaluedMapImpl(); + } + + public ListerImpl(MultivaluedMap<String, String> queryParameters) { + this(); + this.queryParameters.putAll(queryParameters); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() + */ + @Override + public MultivaluedMap<String, String> getQueryParameters() { + return queryParameters; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getResponseGenericType() + */ + @Override + public GenericType<ListResult<AccessPolicyInfo>> getResponseGenericType() { + return new GenericType<ListResult<AccessPolicyInfo>>() { + }; + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java index c7d41158a844b..7dbc28928416f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java @@ -20,11 +20,14 @@ import java.net.URLEncoder; import java.util.EnumSet; +import javax.ws.rs.core.MultivaluedMap; + import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for access policy entity @@ -60,4 +63,24 @@ public void getReturnsExpectedUri() throws Exception { assertEquals(expectedUri, getter.getUri()); } + + @Test + public void listReturnsExpectedUri() throws Exception { + EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list(); + + assertEquals("AccessPolicies", lister.getUri()); + } + + @Test + public void listWithQueryParametersReturnsThem() throws Exception { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } } From 1f6aef83ac357b5eadef3a8b28829b97d1f75a46 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 18:08:42 -0800 Subject: [PATCH 451/664] Deleting Access Policies --- .../services/media/entities/AccessPolicy.java | 27 +++++++++++++++++++ .../entities/AccessPolicyEntityTest.java | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index 94eb62baa17e4..f1d0006535621 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -15,6 +15,9 @@ package com.microsoft.windowsazure.services.media.entities; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.InvalidParameterException; import java.util.EnumSet; import javax.ws.rs.core.MultivaluedMap; @@ -112,4 +115,28 @@ public GenericType<ListResult<AccessPolicyInfo>> getResponseGenericType() { }; } } + + public static EntityDeleteOperation delete(String accessPolicyId) { + return new DeleteImpl(accessPolicyId); + } + + private static class DeleteImpl implements EntityDeleteOperation { + private final String accessPolicyId; + + public DeleteImpl(String id) { + this.accessPolicyId = id; + } + + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(accessPolicyId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(accessPolicyId); + } + return String.format("%s('%s')", "AccessPolicies", escapedEntityId); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java index 7dbc28928416f..92cf0c967600d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java @@ -83,4 +83,9 @@ public void listWithQueryParametersReturnsThem() throws Exception { assertEquals("2", lister.getQueryParameters().getFirst("$skip")); assertEquals(2, lister.getQueryParameters().size()); } + + @Test + public void deleteReturnsExpectedUri() throws Exception { + assertEquals(expectedUri, AccessPolicy.delete(examplePolicyId).getUri()); + } } From 3c1239257cc1d54d30a85e26e6719f50db46dcf8 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 18:13:02 -0800 Subject: [PATCH 452/664] Common getter implementation --- .../services/media/entities/AccessPolicy.java | 9 +----- .../services/media/entities/Asset.java | 10 +----- .../entities/DefaultGetterOperation.java | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index f1d0006535621..64869de6e82f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -67,14 +67,7 @@ public Object getRequestContents() { } public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { - return new GetterImpl(accessPolicyId); - } - - private static class GetterImpl extends EntityOperationSingleResultBase<AccessPolicyInfo> implements - EntityGetOperation<AccessPolicyInfo> { - public GetterImpl(String accessPolicyId) { - super(new EntityOperationBase.EntityIdUriBuilder("AccessPolicies", accessPolicyId), AccessPolicyInfo.class); - } + return new DefaultGetterOperation<AccessPolicyInfo>("AccessPolicies", accessPolicyId, AccessPolicyInfo.class); } public static EntityListOperation<AccessPolicyInfo> list() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 8d2420342900c..aa8223bfaed43 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -97,15 +97,7 @@ public Creator alternateId(String alternateId) { } public static EntityGetOperation<AssetInfo> get(String assetId) { - return new GetterImpl(assetId); - } - - private static class GetterImpl extends EntityOperationSingleResultBase<AssetInfo> implements - EntityGetOperation<AssetInfo> { - - public GetterImpl(String assetId) { - super(new EntityOperationBase.EntityIdUriBuilder("Assets", assetId), AssetInfo.class); - } + return new DefaultGetterOperation<AssetInfo>("Assets", assetId, AssetInfo.class); } public static EntityListOperation<AssetInfo> list() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java new file mode 100644 index 0000000000000..64cc5db84aabe --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +/** + * Generic implementation of the get operation usable for most entities + * + */ +public class DefaultGetterOperation<T> extends EntityOperationSingleResultBase<T> implements EntityGetOperation<T> { + + /** + * @param uri + * @param responseClass + */ + public DefaultGetterOperation(String entityTypeUri, String entityId, Class<T> responseClass) { + super(new EntityOperationBase.EntityIdUriBuilder(entityTypeUri, entityId), responseClass); + } +} From cdc8bf7aa44d1d56ea9cbd6b62553399afbdd0fd Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 18:28:00 -0800 Subject: [PATCH 453/664] Added default list and delete operation implementations --- .../services/media/entities/AccessPolicy.java | 65 ++---------------- .../services/media/entities/Asset.java | 66 ++----------------- .../entities/DefaultDeleteOperation.java | 39 +++++++++++ .../media/entities/DefaultListOperation.java | 59 +++++++++++++++++ 4 files changed, 111 insertions(+), 118 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index 64869de6e82f4..fd5a8d633874d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -15,9 +15,6 @@ package com.microsoft.windowsazure.services.media.entities; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.security.InvalidParameterException; import java.util.EnumSet; import javax.ws.rs.core.MultivaluedMap; @@ -27,7 +24,6 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * @@ -71,65 +67,18 @@ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { } public static EntityListOperation<AccessPolicyInfo> list() { - return new ListerImpl(); + return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", + new GenericType<ListResult<AccessPolicyInfo>>() { + }); } public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { - return new ListerImpl(queryParameters); - } - - private static class ListerImpl extends EntityOperationBase implements EntityListOperation<AccessPolicyInfo> { - private final MultivaluedMap<String, String> queryParameters; - - public ListerImpl() { - super("AccessPolicies"); - queryParameters = new MultivaluedMapImpl(); - } - - public ListerImpl(MultivaluedMap<String, String> queryParameters) { - this(); - this.queryParameters.putAll(queryParameters); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() - */ - @Override - public MultivaluedMap<String, String> getQueryParameters() { - return queryParameters; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getResponseGenericType() - */ - @Override - public GenericType<ListResult<AccessPolicyInfo>> getResponseGenericType() { - return new GenericType<ListResult<AccessPolicyInfo>>() { - }; - } + return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", + new GenericType<ListResult<AccessPolicyInfo>>() { + }, queryParameters); } public static EntityDeleteOperation delete(String accessPolicyId) { - return new DeleteImpl(accessPolicyId); - } - - private static class DeleteImpl implements EntityDeleteOperation { - private final String accessPolicyId; - - public DeleteImpl(String id) { - this.accessPolicyId = id; - } - - @Override - public String getUri() { - String escapedEntityId; - try { - escapedEntityId = URLEncoder.encode(accessPolicyId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(accessPolicyId); - } - return String.format("%s('%s')", "AccessPolicies", escapedEntityId); - } + return new DefaultDeleteOperation("AccessPolicies", accessPolicyId); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index aa8223bfaed43..8de30341ef7e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -15,17 +15,12 @@ package com.microsoft.windowsazure.services.media.entities; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.security.InvalidParameterException; - import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * @@ -101,42 +96,13 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { } public static EntityListOperation<AssetInfo> list() { - return new ListerImpl(); + return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { + }); } public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { - return new ListerImpl(queryParameters); - } - - private static class ListerImpl extends EntityOperationBase implements EntityListOperation<AssetInfo> { - private final MultivaluedMap<String, String> queryParameters; - - public ListerImpl() { - super("Assets"); - queryParameters = new MultivaluedMapImpl(); - } - - public ListerImpl(MultivaluedMap<String, String> queryParameters) { - this(); - this.queryParameters.putAll(queryParameters); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() - */ - @Override - public MultivaluedMap<String, String> getQueryParameters() { - return queryParameters; - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getResponseGenericType() - */ - @Override - public GenericType<ListResult<AssetInfo>> getResponseGenericType() { - return new GenericType<ListResult<AssetInfo>>() { - }; - } + return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { + }, queryParameters); } public static Updater update(String assetId) { @@ -178,27 +144,7 @@ public Updater alternateId(String alternateId) { } } - public static EntityDeleteOperation delete(String id) { - return new DeleteImpl(id); - } - - private static class DeleteImpl implements EntityDeleteOperation { - private final String assetId; - - public DeleteImpl(String id) { - this.assetId = id; - } - - @Override - public String getUri() { - String escapedEntityId; - try { - escapedEntityId = URLEncoder.encode(assetId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(assetId); - } - return String.format("%s('%s')", "Assets", escapedEntityId); - } + public static EntityDeleteOperation delete(String assetId) { + return new DefaultDeleteOperation("Assets", assetId); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java new file mode 100644 index 0000000000000..fc7d23be2ce5d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +/** + * Generic implementation of Delete operation usable by most entities + * + */ +public class DefaultDeleteOperation implements EntityDeleteOperation { + private final EntityOperationBase.EntityUriBuilder uriBuilder; + + /** + * + */ + public DefaultDeleteOperation(String entityUri, String entityId) { + uriBuilder = new EntityOperationBase.EntityIdUriBuilder(entityUri, entityId); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation#getUri() + */ + @Override + public String getUri() { + return uriBuilder.getUri(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java new file mode 100644 index 0000000000000..ebd8732e605f8 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java @@ -0,0 +1,59 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.sun.jersey.api.client.GenericType; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Generic implementation of the list operation, usable by most entities + * + */ +public class DefaultListOperation<T> extends EntityOperationBase implements EntityListOperation<T> { + private final MultivaluedMap<String, String> queryParameters; + private final GenericType<ListResult<T>> responseType; + + public DefaultListOperation(String entityUri, GenericType<ListResult<T>> responseType) { + super(entityUri); + queryParameters = new MultivaluedMapImpl(); + this.responseType = responseType; + } + + public DefaultListOperation(String entityUri, GenericType<ListResult<T>> responseType, + MultivaluedMap<String, String> queryParameters) { + this(entityUri, responseType); + this.queryParameters.putAll(queryParameters); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() + */ + @Override + public MultivaluedMap<String, String> getQueryParameters() { + return queryParameters; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getResponseGenericType() + */ + @Override + public GenericType<ListResult<T>> getResponseGenericType() { + return responseType; + } +} From a16e25dd6c1124347b17b0ba7491fc6b9e46470a Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 21:36:07 -0800 Subject: [PATCH 454/664] Adding Locator entity --- .../services/media/entities/Locator.java | 151 ++++++++++++++++++ .../media/entities/LocatorEntityTest.java | 140 ++++++++++++++++ 2 files changed, 291 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java new file mode 100644 index 0000000000000..a46b2bd33e55c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java @@ -0,0 +1,151 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import java.util.Date; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.sun.jersey.api.client.GenericType; + +/** + * Implementation of Locator entity + * + */ +public class Locator { + + private final static String ENTITY_SET = "Locators"; + + private Locator() { + } + + public static Creator create(String accessPolicyId, String assetId, LocatorType locatorType) { + return new CreatorImpl(accessPolicyId, assetId, locatorType); + } + + public interface Creator extends EntityCreationOperation<LocatorInfo> { + /** + * Set the date and time for when the locator starts to be available + * + * @param startDateTime + * The date/time + * @return The creator instance (for function chaining) + */ + Creator startDateTime(Date startDateTime); + + /** + * Set the date and time at which the locator will expire + * + * @param expirationDateTime + * Expiration date and time + * @return The creator instance (for function chaining) + */ + Creator expirationDateTime(Date expirationDateTime); + } + + private static class CreatorImpl extends EntityOperationSingleResultBase<LocatorInfo> implements Creator { + private final String accessPolicyId; + private final String assetId; + private final LocatorType locatorType; + private Date startDateTime; + private Date expirationDateTime; + + protected CreatorImpl(String accessPolicyId, String assetId, LocatorType locatorType) { + super(ENTITY_SET, LocatorInfo.class); + this.accessPolicyId = accessPolicyId; + this.assetId = assetId; + this.locatorType = locatorType; + } + + @Override + public Object getRequestContents() { + return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId) + .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) + .setType(locatorType.getCode()); + } + + @Override + public Creator startDateTime(Date startDateTime) { + this.startDateTime = startDateTime; + return this; + } + + @Override + public Creator expirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + } + + public static EntityGetOperation<LocatorInfo> get(String locatorId) { + return new DefaultGetterOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); + } + + public static EntityListOperation<LocatorInfo> list() { + return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { + }); + } + + public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { + }, queryParameters); + } + + public static Updater update(String locatorId) { + return new UpdaterImpl(locatorId); + } + + public interface Updater extends EntityUpdateOperation { + Updater startDateTime(Date startDateTime); + + Updater expirationDateTime(Date expirationDateTime); + } + + private static class UpdaterImpl extends EntityOperationBase implements Updater { + private Date startDateTime; + private Date expirationDateTime; + + public UpdaterImpl(String locatorId) { + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId)); + } + + @Override + public Object getRequestContents() { + return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); + } + + @Override + public Updater startDateTime(Date startDateTime) { + this.startDateTime = startDateTime; + return this; + } + + @Override + public Updater expirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + } + + public static EntityDeleteOperation delete(String locatorId) { + return new DefaultDeleteOperation(ENTITY_SET, locatorId); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java new file mode 100644 index 0000000000000..3eaf8ee6bb84c --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java @@ -0,0 +1,140 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import static org.junit.Assert.*; + +import java.net.URLEncoder; +import java.util.Date; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the Locator entity + * + */ +public class LocatorEntityTest { + private final String exampleAssetId = "nb:cid:UUID:61a5ebbe-d5e0-49a5-b28c-e9535321b6cd"; + private final String exampleAccessPolicyId = "nb:pid:UUID:c82307be-1a81-4554-ba7d-cf6dfa735a5a"; + private final String exampleLocatorId = "nb:lid:UUID:f282b0a1-fb21-4b83-87d6-d4c96d77aef9"; + private final String expectedLocatorUri = String.format("Locators('%s')", + URLEncoder.encode(exampleLocatorId, "UTF-8")); + + public LocatorEntityTest() throws Exception { + + } + + @Test + public void createLocatorHasCorrectUrl() throws Exception { + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS); + + assertEquals("Locators", creator.getUri()); + } + + @Test + public void createLocatorHasCorrectPayload() throws Exception { + LocatorRestType locatorType = (LocatorRestType) Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).getRequestContents(); + + assertEquals(exampleAssetId, locatorType.getAssetId()); + assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertNull(locatorType.getStartTime()); + assertNull(locatorType.getExpirationDateTime()); + } + + @Test + public void createLocatorCanSetTimes() throws Exception { + Date now = new Date(); + Date tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000); + + EntityCreationOperation<LocatorInfo> creator = Locator + .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).startDateTime(now) + .expirationDateTime(tomorrow); + + LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); + + assertEquals(exampleAssetId, locatorType.getAssetId()); + assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertEquals(now, locatorType.getStartTime()); + assertEquals(tomorrow, locatorType.getExpirationDateTime()); + } + + @Test + public void getLocatorGivesExpectedUri() throws Exception { + assertEquals(expectedLocatorUri, Locator.get(exampleLocatorId).getUri()); + } + + @Test + public void listLocatorReturnsExpectedUri() { + EntityListOperation<LocatorInfo> lister = Locator.list(); + + assertEquals("Locators", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void listLocatorCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<LocatorInfo> lister = Locator.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void locatorUpdateReturnsExpectedUri() throws Exception { + EntityUpdateOperation updater = Locator.update(exampleLocatorId); + assertEquals(expectedLocatorUri, updater.getUri()); + } + + @Test + public void locatorUpdateCanStartAndExpirationTime() throws Exception { + Date now = new Date(); + + Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); + Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); + + EntityUpdateOperation updater = Locator.update(exampleLocatorId).startDateTime(tenMinutesAgo) + .expirationDateTime(twoHoursFromNow); + + LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); + + assertEquals(tenMinutesAgo, payload.getStartTime()); + assertEquals(twoHoursFromNow, payload.getExpirationDateTime()); + } + + @Test + public void locatorDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = Locator.delete(exampleLocatorId); + + assertEquals(expectedLocatorUri, deleter.getUri()); + } +} From 4ae410dd8c64c91b069e6648f967eb5f72dfb96c Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 21:45:53 -0800 Subject: [PATCH 455/664] Implemented media processor entity --- .../media/entities/MediaProcessor.java | 46 +++++++++++++++++ .../entities/MediaProcessorEntityTest.java | 51 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java new file mode 100644 index 0000000000000..3a853d6e904b5 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java @@ -0,0 +1,46 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.sun.jersey.api.client.GenericType; + +/** + * Entity operations for Media processors + * + */ +public class MediaProcessor { + + private static final String ENTITY_SET = "MediaProcessors"; + + private MediaProcessor() { + } + + public static EntityListOperation<MediaProcessorInfo> list() { + return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, + new GenericType<ListResult<MediaProcessorInfo>>() { + }); + } + + public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, + new GenericType<ListResult<MediaProcessorInfo>>() { + }, queryParameters); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java new file mode 100644 index 0000000000000..aa6d8c03689bb --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java @@ -0,0 +1,51 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.entities; + +import static org.junit.Assert.*; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the MediaProcessor entity + * + */ +public class MediaProcessorEntityTest { + + @Test + public void listMediaProcessorsReturnsExpectedUri() { + assertEquals("MediaProcessors", MediaProcessor.list().getUri()); + } + + @Test + public void listMediaProcessorsCanTakeQueryParmeters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + +} From f0fc09db93e8fc5e533306257f3fd68a3fed1ba3 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 22:26:53 -0800 Subject: [PATCH 456/664] Filling out javadocs --- .../services/media/entities/AccessPolicy.java | 39 ++++++++++- .../services/media/entities/Asset.java | 56 ++++++++++++++++ .../services/media/entities/Locator.java | 67 ++++++++++++++++++- .../media/entities/MediaProcessor.java | 12 ++++ 4 files changed, 172 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index fd5a8d633874d..325700712e7fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -26,14 +26,25 @@ import com.sun.jersey.api.client.GenericType; /** + * Class for creating operations to manipulate Access Policy entities. * - * */ public class AccessPolicy { private AccessPolicy() { } + /** + * Creates an operation to create a new access policy + * + * @param name + * name of the access policy + * @param durationInMinutes + * how long the access policy will be in force + * @param permissions + * permissions allowed by this access policy + * @return The operation + */ public static EntityCreationOperation<AccessPolicyInfo> create(String name, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { return new CreatorImpl(name, durationInMinutes, permissions); @@ -62,22 +73,48 @@ public Object getRequestContents() { } + /** + * Create an operation that will retrieve the given access policy + * + * @param accessPolicyId + * id of access policy to retrieve + * @return the operation + */ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { return new DefaultGetterOperation<AccessPolicyInfo>("AccessPolicies", accessPolicyId, AccessPolicyInfo.class); } + /** + * Create an operation that will retrieve all access policies + * + * @return the operation + */ public static EntityListOperation<AccessPolicyInfo> list() { return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", new GenericType<ListResult<AccessPolicyInfo>>() { }); } + /** + * Create an operation that will retrieve all access policies that match the given query parameters + * + * @param queryParameters + * query parameters to add to the request + * @return the operation + */ public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", new GenericType<ListResult<AccessPolicyInfo>>() { }, queryParameters); } + /** + * Create an operation to delete the given access policy + * + * @param accessPolicyId + * id of access policy to delete + * @return the delete operation + */ public static EntityDeleteOperation delete(String accessPolicyId) { return new DefaultDeleteOperation("AccessPolicies", accessPolicyId); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index 8de30341ef7e4..b3bc3a2b6e30a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -23,6 +23,7 @@ import com.sun.jersey.api.client.GenericType; /** + * Class for creating operations to manipulate Asset entities. * */ public class Asset { @@ -35,6 +36,10 @@ public static Creator create() { return new CreatorImpl(); } + /** + * Interface defining optional fields that can be set at asset creation. + * + */ public interface Creator extends EntityCreationOperation<AssetInfo> { /** * Set the name of the asset to be created @@ -91,27 +96,71 @@ public Creator alternateId(String alternateId) { } } + /** + * Create an operation object that will get the state of the given asset. + * + * @param assetId + * id of asset to retrieve + * @return the get operation + */ public static EntityGetOperation<AssetInfo> get(String assetId) { return new DefaultGetterOperation<AssetInfo>("Assets", assetId, AssetInfo.class); } + /** + * Create an operation that will list all the assets. + * + * @return The list operation + */ public static EntityListOperation<AssetInfo> list() { return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { }); } + /** + * Create an operation that will list all the assets which match the given query parameters + * + * @param queryParameters + * query parameters to pass to the server. + * @return the list operation. + */ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { }, queryParameters); } + /** + * Create an operation that will update the given asset + * + * @param assetId + * id of the asset to update + * @return the update operation + */ public static Updater update(String assetId) { return new UpdaterImpl(assetId); } + /** + * Interface defining which fields can be updated after asset creation + * + */ public interface Updater extends EntityUpdateOperation { + /** + * Sets new name for asset + * + * @param name + * The new name + * @return Updater instance + */ Updater name(String name); + /** + * Sets new alternate id for asset + * + * @param alternateId + * the new alternate id + * @return Updater instance + */ Updater alternateId(String alternateId); } @@ -144,6 +193,13 @@ public Updater alternateId(String alternateId) { } } + /** + * Create an operation to delete the given asset + * + * @param assetId + * id of asset to delete + * @return the delete operation + */ public static EntityDeleteOperation delete(String assetId) { return new DefaultDeleteOperation("Assets", assetId); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java index a46b2bd33e55c..b1c6787179aff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.microsoft.windowsazure.services.media.entities; import java.util.Date; @@ -36,10 +35,25 @@ public class Locator { private Locator() { } + /** + * Create an operation to create a new locator entity + * + * @param accessPolicyId + * id of access policy for locator + * @param assetId + * id of asset for locator + * @param locatorType + * locator type + * @return the operation + */ public static Creator create(String accessPolicyId, String assetId, LocatorType locatorType) { return new CreatorImpl(accessPolicyId, assetId, locatorType); } + /** + * Interface defining optional parameters that can get set when creating a locator + * + */ public interface Creator extends EntityCreationOperation<LocatorInfo> { /** * Set the date and time for when the locator starts to be available @@ -94,27 +108,71 @@ public Creator expirationDateTime(Date expirationDateTime) { } } + /** + * Create an operation to get the given locator + * + * @param locatorId + * id of locator to retrieve + * @return the get operation + */ public static EntityGetOperation<LocatorInfo> get(String locatorId) { return new DefaultGetterOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); } + /** + * Create an operation to list all locators + * + * @return the list operation + */ public static EntityListOperation<LocatorInfo> list() { return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { }); } + /** + * Create an operation to list all locators matching the given query parameters + * + * @param queryParameters + * query parameters to send with the request + * @return the list operation + */ public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { }, queryParameters); } + /** + * Create an operation to update the given locator + * + * @param locatorId + * id of locator to update + * @return the update operation + */ public static Updater update(String locatorId) { return new UpdaterImpl(locatorId); } + /** + * Interface defining fields that can be updated after locator has been created. + * + */ public interface Updater extends EntityUpdateOperation { + /** + * Set when the locator will become available + * + * @param startDateTime + * the date & time + * @return Updater instance + */ Updater startDateTime(Date startDateTime); + /** + * Set when the locator will expire + * + * @param expirationDateTime + * the expiration date & time + * @return Updater instance + */ Updater expirationDateTime(Date expirationDateTime); } @@ -145,6 +203,13 @@ public Updater expirationDateTime(Date expirationDateTime) { } + /** + * Create an operation to delete the given locator + * + * @param locatorId + * id of locator to delete + * @return the operation + */ public static EntityDeleteOperation delete(String locatorId) { return new DefaultDeleteOperation(ENTITY_SET, locatorId); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java index 3a853d6e904b5..cdf49a1b3e7f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java @@ -32,12 +32,24 @@ public class MediaProcessor { private MediaProcessor() { } + /** + * Create an operation to list all Media processors + * + * @return the list operation + */ public static EntityListOperation<MediaProcessorInfo> list() { return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, new GenericType<ListResult<MediaProcessorInfo>>() { }); } + /** + * Create an operation to list all media processors that satisfy the given query parameters + * + * @param queryParameters + * query parameters to pass with the request + * @return the list operation + */ public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, new GenericType<ListResult<MediaProcessorInfo>>() { From 007f1ef05a7be4d65240be63776bdce72b700ed3 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 5 Nov 2012 22:31:18 -0800 Subject: [PATCH 457/664] Updating comments --- .../windowsazure/services/media/MediaEntityContract.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index ca7d61984f736..de3937e5a891f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -63,7 +63,7 @@ public interface MediaEntityContract extends FilterableService<MediaEntityContra <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; /** - * Update an existing asset + * Update an existing entity * * @param updater * Object providing details of the update @@ -72,7 +72,7 @@ public interface MediaEntityContract extends FilterableService<MediaEntityContra void update(EntityUpdateOperation updater) throws ServiceException; /** - * Delete an asset + * Delete an entity * * @param deleter * Object providing details of the delete From bffb8ea39fd16eb9c4ba39b7a624389f4e5b657d Mon Sep 17 00:00:00 2001 From: "Justin Yu (Microsoft)" <justinyu@microsoft.com> Date: Tue, 6 Nov 2012 11:15:38 -0800 Subject: [PATCH 458/664] Add SendingRequestEvent in jxscl. --- .../core/storage/OperationContext.java | 25 ++++++++ .../core/storage/SendingRequestEvent.java | 63 +++++++++++++++++++ .../utils/implementation/ExecutionEngine.java | 10 +++ .../blob/client/CloudBlobContainerTests.java | 46 ++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 59106461ea272..9d6ce173b063f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -53,6 +53,15 @@ public final class OperationContext { */ private ArrayList<RequestResult> requestResults; + /** + * Represents an event that is triggered before sending a request. + * + * @see StorageEvent + * @see StorageEventMultiCaster + * @see SendingRequestEvent + */ + private StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> sendingRequestEventHandler = new StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>>(); + /** * Represents an event that is triggered when a response is received from the storage service while processing a * request. @@ -156,6 +165,13 @@ public ArrayList<RequestResult> getRequestResults() { return this.requestResults; } + /** + * @return the SendingRequestEvent + */ + public StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> getSendingRequestEventHandler() { + return this.sendingRequestEventHandler; + } + /** * @return the responseReceivedEventHandler */ @@ -218,6 +234,15 @@ private void setLogger(final Logger logger) { this.logger = logger; } + /** + * @param sendingRequestEventHandler + * the sendingRequestEventHandler to set + */ + public void setSendingRequestEventHandler( + final StorageEventMultiCaster<SendingRequestEvent, StorageEvent<SendingRequestEvent>> sendingRequestEventHandler) { + this.sendingRequestEventHandler = sendingRequestEventHandler; + } + /** * @param responseReceivedEventHandler * the responseReceivedEventHandler to set diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java new file mode 100644 index 0000000000000..94efc9555634f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java @@ -0,0 +1,63 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.core.storage; + +/** + * Represents an event that is fired when before sending a request. + */ +public final class SendingRequestEvent { + + /** + * Represents a connection object. Currently only <code>java.net.HttpURLConnection</code> is supported as a + * connection object. + */ + private final Object connectionObject; + + /** + * Represents a context for the current operation. This object is used to track requests to the storage service, and + * to provide additional runtime information about the operation. + */ + private final OperationContext opContext; + + /** + * Creates an instance of the <code>SendingRequestEvent</code> class. + * + * @param opContext + * An {@link OperationContext} object that represents the context for the current operation. This object + * is used to track requests to the storage service, and to provide additional runtime information about + * the operation. + * @param connectionObject + * Represents a connection object. Currently only <code>java.net.HttpURLConnection</code> is supported as + * a connection object. + */ + public SendingRequestEvent(final OperationContext opContext, final Object connectionObject) { + this.opContext = opContext; + this.connectionObject = connectionObject; + } + + /** + * @return the connectionObject + */ + public Object getConnectionObject() { + return this.connectionObject; + } + + /** + * @return the opContext + */ + public OperationContext getOpContext() { + return this.opContext; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index e30d5f1e45440..fd9ea785cffc5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -33,6 +33,7 @@ import com.microsoft.windowsazure.services.core.storage.RetryPolicy; import com.microsoft.windowsazure.services.core.storage.RetryPolicyFactory; import com.microsoft.windowsazure.services.core.storage.RetryResult; +import com.microsoft.windowsazure.services.core.storage.SendingRequestEvent; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; import com.microsoft.windowsazure.services.core.storage.StorageException; import com.microsoft.windowsazure.services.table.client.TableServiceException; @@ -223,6 +224,11 @@ public static InputStream getInputStream(final HttpURLConnection request, final opContext.setCurrentRequestObject(request); currResult.setStartDate(new Date()); opContext.getRequestResults().add(currResult); + + if (opContext.getSendingRequestEventHandler().hasListeners()) { + opContext.getSendingRequestEventHandler().fireEvent(new SendingRequestEvent(opContext, request)); + } + try { return request.getInputStream(); } @@ -295,6 +301,10 @@ public static RequestResult processRequest(final HttpURLConnection request, fina opContext.getRequestResults().add(currResult); opContext.setCurrentRequestObject(request); + if (opContext.getSendingRequestEventHandler().hasListeners()) { + opContext.getSendingRequestEventHandler().fireEvent(new SendingRequestEvent(opContext, request)); + } + // Send the request currResult.setStatusCode(request.getResponseCode()); currResult.setStatusMessage(request.getResponseMessage()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index d7602c93d75bc..658e878eb9cf9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -38,8 +38,10 @@ import com.microsoft.windowsazure.services.core.storage.AccessCondition; import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.SendingRequestEvent; import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; +import com.microsoft.windowsazure.services.core.storage.StorageEvent; import com.microsoft.windowsazure.services.core.storage.StorageException; /** @@ -671,4 +673,48 @@ public void testListContainersTest() throws StorageException, URISyntaxException null); } } + + @Test + public void testSendingRequestEventBlob() throws StorageException, URISyntaxException, IOException, + InterruptedException { + String name = generateRandomContainerName(); + CloudBlobContainer newContainer = bClient.getContainerReference(name); + newContainer.create(); + + final ArrayList<Boolean> callList = new ArrayList<Boolean>(); + OperationContext sendingRequestEventContext = new OperationContext(); + sendingRequestEventContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { + + @Override + public void eventOccurred(SendingRequestEvent eventArg) { + callList.add(true); + } + }); + + try { + Assert.assertEquals(0, callList.size()); + + //Put blob + CloudBlob blob = newContainer.getBlockBlobReference("newblob"); + blob.upload(new ByteArrayInputStream(testData), testData.length, null, null, sendingRequestEventContext); + Assert.assertEquals(1, callList.size()); + + //Get blob + blob.download(new ByteArrayOutputStream(), null, null, sendingRequestEventContext); + Assert.assertEquals(2, callList.size()); + + //uploadMetadata + blob.uploadMetadata(null, null, sendingRequestEventContext); + Assert.assertEquals(3, callList.size()); + + //uploadMetadata + blob.downloadAttributes(null, null, sendingRequestEventContext); + Assert.assertEquals(4, callList.size()); + + } + finally { + // cleanup + newContainer.deleteIfExists(); + } + } } From 368210530a7eacd2406d9610fcfa517bd2609aba Mon Sep 17 00:00:00 2001 From: "Justin Yu (Microsoft)" <justinyu@microsoft.com> Date: Tue, 6 Nov 2012 11:29:01 -0800 Subject: [PATCH 459/664] Update the useragent to 0.1.3.1 --- .../microsoft/windowsazure/services/core/storage/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java index 58e4d2bc8beca..61895ba9a162b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -327,7 +327,7 @@ public static class HeaderConstants { /** * Specifies the value to use for UserAgent header. */ - public static final String USER_AGENT_VERSION = "Client v0.1.3"; + public static final String USER_AGENT_VERSION = "Client v0.1.3.1"; } /** From cc8d2d98719ab4570da802092ee5c72dce401d62 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 14:16:00 -0800 Subject: [PATCH 460/664] Removed unnecessary interfaces from Asset --- .../services/media/entities/Asset.java | 97 +++++++------------ 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java index b3bc3a2b6e30a..1cde764fd65d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java @@ -33,39 +33,15 @@ private Asset() { } public static Creator create() { - return new CreatorImpl(); + return new Creator(); } - /** - * Interface defining optional fields that can be set at asset creation. - * - */ - public interface Creator extends EntityCreationOperation<AssetInfo> { - /** - * Set the name of the asset to be created - * - * @param name - * The name - * @return The creator object (for call chaining) - */ - Creator name(String name); - - /** - * Sets the alternate id of the asset to be created. - * - * @param alternateId - * The id - * - * @return The creator object (for call chaining) - */ - Creator alternateId(String alternateId); - } - - private static class CreatorImpl extends EntityOperationSingleResultBase<AssetInfo> implements Creator { + public static class Creator extends EntityOperationSingleResultBase<AssetInfo> implements + EntityCreationOperation<AssetInfo> { private String name; private String alternateId; - public CreatorImpl() { + public Creator() { super("Assets", AssetInfo.class); } @@ -77,19 +53,26 @@ public Object getRequestContents() { return assetType; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.Asset.Creator#name(java.lang.String) + /** + * Set the name of the asset to be created + * + * @param name + * The name + * @return The creator object (for call chaining) */ - @Override public Creator name(String name) { this.name = name; return this; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.entities.Asset.Creator#alternateId(java.lang.String) + /** + * Sets the alternate id of the asset to be created. + * + * @param alternateId + * The id + * + * @return The creator object (for call chaining) */ - @Override public Creator alternateId(String alternateId) { this.alternateId = alternateId; return this; @@ -137,38 +120,14 @@ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> * @return the update operation */ public static Updater update(String assetId) { - return new UpdaterImpl(assetId); + return new Updater(assetId); } - /** - * Interface defining which fields can be updated after asset creation - * - */ - public interface Updater extends EntityUpdateOperation { - /** - * Sets new name for asset - * - * @param name - * The new name - * @return Updater instance - */ - Updater name(String name); - - /** - * Sets new alternate id for asset - * - * @param alternateId - * the new alternate id - * @return Updater instance - */ - Updater alternateId(String alternateId); - } - - private static class UpdaterImpl extends EntityOperationBase implements Updater { + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { private String name; private String alternateId; - protected UpdaterImpl(String assetId) { + protected Updater(String assetId) { super(new EntityOperationBase.EntityIdUriBuilder("Assets", assetId)); } @@ -180,13 +139,25 @@ public Object getRequestContents() { return assetType; } - @Override + /** + * Sets new name for asset + * + * @param name + * The new name + * @return Updater instance + */ public Updater name(String name) { this.name = name; return this; } - @Override + /** + * Sets new alternate id for asset + * + * @param alternateId + * the new alternate id + * @return Updater instance + */ public Updater alternateId(String alternateId) { this.alternateId = alternateId; return this; From c37d4d37a04adad5a78982b1b0cade78259c05fa Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 14:20:20 -0800 Subject: [PATCH 461/664] Removing unnecessary interfaces from locator, tweaked name in access policy --- .../services/media/entities/AccessPolicy.java | 6 +- .../services/media/entities/Locator.java | 93 +++++++------------ 2 files changed, 38 insertions(+), 61 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java index 325700712e7fd..ce4a1de23c626 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java @@ -47,16 +47,16 @@ private AccessPolicy() { */ public static EntityCreationOperation<AccessPolicyInfo> create(String name, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { - return new CreatorImpl(name, durationInMinutes, permissions); + return new Creator(name, durationInMinutes, permissions); } - private static class CreatorImpl extends EntityOperationSingleResultBase<AccessPolicyInfo> implements + private static class Creator extends EntityOperationSingleResultBase<AccessPolicyInfo> implements EntityCreationOperation<AccessPolicyInfo> { private final String policyName; private final double durationInMinutes; private final EnumSet<AccessPolicyPermission> permissions; - public CreatorImpl(String policyName, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { + public Creator(String policyName, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { super("AccessPolicies", AccessPolicyInfo.class); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java index b1c6787179aff..a774d1610b8bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java @@ -47,41 +47,18 @@ private Locator() { * @return the operation */ public static Creator create(String accessPolicyId, String assetId, LocatorType locatorType) { - return new CreatorImpl(accessPolicyId, assetId, locatorType); + return new Creator(accessPolicyId, assetId, locatorType); } - /** - * Interface defining optional parameters that can get set when creating a locator - * - */ - public interface Creator extends EntityCreationOperation<LocatorInfo> { - /** - * Set the date and time for when the locator starts to be available - * - * @param startDateTime - * The date/time - * @return The creator instance (for function chaining) - */ - Creator startDateTime(Date startDateTime); - - /** - * Set the date and time at which the locator will expire - * - * @param expirationDateTime - * Expiration date and time - * @return The creator instance (for function chaining) - */ - Creator expirationDateTime(Date expirationDateTime); - } - - private static class CreatorImpl extends EntityOperationSingleResultBase<LocatorInfo> implements Creator { + public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements + EntityCreationOperation<LocatorInfo> { private final String accessPolicyId; private final String assetId; private final LocatorType locatorType; private Date startDateTime; private Date expirationDateTime; - protected CreatorImpl(String accessPolicyId, String assetId, LocatorType locatorType) { + protected Creator(String accessPolicyId, String assetId, LocatorType locatorType) { super(ENTITY_SET, LocatorInfo.class); this.accessPolicyId = accessPolicyId; this.assetId = assetId; @@ -95,13 +72,25 @@ public Object getRequestContents() { .setType(locatorType.getCode()); } - @Override + /** + * Set the date and time for when the locator starts to be available + * + * @param startDateTime + * The date/time + * @return The creator instance (for function chaining) + */ public Creator startDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } - @Override + /** + * Set the date and time at which the locator will expire + * + * @param expirationDateTime + * Expiration date and time + * @return The creator instance (for function chaining) + */ public Creator expirationDateTime(Date expirationDateTime) { this.expirationDateTime = expirationDateTime; return this; @@ -149,38 +138,14 @@ public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, Strin * @return the update operation */ public static Updater update(String locatorId) { - return new UpdaterImpl(locatorId); + return new Updater(locatorId); } - /** - * Interface defining fields that can be updated after locator has been created. - * - */ - public interface Updater extends EntityUpdateOperation { - /** - * Set when the locator will become available - * - * @param startDateTime - * the date & time - * @return Updater instance - */ - Updater startDateTime(Date startDateTime); - - /** - * Set when the locator will expire - * - * @param expirationDateTime - * the expiration date & time - * @return Updater instance - */ - Updater expirationDateTime(Date expirationDateTime); - } - - private static class UpdaterImpl extends EntityOperationBase implements Updater { + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { private Date startDateTime; private Date expirationDateTime; - public UpdaterImpl(String locatorId) { + public Updater(String locatorId) { super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId)); } @@ -189,13 +154,25 @@ public Object getRequestContents() { return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); } - @Override + /** + * Set when the locator will become available + * + * @param startDateTime + * the date & time + * @return Updater instance + */ public Updater startDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } - @Override + /** + * Set when the locator will expire + * + * @param expirationDateTime + * the expiration date & time + * @return Updater instance + */ public Updater expirationDateTime(Date expirationDateTime) { this.expirationDateTime = expirationDateTime; return this; From e8fefe90f92ac4b1a54df905f1f027c47421a5c3 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 6 Nov 2012 15:25:34 -0800 Subject: [PATCH 462/664] Update for create Job and create Task operations --- .../implementation/CreateJobOperation.java | 27 +++++++--- .../implementation/CreateTaskOperation.java | 2 +- .../implementation/MediaBatchOperations.java | 3 +- .../media/implementation/MediaRestProxy.java | 5 +- .../media/implementation/Operation.java | 54 ++++++++++++++++++- .../media/implementation/atom/EntryType.java | 11 ---- .../services/media/models/AssetInfo.java | 14 ----- .../MediaBatchOperationsTest.java | 7 ++- 8 files changed, 83 insertions(+), 40 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java index 3e75e6ef5341a..ee900a8c4bded 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java @@ -15,19 +15,30 @@ package com.microsoft.windowsazure.services.media.implementation; -import com.microsoft.windowsazure.services.media.implementation.content.JobType; +import java.net.URI; +import java.util.List; -public class CreateJobOperation implements Operation { +import com.microsoft.windowsazure.services.media.implementation.content.JobType; - private JobType jobType; +public class CreateJobOperation extends Operation { - public CreateJobOperation setJob(JobType jobType) { - this.jobType = jobType; - return this; + public CreateJobOperation() { + this.verb = "POST"; } - public JobType getJob() { - return this.jobType; + public CreateJobOperation setJob(List<URI> inputMediaAssets, List<URI> outputMediaAssets, JobType jobType) { + addContentObject(jobType); + for (URI inputMediaAsset : inputMediaAssets) { + addLink("InputMediaAssets", inputMediaAsset.toString(), "application/atom+xml;type=feed", + "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); + } + + for (URI outputMediaAsset : outputMediaAssets) { + addLink("OutputMediaAssets", outputMediaAsset.toString(), "application/atom+xml;type=feed", + "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); + } + + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java index 1a90a4e6f5f86..5a815bd90f95a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.TaskType; -public class CreateTaskOperation implements Operation { +public class CreateTaskOperation extends Operation { private TaskType taskType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 09111dfad70f3..c769ad11f69da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -121,7 +121,8 @@ private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int conten if (operation instanceof CreateJobOperation) { CreateJobOperation createJobOperation = (CreateJobOperation) operation; jobContentId = contentId; - bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getJob(), jobURI, contentId); + bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getEntityType(), jobURI, + contentId); contentId++; if (bodyPartContent != null) { bodyPartContents.add(bodyPartContent); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 96b2149c4cc54..1765b0bb92a6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -276,15 +276,14 @@ private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksO private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOptions) { JobType jobType = new JobType(); if (createJobOptions != null) { - jobType.setInputMediaAssets(createJobOptions.getInputMediaAssets()); jobType.setName(createJobOptions.getName()); - jobType.setOutputMediaAssets(createJobOptions.getOutputMediaAssets()); jobType.setPriority(createJobOptions.getPriority()); jobType.setStartTime(createJobOptions.getStartTime()); } CreateJobOperation createJobOperation = new CreateJobOperation(); - createJobOperation.setJob(jobType); + createJobOperation.setJob(createJobOptions.getInputMediaAssets(), createJobOptions.getOutputMediaAssets(), + jobType); return createJobOperation; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java index 00d3c129b7e5a..d0ac5c85e78b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java @@ -15,6 +15,58 @@ package com.microsoft.windowsazure.services.media.implementation; -public interface Operation { +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; + +public class Operation { + + protected String verb; + protected EntryType entryType; + + public Operation() { + this.entryType = new EntryType(); + } + + public EntryType getEntityType() { + return entryType; + } + + public void setEntityType(EntryType entryType) { + this.entryType = entryType; + } + + protected void setVerb(String verb) { + this.verb = verb; + } + + protected String getVerb() { + return this.verb; + } + + protected void addContentObject(Object contentObject) { + ContentType atomContent = new ContentType(); + atomContent.setType("application/xml"); + atomContent.getContent().add( + new JAXBElement(new QName(Constants.ODATA_METADATA_NS, "properties"), atomContent.getClass(), + atomContent)); + + this.entryType.getEntryChildren().add( + new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); + } + + protected void addLink(String title, String href, String type, String rel) { + LinkType linkType = new LinkType(); + linkType.setTitle(title); + linkType.setHref(href); + linkType.setType(type); + linkType.setRel(rel); + this.entryType.getEntryChildren().add( + new JAXBElement(new QName(Constants.ATOM_NS, "link"), LinkType.class, linkType)); + + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index db365e0a5adfe..12a7ab6afa5a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -8,7 +8,6 @@ package com.microsoft.windowsazure.services.media.implementation.atom; -import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -191,14 +190,4 @@ public Map<QName, String> getOtherAttributes() { return otherAttributes; } - public URI getLink() { - - return null; - } - - public void setLink(URI uri) { - // TODO Auto-generated method stub - - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 5053644b7de71..4c2ed0f646cc3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -17,7 +17,6 @@ import java.net.URI; import java.util.Date; -import java.util.List; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; @@ -186,17 +185,4 @@ public AssetInfo setOptions(EncryptionOption options) { return this; } - public URI getUri() { - return this.getEntry().getLink(); - } - - public AssetInfo setUri(URI uri) { - this.uri = uri; - return this; - } - - public List<Object> getChildren() { - return this.getEntry().getEntryChildren(); - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index e6781b18c5e27..d80cdc96c3a4e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -19,6 +19,8 @@ import java.io.IOException; import java.net.URI; +import java.util.ArrayList; +import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; @@ -99,7 +101,10 @@ public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationE JobType jobType = new JobType(); TaskType taskType = new TaskType(); CreateTaskOperation createTaskOperation = new CreateTaskOperation().setTask(taskType); - CreateJobOperation createJobOperation = new CreateJobOperation().setJob(jobType); + List<URI> inputMediaAssets = new ArrayList<URI>(); + List<URI> outputMediaAssets = new ArrayList<URI>(); + CreateJobOperation createJobOperation = new CreateJobOperation().setJob(inputMediaAssets, outputMediaAssets, + jobType); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); From ed49621cc0d51b764ab89a311e555d12eead9473 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 16:20:13 -0800 Subject: [PATCH 463/664] Inlining function --- .../services/media/implementation/MediaEntityRestProxy.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index 83fce1ad169e5..f291ab075e348 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -158,9 +158,7 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { */ @Override public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { - WebResource resource = getResource(lister.getUri()); - - return resource.queryParams(lister.getQueryParameters()).type(lister.getContentType()) + return getResource(lister.getUri()).queryParams(lister.getQueryParameters()).type(lister.getContentType()) .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); } From 7b84b2d061074f6d99183cbbfcfd4008c8dc9d39 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 16:44:28 -0800 Subject: [PATCH 464/664] Moved things around - implementation into media.implementation.entities, entity helpers into media.models. Also factored out rest proxy from media rest proxy, to separate generic from specific. --- .../services/media/MediaEntityContract.java | 62 +-- .../implementation/MediaEntityRestProxy.java | 118 +----- .../entities/DefaultDeleteOperation.java | 3 +- .../entities/DefaultGetterOperation.java | 3 +- .../entities/DefaultListOperation.java | 2 +- .../entities/EntityContract.java | 77 ++++ .../entities/EntityCreationOperation.java | 3 +- .../entities/EntityDeleteOperation.java | 2 +- .../entities/EntityGetOperation.java | 3 +- .../entities/EntityListOperation.java | 2 +- .../entities/EntityOperation.java | 2 +- .../entities/EntityOperationBase.java | 3 +- .../entities/EntityOperationSingleResult.java | 3 +- .../EntityOperationSingleResultBase.java | 3 +- .../entities/EntityRestProxy.java | 81 ++++ .../entities/EntityUpdateOperation.java | 3 +- .../{entities => models}/AccessPolicy.java | 13 +- .../media/{entities => models}/Asset.java | 14 +- .../media/{entities => models}/Locator.java | 393 +++++++++--------- .../{entities => models}/MediaProcessor.java | 116 +++--- .../services/media/EntityProxyTest.java | 2 +- .../AccessPolicyEntityTest.java | 6 +- .../{entities => models}/AssetEntityTest.java | 7 +- .../LocatorEntityTest.java | 285 ++++++------- .../MediaProcessorEntityTest.java | 104 ++--- 25 files changed, 677 insertions(+), 633 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/DefaultDeleteOperation.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/DefaultGetterOperation.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/DefaultListOperation.java (96%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityCreationOperation.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityDeleteOperation.java (67%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityGetOperation.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityListOperation.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityOperation.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityOperationBase.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityOperationSingleResult.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityOperationSingleResultBase.java (94%) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{ => implementation}/entities/EntityUpdateOperation.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{entities => models}/AccessPolicy.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{entities => models}/Asset.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{entities => models}/Locator.java (85%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{entities => models}/MediaProcessor.java (87%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{entities => models}/AccessPolicyEntityTest.java (88%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{entities => models}/AssetEntityTest.java (89%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{entities => models}/LocatorEntityTest.java (91%) rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/{entities => models}/MediaProcessorEntityTest.java (87%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java index de3937e5a891f..28ade12b713e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java @@ -16,67 +16,11 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; -import com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; -import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; /** - * Contract for interacting with the back end service - * providing various odata entities. + * Contract for interacting with the back end of Media Services * */ -public interface MediaEntityContract extends FilterableService<MediaEntityContract> { - - /** - * Create a new instance of an entity - * - * @param creator - * Object providing the details of the entity to be - * created - * @return - * The created entity - */ - <T> T create(EntityCreationOperation<T> creator) throws ServiceException; - - /** - * Retrieve an existing entity by id - * - * @param getter - * object providing the details of the entity to be retrieved - * @return The retrieved entity - * @throws ServiceException - */ - <T> T get(EntityGetOperation<T> getter) throws ServiceException; - - /** - * Retrieve a list of entities - * - * @param lister - * object providing details of entities to list - * @return The resulting list - * @throws ServiceException - */ - <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; - - /** - * Update an existing entity - * - * @param updater - * Object providing details of the update - * @throws ServiceException - */ - void update(EntityUpdateOperation updater) throws ServiceException; - - /** - * Delete an entity - * - * @param deleter - * Object providing details of the delete - * @throws ServiceException - */ - void delete(EntityDeleteOperation deleter) throws ServiceException; +public interface MediaEntityContract extends FilterableService<MediaEntityContract>, EntityContract { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java index f291ab075e348..feb2f3a556735 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java @@ -22,36 +22,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; -import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaEntityContract; -import com.microsoft.windowsazure.services.media.entities.EntityCreationOperation; -import com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.entities.EntityOperation; -import com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation; -import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; 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; /** * * */ -public class MediaEntityRestProxy implements MediaEntityContract { - /** The channel. */ - private Client channel; - +public class MediaEntityRestProxy extends EntityRestProxy implements MediaEntityContract { /** The log. */ - static Log log = LogFactory.getLog(MediaContract.class); - /** The filters. */ - ServiceFilter[] filters; + static Log log = LogFactory.getLog(MediaEntityContract.class); /** * Instantiates a new media rest proxy. @@ -68,8 +50,7 @@ public class MediaEntityRestProxy implements MediaEntityContract { @Inject public MediaEntityRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, VersionHeadersFilter versionHeadersFilter) { - this.channel = channel; - this.filters = new ServiceFilter[0]; + super(channel, new ServiceFilter[0]); channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -84,9 +65,8 @@ public MediaEntityRestProxy(Client channel, OAuthFilter authFilter, RedirectFilt * @param filters * the filters */ - public MediaEntityRestProxy(Client channel, ServiceFilter[] filters) { - this.channel = channel; - this.filters = filters; + private MediaEntityRestProxy(Client channel, ServiceFilter[] filters) { + super(channel, filters); } /* (non-Javadoc) @@ -94,91 +74,9 @@ public MediaEntityRestProxy(Client channel, ServiceFilter[] filters) { */ @Override public MediaEntityContract withFilter(ServiceFilter filter) { + ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new MediaEntityRestProxy(channel, newFilters); - } - - /** - * Gets the channel. - * - * @return the channel - */ - public Client getChannel() { - return channel; - } - - /** - * Sets the channel. - * - * @param channel - * the new channel - */ - public void setChannel(Client channel) { - this.channel = channel; - } - - /** - * Gets the resource. - * - * @param entityName - * the entity name - * @return the resource - */ - private WebResource getResource(String entityName) { - WebResource resource = getChannel().resource(entityName); - for (ServiceFilter filter : filters) { - resource.addFilter(new ClientFilterAdapter(filter)); - } - return resource; - } - - private Builder getResource(EntityOperation operation) { - return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaEntityContract#create(com.microsoft.windowsazure.services.media.entities.EntityCreationOperation) - */ - @Override - public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { - return getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaEntityContract#get(com.microsoft.windowsazure.services.media.entities.EntityGetOperation) - */ - @Override - public <T> T get(EntityGetOperation<T> getter) throws ServiceException { - return getResource(getter).get(getter.getResponseClass()); + return new MediaEntityRestProxy(getChannel(), newFilters); } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaEntityContract#list(com.microsoft.windowsazure.services.media.entities.EntityListOperation) - */ - @Override - public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { - return getResource(lister.getUri()).queryParams(lister.getQueryParameters()).type(lister.getContentType()) - .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaEntityContract#update(com.microsoft.windowsazure.services.media.entities.EntityUpdateOperation) - */ - @Override - public void update(EntityUpdateOperation updater) throws ServiceException { - ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, - updater.getRequestContents()); - - PipelineHelpers.ThrowIfNotSuccess(response); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaEntityContract#delete(com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation) - */ - @Override - public void delete(EntityDeleteOperation deleter) throws ServiceException { - getResource(deleter.getUri()).delete(); - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java index fc7d23be2ce5d..cb1675e490627 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * Generic implementation of Delete operation usable by most entities diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java index 64cc5db84aabe..986621cd0505d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultGetterOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * Generic implementation of the get operation usable for most entities diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index ebd8732e605f8..128dce080b1e8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; import javax.ws.rs.core.MultivaluedMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java new file mode 100644 index 0000000000000..fdb045b54388f --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -0,0 +1,77 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.entities; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.ListResult; + +/** + * Contract for interacting with the back end service + * providing various odata entities. + * + */ +public interface EntityContract { + + /** + * Create a new instance of an entity + * + * @param creator + * Object providing the details of the entity to be + * created + * @return + * The created entity + */ + public abstract <T> T create(EntityCreationOperation<T> creator) throws ServiceException; + + /** + * Retrieve an existing entity by id + * + * @param getter + * object providing the details of the entity to be retrieved + * @return The retrieved entity + * @throws ServiceException + */ + public abstract <T> T get(EntityGetOperation<T> getter) throws ServiceException; + + /** + * Retrieve a list of entities + * + * @param lister + * object providing details of entities to list + * @return The resulting list + * @throws ServiceException + */ + public abstract <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; + + /** + * Update an existing entity + * + * @param updater + * Object providing details of the update + * @throws ServiceException + */ + public abstract void update(EntityUpdateOperation updater) throws ServiceException; + + /** + * Delete an entity + * + * @param deleter + * Object providing details of the delete + * @throws ServiceException + */ + public abstract void delete(EntityDeleteOperation deleter) throws ServiceException; + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java index ffda9a16cffce..4fc92268ea4c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java similarity index 67% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java index 44736e7c4ca72..56c1e0de70352 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java @@ -1,4 +1,4 @@ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; public interface EntityDeleteOperation { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java index d4c9ed00def33..f3a90ade8a5eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * Get operation for Entities diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java index 430a15c5659a1..07f71c5b5d712 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; import javax.ws.rs.core.MultivaluedMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 21377a0b38967..6200ab12419fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index 94beafff6aaad..ac5dd3a556ef6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -21,6 +21,7 @@ import javax.ws.rs.core.MediaType; + /** * Default implementation of EntityOperation<T> to provide * default values for common methods. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java index 6bedba3a63bab..36f8e9a0c8a90 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + public interface EntityOperationSingleResult<T> extends EntityOperation { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java index 6913ad466296f..d819987c3c581 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java new file mode 100644 index 0000000000000..2858fe24b81a9 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -0,0 +1,81 @@ +package com.microsoft.windowsazure.services.media.implementation.entities; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.media.models.ListResult; +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; + +public class EntityRestProxy implements EntityContract { + + /** The channel. */ + private final Client channel; + /** The filters. */ + private final ServiceFilter[] filters; + + public EntityRestProxy(Client channel, ServiceFilter[] filters) { + this.channel = channel; + this.filters = filters; + } + + protected Client getChannel() { + return channel; + } + + protected ServiceFilter[] getFilters() { + return filters; + } + + /** + * Gets the resource. + * + * @param entityName + * the entity name + * @return the resource + */ + private WebResource getResource(String entityName) { + WebResource resource = channel.resource(entityName); + for (ServiceFilter filter : filters) { + resource.addFilter(new ClientFilterAdapter(filter)); + } + return resource; + } + + private Builder getResource(EntityOperation operation) { + return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); + } + + @Override + public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { + return getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); + } + + @Override + public <T> T get(EntityGetOperation<T> getter) throws ServiceException { + return getResource(getter).get(getter.getResponseClass()); + } + + @Override + public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { + return getResource(lister.getUri()).queryParams(lister.getQueryParameters()).type(lister.getContentType()) + .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); + } + + @Override + public void update(EntityUpdateOperation updater) throws ServiceException { + ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, + updater.getRequestContents()); + + PipelineHelpers.ThrowIfNotSuccess(response); + } + + @Override + public void delete(EntityDeleteOperation deleter) throws ServiceException { + getResource(deleter.getUri()).delete(); + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java index 33feab73a8862..598964145229f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/EntityUpdateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java @@ -13,7 +13,8 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.implementation.entities; + /** * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index ce4a1de23c626..a4aa5e6b6d7c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -13,16 +13,21 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.models; import java.util.EnumSet; import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 1cde764fd65d8..7b9c2cffabe2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -13,13 +13,21 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.models; import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index a774d1610b8bd..89335b41364cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -1,193 +1,200 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.entities; - -import java.util.Date; - -import javax.ws.rs.core.MultivaluedMap; - -import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.sun.jersey.api.client.GenericType; - -/** - * Implementation of Locator entity - * - */ -public class Locator { - - private final static String ENTITY_SET = "Locators"; - - private Locator() { - } - - /** - * Create an operation to create a new locator entity - * - * @param accessPolicyId - * id of access policy for locator - * @param assetId - * id of asset for locator - * @param locatorType - * locator type - * @return the operation - */ - public static Creator create(String accessPolicyId, String assetId, LocatorType locatorType) { - return new Creator(accessPolicyId, assetId, locatorType); - } - - public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements - EntityCreationOperation<LocatorInfo> { - private final String accessPolicyId; - private final String assetId; - private final LocatorType locatorType; - private Date startDateTime; - private Date expirationDateTime; - - protected Creator(String accessPolicyId, String assetId, LocatorType locatorType) { - super(ENTITY_SET, LocatorInfo.class); - this.accessPolicyId = accessPolicyId; - this.assetId = assetId; - this.locatorType = locatorType; - } - - @Override - public Object getRequestContents() { - return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId) - .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) - .setType(locatorType.getCode()); - } - - /** - * Set the date and time for when the locator starts to be available - * - * @param startDateTime - * The date/time - * @return The creator instance (for function chaining) - */ - public Creator startDateTime(Date startDateTime) { - this.startDateTime = startDateTime; - return this; - } - - /** - * Set the date and time at which the locator will expire - * - * @param expirationDateTime - * Expiration date and time - * @return The creator instance (for function chaining) - */ - public Creator expirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - } - - /** - * Create an operation to get the given locator - * - * @param locatorId - * id of locator to retrieve - * @return the get operation - */ - public static EntityGetOperation<LocatorInfo> get(String locatorId) { - return new DefaultGetterOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); - } - - /** - * Create an operation to list all locators - * - * @return the list operation - */ - public static EntityListOperation<LocatorInfo> list() { - return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { - }); - } - - /** - * Create an operation to list all locators matching the given query parameters - * - * @param queryParameters - * query parameters to send with the request - * @return the list operation - */ - public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { - }, queryParameters); - } - - /** - * Create an operation to update the given locator - * - * @param locatorId - * id of locator to update - * @return the update operation - */ - public static Updater update(String locatorId) { - return new Updater(locatorId); - } - - public static class Updater extends EntityOperationBase implements EntityUpdateOperation { - private Date startDateTime; - private Date expirationDateTime; - - public Updater(String locatorId) { - super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId)); - } - - @Override - public Object getRequestContents() { - return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); - } - - /** - * Set when the locator will become available - * - * @param startDateTime - * the date & time - * @return Updater instance - */ - public Updater startDateTime(Date startDateTime) { - this.startDateTime = startDateTime; - return this; - } - - /** - * Set when the locator will expire - * - * @param expirationDateTime - * the expiration date & time - * @return Updater instance - */ - public Updater expirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - - } - - /** - * Create an operation to delete the given locator - * - * @param locatorId - * id of locator to delete - * @return the operation - */ - public static EntityDeleteOperation delete(String locatorId) { - return new DefaultDeleteOperation(ENTITY_SET, locatorId); - } -} +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.sun.jersey.api.client.GenericType; + +/** + * Implementation of Locator entity + * + */ +public class Locator { + + private final static String ENTITY_SET = "Locators"; + + private Locator() { + } + + /** + * Create an operation to create a new locator entity + * + * @param accessPolicyId + * id of access policy for locator + * @param assetId + * id of asset for locator + * @param locatorType + * locator type + * @return the operation + */ + public static Creator create(String accessPolicyId, String assetId, LocatorType locatorType) { + return new Creator(accessPolicyId, assetId, locatorType); + } + + public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements + EntityCreationOperation<LocatorInfo> { + private final String accessPolicyId; + private final String assetId; + private final LocatorType locatorType; + private Date startDateTime; + private Date expirationDateTime; + + protected Creator(String accessPolicyId, String assetId, LocatorType locatorType) { + super(ENTITY_SET, LocatorInfo.class); + this.accessPolicyId = accessPolicyId; + this.assetId = assetId; + this.locatorType = locatorType; + } + + @Override + public Object getRequestContents() { + return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId) + .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) + .setType(locatorType.getCode()); + } + + /** + * Set the date and time for when the locator starts to be available + * + * @param startDateTime + * The date/time + * @return The creator instance (for function chaining) + */ + public Creator startDateTime(Date startDateTime) { + this.startDateTime = startDateTime; + return this; + } + + /** + * Set the date and time at which the locator will expire + * + * @param expirationDateTime + * Expiration date and time + * @return The creator instance (for function chaining) + */ + public Creator expirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + } + + /** + * Create an operation to get the given locator + * + * @param locatorId + * id of locator to retrieve + * @return the get operation + */ + public static EntityGetOperation<LocatorInfo> get(String locatorId) { + return new DefaultGetterOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); + } + + /** + * Create an operation to list all locators + * + * @return the list operation + */ + public static EntityListOperation<LocatorInfo> list() { + return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { + }); + } + + /** + * Create an operation to list all locators matching the given query parameters + * + * @param queryParameters + * query parameters to send with the request + * @return the list operation + */ + public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { + }, queryParameters); + } + + /** + * Create an operation to update the given locator + * + * @param locatorId + * id of locator to update + * @return the update operation + */ + public static Updater update(String locatorId) { + return new Updater(locatorId); + } + + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + private Date startDateTime; + private Date expirationDateTime; + + public Updater(String locatorId) { + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId)); + } + + @Override + public Object getRequestContents() { + return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); + } + + /** + * Set when the locator will become available + * + * @param startDateTime + * the date & time + * @return Updater instance + */ + public Updater startDateTime(Date startDateTime) { + this.startDateTime = startDateTime; + return this; + } + + /** + * Set when the locator will expire + * + * @param expirationDateTime + * the expiration date & time + * @return Updater instance + */ + public Updater expirationDateTime(Date expirationDateTime) { + this.expirationDateTime = expirationDateTime; + return this; + } + + } + + /** + * Create an operation to delete the given locator + * + * @param locatorId + * id of locator to delete + * @return the operation + */ + public static EntityDeleteOperation delete(String locatorId) { + return new DefaultDeleteOperation(ENTITY_SET, locatorId); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java similarity index 87% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index cdf49a1b3e7f9..efb94a0e29734 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entities/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -1,58 +1,58 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.entities; - -import javax.ws.rs.core.MultivaluedMap; - -import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.sun.jersey.api.client.GenericType; - -/** - * Entity operations for Media processors - * - */ -public class MediaProcessor { - - private static final String ENTITY_SET = "MediaProcessors"; - - private MediaProcessor() { - } - - /** - * Create an operation to list all Media processors - * - * @return the list operation - */ - public static EntityListOperation<MediaProcessorInfo> list() { - return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, - new GenericType<ListResult<MediaProcessorInfo>>() { - }); - } - - /** - * Create an operation to list all media processors that satisfy the given query parameters - * - * @param queryParameters - * query parameters to pass with the request - * @return the list operation - */ - public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, - new GenericType<ListResult<MediaProcessorInfo>>() { - }, queryParameters); - } -} +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.sun.jersey.api.client.GenericType; + +/** + * Entity operations for Media processors + * + */ +public class MediaProcessor { + + private static final String ENTITY_SET = "MediaProcessors"; + + private MediaProcessor() { + } + + /** + * Create an operation to list all Media processors + * + * @return the list operation + */ + public static EntityListOperation<MediaProcessorInfo> list() { + return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, + new GenericType<ListResult<MediaProcessorInfo>>() { + }); + } + + /** + * Create an operation to list all media processors that satisfy the given query parameters + * + * @param queryParameters + * query parameters to pass with the request + * @return the list operation + */ + public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, + new GenericType<ListResult<MediaProcessorInfo>>() { + }, queryParameters); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index afcf0ab88a08c..504dfa894979d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -10,7 +10,7 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.windowsazure.services.media.entities.Asset; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.core.util.MultivaluedMapImpl; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java similarity index 88% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index 92cf0c967600d..b3ba31d391914 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.models; import static org.junit.Assert.*; @@ -25,6 +25,10 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.sun.jersey.core.util.MultivaluedMapImpl; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java similarity index 89% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index c09437f03f456..e75402f15dfa5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.entities; +package com.microsoft.windowsazure.services.media.models; import static org.junit.Assert.*; @@ -24,6 +24,11 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.core.util.MultivaluedMapImpl; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java similarity index 91% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 3eaf8ee6bb84c..c9e4597e1bc7f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -1,140 +1,145 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.entities; - -import static org.junit.Assert.*; - -import java.net.URLEncoder; -import java.util.Date; - -import javax.ws.rs.core.MultivaluedMap; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -/** - * Tests for the Locator entity - * - */ -public class LocatorEntityTest { - private final String exampleAssetId = "nb:cid:UUID:61a5ebbe-d5e0-49a5-b28c-e9535321b6cd"; - private final String exampleAccessPolicyId = "nb:pid:UUID:c82307be-1a81-4554-ba7d-cf6dfa735a5a"; - private final String exampleLocatorId = "nb:lid:UUID:f282b0a1-fb21-4b83-87d6-d4c96d77aef9"; - private final String expectedLocatorUri = String.format("Locators('%s')", - URLEncoder.encode(exampleLocatorId, "UTF-8")); - - public LocatorEntityTest() throws Exception { - - } - - @Test - public void createLocatorHasCorrectUrl() throws Exception { - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, - LocatorType.SAS); - - assertEquals("Locators", creator.getUri()); - } - - @Test - public void createLocatorHasCorrectPayload() throws Exception { - LocatorRestType locatorType = (LocatorRestType) Locator.create(exampleAccessPolicyId, exampleAssetId, - LocatorType.SAS).getRequestContents(); - - assertEquals(exampleAssetId, locatorType.getAssetId()); - assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); - assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); - assertNull(locatorType.getStartTime()); - assertNull(locatorType.getExpirationDateTime()); - } - - @Test - public void createLocatorCanSetTimes() throws Exception { - Date now = new Date(); - Date tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000); - - EntityCreationOperation<LocatorInfo> creator = Locator - .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).startDateTime(now) - .expirationDateTime(tomorrow); - - LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); - - assertEquals(exampleAssetId, locatorType.getAssetId()); - assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); - assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); - assertEquals(now, locatorType.getStartTime()); - assertEquals(tomorrow, locatorType.getExpirationDateTime()); - } - - @Test - public void getLocatorGivesExpectedUri() throws Exception { - assertEquals(expectedLocatorUri, Locator.get(exampleLocatorId).getUri()); - } - - @Test - public void listLocatorReturnsExpectedUri() { - EntityListOperation<LocatorInfo> lister = Locator.list(); - - assertEquals("Locators", lister.getUri()); - assertNotNull(lister.getQueryParameters()); - assertEquals(0, lister.getQueryParameters().size()); - } - - @Test - public void listLocatorCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); - - EntityListOperation<LocatorInfo> lister = Locator.list(queryParams); - - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals(2, lister.getQueryParameters().size()); - } - - @Test - public void locatorUpdateReturnsExpectedUri() throws Exception { - EntityUpdateOperation updater = Locator.update(exampleLocatorId); - assertEquals(expectedLocatorUri, updater.getUri()); - } - - @Test - public void locatorUpdateCanStartAndExpirationTime() throws Exception { - Date now = new Date(); - - Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); - Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); - - EntityUpdateOperation updater = Locator.update(exampleLocatorId).startDateTime(tenMinutesAgo) - .expirationDateTime(twoHoursFromNow); - - LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); - - assertEquals(tenMinutesAgo, payload.getStartTime()); - assertEquals(twoHoursFromNow, payload.getExpirationDateTime()); - } - - @Test - public void locatorDeleteReturnsExpectedUri() throws Exception { - EntityDeleteOperation deleter = Locator.delete(exampleLocatorId); - - assertEquals(expectedLocatorUri, deleter.getUri()); - } -} +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.net.URLEncoder; +import java.util.Date; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.microsoft.windowsazure.services.media.models.Locator; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the Locator entity + * + */ +public class LocatorEntityTest { + private final String exampleAssetId = "nb:cid:UUID:61a5ebbe-d5e0-49a5-b28c-e9535321b6cd"; + private final String exampleAccessPolicyId = "nb:pid:UUID:c82307be-1a81-4554-ba7d-cf6dfa735a5a"; + private final String exampleLocatorId = "nb:lid:UUID:f282b0a1-fb21-4b83-87d6-d4c96d77aef9"; + private final String expectedLocatorUri = String.format("Locators('%s')", + URLEncoder.encode(exampleLocatorId, "UTF-8")); + + public LocatorEntityTest() throws Exception { + + } + + @Test + public void createLocatorHasCorrectUrl() throws Exception { + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS); + + assertEquals("Locators", creator.getUri()); + } + + @Test + public void createLocatorHasCorrectPayload() throws Exception { + LocatorRestType locatorType = (LocatorRestType) Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).getRequestContents(); + + assertEquals(exampleAssetId, locatorType.getAssetId()); + assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertNull(locatorType.getStartTime()); + assertNull(locatorType.getExpirationDateTime()); + } + + @Test + public void createLocatorCanSetTimes() throws Exception { + Date now = new Date(); + Date tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000); + + EntityCreationOperation<LocatorInfo> creator = Locator + .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).startDateTime(now) + .expirationDateTime(tomorrow); + + LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); + + assertEquals(exampleAssetId, locatorType.getAssetId()); + assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertEquals(now, locatorType.getStartTime()); + assertEquals(tomorrow, locatorType.getExpirationDateTime()); + } + + @Test + public void getLocatorGivesExpectedUri() throws Exception { + assertEquals(expectedLocatorUri, Locator.get(exampleLocatorId).getUri()); + } + + @Test + public void listLocatorReturnsExpectedUri() { + EntityListOperation<LocatorInfo> lister = Locator.list(); + + assertEquals("Locators", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void listLocatorCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<LocatorInfo> lister = Locator.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void locatorUpdateReturnsExpectedUri() throws Exception { + EntityUpdateOperation updater = Locator.update(exampleLocatorId); + assertEquals(expectedLocatorUri, updater.getUri()); + } + + @Test + public void locatorUpdateCanStartAndExpirationTime() throws Exception { + Date now = new Date(); + + Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); + Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); + + EntityUpdateOperation updater = Locator.update(exampleLocatorId).startDateTime(tenMinutesAgo) + .expirationDateTime(twoHoursFromNow); + + LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); + + assertEquals(tenMinutesAgo, payload.getStartTime()); + assertEquals(twoHoursFromNow, payload.getExpirationDateTime()); + } + + @Test + public void locatorDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = Locator.delete(exampleLocatorId); + + assertEquals(expectedLocatorUri, deleter.getUri()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java similarity index 87% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index aa6d8c03689bb..e81fbcea76e94 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/entities/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -1,51 +1,53 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.entities; - -import static org.junit.Assert.*; - -import javax.ws.rs.core.MultivaluedMap; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.sun.jersey.core.util.MultivaluedMapImpl; - -/** - * Tests for the MediaProcessor entity - * - */ -public class MediaProcessorEntityTest { - - @Test - public void listMediaProcessorsReturnsExpectedUri() { - assertEquals("MediaProcessors", MediaProcessor.list().getUri()); - } - - @Test - public void listMediaProcessorsCanTakeQueryParmeters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); - - EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list(queryParams); - - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals(2, lister.getQueryParameters().size()); - } - -} +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.models.MediaProcessor; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the MediaProcessor entity + * + */ +public class MediaProcessorEntityTest { + + @Test + public void listMediaProcessorsReturnsExpectedUri() { + assertEquals("MediaProcessors", MediaProcessor.list().getUri()); + } + + @Test + public void listMediaProcessorsCanTakeQueryParmeters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + +} From 926ed8db55d9526bf15841f0c7705645d5278e2c Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 17:07:47 -0800 Subject: [PATCH 465/664] Updating setter names to match naming guidelines --- .../windowsazure/services/media/models/Asset.java | 8 ++++---- .../windowsazure/services/media/models/Locator.java | 8 ++++---- .../windowsazure/services/media/EntityProxyTest.java | 10 +++++----- .../services/media/models/AssetEntityTest.java | 4 ++-- .../services/media/models/LocatorEntityTest.java | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 7b9c2cffabe2c..6e11adc742811 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -68,7 +68,7 @@ public Object getRequestContents() { * The name * @return The creator object (for call chaining) */ - public Creator name(String name) { + public Creator setName(String name) { this.name = name; return this; } @@ -81,7 +81,7 @@ public Creator name(String name) { * * @return The creator object (for call chaining) */ - public Creator alternateId(String alternateId) { + public Creator setAlternateId(String alternateId) { this.alternateId = alternateId; return this; } @@ -154,7 +154,7 @@ public Object getRequestContents() { * The new name * @return Updater instance */ - public Updater name(String name) { + public Updater setName(String name) { this.name = name; return this; } @@ -166,7 +166,7 @@ public Updater name(String name) { * the new alternate id * @return Updater instance */ - public Updater alternateId(String alternateId) { + public Updater setAlternateId(String alternateId) { this.alternateId = alternateId; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 89335b41364cc..6169911f037f8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -86,7 +86,7 @@ public Object getRequestContents() { * The date/time * @return The creator instance (for function chaining) */ - public Creator startDateTime(Date startDateTime) { + public Creator setStartDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } @@ -98,7 +98,7 @@ public Creator startDateTime(Date startDateTime) { * Expiration date and time * @return The creator instance (for function chaining) */ - public Creator expirationDateTime(Date expirationDateTime) { + public Creator setExpirationDateTime(Date expirationDateTime) { this.expirationDateTime = expirationDateTime; return this; } @@ -168,7 +168,7 @@ public Object getRequestContents() { * the date & time * @return Updater instance */ - public Updater startDateTime(Date startDateTime) { + public Updater setStartDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } @@ -180,7 +180,7 @@ public Updater startDateTime(Date startDateTime) { * the expiration date & time * @return Updater instance */ - public Updater expirationDateTime(Date expirationDateTime) { + public Updater setExpirationDateTime(Date expirationDateTime) { this.expirationDateTime = expirationDateTime; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 504dfa894979d..98930fe7dd31c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -41,7 +41,7 @@ public void canCreateAssetOnServerWithNameAndAltId() throws Exception { String name = testAssetPrefix + "AName"; String altId = "unit test alt id"; - AssetInfo asset = entityService.create(Asset.create().name(name).alternateId(altId)); + AssetInfo asset = entityService.create(Asset.create().setName(name).setAlternateId(altId)); assertNotNull(asset.getId()); assertEquals(name, asset.getName()); @@ -50,7 +50,7 @@ public void canCreateAssetOnServerWithNameAndAltId() throws Exception { @Test public void canRetrieveAssetById() throws Exception { - AssetInfo createdAsset = entityService.create(Asset.create().name(testAssetPrefix + "canRetrieveAssetById")); + AssetInfo createdAsset = entityService.create(Asset.create().setName(testAssetPrefix + "canRetrieveAssetById")); AssetInfo retrieved = entityService.get(Asset.get(createdAsset.getId())); @@ -93,9 +93,9 @@ public void canUpdateAssetNameAndAltId() throws Exception { String newName = testAssetPrefix + "newName"; String newAltId = "updated alt id"; - AssetInfo initialAsset = entityService.create(Asset.create().name(testAssetPrefix + "originalName")); + AssetInfo initialAsset = entityService.create(Asset.create().setName(testAssetPrefix + "originalName")); - entityService.update(Asset.update(initialAsset.getId()).name(newName).alternateId(newAltId)); + entityService.update(Asset.update(initialAsset.getId()).setName(newName).setAlternateId(newAltId)); AssetInfo updatedAsset = entityService.get(Asset.get(initialAsset.getId())); @@ -131,7 +131,7 @@ private Set<String> createTestAssets(int numAssets, String namePart) throws Exce for (int i = 0; i < numAssets; ++i) { AssetInfo asset = entityService.create(Asset.create() - .name(testAssetPrefix + namePart + Integer.toString(i))); + .setName(testAssetPrefix + namePart + Integer.toString(i))); expectedAssets.add(asset.getId()); } return expectedAssets; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index e75402f15dfa5..8cf88ca8c00a9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -60,7 +60,7 @@ public void assetCreateReturnsDefaultCreatePayload() { public void assetCreateCanSetAssetName() { String name = "assetCreateCanSetAssetName"; - Asset.Creator creator = Asset.create().name("assetCreateCanSetAssetName"); + Asset.Creator creator = Asset.create().setName("assetCreateCanSetAssetName"); AssetType payload = (AssetType) creator.getRequestContents(); @@ -117,7 +117,7 @@ public void assetUpdateCanSetNameAndAltId() throws Exception { String expectedName = "newAssetName"; String expectedAltId = "newAltId"; - EntityUpdateOperation updater = Asset.update(sampleAssetId).name(expectedName).alternateId(expectedAltId); + EntityUpdateOperation updater = Asset.update(sampleAssetId).setName(expectedName).setAlternateId(expectedAltId); AssetType payload = (AssetType) updater.getRequestContents(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index c9e4597e1bc7f..4dc816de535b6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -75,8 +75,8 @@ public void createLocatorCanSetTimes() throws Exception { Date tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000); EntityCreationOperation<LocatorInfo> creator = Locator - .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).startDateTime(now) - .expirationDateTime(tomorrow); + .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setStartDateTime(now) + .setExpirationDateTime(tomorrow); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); @@ -127,8 +127,8 @@ public void locatorUpdateCanStartAndExpirationTime() throws Exception { Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); - EntityUpdateOperation updater = Locator.update(exampleLocatorId).startDateTime(tenMinutesAgo) - .expirationDateTime(twoHoursFromNow); + EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo) + .setExpirationDateTime(twoHoursFromNow); LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); From 92d58244e0c72af761a4c0fdf5173f05c35d9f65 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 6 Nov 2012 17:10:47 -0800 Subject: [PATCH 466/664] Added ENTITY_SET constant to asset, access policy entity implementations --- .../services/media/models/AccessPolicy.java | 18 +++++++++--------- .../services/media/models/Asset.java | 13 +++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index a4aa5e6b6d7c5..50ea85034e3fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -36,6 +36,8 @@ */ public class AccessPolicy { + private static final String ENTITY_SET = "AccessPolicies"; + private AccessPolicy() { } @@ -63,7 +65,7 @@ private static class Creator extends EntityOperationSingleResultBase<AccessPolic public Creator(String policyName, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { - super("AccessPolicies", AccessPolicyInfo.class); + super(ENTITY_SET, AccessPolicyInfo.class); this.policyName = policyName; this.durationInMinutes = durationInMinutes; @@ -86,7 +88,7 @@ public Object getRequestContents() { * @return the operation */ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { - return new DefaultGetterOperation<AccessPolicyInfo>("AccessPolicies", accessPolicyId, AccessPolicyInfo.class); + return new DefaultGetterOperation<AccessPolicyInfo>(ENTITY_SET, accessPolicyId, AccessPolicyInfo.class); } /** @@ -95,9 +97,8 @@ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { * @return the operation */ public static EntityListOperation<AccessPolicyInfo> list() { - return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", - new GenericType<ListResult<AccessPolicyInfo>>() { - }); + return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() { + }); } /** @@ -108,9 +109,8 @@ public static EntityListOperation<AccessPolicyInfo> list() { * @return the operation */ public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<AccessPolicyInfo>("AccessPolicies", - new GenericType<ListResult<AccessPolicyInfo>>() { - }, queryParameters); + return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() { + }, queryParameters); } /** @@ -121,6 +121,6 @@ public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, * @return the delete operation */ public static EntityDeleteOperation delete(String accessPolicyId) { - return new DefaultDeleteOperation("AccessPolicies", accessPolicyId); + return new DefaultDeleteOperation(ENTITY_SET, accessPolicyId); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 6e11adc742811..a801016025d98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -35,6 +35,7 @@ * */ public class Asset { + private static final String ENTITY_SET = "Assets"; // Prevent instantiation private Asset() { @@ -50,7 +51,7 @@ public static class Creator extends EntityOperationSingleResultBase<AssetInfo> i private String alternateId; public Creator() { - super("Assets", AssetInfo.class); + super(ENTITY_SET, AssetInfo.class); } @Override @@ -95,7 +96,7 @@ public Creator setAlternateId(String alternateId) { * @return the get operation */ public static EntityGetOperation<AssetInfo> get(String assetId) { - return new DefaultGetterOperation<AssetInfo>("Assets", assetId, AssetInfo.class); + return new DefaultGetterOperation<AssetInfo>(ENTITY_SET, assetId, AssetInfo.class); } /** @@ -104,7 +105,7 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { * @return The list operation */ public static EntityListOperation<AssetInfo> list() { - return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { + return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() { }); } @@ -116,7 +117,7 @@ public static EntityListOperation<AssetInfo> list() { * @return the list operation. */ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<AssetInfo>("Assets", new GenericType<ListResult<AssetInfo>>() { + return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() { }, queryParameters); } @@ -136,7 +137,7 @@ public static class Updater extends EntityOperationBase implements EntityUpdateO private String alternateId; protected Updater(String assetId) { - super(new EntityOperationBase.EntityIdUriBuilder("Assets", assetId)); + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, assetId)); } @Override @@ -180,6 +181,6 @@ public Updater setAlternateId(String alternateId) { * @return the delete operation */ public static EntityDeleteOperation delete(String assetId) { - return new DefaultDeleteOperation("Assets", assetId); + return new DefaultDeleteOperation(ENTITY_SET, assetId); } } From 333a34b5cbd57f905722e46a39de3540302a58ca Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 7 Nov 2012 13:36:33 -0800 Subject: [PATCH 467/664] Renamed DefaultGetterOperation to DefaultGetOperation for consistency with interface name --- .../{DefaultGetterOperation.java => DefaultGetOperation.java} | 4 ++-- .../windowsazure/services/media/models/AccessPolicy.java | 4 ++-- .../microsoft/windowsazure/services/media/models/Asset.java | 4 ++-- .../microsoft/windowsazure/services/media/models/Locator.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/{DefaultGetterOperation.java => DefaultGetOperation.java} (81%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java similarity index 81% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java index 986621cd0505d..9f24fb969af87 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetterOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java @@ -20,13 +20,13 @@ * Generic implementation of the get operation usable for most entities * */ -public class DefaultGetterOperation<T> extends EntityOperationSingleResultBase<T> implements EntityGetOperation<T> { +public class DefaultGetOperation<T> extends EntityOperationSingleResultBase<T> implements EntityGetOperation<T> { /** * @param uri * @param responseClass */ - public DefaultGetterOperation(String entityTypeUri, String entityId, Class<T> responseClass) { + public DefaultGetOperation(String entityTypeUri, String entityId, Class<T> responseClass) { super(new EntityOperationBase.EntityIdUriBuilder(entityTypeUri, entityId), responseClass); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index 50ea85034e3fc..a0d7cb38e9475 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -21,7 +21,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; @@ -88,7 +88,7 @@ public Object getRequestContents() { * @return the operation */ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { - return new DefaultGetterOperation<AccessPolicyInfo>(ENTITY_SET, accessPolicyId, AccessPolicyInfo.class); + return new DefaultGetOperation<AccessPolicyInfo>(ENTITY_SET, accessPolicyId, AccessPolicyInfo.class); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index a801016025d98..e43f7fcd6a372 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -19,7 +19,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; @@ -96,7 +96,7 @@ public Creator setAlternateId(String alternateId) { * @return the get operation */ public static EntityGetOperation<AssetInfo> get(String assetId) { - return new DefaultGetterOperation<AssetInfo>(ENTITY_SET, assetId, AssetInfo.class); + return new DefaultGetOperation<AssetInfo>(ENTITY_SET, assetId, AssetInfo.class); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 6169911f037f8..6684aa1f8a56f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -20,7 +20,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetterOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; @@ -112,7 +112,7 @@ public Creator setExpirationDateTime(Date expirationDateTime) { * @return the get operation */ public static EntityGetOperation<LocatorInfo> get(String locatorId) { - return new DefaultGetterOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); + return new DefaultGetOperation<LocatorInfo>(ENTITY_SET, locatorId, LocatorInfo.class); } /** From d26abcd79f5491850d958c9ff2b93a9656aa3223 Mon Sep 17 00:00:00 2001 From: "Justin Yu (Microsoft)" <justinyu@microsoft.com> Date: Wed, 7 Nov 2012 13:55:43 -0800 Subject: [PATCH 468/664] Change the file header from Copyright 2011 Microsoft Corporation and Copyright 2012 Microsoft Corporation --- .../windowsazure/services/core/storage/SendingRequestEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java index 94efc9555634f..2e86fbe6166d6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2012 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 9c015a5e9adea1b38242a3540aec2dfe1cf7bda1 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 7 Nov 2012 14:01:36 -0800 Subject: [PATCH 469/664] Converted existing code to use new design, removed old rest proxy contract & design. --- .../org.eclipse.core.resources.prefs | 6 + .../windowsazure/services/media/Exports.java | 4 - .../services/media/MediaContract.java | 265 +----------- .../services/media/MediaEntityContract.java | 26 -- .../implementation/MediaEntityRestProxy.java | 82 ---- .../MediaExceptionProcessor.java | 318 +------------- .../media/implementation/MediaRestProxy.java | 398 +----------------- .../services/media/models/Asset.java | 18 + .../media/models/CreateAssetOptions.java | 118 ------ .../media/models/CreateLocatorOptions.java | 72 ---- .../media/models/ListAccessPolicyOptions.java | 24 -- .../media/models/ListAssetsOptions.java | 19 - .../media/models/ListLocatorsOptions.java | 22 - .../models/ListMediaProcessorsOptions.java | 22 - .../services/media/models/ListOptions.java | 45 -- .../media/models/UpdateAssetOptions.java | 70 --- .../media/models/UpdateLocatorOptions.java | 72 ---- .../media/AccessPolicyIntegrationTest.java | 57 +-- .../services/media/AssetIntegrationTest.java | 88 ++-- .../services/media/EntityProxyTest.java | 4 +- .../services/media/IntegrationTestBase.java | 23 +- .../media/LocatorIntegrationTests.java | 104 +++-- .../media/MediaProcessorIntegrationTest.java | 18 +- .../media/UploadingIntegrationTest.java | 16 +- .../ODataSerializationFromJerseyTest.java | 15 +- .../media/models/CreateAssetOptionsTest.java | 75 ---- .../ListMediaProcessorsOptionsTest.java | 34 -- .../media/models/UpdateAssetOptionsTest.java | 49 --- 28 files changed, 216 insertions(+), 1848 deletions(-) create mode 100644 microsoft-azure-api/.settings/org.eclipse.core.resources.prefs delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java diff --git a/microsoft-azure-api/.settings/org.eclipse.core.resources.prefs b/microsoft-azure-api/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000000..29abf99956411 --- /dev/null +++ b/microsoft-azure-api/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/<project>=UTF-8 diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 0338244010bc9..558ec8a18a8e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -21,7 +21,6 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.media.implementation.MediaContentProvider; -import com.microsoft.windowsazure.services.media.implementation.MediaEntityRestProxy; import com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor; import com.microsoft.windowsazure.services.media.implementation.MediaRestProxy; import com.microsoft.windowsazure.services.media.implementation.OAuthContract; @@ -44,7 +43,6 @@ public class Exports implements Builder.Exports { @Override public void register(Builder.Registry registry) { registry.add(MediaContract.class, MediaExceptionProcessor.class); - registry.add(MediaExceptionProcessor.class); registry.add(MediaRestProxy.class); registry.add(OAuthContract.class, OAuthRestProxy.class); registry.add(OAuthTokenManager.class); @@ -53,8 +51,6 @@ public void register(Builder.Registry registry) { registry.add(RedirectFilter.class); registry.add(VersionHeadersFilter.class); - registry.add(MediaEntityContract.class, MediaEntityRestProxy.class); - registry.alter(ClientConfig.class, new Builder.Alteration<ClientConfig>() { @Override public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Object> properties) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 8a9244ccb35ec..9680009a1507e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -12,270 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.microsoft.windowsazure.services.media; -import java.util.EnumSet; +package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; -import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; -import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; /** - * Defines the methods available for Windows Azure Media Services. + * Contract for interacting with the back end of Media Services + * */ -public interface MediaContract extends FilterableService<MediaContract> { - - /** - * Creates the asset. - * - * @return the asset info - * @throws ServiceException - * the service exception - */ - public AssetInfo createAsset() throws ServiceException; - - /** - * Creates the asset. - * - * @param createAssetOptions - * the create asset options - * @return the asset info - * @throws ServiceException - * the service exception - */ - public AssetInfo createAsset(CreateAssetOptions createAssetOptions) throws ServiceException; - - /** - * Delete asset. - * - * @param assetId - * the asset id - * @throws ServiceException - * the service exception - */ - public void deleteAsset(String assetId) throws ServiceException; - - /** - * Gets the asset. - * - * @param assetId - * the asset id - * @return the asset - * @throws ServiceException - * the service exception - */ - public AssetInfo getAsset(String assetId) throws ServiceException; - - /** - * List assets. - * - * @return the list - * @throws ServiceException - * the service exception - */ - public ListResult<AssetInfo> listAssets() throws ServiceException; - - /** - * List assets. - * - * @param listAssetsOptions - * the list assets options - * @return the list - * @throws ServiceException - * the service exception - */ - public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException; - - /** - * Update asset. - * - * @param assetId - * the asset id - * @param updateAssetOptions - * the update asset options - * @throws ServiceException - * the service exception - */ - public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException; - - /** - * Create the access policy. - * - * @param accessPolicyName - * name of access policy - * @param durationInMinutes - * Duration in minutes that blob access will be granted when using this access policy - * @param permissions - * Permissions that the access policy should grant. - * @return Created access policy - * @throws ServiceException - * the service exception - */ - AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - EnumSet<AccessPolicyPermission> permissions) throws ServiceException; - - /** - * Delete the access policy with the given id. - * - * @param accessPolicyId - * of access policy to delete - * @throws ServiceException - * the service exception - */ - void deleteAccessPolicy(String accessPolicyId) throws ServiceException; - - /** - * Get a single access policy. - * - * @param accessPolicyId - * the id of the asset to retrieve - * @return the asset - * @throws ServiceException - * the service exception - */ - AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException; - - /** - * List access policies. - * - * @return the list - * @throws ServiceException - * the service exception - */ - ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException; - - /** - * List access policies. - * - * @param options - * the list access policy options - * @return the list - * @throws ServiceException - * the service exception - */ - ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException; - - /** - * Creates the locator. - * - * @param accessPolicyId - * the access policy id - * @param assetId - * the asset id - * @param locatorType - * the locator type - * @return the locator info - * @throws ServiceException - * the service exception - */ - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType) - throws ServiceException; - - /** - * Creates the locator. - * - * @param accessPolicyId - * the access policy id - * @param assetId - * the asset id - * @param locatorType - * the locator type - * @param createLocatorOptions - * the create locator options - * @return the locator info - * @throws ServiceException - * the service exception - */ - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, - CreateLocatorOptions createLocatorOptions) throws ServiceException; - - /** - * Gets the locator. - * - * @param locatorId - * the locator id - * @return the locator - * @throws ServiceException - * the service exception - */ - public LocatorInfo getLocator(String locatorId) throws ServiceException; - - /** - * List locators. - * - * @return the list locators result - * @throws ServiceException - * the service exception - */ - public ListResult<LocatorInfo> listLocators() throws ServiceException; - - /** - * Delete locator. - * - * @param locatorId - * the id - * - * @throws ServiceException - * the service exception - */ - public void deleteLocator(String locatorId) throws ServiceException; - - /** - * List locators. - * - * @param listLocatorOptions - * the list locator options - * @return the list locators result - * @throws ServiceException - * the service exception - */ - public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorOptions) throws ServiceException; - - /** - * Update locator. - * - * @param locatorId - * the locator id - * @param updateLocatorOptions - * the update locator options - * @throws ServiceException - * the service exception - */ - public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException; - - /** - * List media processors. - * - * @return the list media processors result - * @throws ServiceException - * the service exception - */ - public ListResult<MediaProcessorInfo> listMediaProcessors() throws ServiceException; - - /** - * List media processors. - * - * @param listMediaProcessorsOptions - * the list media processors options - * @return the list media processors result - * @throws ServiceException - * the service exception - */ - public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) - throws ServiceException; - +public interface MediaContract extends FilterableService<MediaContract>, EntityContract { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java deleted file mode 100644 index 28ade12b713e1..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaEntityContract.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media; - -import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; - -/** - * Contract for interacting with the back end of Media Services - * - */ -public interface MediaEntityContract extends FilterableService<MediaEntityContract>, EntityContract { -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java deleted file mode 100644 index feb2f3a556735..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaEntityRestProxy.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.implementation; - -import java.util.Arrays; - -import javax.inject.Inject; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.media.MediaEntityContract; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; -import com.sun.jersey.api.client.Client; - -/** - * - * - */ -public class MediaEntityRestProxy extends EntityRestProxy implements MediaEntityContract { - /** The log. */ - static Log log = LogFactory.getLog(MediaEntityContract.class); - - /** - * Instantiates a new media rest proxy. - * - * @param channel - * the channel - * @param authFilter - * the auth filter - * @param redirectFilter - * the redirect filter - * @param versionHeadersFilter - * the version headers filter - */ - @Inject - public MediaEntityRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, - VersionHeadersFilter versionHeadersFilter) { - super(channel, new ServiceFilter[0]); - - channel.addFilter(redirectFilter); - channel.addFilter(authFilter); - channel.addFilter(versionHeadersFilter); - } - - /** - * Instantiates a new media rest proxy. - * - * @param channel - * the channel - * @param filters - * the filters - */ - private MediaEntityRestProxy(Client channel, ServiceFilter[] filters) { - super(channel, filters); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.core.FilterableService#withFilter(com.microsoft.windowsazure.services.core.ServiceFilter) - */ - @Override - public MediaEntityContract withFilter(ServiceFilter filter) { - ServiceFilter[] filters = getFilters(); - ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); - newFilters[filters.length] = filter; - return new MediaEntityRestProxy(getChannel(), newFilters); - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 0a7253cc4162c..0818049ac61fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.util.EnumSet; - import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -26,36 +24,25 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; -import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; -import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; /** - * Wrapper implementation of <code>MediaServicesContract</code> that + * /** + * Wrapper implementation of <code>MediaEntityContract</code> that * translates exceptions into ServiceExceptions. * */ public class MediaExceptionProcessor implements MediaContract { - /** The service. */ private final MediaContract service; - - /** The log. */ - static Log log = LogFactory.getLog(MediaContract.class); + private static Log log = LogFactory.getLog(MediaContract.class); /** * Instantiates a new media exception processor. @@ -99,205 +86,12 @@ private ServiceException processCatch(ServiceException e) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() - */ - @Override - public AssetInfo createAsset() throws ServiceException { - try { - return service.createAsset(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) - */ - @Override - public AssetInfo createAsset(CreateAssetOptions createAssetOptions) throws ServiceException { - try { - return service.createAsset(createAssetOptions); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) - */ - @Override - public void deleteAsset(String assetId) throws ServiceException { - try { - service.deleteAsset(assetId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAsset(java.lang.String) - */ - @Override - public AssetInfo getAsset(String assetId) throws ServiceException { - try { - return service.getAsset(assetId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() - */ - @Override - public ListResult<AssetInfo> listAssets() throws ServiceException { - try { - return service.listAssets(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) - */ - @Override - public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) throws ServiceException { - try { - return service.listAssets(listAssetsOptions); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) - */ - @Override - public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { - try { - service.updateAsset(assetId, updateAssetOptions); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double) - */ - @Override - public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - EnumSet<AccessPolicyPermission> permissions) throws ServiceException { - try { - return service.createAccessPolicy(accessPolicyName, durationInMinutes, permissions); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicies() - */ - @Override - public ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException { - try { - return service.listAccessPolicies(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) - */ - @Override - public void deleteAccessPolicy(String accessPolicyId) throws ServiceException { - try { - service.deleteAccessPolicy(accessPolicyId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) - */ - @Override - public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException { - try { - return service.getAccessPolicy(accessPolicyId); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies(com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions) - */@Override - public ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { - try { - return service.listAccessPolicies(options); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType, com.microsoft.windowsazure.services.media.models.CreateLocatorOptions) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation) */ @Override - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, - CreateLocatorOptions createLocatorOptions) throws ServiceException { + public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { try { - return service.createLocator(accessPolicyId, assetId, locatorType, createLocatorOptions); + return service.create(creator); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -308,12 +102,12 @@ public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorT } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getLocator(java.lang.String) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation) */ @Override - public LocatorInfo getLocator(String locatorId) throws ServiceException { + public <T> T get(EntityGetOperation<T> getter) throws ServiceException { try { - return service.getLocator(locatorId); + return service.get(getter); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -324,12 +118,12 @@ public LocatorInfo getLocator(String locatorId) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteLocator(java.lang.String) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation) */ @Override - public void deleteLocator(String locatorId) throws ServiceException { + public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { try { - service.deleteLocator(locatorId); + return service.list(lister); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -340,12 +134,12 @@ public void deleteLocator(String locatorId) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#updateLocator(java.lang.String, com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#update(com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation) */ @Override - public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException { + public void update(EntityUpdateOperation updater) throws ServiceException { try { - service.updateLocator(locatorId, updateLocatorOptions); + service.update(updater); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -357,12 +151,12 @@ public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOp } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#delete(com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation) */ @Override - public ListResult<LocatorInfo> listLocators() throws ServiceException { + public void delete(EntityDeleteOperation deleter) throws ServiceException { try { - return service.listLocators(); + service.delete(deleter); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); @@ -372,70 +166,4 @@ public ListResult<LocatorInfo> listLocators() throws ServiceException { } } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators(com.microsoft.windowsazure.services.media.models.ListLocatorsOptions) - */ - @Override - public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorsOptions) throws ServiceException { - try { - return service.listLocators(listLocatorsOptions); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType) - */ - @Override - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType) - throws ServiceException { - try { - return service.createLocator(accessPolicyId, assetId, locatorType); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() - */ - @Override - public ListResult<MediaProcessorInfo> listMediaProcessors() throws ServiceException { - try { - return service.listMediaProcessors(); - } - catch (UniformInterfaceException e) { - throw processCatch(new ServiceException(e)); - } - catch (ClientHandlerException e) { - throw processCatch(new ServiceException(e)); - } - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) - */ - @Override - public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) - throws ServiceException { - try { - return service.listMediaProcessors(listMediaProcessorsOptions); - } - 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 883c7fbc0e1af..b4b146b58a98b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,60 +15,25 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import java.util.Arrays; -import java.util.EnumSet; import javax.inject.Inject; -import javax.ws.rs.core.MediaType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.microsoft.windowsazure.services.media.implementation.content.AssetType; -import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; -import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; -import com.microsoft.windowsazure.services.media.models.ListOptions; -import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; -import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.GenericType; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.client.WebResource; -// TODO: Auto-generated Javadoc /** - * The Class MediaRestProxy. + * + * */ -public class MediaRestProxy implements MediaContract { - - /** The channel. */ - private Client channel; - +public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); - /** The filters. */ - ServiceFilter[] filters; /** * Instantiates a new media rest proxy. @@ -85,8 +50,7 @@ public class MediaRestProxy implements MediaContract { @Inject public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, VersionHeadersFilter versionHeadersFilter) { - this.channel = channel; - this.filters = new ServiceFilter[0]; + super(channel, new ServiceFilter[0]); channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -101,9 +65,8 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red * @param filters * the filters */ - public MediaRestProxy(Client channel, ServiceFilter[] filters) { - this.channel = channel; - this.filters = filters; + private MediaRestProxy(Client channel, ServiceFilter[] filters) { + super(channel, filters); } /* (non-Javadoc) @@ -111,352 +74,9 @@ public MediaRestProxy(Client channel, ServiceFilter[] filters) { */ @Override public MediaContract withFilter(ServiceFilter filter) { + ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new MediaRestProxy(channel, newFilters); - } - - /** - * Gets the channel. - * - * @return the channel - */ - public Client getChannel() { - return channel; - } - - /** - * Sets the channel. - * - * @param channel - * the new channel - */ - public void setChannel(Client channel) { - this.channel = channel; - } - - /** - * Gets the resource. - * - * @param entityName - * the entity name - * @return the resource - */ - private WebResource getResource(String entityName) { - WebResource resource = getChannel().resource(entityName); - for (ServiceFilter filter : filters) { - resource.addFilter(new ClientFilterAdapter(filter)); - } - return resource; + return new MediaRestProxy(getChannel(), newFilters); } - - private WebResource getResource(String entityName, ListOptions options) { - WebResource resource = getResource(entityName); - if (options != null) { - resource = resource.queryParams(options.getQueryParameters()); - } - return resource; - } - - /** - * Gets the resource. - * - * @param entityType - * the entity type - * @param entityId - * the entity id - * @return the resource - * @throws ServiceException - * the service exception - */ - private WebResource getResource(String entityType, String entityId) throws ServiceException { - String escapedEntityId = null; - try { - escapedEntityId = URLEncoder.encode(entityId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new ServiceException(e); - } - String entityPath = String.format("%s(\'%s\')", entityType, escapedEntityId); - - return getResource(entityPath); - } - - /** - * Merge request. - * - * @param <T> - * the generic type - * @param entityType - * the entity type - * @param entityId - * the entity id - * @param c - * the c - * @param requestEntity - * the request entity - * @return the t - * @throws ServiceException - * the service exception - */ - private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T> c, java.lang.Object requestEntity) - throws ServiceException { - WebResource resource = getResource(entityType, entityId); - WebResource.Builder builder = resource.getRequestBuilder(); - builder = builder.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .header("X-HTTP-Method", "MERGE"); - return builder.post(c, requestEntity); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() - */ - @Override - public AssetInfo createAsset() { - return this.createAsset(null); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset(java.lang.String, com.microsoft.windowsazure.services.media.models.CreateAssetOptions) - */ - @Override - public AssetInfo createAsset(CreateAssetOptions createAssetOptions) { - WebResource resource = getResource("Assets"); - AssetType assetTypeForSubmission = new AssetType(); - if (createAssetOptions != null) { - assetTypeForSubmission.setName(createAssetOptions.getName()); - assetTypeForSubmission.setAlternateId(createAssetOptions.getAlternateId()); - - if (createAssetOptions.getOptions() != null) { - assetTypeForSubmission.setOptions(createAssetOptions.getOptions().getCode()); - } - if (createAssetOptions.getState() != null) { - assetTypeForSubmission.setState(createAssetOptions.getState().getCode()); - } - } - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(AssetInfo.class, assetTypeForSubmission); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAsset(java.lang.String) - */ - @Override - public AssetInfo getAsset(String assetId) throws ServiceException { - WebResource resource = getResource("Assets", assetId); - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(AssetInfo.class); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets(com.microsoft.windowsazure.services.media.models.ListAssetsOptions) - */ - @Override - public ListResult<AssetInfo> listAssets(ListAssetsOptions listAssetsOptions) { - WebResource resource = getResource("Assets", listAssetsOptions); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<ListResult<AssetInfo>>() { - }); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAssets() - */ - @Override - public ListResult<AssetInfo> listAssets() { - ListAssetsOptions listAssetsOptions = new ListAssetsOptions(); - return listAssets(listAssetsOptions); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#updateAsset(com.microsoft.windowsazure.services.media.models.AssetInfo) - */ - @Override - public void updateAsset(String assetId, UpdateAssetOptions updateAssetOptions) throws ServiceException { - - AssetType updatedAssetType = new AssetType(); - updatedAssetType.setAlternateId(updateAssetOptions.getAlternateId()); - updatedAssetType.setName(updateAssetOptions.getName()); - - ClientResponse clientResponse = mergeRequest("Assets", assetId, ClientResponse.class, updatedAssetType); - PipelineHelpers.ThrowIfNotSuccess(clientResponse); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAsset(java.lang.String) - */ - @Override - public void deleteAsset(String assetId) throws ServiceException { - getResource("Assets", assetId).delete(); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createAccessPolicy(double, com.microsoft.windowsazure.services.media.models.CreateAccessPolicyOptions) - */ - @Override - public AccessPolicyInfo createAccessPolicy(String accessPolicyName, double durationInMinutes, - EnumSet<AccessPolicyPermission> permissions) throws ServiceException { - - AccessPolicyType requestData = new AccessPolicyType().setDurationInMinutes(durationInMinutes) - .setName(accessPolicyName).setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); - - WebResource resource = getResource("AccessPolicies"); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(AccessPolicyInfo.class, requestData); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getAccessPolicy(java.lang.String) - */ - @Override - public AccessPolicyInfo getAccessPolicy(String accessPolicyId) throws ServiceException { - WebResource resource = getResource("AccessPolicies", accessPolicyId); - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(AccessPolicyInfo.class); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteAccessPolicy(java.lang.String) - */ - @Override - public void deleteAccessPolicy(String accessPolicyId) throws ServiceException { - getResource("AccessPolicies", accessPolicyId).delete(); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() - */ - @Override - public ListResult<AccessPolicyInfo> listAccessPolicies() throws ServiceException { - return listAccessPolicies(null); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listAccessPolicies() - */ - @Override - public ListResult<AccessPolicyInfo> listAccessPolicies(ListAccessPolicyOptions options) throws ServiceException { - WebResource resource = getResource("AccessPolicies", options); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<ListResult<AccessPolicyInfo>>() { - }); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType) - */ - @Override - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType) { - return this.createLocator(accessPolicyId, assetId, locatorType, null); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#createLocator(java.lang.String, java.lang.String, com.microsoft.windowsazure.services.media.models.LocatorType, com.microsoft.windowsazure.services.media.models.CreateLocatorOptions) - */ - @Override - public LocatorInfo createLocator(String accessPolicyId, String assetId, LocatorType locatorType, - CreateLocatorOptions createLocatorOptions) { - - LocatorRestType locatorRestType = new LocatorRestType(); - locatorRestType.setAccessPolicyId(accessPolicyId); - locatorRestType.setAssetId(assetId); - locatorRestType.setType(locatorType.getCode()); - if (createLocatorOptions != null) { - if (createLocatorOptions.getExpirationDateTime() != null) { - locatorRestType.setExpirationDateTime(createLocatorOptions.getExpirationDateTime()); - } - - if (createLocatorOptions.getStartTime() != null) { - locatorRestType.setStartTime(createLocatorOptions.getStartTime()); - } - } - - WebResource resource = getResource("Locators"); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .post(LocatorInfo.class, locatorRestType); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getLocator(java.lang.String) - */ - @Override - public LocatorInfo getLocator(String locatorId) throws ServiceException { - WebResource resource = getResource("Locators", locatorId); - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(LocatorInfo.class); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators() - */ - @Override - public ListResult<LocatorInfo> listLocators() { - return listLocators(null); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listLocators(com.microsoft.windowsazure.services.media.models.ListLocatorsOptions) - */ - @Override - public ListResult<LocatorInfo> listLocators(ListLocatorsOptions listLocatorOptions) { - WebResource resource = getResource("Locators", listLocatorOptions); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<ListResult<LocatorInfo>>() { - }); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#deleteLocator(java.lang.String) - */ - @Override - public void deleteLocator(String locatorId) throws UniformInterfaceException, ServiceException { - getResource("Locators", locatorId).delete(); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#updateLocator(java.lang.String, com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions) - */ - @Override - public void updateLocator(String locatorId, UpdateLocatorOptions updateLocatorOptions) throws ServiceException { - LocatorRestType updatedLocatorRestType = new LocatorRestType(); - - updatedLocatorRestType.setId(locatorId); - if (updateLocatorOptions != null) { - if (updateLocatorOptions.getExpirationDateTime() != null) { - updatedLocatorRestType.setExpirationDateTime(updateLocatorOptions.getExpirationDateTime()); - } - if (updateLocatorOptions.getStartTime() != null) { - updatedLocatorRestType.setStartTime(updateLocatorOptions.getStartTime()); - } - } - ClientResponse clientResponse = mergeRequest("Locators", locatorId, ClientResponse.class, - updatedLocatorRestType); - PipelineHelpers.ThrowIfNotSuccess(clientResponse); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors() - */ - @Override - public ListResult<MediaProcessorInfo> listMediaProcessors() { - return this.listMediaProcessors(null); - } - - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#listMediaProcessors(com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions) - */ - @Override - public ListResult<MediaProcessorInfo> listMediaProcessors(ListMediaProcessorsOptions listMediaProcessorsOptions) { - WebResource resource = getResource("MediaProcessors", listMediaProcessorsOptions); - - return resource.type(MediaType.APPLICATION_ATOM_XML).accept(MediaType.APPLICATION_ATOM_XML) - .get(new GenericType<ListResult<MediaProcessorInfo>>() { - }); - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index e43f7fcd6a372..172470300362e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -49,6 +49,8 @@ public static class Creator extends EntityOperationSingleResultBase<AssetInfo> i EntityCreationOperation<AssetInfo> { private String name; private String alternateId; + private EncryptionOption options; + private AssetState state; public Creator() { super(ENTITY_SET, AssetInfo.class); @@ -59,6 +61,12 @@ public Object getRequestContents() { AssetType assetType = new AssetType(); assetType.setName(name); assetType.setAlternateId(alternateId); + if (options != null) { + assetType.setOptions(options.getCode()); + } + if (state != null) { + assetType.setState(state.getCode()); + } return assetType; } @@ -86,6 +94,16 @@ public Creator setAlternateId(String alternateId) { this.alternateId = alternateId; return this; } + + public Creator setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + public Creator setState(AssetState state) { + this.state = state; + return this; + } } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java deleted file mode 100644 index 86b6773a58d1d..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptions.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class CreateAssetOptions. - */ -public class CreateAssetOptions { - - /** The name. */ - private String name; - - /** The alternate id. */ - private String alternateId; - - /** The options. */ - private EncryptionOption options; - - /** The state. */ - private AssetState state; - - /** - * Gets the alternate id. - * - * @return the alternate id - */ - public String getAlternateId() { - return alternateId; - } - - /** - * Sets the alternate id. - * - * @param alternateId - * the alternate id - * @return the creates the asset options - */ - public CreateAssetOptions setAlternateId(String alternateId) { - this.alternateId = alternateId; - return this; - } - - /** - * Gets the options. - * - * @return the options - */ - public EncryptionOption getOptions() { - return options; - } - - /** - * Sets the options. - * - * @param encryptionOption - * the encryption option - * @return the creates the asset options - */ - public CreateAssetOptions setOptions(EncryptionOption encryptionOption) { - this.options = encryptionOption; - return this; - } - - /** - * Gets the state. - * - * @return the state - */ - public AssetState getState() { - return state; - } - - /** - * Sets the state. - * - * @param assetState - * the asset state - * @return the creates the asset options - */ - public CreateAssetOptions setState(AssetState assetState) { - this.state = assetState; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param name - * the name - * @return the creates the asset options - */ - public CreateAssetOptions setName(String name) { - this.name = name; - return this; - } - -} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java deleted file mode 100644 index 1ee60ca01bf0b..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateLocatorOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -/** - * The Class CreateLocatorOptions. - */ -public class CreateLocatorOptions { - - /** The expiration date time. */ - private Date expirationDateTime; - - /** The start time. */ - private Date startTime; - - /** - * Gets the expiration date time. - * - * @return the expiration date time - */ - public Date getExpirationDateTime() { - return expirationDateTime; - } - - /** - * Sets the expiration date time. - * - * @param expirationDateTime - * the expiration date time - * @return the creates the locator options - */ - public CreateLocatorOptions setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the creates the locator options - */ - public CreateLocatorOptions setStartTime(Date startTime) { - this.startTime = startTime; - return this; - } - -} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java deleted file mode 100644 index ca8bd29ab984a..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAccessPolicyOptions.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -/** - * Options class for listing access policies - * No options available at this time. - */ -public class ListAccessPolicyOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java deleted file mode 100644 index 33cacc6d30191..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListAssetsOptions.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -public class ListAssetsOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java deleted file mode 100644 index c5129f9cd0695..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListLocatorsOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class ListLocatorsOptions. - */ -public class ListLocatorsOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java deleted file mode 100644 index 1e580ab757945..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class ListLocatorsOptions. - */ -public class ListMediaProcessorsOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java deleted file mode 100644 index 57143bfc179d2..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListOptions.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import javax.ws.rs.core.MultivaluedMap; - -import com.sun.jersey.core.util.MultivaluedMapImpl; - -/** - * The Class ListOptions. - */ -public class ListOptions { - - /** - * Instantiates a new list options. - */ - public ListOptions() { - this.queryParameters = new MultivaluedMapImpl(); - } - - /** The query parameters. */ - private final MultivaluedMap<String, String> queryParameters; - - /** - * Gets the query parameters. - * - * @return the query parameters - */ - public MultivaluedMap<String, String> getQueryParameters() { - return this.queryParameters; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java deleted file mode 100644 index 559a01d2eebdb..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptions.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class UpdateAssetOptions. - */ -public class UpdateAssetOptions { - - /** The alternate id. */ - private String alternateId; - - /** The name. */ - private String name; - - /** - * Gets the alternate id. - * - * @return the alternate id - */ - public String getAlternateId() { - return alternateId; - } - - /** - * Sets the alternate id. - * - * @param alternateId - * the alternate id - * @return the update asset options - */ - public UpdateAssetOptions setAlternateId(String alternateId) { - this.alternateId = alternateId; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets the name. - * - * @param name - * the name - * @return the update asset options - */ - public UpdateAssetOptions setName(String name) { - this.name = name; - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java deleted file mode 100644 index 4f9ec645b1c47..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/UpdateLocatorOptions.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -/** - * The Class UpdateLocatorOptions. - */ -public class UpdateLocatorOptions { - - /** The expiration date time. */ - private Date expirationDateTime; - - /** The start time. */ - private Date startTime; - - /** - * Gets the expiration date time. - * - * @return the expiration date time - */ - public Date getExpirationDateTime() { - return expirationDateTime; - } - - /** - * Sets the expiration date time. - * - * @param expirationDateTime - * the expiration date time - * @return the creates the locator options - */ - public UpdateLocatorOptions setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the creates the locator options - */ - public UpdateLocatorOptions setStartTime(Date startTime) { - this.startTime = startTime; - return this; - } - -} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 2510f26976702..f7de5b1026065 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -21,14 +21,17 @@ import java.util.EnumSet; import java.util.List; +import javax.ws.rs.core.MultivaluedMap; + import org.junit.Test; import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; import com.microsoft.windowsazure.services.core.RetryPolicyFilter; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.microsoft.windowsazure.services.media.models.ListAccessPolicyOptions; +import com.sun.jersey.core.util.MultivaluedMapImpl; public class AccessPolicyIntegrationTest extends IntegrationTestBase { private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) { @@ -65,8 +68,8 @@ public void canCreateAccessPolicy() throws Exception { String testName = testPolicyPrefix + "CanCreate"; double duration = 5; - AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, - EnumSet.of(AccessPolicyPermission.WRITE)); + AccessPolicyInfo policy = service.create(AccessPolicy.create(testName, duration, + EnumSet.of(AccessPolicyPermission.WRITE))); verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.WRITE, policy); } @@ -76,8 +79,8 @@ public void canCreateAccessPolicyWithReadPermissions() throws Exception { String testName = testPolicyPrefix + "CanCreateRead"; double duration = 5; - AccessPolicyInfo policy = service.createAccessPolicy(testName, duration, - EnumSet.of(AccessPolicyPermission.READ)); + AccessPolicyInfo policy = service.create(AccessPolicy.create(testName, duration, + EnumSet.of(AccessPolicyPermission.READ))); verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.READ, policy); } @@ -88,10 +91,10 @@ public void canCreateAccessPolicyWithReadPermissions() throws Exception { public void canGetSinglePolicyById() throws Exception { String expectedName = testPolicyPrefix + "GetOne"; double duration = 1; - AccessPolicyInfo policyToGet = service.createAccessPolicy(expectedName, duration, - EnumSet.of(AccessPolicyPermission.WRITE)); + AccessPolicyInfo policyToGet = service.create(AccessPolicy.create(expectedName, duration, + EnumSet.of(AccessPolicyPermission.WRITE))); - AccessPolicyInfo retrievedPolicy = service.getAccessPolicy(policyToGet.getId()); + AccessPolicyInfo retrievedPolicy = service.get(AccessPolicy.get(policyToGet.getId())); assertEquals(policyToGet.getId(), retrievedPolicy.getId()); verifyPolicyProperties("retrievedPolicy", expectedName, duration, AccessPolicyPermission.WRITE, retrievedPolicy); @@ -101,14 +104,14 @@ public void canGetSinglePolicyById() throws Exception { public void canGetSinglePolicyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); - service.getAccessPolicy(invalidId); + service.get(AccessPolicy.get(invalidId)); } @Test public void canGetSinglePolicyByNonexistId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAccessPolicy(validButNonexistAccessPolicyId); + service.get(AccessPolicy.get(validButNonexistAccessPolicyId)); } @Test @@ -120,11 +123,11 @@ public void canRetrieveListOfAccessPolicies() throws Exception { List<AccessPolicyInfo> expectedAccessPolicies = new ArrayList<AccessPolicyInfo>(); for (int i = 0; i < policyNames.length; i++) { - AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, permissions); + AccessPolicyInfo policy = service.create(AccessPolicy.create(policyNames[i], duration, permissions)); expectedAccessPolicies.add(policy); } - List<AccessPolicyInfo> actualAccessPolicies = service.listAccessPolicies(); + List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list()); verifyListResultContains("listAccessPolicies", expectedAccessPolicies, actualAccessPolicies, new ComponentDelegate() { @@ -146,14 +149,14 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { List<AccessPolicyInfo> expectedAccessPolicies = new ArrayList<AccessPolicyInfo>(); for (int i = 0; i < policyNames.length; i++) { - AccessPolicyInfo policy = service.createAccessPolicy(policyNames[i], duration, permissions); + AccessPolicyInfo policy = service.create(AccessPolicy.create(policyNames[i], duration, permissions)); expectedAccessPolicies.add(policy); } - ListAccessPolicyOptions options = new ListAccessPolicyOptions(); - options.getQueryParameters().add("$top", "2"); + MultivaluedMap<String, String> options = new MultivaluedMapImpl(); + options.add("$top", "2"); - List<AccessPolicyInfo> actualAccessPolicies = service.listAccessPolicies(options); + List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list(options)); assertEquals(2, actualAccessPolicies.size()); } @@ -164,37 +167,37 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { public void canDeleteAccessPolicyById() throws Exception { String policyName = testPolicyPrefix + "ToDelete"; double duration = 1; - AccessPolicyInfo policyToDelete = service.createAccessPolicy(policyName, duration, - EnumSet.of(AccessPolicyPermission.WRITE)); - List<AccessPolicyInfo> listPoliciesResult = service.listAccessPolicies(); + AccessPolicyInfo policyToDelete = service.create(AccessPolicy.create(policyName, duration, + EnumSet.of(AccessPolicyPermission.WRITE))); + List<AccessPolicyInfo> listPoliciesResult = service.list(AccessPolicy.list()); int policyCountBaseline = listPoliciesResult.size(); - service.deleteAccessPolicy(policyToDelete.getId()); + service.delete(AccessPolicy.delete(policyToDelete.getId())); - listPoliciesResult = service.listAccessPolicies(); + listPoliciesResult = service.list(AccessPolicy.list()); assertEquals("listPoliciesResult.size", policyCountBaseline - 1, listPoliciesResult.size()); - for (AccessPolicyInfo policy : service.listAccessPolicies()) { + for (AccessPolicyInfo policy : service.list(AccessPolicy.list())) { assertFalse(policyToDelete.getId().equals(policy.getId())); } expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAccessPolicy(policyToDelete.getId()); + service.get(AccessPolicy.get(policyToDelete.getId())); } @Test public void canDeleteAccessPolicyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); - service.deleteAccessPolicy(invalidId); + service.delete(AccessPolicy.delete(invalidId)); } @Test public void canDeleteAccessPolicyByNonexistId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.deleteAccessPolicy(validButNonexistAccessPolicyId); + service.delete(AccessPolicy.delete(validButNonexistAccessPolicyId)); } @Test @@ -202,11 +205,11 @@ public void canRetryAccessPolicyCreation() throws Exception { String name = testPolicyPrefix + "canRetryAccessPolicyCreationPolicy"; double duration = 1; EnumSet<AccessPolicyPermission> write = EnumSet.of(AccessPolicyPermission.WRITE); - service.createAccessPolicy(name + "1", duration, write); + service.create(AccessPolicy.create(name + "1", duration, write)); ExponentialRetryPolicy forceRetryPolicy = new ExponentialRetryPolicy(1, 1, new int[] { 201 }); MediaContract forceRetryService = service.withFilter(new RetryPolicyFilter(forceRetryPolicy)); - forceRetryService.createAccessPolicy(name + "2", duration, write); + forceRetryService.create(AccessPolicy.create(name + "2", duration, write)); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index e0d0f304557ee..e76056ba44a5d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -25,12 +25,11 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; -import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; +import com.sun.jersey.core.util.MultivaluedMapImpl; public class AssetIntegrationTest extends IntegrationTestBase { @@ -70,11 +69,10 @@ public void createAssetOptionsSuccess() throws Exception { String altId = "altId"; EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(testName); // Act - AssetInfo actualAsset = service.createAsset(options); + AssetInfo actualAsset = service.create(Asset.create().setAlternateId(altId).setOptions(encryptionOption) + .setState(assetState).setName(testName)); // Assert verifyAssetProperties("actualAsset", testName, altId, encryptionOption, assetState, actualAsset); @@ -88,10 +86,9 @@ public void createAssetMeanString() throws Exception { + "Some unicode: \uB2E4\uB974\uB2E4\uB294\u0625 \u064A\u062F\u064A\u0648\u0009\r\n"; String testName = testAssetPrefix + "createAssetMeanString" + meanString; - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(testName); // Act - AssetInfo actualAsset = service.createAsset(createAssetOptions); + AssetInfo actualAsset = service.create(Asset.create().setName(testName)); // Assert assertEquals("actualAsset Name", testName, actualAsset.getName()); @@ -104,7 +101,7 @@ public void createAssetNullNameSuccess() throws Exception { // Act AssetInfo actualAsset = null; try { - actualAsset = service.createAsset(); + actualAsset = service.create(Asset.create()); // Assert verifyAssetProperties("actualAsset", "", "", EncryptionOption.None, AssetState.Initialized, actualAsset); } @@ -113,7 +110,7 @@ public void createAssetNullNameSuccess() throws Exception { // do not want to delete all anonymous assets in the bulk-cleanup code. try { if (actualAsset != null) { - service.deleteAsset(actualAsset.getId()); + service.delete(Asset.delete(actualAsset.getId())); } } catch (ServiceException ex) { @@ -129,12 +126,12 @@ public void getAssetSuccess() throws Exception { String altId = "altId"; EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(testName); - AssetInfo assetInfo = service.createAsset(options); + + AssetInfo assetInfo = service.create(Asset.create().setName(testName).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState)); // Act - AssetInfo actualAsset = service.getAsset(assetInfo.getId()); + AssetInfo actualAsset = service.get(Asset.get(assetInfo.getId())); // Assert verifyInfosEqual("actualAsset", assetInfo, actualAsset); @@ -144,14 +141,14 @@ public void getAssetSuccess() throws Exception { public void getAssetInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); - service.getAsset(invalidId); + service.get(Asset.get(invalidId)); } @Test public void getAssetNonexistId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(validButNonexistAssetId); + service.get(Asset.get(validButNonexistAssetId)); } @Test @@ -165,13 +162,12 @@ public void listAssetSuccess() throws ServiceException { List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); for (int i = 0; i < assetNames.length; i++) { String name = assetNames[i]; - CreateAssetOptions options = new CreateAssetOptions().setName(name).setAlternateId(altId) - .setOptions(encryptionOption).setState(assetState); - expectedAssets.add(service.createAsset(options)); + expectedAssets.add(service.create(Asset.create().setName(name).setAlternateId(altId) + .setOptions(encryptionOption).setState(assetState))); } // Act - Collection<AssetInfo> listAssetResult = service.listAssets(); + Collection<AssetInfo> listAssetResult = service.list(Asset.list()); // Assert @@ -191,13 +187,12 @@ public void canListAssetsWithOptions() throws ServiceException { List<AssetInfo> expectedAssets = new ArrayList<AssetInfo>(); for (int i = 0; i < assetNames.length; i++) { String name = assetNames[i]; - CreateAssetOptions options = new CreateAssetOptions().setName(name); - expectedAssets.add(service.createAsset(options)); + expectedAssets.add(service.create(Asset.create().setName(name))); } - ListAssetsOptions options = new ListAssetsOptions(); - options.getQueryParameters().add("$top", "2"); - Collection<AssetInfo> listAssetResult = service.listAssets(options); + MultivaluedMapImpl options = new MultivaluedMapImpl(); + options.add("$top", "2"); + Collection<AssetInfo> listAssetResult = service.list(Asset.list(options)); // Assert @@ -209,18 +204,16 @@ public void updateAssetSuccess() throws Exception { // Arrange String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; EncryptionOption originalEncryptionOption = EncryptionOption.StorageEncrypted; - AssetState originalAssetState = AssetState.Published; - CreateAssetOptions originalOptions = new CreateAssetOptions().setAlternateId("altId") - .setOptions(originalEncryptionOption).setState(originalAssetState).setName(originalTestName); - AssetInfo originalAsset = service.createAsset(originalOptions); + AssetState originalAssetState = AssetState.Initialized; + AssetInfo originalAsset = service.create(Asset.create().setName(originalTestName).setAlternateId("altId") + .setOptions(originalEncryptionOption)); String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated"; String altId = "otherAltId"; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions().setName(updatedTestName).setAlternateId(altId); // Act - service.updateAsset(originalAsset.getId(), updateAssetOptions); - AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); + service.update(Asset.update(originalAsset.getId()).setName(updatedTestName).setAlternateId(altId)); + AssetInfo updatedAsset = service.get(Asset.get(originalAsset.getId())); // Assert verifyAssetProperties("updatedAsset", updatedTestName, altId, originalEncryptionOption, originalAssetState, @@ -232,17 +225,11 @@ public void updateAssetNoChangesSuccess() throws Exception { // Arrange String originalTestName = testAssetPrefix + "updateAssetNoChangesSuccess"; String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; - AssetState assetState = AssetState.Published; - CreateAssetOptions options = new CreateAssetOptions().setAlternateId(altId).setOptions(encryptionOption) - .setState(assetState).setName(originalTestName); - AssetInfo originalAsset = service.createAsset(options); - - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); + AssetInfo originalAsset = service.create(Asset.create().setName(originalTestName).setAlternateId(altId)); // Act - service.updateAsset(originalAsset.getId(), updateAssetOptions); - AssetInfo updatedAsset = service.getAsset(originalAsset.getId()); + service.update(Asset.update(originalAsset.getId())); + AssetInfo updatedAsset = service.get(Asset.get(originalAsset.getId())); // Assert verifyInfosEqual("updatedAsset", originalAsset, updatedAsset); @@ -250,40 +237,35 @@ public void updateAssetNoChangesSuccess() throws Exception { @Test public void updateAssetFailedWithInvalidId() throws ServiceException { - // Arrange - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.updateAsset(validButNonexistAssetId, updateAssetOptions); + service.update(Asset.update(validButNonexistAssetId)); } @Test public void deleteAssetSuccess() throws Exception { // Arrange String assetName = testAssetPrefix + "deleteAssetSuccess"; - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(assetName); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - List<AssetInfo> listAssetsResult = service.listAssets(); + AssetInfo assetInfo = service.create(Asset.create().setName(assetName)); + List<AssetInfo> listAssetsResult = service.list(Asset.list()); int assetCountBaseline = listAssetsResult.size(); // Act - service.deleteAsset(assetInfo.getId()); + service.delete(Asset.delete(assetInfo.getId())); // Assert - listAssetsResult = service.listAssets(); + listAssetsResult = service.list(Asset.list()); assertEquals("listAssetsResult.size", assetCountBaseline - 1, listAssetsResult.size()); expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getAsset(assetInfo.getId()); + service.get(Asset.get(assetInfo.getId())); } @Test public void deleteAssetFailedWithInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.deleteAsset(validButNonexistAssetId); + service.delete(Asset.delete(validButNonexistAssetId)); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 98930fe7dd31c..11f3870db5c6d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -16,11 +16,11 @@ import com.sun.jersey.core.util.MultivaluedMapImpl; public class EntityProxyTest extends IntegrationTestBase { - private static MediaEntityContract entityService; + private static MediaContract entityService; @BeforeClass public static void entityProxyTestSetup() { - entityService = config.create(MediaEntityContract.class); + entityService = config.create(MediaContract.class); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index b648959504868..c86c008a556c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -14,9 +14,12 @@ import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; public abstract class IntegrationTestBase { @@ -44,6 +47,7 @@ public static void setup() throws Exception { overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); + // TODO: Replace with call to MediaService.create once that's updated service = MediaService.create(config); cleanupEnvironment(); @@ -73,10 +77,11 @@ private static void cleanupEnvironment() { private static void removeAllTestAccessPolicies() { try { - List<AccessPolicyInfo> policies = service.listAccessPolicies(); + List<AccessPolicyInfo> policies = service.list(AccessPolicy.list()); + for (AccessPolicyInfo policy : policies) { if (policy.getName().startsWith(testPolicyPrefix)) { - service.deleteAccessPolicy(policy.getId()); + service.delete(AccessPolicy.delete(policy.getId())); } } } @@ -87,10 +92,10 @@ private static void removeAllTestAccessPolicies() { private static void removeAllTestAssets() { try { - List<AssetInfo> listAssetsResult = service.listAssets(); + List<AssetInfo> listAssetsResult = service.list(Asset.list()); for (AssetInfo assetInfo : listAssetsResult) { if (assetInfo.getName().startsWith(testAssetPrefix)) { - service.deleteAsset(assetInfo.getId()); + service.delete(Asset.delete(assetInfo.getId())); } } } @@ -101,11 +106,11 @@ private static void removeAllTestAssets() { private static void removeAllTestLocators() { try { - ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); + ListResult<LocatorInfo> listLocatorsResult = service.list(Locator.list()); for (LocatorInfo locatorInfo : listLocatorsResult) { - AssetInfo ai = service.getAsset(locatorInfo.getAssetId()); + AssetInfo ai = service.get(Asset.get(locatorInfo.getAssetId())); if (ai.getName().startsWith(testAssetPrefix)) { - service.deleteLocator(locatorInfo.getId()); + service.delete(Locator.delete(locatorInfo.getId())); } } } @@ -174,8 +179,8 @@ protected void assertDateApproxEquals(String message, Date expected, Date actual // TODO: Remove this time-zone workaround when fixed: // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/413 if (diffInMilliseconds > deltaInMilliseconds) { - // Just hard-code time-zone offset of 7 hours for now. - diffInMilliseconds = Math.abs(diffInMilliseconds - 7 * 60 * 60 * 1000); + // Just hard-code time-zone offset of 8 hours for now. + diffInMilliseconds = Math.abs(diffInMilliseconds - 8 * 60 * 60 * 1000); } if (diffInMilliseconds > deltaInMilliseconds) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 7c336c8f02798..2a2d7be24c7f2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -28,16 +28,16 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; -import com.microsoft.windowsazure.services.media.models.ListLocatorsOptions; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; +import com.sun.jersey.core.util.MultivaluedMapImpl; public class LocatorIntegrationTests extends IntegrationTestBase { @@ -92,15 +92,15 @@ private void verifyLocatorProperties(String message, String accessPolicyId, Stri @BeforeClass public static void setup() throws Exception { IntegrationTestBase.setup(); - accessPolicyInfo = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTest", 5, - EnumSet.of(AccessPolicyPermission.WRITE)); - accessPolicyInfoRead = service.createAccessPolicy(testPolicyPrefix + "ForLocatorTestRead", 15, - EnumSet.of(AccessPolicyPermission.READ)); + accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + "ForLocatorTest", 5, + EnumSet.of(AccessPolicyPermission.WRITE))); + accessPolicyInfoRead = service.create(AccessPolicy.create(testPolicyPrefix + "ForLocatorTestRead", 15, + EnumSet.of(AccessPolicyPermission.READ))); } @Before public void instanceSetup() throws Exception { - assetInfo = service.createAsset(new CreateAssetOptions().setName(testAssetPrefix + "ForLocatorTest")); + assetInfo = service.create(Asset.create().setName(testAssetPrefix + "ForLocatorTest")); } @Test @@ -110,7 +110,8 @@ public void createLocatorSuccess() throws ServiceException { Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), + locatorType)); // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, @@ -121,16 +122,13 @@ public void createLocatorSuccess() throws ServiceException { @Test public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceException { // Arrange - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedExpirationDateTime = new Date(); expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + tenMinutesInMS); - createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); LocatorType locatorType = LocatorType.SAS; // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType).setExpirationDateTime(expectedExpirationDateTime)); // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, null, expectedExpirationDateTime, locatorInfo); @@ -140,16 +138,14 @@ public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceExc @Test public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Arrange - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); - createLocatorOptions.setStartTime(expectedStartDateTime); LocatorType locatorType = LocatorType.SAS; Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfo, assetInfo); // Act - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType).setStartDateTime(expectedStartDateTime)); // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, @@ -164,14 +160,12 @@ public void getLocatorSuccess() throws ServiceException { expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + tenMinutesInMS); - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - createLocatorOptions.setStartTime(expectedStartDateTime); - createLocatorOptions.setExpirationDateTime(expectedExpirationDateTime); - LocatorInfo expectedLocatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), - locatorType, createLocatorOptions); + LocatorInfo expectedLocatorInfo = service.create(Locator + .create(accessPolicyInfo.getId(), assetInfo.getId(), locatorType) + .setStartDateTime(expectedStartDateTime).setExpirationDateTime(expectedExpirationDateTime)); // Act - LocatorInfo actualLocatorInfo = service.getLocator(expectedLocatorInfo.getId()); + LocatorInfo actualLocatorInfo = service.get(Locator.get(expectedLocatorInfo.getId())); // Assert verifyLocatorInfosEqual("actualLocatorInfo", expectedLocatorInfo, actualLocatorInfo); @@ -181,14 +175,14 @@ public void getLocatorSuccess() throws ServiceException { public void getLocatorInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); - service.getLocator(invalidId); + service.get(Locator.get(invalidId)); } @Test public void getLocatorNonexistId() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getLocator(validButNonexistLocatorId); + service.get(Locator.get(validButNonexistLocatorId)); } @Test @@ -197,11 +191,12 @@ public void listLocatorsSuccess() throws ServiceException { LocatorType locatorType = LocatorType.SAS; List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); for (int i = 0; i < 2; i++) { - expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType)); + expectedLocators.add(service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType))); } // Act - ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); + ListResult<LocatorInfo> listLocatorsResult = service.list(Locator.list()); // Assert assertNotNull(listLocatorsResult); @@ -217,17 +212,16 @@ public void verifyEquals(String message, Object expected, Object actual) { public void listLocatorsWithOptions() throws ServiceException { List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); for (int i = 0; i < 5; i++) { - expectedLocators.add(service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), LocatorType.SAS)); + expectedLocators.add(service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS))); } - ListLocatorsOptions options = new ListLocatorsOptions(); - options.getQueryParameters().add( - "$filter", - "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '" + expectedLocators.get(3).getId() - + "')"); - options.getQueryParameters().add("$top", "3"); + MultivaluedMapImpl options = new MultivaluedMapImpl(); + options.add("$filter", "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '" + + expectedLocators.get(3).getId() + "')"); + options.add("$top", "3"); - ListResult<LocatorInfo> result = service.listLocators(options); + ListResult<LocatorInfo> result = service.list(Locator.list(options)); assertEquals(2, result.size()); } @@ -236,18 +230,18 @@ public void listLocatorsWithOptions() throws ServiceException { public void updateLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.Origin; - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), + locatorType)); Date expirationDateTime = new Date(); expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); startTime.setTime(startTime.getTime() - tenMinutesInMS); - UpdateLocatorOptions updateLocatorOptions = new UpdateLocatorOptions() - .setExpirationDateTime(expirationDateTime).setStartTime(startTime); // Act - service.updateLocator(locatorInfo.getId(), updateLocatorOptions); - LocatorInfo updatedLocatorInfo = service.getLocator(locatorInfo.getId()); + service.update(Locator.update(locatorInfo.getId()).setExpirationDateTime(expirationDateTime) + .setStartDateTime(startTime)); + LocatorInfo updatedLocatorInfo = service.get(Locator.get(locatorInfo.getId())); // Assert verifyLocatorProperties("updatedLocatorInfo", locatorInfo.getAccessPolicyId(), locatorInfo.getAssetId(), @@ -263,15 +257,14 @@ public void updateLocatorNoChangesSuccess() throws ServiceException { expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); startTime.setTime(startTime.getTime() - tenMinutesInMS); - CreateLocatorOptions options = new CreateLocatorOptions().setExpirationDateTime(expirationDateTime) - .setStartTime(startTime); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, - options); + LocatorInfo locatorInfo = service.create(Locator + .create(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType) + .setExpirationDateTime(expirationDateTime).setStartDateTime(startTime)); // Act - service.updateLocator(locatorInfo.getId(), null); - LocatorInfo updatedLocatorInfo = service.getLocator(locatorInfo.getId()); + service.update(Locator.update(locatorInfo.getId())); + LocatorInfo updatedLocatorInfo = service.get(Locator.get(locatorInfo.getId())); // Assert verifyLocatorInfosEqual("updatedLocatorInfo", locatorInfo, updatedLocatorInfo); @@ -281,28 +274,27 @@ public void updateLocatorNoChangesSuccess() throws ServiceException { public void deleteLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; - CreateLocatorOptions createLocatorOptions = new CreateLocatorOptions(); - LocatorInfo locatorInfo = service.createLocator(accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - createLocatorOptions); - ListResult<LocatorInfo> listLocatorsResult = service.listLocators(); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType)); + ListResult<LocatorInfo> listLocatorsResult = service.list(Locator.list()); int assetCountBaseline = listLocatorsResult.size(); // Act - service.deleteLocator(locatorInfo.getId()); + service.delete(Locator.delete(locatorInfo.getId())); // Assert - listLocatorsResult = service.listLocators(); + listLocatorsResult = service.list(Locator.list()); assertEquals("listLocatorsResult.size", assetCountBaseline - 1, listLocatorsResult.size()); expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.getLocator(locatorInfo.getId()); + service.get(Locator.get(locatorInfo.getId())); } @Test public void deleteLocatorInvalidIdFailed() throws ServiceException { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); - service.deleteLocator(invalidId); + service.delete(Locator.delete(invalidId)); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 574ba057e655a..d2a4a0de9882e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -19,12 +19,15 @@ import java.util.List; +import javax.ws.rs.core.MultivaluedMap; + import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.sun.jersey.core.util.MultivaluedMapImpl; public class MediaProcessorIntegrationTest extends IntegrationTestBase { @@ -52,7 +55,7 @@ public void listMediaProcessorsSuccess() throws ServiceException { // Arrange // Act - ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.listMediaProcessors(); + ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor.list()); // Assert assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); @@ -67,14 +70,13 @@ public void listMediaProcessorsSuccess() throws ServiceException { @Test public void listMediaProcessorWithOptionSuccess() throws ServiceException { // Arrange - ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); - listMediaProcessorsOptions.getQueryParameters().add("$filter", - "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"); - listMediaProcessorsOptions.getQueryParameters().add("$top", "2"); + MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); + queryParameters.add("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"); + queryParameters.add("$top", "2"); // Act - ListResult<MediaProcessorInfo> listMediaProcessorsResult = service - .listMediaProcessors(listMediaProcessorsOptions); + ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor + .list(queryParameters)); // Assert assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index cca9799c59e26..55e3aa790b12b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -29,11 +29,12 @@ import com.microsoft.windowsazure.services.blob.models.CreateBlobOptions; import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; import com.microsoft.windowsazure.services.core.RetryPolicyFilter; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateLocatorOptions; +import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -49,18 +50,17 @@ public class UploadingIntegrationTest extends IntegrationTestBase { public static void setup() throws Exception { IntegrationTestBase.setup(); - AssetInfo asset = service.createAsset(new CreateAssetOptions() - .setName(testAssetPrefix + "uploadBlockBlobAsset")); + AssetInfo asset = service.create(Asset.create().setName(testAssetPrefix + "uploadBlockBlobAsset")); - AccessPolicyInfo policy = service.createAccessPolicy(testPolicyPrefix + "uploadWritePolicy", 10, - EnumSet.of(AccessPolicyPermission.WRITE)); + AccessPolicyInfo policy = service.create(AccessPolicy.create(testPolicyPrefix + "uploadWritePolicy", 10, + EnumSet.of(AccessPolicyPermission.WRITE))); Date now = new Date(); Date fiveMinutesAgo = new Date(now.getTime() - (5 * 60 * 1000)); Date tenMinutesFromNow = new Date(now.getTime() + (10 * 60 * 1000)); - LocatorInfo locator = service.createLocator(policy.getId(), asset.getId(), LocatorType.SAS, - new CreateLocatorOptions().setStartTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); + LocatorInfo locator = service.create(Locator.create(policy.getId(), asset.getId(), LocatorType.SAS) + .setStartDateTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); blobWriter = MediaService.createBlobWriter(locator); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 6ee6d7d77b4e3..2d03d319f8b25 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -27,10 +27,9 @@ import com.microsoft.windowsazure.services.media.IntegrationTestBase; import com.microsoft.windowsazure.services.media.MediaConfiguration; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; @@ -90,19 +89,21 @@ private ResourceLocationManager createLocationManager() throws URISyntaxExceptio @Test public void canCreateAssetThroughMediaServiceAPI() throws Exception { - MediaContract client = MediaService.create(config); - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName("secondTestAsset"); - AssetInfo newAsset = client.createAsset(createAssetOptions); + MediaContract client = createService(); + AssetInfo newAsset = client.create(Asset.create().setName("secondTestAsset")); Assert.assertEquals("secondTestAsset", newAsset.getName()); } @Test public void canRetrieveListOfAssets() throws Exception { - MediaContract client = MediaService.create(config); - List<AssetInfo> assets = client.listAssets(); + MediaContract client = createService(); + List<AssetInfo> assets = client.list(Asset.list()); Assert.assertNotNull(assets); } + private MediaContract createService() { + return config.create(MediaContract.class); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java deleted file mode 100644 index 6a09d47f6e68d..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateAssetOptionsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class CreateAssetOptionsTest { - - @Test - public void testGetSetState() { - // Arrange - AssetState expectedState = AssetState.Published; - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - - // Act - AssetState actualState = createAssetOptions.setState(expectedState).getState(); - - // Assert - assertEquals(expectedState, actualState); - } - - @Test - public void testGetSetAlternateId() { - // Arrange - String expectedAlternateId = "testAlternateId"; - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - - // Act - String actualAlternateId = createAssetOptions.setAlternateId(expectedAlternateId).getAlternateId(); - - // Assert - assertEquals(expectedAlternateId, actualAlternateId); - } - - @Test - public void testGetSetOptions() { - // Arrange - EncryptionOption expectedOptions = EncryptionOption.None; - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - - // Act - EncryptionOption actualOptions = createAssetOptions.setOptions(expectedOptions).getOptions(); - - // Assert - assertEquals(expectedOptions, actualOptions); - } - - @Test - public void testGetSetName() { - // Arrange - String expectedName = "testGetSetName"; - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - - // Act - String actualName = createAssetOptions.setName(expectedName).getName(); - - // Assert - assertEquals(expectedName, actualName); - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java deleted file mode 100644 index 994cbccee1401..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ListMediaProcessorsOptionsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ListMediaProcessorsOptionsTest { - - @Test - public void createListMediaProcessorsOptionsSuccess() { - // Arrange - - // Act - ListMediaProcessorsOptions listMediaProcessorsOptions = new ListMediaProcessorsOptions(); - - // Assert - assertNotNull(listMediaProcessorsOptions); - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java deleted file mode 100644 index 624c3baaa11f1..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/UpdateAssetOptionsTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class UpdateAssetOptionsTest { - - @Test - public void testGetSetAlternateId() { - // Arrange - String expectedAlternateId = "testAlternateId"; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - String actualAlternateId = updateAssetOptions.setAlternateId(expectedAlternateId).getAlternateId(); - - // Assert - assertEquals(expectedAlternateId, actualAlternateId); - } - - @Test - public void testGetSetName() { - // Arrange - String expectedName = "testName"; - UpdateAssetOptions updateAssetOptions = new UpdateAssetOptions(); - - // Act - String actualName = updateAssetOptions.setName(expectedName).getName(); - - // Assert - assertEquals(expectedName, actualName); - } - -} From 726cf38b43a088cd70669af1e1efd2b5aaaeb304 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 7 Nov 2012 12:40:04 -0800 Subject: [PATCH 470/664] Initial checkin of the Media Service scenario tests. Refactoring scenario tests seperate actions and verifications. Including a short 9kb test MPEG4 video. --- .../scenarios/MediaServiceScenarioTest.java | 142 ++++++ .../scenarios/MediaServiceValidation.java | 213 +++++++++ .../scenarios/MediaServiceWrapper.java | 434 ++++++++++++++++++ .../services/scenarios/ScenarioTestBase.java | 121 +++++ .../src/test/resources/media/MPEG4-H264.mp4 | Bin 0 -> 8697 bytes 5 files changed, 910 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java create mode 100644 microsoft-azure-api/src/test/resources/media/MPEG4-H264.mp4 diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java new file mode 100644 index 0000000000000..3e50bcaab96c3 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -0,0 +1,142 @@ +package com.microsoft.windowsazure.services.scenarios; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.UUID; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.MediaService; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.ListResult; + +public class MediaServiceScenarioTest extends ScenarioTestBase { + private static final String rootTestAssetPrefix = "testAssetPrefix-"; + private static String testAssetPrefix; + private static MediaServiceWrapper wrapper; + private static MediaServiceValidation validator; + + @BeforeClass + public static void setup() throws ServiceException { + ScenarioTestBase.initializeConfig(); + MediaContract service = MediaService.create(config); + wrapper = new MediaServiceWrapper(service); + validator = new MediaServiceValidation(service); + testAssetPrefix = rootTestAssetPrefix + UUID.randomUUID() + "-"; + } + + @AfterClass + public static void cleanup() throws ServiceException { + wrapper.removeAllAssetsWithPrefix(rootTestAssetPrefix); + wrapper.removeAllAccessPoliciesWithPrefix(); + } + + @Test + public void newAsset() throws Exception { + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "newAsset", EncryptionOption.None); + validator.validateAsset(asset, testAssetPrefix + "newAsset", EncryptionOption.None); + } + + @Test + public void pageOverAssets() throws ServiceException { + signalSetupStarting(); + String rootName = testAssetPrefix + "pageOverAssets"; + List<String> assetNames = createListOfAssetNames(rootName, 4); + for (String assetName : assetNames) { + wrapper.createAsset(assetName, EncryptionOption.None); + } + signalSetupFinished(); + + List<ListResult<AssetInfo>> pages = wrapper.getAssetSortedPagedResults(rootName, 3); + validator.validateAssetSortedPages(pages, assetNames, 3); + } + + @Ignore("Needs https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/277") + @Test + public void uploadFiles() throws Exception { + signalSetupStarting(); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadFiles", EncryptionOption.None); + signalSetupFinished(); + + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); + validator.validateAssetFiles(asset, getTestAssetFiles()); + } + + @Ignore("Needs https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/277") + @Test + public void downloadFiles() throws Exception { + signalSetupStarting(); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "downloadFiles", EncryptionOption.None); + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); + signalSetupFinished(); + + List<URL> fileUrls = wrapper.createFileURLsFromAsset(asset, 10); + validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); + } + + @Test + public void createJob() throws Exception { + signalSetupStarting(); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "createJob", EncryptionOption.None); + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); + signalSetupFinished(); + + MediaServiceWrapper.JobInfo job = wrapper.createJob("my job createJob", asset, createTasks()); + validator.validateJob(job, "my job", asset, createTasks()); + } + + @Test + public void transformAsset() throws Exception { + signalSetupStarting(); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", EncryptionOption.None); + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); + MediaServiceWrapper.JobInfo job = wrapper.createJob("my job transformAsset", asset, createTasks()); + signalSetupFinished(); + + waitForJobToFinish(job); + List<AssetInfo> outputAssets = wrapper.getJobOutputMediaAssets(job); + validator.validateOutputAssets(outputAssets); + } + + private void waitForJobToFinish(MediaServiceWrapper.JobInfo job) throws InterruptedException { + for (int counter = 0; !wrapper.isJobFinished(job); counter++) { + if (counter > 10) { + fail("Took took long for the job to finish"); + } + Thread.sleep(20000); + } + } + + private List<MediaServiceWrapper.CreateTaskOptions> createTasks() throws ServiceException { + List<MediaServiceWrapper.CreateTaskOptions> tasks = new ArrayList<MediaServiceWrapper.CreateTaskOptions>(); + tasks.add(wrapper.createTaskOptionsMp4ToSmoothStreams("MP4 to SS")); + tasks.add(wrapper.createTaskOptionsSmoothStreamsToHls("SS to HLS")); + return tasks; + } + + private Hashtable<String, InputStream> getTestAssetFiles() { + // TODO: Get smaller asset. 1.2MB is too large. + Hashtable<String, InputStream> inputFiles = new Hashtable<String, InputStream>(); + inputFiles.put("interview.wmv", getClass().getResourceAsStream("/media/interview.wmv")); + return inputFiles; + } + + private List<String> createListOfAssetNames(String rootName, int count) { + List<String> assetNames = new ArrayList<String>(); + for (int i = 0; i < count; i++) { + assetNames.add(rootName + i); + } + return assetNames; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java new file mode 100644 index 0000000000000..b47c0055da884 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -0,0 +1,213 @@ +package com.microsoft.windowsazure.services.scenarios; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetState; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.FileInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.CreateTaskOptions; +import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.JobInfo; +import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.MockMediaContract; + +class MediaServiceValidation { + private final MediaContract service; + // TODO: Remove this mock + private final MockMediaContract serviceMock; + + public MediaServiceValidation(MediaContract service) { + this.service = service; + this.serviceMock = new MockMediaContract(); + } + + public void validateAsset(AssetInfo asset, String name, EncryptionOption encryption) throws ServiceException { + // Check the asset state. + assertNotNull("asset", asset); + assertNotNull("asset.getId", asset.getId()); + assertFalse("asset.getId != ''", "".equals(asset.getId())); + assertEquals("asset.state", AssetState.Initialized, asset.getState()); + assertEquals("asset.getOptions", encryption, asset.getOptions()); + + // Verify no files by default. + List<FileInfo> initialFiles = serviceMock.getAssetFiles(asset.getId()); + assertNotNull("initialFiles", initialFiles); + assertEquals("initialFiles.size", 0, initialFiles.size()); + + // Reload asset from server for ID + AssetInfo reloadedAsset = service.getAsset(asset.getId()); + + // Verify names match + assertNotNull("reloadedAsset", reloadedAsset); + assertNotNull("reloadedAsset.getId", reloadedAsset.getId()); + assertEquals("reloadedAsset.getId, asset.getId", asset.getId(), reloadedAsset.getId()); + assertEquals("reloadedAsset.state", AssetState.Initialized, reloadedAsset.getState()); + assertEquals("reloadedAsset.getOptions", encryption, reloadedAsset.getOptions()); + } + + public void validateAssetSortedPages(List<ListResult<AssetInfo>> pages, List<String> assetNames, int pageSize) { + int sumSizeOfPages = 0; + List<String> actualAssetNames = new ArrayList<String>(); + + for (ListResult<AssetInfo> page : pages) { + sumSizeOfPages += page.size(); + for (AssetInfo asset : page) { + actualAssetNames.add(asset.getName()); + } + } + + assertEquals("sumSizeOfPages", assetNames.size(), sumSizeOfPages); + assertEquals("size of last page", 0, pages.get(pages.size() - 1).size()); + // Can do this comparison directly because the incoming pages are assumed to be sorted. + for (int i = 0; i < assetNames.size(); i++) { + assertEquals("Asset name:" + i, assetNames.get(i), actualAssetNames.get(i)); + } + } + + public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> inputFiles) throws ServiceException, + IOException, NoSuchAlgorithmException { + List<FileInfo> assetFiles = serviceMock.getAssetFiles(asset.getId()); + + assertNotNull("assetFiles", assetFiles); + // TODO: Uncomment + assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); + + // More general verifications: + // * Verify that the asset count on the server increments for each asset added. + // * Verify that the file count on the server increments for each file added. + // * Verify that can query the server for assets matching + // * The created asset ID, and get only that one item + // * The created asset name, get only that one. + + // 13. If Encrypted, verify file and content key + // SKIP + + // TODO: Get the asset encryption info and compare with the file's encryption info + // Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion + + // Compare the asset files with all files + List<FileInfo> allFiles = serviceMock.getFiles(); + for (FileInfo assetFile : assetFiles) { + assertEquals("fi.getParentAssetId", asset.getId(), assetFile.getParentAssetId()); + FileInfo match = null; + for (FileInfo aFile : allFiles) { + if (aFile.getId().equals(assetFile.getId())) { + match = aFile; + break; + } + } + + assertFileInfosEqual("match from all files", assetFile, match); + } + } + + public void validateAssetFileUrls(List<URL> fileUrls, Hashtable<String, InputStream> inputFiles) + throws IOException, InterruptedException { + assertEquals("fileUrls count", inputFiles.size(), fileUrls.size()); + for (URL file : fileUrls) { + InputStream expected = inputFiles.get(inputFiles.keySet().toArray()[0]); + InputStream actual = getInputStreamWithRetry(file); + assertStreamsEqual(expected, actual); + } + } + + public void validateJob(JobInfo job, String string, AssetInfo asset, List<CreateTaskOptions> createTasks) { + // TODO: Add validation + } + + public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException, MalformedURLException { + // TODO: How to validate the output assets? + + // for (AssetInfo outputAsset : outputAssets) { + // List<URL> urls = wrapper.createOriginUrlsForAppleHLSContent(outputAsset, 1000); + // for (URL url : urls) { + // System.out.println(url); + // } + // } + // + // for (URL url : wrapper.createOriginUrlsForStreamingContent(asset, 10)) { + // // print(url.toString()); + // // TODO: more to verify here? + // } + } + + // This method is needed because there can be a delay before a new read locator + // is applied for the asset files. + private InputStream getInputStreamWithRetry(URL file) throws InterruptedException, IOException { + InputStream reader = null; + for (int counter = 0; true; counter++) { + try { + reader = file.openConnection().getInputStream(); + break; + } + catch (IOException e) { + print("Got error, wait a bit and try again"); + if (counter < 6) { + Thread.sleep(10000); + } + else { + // No more retries. + throw e; + } + } + } + + return reader; + } + + public void assertFileInfosEqual(String message, FileInfo fi, FileInfo match) { + assertNotNull(message + ":fi", fi); + assertNotNull(message + ":match", match); + assertEquals(message + ":getContentChecksum", fi.getContentChecksum(), match.getContentChecksum()); + assertEquals(message + ":getContentFileSize", fi.getContentFileSize(), match.getContentFileSize()); + assertEquals(message + ":getCreated", fi.getCreated(), match.getCreated()); + assertEquals(message + ":getEncryptionKeyId", fi.getEncryptionKeyId(), match.getEncryptionKeyId()); + assertEquals(message + ":getEncryptionScheme", fi.getEncryptionScheme(), match.getEncryptionScheme()); + assertEquals(message + ":getEncryptionVersion", fi.getEncryptionVersion(), match.getEncryptionVersion()); + assertEquals(message + ":getId", fi.getId(), match.getId()); + assertEquals(message + ":getIsEncrypted", fi.getIsEncrypted(), match.getIsEncrypted()); + assertEquals(message + ":getIsPrimary", fi.getIsPrimary(), match.getIsPrimary()); + assertEquals(message + ":getLastModified", fi.getLastModified(), match.getLastModified()); + assertEquals(message + ":getMimeType", fi.getMimeType(), match.getMimeType()); + assertEquals(message + ":getName", fi.getName(), match.getName()); + assertEquals(message + ":getParentAssetId", fi.getParentAssetId(), match.getParentAssetId()); + } + + private void assertStreamsEqual(InputStream inputStream1, InputStream inputStream2) throws IOException { + byte[] buffer1 = new byte[1024]; + byte[] buffer2 = new byte[1024]; + try { + while (true) { + int n1 = inputStream1.read(buffer1); + int n2 = inputStream2.read(buffer2); + assertEquals("number of bytes read from streams", n1, n2); + if (n1 == -1) { + break; + } + for (int i = 0; i < n1; i++) { + assertEquals("byte " + i + " read from streams", buffer1[i], buffer2[i]); + } + } + } + finally { + inputStream1.close(); + inputStream2.close(); + } + } + + private static void print(String name) { + System.out.println(name); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java new file mode 100644 index 0000000000000..928203bfb73d7 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -0,0 +1,434 @@ +package com.microsoft.windowsazure.services.scenarios; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.Hashtable; +import java.util.List; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.MediaService; +import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.FileInfo; +import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; +import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; + +class MediaServiceWrapper { + private final MediaContract service; + // TODO: Remove this mock + private final MockMediaContract serviceMock; + + private static final String accessPolicyPrefix = "scenarioTestPrefix"; + + // private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption"; + private final String MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER = "Windows Azure Media Encoder"; + private final String MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS = "MP4 to Smooth Streams Task"; + private final String MEDIA_PROCESSOR_PLAYREADY_PROTECTION = "PlayReady Protection Task"; + private final String MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS = "Smooth Streams to HLS Task"; + + private final String configMp4ToSmoothStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" + + " <name>MP4 to Smooth Streams</name>" + + " <id>5e1e1a1c-bba6-11df-8991-0019d1916af0</id>" + + " <description xml:lang='en'>Converts MP4 files encoded with H.264 (AVC) video and AAC-LC audio codecs to Smooth Streams.</description>" + + " <inputFolder />" + + " <properties namespace='http://schemas.microsoft.com/iis/media/V4/TM/MP4ToSmooth#' prefix='mp4'>" + + " <property name='keepSourceNames' required='false' value='true' helpText='This property tells the MP4 to Smooth task to keep the original file name rather than add the bitrate bitrate information.' />" + + " </properties>" + + " <taskCode>" + + " <type>Microsoft.Web.Media.TransformManager.MP4toSmooth.MP4toSmooth_Task, Microsoft.Web.Media.TransformManager.MP4toSmooth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" + + " </taskCode>" + "</taskDefinition>"; + + private final String configSmoothStreamsToAppleHttpLiveStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" + + " <name>Smooth Streams to Apple HTTP Live Streams</name>" + + " <id>A72D7A5D-3022-45f2-89B4-1DDC5457C111</id>" + + " <description xml:lang='en'>Converts on-demand Smooth Streams encoded with H.264 (AVC) video and AAC-LC audio codecs to Apple HTTP Live Streams (MPEG-2 TS) and creates an Apple HTTP Live Streaming playlist (.m3u8) file for the converted presentation.</description>" + + " <inputDirectory></inputDirectory>" + + " <outputFolder>TS_Out</outputFolder>" + + " <properties namespace='http://schemas.microsoft.com/iis/media/AppleHTTP#' prefix='hls'>" + + " <property name='maxbitrate' required='true' value='8500000' helpText='The maximum bit rate, in bits per second (bps), to be converted to MPEG-2 TS. On-demand Smooth Streams at or below this value are converted to MPEG-2 TS segments. Smooth Streams above this value are not converted. Most Apple devices can play media encoded at bit rates up to 8,500 Kbps.'/>" + + " <property name='manifest' required='false' value='' helpText='The file name to use for the converted Apple HTTP Live Streaming playlist file (a file with an .m3u8 file name extension). If no value is specified, the following default value is used: <ISM_file_name>-m3u8-aapl.m3u8'/>" + + " <property name='segment' required='false' value='10' helpText='The duration of each MPEG-2 TS segment, in seconds. 10 seconds is the Apple-recommended setting for most Apple mobile digital devices.'/>" + + " <property name='log' required='false' value='' helpText='The file name to use for a log file (with a .log file name extension) that records the conversion activity. If you specify a log file name, the file is stored in the task output folder.' /> " + + " <property name='encrypt' required='false' value='false' helpText='Enables encryption of MPEG-2 TS segments by using the Advanced Encryption Standard (AES) with a 128-bit key (AES-128).' />" + + " <property name='pid' required='false' value='' helpText='The program ID of the MPEG-2 TS presentation. Different encodings of MPEG-2 TS streams in the same presentation use the same program ID so that clients can easily switch between bit rates.' />" + + " <property name='codecs' required='false' value='false' helpText='Enables codec format identifiers, as defined by RFC 4281, to be included in the Apple HTTP Live Streaming playlist (.m3u8) file.' />" + + " <property name='backwardcompatible' required='false' value='false' helpText='Enables playback of the MPEG-2 TS presentation on devices that use the Apple iOS 3.0 mobile operating system.' />" + + " <property name='allowcaching' required='false' value='true' helpText='Enables the MPEG-2 TS segments to be cached on Apple devices for later playback.' />" + + " <property name='passphrase' required='false' value='' helpText='A passphrase that is used to generate the content key identifier.' />" + + " <property name='key' required='false' value='' helpText='The hexadecimal representation of the 16-octet content key value that is used for encryption.' />" + + " <property name='keyuri' required='false' value='' helpText='An alternate URI to be used by clients for downloading the key file. If no value is specified, it is assumed that the Live Smooth Streaming publishing point provides the key file.' />" + + " <property name='overwrite' required='false' value='true' helpText='Enables existing files in the output folder to be overwritten if converted output files have identical file names.' />" + + " </properties>" + + " <taskCode>" + + " <type>Microsoft.Web.Media.TransformManager.SmoothToHLS.SmoothToHLSTask, Microsoft.Web.Media.TransformManager.SmoothToHLS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" + + " </taskCode>" + "</taskDefinition>"; + + public MediaServiceWrapper(MediaContract service) { + this.service = service; + this.serviceMock = new MockMediaContract(); + } + + // Manage + public AssetInfo createAsset(String name, EncryptionOption encryption) throws ServiceException { + // Create asset. The SDK's top-level method is the simplest way to do that. + return service.createAsset(new CreateAssetOptions().setName(name).setAlternateId("altId") + .setOptions(encryption)); + } + + public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, int pageSize) + throws ServiceException { + List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>(); + for (int skip = 0; true; skip += pageSize) { + ListAssetsOptions options = new ListAssetsOptions(); + // TODO: Remove the hack of adding "": https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/452 + options.getQueryParameters().add("$skip", skip + ""); + options.getQueryParameters().add("$top", pageSize + ""); + options.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')"); + options.getQueryParameters().add("$orderby", "Name"); + ListResult<AssetInfo> listAssetResult = service.listAssets(options); + pages.add(listAssetResult); + if (listAssetResult.size() == 0) { + break; + } + } + + return pages; + } + + // Ingest + public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hashtable<String, InputStream> inputFiles) + throws ServiceException, IOException, NoSuchAlgorithmException { + AccessPolicyInfo accessPolicy = service.createAccessPolicy(accessPolicyPrefix + "tempAccessPolicy", + uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE)); + LocatorInfo locator = service.createLocator(accessPolicy.getId(), asset.getId(), LocatorType.SAS); + WritableBlobContainerContract uploader = MediaService.createBlobWriter(locator); + for (String fileName : inputFiles.keySet()) { + MessageDigest digest = MessageDigest.getInstance("MD5"); + InputStream inputStream = inputFiles.get(fileName); + inputStream = new DigestInputStream(inputStream, digest); + + uploader.createBlockBlob(fileName, inputStream); + + inputStream.close(); + byte[] md5hash = digest.digest(); + String md5 = Base64.encode(md5hash); + System.out.println("md5: " + md5); + + // TODO: Use this MD5 to set the associated FileInfo + // TODO: Create the associated FileInfos. + } + service.deleteLocator(locator.getId()); + service.deleteAccessPolicy(accessPolicy.getId()); + } + + // Process + public JobInfo createJob(String jobName, AssetInfo inputAsset, List<CreateTaskOptions> tasks) { + CreateJobOptions jobOptions = new CreateJobOptions().setName(jobName).addInputMediaAsset(inputAsset.getId()); + + for (CreateTaskOptions task : tasks) { + jobOptions.addTask(task); + } + + return serviceMock.createJob(jobOptions); + } + + // Process + public CreateTaskOptions createTaskOptionsWindowsAzureMediaEncoder(String taskName) throws ServiceException { + return new CreateTaskOptions() + .setName(taskName) + .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER)) + .setConfiguration("H.264 256k DSL CBR") + .setTaskBody( + "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" + + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + } + + // Process + public CreateTaskOptions createTaskOptionsPlayReadyProtection(String taskName, String playReadyConfiguration) + throws ServiceException { + return new CreateTaskOptions() + .setName(taskName) + .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration) + .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION)) + .setConfiguration(playReadyConfiguration) + .setTaskBody( + "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" + + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + } + + // Process + public CreateTaskOptions createTaskOptionsMp4ToSmoothStreams(String taskName) throws ServiceException { + return new CreateTaskOptions() + .setName(taskName) + .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS)) + .setConfiguration(configMp4ToSmoothStreams) + .setTaskBody( + "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" + + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + } + + // Process + public CreateTaskOptions createTaskOptionsSmoothStreamsToHls(String taskName) throws ServiceException { + return new CreateTaskOptions() + .setName(taskName) + .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS)) + .setConfiguration(configSmoothStreamsToAppleHttpLiveStreams) + .setTaskBody( + "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" + + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + } + + private String getMediaProcessorIdByName(String processorName) throws ServiceException { + ListMediaProcessorsOptions options = new ListMediaProcessorsOptions(); + options.getQueryParameters().putSingle("$filter", "Name eq '" + processorName + "'"); + MediaProcessorInfo processor = service.listMediaProcessors(options).get(0); + return processor.getId(); + } + + // Process + public boolean isJobFinished(JobInfo initialJobInfo) { + JobInfo currentJob = serviceMock.getJob(initialJobInfo.getId()); + switch (currentJob.getState()) { + case Finished: + case Canceled: + case Error: + return true; + default: + return false; + } + } + + public List<AssetInfo> getJobOutputMediaAssets(JobInfo job) { + return serviceMock.getJobOutputMediaAssets(job.getId()); + } + + // // Process + // public List<AssetInfo> waitForJobToComplete(JobInfo initialJobInfo) throws InterruptedException { + // boolean jobCompleted = false; + // int JobProgressInterval = 20000; + // while (!jobCompleted) { + // JobInfo currentJob = serviceMock.getJob(initialJobInfo.getId()); + // switch (currentJob.getState()) { + // case Finished: + // case Canceled: + // case Error: + // jobCompleted = true; + // break; + // default: + // print() + // Thread.sleep(JobProgressInterval); + // break; + // } + // } + // + // return serviceMock.getJobOutputMediaAssets(initialJobInfo.getId()); + // } + + // Process + public void cancelJob(JobInfo job) throws InterruptedException { + // Use the service function + serviceMock.cancelJob(job.getId()); + } + + // Deliver + public List<URL> createOriginUrlsForStreamingContent(AssetInfo asset, int availabilityWindowInMinutes) + throws ServiceException, MalformedURLException { + return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, "", + LocatorType.Origin); + } + + // Deliver + public List<URL> createOriginUrlsForAppleHLSContent(AssetInfo asset, int availabilityWindowInMinutes) + throws ServiceException, MalformedURLException { + return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, + "(format=m3u8-aapl)", LocatorType.Origin); + } + + // Deliver + public List<URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, + MalformedURLException { + return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, false, null, + LocatorType.SAS); + } + + private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int availabilityWindowInMinutes, + boolean isSmooth, String suffix, LocatorType locatorType) throws ServiceException, MalformedURLException { + List<URL> ret = new ArrayList<URL>(); + + AccessPolicyInfo readAP = service.createAccessPolicy(accessPolicyPrefix + "tempAccessPolicy", + availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ)); + LocatorInfo readLocator = service.createLocator(readAP.getId(), asset.getId(), locatorType); + + List<FileInfo> publishedFiles = serviceMock.getAssetFiles(asset.getId()); + for (FileInfo fi : publishedFiles) { + if (isSmooth) { + // Smooth Streaming format ends with ".ism*" + int index = fi.getName().lastIndexOf('.'); + boolean isSmoothSteamFile = fi.getName().regionMatches(true, index + 1, "ism", 0, 3); + if (isSmoothSteamFile) { + ret.add(constructUrlFromLocatorAndFileName(readLocator, fi.getName() + "/manifest")); + } + } + else { + URL file = constructUrlFromLocatorAndFileName(readLocator, fi.getName()); + ret.add(file); + } + } + + return ret; + } + + private URL constructUrlFromLocatorAndFileName(LocatorInfo locator, String fileName) throws MalformedURLException { + String locatorPath = locator.getPath(); + int startOfSas = locatorPath.indexOf("?"); + String blobPath = locatorPath + fileName; + if (startOfSas >= 0) { + blobPath = locatorPath.substring(0, startOfSas) + "/" + fileName + locatorPath.substring(startOfSas); + } + + return new URL(blobPath); + } + + public void removeAllAssetsWithPrefix(String assetPrefix) throws ServiceException { + ListResult<LocatorInfo> locators = service.listLocators(); + ListAssetsOptions options = new ListAssetsOptions(); + options.getQueryParameters().add("$filter", "startswith(Name,'" + assetPrefix + "')"); + List<AssetInfo> assets = service.listAssets(options); + for (AssetInfo asset : assets) { + if (asset.getName().length() > assetPrefix.length() + && asset.getName().substring(0, assetPrefix.length()).equals(assetPrefix)) { + print("Looking for locators belonging to asset: " + asset.getId()); + for (LocatorInfo locator : locators) { + if (locator.getAssetId().equals(asset.getId())) { + print("Deleting locator for asset: " + locator.getId()); + service.deleteLocator(locator.getId()); + } + } + + print("Deleting asset: " + asset.getId()); + service.deleteAsset(asset.getId()); + } + } + } + + private void print(String string) { + System.out.println(string); + } + + public void removeAllAccessPoliciesWithPrefix() throws ServiceException { + List<AccessPolicyInfo> accessPolicies = service.listAccessPolicies(); + for (AccessPolicyInfo accessPolicy : accessPolicies) { + if (accessPolicy.getName().length() > accessPolicyPrefix.length() + && accessPolicy.getName().substring(0, accessPolicyPrefix.length()).equals(accessPolicyPrefix)) { + print("Deleting accessPolicy: " + accessPolicy.getId()); + service.deleteAccessPolicy(accessPolicy.getId()); + } + } + } + + // TODO: Replace with real media contract + static class MockMediaContract { + public List<FileInfo> getAssetFiles(String id) { + return new ArrayList<FileInfo>(); + } + + public JobInfo createJob(CreateJobOptions jobOptions) { + return new JobInfo(); + } + + public JobInfo getJob(String id) { + return new JobInfo(); + } + + public List<AssetInfo> getJobOutputMediaAssets(String id) { + return new ArrayList<AssetInfo>(); + } + + public void cancelJob(String id) { + } + + public List<FileInfo> getFiles() { + return new ArrayList<FileInfo>(); + } + } + + // TODO: Replace with real JobState + static enum JobState { + Finished, Canceled, Error + } + + // TODO: Replace with real JobInfo + static class JobInfo { + + public String getId() { + return null; + } + + public JobState getState() { + return JobState.Finished; + } + } + + // TODO: Replace with real CreateTaskOptions + static class CreateTaskOptions { + + public CreateTaskOptions setName(String string) { + return this; + } + + public CreateTaskOptions setProcessorId(String id) { + return this; + } + + public CreateTaskOptions setConfiguration(String string) { + return this; + } + + public CreateTaskOptions setTaskBody(String string) { + return this; + } + + public CreateTaskOptions setTaskCreationOptions(TaskCreationOptions options) { + return this; + } + } + + // TODO: Replace with real CreateJobOptions + static class CreateJobOptions { + + public CreateJobOptions setName(String jobName) { + return this; + } + + public CreateJobOptions addInputMediaAsset(String id) { + return this; + } + + public CreateJobOptions addTask(CreateTaskOptions task) { + return this; + } + } + + // TODO: Replace with real TaskCreationOptions + static enum TaskCreationOptions { + ProtectedConfiguration + } + +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java new file mode 100644 index 0000000000000..0d471e7da87ec --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java @@ -0,0 +1,121 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.scenarios; + +import static org.junit.Assert.*; + +import org.junit.Rule; +import org.junit.rules.MethodRule; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.Statement; + +import com.microsoft.windowsazure.services.blob.BlobConfiguration; +import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.media.MediaConfiguration; +import com.microsoft.windowsazure.services.queue.QueueConfiguration; +import com.microsoft.windowsazure.services.serviceBus.ServiceBusConfiguration; +import com.microsoft.windowsazure.services.table.TableConfiguration; + +@SuppressWarnings("deprecation") +public abstract class ScenarioTestBase { + protected static Configuration config; + + @Rule + public SetupManager setupManager = new SetupManager(); + + protected static void initializeConfig() { + config = new Configuration(); + + overrideWithEnv(config, BlobConfiguration.ACCOUNT_NAME); + overrideWithEnv(config, BlobConfiguration.ACCOUNT_KEY); + overrideWithEnv(config, BlobConfiguration.URI); + + overrideWithEnv(config, QueueConfiguration.ACCOUNT_NAME); + overrideWithEnv(config, QueueConfiguration.ACCOUNT_KEY); + overrideWithEnv(config, QueueConfiguration.URI); + + overrideWithEnv(config, TableConfiguration.ACCOUNT_NAME); + overrideWithEnv(config, TableConfiguration.ACCOUNT_KEY); + overrideWithEnv(config, TableConfiguration.URI); + + overrideWithEnv(config, ServiceBusConfiguration.URI); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_URI); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_NAME); + overrideWithEnv(config, ServiceBusConfiguration.WRAP_PASSWORD); + + overrideWithEnv(config, MediaConfiguration.URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_URI); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_ID); + overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); + overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); + } + + private static void overrideWithEnv(Configuration config, String key) { + String value = System.getenv(key); + if (value == null) + return; + + config.setProperty(key, value); + } + + protected void signalSetupStarting() { + setupManager.startSetup(); + } + + protected void signalSetupFinished() { + setupManager.endSetup(); + } + + protected class SetupManager implements MethodRule { + private boolean shouldCapture; + + @Override + public Statement apply(Statement base, FrameworkMethod method, Object target) { + return new SetupManagerStatement(base); + } + + public void startSetup() { + this.shouldCapture = true; + } + + public void endSetup() { + this.shouldCapture = false; + } + + private class SetupManagerStatement extends Statement { + private final Statement next; + + public SetupManagerStatement(Statement base) { + next = base; + } + + @Override + public void evaluate() throws Throwable { + try { + next.evaluate(); + } + catch (Throwable e) { + if (shouldCapture) { + fail("Error occured during setup: " + e); + } + else { + throw e; + } + } + } + } + } +} diff --git a/microsoft-azure-api/src/test/resources/media/MPEG4-H264.mp4 b/microsoft-azure-api/src/test/resources/media/MPEG4-H264.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..54c15e4ec7532491d1e5ebd6cecc6a06413edfcc GIT binary patch literal 8697 zcmeHN30PBC7QT6j5SG$ZD58V<aKW_@!Xl<95pYU7h_=Wgitr!=C<#fk0MZ~4gGIVw zZ5a})sBOjK0=4z44pkATWeOFh9i_Ey*oqaZVv!0KVa^R(NSYa#iZfroUUT2M_y5mb z-Z|%<muEl-ISAzIBqE6i2SEYpmLwC45Skbv;!|>rL1959Eb!IcY@936Nv-IXERlZ9 z32ZN(yU1f%Qk+yQ6AR>IpbN*#gIt;tC+5dX$uKt;PZxKjf?+q!#<kQQvVEga=6`PQ zp3nRWJ%t@IX&l#`OyqJr*kl^lox>&t5*e4X&}HEQHYpKsy}U?as*vkJ#&X$Y><bc5 zP7q7D3)y56Uy6lH7{_%Z<3tkRVJ<fkbT}TQl#<7D-8|X2kdk;R84p(o1YA!q4xpqo zUI4nVdLk@JQo0886|oY4C6tuwMY_X3X$l_(#!<0U97rKdO~%Pn<j|%Re9#n9xSb|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8QbWwnUFUN83 gA&S>YjFI{eRye?e4_Qn?VI~P>_zyam5s*Rt1xb%oW&i*H literal 0 HcmV?d00001 From 2df5ea331c5b44f4d17ea3093b96d8e277f54a6d Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 7 Nov 2012 12:55:49 -0800 Subject: [PATCH 471/664] Some more cleanup --- .../services/scenarios/MediaServiceMocks.java | 99 ++++++++++++++ .../scenarios/MediaServiceScenarioTest.java | 11 +- .../scenarios/MediaServiceValidation.java | 31 ++--- .../scenarios/MediaServiceWrapper.java | 126 +----------------- 4 files changed, 121 insertions(+), 146 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java new file mode 100644 index 0000000000000..e626df3733729 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java @@ -0,0 +1,99 @@ +package com.microsoft.windowsazure.services.scenarios; + +import java.util.ArrayList; +import java.util.List; + +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.FileInfo; + +class MediaServiceMocks { + + // TODO: Replace with real media contract + static class MockMediaContract { + public List<FileInfo> getAssetFiles(String id) { + return new ArrayList<FileInfo>(); + } + + public JobInfo createJob(CreateJobOptions jobOptions) { + return new JobInfo(); + } + + public JobInfo getJob(String id) { + return new JobInfo(); + } + + public List<AssetInfo> getJobOutputMediaAssets(String id) { + return new ArrayList<AssetInfo>(); + } + + public void cancelJob(String id) { + } + + public List<FileInfo> getFiles() { + return new ArrayList<FileInfo>(); + } + } + + // TODO: Replace with real JobState + static enum JobState { + Finished, Canceled, Error + } + + // TODO: Replace with real JobInfo + static class JobInfo { + + public String getId() { + return null; + } + + public JobState getState() { + return JobState.Finished; + } + } + + // TODO: Replace with real CreateTaskOptions + static class CreateTaskOptions { + + public CreateTaskOptions setName(String string) { + return this; + } + + public CreateTaskOptions setProcessorId(String id) { + return this; + } + + public CreateTaskOptions setConfiguration(String string) { + return this; + } + + public CreateTaskOptions setTaskBody(String string) { + return this; + } + + public CreateTaskOptions setTaskCreationOptions(TaskCreationOptions options) { + return this; + } + } + + // TODO: Replace with real CreateJobOptions + static class CreateJobOptions { + + public CreateJobOptions setName(String jobName) { + return this; + } + + public CreateJobOptions addInputMediaAsset(String id) { + return this; + } + + public CreateJobOptions addTask(CreateTaskOptions task) { + return this; + } + } + + // TODO: Replace with real TaskCreationOptions + static enum TaskCreationOptions { + ProtectedConfiguration + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 3e50bcaab96c3..ab9c31d223870 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -92,7 +92,7 @@ public void createJob() throws Exception { wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); - MediaServiceWrapper.JobInfo job = wrapper.createJob("my job createJob", asset, createTasks()); + MediaServiceMocks.JobInfo job = wrapper.createJob("my job createJob", asset, createTasks()); validator.validateJob(job, "my job", asset, createTasks()); } @@ -101,7 +101,7 @@ public void transformAsset() throws Exception { signalSetupStarting(); AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", EncryptionOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); - MediaServiceWrapper.JobInfo job = wrapper.createJob("my job transformAsset", asset, createTasks()); + MediaServiceMocks.JobInfo job = wrapper.createJob("my job transformAsset", asset, createTasks()); signalSetupFinished(); waitForJobToFinish(job); @@ -109,7 +109,7 @@ public void transformAsset() throws Exception { validator.validateOutputAssets(outputAssets); } - private void waitForJobToFinish(MediaServiceWrapper.JobInfo job) throws InterruptedException { + private void waitForJobToFinish(MediaServiceMocks.JobInfo job) throws InterruptedException { for (int counter = 0; !wrapper.isJobFinished(job); counter++) { if (counter > 10) { fail("Took took long for the job to finish"); @@ -118,15 +118,14 @@ private void waitForJobToFinish(MediaServiceWrapper.JobInfo job) throws Interrup } } - private List<MediaServiceWrapper.CreateTaskOptions> createTasks() throws ServiceException { - List<MediaServiceWrapper.CreateTaskOptions> tasks = new ArrayList<MediaServiceWrapper.CreateTaskOptions>(); + private List<MediaServiceMocks.CreateTaskOptions> createTasks() throws ServiceException { + List<MediaServiceMocks.CreateTaskOptions> tasks = new ArrayList<MediaServiceMocks.CreateTaskOptions>(); tasks.add(wrapper.createTaskOptionsMp4ToSmoothStreams("MP4 to SS")); tasks.add(wrapper.createTaskOptionsSmoothStreamsToHls("SS to HLS")); return tasks; } private Hashtable<String, InputStream> getTestAssetFiles() { - // TODO: Get smaller asset. 1.2MB is too large. Hashtable<String, InputStream> inputFiles = new Hashtable<String, InputStream>(); inputFiles.put("interview.wmv", getClass().getResourceAsStream("/media/interview.wmv")); return inputFiles; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index b47c0055da884..772110af48b8f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -18,18 +18,17 @@ import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.FileInfo; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.CreateTaskOptions; -import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.JobInfo; -import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.MockMediaContract; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.JobInfo; class MediaServiceValidation { private final MediaContract service; // TODO: Remove this mock - private final MockMediaContract serviceMock; + private final MediaServiceMocks.MockMediaContract serviceMock; public MediaServiceValidation(MediaContract service) { this.service = service; - this.serviceMock = new MockMediaContract(); + this.serviceMock = new MediaServiceMocks.MockMediaContract(); } public void validateAsset(AssetInfo asset, String name, EncryptionOption encryption) throws ServiceException { @@ -80,7 +79,6 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i List<FileInfo> assetFiles = serviceMock.getAssetFiles(asset.getId()); assertNotNull("assetFiles", assetFiles); - // TODO: Uncomment assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); // More general verifications: @@ -89,12 +87,9 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i // * Verify that can query the server for assets matching // * The created asset ID, and get only that one item // * The created asset name, get only that one. - - // 13. If Encrypted, verify file and content key - // SKIP - - // TODO: Get the asset encryption info and compare with the file's encryption info - // Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion + // * If Encrypted, verify file and content key + // * Get the asset encryption info and compare with the file's encryption info + // * Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion // Compare the asset files with all files List<FileInfo> allFiles = serviceMock.getFiles(); @@ -127,7 +122,7 @@ public void validateJob(JobInfo job, String string, AssetInfo asset, List<Create } public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException, MalformedURLException { - // TODO: How to validate the output assets? + // TODO: validate the output assets? // for (AssetInfo outputAsset : outputAssets) { // List<URL> urls = wrapper.createOriginUrlsForAppleHLSContent(outputAsset, 1000); @@ -137,8 +132,7 @@ public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceExc // } // // for (URL url : wrapper.createOriginUrlsForStreamingContent(asset, 10)) { - // // print(url.toString()); - // // TODO: more to verify here? + // // TODO: What to verify here? // } } @@ -152,7 +146,7 @@ private InputStream getInputStreamWithRetry(URL file) throws InterruptedExceptio break; } catch (IOException e) { - print("Got error, wait a bit and try again"); + System.out.println("Got error, wait a bit and try again"); if (counter < 6) { Thread.sleep(10000); } @@ -205,9 +199,4 @@ private void assertStreamsEqual(InputStream inputStream1, InputStream inputStrea inputStream2.close(); } } - - private static void print(String name) { - System.out.println(name); - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 928203bfb73d7..d3b17935727c1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -29,6 +29,11 @@ import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateJobOptions; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.JobInfo; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.MockMediaContract; +import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.TaskCreationOptions; class MediaServiceWrapper { private final MediaContract service; @@ -43,6 +48,7 @@ class MediaServiceWrapper { private final String MEDIA_PROCESSOR_PLAYREADY_PROTECTION = "PlayReady Protection Task"; private final String MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS = "Smooth Streams to HLS Task"; + // From http://msdn.microsoft.com/en-us/library/windowsazure/hh973635.aspx private final String configMp4ToSmoothStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" + " <name>MP4 to Smooth Streams</name>" + " <id>5e1e1a1c-bba6-11df-8991-0019d1916af0</id>" @@ -55,6 +61,7 @@ class MediaServiceWrapper { + " <type>Microsoft.Web.Media.TransformManager.MP4toSmooth.MP4toSmooth_Task, Microsoft.Web.Media.TransformManager.MP4toSmooth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" + " </taskCode>" + "</taskDefinition>"; + // From http://msdn.microsoft.com/en-us/library/windowsazure/hh973636.aspx private final String configSmoothStreamsToAppleHttpLiveStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" + " <name>Smooth Streams to Apple HTTP Live Streams</name>" + " <id>A72D7A5D-3022-45f2-89B4-1DDC5457C111</id>" @@ -219,28 +226,6 @@ public List<AssetInfo> getJobOutputMediaAssets(JobInfo job) { return serviceMock.getJobOutputMediaAssets(job.getId()); } - // // Process - // public List<AssetInfo> waitForJobToComplete(JobInfo initialJobInfo) throws InterruptedException { - // boolean jobCompleted = false; - // int JobProgressInterval = 20000; - // while (!jobCompleted) { - // JobInfo currentJob = serviceMock.getJob(initialJobInfo.getId()); - // switch (currentJob.getState()) { - // case Finished: - // case Canceled: - // case Error: - // jobCompleted = true; - // break; - // default: - // print() - // Thread.sleep(JobProgressInterval); - // break; - // } - // } - // - // return serviceMock.getJobOutputMediaAssets(initialJobInfo.getId()); - // } - // Process public void cancelJob(JobInfo job) throws InterruptedException { // Use the service function @@ -314,121 +299,24 @@ public void removeAllAssetsWithPrefix(String assetPrefix) throws ServiceExceptio for (AssetInfo asset : assets) { if (asset.getName().length() > assetPrefix.length() && asset.getName().substring(0, assetPrefix.length()).equals(assetPrefix)) { - print("Looking for locators belonging to asset: " + asset.getId()); for (LocatorInfo locator : locators) { if (locator.getAssetId().equals(asset.getId())) { - print("Deleting locator for asset: " + locator.getId()); service.deleteLocator(locator.getId()); } } - print("Deleting asset: " + asset.getId()); service.deleteAsset(asset.getId()); } } } - private void print(String string) { - System.out.println(string); - } - public void removeAllAccessPoliciesWithPrefix() throws ServiceException { List<AccessPolicyInfo> accessPolicies = service.listAccessPolicies(); for (AccessPolicyInfo accessPolicy : accessPolicies) { if (accessPolicy.getName().length() > accessPolicyPrefix.length() && accessPolicy.getName().substring(0, accessPolicyPrefix.length()).equals(accessPolicyPrefix)) { - print("Deleting accessPolicy: " + accessPolicy.getId()); service.deleteAccessPolicy(accessPolicy.getId()); } } } - - // TODO: Replace with real media contract - static class MockMediaContract { - public List<FileInfo> getAssetFiles(String id) { - return new ArrayList<FileInfo>(); - } - - public JobInfo createJob(CreateJobOptions jobOptions) { - return new JobInfo(); - } - - public JobInfo getJob(String id) { - return new JobInfo(); - } - - public List<AssetInfo> getJobOutputMediaAssets(String id) { - return new ArrayList<AssetInfo>(); - } - - public void cancelJob(String id) { - } - - public List<FileInfo> getFiles() { - return new ArrayList<FileInfo>(); - } - } - - // TODO: Replace with real JobState - static enum JobState { - Finished, Canceled, Error - } - - // TODO: Replace with real JobInfo - static class JobInfo { - - public String getId() { - return null; - } - - public JobState getState() { - return JobState.Finished; - } - } - - // TODO: Replace with real CreateTaskOptions - static class CreateTaskOptions { - - public CreateTaskOptions setName(String string) { - return this; - } - - public CreateTaskOptions setProcessorId(String id) { - return this; - } - - public CreateTaskOptions setConfiguration(String string) { - return this; - } - - public CreateTaskOptions setTaskBody(String string) { - return this; - } - - public CreateTaskOptions setTaskCreationOptions(TaskCreationOptions options) { - return this; - } - } - - // TODO: Replace with real CreateJobOptions - static class CreateJobOptions { - - public CreateJobOptions setName(String jobName) { - return this; - } - - public CreateJobOptions addInputMediaAsset(String id) { - return this; - } - - public CreateJobOptions addTask(CreateTaskOptions task) { - return this; - } - } - - // TODO: Replace with real TaskCreationOptions - static enum TaskCreationOptions { - ProtectedConfiguration - } - } \ No newline at end of file From d6c70cd7b05eb3869277fc7d3f2c68a58ae031b3 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 7 Nov 2012 15:55:16 -0800 Subject: [PATCH 472/664] Remove unneeded TODO messages. Add link to tracking item for removing the Mock types. Add copyright notices Update uploadFilesToAsset to use mock types. --- .../services/scenarios/MediaServiceMocks.java | 28 +++++++--- .../scenarios/MediaServiceScenarioTest.java | 17 ++++++- .../scenarios/MediaServiceValidation.java | 20 ++++++-- .../scenarios/MediaServiceWrapper.java | 51 ++++++++++++++++--- 4 files changed, 99 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java index e626df3733729..5703a8d6e4c01 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.scenarios; import java.util.ArrayList; @@ -6,9 +21,10 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.FileInfo; +// TODO: Remove when no longer needed. +// Tracked by https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/457 class MediaServiceMocks { - // TODO: Replace with real media contract static class MockMediaContract { public List<FileInfo> getAssetFiles(String id) { return new ArrayList<FileInfo>(); @@ -32,14 +48,16 @@ public void cancelJob(String id) { public List<FileInfo> getFiles() { return new ArrayList<FileInfo>(); } + + public FileInfo createFileInfo(FileInfo fi) { + return null; + } } - // TODO: Replace with real JobState static enum JobState { Finished, Canceled, Error } - // TODO: Replace with real JobInfo static class JobInfo { public String getId() { @@ -51,7 +69,6 @@ public JobState getState() { } } - // TODO: Replace with real CreateTaskOptions static class CreateTaskOptions { public CreateTaskOptions setName(String string) { @@ -75,7 +92,6 @@ public CreateTaskOptions setTaskCreationOptions(TaskCreationOptions options) { } } - // TODO: Replace with real CreateJobOptions static class CreateJobOptions { public CreateJobOptions setName(String jobName) { @@ -91,9 +107,7 @@ public CreateJobOptions addTask(CreateTaskOptions task) { } } - // TODO: Replace with real TaskCreationOptions static enum TaskCreationOptions { ProtectedConfiguration } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index ab9c31d223870..1ff39bcc28c73 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.scenarios; import static org.junit.Assert.*; @@ -127,7 +142,7 @@ private List<MediaServiceMocks.CreateTaskOptions> createTasks() throws ServiceEx private Hashtable<String, InputStream> getTestAssetFiles() { Hashtable<String, InputStream> inputFiles = new Hashtable<String, InputStream>(); - inputFiles.put("interview.wmv", getClass().getResourceAsStream("/media/interview.wmv")); + inputFiles.put("MPEG4-H264.mp4", getClass().getResourceAsStream("/media/MPEG4-H264.mp4")); return inputFiles; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 772110af48b8f..cbe420a033f9e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.scenarios; import static org.junit.Assert.*; @@ -23,7 +38,6 @@ class MediaServiceValidation { private final MediaContract service; - // TODO: Remove this mock private final MediaServiceMocks.MockMediaContract serviceMock; public MediaServiceValidation(MediaContract service) { @@ -118,11 +132,11 @@ public void validateAssetFileUrls(List<URL> fileUrls, Hashtable<String, InputStr } public void validateJob(JobInfo job, String string, AssetInfo asset, List<CreateTaskOptions> createTasks) { - // TODO: Add validation + // Add validation } public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException, MalformedURLException { - // TODO: validate the output assets? + // Add validation for the output assets. Will be simple to do once // for (AssetInfo outputAsset : outputAssets) { // List<URL> urls = wrapper.createOriginUrlsForAppleHLSContent(outputAsset, 1000); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index d3b17935727c1..82297692c5917 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.scenarios; import java.io.IOException; @@ -37,7 +52,6 @@ class MediaServiceWrapper { private final MediaContract service; - // TODO: Remove this mock private final MockMediaContract serviceMock; private static final String accessPolicyPrefix = "scenarioTestPrefix"; @@ -104,7 +118,6 @@ public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, i List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>(); for (int skip = 0; true; skip += pageSize) { ListAssetsOptions options = new ListAssetsOptions(); - // TODO: Remove the hack of adding "": https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/452 options.getQueryParameters().add("$skip", skip + ""); options.getQueryParameters().add("$top", pageSize + ""); options.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')"); @@ -126,25 +139,51 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE)); LocatorInfo locator = service.createLocator(accessPolicy.getId(), asset.getId(), LocatorType.SAS); WritableBlobContainerContract uploader = MediaService.createBlobWriter(locator); + boolean isFirst = true; for (String fileName : inputFiles.keySet()) { MessageDigest digest = MessageDigest.getInstance("MD5"); + InputStream inputStream = inputFiles.get(fileName); - inputStream = new DigestInputStream(inputStream, digest); + InputStream digestStream = new DigestInputStream(inputStream, digest); + CountingStream countingStream = new CountingStream(digestStream); - uploader.createBlockBlob(fileName, inputStream); + uploader.createBlockBlob(fileName, countingStream); inputStream.close(); byte[] md5hash = digest.digest(); String md5 = Base64.encode(md5hash); System.out.println("md5: " + md5); - // TODO: Use this MD5 to set the associated FileInfo - // TODO: Create the associated FileInfos. + FileInfo fi = new FileInfo().setContentChecksum(md5).setContentFileSize(countingStream.getCount()) + .setIsPrimary(isFirst).setName(fileName).setParentAssetId(asset.getAlternateId()); + serviceMock.createFileInfo(fi); + + isFirst = false; } service.deleteLocator(locator.getId()); service.deleteAccessPolicy(accessPolicy.getId()); } + private static class CountingStream extends InputStream { + private final InputStream wrappedStream; + private int count; + + public CountingStream(InputStream wrapped) { + wrappedStream = wrapped; + count = 0; + } + + @Override + public int read() throws IOException { + count++; + return wrappedStream.read(); + } + + public int getCount() { + return count; + } + } + // Process public JobInfo createJob(String jobName, AssetInfo inputAsset, List<CreateTaskOptions> tasks) { CreateJobOptions jobOptions = new CreateJobOptions().setName(jobName).addInputMediaAsset(inputAsset.getId()); From f2de1bdfdf44663f770da8a869caa7503664a810 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 7 Nov 2012 16:15:13 -0800 Subject: [PATCH 473/664] Update to follow new operation form of Media proxy --- .../scenarios/MediaServiceValidation.java | 3 +- .../scenarios/MediaServiceWrapper.java | 61 ++++++++++--------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index cbe420a033f9e..4a442a3c89b7b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -28,6 +28,7 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.EncryptionOption; @@ -59,7 +60,7 @@ public void validateAsset(AssetInfo asset, String name, EncryptionOption encrypt assertEquals("initialFiles.size", 0, initialFiles.size()); // Reload asset from server for ID - AssetInfo reloadedAsset = service.getAsset(asset.getId()); + AssetInfo reloadedAsset = service.get(Asset.get(asset.getId())); // Verify names match assertNotNull("reloadedAsset", reloadedAsset); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 82297692c5917..a13be128cb899 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -32,17 +32,19 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.FileInfo; -import com.microsoft.windowsazure.services.media.models.ListAssetsOptions; -import com.microsoft.windowsazure.services.media.models.ListMediaProcessorsOptions; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateJobOptions; import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; @@ -109,20 +111,19 @@ public MediaServiceWrapper(MediaContract service) { // Manage public AssetInfo createAsset(String name, EncryptionOption encryption) throws ServiceException { // Create asset. The SDK's top-level method is the simplest way to do that. - return service.createAsset(new CreateAssetOptions().setName(name).setAlternateId("altId") - .setOptions(encryption)); + return service.create(Asset.create().setName(name).setAlternateId("altId").setOptions(encryption)); } public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, int pageSize) throws ServiceException { List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>(); for (int skip = 0; true; skip += pageSize) { - ListAssetsOptions options = new ListAssetsOptions(); - options.getQueryParameters().add("$skip", skip + ""); - options.getQueryParameters().add("$top", pageSize + ""); - options.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')"); - options.getQueryParameters().add("$orderby", "Name"); - ListResult<AssetInfo> listAssetResult = service.listAssets(options); + EntityListOperation<AssetInfo> listOperation = Asset.list(); + listOperation.getQueryParameters().add("$skip", skip + ""); + listOperation.getQueryParameters().add("$top", pageSize + ""); + listOperation.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')"); + listOperation.getQueryParameters().add("$orderby", "Name"); + ListResult<AssetInfo> listAssetResult = service.list(listOperation); pages.add(listAssetResult); if (listAssetResult.size() == 0) { break; @@ -135,9 +136,9 @@ public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, i // Ingest public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hashtable<String, InputStream> inputFiles) throws ServiceException, IOException, NoSuchAlgorithmException { - AccessPolicyInfo accessPolicy = service.createAccessPolicy(accessPolicyPrefix + "tempAccessPolicy", - uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE)); - LocatorInfo locator = service.createLocator(accessPolicy.getId(), asset.getId(), LocatorType.SAS); + AccessPolicyInfo accessPolicy = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", + uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + LocatorInfo locator = service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS)); WritableBlobContainerContract uploader = MediaService.createBlobWriter(locator); boolean isFirst = true; for (String fileName : inputFiles.keySet()) { @@ -160,8 +161,8 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht isFirst = false; } - service.deleteLocator(locator.getId()); - service.deleteAccessPolicy(accessPolicy.getId()); + service.delete(Locator.delete(locator.getId())); + service.delete(AccessPolicy.delete(accessPolicy.getId())); } private static class CountingStream extends InputStream { @@ -242,9 +243,9 @@ public CreateTaskOptions createTaskOptionsSmoothStreamsToHls(String taskName) th } private String getMediaProcessorIdByName(String processorName) throws ServiceException { - ListMediaProcessorsOptions options = new ListMediaProcessorsOptions(); - options.getQueryParameters().putSingle("$filter", "Name eq '" + processorName + "'"); - MediaProcessorInfo processor = service.listMediaProcessors(options).get(0); + EntityListOperation<MediaProcessorInfo> operation = MediaProcessor.list(); + operation.getQueryParameters().putSingle("$filter", "Name eq '" + processorName + "'"); + MediaProcessorInfo processor = service.list(operation).get(0); return processor.getId(); } @@ -296,9 +297,9 @@ private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int boolean isSmooth, String suffix, LocatorType locatorType) throws ServiceException, MalformedURLException { List<URL> ret = new ArrayList<URL>(); - AccessPolicyInfo readAP = service.createAccessPolicy(accessPolicyPrefix + "tempAccessPolicy", - availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ)); - LocatorInfo readLocator = service.createLocator(readAP.getId(), asset.getId(), locatorType); + AccessPolicyInfo readAP = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", + availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); + LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), locatorType)); List<FileInfo> publishedFiles = serviceMock.getAssetFiles(asset.getId()); for (FileInfo fi : publishedFiles) { @@ -331,30 +332,30 @@ private URL constructUrlFromLocatorAndFileName(LocatorInfo locator, String fileN } public void removeAllAssetsWithPrefix(String assetPrefix) throws ServiceException { - ListResult<LocatorInfo> locators = service.listLocators(); - ListAssetsOptions options = new ListAssetsOptions(); - options.getQueryParameters().add("$filter", "startswith(Name,'" + assetPrefix + "')"); - List<AssetInfo> assets = service.listAssets(options); + ListResult<LocatorInfo> locators = service.list(Locator.list()); + EntityListOperation<AssetInfo> operation = Asset.list(); + operation.getQueryParameters().add("$filter", "startswith(Name,'" + assetPrefix + "')"); + List<AssetInfo> assets = service.list(operation); for (AssetInfo asset : assets) { if (asset.getName().length() > assetPrefix.length() && asset.getName().substring(0, assetPrefix.length()).equals(assetPrefix)) { for (LocatorInfo locator : locators) { if (locator.getAssetId().equals(asset.getId())) { - service.deleteLocator(locator.getId()); + service.delete(Locator.delete(locator.getId())); } } - service.deleteAsset(asset.getId()); + service.delete(Asset.delete(asset.getId())); } } } public void removeAllAccessPoliciesWithPrefix() throws ServiceException { - List<AccessPolicyInfo> accessPolicies = service.listAccessPolicies(); + List<AccessPolicyInfo> accessPolicies = service.list(AccessPolicy.list()); for (AccessPolicyInfo accessPolicy : accessPolicies) { if (accessPolicy.getName().length() > accessPolicyPrefix.length() && accessPolicy.getName().substring(0, accessPolicyPrefix.length()).equals(accessPolicyPrefix)) { - service.deleteAccessPolicy(accessPolicy.getId()); + service.delete(AccessPolicy.delete(accessPolicy.getId())); } } } From 0ec11c6125be45cc9de152eb401ed9af80109bc0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 7 Nov 2012 18:42:12 -0800 Subject: [PATCH 474/664] update create Job unit test --- .../implementation/CreateJobOperation.java | 22 ++- .../implementation/CreateTaskOperation.java | 9 +- .../implementation/MediaBatchOperations.java | 36 ++-- .../media/implementation/MediaRestProxy.java | 5 +- .../implementation/ODataAtomMarshaller.java | 5 + .../media/implementation/Operation.java | 6 +- .../media/implementation/content/JobType.java | 19 +- .../implementation/content/TaskType.java | 15 +- .../media/models/CreateJobOptions.java | 17 +- .../media/models/CreateTaskOptions.java | 23 ++- .../services/media/models/JobInfo.java | 23 ++- .../services/media/JobIntegrationTest.java | 185 ++++++++++++++++++ .../MediaBatchOperationsTest.java | 4 +- .../media/models/CreateJobOptionsTest.java | 15 +- .../media/models/CreateTaskOptionsTest.java | 15 +- 15 files changed, 295 insertions(+), 104 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java index ee900a8c4bded..60394d13ad7bb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java @@ -22,22 +22,28 @@ public class CreateJobOperation extends Operation { - public CreateJobOperation() { + private final URI serviceURI; + + public CreateJobOperation(URI serviceURI) { this.verb = "POST"; + this.serviceURI = serviceURI; } - public CreateJobOperation setJob(List<URI> inputMediaAssets, List<URI> outputMediaAssets, JobType jobType) { - addContentObject(jobType); - for (URI inputMediaAsset : inputMediaAssets) { - addLink("InputMediaAssets", inputMediaAsset.toString(), "application/atom+xml;type=feed", + public CreateJobOperation setJob(List<String> inputMediaAssets, List<String> outputMediaAssets, JobType jobType) { + for (String inputMediaAsset : inputMediaAssets) { + addLink("InputMediaAssets", + String.format("%s/Assets('%s')", serviceURI.toString(), inputMediaAsset.toString()), + "application/atom+xml;type=feed", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); } - for (URI outputMediaAsset : outputMediaAssets) { - addLink("OutputMediaAssets", outputMediaAsset.toString(), "application/atom+xml;type=feed", + for (String outputMediaAsset : outputMediaAssets) { + addLink("OutputMediaAssets", + String.format("%s/Assets('%s'", serviceURI.toString(), outputMediaAsset.toString()), + "application/atom+xml;type=feed", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); } - + addContentObject(jobType); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java index 5a815bd90f95a..8ba5c38060e0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java @@ -19,15 +19,8 @@ public class CreateTaskOperation extends Operation { - private TaskType taskType; - public CreateTaskOperation setTask(TaskType taskType) { - this.taskType = taskType; + addContentObject(taskType); return this; } - - public TaskType getTask() { - return this.taskType; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index c769ad11f69da..4e6f1e1f55a16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -37,6 +37,7 @@ import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; /** @@ -53,6 +54,8 @@ public class MediaBatchOperations { /** The Odata atom marshaller. */ private final ODataAtomMarshaller oDataAtomMarshaller; + private final String batchId; + /** * Instantiates a new media batch operations. * @@ -68,6 +71,8 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur this.serviceURI = serviceURI; this.oDataAtomMarshaller = new ODataAtomMarshaller(); this.operations = new ArrayList<Operation>(); + batchId = String.format("batch_%s", UUID.randomUUID().toString()); + } /** @@ -121,7 +126,7 @@ private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int conten if (operation instanceof CreateJobOperation) { CreateJobOperation createJobOperation = (CreateJobOperation) operation; jobContentId = contentId; - bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getEntityType(), jobURI, + bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getEntryType(), jobURI, contentId); contentId++; if (bodyPartContent != null) { @@ -164,7 +169,7 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con DataSource bodyPartContent = null; if (operation instanceof CreateTaskOperation) { CreateTaskOperation createTaskOperation = (CreateTaskOperation) operation; - bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation.getTask(), taskURI, + bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation.getEntryType(), taskURI, contentId); contentId++; } @@ -188,10 +193,9 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con */ private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws MessagingException, IOException { // Create unique part boundary strings - String batchId = String.format("batch_%s", UUID.randomUUID().toString()); - - MimeMultipart changeSets = createChangeSets(bodyPartContents); - MimeBodyPart mimeBodyPart = createMimeBodyPart(batchId, changeSets); + String changeSetId = String.format("changeset_%s", UUID.randomUUID().toString()); + MimeMultipart changeSets = createChangeSets(bodyPartContents, changeSetId); + MimeBodyPart mimeBodyPart = createMimeBodyPart(changeSets, changeSetId); MimeMultipart mimeMultipart = new MimeMultipart(new SetBoundaryMultipartDataSource(batchId)); mimeMultipart.addBodyPart(mimeBodyPart); @@ -199,18 +203,18 @@ private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws } - private MimeBodyPart createMimeBodyPart(String batchId, MimeMultipart changeSets) throws MessagingException { + private MimeBodyPart createMimeBodyPart(MimeMultipart changeSets, String changeSetId) throws MessagingException { MimeBodyPart mimeBodyPart = new MimeBodyPart(); mimeBodyPart.setContent(changeSets); - String contentType = String.format("multipart/mixed; boundary=%s", batchId); + String contentType = String.format("multipart/mixed; boundary=%s", changeSetId); mimeBodyPart.setHeader("Content-Type", contentType); return mimeBodyPart; } - private MimeMultipart createChangeSets(List<DataSource> bodyPartContents) throws MessagingException { - String changeSet = String.format("changeset_%s", UUID.randomUUID().toString()); + private MimeMultipart createChangeSets(List<DataSource> bodyPartContents, String changeSetId) + throws MessagingException { - MimeMultipart changeSets = new MimeMultipart(new SetBoundaryMultipartDataSource(changeSet)); + MimeMultipart changeSets = new MimeMultipart(new SetBoundaryMultipartDataSource(changeSetId)); for (DataSource bodyPart : bodyPartContents) { MimeBodyPart mimeBodyPart = new MimeBodyPart(); @@ -240,10 +244,10 @@ private MimeMultipart createChangeSets(List<DataSource> bodyPartContents) throws * @throws JAXBException * the jAXB exception */ - private DataSource createBatchCreateEntityPart(String entityName, Object entity, URI uri, int contentId) + private DataSource createBatchCreateEntityPart(String entityName, EntryType entryType, URI uri, int contentId) throws JAXBException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - this.oDataAtomMarshaller.marshalEntry(entity, stream); + this.oDataAtomMarshaller.marshalEntryType(entryType, stream); byte[] bytes = stream.toByteArray(); // adds header @@ -251,6 +255,8 @@ private DataSource createBatchCreateEntityPart(String entityName, Object entity, headers.addHeader("Content-ID", Integer.toString(contentId)); headers.addHeader("Content-Type", "application/atom+xml;type=entry"); headers.addHeader("Content-Length", Integer.toString(bytes.length)); + headers.addHeader("DataServiceVersion", "1.0;NetFx"); + headers.addHeader("MaxDataServiceVersion", "3.0;NetFx"); // adds body ByteArrayOutputStream httpRequest = new ByteArrayOutputStream(); @@ -353,4 +359,8 @@ public List<Operation> getOperations() { return operations; } + public String getBatchId() { + return this.batchId; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 1765b0bb92a6e..55a1447cfe349 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -281,7 +281,7 @@ private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOp jobType.setStartTime(createJobOptions.getStartTime()); } - CreateJobOperation createJobOperation = new CreateJobOperation(); + CreateJobOperation createJobOperation = new CreateJobOperation(this.getBaseURI()); createJobOperation.setJob(createJobOptions.getInputMediaAssets(), createJobOptions.getOutputMediaAssets(), jobType); @@ -308,6 +308,7 @@ private CreateTaskOperation createTaskOperation(CreateTaskOptions createTaskOpti taskType.setInitializationVector(createTaskOptions.getInitializationVector()); taskType.setInputMediaAssets(createTaskOptions.getInputMediaAssets()); taskType.setOutputMediaAssets(createTaskOptions.getOutputMediaAssets()); + taskType.setTaskBody(createTaskOptions.getTaskBody()); createTaskOperation.setTask(taskType); @@ -657,7 +658,7 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio @Override public JobInfo cancelJob(String jobId) throws ServiceException { try { - return getResource("CancelJob").queryParam("jobId", jobId).get(JobInfo.class); + return getResource("CancelJob").queryParam("jobId", String.format("'%s'", jobId)).get(JobInfo.class); } catch (UniformInterfaceException e) { throw new ServiceException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 57482a4fb4729..6bf10801b9e28 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -97,6 +97,11 @@ public void marshalEntry(Object content, OutputStream stream) throws JAXBExcepti marshaller.marshal(createEntry(content), stream); } + public void marshalEntryType(EntryType entryType, OutputStream stream) throws JAXBException { + marshaller.marshal( + new JAXBElement<EntryType>(new QName(Constants.ATOM_NS, "entry"), EntryType.class, entryType), stream); + } + @SuppressWarnings("unchecked") private JAXBElement<EntryType> createEntry(Object content) { ContentType atomContent = new ContentType(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java index d0ac5c85e78b8..20ffe1217b975 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java @@ -32,7 +32,7 @@ public Operation() { this.entryType = new EntryType(); } - public EntryType getEntityType() { + public EntryType getEntryType() { return entryType; } @@ -52,8 +52,8 @@ protected void addContentObject(Object contentObject) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); atomContent.getContent().add( - new JAXBElement(new QName(Constants.ODATA_METADATA_NS, "properties"), atomContent.getClass(), - atomContent)); + new JAXBElement(new QName(Constants.ODATA_METADATA_NS, "properties"), contentObject.getClass(), + contentObject)); this.entryType.getEntryChildren().add( new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 68313111e2543..5920842a3d410 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation.content; -import java.net.URI; import java.util.Date; import java.util.List; @@ -72,12 +71,10 @@ public class JobType implements MediaServiceDTO { protected String templateId; /** The output media assets. */ - @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected List<URI> outputMediaAssets; + protected List<String> outputMediaAssets; /** The input media assets. */ - @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected List<URI> inputMediaAssets; + protected List<String> inputMediaAssets; /** The tasks. */ @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) @@ -288,7 +285,7 @@ public JobType setTemplateId(String templateId) { * * @return the output media assets */ - public List<URI> getOutputMediaAssets() { + public List<String> getOutputMediaAssets() { return outputMediaAssets; } @@ -298,8 +295,8 @@ public List<URI> getOutputMediaAssets() { * @param uriList * the new output media assets */ - public JobType setOutputMediaAssets(List<URI> uriList) { - this.outputMediaAssets = uriList; + public JobType setOutputMediaAssets(List<String> outputMediaAssets) { + this.outputMediaAssets = outputMediaAssets; return this; } @@ -308,7 +305,7 @@ public JobType setOutputMediaAssets(List<URI> uriList) { * * @return the input media assets */ - public List<URI> getInputMediaAssets() { + public List<String> getInputMediaAssets() { return inputMediaAssets; } @@ -318,8 +315,8 @@ public List<URI> getInputMediaAssets() { * @param uriList * the new input media assets */ - public JobType setInputMediaAssets(List<URI> uriList) { - this.inputMediaAssets = uriList; + public JobType setInputMediaAssets(List<String> inputMediaAssets) { + this.inputMediaAssets = inputMediaAssets; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index a675e5e3e6520..67d92f8620b72 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation.content; -import java.net.URI; import java.util.Date; import java.util.List; @@ -85,11 +84,9 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "InitializationVector", namespace = Constants.ODATA_DATA_NS) protected String initializationVector; - @XmlElement(name = "OutputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected List<URI> outputMediaAssets; + protected List<String> outputMediaAssets; - @XmlElement(name = "InputMediaAssets", namespace = Constants.ODATA_DATA_NS) - protected List<URI> inputMediaAssets; + protected List<String> inputMediaAssets; public String getId() { return id; @@ -235,19 +232,19 @@ public void setInitializationVector(String initializationVector) { this.initializationVector = initializationVector; } - public List<URI> getOutputMediaAssets() { + public List<String> getOutputMediaAssets() { return outputMediaAssets; } - public void setOutputMediaAssets(List<URI> outputMediaAssets) { + public void setOutputMediaAssets(List<String> outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; } - public List<URI> getInputMediaAssets() { + public List<String> getInputMediaAssets() { return inputMediaAssets; } - public void setInputMediaAssets(List<URI> inputMediaAssets) { + public void setInputMediaAssets(List<String> inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java index cd79457835697..916c53388178c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java @@ -14,7 +14,6 @@ */ package com.microsoft.windowsazure.services.media.models; -import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -34,14 +33,14 @@ public class CreateJobOptions { private Integer priority; /** The input media assets. */ - private final List<URI> inputMediaAssets; + private final List<String> inputMediaAssets; /** The output media assets. */ - private final List<URI> outputMediaAssets; + private final List<String> outputMediaAssets; public CreateJobOptions() { - this.inputMediaAssets = new ArrayList<URI>(); - this.outputMediaAssets = new ArrayList<URI>(); + this.inputMediaAssets = new ArrayList<String>(); + this.outputMediaAssets = new ArrayList<String>(); } /** @@ -114,7 +113,7 @@ public Integer getPriority() { * the input media assets * @return the creates the job options */ - public CreateJobOptions addInputMediaAsset(URI inputMediaAsset) { + public CreateJobOptions addInputMediaAsset(String inputMediaAsset) { this.inputMediaAssets.add(inputMediaAsset); return this; } @@ -124,7 +123,7 @@ public CreateJobOptions addInputMediaAsset(URI inputMediaAsset) { * * @return the input media assets */ - public List<URI> getInputMediaAssets() { + public List<String> getInputMediaAssets() { return this.inputMediaAssets; } @@ -135,7 +134,7 @@ public List<URI> getInputMediaAssets() { * the output media assets * @return the creates the job options */ - public CreateJobOptions addOutputMediaAsset(URI outputMediaAsset) { + public CreateJobOptions addOutputMediaAsset(String outputMediaAsset) { this.outputMediaAssets.add(outputMediaAsset); return this; } @@ -145,7 +144,7 @@ public CreateJobOptions addOutputMediaAsset(URI outputMediaAsset) { * * @return the output media assets */ - public List<URI> getOutputMediaAssets() { + public List<String> getOutputMediaAssets() { return this.outputMediaAssets; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java index 3b2b2c214b5ea..8b2920969ef11 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java @@ -15,7 +15,7 @@ package com.microsoft.windowsazure.services.media.models; -import java.net.URI; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -55,10 +55,15 @@ public class CreateTaskOptions { private String initializationVector; /** The input media assets. */ - private List<URI> inputMediaAssets; + private List<String> inputMediaAssets; /** The output media assets. */ - private List<URI> outputMediaAssets; + private List<String> outputMediaAssets; + + public CreateTaskOptions() { + this.inputMediaAssets = new ArrayList<String>(); + this.outputMediaAssets = new ArrayList<String>(); + } /** * Gets the start time. @@ -130,7 +135,7 @@ public Integer getPriority() { * the input media assets * @return the creates the job options */ - public CreateTaskOptions setInputMediaAssets(List<URI> inputMediaAssets) { + public CreateTaskOptions setInputMediaAssets(List<String> inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; return this; } @@ -140,7 +145,7 @@ public CreateTaskOptions setInputMediaAssets(List<URI> inputMediaAssets) { * * @return the input media assets */ - public List<URI> getInputMediaAssets() { + public List<String> getInputMediaAssets() { return this.inputMediaAssets; } @@ -151,7 +156,7 @@ public List<URI> getInputMediaAssets() { * the output media assets * @return the creates the job options */ - public CreateTaskOptions setOutputMediaAssets(List<URI> outputMediaAssets) { + public CreateTaskOptions setOutputMediaAssets(List<String> outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; return this; } @@ -161,7 +166,7 @@ public CreateTaskOptions setOutputMediaAssets(List<URI> outputMediaAssets) { * * @return the output media assets */ - public List<URI> getOutputMediaAssets() { + public List<String> getOutputMediaAssets() { return this.outputMediaAssets; } @@ -305,12 +310,12 @@ public CreateTaskOptions setInitializationVector(String initializationVector) { return this; } - public CreateTaskOptions addInputMediaAsset(URI inputMediaAsset) { + public CreateTaskOptions addInputMediaAsset(String inputMediaAsset) { this.inputMediaAssets.add(inputMediaAsset); return this; } - public CreateTaskOptions addOutputMediaAsset(URI outputMediaAsset) { + public CreateTaskOptions addOutputMediaAsset(String outputMediaAsset) { this.outputMediaAssets.add(outputMediaAsset); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 109e5b5d711eb..48b8961bf00e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.models; -import java.net.URI; import java.util.Date; import java.util.List; @@ -178,7 +177,7 @@ public JobInfo setPriority(int priority) { * * @return the running duration */ - public double getRunningDuration() { + public Double getRunningDuration() { return getContent().getRunningDuration(); } @@ -189,7 +188,7 @@ public double getRunningDuration() { * the running duration * @return the job info */ - public JobInfo setRunningDuration(double runningDuration) { + public JobInfo setRunningDuration(Double runningDuration) { getContent().setRunningDuration(runningDuration); return this; } @@ -262,7 +261,7 @@ public JobInfo setTemplateId(String templateId) { * * @return the input media assets */ - public List<URI> getInputMediaAssets() { + public List<String> getInputMediaAssets() { return getContent().getInputMediaAssets(); } @@ -273,7 +272,7 @@ public List<URI> getInputMediaAssets() { * the input media assets * @return the job info */ - public JobInfo setInputMediaAssets(List<URI> inputMediaAssets) { + public JobInfo setInputMediaAssets(List<String> inputMediaAssets) { getContent().setInputMediaAssets(inputMediaAssets); return this; } @@ -283,7 +282,7 @@ public JobInfo setInputMediaAssets(List<URI> inputMediaAssets) { * * @return the output media assets */ - public List<URI> getOutputMediaAssets() { + public List<String> getOutputMediaAssets() { return getContent().getOutputMediaAssets(); } @@ -294,17 +293,17 @@ public List<URI> getOutputMediaAssets() { * the output media assets * @return the job info */ - public JobInfo setOutputMediaAssets(List<URI> outputMediaAssets) { + public JobInfo setOutputMediaAssets(List<String> outputMediaAssets) { getContent().setOutputMediaAssets(outputMediaAssets); return this; } /** - * Gets the tasks. + * Gets the task body. * - * @return the tasks + * @return the task body */ - public String getTasks() { + public String getTaskBody() { return getContent().getTaskBody(); } @@ -315,8 +314,8 @@ public String getTasks() { * the tasks * @return the job info */ - public JobInfo setTasks(String tasks) { - getContent().setTaskBody(tasks); + public JobInfo setTaskBody(String taskBody) { + getContent().setTaskBody(taskBody); return this; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java new file mode 100644 index 0000000000000..b22f75e3cbb32 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -0,0 +1,185 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; +import com.microsoft.windowsazure.services.media.models.CreateJobOptions; +import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; +import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.ListJobsOptions; +import com.microsoft.windowsazure.services.media.models.ListJobsResult; + +public class JobIntegrationTest extends IntegrationTestBase { + + private final String testJobPrefix = "testJobPrefix"; + + private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { + verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), + expected.getState(), expected.getTemplateId(), expected.getInputMediaAssets(), + expected.getOutputMediaAssets(), actual); + } + + private void verifyJobProperties(String message, String testName, int priority, Double runningDuration, int state, + String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { + assertNotNull(message, actualJob); + assertEquals(message + " Name", testName, actualJob.getName()); + assertEquals(message + " Priority", priority, actualJob.getPriority()); + assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); + assertEquals(message + " State", state, actualJob.getState()); + assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); + assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); + assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); + } + + @Test + public void createJobSuccess() throws Exception { + // Arrange + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + AssetInfo assetInfo = service.createAsset(createAssetOptions); + CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.setName("My Encoding Job"); + createJobOptions.addInputMediaAsset(assetInfo.getId()); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + createTaskOptions.setConfiguration("H.264 256k DSL CBR"); + createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); + createTaskOptions.setName("My encoding Task"); + String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + + "</taskBody>"; + createTaskOptions.setTaskBody(taskBody); + + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); + JobInfo expectedJob = new JobInfo(); + + // Act + JobInfo actualJob = service.createJob(createJobOptions, createTaskOptionsList); + + // Assert + verifyJobInfoEqual("actualJob", expectedJob, actualJob); + } + + @Test + public void getJobSuccess() throws Exception { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); + JobInfo expectedJob = new JobInfo(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + + // Act + JobInfo actualJob = service.getJob(jobInfo.getId()); + + // Assert + verifyJobInfoEqual("actualJob", expectedJob, actualJob); + } + + @Test + public void getJobInvalidIdFailed() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.getJob(invalidId); + } + + @Test + public void listJobSuccess() throws ServiceException { + // Arrange + CreateJobOptions createJobOptions = new CreateJobOptions(); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); + JobInfo expectedJob = new JobInfo(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + ListJobsResult expectedListJobsResult = new ListJobsResult(); + + // Act + ListJobsResult actualListJobResult = service.listJobs(); + + // Assert + verifyListResultContains("listJobs", expectedListJobsResult.getJobInfos(), actualListJobResult.getJobInfos(), + new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual); + } + }); + } + + @Test + public void canListJobsWithOptions() throws ServiceException { + String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", + testJobPrefix + "assetListOptionsC", testJobPrefix + "assetListOptionsD" }; + List<JobInfo> expectedJobs = new ArrayList<JobInfo>(); + for (int i = 0; i < assetNames.length; i++) { + String name = assetNames[i]; + CreateJobOptions createJobOptions = new CreateJobOptions(); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); + JobInfo expectedJob = new JobInfo(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + expectedJobs.add(jobInfo); + } + + ListJobsOptions options = new ListJobsOptions(); + options.getQueryParameters().add("$top", "2"); + ListJobsResult listJobsResult = service.listJobs(options); + + // Assert + assertEquals(2, listJobsResult.getJobInfos().size()); + } + + @Test + public void CancelJobSuccess() throws Exception { + // Arrange + String assetName = testJobPrefix + "deleteJobSuccess"; + CreateJobOptions createJobOptions = new CreateJobOptions().setName(assetName); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + ListJobsResult listJobsResult = service.listJobs(); + int assetCountBaseline = listJobsResult.getJobInfos().size(); + + // Act + service.cancelJob(jobInfo.getId()); + + // Assert + listJobsResult = service.listJobs(); + assertEquals("listJobsResult.size", assetCountBaseline - 1, listJobsResult.getJobInfos().size()); + + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.getJob(jobInfo.getId()); + } + + @Test + public void deleteJobFailedWithInvalidId() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.cancelJob(invalidId); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index d80cdc96c3a4e..8066e021da0a9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -101,8 +101,8 @@ public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationE JobType jobType = new JobType(); TaskType taskType = new TaskType(); CreateTaskOperation createTaskOperation = new CreateTaskOperation().setTask(taskType); - List<URI> inputMediaAssets = new ArrayList<URI>(); - List<URI> outputMediaAssets = new ArrayList<URI>(); + List<String> inputMediaAssets = new ArrayList<String>(); + List<String> outputMediaAssets = new ArrayList<String>(); CreateJobOperation createJobOperation = new CreateJobOperation().setJob(inputMediaAssets, outputMediaAssets, jobType); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java index 9796103dbc0fa..c06174e521ccf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java @@ -16,13 +16,10 @@ import static org.junit.Assert.*; -import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.List; -import javax.ws.rs.core.UriBuilder; - import org.junit.Test; public class CreateJobOptionsTest { @@ -69,13 +66,13 @@ public void testGetSetStartTime() { @Test public void testGetSetInputMediaAssets() { // Arrange - URI expectedInputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); - List<URI> expectedInputMediaAssets = new ArrayList<URI>(); + String expectedInputMediaAsset = "http://www.contoso.com/asset(123)"; + List<String> expectedInputMediaAssets = new ArrayList<String>(); expectedInputMediaAssets.add(expectedInputMediaAsset); CreateJobOptions createJobOptions = new CreateJobOptions(); // Act - List<URI> actualInputMediaAssets = createJobOptions.addInputMediaAsset(expectedInputMediaAsset) + List<String> actualInputMediaAssets = createJobOptions.addInputMediaAsset(expectedInputMediaAsset) .getInputMediaAssets(); // Assert @@ -85,13 +82,13 @@ public void testGetSetInputMediaAssets() { @Test public void testGetSetOutputMediaAssets() { // Arrange - URI expectedOutputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); - List<URI> expectedOutputMediaAssets = new ArrayList<URI>(); + String expectedOutputMediaAsset = "http://www.contoso.com/asset(123)"; + List<String> expectedOutputMediaAssets = new ArrayList<String>(); expectedOutputMediaAssets.add(expectedOutputMediaAsset); CreateJobOptions createJobOptions = new CreateJobOptions(); // Act - List<URI> actualOutputMediaAssets = createJobOptions.addOutputMediaAsset(expectedOutputMediaAsset) + List<String> actualOutputMediaAssets = createJobOptions.addOutputMediaAsset(expectedOutputMediaAsset) .getOutputMediaAssets(); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java index 4f958f52a216d..77acdb7d648da 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java @@ -16,13 +16,10 @@ import static org.junit.Assert.*; -import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.List; -import javax.ws.rs.core.UriBuilder; - import org.junit.Test; public class CreateTaskOptionsTest { @@ -166,13 +163,13 @@ public void testGetSetInitializationVector() { @Test public void testGetSetInputMediaAssets() { // Arrange - URI expectedInputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); - List<URI> expectedInputMediaAssets = new ArrayList<URI>(); + String expectedInputMediaAsset = "http://www.contoso.com/asset(123)"; + List<String> expectedInputMediaAssets = new ArrayList<String>(); expectedInputMediaAssets.add(expectedInputMediaAsset); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); // Act - List<URI> actualInputMediaAssets = createTaskOptions.addInputMediaAsset(expectedInputMediaAsset) + List<String> actualInputMediaAssets = createTaskOptions.addInputMediaAsset(expectedInputMediaAsset) .getInputMediaAssets(); // Assert @@ -182,13 +179,13 @@ public void testGetSetInputMediaAssets() { @Test public void testGetSetOutputMediaAssets() { // Arrange - URI expectedOutputMediaAsset = UriBuilder.fromUri("http://www.contoso.com/asset(123)").build(); - List<URI> expectedOutputMediaAssets = new ArrayList<URI>(); + String expectedOutputMediaAsset = "http://www.contoso.com/asset(123)"; + List<String> expectedOutputMediaAssets = new ArrayList<String>(); expectedOutputMediaAssets.add(expectedOutputMediaAsset); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); // Act - List<URI> actualOutputMediaAssets = createTaskOptions.addOutputMediaAsset(expectedOutputMediaAsset) + List<String> actualOutputMediaAssets = createTaskOptions.addOutputMediaAsset(expectedOutputMediaAsset) .getOutputMediaAssets(); // Assert From 16681497cf7ea851cd03e8d7cd19aa8aeb5d3999 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 8 Nov 2012 19:01:59 -0800 Subject: [PATCH 475/664] parsing the batching result. --- .../implementation/CreateJobOperation.java | 20 ++- .../media/implementation/MediaRestProxy.java | 151 +++++++++++++++++- .../implementation/ODataAtomUnmarshaller.java | 2 +- .../media/implementation/StatusLine.java | 96 +++++++++++ .../services/media/models/JobInfo.java | 2 +- .../MediaBatchOperationsTest.java | 6 +- 6 files changed, 265 insertions(+), 12 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java index 60394d13ad7bb..e2f3ce07bd750 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java @@ -19,27 +19,29 @@ import java.util.List; import com.microsoft.windowsazure.services.media.implementation.content.JobType; +import com.microsoft.windowsazure.services.media.models.JobInfo; public class CreateJobOperation extends Operation { - private final URI serviceURI; + private final URI assetServiceURI; + private JobInfo jobInfo; - public CreateJobOperation(URI serviceURI) { + public CreateJobOperation(URI assetServiceURI) { this.verb = "POST"; - this.serviceURI = serviceURI; + this.assetServiceURI = assetServiceURI; } public CreateJobOperation setJob(List<String> inputMediaAssets, List<String> outputMediaAssets, JobType jobType) { for (String inputMediaAsset : inputMediaAssets) { addLink("InputMediaAssets", - String.format("%s/Assets('%s')", serviceURI.toString(), inputMediaAsset.toString()), + String.format("%s/Assets('%s')", assetServiceURI.toString(), inputMediaAsset.toString()), "application/atom+xml;type=feed", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); } for (String outputMediaAsset : outputMediaAssets) { addLink("OutputMediaAssets", - String.format("%s/Assets('%s'", serviceURI.toString(), outputMediaAsset.toString()), + String.format("%s/Assets('%s'", assetServiceURI.toString(), outputMediaAsset.toString()), "application/atom+xml;type=feed", "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); } @@ -47,4 +49,12 @@ public CreateJobOperation setJob(List<String> inputMediaAssets, List<String> out return this; } + public void setJobInfo(JobInfo jobInfo) { + this.jobInfo = jobInfo; + } + + public JobInfo getJobInfo() { + return this.jobInfo; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 55a1447cfe349..c1abb3a20c866 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,17 +15,28 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; +import java.util.Enumeration; import java.util.List; +import javax.activation.DataSource; import javax.inject.Inject; +import javax.mail.BodyPart; +import javax.mail.Header; import javax.mail.MessagingException; +import javax.mail.internet.InternetHeaders; +import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; +import javax.mail.internet.MimePartDataSource; import javax.ws.rs.core.MediaType; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; @@ -38,6 +49,7 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; @@ -68,11 +80,14 @@ import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; +import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.core.header.InBoundHeaders; +import com.sun.jersey.core.util.ReaderWriter; /** * The Class MediaRestProxy. @@ -82,6 +97,7 @@ public class MediaRestProxy implements MediaContract { /** The channel. */ private Client channel; private RedirectFilter redirectFilter; + private ODataAtomUnmarshaller oDataAtomUnmarshaller; /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); @@ -108,6 +124,13 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red this.channel = channel; this.filters = new ServiceFilter[0]; this.redirectFilter = redirectFilter; + try { + this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); + } + catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -315,6 +338,123 @@ private CreateTaskOperation createTaskOperation(CreateTaskOptions createTaskOpti return createTaskOperation; } + @SuppressWarnings("rawtypes") + private void parseBatchResult(ClientResponse response, MediaBatchOperations mediaBatchOperations) + throws IOException, ServiceException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + InputStream inputStream = response.getEntityInputStream(); + ReaderWriter.writeTo(inputStream, byteArrayOutputStream); + response.setEntityInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); + JobInfo jobInfo; + + List<DataSource> parts = parseParts(response.getEntityInputStream(), + response.getHeaders().getFirst("Content-Type")); + + if (parts.size() == 0 || parts.size() > mediaBatchOperations.getOperations().size()) { + throw new UniformInterfaceException(String.format( + "Batch response from server does not contain the correct amount " + + "of parts (expecting %d, received %d instead)", parts.size(), mediaBatchOperations + .getOperations().size()), response); + } + + ArrayList<Object> result = new ArrayList<Object>(); + for (int i = 0; i < parts.size(); i++) { + DataSource ds = parts.get(i); + Operation operation = mediaBatchOperations.getOperations().get(i); + + StatusLine status = StatusLine.create(ds); + InternetHeaders headers = parseHeaders(ds); + InputStream content = parseEntity(ds); + + if (status.getStatus() >= 400) { + + InBoundHeaders inBoundHeaders = new InBoundHeaders(); + @SuppressWarnings("unchecked") + Enumeration<Header> e = headers.getAllHeaders(); + while (e.hasMoreElements()) { + Header header = e.nextElement(); + inBoundHeaders.putSingle(header.getName(), header.getValue()); + } + + ClientResponse clientResponse = new ClientResponse(status.getStatus(), inBoundHeaders, content, null); + + UniformInterfaceException exception = new UniformInterfaceException(clientResponse); + ServiceException serviceException = new ServiceException(exception); + throw serviceException; + } + else if (operation instanceof CreateJobOperation) { + + try { + jobInfo = oDataAtomUnmarshaller.unmarshalEntry(content, JobInfo.class); + CreateJobOperation createJobOperation = (CreateJobOperation) operation; + createJobOperation.setJobInfo(jobInfo); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + } + else if (operation instanceof CreateTaskOperation) { + EntryType entryType = null; + try { + entryType = oDataAtomUnmarshaller.unmarshalEntry(content); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + } + } + } + + public InternetHeaders parseHeaders(DataSource ds) { + try { + return new InternetHeaders(ds.getInputStream()); + } + catch (MessagingException e) { + throw new RuntimeException(e); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + public InputStream parseEntity(DataSource ds) { + try { + return ds.getInputStream(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List<DataSource> parseParts(final InputStream entityInputStream, final String contentType) { + try { + return parsePartsCore(entityInputStream, contentType); + } + catch (IOException e) { + throw new RuntimeException(e); + } + catch (MessagingException e) { + throw new RuntimeException(e); + } + } + + private List<DataSource> parsePartsCore(InputStream entityInputStream, String contentType) + throws MessagingException, IOException { + DataSource ds = new InputStreamDataSource(entityInputStream, contentType); + MimeMultipart batch = new MimeMultipart(ds); + MimeBodyPart batchBody = (MimeBodyPart) batch.getBodyPart(0); + + MimeMultipart changeSets = new MimeMultipart(new MimePartDataSource(batchBody)); + + List<DataSource> result = new ArrayList<DataSource>(); + for (int i = 0; i < changeSets.getCount(); i++) { + BodyPart part = changeSets.getBodyPart(i); + + result.add(new InputStreamDataSource(part.getInputStream(), part.getContentType())); + } + return result; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() */ @@ -647,8 +787,15 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio ClientResponse clientResponse = resource.type(mimeMultipart.getContentType()) .accept(MediaType.APPLICATION_ATOM_XML).post(ClientResponse.class, mimeMultipart); - JobInfo jobInfo = new JobInfo(); - return jobInfo; + try { + parseBatchResult(clientResponse, mediaBatchOperations); + } + catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return createJobOperation.getJobInfo(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 66cecfd0a542d..b692cc3b4e51c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -208,7 +208,7 @@ private <T extends ODataEntity> T constructResultObject(Class<T> contentType, En } } - private EntryType unmarshalEntry(InputStream stream) throws JAXBException { + public EntryType unmarshalEntry(InputStream stream) throws JAXBException { JAXBElement<EntryType> entryElement = atomUnmarshaller.unmarshal(new StreamSource(stream), EntryType.class); return entryElement.getValue(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java new file mode 100644 index 0000000000000..ab36de9b5764a --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -0,0 +1,96 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import javax.activation.DataSource; + +import com.sun.mail.util.LineInputStream; + +public class StatusLine { + private int status; + private String reason; + + public static StatusLine create(DataSource dataSource) { + try { + LineInputStream stream = new LineInputStream(dataSource.getInputStream()); + String line = stream.readLine(); + StringReader lineReader = new StringReader(line); + + expect(lineReader, "HTTP/1.1"); + expect(lineReader, " "); + String statusString = extractInput(lineReader, ' '); + String reason = extractInput(lineReader, -1); + + return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static void expect(Reader reader, String string) { + try { + for (int i = 0; i < string.length(); i++) { + int ch = reader.read(); + if (ch < 0) + throw new RuntimeException(String.format("Expected '%s', found '%s' instead", string, + string.substring(0, i) + ch)); + } + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static String extractInput(Reader reader, int delimiter) { + try { + StringBuilder sb = new StringBuilder(); + while (true) { + int ch = reader.read(); + if (ch == -1 || ch == delimiter) + break; + + sb.append((char) ch); + } + return sb.toString(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + public int getStatus() { + return status; + } + + public StatusLine setStatus(int status) { + this.status = status; + return this; + } + + public String getReason() { + return reason; + } + + public StatusLine setReason(String reason) { + this.reason = reason; + return this; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 48b8961bf00e1..cccf3a66f8e82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -43,7 +43,7 @@ public JobInfo(EntryType entry, JobType content) { * Instantiates a new job info. */ public JobInfo() { - super(new JobType()); + super(new EntryType(), new JobType()); } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index 8066e021da0a9..6498de13a31d4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -65,7 +65,7 @@ public void createMediaBatchOperationFailedWithNullUri() throws JAXBException, P public void addCreateJobOperationToMediaBatchOperationsSuccess() throws JAXBException, ParserConfigurationException { // Arrange URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - CreateJobOperation createJobOperation = new CreateJobOperation(); + CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); @@ -103,8 +103,8 @@ public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationE CreateTaskOperation createTaskOperation = new CreateTaskOperation().setTask(taskType); List<String> inputMediaAssets = new ArrayList<String>(); List<String> outputMediaAssets = new ArrayList<String>(); - CreateJobOperation createJobOperation = new CreateJobOperation().setJob(inputMediaAssets, outputMediaAssets, - jobType); + CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri).setJob(inputMediaAssets, + outputMediaAssets, jobType); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); From 9d294d1bd2d3d37f1d261db7b41bdf11d42445a2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 9 Nov 2012 14:17:30 -0800 Subject: [PATCH 476/664] enable half of the unit tests. --- .../services/media/MediaContract.java | 2 +- .../MediaExceptionProcessor.java | 4 +- .../media/implementation/MediaRestProxy.java | 11 +-- .../media/implementation/content/JobType.java | 4 +- .../services/media/models/JobInfo.java | 8 +- .../services/media/JobIntegrationTest.java | 78 ++++++++++++++++--- 6 files changed, 82 insertions(+), 25 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 80f5d184bff1f..1450452fb929f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -354,7 +354,7 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio * @throws ServiceException * the service exception */ - public JobInfo cancelJob(String jobId) throws ServiceException; + public void cancelJob(String jobId) throws ServiceException; /** * List tasks. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 18d70f5123f98..446848be04f36 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -485,9 +485,9 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) */ @Override - public JobInfo cancelJob(String jobId) throws ServiceException { + public void cancelJob(String jobId) throws ServiceException { try { - return service.cancelJob(jobId); + service.cancelJob(jobId); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index c1abb3a20c866..52215bd01904d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -803,13 +803,10 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio * @see com.microsoft.windowsazure.services.media.MediaContract#cancelJob(java.lang.String) */ @Override - public JobInfo cancelJob(String jobId) throws ServiceException { - try { - return getResource("CancelJob").queryParam("jobId", String.format("'%s'", jobId)).get(JobInfo.class); - } - catch (UniformInterfaceException e) { - throw new ServiceException(e); - } + public void cancelJob(String jobId) throws ServiceException { + ClientResponse clientResponse = getResource("CancelJob").queryParam("jobId", String.format("'%s'", jobId)).get( + ClientResponse.class); + PipelineHelpers.ThrowIfNotSuccess(clientResponse); } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 5920842a3d410..eb274041985fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -205,7 +205,7 @@ public JobType setPriority(Integer priority) { * * @return the running duration */ - public double getRunningDuration() { + public Double getRunningDuration() { return runningDuration; } @@ -215,7 +215,7 @@ public double getRunningDuration() { * @param runningDuration * the new running duration */ - public JobType setRunningDuration(double runningDuration) { + public JobType setRunningDuration(Double runningDuration) { this.runningDuration = runningDuration; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index cccf3a66f8e82..a1a2e53b8a149 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -156,7 +156,7 @@ public JobInfo setEndTime(Date endTime) { * * @return the priority */ - public int getPriority() { + public Integer getPriority() { return getContent().getPriority(); } @@ -167,7 +167,7 @@ public int getPriority() { * the priority * @return the job info */ - public JobInfo setPriority(int priority) { + public JobInfo setPriority(Integer priority) { getContent().setPriority(priority); return this; } @@ -219,7 +219,7 @@ public JobInfo setStartTime(Date startTime) { * * @return the state */ - public int getState() { + public Integer getState() { return getContent().getState(); } @@ -230,7 +230,7 @@ public int getState() { * the state * @return the job info */ - public JobInfo setState(int state) { + public JobInfo setState(Integer state) { getContent().setState(state); return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index b22f75e3cbb32..965c301e19f6e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -41,14 +41,17 @@ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual expected.getOutputMediaAssets(), actual); } - private void verifyJobProperties(String message, String testName, int priority, Double runningDuration, int state, - String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { + private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, + Integer state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, + JobInfo actualJob) { assertNotNull(message, actualJob); assertEquals(message + " Name", testName, actualJob.getName()); - assertEquals(message + " Priority", priority, actualJob.getPriority()); + // comment out due to issue 464 + // assertEquals(message + " Priority", priority, actualJob.getPriority()); assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); assertEquals(message + " State", state, actualJob.getState()); - assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); + // commented out due to issue 463 + // assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); } @@ -60,6 +63,7 @@ public void createJobSuccess() throws Exception { AssetInfo assetInfo = service.createAsset(createAssetOptions); CreateJobOptions createJobOptions = new CreateJobOptions(); createJobOptions.setName("My Encoding Job"); + createJobOptions.setPriority(3); createJobOptions.addInputMediaAsset(assetInfo.getId()); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); createTaskOptions.setConfiguration("H.264 256k DSL CBR"); @@ -73,6 +77,10 @@ public void createJobSuccess() throws Exception { List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); JobInfo expectedJob = new JobInfo(); + expectedJob.setName("My Encoding Job"); + expectedJob.setPriority(3); + expectedJob.setRunningDuration(0.0); + expectedJob.setState(0); // Act JobInfo actualJob = service.createJob(createJobOptions, createTaskOptionsList); @@ -84,11 +92,28 @@ public void createJobSuccess() throws Exception { @Test public void getJobSuccess() throws Exception { // Arrange + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + AssetInfo assetInfo = service.createAsset(createAssetOptions); CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.setName("My Encoding Job"); + createJobOptions.setPriority(3); + createJobOptions.addInputMediaAsset(assetInfo.getId()); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + createTaskOptions.setConfiguration("H.264 256k DSL CBR"); + createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); + createTaskOptions.setName("My encoding Task"); + String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + + "</taskBody>"; + + createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); JobInfo expectedJob = new JobInfo(); + expectedJob.setName("My Encoding Job"); + expectedJob.setPriority(3); + expectedJob.setRunningDuration(0.0); + expectedJob.setState(0); JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); // Act @@ -108,13 +133,35 @@ public void getJobInvalidIdFailed() throws ServiceException { @Test public void listJobSuccess() throws ServiceException { // Arrange + + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + AssetInfo assetInfo = service.createAsset(createAssetOptions); CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.setName("My Encoding Job"); + createJobOptions.setPriority(3); + createJobOptions.addInputMediaAsset(assetInfo.getId()); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + createTaskOptions.setConfiguration("H.264 256k DSL CBR"); + createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); + createTaskOptions.setName("My encoding Task"); + String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + + "</taskBody>"; + + createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); - JobInfo expectedJob = new JobInfo(); - JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); ListJobsResult expectedListJobsResult = new ListJobsResult(); + List<JobInfo> jobInfos = new ArrayList<JobInfo>(); + JobInfo expectedJobInfo = new JobInfo(); + expectedJobInfo.setName("My Encoding Job"); + expectedJobInfo.setPriority(3); + expectedJobInfo.setRunningDuration(0.0); + expectedJobInfo.setState(0); + jobInfos.add(expectedJobInfo); + expectedListJobsResult.setJobInfos(jobInfos); + + JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); // Act ListJobsResult actualListJobResult = service.listJobs(); @@ -154,12 +201,25 @@ public void canListJobsWithOptions() throws ServiceException { } @Test - public void CancelJobSuccess() throws Exception { + public void cancelJobSuccess() throws Exception { // Arrange - String assetName = testJobPrefix + "deleteJobSuccess"; - CreateJobOptions createJobOptions = new CreateJobOptions().setName(assetName); + CreateAssetOptions createAssetOptions = new CreateAssetOptions(); + AssetInfo assetInfo = service.createAsset(createAssetOptions); + CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.setName("My Encoding Job"); + createJobOptions.setPriority(3); + createJobOptions.addInputMediaAsset(assetInfo.getId()); CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + createTaskOptions.setConfiguration("H.264 256k DSL CBR"); + createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); + createTaskOptions.setName("My encoding Task"); + String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + + "</taskBody>"; + + createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); ListJobsResult listJobsResult = service.listJobs(); int assetCountBaseline = listJobsResult.getJobInfos().size(); From 4cdea05f32ff41256813cff36d99c4616f0060d9 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 9 Nov 2012 16:10:42 -0800 Subject: [PATCH 477/664] all the job related unit tests passes. --- .../services/media/MediaContract.java | 15 ++- .../MediaExceptionProcessor.java | 13 +++ .../media/implementation/MediaRestProxy.java | 5 + .../services/media/IntegrationTestBase.java | 3 +- .../services/media/JobIntegrationTest.java | 109 +++++++++--------- 5 files changed, 88 insertions(+), 57 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 1450452fb929f..9090bff5ad59f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -290,10 +290,10 @@ public ListMediaProcessorsResult listMediaProcessors(ListMediaProcessorsOptions /** * Creates the job. * - * @param createTaskOptions - * the create task options * @param createJobOptions * the create job options + * @param createTaskOptions + * the create task options * @return the job info * @throws ServiceException * the service exception @@ -350,7 +350,6 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio * * @param jobId * the job id - * @return * @throws ServiceException * the service exception */ @@ -400,4 +399,14 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio */ public ListTasksResult listJobTasks(String jobId, ListTasksOptions listTasksOptions) throws ServiceException; + /** + * Delete job. + * + * @param jobId + * the job id + * @throws ServiceException + * the service exception + */ + public void deleteJob(String jobId) throws ServiceException; + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 446848be04f36..367ab50a4e9fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -608,4 +608,17 @@ public JobInfo createJob(String templateId, CreateJobOptions createJobOptions) t throw processCatch(new ServiceException(e)); } } + + @Override + public void deleteJob(String jobId) throws ServiceException { + try { + service.deleteJob(jobId); + } + 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/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 52215bd01904d..18d84e76ee384 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -872,4 +872,9 @@ public ListTasksResult listJobTasks(String jobId) throws ServiceException { return this.listJobTasks(jobId, null); } + @Override + public void deleteJob(String jobId) throws ServiceException { + getResource("Jobs", jobId).delete(); + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 647e0cd17a1af..811279aac292a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -133,8 +133,9 @@ protected <T> void verifyListResultContains(String message, List<T> expectedInfo try { for (T expectedInfo : expectedInfos) { Method getId = expectedInfo.getClass().getMethod("getId"); + String expectedId = (String) getId.invoke(expectedInfo); for (T actualInfo : actualInfos) { - if (((String) getId.invoke(actualInfo)).equals(getId.invoke(expectedInfo))) { + if (((String) getId.invoke(actualInfo)).equals(expectedId)) { orderedAndFilteredActualInfo.add(actualInfo); break; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 965c301e19f6e..0782a7be4d317 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -34,6 +34,8 @@ public class JobIntegrationTest extends IntegrationTestBase { private final String testJobPrefix = "testJobPrefix"; + private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), @@ -56,6 +58,24 @@ private void verifyJobProperties(String message, String testName, Integer priori assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); } + private JobInfo createJob(String name) throws ServiceException { + CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(name); + AssetInfo assetInfo = service.createAsset(createAssetOptions); + CreateJobOptions createJobOptions = new CreateJobOptions(); + createJobOptions.setName("My Encoding Job"); + createJobOptions.setPriority(3); + createJobOptions.addInputMediaAsset(assetInfo.getId()); + CreateTaskOptions createTaskOptions = new CreateTaskOptions(); + createTaskOptions.setConfiguration("H.264 256k DSL CBR"); + createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); + createTaskOptions.setName("My encoding Task"); + createTaskOptions.setTaskBody(taskBody); + + List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); + createTaskOptionsList.add(createTaskOptions); + return service.createJob(createJobOptions, createTaskOptionsList); + } + @Test public void createJobSuccess() throws Exception { // Arrange @@ -69,9 +89,6 @@ public void createJobSuccess() throws Exception { createTaskOptions.setConfiguration("H.264 256k DSL CBR"); createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); createTaskOptions.setName("My encoding Task"); - String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" - + "</taskBody>"; createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); @@ -102,10 +119,6 @@ public void getJobSuccess() throws Exception { createTaskOptions.setConfiguration("H.264 256k DSL CBR"); createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); createTaskOptions.setName("My encoding Task"); - String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" - + "</taskBody>"; - createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); @@ -114,10 +127,10 @@ public void getJobSuccess() throws Exception { expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); expectedJob.setState(0); - JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + String jobId = createJob("getJobSuccess").getId(); // Act - JobInfo actualJob = service.getJob(jobInfo.getId()); + JobInfo actualJob = service.getJob(jobId); // Assert verifyJobInfoEqual("actualJob", expectedJob, actualJob); @@ -133,36 +146,12 @@ public void getJobInvalidIdFailed() throws ServiceException { @Test public void listJobSuccess() throws ServiceException { // Arrange - - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.setName("My Encoding Job"); - createJobOptions.setPriority(3); - createJobOptions.addInputMediaAsset(assetInfo.getId()); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - createTaskOptions.setConfiguration("H.264 256k DSL CBR"); - createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); - createTaskOptions.setName("My encoding Task"); - String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" - + "</taskBody>"; - - createTaskOptions.setTaskBody(taskBody); - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); - ListJobsResult expectedListJobsResult = new ListJobsResult(); + JobInfo jobInfo = createJob("listJobSuccess"); List<JobInfo> jobInfos = new ArrayList<JobInfo>(); - JobInfo expectedJobInfo = new JobInfo(); - expectedJobInfo.setName("My Encoding Job"); - expectedJobInfo.setPriority(3); - expectedJobInfo.setRunningDuration(0.0); - expectedJobInfo.setState(0); - jobInfos.add(expectedJobInfo); + ListJobsResult expectedListJobsResult = new ListJobsResult(); + jobInfos.add(jobInfo); expectedListJobsResult.setJobInfos(jobInfos); - JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); - // Act ListJobsResult actualListJobResult = service.listJobs(); @@ -183,12 +172,7 @@ public void canListJobsWithOptions() throws ServiceException { List<JobInfo> expectedJobs = new ArrayList<JobInfo>(); for (int i = 0; i < assetNames.length; i++) { String name = assetNames[i]; - CreateJobOptions createJobOptions = new CreateJobOptions(); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); - JobInfo expectedJob = new JobInfo(); - JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); + JobInfo jobInfo = createJob(name); expectedJobs.add(jobInfo); } @@ -213,33 +197,52 @@ public void cancelJobSuccess() throws Exception { createTaskOptions.setConfiguration("H.264 256k DSL CBR"); createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); createTaskOptions.setName("My encoding Task"); - String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" - + "</taskBody>"; createTaskOptions.setTaskBody(taskBody); List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); - ListJobsResult listJobsResult = service.listJobs(); - int assetCountBaseline = listJobsResult.getJobInfos().size(); // Act service.cancelJob(jobInfo.getId()); // Assert - listJobsResult = service.listJobs(); - assertEquals("listJobsResult.size", assetCountBaseline - 1, listJobsResult.getJobInfos().size()); + JobInfo canceledJob = service.getJob(jobInfo.getId()); + assertEquals((Integer) 6, canceledJob.getState()); - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.getJob(jobInfo.getId()); } @Test - public void deleteJobFailedWithInvalidId() throws ServiceException { + public void cancelJobFailedWithInvalidId() throws ServiceException { + // Arrange expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); + + // Act service.cancelJob(invalidId); + + // Assert + } + + @Test + public void deleteJobSuccess() { + // Arrange + + // Act + + // Assert + + } + + @Test + public void deleteJobIvalidIdFail() throws ServiceException { + // Arrange + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + + // Act + service.deleteJob(invalidId); + + // Assert } } From 96d92104058770b4d40f2992049d365d9d833abd Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 12 Nov 2012 15:39:41 -0800 Subject: [PATCH 478/664] address the code review feedback --- .../implementation/CreateTaskOperation.java | 4 + .../implementation/MediaBatchOperations.java | 196 +++++++++++++++++- .../media/implementation/MediaRestProxy.java | 190 ++++------------- .../media/implementation/Operation.java | 3 + .../media/implementation/StatusLine.java | 7 +- .../media/implementation/StatusLineTest.java | 71 +++++++ 6 files changed, 317 insertions(+), 154 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java index 8ba5c38060e0c..d2f4ac99e2179 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java @@ -19,6 +19,10 @@ public class CreateTaskOperation extends Operation { + public CreateTaskOperation() { + this.verb = "POST"; + } + public CreateTaskOperation setTask(TaskType taskType) { addContentObject(taskType); return this; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 4e6f1e1f55a16..19654481e8a7e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -18,6 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -28,17 +29,25 @@ import javax.activation.DataHandler; import javax.activation.DataSource; +import javax.mail.BodyPart; import javax.mail.Header; import javax.mail.MessagingException; import javax.mail.internet.InternetHeaders; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; +import javax.mail.internet.MimePartDataSource; import javax.ws.rs.core.UriBuilder; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.UniformInterfaceException; +import com.sun.jersey.core.header.InBoundHeaders; +import com.sun.jersey.core.util.ReaderWriter; /** * The Class MediaBatchOperations. @@ -54,6 +63,9 @@ public class MediaBatchOperations { /** The Odata atom marshaller. */ private final ODataAtomMarshaller oDataAtomMarshaller; + /** The o data atom unmarshaller. */ + private ODataAtomUnmarshaller oDataAtomUnmarshaller; + private final String batchId; /** @@ -72,6 +84,13 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur this.oDataAtomMarshaller = new ODataAtomMarshaller(); this.operations = new ArrayList<Operation>(); batchId = String.format("batch_%s", UUID.randomUUID().toString()); + try { + this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); + } + catch (JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } @@ -126,8 +145,8 @@ private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int conten if (operation instanceof CreateJobOperation) { CreateJobOperation createJobOperation = (CreateJobOperation) operation; jobContentId = contentId; - bodyPartContent = createBatchCreateEntityPart("Jobs", createJobOperation.getEntryType(), jobURI, - contentId); + bodyPartContent = createBatchCreateEntityPart(createJobOperation.getVerb(), "Jobs", + createJobOperation.getEntryType(), jobURI, contentId); contentId++; if (bodyPartContent != null) { bodyPartContents.add(bodyPartContent); @@ -169,8 +188,8 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con DataSource bodyPartContent = null; if (operation instanceof CreateTaskOperation) { CreateTaskOperation createTaskOperation = (CreateTaskOperation) operation; - bodyPartContent = createBatchCreateEntityPart("Tasks", createTaskOperation.getEntryType(), taskURI, - contentId); + bodyPartContent = createBatchCreateEntityPart(createTaskOperation.getVerb(), "Tasks", + createTaskOperation.getEntryType(), taskURI, contentId); contentId++; } @@ -244,8 +263,8 @@ private MimeMultipart createChangeSets(List<DataSource> bodyPartContents, String * @throws JAXBException * the jAXB exception */ - private DataSource createBatchCreateEntityPart(String entityName, EntryType entryType, URI uri, int contentId) - throws JAXBException { + private DataSource createBatchCreateEntityPart(String verb, String entityName, EntryType entryType, URI uri, + int contentId) throws JAXBException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); this.oDataAtomMarshaller.marshalEntryType(entryType, stream); byte[] bytes = stream.toByteArray(); @@ -260,7 +279,7 @@ private DataSource createBatchCreateEntityPart(String entityName, EntryType entr // adds body ByteArrayOutputStream httpRequest = new ByteArrayOutputStream(); - addHttpMethod(httpRequest, "POST", uri); + addHttpMethod(httpRequest, verb, uri); appendHeaders(httpRequest, headers); appendEntity(httpRequest, new ByteArrayInputStream(bytes)); @@ -269,6 +288,169 @@ private DataSource createBatchCreateEntityPart(String entityName, EntryType entr return bodyPartContent; } + /** + * Parses the batch result. + * + * @param response + * the response + * @param mediaBatchOperations + * the media batch operations + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws ServiceException + * the service exception + */ + @SuppressWarnings("rawtypes") + public void parseBatchResult(ClientResponse response) throws IOException, ServiceException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + InputStream inputStream = response.getEntityInputStream(); + ReaderWriter.writeTo(inputStream, byteArrayOutputStream); + response.setEntityInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); + JobInfo jobInfo; + + List<DataSource> parts = parseParts(response.getEntityInputStream(), + response.getHeaders().getFirst("Content-Type")); + + if (parts.size() == 0 || parts.size() > operations.size()) { + throw new UniformInterfaceException(String.format( + "Batch response from server does not contain the correct amount " + + "of parts (expecting %d, received %d instead)", parts.size(), operations.size()), + response); + } + + ArrayList<Object> result = new ArrayList<Object>(); + for (int i = 0; i < parts.size(); i++) { + DataSource ds = parts.get(i); + Operation operation = operations.get(i); + + StatusLine status = StatusLine.create(ds); + InternetHeaders headers = parseHeaders(ds); + InputStream content = parseEntity(ds); + + if (status.getStatus() >= 400) { + + InBoundHeaders inBoundHeaders = new InBoundHeaders(); + @SuppressWarnings("unchecked") + Enumeration<Header> e = headers.getAllHeaders(); + while (e.hasMoreElements()) { + Header header = e.nextElement(); + inBoundHeaders.putSingle(header.getName(), header.getValue()); + } + + ClientResponse clientResponse = new ClientResponse(status.getStatus(), inBoundHeaders, content, null); + + UniformInterfaceException uniformInterfaceException = new UniformInterfaceException(clientResponse); + throw uniformInterfaceException; + } + else if (operation instanceof CreateJobOperation) { + + try { + jobInfo = oDataAtomUnmarshaller.unmarshalEntry(content, JobInfo.class); + CreateJobOperation createJobOperation = (CreateJobOperation) operation; + createJobOperation.setJobInfo(jobInfo); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + } + else if (operation instanceof CreateTaskOperation) { + EntryType entryType = null; + try { + entryType = oDataAtomUnmarshaller.unmarshalEntry(content); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + } + } + } + + /** + * Parses the headers. + * + * @param ds + * the ds + * @return the internet headers + */ + public InternetHeaders parseHeaders(DataSource ds) { + try { + return new InternetHeaders(ds.getInputStream()); + } + catch (MessagingException e) { + throw new RuntimeException(e); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Parses the entity. + * + * @param ds + * the ds + * @return the input stream + */ + public InputStream parseEntity(DataSource ds) { + try { + return ds.getInputStream(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Parses the parts. + * + * @param entityInputStream + * the entity input stream + * @param contentType + * the content type + * @return the list + */ + public List<DataSource> parseParts(final InputStream entityInputStream, final String contentType) { + try { + return parsePartsCore(entityInputStream, contentType); + } + catch (IOException e) { + throw new RuntimeException(e); + } + catch (MessagingException e) { + throw new RuntimeException(e); + } + } + + /** + * Parses the parts core. + * + * @param entityInputStream + * the entity input stream + * @param contentType + * the content type + * @return the list + * @throws MessagingException + * the messaging exception + * @throws IOException + * Signals that an I/O exception has occurred. + */ + private List<DataSource> parsePartsCore(InputStream entityInputStream, String contentType) + throws MessagingException, IOException { + DataSource dataSource = new InputStreamDataSource(entityInputStream, contentType); + MimeMultipart batch = new MimeMultipart(dataSource); + MimeBodyPart batchBody = (MimeBodyPart) batch.getBodyPart(0); + + MimeMultipart changeSets = new MimeMultipart(new MimePartDataSource(batchBody)); + + List<DataSource> result = new ArrayList<DataSource>(); + for (int i = 0; i < changeSets.getCount(); i++) { + BodyPart part = changeSets.getBodyPart(i); + + result.add(new InputStreamDataSource(part.getInputStream(), part.getContentType())); + } + return result; + } + /** * Adds the operation. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 18d84e76ee384..297cf6a9ccbc8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,28 +15,17 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; -import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; -import java.util.Enumeration; import java.util.List; -import javax.activation.DataSource; import javax.inject.Inject; -import javax.mail.BodyPart; -import javax.mail.Header; import javax.mail.MessagingException; -import javax.mail.internet.InternetHeaders; -import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; -import javax.mail.internet.MimePartDataSource; import javax.ws.rs.core.MediaType; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; @@ -49,7 +38,6 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; @@ -80,14 +68,11 @@ import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.media.models.UpdateAssetOptions; import com.microsoft.windowsazure.services.media.models.UpdateLocatorOptions; -import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.core.header.InBoundHeaders; -import com.sun.jersey.core.util.ReaderWriter; /** * The Class MediaRestProxy. @@ -96,11 +81,13 @@ public class MediaRestProxy implements MediaContract { /** The channel. */ private Client channel; + + /** The redirect filter. */ private RedirectFilter redirectFilter; - private ODataAtomUnmarshaller oDataAtomUnmarshaller; /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); + /** The filters. */ ServiceFilter[] filters; @@ -109,8 +96,6 @@ public class MediaRestProxy implements MediaContract { * * @param channel * the channel - * @param uri - * the uri * @param authFilter * the auth filter * @param redirectFilter @@ -124,13 +109,6 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red this.channel = channel; this.filters = new ServiceFilter[0]; this.redirectFilter = redirectFilter; - try { - this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); - } - catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -194,6 +172,15 @@ private WebResource getResource(String entityName) { return resource; } + /** + * Gets the resource. + * + * @param entityName + * the entity name + * @param options + * the options + * @return the resource + */ private WebResource getResource(String entityName, ListOptions options) { WebResource resource = getResource(entityName); if (options != null) { @@ -253,6 +240,11 @@ private WebResource getResource(String parentEntityType, String childEntityType, return getResource(entityPath); } + /** + * Gets the base uri. + * + * @return the base uri + */ private URI getBaseURI() { return this.redirectFilter.getBaseURI(); } @@ -283,6 +275,15 @@ private <T> T mergeRequest(String entityType, String entityId, java.lang.Class<T return builder.post(c, requestEntity); } + /** + * List web resource tasks. + * + * @param webResource + * the web resource + * @param listTasksOptions + * the list tasks options + * @return the list tasks result + */ private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksOptions listTasksOptions) { if ((listTasksOptions != null) && (listTasksOptions.getQueryParameters() != null)) { webResource = webResource.queryParams(listTasksOptions.getQueryParameters()); @@ -296,6 +297,13 @@ private ListTasksResult listWebResourceTasks(WebResource webResource, ListTasksO return listTasksResult; } + /** + * Creates the create job operation. + * + * @param createJobOptions + * the create job options + * @return the creates the job operation + */ private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOptions) { JobType jobType = new JobType(); if (createJobOptions != null) { @@ -311,6 +319,13 @@ private CreateJobOperation createCreateJobOperation(CreateJobOptions createJobOp return createJobOperation; } + /** + * Creates the task operation. + * + * @param createTaskOptions + * the create task options + * @return the creates the task operation + */ private CreateTaskOperation createTaskOperation(CreateTaskOptions createTaskOptions) { CreateTaskOperation createTaskOperation = new CreateTaskOperation(); @@ -338,123 +353,6 @@ private CreateTaskOperation createTaskOperation(CreateTaskOptions createTaskOpti return createTaskOperation; } - @SuppressWarnings("rawtypes") - private void parseBatchResult(ClientResponse response, MediaBatchOperations mediaBatchOperations) - throws IOException, ServiceException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - InputStream inputStream = response.getEntityInputStream(); - ReaderWriter.writeTo(inputStream, byteArrayOutputStream); - response.setEntityInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); - JobInfo jobInfo; - - List<DataSource> parts = parseParts(response.getEntityInputStream(), - response.getHeaders().getFirst("Content-Type")); - - if (parts.size() == 0 || parts.size() > mediaBatchOperations.getOperations().size()) { - throw new UniformInterfaceException(String.format( - "Batch response from server does not contain the correct amount " - + "of parts (expecting %d, received %d instead)", parts.size(), mediaBatchOperations - .getOperations().size()), response); - } - - ArrayList<Object> result = new ArrayList<Object>(); - for (int i = 0; i < parts.size(); i++) { - DataSource ds = parts.get(i); - Operation operation = mediaBatchOperations.getOperations().get(i); - - StatusLine status = StatusLine.create(ds); - InternetHeaders headers = parseHeaders(ds); - InputStream content = parseEntity(ds); - - if (status.getStatus() >= 400) { - - InBoundHeaders inBoundHeaders = new InBoundHeaders(); - @SuppressWarnings("unchecked") - Enumeration<Header> e = headers.getAllHeaders(); - while (e.hasMoreElements()) { - Header header = e.nextElement(); - inBoundHeaders.putSingle(header.getName(), header.getValue()); - } - - ClientResponse clientResponse = new ClientResponse(status.getStatus(), inBoundHeaders, content, null); - - UniformInterfaceException exception = new UniformInterfaceException(clientResponse); - ServiceException serviceException = new ServiceException(exception); - throw serviceException; - } - else if (operation instanceof CreateJobOperation) { - - try { - jobInfo = oDataAtomUnmarshaller.unmarshalEntry(content, JobInfo.class); - CreateJobOperation createJobOperation = (CreateJobOperation) operation; - createJobOperation.setJobInfo(jobInfo); - } - catch (JAXBException e) { - throw new ServiceException(e); - } - } - else if (operation instanceof CreateTaskOperation) { - EntryType entryType = null; - try { - entryType = oDataAtomUnmarshaller.unmarshalEntry(content); - } - catch (JAXBException e) { - throw new ServiceException(e); - } - } - } - } - - public InternetHeaders parseHeaders(DataSource ds) { - try { - return new InternetHeaders(ds.getInputStream()); - } - catch (MessagingException e) { - throw new RuntimeException(e); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public InputStream parseEntity(DataSource ds) { - try { - return ds.getInputStream(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public List<DataSource> parseParts(final InputStream entityInputStream, final String contentType) { - try { - return parsePartsCore(entityInputStream, contentType); - } - catch (IOException e) { - throw new RuntimeException(e); - } - catch (MessagingException e) { - throw new RuntimeException(e); - } - } - - private List<DataSource> parsePartsCore(InputStream entityInputStream, String contentType) - throws MessagingException, IOException { - DataSource ds = new InputStreamDataSource(entityInputStream, contentType); - MimeMultipart batch = new MimeMultipart(ds); - MimeBodyPart batchBody = (MimeBodyPart) batch.getBodyPart(0); - - MimeMultipart changeSets = new MimeMultipart(new MimePartDataSource(batchBody)); - - List<DataSource> result = new ArrayList<DataSource>(); - for (int i = 0; i < changeSets.getCount(); i++) { - BodyPart part = changeSets.getBodyPart(i); - - result.add(new InputStreamDataSource(part.getInputStream(), part.getContentType())); - } - return result; - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createAsset() */ @@ -788,11 +686,10 @@ public JobInfo createJob(CreateJobOptions createJobOptions, List<CreateTaskOptio .accept(MediaType.APPLICATION_ATOM_XML).post(ClientResponse.class, mimeMultipart); try { - parseBatchResult(clientResponse, mediaBatchOperations); + mediaBatchOperations.parseBatchResult(clientResponse); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new ServiceException(e); } return createJobOperation.getJobInfo(); @@ -872,6 +769,9 @@ public ListTasksResult listJobTasks(String jobId) throws ServiceException { return this.listJobTasks(jobId, null); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#deleteJob(java.lang.String) + */ @Override public void deleteJob(String jobId) throws ServiceException { getResource("Jobs", jobId).delete(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java index 20ffe1217b975..888798c8b1149 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java @@ -48,6 +48,7 @@ protected String getVerb() { return this.verb; } + @SuppressWarnings("unchecked") protected void addContentObject(Object contentObject) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); @@ -59,6 +60,7 @@ protected void addContentObject(Object contentObject) { new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); } + @SuppressWarnings("unchecked") protected void addLink(String title, String href, String type, String rel) { LinkType linkType = new LinkType(); linkType.setTitle(title); @@ -69,4 +71,5 @@ protected void addLink(String title, String href, String type, String rel) { new JAXBElement(new QName(Constants.ATOM_NS, "link"), LinkType.class, linkType)); } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index ab36de9b5764a..74e30a558c4f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -47,11 +47,14 @@ public static StatusLine create(DataSource dataSource) { private static void expect(Reader reader, String string) { try { + byte[] byteArray = string.getBytes(); + int ch; for (int i = 0; i < string.length(); i++) { - int ch = reader.read(); - if (ch < 0) + ch = reader.read(); + if (ch != byteArray[i]) { throw new RuntimeException(String.format("Expected '%s', found '%s' instead", string, string.substring(0, i) + ch)); + } } } catch (IOException e) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java new file mode 100644 index 0000000000000..6ff249b4d069c --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java @@ -0,0 +1,71 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; + +import javax.activation.DataSource; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; + +public class StatusLineTest { + + @Test + public void testCanCreateStatus() throws Exception { + // Arrange + String httpResponse = "HTTP/1.1 200 OK"; + int expectedStatus = 200; + String expectedReason = "OK"; + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(httpResponse.getBytes()); + DataSource dataSource = new InputStreamDataSource(byteArrayInputStream, "defaultContentType"); + + // Act + StatusLine statusLine = StatusLine.create(dataSource); + + // Assert + assertEquals(expectedStatus, statusLine.getStatus()); + assertEquals(expectedReason, statusLine.getReason()); + } + + @Test + public void testGetSetStatus() { + // Arrange + String httpResponse = "HTTP/1.1 200 OK"; + int expectedStatus = 300; + String expectedReason = "NotOK"; + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(httpResponse.getBytes()); + DataSource dataSource = new InputStreamDataSource(byteArrayInputStream, "defaultContentType"); + StatusLine statusLine = StatusLine.create(dataSource); + + // Act + statusLine.setStatus(expectedStatus); + statusLine.setReason(expectedReason); + + // Assert + assertEquals(expectedStatus, statusLine.getStatus()); + assertEquals(expectedReason, statusLine.getReason()); + } + + @Test + public void testGetSetReason() { + + } + +} From 66411b7e4c7ef5c7dbc72df19301aae077915160 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 12 Nov 2012 16:52:33 -0800 Subject: [PATCH 479/664] address additional code review feedback. --- .../services/media/JobIntegrationTest.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 0782a7be4d317..158e3f1d13c96 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -34,7 +34,7 @@ public class JobIntegrationTest extends IntegrationTestBase { private final String testJobPrefix = "testJobPrefix"; - private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-16\"?><taskBody>" + private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { @@ -93,7 +93,7 @@ public void createJobSuccess() throws Exception { List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); createTaskOptionsList.add(createTaskOptions); - JobInfo expectedJob = new JobInfo(); + JobInfo expectedJob = createJob("My EncodingJob"); expectedJob.setName("My Encoding Job"); expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); @@ -109,19 +109,7 @@ public void createJobSuccess() throws Exception { @Test public void getJobSuccess() throws Exception { // Arrange - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.setName("My Encoding Job"); - createJobOptions.setPriority(3); - createJobOptions.addInputMediaAsset(assetInfo.getId()); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - createTaskOptions.setConfiguration("H.264 256k DSL CBR"); - createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); - createTaskOptions.setName("My encoding Task"); - createTaskOptions.setTaskBody(taskBody); - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); + JobInfo expectedJob = new JobInfo(); expectedJob.setName("My Encoding Job"); expectedJob.setPriority(3); @@ -225,12 +213,22 @@ public void cancelJobFailedWithInvalidId() throws ServiceException { } @Test - public void deleteJobSuccess() { + public void deleteJobSuccess() throws ServiceException { // Arrange + JobInfo jobInfo = createJob("deleteJobSuccess"); + service.cancelJob(jobInfo.getId()); + JobInfo cancellingJobInfo = service.getJob(jobInfo.getId()); + while (cancellingJobInfo.getState() == 6) { + cancellingJobInfo = service.getJob(jobInfo.getId()); + } // Act + service.deleteJob(jobInfo.getId()); + // Assert + expectedException.expect(ServiceException.class); + service.getJob(jobInfo.getId()); } From de7fb8c76c30769cc71eae48d419e184e4760d02 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 12 Nov 2012 18:32:57 -0800 Subject: [PATCH 480/664] Resolving merge conflicts for forward integration. --- .../services/media/MediaContract.java | 2 + .../MediaExceptionProcessor.java | 6 + .../media/implementation/MediaRestProxy.java | 3 + .../media/models/ListJobsOptions.java | 22 -- .../media/models/ListTasksOptions.java | 23 -- .../services/media/JobIntegrationTest.java | 246 ------------------ .../media/models/CreateTaskOptionsTest.java | 3 +- 7 files changed, 13 insertions(+), 292 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 931fe465c7237..9680009a1507e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -16,9 +16,11 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; /** * Contract for interacting with the back end of Media Services * */ +public interface MediaContract extends FilterableService<MediaContract>, EntityContract { } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 60bc3d40d9e31..0818049ac61fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -24,6 +24,12 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 155d1991708dd..b4b146b58a98b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -24,12 +24,14 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; import com.sun.jersey.api.client.Client; /** * * */ +public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); @@ -75,5 +77,6 @@ public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; + return new MediaRestProxy(getChannel(), newFilters); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java deleted file mode 100644 index 9280d8ecdd726..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class ListJobsOptions. - */ -public class ListJobsOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java deleted file mode 100644 index 956e501a55280..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksOptions.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -/** - * The Class ListTasksOptions. - */ -public class ListTasksOptions extends ListOptions { - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java deleted file mode 100644 index 158e3f1d13c96..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.CreateAssetOptions; -import com.microsoft.windowsazure.services.media.models.CreateJobOptions; -import com.microsoft.windowsazure.services.media.models.CreateTaskOptions; -import com.microsoft.windowsazure.services.media.models.JobInfo; -import com.microsoft.windowsazure.services.media.models.ListJobsOptions; -import com.microsoft.windowsazure.services.media.models.ListJobsResult; - -public class JobIntegrationTest extends IntegrationTestBase { - - private final String testJobPrefix = "testJobPrefix"; - private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; - - private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { - verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), - expected.getState(), expected.getTemplateId(), expected.getInputMediaAssets(), - expected.getOutputMediaAssets(), actual); - } - - private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, - Integer state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, - JobInfo actualJob) { - assertNotNull(message, actualJob); - assertEquals(message + " Name", testName, actualJob.getName()); - // comment out due to issue 464 - // assertEquals(message + " Priority", priority, actualJob.getPriority()); - assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); - assertEquals(message + " State", state, actualJob.getState()); - // commented out due to issue 463 - // assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); - assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); - assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); - } - - private JobInfo createJob(String name) throws ServiceException { - CreateAssetOptions createAssetOptions = new CreateAssetOptions().setName(name); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.setName("My Encoding Job"); - createJobOptions.setPriority(3); - createJobOptions.addInputMediaAsset(assetInfo.getId()); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - createTaskOptions.setConfiguration("H.264 256k DSL CBR"); - createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); - createTaskOptions.setName("My encoding Task"); - createTaskOptions.setTaskBody(taskBody); - - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); - return service.createJob(createJobOptions, createTaskOptionsList); - } - - @Test - public void createJobSuccess() throws Exception { - // Arrange - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.setName("My Encoding Job"); - createJobOptions.setPriority(3); - createJobOptions.addInputMediaAsset(assetInfo.getId()); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - createTaskOptions.setConfiguration("H.264 256k DSL CBR"); - createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); - createTaskOptions.setName("My encoding Task"); - createTaskOptions.setTaskBody(taskBody); - - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); - JobInfo expectedJob = createJob("My EncodingJob"); - expectedJob.setName("My Encoding Job"); - expectedJob.setPriority(3); - expectedJob.setRunningDuration(0.0); - expectedJob.setState(0); - - // Act - JobInfo actualJob = service.createJob(createJobOptions, createTaskOptionsList); - - // Assert - verifyJobInfoEqual("actualJob", expectedJob, actualJob); - } - - @Test - public void getJobSuccess() throws Exception { - // Arrange - - JobInfo expectedJob = new JobInfo(); - expectedJob.setName("My Encoding Job"); - expectedJob.setPriority(3); - expectedJob.setRunningDuration(0.0); - expectedJob.setState(0); - String jobId = createJob("getJobSuccess").getId(); - - // Act - JobInfo actualJob = service.getJob(jobId); - - // Assert - verifyJobInfoEqual("actualJob", expectedJob, actualJob); - } - - @Test - public void getJobInvalidIdFailed() throws ServiceException { - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); - service.getJob(invalidId); - } - - @Test - public void listJobSuccess() throws ServiceException { - // Arrange - JobInfo jobInfo = createJob("listJobSuccess"); - List<JobInfo> jobInfos = new ArrayList<JobInfo>(); - ListJobsResult expectedListJobsResult = new ListJobsResult(); - jobInfos.add(jobInfo); - expectedListJobsResult.setJobInfos(jobInfos); - - // Act - ListJobsResult actualListJobResult = service.listJobs(); - - // Assert - verifyListResultContains("listJobs", expectedListJobsResult.getJobInfos(), actualListJobResult.getJobInfos(), - new ComponentDelegate() { - @Override - public void verifyEquals(String message, Object expected, Object actual) { - verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual); - } - }); - } - - @Test - public void canListJobsWithOptions() throws ServiceException { - String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", - testJobPrefix + "assetListOptionsC", testJobPrefix + "assetListOptionsD" }; - List<JobInfo> expectedJobs = new ArrayList<JobInfo>(); - for (int i = 0; i < assetNames.length; i++) { - String name = assetNames[i]; - JobInfo jobInfo = createJob(name); - expectedJobs.add(jobInfo); - } - - ListJobsOptions options = new ListJobsOptions(); - options.getQueryParameters().add("$top", "2"); - ListJobsResult listJobsResult = service.listJobs(options); - - // Assert - assertEquals(2, listJobsResult.getJobInfos().size()); - } - - @Test - public void cancelJobSuccess() throws Exception { - // Arrange - CreateAssetOptions createAssetOptions = new CreateAssetOptions(); - AssetInfo assetInfo = service.createAsset(createAssetOptions); - CreateJobOptions createJobOptions = new CreateJobOptions(); - createJobOptions.setName("My Encoding Job"); - createJobOptions.setPriority(3); - createJobOptions.addInputMediaAsset(assetInfo.getId()); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - createTaskOptions.setConfiguration("H.264 256k DSL CBR"); - createTaskOptions.setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"); - createTaskOptions.setName("My encoding Task"); - - createTaskOptions.setTaskBody(taskBody); - List<CreateTaskOptions> createTaskOptionsList = new ArrayList<CreateTaskOptions>(); - createTaskOptionsList.add(createTaskOptions); - JobInfo jobInfo = service.createJob(createJobOptions, createTaskOptionsList); - - // Act - service.cancelJob(jobInfo.getId()); - - // Assert - JobInfo canceledJob = service.getJob(jobInfo.getId()); - assertEquals((Integer) 6, canceledJob.getState()); - - } - - @Test - public void cancelJobFailedWithInvalidId() throws ServiceException { - // Arrange - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); - - // Act - service.cancelJob(invalidId); - - // Assert - } - - @Test - public void deleteJobSuccess() throws ServiceException { - // Arrange - JobInfo jobInfo = createJob("deleteJobSuccess"); - service.cancelJob(jobInfo.getId()); - JobInfo cancellingJobInfo = service.getJob(jobInfo.getId()); - while (cancellingJobInfo.getState() == 6) { - cancellingJobInfo = service.getJob(jobInfo.getId()); - } - - // Act - - service.deleteJob(jobInfo.getId()); - - // Assert - expectedException.expect(ServiceException.class); - service.getJob(jobInfo.getId()); - - } - - @Test - public void deleteJobIvalidIdFail() throws ServiceException { - // Arrange - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); - - // Act - service.deleteJob(invalidId); - - // Assert - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java index 77acdb7d648da..867334a22703c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java @@ -31,7 +31,8 @@ public void testGetSetConfiguration() { CreateTaskOptions createTaskOptions = new CreateTaskOptions(); // Act - String actualTaskConfiguration = createTaskOptions.setName(expectedTaskConfiguration).getConfiguration(); + String actualTaskConfiguration = createTaskOptions.setConfiguration(expectedTaskConfiguration) + .getConfiguration(); // Assert assertEquals(expectedTaskConfiguration, actualTaskConfiguration); From 27a243ff27bd4a6961de7d829e27580e987b20c2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 13 Nov 2012 14:52:05 -0800 Subject: [PATCH 481/664] initial check in for crudy Job and Task. --- .../services/media/MediaContract.java | 1 + .../entities/EntityContract.java | 9 + .../media/models/CreateJobOptions.java | 151 -------- .../media/models/CreateTaskOptions.java | 323 ------------------ .../services/media/models/Job.java | 193 +++++++++++ .../services/media/models/ListJobsResult.java | 48 --- .../services/media/models/Task.java | 209 ++++++++++++ .../services/media/JobIntegrationTest.java | 222 ++++++++++++ 8 files changed, 634 insertions(+), 522 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 9680009a1507e..58e56ea16c7eb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -23,4 +23,5 @@ * */ public interface MediaContract extends FilterableService<MediaContract>, EntityContract { + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index fdb045b54388f..f17a703cb8eb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -74,4 +74,13 @@ public interface EntityContract { */ public abstract void delete(EntityDeleteOperation deleter) throws ServiceException; + /** + * Perform an action on an entity + * + * @param action + * Object providing details of the action + * @throws ServiceException + */ + public abstract void action(ActionOperation<T> action) throws ServiceException; + } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java deleted file mode 100644 index 916c53388178c..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateJobOptions.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * The Class CreateJobOptions. - */ -public class CreateJobOptions { - - /** The start time. */ - private Date startTime; - - /** The name. */ - private String name; - - /** The priority. */ - private Integer priority; - - /** The input media assets. */ - private final List<String> inputMediaAssets; - - /** The output media assets. */ - private final List<String> outputMediaAssets; - - public CreateJobOptions() { - this.inputMediaAssets = new ArrayList<String>(); - this.outputMediaAssets = new ArrayList<String>(); - } - - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the creates the locator options - */ - public CreateJobOptions setStartTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Sets the name. - * - * @param name - * the name - * @return the creates the job options - */ - public CreateJobOptions setName(String name) { - this.name = name; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the priority. - * - * @param priority - * the priority - * @return the creates the job options - */ - public CreateJobOptions setPriority(Integer priority) { - this.priority = priority; - return this; - } - - /** - * Gets the priority. - * - * @return the priority - */ - public Integer getPriority() { - return this.priority; - } - - /** - * Sets the input media assets. - * - * @param inputMediaAssets - * the input media assets - * @return the creates the job options - */ - public CreateJobOptions addInputMediaAsset(String inputMediaAsset) { - this.inputMediaAssets.add(inputMediaAsset); - return this; - } - - /** - * Gets the input media assets. - * - * @return the input media assets - */ - public List<String> getInputMediaAssets() { - return this.inputMediaAssets; - } - - /** - * Sets the output media assets. - * - * @param outputMediaAssets - * the output media assets - * @return the creates the job options - */ - public CreateJobOptions addOutputMediaAsset(String outputMediaAsset) { - this.outputMediaAssets.add(outputMediaAsset); - return this; - } - - /** - * Gets the output media assets. - * - * @return the output media assets - */ - public List<String> getOutputMediaAssets() { - return this.outputMediaAssets; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java deleted file mode 100644 index 8b2920969ef11..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptions.java +++ /dev/null @@ -1,323 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * The Class CreateTaskOptions. - */ -public class CreateTaskOptions { - - /** The configuration. */ - private String configuration; - - /** The media processor id. */ - private String mediaProcessorId; - - /** The name. */ - private String name; - - /** The priority. */ - private Integer priority; - - /** The start time. */ - private Date startTime; - - /** The task body. */ - private String taskBody; - - /** The encryption key id. */ - private String encryptionKeyId; - - /** The encryption scheme. */ - private String encryptionScheme; - - /** The encryption version. */ - private String encryptionVersion; - - /** The initialization vector. */ - private String initializationVector; - - /** The input media assets. */ - private List<String> inputMediaAssets; - - /** The output media assets. */ - private List<String> outputMediaAssets; - - public CreateTaskOptions() { - this.inputMediaAssets = new ArrayList<String>(); - this.outputMediaAssets = new ArrayList<String>(); - } - - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the creates the locator options - */ - public CreateTaskOptions setStartTime(Date startTime) { - this.startTime = startTime; - return this; - } - - /** - * Sets the name. - * - * @param name - * the name - * @return the creates the job options - */ - public CreateTaskOptions setName(String name) { - this.name = name; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the priority. - * - * @param priority - * the priority - * @return the creates the job options - */ - public CreateTaskOptions setPriority(Integer priority) { - this.priority = priority; - return this; - } - - /** - * Gets the priority. - * - * @return the priority - */ - public Integer getPriority() { - return this.priority; - } - - /** - * Sets the input media assets. - * - * @param inputMediaAssets - * the input media assets - * @return the creates the job options - */ - public CreateTaskOptions setInputMediaAssets(List<String> inputMediaAssets) { - this.inputMediaAssets = inputMediaAssets; - return this; - } - - /** - * Gets the input media assets. - * - * @return the input media assets - */ - public List<String> getInputMediaAssets() { - return this.inputMediaAssets; - } - - /** - * Sets the output media assets. - * - * @param outputMediaAssets - * the output media assets - * @return the creates the job options - */ - public CreateTaskOptions setOutputMediaAssets(List<String> outputMediaAssets) { - this.outputMediaAssets = outputMediaAssets; - return this; - } - - /** - * Gets the output media assets. - * - * @return the output media assets - */ - public List<String> getOutputMediaAssets() { - return this.outputMediaAssets; - } - - /** - * Gets the configuration. - * - * @return the configuration - */ - public String getConfiguration() { - return configuration; - } - - /** - * Sets the configuration. - * - * @param configuration - * the new configuration - */ - public CreateTaskOptions setConfiguration(String configuration) { - this.configuration = configuration; - return this; - } - - /** - * Gets the media processor id. - * - * @return the media processor id - */ - public String getMediaProcessorId() { - return mediaProcessorId; - } - - /** - * Sets the media processor id. - * - * @param mediaProcessorId - * the new media processor id - */ - public CreateTaskOptions setMediaProcessorId(String mediaProcessorId) { - this.mediaProcessorId = mediaProcessorId; - return this; - } - - /** - * Gets the task body. - * - * @return the task body - */ - public String getTaskBody() { - return taskBody; - } - - /** - * Sets the task body. - * - * @param taskBody - * the new task body - */ - public CreateTaskOptions setTaskBody(String taskBody) { - this.taskBody = taskBody; - return this; - } - - /** - * Gets the encryption key id. - * - * @return the encryption key id - */ - public String getEncryptionKeyId() { - return encryptionKeyId; - } - - /** - * Sets the encryption key id. - * - * @param encryptionKeyId - * the new encryption key id - */ - public CreateTaskOptions setEncryptionKeyId(String encryptionKeyId) { - this.encryptionKeyId = encryptionKeyId; - return this; - } - - /** - * Gets the encryption scheme. - * - * @return the encryption scheme - */ - public String getEncryptionScheme() { - return encryptionScheme; - } - - /** - * Sets the encryption scheme. - * - * @param encryptionScheme - * the new encryption scheme - */ - public CreateTaskOptions setEncryptionScheme(String encryptionScheme) { - this.encryptionScheme = encryptionScheme; - return this; - } - - /** - * Gets the encryption version. - * - * @return the encryption version - */ - public String getEncryptionVersion() { - return encryptionVersion; - } - - /** - * Sets the encryption version. - * - * @param encryptionVersion - * the new encryption version - */ - public CreateTaskOptions setEncryptionVersion(String encryptionVersion) { - this.encryptionVersion = encryptionVersion; - return this; - } - - /** - * Gets the initialization vector. - * - * @return the initialization vector - */ - public String getInitializationVector() { - return initializationVector; - } - - /** - * Sets the initialization vector. - * - * @param initializationVector - * the new initialization vector - */ - public CreateTaskOptions setInitializationVector(String initializationVector) { - this.initializationVector = initializationVector; - return this; - } - - public CreateTaskOptions addInputMediaAsset(String inputMediaAsset) { - this.inputMediaAssets.add(inputMediaAsset); - return this; - } - - public CreateTaskOptions addOutputMediaAsset(String outputMediaAsset) { - this.outputMediaAssets.add(outputMediaAsset); - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java new file mode 100644 index 0000000000000..696cd7461d964 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -0,0 +1,193 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.io.IOException; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMultipart; +import javax.print.attribute.standard.JobState; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.CreateJobOperation; +import com.microsoft.windowsazure.services.media.implementation.CreateTaskOperation; +import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.sun.jersey.api.client.GenericType; + +/** + * Class for creating operations to manipulate Job entities. + * + */ +public class Job { + private static final String ENTITY_SET = "Jobs"; + + // Prevent instantiation + private Job() { + } + + public static Creator create() { + return new Creator(); + } + + public static class Creator extends EntityOperationSingleResultBase<JobInfo> implements + EntityCreationOperation<JobInfo> { + private String name; + private String alternateId; + private EncryptionOption options; + private JobState state; + + public Creator() { + super(ENTITY_SET, JobInfo.class); + } + + @Override + public Object getRequestContents() { + MediaBatchOperations mediaBatchOperations = null; + try { + mediaBatchOperations = new MediaBatchOperations(getBaseURI()); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + catch (ParserConfigurationException e) { + throw new ServiceException(e); + } + + CreateJobOperation createJobOperation = createCreateJobOperation(createJobOptions); + + mediaBatchOperations.addOperation(createJobOperation); + for (CreateTaskOptions createTaskOptionsInstance : createTaskOptions) { + CreateTaskOperation createTaskOperation = createTaskOperation(createTaskOptionsInstance); + mediaBatchOperations.addOperation(createTaskOperation); + } + + MimeMultipart mimeMultipart; + try { + mimeMultipart = mediaBatchOperations.getMimeMultipart(); + } + catch (MessagingException e) { + throw new ServiceException(e); + } + catch (IOException e) { + throw new ServiceException(e); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + + return mimeMultipart; + } + + /** + * Set the name of the job to be created + * + * @param name + * The name + * @return The creator object (for call chaining) + */ + public Creator setName(String name) { + this.name = name; + return this; + } + + /** + * Sets the alternate id of the job to be created. + * + * @param alternateId + * The id + * + * @return The creator object (for call chaining) + */ + public Creator setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + public Creator setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + public Creator setState(JobState state) { + this.state = state; + return this; + } + + public Object setPriority(int i) { + // TODO Auto-generated method stub + return null; + } + } + + /** + * Create an operation object that will get the state of the given job. + * + * @param jobId + * id of job to retrieve + * @return the get operation + */ + public static EntityGetOperation<JobInfo> get(String jobId) { + return new DefaultGetOperation<JobInfo>(ENTITY_SET, jobId, JobInfo.class); + } + + /** + * Create an operation that will list all the jobs. + * + * @return The list operation + */ + public static EntityListOperation<JobInfo> list() { + return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() { + }); + } + + /** + * Create an operation that will list all the jobs which match the given query parameters + * + * @param queryParameters + * query parameters to pass to the server. + * @return the list operation. + */ + public static EntityListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() { + }, queryParameters); + } + + /** + * Create an operation to delete the given job + * + * @param jobId + * id of job to delete + * @return the delete operation + */ + public static EntityDeleteOperation delete(String jobId) { + return new DefaultDeleteOperation(ENTITY_SET, jobId); + } + + public static Object cancel(String jobId) { + return null; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java deleted file mode 100644 index b436acb898784..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListJobsResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.List; - -/** - * The Class ListJobsResult. - */ -public class ListJobsResult { - - /** The job infos. */ - private List<JobInfo> jobInfos; - - /** - * Gets the job infos. - * - * @return the job infos - */ - public List<JobInfo> getJobInfos() { - return jobInfos; - } - - /** - * Sets the job infos. - * - * @param jobInfos - * the job infos - * @return the list jobs result - */ - public ListJobsResult setJobInfos(List<JobInfo> jobInfos) { - this.jobInfos = jobInfos; - return this; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java new file mode 100644 index 0000000000000..2c4b4e77ba1cc --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -0,0 +1,209 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.sun.jersey.api.client.GenericType; + +/** + * Class for creating operations to manipulate Task entities. + * + */ +public class Task { + private static final String ENTITY_SET = "Tasks"; + + // Prevent instantiation + private Task() { + } + + public static Creator create() { + return new Creator(); + } + + public static class Creator extends EntityOperationSingleResultBase<TaskInfo> implements + EntityCreationOperation<TaskInfo> { + private String name; + private String alternateId; + private EncryptionOption options; + private TaskState state; + + public Creator() { + super(ENTITY_SET, TaskInfo.class); + } + + @Override + public Object getRequestContents() { + TaskType taskType = new TaskType(); + taskType.setName(name); + taskType.setAlternateId(alternateId); + if (options != null) { + taskType.setOptions(options.getCode()); + } + if (state != null) { + taskType.setState(state.getCode()); + } + return taskType; + } + + /** + * Set the name of the task to be created + * + * @param name + * The name + * @return The creator object (for call chaining) + */ + public Creator setName(String name) { + this.name = name; + return this; + } + + /** + * Sets the alternate id of the task to be created. + * + * @param alternateId + * The id + * + * @return The creator object (for call chaining) + */ + public Creator setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + + public Creator setOptions(EncryptionOption options) { + this.options = options; + return this; + } + + public Creator setState(TaskState state) { + this.state = state; + return this; + } + + public Object setConfiguration(String string) { + // TODO Auto-generated method stub + return null; + } + } + + /** + * Create an operation object that will get the state of the given task. + * + * @param taskId + * id of task to retrieve + * @return the get operation + */ + public static EntityGetOperation<TaskInfo> get(String taskId) { + return new DefaultGetOperation<TaskInfo>(ENTITY_SET, taskId, TaskInfo.class); + } + + /** + * Create an operation that will list all the tasks. + * + * @return The list operation + */ + public static EntityListOperation<TaskInfo> list() { + return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() { + }); + } + + /** + * Create an operation that will list all the tasks which match the given query parameters + * + * @param queryParameters + * query parameters to pass to the server. + * @return the list operation. + */ + public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() { + }, queryParameters); + } + + /** + * Create an operation that will update the given task + * + * @param taskId + * id of the task to update + * @return the update operation + */ + public static Updater update(String taskId) { + return new Updater(taskId); + } + + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + private String name; + private String alternateId; + + protected Updater(String taskId) { + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, taskId)); + } + + @Override + public Object getRequestContents() { + TaskType taskType = new TaskType(); + taskType.setName(name); + taskType.setAlternateId(alternateId); + return taskType; + } + + /** + * Sets new name for task + * + * @param name + * The new name + * @return Updater instance + */ + public Updater setName(String name) { + this.name = name; + return this; + } + + /** + * Sets new alternate id for task + * + * @param alternateId + * the new alternate id + * @return Updater instance + */ + public Updater setAlternateId(String alternateId) { + this.alternateId = alternateId; + return this; + } + } + + /** + * Create an operation to delete the given task + * + * @param taskId + * id of task to delete + * @return the delete operation + */ + public static EntityDeleteOperation delete(String taskId) { + return new DefaultDeleteOperation(ENTITY_SET, taskId); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java new file mode 100644 index 0000000000000..a5ec7a24a847c --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -0,0 +1,222 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Task; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class JobIntegrationTest extends IntegrationTestBase { + + private final String testJobPrefix = "testJobPrefix"; + private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; + + private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { + verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), + expected.getState(), expected.getTemplateId(), expected.getInputMediaAssets(), + expected.getOutputMediaAssets(), actual); + } + + private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, + Integer state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, + JobInfo actualJob) { + assertNotNull(message, actualJob); + assertEquals(message + " Name", testName, actualJob.getName()); + // comment out due to issue 464 + // assertEquals(message + " Priority", priority, actualJob.getPriority()); + assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); + assertEquals(message + " State", state, actualJob.getState()); + // commented out due to issue 463 + // assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); + assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); + assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); + } + + private JobInfo createJob(String name) throws ServiceException { + AssetInfo assetInfo = service.create(Asset.create().setName(name)); + return service.create(Job + .create() + .setName("My Encoding Job") + .setPriority(3) + .addInputMediaAsset(assetInfo.getId()) + .addTask( + Task.create().setConfiguration("H.264 256k DSL CBR") + .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") + .setName("My encoding Task").setTaskBody(taskBody))); + } + + @Test + public void createJobSuccess() throws Exception { + // Arrange + AssetInfo assetInfo = service.create(Asset.create()); + + JobInfo expectedJob = new JobInfo(); + expectedJob.setName("My Encoding Job"); + expectedJob.setPriority(3); + expectedJob.setRunningDuration(0.0); + expectedJob.setState(0); + + // Act + JobInfo actualJob = service.create(Job + .create() + .setName("My Encoding Job") + .setPriority(3) + .addInputMediaAsset(assetInfo.getId()) + .addTask( + Task.create().setConfiguration("H.264 256k DSL CBR") + .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") + .setName("My encoding Task").setTaskBody(taskBody))); + + // Assert + verifyJobInfoEqual("actualJob", expectedJob, actualJob); + } + + @Test + public void getJobSuccess() throws Exception { + // Arrange + + JobInfo expectedJob = new JobInfo(); + expectedJob.setName("My Encoding Job"); + expectedJob.setPriority(3); + expectedJob.setRunningDuration(0.0); + expectedJob.setState(0); + String jobId = createJob("getJobSuccess").getId(); + + // Act + JobInfo actualJob = service.get(Job.get(jobId)); + + // Assert + verifyJobInfoEqual("actualJob", expectedJob, actualJob); + } + + @Test + public void getJobInvalidIdFailed() throws ServiceException { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.get(Job.get(invalidId)); + } + + @Test + public void listJobSuccess() throws ServiceException { + // Arrange + JobInfo jobInfo = createJob("listJobSuccess"); + List<JobInfo> jobInfos = new ArrayList<JobInfo>(); + jobInfos.add(jobInfo); + ListResult<JobInfo> expectedListJobsResult = new ListResult<JobInfo>(jobInfos); + + // Act + ListResult<JobInfo> actualListJobResult = service.list(Job.list()); + + // Assert + verifyListResultContains("listJobs", expectedListJobsResult, actualListJobResult, new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual); + } + }); + } + + @Test + public void canListJobsWithOptions() throws ServiceException { + String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", + testJobPrefix + "assetListOptionsC", testJobPrefix + "assetListOptionsD" }; + List<JobInfo> expectedJobs = new ArrayList<JobInfo>(); + for (int i = 0; i < assetNames.length; i++) { + String name = assetNames[i]; + JobInfo jobInfo = createJob(name); + expectedJobs.add(jobInfo); + } + + MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); + queryParameters.add("top", "2"); + ListResult<JobInfo> listJobsResult = service.list(Job.list(queryParameters)); + + // Assert + assertEquals(2, listJobsResult.size()); + } + + @Test + public void cancelJobSuccess() throws Exception { + // Arrange + JobInfo jobInfo = createJob("cancelJobSuccess"); + + // Act + service.action(Job.cancel(jobInfo.getId())); + + // Assert + JobInfo canceledJob = service.get(Job.get(jobInfo.getId())); + assertEquals((Integer) 6, canceledJob.getState()); + + } + + @Test + public void cancelJobFailedWithInvalidId() throws ServiceException { + // Arrange + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + + // Act + service.action(Job.cancel(invalidId)); + + // Assert + } + + @Test + public void deleteJobSuccess() throws ServiceException { + // Arrange + JobInfo jobInfo = createJob("deleteJobSuccess"); + service.action(Job.cancel(jobInfo.getId())); + JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); + while (cancellingJobInfo.getState() == 6) { + cancellingJobInfo = service.get(Job.get(jobInfo.getId())); + } + + // Act + service.delete(Job.delete(jobInfo.getId())); + + // Assert + expectedException.expect(ServiceException.class); + service.get(Job.get(jobInfo.getId())); + + } + + @Test + public void deleteJobIvalidIdFail() throws ServiceException { + // Arrange + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + + // Act + service.delete(Job.delete(invalidId)); + + // Assert + } +} From fcb8275358cd13396d328b5e5f70f6e806b524af Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 13 Nov 2012 15:58:29 -0800 Subject: [PATCH 482/664] Initial check in for action. --- .../entities/DefaultActionOperation.java | 102 ++++++++++++++++++ .../entities/EntityActionOperation.java | 53 +++++++++ .../entities/EntityContract.java | 2 +- .../entities/EntityRestProxy.java | 8 ++ .../services/media/models/Job.java | 7 +- 5 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java new file mode 100644 index 0000000000000..addc28195958b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -0,0 +1,102 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.entities; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +// TODO: Auto-generated Javadoc +/** + * Generic implementation of Delete operation usable by most entities. + */ +public class DefaultActionOperation implements EntityActionOperation { + + /** The entity set. */ + private final String entitySet; + + /** The verb. */ + private final String verb; + + /** The query parameters. */ + private final MultivaluedMap queryParameters; + + /** + * The default action operation. + * + * @param entitySet + * the entity set + * @param verb + * the verb + */ + public DefaultActionOperation(String entitySet, String verb) { + this.entitySet = entitySet; + this.verb = verb; + this.queryParameters = new MultivaluedMapImpl(); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation#getUri() + */ + @Override + public String getUri() { + return String.format("%s/%s", entitySet, verb); + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getQueryParameters() + */ + @Override + public MultivaluedMap getQueryParameters() { + return this.queryParameters; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() + */ + @Override + public MediaType getContentType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() + */ + @Override + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) + */ + @Override + public EntityActionOperation addQueryParameter(String key, String value) { + this.queryParameters.add(key, value); + return null; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + */ + @Override + public void processResponse(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java new file mode 100644 index 0000000000000..9dcf29522a767 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -0,0 +1,53 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.entities; + +import javax.ws.rs.core.MultivaluedMap; + +import com.sun.jersey.api.client.ClientResponse; + +// TODO: Auto-generated Javadoc +/** + * Action operation for Entities. + */ +public interface EntityActionOperation extends EntityOperation { + + /** + * Gets the query parameters. + * + * @return the query parameters + */ + MultivaluedMap getQueryParameters(); + + /** + * Adds the query parameter. + * + * @param key + * the key + * @param value + * the value + * @return the entity action operation + */ + EntityActionOperation addQueryParameter(String key, String value); + + /** + * Process response. + * + * @param clientResponse + * the client response + */ + void processResponse(ClientResponse clientResponse); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index f17a703cb8eb0..7919309a56b99 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -81,6 +81,6 @@ public interface EntityContract { * Object providing details of the action * @throws ServiceException */ - public abstract void action(ActionOperation<T> action) throws ServiceException; + public abstract void action(EntityActionOperation action) throws ServiceException; } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 2858fe24b81a9..9a81f80e755a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -78,4 +78,12 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { getResource(deleter.getUri()).delete(); } + @Override + public void action(EntityActionOperation entityActionOperation) { + ClientResponse clientResponse = getResource(entityActionOperation.getUri()) + .queryParams(entityActionOperation.getQueryParameters()).type(entityActionOperation.getContentType()) + .accept(entityActionOperation.getAcceptType()).post(ClientResponse.class); + entityActionOperation.processResponse(clientResponse); + } + } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 696cd7461d964..9fb44e8b90171 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -28,9 +28,11 @@ import com.microsoft.windowsazure.services.media.implementation.CreateJobOperation; import com.microsoft.windowsazure.services.media.implementation.CreateTaskOperation; import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; @@ -187,7 +189,8 @@ public static EntityDeleteOperation delete(String jobId) { return new DefaultDeleteOperation(ENTITY_SET, jobId); } - public static Object cancel(String jobId) { - return null; + public static EntityActionOperation cancel(String jobId) { + return new DefaultActionOperation(ENTITY_SET, "Cancel") + .addQueryParameter("jobId", String.format("'%s'", jobId)); } } From 410cd4a9e8a501573f757797f8d6e4a277b12574 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 13 Nov 2012 17:56:39 -0800 Subject: [PATCH 483/664] Update unit test, add the initial check in for Entity Action Operation. --- .../implementation/MediaBatchOperations.java | 6 +- .../entities/EntityActionOperation.java | 2 +- .../EntityBatchOperation.java} | 0 .../services/media/models/Job.java | 106 +++++++++--------- .../services/media/models/Task.java | 40 +++---- .../services/media/JobIntegrationTest.java | 4 +- 6 files changed, 79 insertions(+), 79 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/{Operation.java => entities/EntityBatchOperation.java} (100%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 19654481e8a7e..c3bd23ed6ad69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -454,11 +454,11 @@ private List<DataSource> parsePartsCore(InputStream entityInputStream, String co /** * Adds the operation. * - * @param operation + * @param entityBatchOperation * the operation */ - public void addOperation(Operation operation) { - this.operations.add(operation); + public void addOperation(EntityBatchOperation entityBatchOperation) { + this.operations.add(entityBatchOperation); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 9dcf29522a767..9053751c49b89 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -30,7 +30,7 @@ public interface EntityActionOperation extends EntityOperation { * * @return the query parameters */ - MultivaluedMap getQueryParameters(); + MultivaluedMap<String, String> getQueryParameters(); /** * Adds the query parameter. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java similarity index 100% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/Operation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 9fb44e8b90171..5db49c8180837 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -15,18 +15,15 @@ package com.microsoft.windowsazure.services.media.models; -import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; -import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; -import javax.print.attribute.standard.JobState; import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.JAXBException; -import javax.xml.parsers.ParserConfigurationException; -import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.CreateJobOperation; -import com.microsoft.windowsazure.services.media.implementation.CreateTaskOperation; import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; @@ -57,53 +54,47 @@ public static Creator create() { public static class Creator extends EntityOperationSingleResultBase<JobInfo> implements EntityCreationOperation<JobInfo> { + private Date startTime; private String name; - private String alternateId; - private EncryptionOption options; - private JobState state; + private Integer priority; + private final List<String> inputMediaAssets; + private URI serviceUri; + private final List<Task.Creator> taskCreators; + + private CreateJobOperation createCreateJobOperation() { + CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri); + return createJobOperation; + } public Creator() { super(ENTITY_SET, JobInfo.class); + this.inputMediaAssets = new ArrayList<String>(); + this.taskCreators = new ArrayList<Task.Creator>(); } @Override public Object getRequestContents() { MediaBatchOperations mediaBatchOperations = null; - try { - mediaBatchOperations = new MediaBatchOperations(getBaseURI()); - } - catch (JAXBException e) { - throw new ServiceException(e); - } - catch (ParserConfigurationException e) { - throw new ServiceException(e); - } - CreateJobOperation createJobOperation = createCreateJobOperation(createJobOptions); + mediaBatchOperations = new MediaBatchOperations(serviceUri); + + CreateJobOperation createJobOperation = createCreateJobOperation(); mediaBatchOperations.addOperation(createJobOperation); - for (CreateTaskOptions createTaskOptionsInstance : createTaskOptions) { - CreateTaskOperation createTaskOperation = createTaskOperation(createTaskOptionsInstance); - mediaBatchOperations.addOperation(createTaskOperation); + for (EntityCreationOperation<Task> taskCreator : taskCreateOperations) { + mediaBatchOperations.addOperation(taskCreator); } MimeMultipart mimeMultipart; - try { - mimeMultipart = mediaBatchOperations.getMimeMultipart(); - } - catch (MessagingException e) { - throw new ServiceException(e); - } - catch (IOException e) { - throw new ServiceException(e); - } - catch (JAXBException e) { - throw new ServiceException(e); - } - + mimeMultipart = mediaBatchOperations.getMimeMultipart(); return mimeMultipart; } + public Creator addTaskCreator(Task.Creator taskCreator) { + this.taskCreators.add(taskCreator); + return this; + } + /** * Set the name of the job to be created * @@ -116,32 +107,39 @@ public Creator setName(String name) { return this; } - /** - * Sets the alternate id of the job to be created. - * - * @param alternateId - * The id - * - * @return The creator object (for call chaining) - */ - public Creator setAlternateId(String alternateId) { - this.alternateId = alternateId; - return this; + public String getName() { + return this.name; } - public Creator setOptions(EncryptionOption options) { - this.options = options; + public Creator setPriority(Integer priority) { + this.priority = priority; return this; } - public Creator setState(JobState state) { - this.state = state; + public Integer getPriority() { + return this.priority; + } + + public Date getStartTime() { + return startTime; + } + + public Creator setStartTime(Date startTime) { + this.startTime = startTime; return this; } - public Object setPriority(int i) { - // TODO Auto-generated method stub - return null; + public List<String> getInputMediaAssets() { + return inputMediaAssets; + } + + public List<Task.Creator> getTaskCreators() { + return this.taskCreators; + } + + public Creator addInputMediaAsset(String assetId) { + this.inputMediaAssets.add(assetId); + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 2c4b4e77ba1cc..ff5844131143b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -50,7 +50,9 @@ public static class Creator extends EntityOperationSingleResultBase<TaskInfo> im private String name; private String alternateId; private EncryptionOption options; - private TaskState state; + private String taskBody; + private String configuration; + private String mediaProcessorId; public Creator() { super(ENTITY_SET, TaskInfo.class); @@ -82,33 +84,33 @@ public Creator setName(String name) { return this; } - /** - * Sets the alternate id of the task to be created. - * - * @param alternateId - * The id - * - * @return The creator object (for call chaining) - */ - public Creator setAlternateId(String alternateId) { - this.alternateId = alternateId; - return this; + public String getConfiguration() { + return this.configuration; } - public Creator setOptions(EncryptionOption options) { - this.options = options; + public Creator setConfiguration(String configuration) { + this.configuration = configuration; return this; } - public Creator setState(TaskState state) { - this.state = state; + public String getMediaProcessorId() { + return this.mediaProcessorId; + } + + public Creator setMediaProcessorId(String mediaProcessorId) { + this.mediaProcessorId = mediaProcessorId; return this; } - public Object setConfiguration(String string) { - // TODO Auto-generated method stub - return null; + public String getTaskBody() { + return taskBody; } + + public Creator setTaskBody(String taskBody) { + this.taskBody = taskBody; + return this; + } + } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index a5ec7a24a847c..ea88206f2255a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -67,7 +67,7 @@ private JobInfo createJob(String name) throws ServiceException { .setName("My Encoding Job") .setPriority(3) .addInputMediaAsset(assetInfo.getId()) - .addTask( + .addTaskCreator( Task.create().setConfiguration("H.264 256k DSL CBR") .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") .setName("My encoding Task").setTaskBody(taskBody))); @@ -90,7 +90,7 @@ public void createJobSuccess() throws Exception { .setName("My Encoding Job") .setPriority(3) .addInputMediaAsset(assetInfo.getId()) - .addTask( + .addTaskCreator( Task.create().setConfiguration("H.264 256k DSL CBR") .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") .setName("My encoding Task").setTaskBody(taskBody))); From 582583e390cd2799fe48e608679ccb003c9ddcfd Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 13 Nov 2012 21:28:25 -0800 Subject: [PATCH 484/664] Resolve all the compilation errors. --- .../implementation/CreateJobOperation.java | 60 ------ .../implementation/CreateTaskOperation.java | 30 --- .../implementation/MediaBatchOperations.java | 49 ++--- .../MediaExceptionProcessor.java | 14 ++ .../entities/EntityBatchOperation.java | 8 +- .../entities/EntityCreationOperation.java | 4 +- .../services/media/models/AssetInfo.java | 12 -- .../services/media/models/Job.java | 178 +++++++++++++++--- .../services/media/models/Task.java | 142 +++----------- 9 files changed, 233 insertions(+), 264 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java deleted file mode 100644 index e2f3ce07bd750..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateJobOperation.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.implementation; - -import java.net.URI; -import java.util.List; - -import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.microsoft.windowsazure.services.media.models.JobInfo; - -public class CreateJobOperation extends Operation { - - private final URI assetServiceURI; - private JobInfo jobInfo; - - public CreateJobOperation(URI assetServiceURI) { - this.verb = "POST"; - this.assetServiceURI = assetServiceURI; - } - - public CreateJobOperation setJob(List<String> inputMediaAssets, List<String> outputMediaAssets, JobType jobType) { - for (String inputMediaAsset : inputMediaAssets) { - addLink("InputMediaAssets", - String.format("%s/Assets('%s')", assetServiceURI.toString(), inputMediaAsset.toString()), - "application/atom+xml;type=feed", - "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); - } - - for (String outputMediaAsset : outputMediaAssets) { - addLink("OutputMediaAssets", - String.format("%s/Assets('%s'", assetServiceURI.toString(), outputMediaAsset.toString()), - "application/atom+xml;type=feed", - "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); - } - addContentObject(jobType); - return this; - } - - public void setJobInfo(JobInfo jobInfo) { - this.jobInfo = jobInfo; - } - - public JobInfo getJobInfo() { - return this.jobInfo; - } - -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java deleted file mode 100644 index d2f4ac99e2179..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/CreateTaskOperation.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.implementation; - -import com.microsoft.windowsazure.services.media.implementation.content.TaskType; - -public class CreateTaskOperation extends Operation { - - public CreateTaskOperation() { - this.verb = "POST"; - } - - public CreateTaskOperation setTask(TaskType taskType) { - addContentObject(taskType); - return this; - } -} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index c3bd23ed6ad69..92cebb563e031 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -42,7 +42,10 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; +import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; @@ -55,7 +58,7 @@ public class MediaBatchOperations { /** The operations. */ - private final List<Operation> operations; + private final List<EntityBatchOperation> entityBatchOperations; /** The service uri. */ private final URI serviceURI; @@ -82,7 +85,7 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur } this.serviceURI = serviceURI; this.oDataAtomMarshaller = new ODataAtomMarshaller(); - this.operations = new ArrayList<Operation>(); + this.entityBatchOperations = new ArrayList<EntityBatchOperation>(); batchId = String.format("batch_%s", UUID.randomUUID().toString()); try { this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); @@ -140,13 +143,13 @@ private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int conten int jobContentId = contentId; ValidateJobOperation(); - for (Operation operation : operations) { + for (EntityBatchOperation entityBatchOperation : entityBatchOperations) { DataSource bodyPartContent = null; - if (operation instanceof CreateJobOperation) { - CreateJobOperation createJobOperation = (CreateJobOperation) operation; + if (entityBatchOperation instanceof Job.CreateBatchOperation) { + Job.CreateBatchOperation jobCreateBatchOperation = (Job.CreateBatchOperation) entityBatchOperation; jobContentId = contentId; - bodyPartContent = createBatchCreateEntityPart(createJobOperation.getVerb(), "Jobs", - createJobOperation.getEntryType(), jobURI, contentId); + bodyPartContent = createBatchCreateEntityPart(jobCreateBatchOperation.getVerb(), "Jobs", + jobCreateBatchOperation.getEntryType(), jobURI, contentId); contentId++; if (bodyPartContent != null) { bodyPartContents.add(bodyPartContent); @@ -159,8 +162,8 @@ private int addJobPart(List<DataSource> bodyPartContents, URI jobURI, int conten private void ValidateJobOperation() { int jobCount = 0; - for (Operation operation : operations) { - if (operation instanceof CreateJobOperation) { + for (EntityBatchOperation entityBatchOperation : entityBatchOperations) { + if (entityBatchOperation instanceof Job.CreateBatchOperation) { jobCount++; } } @@ -184,10 +187,10 @@ private void ValidateJobOperation() { * the jAXB exception */ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int contentId) throws JAXBException { - for (Operation operation : operations) { + for (EntityBatchOperation entityBatchOperation : entityBatchOperations) { DataSource bodyPartContent = null; - if (operation instanceof CreateTaskOperation) { - CreateTaskOperation createTaskOperation = (CreateTaskOperation) operation; + if (entityBatchOperation instanceof Task.CreateBatchOperation) { + Task.CreateBatchOperation createTaskOperation = (Task.CreateBatchOperation) entityBatchOperation; bodyPartContent = createBatchCreateEntityPart(createTaskOperation.getVerb(), "Tasks", createTaskOperation.getEntryType(), taskURI, contentId); contentId++; @@ -311,17 +314,17 @@ public void parseBatchResult(ClientResponse response) throws IOException, Servic List<DataSource> parts = parseParts(response.getEntityInputStream(), response.getHeaders().getFirst("Content-Type")); - if (parts.size() == 0 || parts.size() > operations.size()) { + if (parts.size() == 0 || parts.size() > entityBatchOperations.size()) { throw new UniformInterfaceException(String.format( "Batch response from server does not contain the correct amount " - + "of parts (expecting %d, received %d instead)", parts.size(), operations.size()), - response); + + "of parts (expecting %d, received %d instead)", parts.size(), + entityBatchOperations.size()), response); } ArrayList<Object> result = new ArrayList<Object>(); for (int i = 0; i < parts.size(); i++) { DataSource ds = parts.get(i); - Operation operation = operations.get(i); + EntityBatchOperation entityBatchOperation = entityBatchOperations.get(i); StatusLine status = StatusLine.create(ds); InternetHeaders headers = parseHeaders(ds); @@ -342,18 +345,18 @@ public void parseBatchResult(ClientResponse response) throws IOException, Servic UniformInterfaceException uniformInterfaceException = new UniformInterfaceException(clientResponse); throw uniformInterfaceException; } - else if (operation instanceof CreateJobOperation) { + else if (entityBatchOperation instanceof Job.CreateBatchOperation) { try { jobInfo = oDataAtomUnmarshaller.unmarshalEntry(content, JobInfo.class); - CreateJobOperation createJobOperation = (CreateJobOperation) operation; - createJobOperation.setJobInfo(jobInfo); + Job.CreateBatchOperation jobCreateBatchOperation = (Job.CreateBatchOperation) entityBatchOperation; + jobCreateBatchOperation.setJobInfo(jobInfo); } catch (JAXBException e) { throw new ServiceException(e); } } - else if (operation instanceof CreateTaskOperation) { + else if (entityBatchOperation instanceof Task.CreateBatchOperation) { EntryType entryType = null; try { entryType = oDataAtomUnmarshaller.unmarshalEntry(content); @@ -458,7 +461,7 @@ private List<DataSource> parsePartsCore(InputStream entityInputStream, String co * the operation */ public void addOperation(EntityBatchOperation entityBatchOperation) { - this.operations.add(entityBatchOperation); + this.entityBatchOperations.add(entityBatchOperation); } /** @@ -537,8 +540,8 @@ private void appendEntity(OutputStream outputStream, ByteArrayInputStream byteAr } } - public List<Operation> getOperations() { - return operations; + public List<EntityBatchOperation> getOperations() { + return entityBatchOperations; } public String getBatchId() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 0818049ac61fd..464de15a7da89 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -24,6 +24,7 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; @@ -166,4 +167,17 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { } } + @Override + public void action(EntityActionOperation action) throws ServiceException { + try { + service.action(action); + } + 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/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index 888798c8b1149..e88100c03986a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation; +package com.microsoft.windowsazure.services.media.implementation.entities; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -23,12 +23,12 @@ import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; -public class Operation { +public class EntityBatchOperation { protected String verb; protected EntryType entryType; - public Operation() { + public EntityBatchOperation() { this.entryType = new EntryType(); } @@ -44,7 +44,7 @@ protected void setVerb(String verb) { this.verb = verb; } - protected String getVerb() { + public String getVerb() { return this.verb; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java index 4fc92268ea4c9..7627e8b7d97a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation.entities; +import com.microsoft.windowsazure.services.core.ServiceException; /** * @@ -27,6 +28,7 @@ public interface EntityCreationOperation<T> extends EntityOperationSingleResult< * the request data for entity creation. * * @return The payload to be marshalled and sent to the server. + * @throws ServiceException */ - Object getRequestContents(); + Object getRequestContents() throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 4c2ed0f646cc3..f9fe303bfbdb1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -173,16 +173,4 @@ public EncryptionOption getOptions() { return EncryptionOption.fromCode(getContent().getOptions()); } - /** - * Set the options - * - * @param options - * the options - * @return the asset info - */ - public AssetInfo setOptions(EncryptionOption options) { - getContent().setOptions(options.getCode()); - return this; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 5db49c8180837..7bad94577c964 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -15,21 +15,26 @@ package com.microsoft.windowsazure.services.media.models; +import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.List; +import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; -import com.microsoft.windowsazure.services.media.implementation.CreateJobOperation; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; @@ -42,61 +47,113 @@ * */ public class Job { + + /** The Constant ENTITY_SET. */ private static final String ENTITY_SET = "Jobs"; // Prevent instantiation + /** + * Instantiates a new job. + */ private Job() { } + /** + * Creates the. + * + * @return the creator + */ public static Creator create() { return new Creator(); } + /** + * The Class Creator. + */ public static class Creator extends EntityOperationSingleResultBase<JobInfo> implements EntityCreationOperation<JobInfo> { + + /** The start time. */ private Date startTime; + + /** The name. */ private String name; + + /** The priority. */ private Integer priority; + + /** The input media assets. */ private final List<String> inputMediaAssets; + + /** The service uri. */ private URI serviceUri; - private final List<Task.Creator> taskCreators; - private CreateJobOperation createCreateJobOperation() { - CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri); - return createJobOperation; - } + /** The task create batch operations. */ + private final List<Task.CreateBatchOperation> taskCreateBatchOperations; + /** + * Instantiates a new creator. + */ public Creator() { super(ENTITY_SET, JobInfo.class); this.inputMediaAssets = new ArrayList<String>(); - this.taskCreators = new ArrayList<Task.Creator>(); + this.taskCreateBatchOperations = new ArrayList<Task.CreateBatchOperation>(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + */ @Override - public Object getRequestContents() { + public Object getRequestContents() throws ServiceException { MediaBatchOperations mediaBatchOperations = null; - mediaBatchOperations = new MediaBatchOperations(serviceUri); + try { + mediaBatchOperations = new MediaBatchOperations(serviceUri); + } + catch (JAXBException e) { + throw new ServiceException(e); + } + catch (ParserConfigurationException e) { + throw new ServiceException(e); + } - CreateJobOperation createJobOperation = createCreateJobOperation(); + CreateBatchOperation createJobBatchOperation = CreateBatchOperation.create(this); - mediaBatchOperations.addOperation(createJobOperation); - for (EntityCreationOperation<Task> taskCreator : taskCreateOperations) { - mediaBatchOperations.addOperation(taskCreator); + mediaBatchOperations.addOperation(createJobBatchOperation); + for (Task.CreateBatchOperation taskCreateBatchOperation : taskCreateBatchOperations) { + mediaBatchOperations.addOperation(taskCreateBatchOperation); } MimeMultipart mimeMultipart; - mimeMultipart = mediaBatchOperations.getMimeMultipart(); + try { + mimeMultipart = mediaBatchOperations.getMimeMultipart(); + } + catch (MessagingException e) { + throw new ServiceException(e); + } + catch (IOException e) { + throw new ServiceException(e); + } + catch (JAXBException e) { + throw new ServiceException(e); + } return mimeMultipart; } - public Creator addTaskCreator(Task.Creator taskCreator) { - this.taskCreators.add(taskCreator); + /** + * Adds the task creator. + * + * @param taskCreateBatchOperation + * the task create batch operation + * @return the creator + */ + public Creator addTaskCreator(Task.CreateBatchOperation taskCreateBatchOperation) { + this.taskCreateBatchOperations.add(taskCreateBatchOperation); return this; } /** - * Set the name of the job to be created + * Set the name of the job to be created. * * @param name * The name @@ -107,42 +164,114 @@ public Creator setName(String name) { return this; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { return this.name; } + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the creator + */ public Creator setPriority(Integer priority) { this.priority = priority; return this; } + /** + * Gets the priority. + * + * @return the priority + */ public Integer getPriority() { return this.priority; } + /** + * Gets the start time. + * + * @return the start time + */ public Date getStartTime() { return startTime; } + /** + * Sets the start time. + * + * @param startTime + * the start time + * @return the creator + */ public Creator setStartTime(Date startTime) { this.startTime = startTime; return this; } + /** + * Gets the input media assets. + * + * @return the input media assets + */ public List<String> getInputMediaAssets() { return inputMediaAssets; } - public List<Task.Creator> getTaskCreators() { - return this.taskCreators; + /** + * Gets the task creators. + * + * @return the task creators + */ + public List<Task.CreateBatchOperation> getTaskCreators() { + return this.taskCreateBatchOperations; } + /** + * Adds the input media asset. + * + * @param assetId + * the asset id + * @return the creator + */ public Creator addInputMediaAsset(String assetId) { this.inputMediaAssets.add(assetId); return this; } } + /** + * The Class CreateBatchOperation. + */ + public static class CreateBatchOperation extends EntityBatchOperation { + + /** + * Creates the. + * + * @param creator + * the creator + * @return the creates the batch operation + */ + public static CreateBatchOperation create(Creator creator) { + CreateBatchOperation createBatchOperation = new CreateBatchOperation(); + return createBatchOperation; + } + + private JobInfo jobInfo; + + public CreateBatchOperation setJobInfo(JobInfo jobInfo) { + this.jobInfo = jobInfo; + return this; + } + + } + /** * Create an operation object that will get the state of the given job. * @@ -165,7 +294,7 @@ public static EntityListOperation<JobInfo> list() { } /** - * Create an operation that will list all the jobs which match the given query parameters + * Create an operation that will list all the jobs which match the given query parameters. * * @param queryParameters * query parameters to pass to the server. @@ -177,7 +306,7 @@ public static EntityListOperation<JobInfo> list(MultivaluedMap<String, String> q } /** - * Create an operation to delete the given job + * Create an operation to delete the given job. * * @param jobId * id of job to delete @@ -187,6 +316,13 @@ public static EntityDeleteOperation delete(String jobId) { return new DefaultDeleteOperation(ENTITY_SET, jobId); } + /** + * Cancel. + * + * @param jobId + * the job id + * @return the entity action operation + */ public static EntityActionOperation cancel(String jobId) { return new DefaultActionOperation(ENTITY_SET, "Cancel") .addQueryParameter("jobId", String.format("'%s'", jobId)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index ff5844131143b..87dd11655f09e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -17,17 +17,13 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.services.media.implementation.content.TaskType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; /** @@ -41,76 +37,8 @@ public class Task { private Task() { } - public static Creator create() { - return new Creator(); - } - - public static class Creator extends EntityOperationSingleResultBase<TaskInfo> implements - EntityCreationOperation<TaskInfo> { - private String name; - private String alternateId; - private EncryptionOption options; - private String taskBody; - private String configuration; - private String mediaProcessorId; - - public Creator() { - super(ENTITY_SET, TaskInfo.class); - } - - @Override - public Object getRequestContents() { - TaskType taskType = new TaskType(); - taskType.setName(name); - taskType.setAlternateId(alternateId); - if (options != null) { - taskType.setOptions(options.getCode()); - } - if (state != null) { - taskType.setState(state.getCode()); - } - return taskType; - } - - /** - * Set the name of the task to be created - * - * @param name - * The name - * @return The creator object (for call chaining) - */ - public Creator setName(String name) { - this.name = name; - return this; - } - - public String getConfiguration() { - return this.configuration; - } - - public Creator setConfiguration(String configuration) { - this.configuration = configuration; - return this; - } - - public String getMediaProcessorId() { - return this.mediaProcessorId; - } - - public Creator setMediaProcessorId(String mediaProcessorId) { - this.mediaProcessorId = mediaProcessorId; - return this; - } - - public String getTaskBody() { - return taskBody; - } - - public Creator setTaskBody(String taskBody) { - this.taskBody = taskBody; - return this; - } - + public static CreateBatchOperation create() { + return new CreateBatchOperation(); } /** @@ -146,56 +74,44 @@ public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> }, queryParameters); } - /** - * Create an operation that will update the given task - * - * @param taskId - * id of the task to update - * @return the update operation - */ - public static Updater update(String taskId) { - return new Updater(taskId); - } - - public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + public static class CreateBatchOperation extends EntityBatchOperation { + private String configuration; + private String mediaProcessorId; private String name; - private String alternateId; + private String taskBody; - protected Updater(String taskId) { - super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, taskId)); + public CreateBatchOperation setConfiguration(String configuration) { + this.configuration = configuration; + return this; + } + + public String getConfiguration() { + return this.configuration; } - @Override - public Object getRequestContents() { - TaskType taskType = new TaskType(); - taskType.setName(name); - taskType.setAlternateId(alternateId); - return taskType; + public CreateBatchOperation setMediaProcessorId(String mediaProcessorId) { + this.mediaProcessorId = mediaProcessorId; + return this; } - /** - * Sets new name for task - * - * @param name - * The new name - * @return Updater instance - */ - public Updater setName(String name) { + public CreateBatchOperation setName(String name) { this.name = name; return this; } - /** - * Sets new alternate id for task - * - * @param alternateId - * the new alternate id - * @return Updater instance - */ - public Updater setAlternateId(String alternateId) { - this.alternateId = alternateId; + public String getName() { + return this.name; + } + + public CreateBatchOperation setTaskBody(String taskBody) { + this.taskBody = taskBody; return this; } + + public String getTaskBody() { + return this.taskBody; + } + } /** From da537bd727b35b9e735e9a0d97a1a22d09b82eda Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 00:16:59 -0800 Subject: [PATCH 485/664] make all unit test runnable. --- .../services/media/MediaContract.java | 4 + .../implementation/MediaBatchOperations.java | 11 +- .../MediaExceptionProcessor.java | 14 ++ .../media/implementation/MediaRestProxy.java | 9 + .../services/media/models/AssetInfo.java | 52 +++-- .../services/media/models/Job.java | 54 ++++- .../services/media/JobIntegrationTest.java | 7 +- .../MediaBatchOperationsTest.java | 25 +-- .../media/models/CreateJobOptionsTest.java | 98 --------- .../media/models/CreateTaskOptionsTest.java | 195 ------------------ 10 files changed, 129 insertions(+), 340 deletions(-) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 58e56ea16c7eb..47ddbbac61b5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media; +import java.net.URI; + import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; @@ -24,4 +26,6 @@ */ public interface MediaContract extends FilterableService<MediaContract>, EntityContract { + URI getRestServiceUri(); + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 92cebb563e031..b717444e68e75 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -67,7 +67,7 @@ public class MediaBatchOperations { private final ODataAtomMarshaller oDataAtomMarshaller; /** The o data atom unmarshaller. */ - private ODataAtomUnmarshaller oDataAtomUnmarshaller; + private final ODataAtomUnmarshaller oDataAtomUnmarshaller; private final String batchId; @@ -87,14 +87,7 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur this.oDataAtomMarshaller = new ODataAtomMarshaller(); this.entityBatchOperations = new ArrayList<EntityBatchOperation>(); batchId = String.format("batch_%s", UUID.randomUUID().toString()); - try { - this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); - } - catch (JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 464de15a7da89..a57799b805224 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.net.URI; + import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -34,6 +36,7 @@ import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; +// TODO: Auto-generated Javadoc /** * /** * Wrapper implementation of <code>MediaEntityContract</code> that @@ -42,7 +45,10 @@ */ public class MediaExceptionProcessor implements MediaContract { + /** The service. */ private final MediaContract service; + + /** The log. */ private static Log log = LogFactory.getLog(MediaContract.class); /** @@ -167,6 +173,9 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + */ @Override public void action(EntityActionOperation action) throws ServiceException { try { @@ -180,4 +189,9 @@ public void action(EntityActionOperation action) throws ServiceException { } } + @Override + public URI getRestServiceUri() { + return service.getRestServiceUri(); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index b4b146b58a98b..166f4ea47275c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation; +import java.net.URI; import java.util.Arrays; import javax.inject.Inject; @@ -35,6 +36,8 @@ public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); + private RedirectFilter redirectFilter; + /** * Instantiates a new media rest proxy. * @@ -52,6 +55,7 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red VersionHeadersFilter versionHeadersFilter) { super(channel, new ServiceFilter[0]); + this.redirectFilter = redirectFilter; channel.addFilter(redirectFilter); channel.addFilter(authFilter); channel.addFilter(versionHeadersFilter); @@ -79,4 +83,9 @@ public MediaContract withFilter(ServiceFilter filter) { newFilters[filters.length] = filter; return new MediaRestProxy(getChannel(), newFilters); } + + @Override + public URI getRestServiceUri() { + return this.redirectFilter.getBaseURI(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index f9fe303bfbdb1..7f0332b953153 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.models; -import java.net.URI; import java.util.Date; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; @@ -28,18 +27,27 @@ */ public class AssetInfo extends ODataEntity<AssetType> { - private URI uri; - + /** + * Instantiates a new asset info. + * + * @param entry + * the entry + * @param content + * the content + */ public AssetInfo(EntryType entry, AssetType content) { super(entry, content); } + /** + * Instantiates a new asset info. + */ public AssetInfo() { super(new AssetType()); } /** - * Get the asset id + * Get the asset id. * * @return the id */ @@ -48,7 +56,7 @@ public String getId() { } /** - * Set the id + * Set the id. * * @param id * the id @@ -60,7 +68,7 @@ public AssetInfo setId(String id) { } /** - * Get the asset name + * Get the asset name. * * @return the name */ @@ -69,7 +77,7 @@ public String getName() { } /** - * set the name + * set the name. * * @param name * the name @@ -81,7 +89,7 @@ public AssetInfo setName(String name) { } /** - * Get the asset state + * Get the asset state. * * @return the state */ @@ -90,7 +98,7 @@ public AssetState getState() { } /** - * Set the state + * Set the state. * * @param state * the state @@ -102,7 +110,7 @@ public AssetInfo setState(AssetState state) { } /** - * Get the creation date + * Get the creation date. * * @return the date */ @@ -111,7 +119,7 @@ public Date getCreated() { } /** - * Set creation date + * Set creation date. * * @param created * the date @@ -123,7 +131,7 @@ public AssetInfo setCreated(Date created) { } /** - * Get last modified date + * Get last modified date. * * @return the date */ @@ -132,7 +140,7 @@ public Date getLastModified() { } /** - * Set last modified date + * Set last modified date. * * @param lastModified * the date @@ -144,7 +152,7 @@ public AssetInfo setLastModified(Date lastModified) { } /** - * Get the alternate id + * Get the alternate id. * * @return the id */ @@ -153,7 +161,7 @@ public String getAlternateId() { } /** - * Set the alternate id + * Set the alternate id. * * @param alternateId * the id @@ -165,7 +173,7 @@ public AssetInfo setAlternateId(String alternateId) { } /** - * Get the options + * Get the options. * * @return the options */ @@ -173,4 +181,16 @@ public EncryptionOption getOptions() { return EncryptionOption.fromCode(getContent().getOptions()); } + /** + * Sets the options. + * + * @param encryptionOption + * the encryption option + * @return the asset info + */ + public AssetInfo setOptions(EncryptionOption encryptionOption) { + getContent().setOptions(encryptionOption.getCode()); + return this; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 7bad94577c964..ecda84cfa3392 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -63,8 +63,8 @@ private Job() { * * @return the creator */ - public static Creator create() { - return new Creator(); + public static Creator create(URI serviceUri) { + return new Creator(serviceUri); } /** @@ -93,9 +93,13 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp /** * Instantiates a new creator. + * + * @param serviceUri + * the service uri */ - public Creator() { + public Creator(URI serviceUri) { super(ENTITY_SET, JobInfo.class); + this.serviceUri = serviceUri; this.inputMediaAssets = new ArrayList<String>(); this.taskCreateBatchOperations = new ArrayList<Task.CreateBatchOperation>(); } @@ -244,6 +248,27 @@ public Creator addInputMediaAsset(String assetId) { this.inputMediaAssets.add(assetId); return this; } + + /** + * Gets the service uri. + * + * @return the service uri + */ + public URI getServiceUri() { + return this.serviceUri; + } + + /** + * Sets the service uri. + * + * @param serviceUri + * the service uri + * @return the creator + */ + public Creator setServiceUri(URI serviceUri) { + this.serviceUri = serviceUri; + return this; + } } /** @@ -251,6 +276,19 @@ public Creator addInputMediaAsset(String assetId) { */ public static class CreateBatchOperation extends EntityBatchOperation { + /** The service uri. */ + private final URI serviceUri; + + /** + * Instantiates a new creates the batch operation. + * + * @param serviceUri + * the service uri + */ + public CreateBatchOperation(URI serviceUri) { + this.serviceUri = serviceUri; + } + /** * Creates the. * @@ -259,12 +297,20 @@ public static class CreateBatchOperation extends EntityBatchOperation { * @return the creates the batch operation */ public static CreateBatchOperation create(Creator creator) { - CreateBatchOperation createBatchOperation = new CreateBatchOperation(); + CreateBatchOperation createBatchOperation = new CreateBatchOperation(creator.getServiceUri()); return createBatchOperation; } + /** The job info. */ private JobInfo jobInfo; + /** + * Sets the job info. + * + * @param jobInfo + * the job info + * @return the creates the batch operation + */ public CreateBatchOperation setJobInfo(JobInfo jobInfo) { this.jobInfo = jobInfo; return this; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index ea88206f2255a..aff73f1250c88 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; +import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -62,8 +63,9 @@ private void verifyJobProperties(String message, String testName, Integer priori private JobInfo createJob(String name) throws ServiceException { AssetInfo assetInfo = service.create(Asset.create().setName(name)); + URI serviceUri = service.getRestServiceUri(); return service.create(Job - .create() + .create(serviceUri) .setName("My Encoding Job") .setPriority(3) .addInputMediaAsset(assetInfo.getId()) @@ -83,10 +85,11 @@ public void createJobSuccess() throws Exception { expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); expectedJob.setState(0); + URI serviceURI = service.getRestServiceUri(); // Act JobInfo actualJob = service.create(Job - .create() + .create(serviceURI) .setName("My Encoding Job") .setPriority(3) .addInputMediaAsset(assetInfo.getId()) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index 6498de13a31d4..c74ea57762d9d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -19,8 +19,6 @@ import java.io.IOException; import java.net.URI; -import java.util.ArrayList; -import java.util.List; import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; @@ -30,8 +28,8 @@ import org.junit.Test; -import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.microsoft.windowsazure.services.media.implementation.content.TaskType; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.Task; public class MediaBatchOperationsTest { @@ -65,7 +63,7 @@ public void createMediaBatchOperationFailedWithNullUri() throws JAXBException, P public void addCreateJobOperationToMediaBatchOperationsSuccess() throws JAXBException, ParserConfigurationException { // Arrange URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri); + Job.CreateBatchOperation createJobOperation = new Job.CreateBatchOperation(serviceUri); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); @@ -82,11 +80,11 @@ public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBExc ParserConfigurationException { // Arrange URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - CreateTaskOperation createTaskOperation = new CreateTaskOperation(); + Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); - mediaBatchOperations.addOperation(createTaskOperation); + mediaBatchOperations.addOperation(taskCreateBatchOperation); // Assert assertNotNull(mediaBatchOperations); @@ -98,18 +96,13 @@ public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationE IOException { // Arrange URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - JobType jobType = new JobType(); - TaskType taskType = new TaskType(); - CreateTaskOperation createTaskOperation = new CreateTaskOperation().setTask(taskType); - List<String> inputMediaAssets = new ArrayList<String>(); - List<String> outputMediaAssets = new ArrayList<String>(); - CreateJobOperation createJobOperation = new CreateJobOperation(serviceUri).setJob(inputMediaAssets, - outputMediaAssets, jobType); + Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(); + Job.CreateBatchOperation jobCreateBatchOperation = new Job.CreateBatchOperation(serviceUri); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); - mediaBatchOperations.addOperation(createJobOperation); - mediaBatchOperations.addOperation(createTaskOperation); + mediaBatchOperations.addOperation(jobCreateBatchOperation); + mediaBatchOperations.addOperation(taskCreateBatchOperation); MimeMultipart mimeMultipart = mediaBatchOperations.getMimeMultipart(); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java deleted file mode 100644 index c06174e521ccf..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateJobOptionsTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.junit.Test; - -public class CreateJobOptionsTest { - - @Test - public void testGetSetName() { - // Arrange - String expectedJobName = "testGetSetNameJobName"; - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - String actualJobName = createJobOptions.setName(expectedJobName).getName(); - - // Assert - assertEquals(expectedJobName, actualJobName); - } - - @Test - public void testGetSetPriority() { - // Arrange - Integer expectedPriority = 3; - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - Integer actualPriority = createJobOptions.setPriority(expectedPriority).getPriority(); - - // Assert - assertEquals(expectedPriority, actualPriority); - } - - @Test - public void testGetSetStartTime() { - // Arrange - Date expectedStartTime = new Date(); - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - Date actualStartTime = createJobOptions.setStartTime(expectedStartTime).getStartTime(); - - // Assert - assertEquals(expectedStartTime, actualStartTime); - } - - @Test - public void testGetSetInputMediaAssets() { - // Arrange - String expectedInputMediaAsset = "http://www.contoso.com/asset(123)"; - List<String> expectedInputMediaAssets = new ArrayList<String>(); - expectedInputMediaAssets.add(expectedInputMediaAsset); - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - List<String> actualInputMediaAssets = createJobOptions.addInputMediaAsset(expectedInputMediaAsset) - .getInputMediaAssets(); - - // Assert - assertEquals(expectedInputMediaAssets, actualInputMediaAssets); - } - - @Test - public void testGetSetOutputMediaAssets() { - // Arrange - String expectedOutputMediaAsset = "http://www.contoso.com/asset(123)"; - List<String> expectedOutputMediaAssets = new ArrayList<String>(); - expectedOutputMediaAssets.add(expectedOutputMediaAsset); - CreateJobOptions createJobOptions = new CreateJobOptions(); - - // Act - List<String> actualOutputMediaAssets = createJobOptions.addOutputMediaAsset(expectedOutputMediaAsset) - .getOutputMediaAssets(); - - // Assert - assertEquals(expectedOutputMediaAssets, actualOutputMediaAssets); - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java deleted file mode 100644 index 867334a22703c..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/CreateTaskOptionsTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.junit.Test; - -public class CreateTaskOptionsTest { - - @Test - public void testGetSetConfiguration() { - // Arrange - String expectedTaskConfiguration = "testGetSetConfiguration"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualTaskConfiguration = createTaskOptions.setConfiguration(expectedTaskConfiguration) - .getConfiguration(); - - // Assert - assertEquals(expectedTaskConfiguration, actualTaskConfiguration); - } - - @Test - public void testGetSetMediaProcessorId() { - // Arrange - String expectedMediaProcessorId = "testGetSetMediaProcessorId"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualMediaProcessorId = createTaskOptions.setMediaProcessorId(expectedMediaProcessorId) - .getMediaProcessorId(); - - // Assert - assertEquals(expectedMediaProcessorId, actualMediaProcessorId); - - } - - @Test - public void testGetSetName() { - // Arrange - String expectedName = "testGetSetName"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualName = createTaskOptions.setName(expectedName).getName(); - - // Assert - assertEquals(expectedName, actualName); - } - - @Test - public void testGetSetPriority() { - // Arrange - Integer expectedPriority = 3; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - Integer actualPriority = createTaskOptions.setPriority(expectedPriority).getPriority(); - - // Assert - assertEquals(expectedPriority, actualPriority); - } - - @Test - public void testGetSetStartTime() { - // Arrange - Date expectedStartTime = new Date(); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - Date actualStartTime = createTaskOptions.setStartTime(expectedStartTime).getStartTime(); - - // Assert - assertEquals(expectedStartTime, actualStartTime); - } - - @Test - public void testGetSetTaskBody() { - // Arrange - String expectedTaskBody = "testExpectedTaskBody"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualTaskBody = createTaskOptions.setTaskBody(expectedTaskBody).getTaskBody(); - - // Assert - assertEquals(expectedTaskBody, actualTaskBody); - } - - @Test - public void testGetSetEncryptionKeyId() { - // Arrange - String expectedEncryptionKeyId = "testGetSetEncryptionKeyId"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualEncryptionKeyId = createTaskOptions.setEncryptionKeyId(expectedEncryptionKeyId) - .getEncryptionKeyId(); - - // Assert - assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); - } - - @Test - public void testGetSetEncryptionScheme() { - // Arrange - String expectedEncryptionScheme = "testEncryptionScheme"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualEncryptionScheme = createTaskOptions.setEncryptionScheme(expectedEncryptionScheme) - .getEncryptionScheme(); - - // Assert - assertEquals(expectedEncryptionScheme, actualEncryptionScheme); - } - - @Test - public void testGetSetEncryptionVersion() { - // Arrange - String expectedEncryptionVersion = "testEncryptionVersion"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualEncryptionVersion = createTaskOptions.setEncryptionVersion(expectedEncryptionVersion) - .getEncryptionVersion(); - - // Assert - assertEquals(expectedEncryptionVersion, actualEncryptionVersion); - } - - @Test - public void testGetSetInitializationVector() { - // Arrange - String expectedInitializationVector = "testInitializatonVector"; - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - String actualInitializationVector = createTaskOptions.setInitializationVector(expectedInitializationVector) - .getInitializationVector(); - - // Assert - assertEquals(expectedInitializationVector, actualInitializationVector); - } - - @Test - public void testGetSetInputMediaAssets() { - // Arrange - String expectedInputMediaAsset = "http://www.contoso.com/asset(123)"; - List<String> expectedInputMediaAssets = new ArrayList<String>(); - expectedInputMediaAssets.add(expectedInputMediaAsset); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - List<String> actualInputMediaAssets = createTaskOptions.addInputMediaAsset(expectedInputMediaAsset) - .getInputMediaAssets(); - - // Assert - assertEquals(expectedInputMediaAssets, actualInputMediaAssets); - } - - @Test - public void testGetSetOutputMediaAssets() { - // Arrange - String expectedOutputMediaAsset = "http://www.contoso.com/asset(123)"; - List<String> expectedOutputMediaAssets = new ArrayList<String>(); - expectedOutputMediaAssets.add(expectedOutputMediaAsset); - CreateTaskOptions createTaskOptions = new CreateTaskOptions(); - - // Act - List<String> actualOutputMediaAssets = createTaskOptions.addOutputMediaAsset(expectedOutputMediaAsset) - .getOutputMediaAssets(); - - // Assert - assertEquals(expectedOutputMediaAssets, actualOutputMediaAssets); - } -} From 46e8857d4b56d8eba9b6790b88862cbae18157ec Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 00:51:52 -0800 Subject: [PATCH 486/664] Get cancel job unit test passed. --- .../MediaExceptionProcessor.java | 4 +- .../entities/DefaultActionOperation.java | 43 +++++------- .../entities/EntityActionOperation.java | 1 - .../entities/EntityRestProxy.java | 66 ++++++++++++++++++- .../services/media/models/Job.java | 3 +- 5 files changed, 85 insertions(+), 32 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index a57799b805224..9f827fe02a0dd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -36,7 +36,6 @@ import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; -// TODO: Auto-generated Javadoc /** * /** * Wrapper implementation of <code>MediaEntityContract</code> that @@ -189,6 +188,9 @@ public void action(EntityActionOperation action) throws ServiceException { } } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getRestServiceUri() + */ @Override public URI getRestServiceUri() { return service.getRestServiceUri(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index addc28195958b..baa0332169ced 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -22,32 +22,25 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.core.util.MultivaluedMapImpl; -// TODO: Auto-generated Javadoc /** * Generic implementation of Delete operation usable by most entities. */ public class DefaultActionOperation implements EntityActionOperation { - /** The entity set. */ - private final String entitySet; - - /** The verb. */ - private final String verb; + /** The name. */ + private final String name; /** The query parameters. */ - private final MultivaluedMap queryParameters; + private final MultivaluedMap<String, String> queryParameters; /** * The default action operation. * - * @param entitySet - * the entity set - * @param verb - * the verb + * @param name + * the name */ - public DefaultActionOperation(String entitySet, String verb) { - this.entitySet = entitySet; - this.verb = verb; + public DefaultActionOperation(String name) { + this.name = name; this.queryParameters = new MultivaluedMapImpl(); } @@ -56,40 +49,40 @@ public DefaultActionOperation(String entitySet, String verb) { */ @Override public String getUri() { - return String.format("%s/%s", entitySet, verb); + return name; } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getQueryParameters() */ @Override - public MultivaluedMap getQueryParameters() { + public MultivaluedMap<String, String> getQueryParameters() { return this.queryParameters; } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) */ @Override - public MediaType getContentType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; + public EntityActionOperation addQueryParameter(String key, String value) { + this.queryParameters.add(key, value); + return this; } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() */ @Override - public MediaType getAcceptType() { + public MediaType getContentType() { return MediaType.APPLICATION_ATOM_XML_TYPE; } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() */ @Override - public EntityActionOperation addQueryParameter(String key, String value) { - this.queryParameters.add(key, value); - return null; + public MediaType getAcceptType() { + return MediaType.APPLICATION_ATOM_XML_TYPE; } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 9053751c49b89..5b575ab34896e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -19,7 +19,6 @@ import com.sun.jersey.api.client.ClientResponse; -// TODO: Auto-generated Javadoc /** * Action operation for Entities. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 9a81f80e755a8..9018d76fbc753 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -1,3 +1,18 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation.entities; import com.microsoft.windowsazure.services.core.ServiceException; @@ -10,6 +25,9 @@ import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; +/** + * The Class EntityRestProxy. + */ public class EntityRestProxy implements EntityContract { /** The channel. */ @@ -17,15 +35,33 @@ public class EntityRestProxy implements EntityContract { /** The filters. */ private final ServiceFilter[] filters; + /** + * Instantiates a new entity rest proxy. + * + * @param channel + * the channel + * @param filters + * the filters + */ public EntityRestProxy(Client channel, ServiceFilter[] filters) { this.channel = channel; this.filters = filters; } + /** + * Gets the channel. + * + * @return the channel + */ protected Client getChannel() { return channel; } + /** + * Gets the filters. + * + * @return the filters + */ protected ServiceFilter[] getFilters() { return filters; } @@ -45,26 +81,45 @@ private WebResource getResource(String entityName) { return resource; } + /** + * Gets the resource. + * + * @param operation + * the operation + * @return the resource + */ private Builder getResource(EntityOperation operation) { return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation) + */ @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { return getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation) + */ @Override public <T> T get(EntityGetOperation<T> getter) throws ServiceException { return getResource(getter).get(getter.getResponseClass()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation) + */ @Override public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { return getResource(lister.getUri()).queryParams(lister.getQueryParameters()).type(lister.getContentType()) .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#update(com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation) + */ @Override public void update(EntityUpdateOperation updater) throws ServiceException { ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, @@ -73,16 +128,21 @@ public void update(EntityUpdateOperation updater) throws ServiceException { PipelineHelpers.ThrowIfNotSuccess(response); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#delete(com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation) + */ @Override public void delete(EntityDeleteOperation deleter) throws ServiceException { getResource(deleter.getUri()).delete(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + */ @Override public void action(EntityActionOperation entityActionOperation) { - ClientResponse clientResponse = getResource(entityActionOperation.getUri()) - .queryParams(entityActionOperation.getQueryParameters()).type(entityActionOperation.getContentType()) - .accept(entityActionOperation.getAcceptType()).post(ClientResponse.class); + ClientResponse clientResponse = getResource(entityActionOperation.getUri()).queryParams( + entityActionOperation.getQueryParameters()).get(ClientResponse.class); entityActionOperation.processResponse(clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index ecda84cfa3392..bc88038564d96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -370,7 +370,6 @@ public static EntityDeleteOperation delete(String jobId) { * @return the entity action operation */ public static EntityActionOperation cancel(String jobId) { - return new DefaultActionOperation(ENTITY_SET, "Cancel") - .addQueryParameter("jobId", String.format("'%s'", jobId)); + return new DefaultActionOperation("CancelJob").addQueryParameter("jobId", String.format("'%s'", jobId)); } } From 0a4dc2117ed4f27ea8ef68118b91d07315969dd2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 13:05:08 -0800 Subject: [PATCH 487/664] sending create job request correctly. --- .../implementation/MediaBatchOperations.java | 13 ++- .../entities/EntityBatchOperation.java | 2 +- .../entities/EntityOperation.java | 5 +- .../entities/EntityOperationBase.java | 3 +- .../entities/EntityRestProxy.java | 3 +- .../services/media/models/Job.java | 103 ++++++++++++++--- .../services/media/models/Task.java | 109 +++++++++++++++--- 7 files changed, 197 insertions(+), 41 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index b717444e68e75..74fc65eef6df6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -24,7 +24,9 @@ import java.net.URI; import java.util.ArrayList; import java.util.Enumeration; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.UUID; import javax.activation.DataHandler; @@ -36,6 +38,7 @@ import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimePartDataSource; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; @@ -85,9 +88,9 @@ public MediaBatchOperations(URI serviceURI) throws JAXBException, ParserConfigur } this.serviceURI = serviceURI; this.oDataAtomMarshaller = new ODataAtomMarshaller(); + this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); this.entityBatchOperations = new ArrayList<EntityBatchOperation>(); batchId = String.format("batch_%s", UUID.randomUUID().toString()); - this.oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); } /** @@ -207,7 +210,6 @@ private void addTaskPart(List<DataSource> bodyPartContents, URI taskURI, int con * Signals that an I/O exception has occurred. */ private MimeMultipart toMimeMultipart(List<DataSource> bodyPartContents) throws MessagingException, IOException { - // Create unique part boundary strings String changeSetId = String.format("changeset_%s", UUID.randomUUID().toString()); MimeMultipart changeSets = createChangeSets(bodyPartContents, changeSetId); MimeBodyPart mimeBodyPart = createMimeBodyPart(changeSets, changeSetId); @@ -541,4 +543,11 @@ public String getBatchId() { return this.batchId; } + public MediaType getContentType() { + Map<String, String> parameters = new Hashtable<String, String>(); + parameters.put("boundary", this.batchId); + MediaType contentType = new MediaType("multipart", "mixed", parameters); + return contentType; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index e88100c03986a..722f5593de5d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -49,7 +49,7 @@ public String getVerb() { } @SuppressWarnings("unchecked") - protected void addContentObject(Object contentObject) { + public void addContentObject(Object contentObject) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); atomContent.getContent().add( diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 6200ab12419fb..b474575b11d4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -17,6 +17,8 @@ import javax.ws.rs.core.MediaType; +import com.microsoft.windowsazure.services.core.ServiceException; + public interface EntityOperation { /** @@ -30,8 +32,9 @@ public interface EntityOperation { * Get the MIME type for the content that's being sent to the server. * * @return The MIME type + * @throws ServiceException */ - public abstract MediaType getContentType(); + public abstract MediaType getContentType() throws ServiceException; /** * Get the MIME type that we're expecting the server to send back. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index ac5dd3a556ef6..2c9944d23f861 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -21,6 +21,7 @@ import javax.ws.rs.core.MediaType; +import com.microsoft.windowsazure.services.core.ServiceException; /** * Default implementation of EntityOperation<T> to provide @@ -58,7 +59,7 @@ public String getUri() { * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getContentType() */ @Override - public MediaType getContentType() { + public MediaType getContentType() throws ServiceException { return MediaType.APPLICATION_ATOM_XML_TYPE; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 9018d76fbc753..00276f839dc4d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -87,8 +87,9 @@ private WebResource getResource(String entityName) { * @param operation * the operation * @return the resource + * @throws ServiceException */ - private Builder getResource(EntityOperation operation) { + private Builder getResource(EntityOperation operation) throws ServiceException { return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index bc88038564d96..ba37f86e1dda7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -23,12 +23,14 @@ import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; @@ -61,6 +63,8 @@ private Job() { /** * Creates the. * + * @param serviceUri + * the service uri * @return the creator */ public static Creator create(URI serviceUri) { @@ -88,27 +92,17 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp /** The service uri. */ private URI serviceUri; + /** The content type. */ + private MediaType contentType; + /** The task create batch operations. */ private final List<Task.CreateBatchOperation> taskCreateBatchOperations; - /** - * Instantiates a new creator. - * - * @param serviceUri - * the service uri - */ - public Creator(URI serviceUri) { - super(ENTITY_SET, JobInfo.class); - this.serviceUri = serviceUri; - this.inputMediaAssets = new ArrayList<String>(); - this.taskCreateBatchOperations = new ArrayList<Task.CreateBatchOperation>(); - } + private Boolean fresh; - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() - */ - @Override - public Object getRequestContents() throws ServiceException { + private MimeMultipart mimeMultipart;; + + private void buildMimeMultipart() throws ServiceException { MediaBatchOperations mediaBatchOperations = null; try { @@ -128,7 +122,6 @@ public Object getRequestContents() throws ServiceException { mediaBatchOperations.addOperation(taskCreateBatchOperation); } - MimeMultipart mimeMultipart; try { mimeMultipart = mediaBatchOperations.getMimeMultipart(); } @@ -141,6 +134,33 @@ public Object getRequestContents() throws ServiceException { catch (JAXBException e) { throw new ServiceException(e); } + + this.contentType = mediaBatchOperations.getContentType(); + fresh = false; + } + + /** + * Instantiates a new creator. + * + * @param serviceUri + * the service uri + */ + public Creator(URI serviceUri) { + super(ENTITY_SET, JobInfo.class); + this.serviceUri = serviceUri; + this.inputMediaAssets = new ArrayList<String>(); + this.taskCreateBatchOperations = new ArrayList<Task.CreateBatchOperation>(); + this.fresh = true; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + */ + @Override + public Object getRequestContents() throws ServiceException { + if (fresh) { + buildMimeMultipart(); + } return mimeMultipart; } @@ -153,6 +173,7 @@ public Object getRequestContents() throws ServiceException { */ public Creator addTaskCreator(Task.CreateBatchOperation taskCreateBatchOperation) { this.taskCreateBatchOperations.add(taskCreateBatchOperation); + this.fresh = true; return this; } @@ -165,6 +186,7 @@ public Creator addTaskCreator(Task.CreateBatchOperation taskCreateBatchOperation */ public Creator setName(String name) { this.name = name; + this.fresh = true; return this; } @@ -186,6 +208,7 @@ public String getName() { */ public Creator setPriority(Integer priority) { this.priority = priority; + this.fresh = true; return this; } @@ -216,6 +239,7 @@ public Date getStartTime() { */ public Creator setStartTime(Date startTime) { this.startTime = startTime; + this.fresh = true; return this; } @@ -246,6 +270,7 @@ public List<Task.CreateBatchOperation> getTaskCreators() { */ public Creator addInputMediaAsset(String assetId) { this.inputMediaAssets.add(assetId); + this.fresh = true; return this; } @@ -267,8 +292,28 @@ public URI getServiceUri() { */ public Creator setServiceUri(URI serviceUri) { this.serviceUri = serviceUri; + this.fresh = true; return this; } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getContentType() + */ + @Override + public MediaType getContentType() throws ServiceException { + if (fresh) { + buildMimeMultipart(); + } + return this.contentType; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getUri() + */ + @Override + public String getUri() { + return "$batch"; + } } /** @@ -287,6 +332,7 @@ public static class CreateBatchOperation extends EntityBatchOperation { */ public CreateBatchOperation(URI serviceUri) { this.serviceUri = serviceUri; + this.verb = "POST"; } /** @@ -298,9 +344,30 @@ public CreateBatchOperation(URI serviceUri) { */ public static CreateBatchOperation create(Creator creator) { CreateBatchOperation createBatchOperation = new CreateBatchOperation(creator.getServiceUri()); + + JobType jobType = new JobType(); + jobType.setStartTime(creator.getStartTime()); + jobType.setName(creator.getName()); + jobType.setPriority(creator.getPriority()); + + for (String inputMediaAsset : creator.getInputMediaAssets()) { + createBatchOperation.addLink("InputMediaAssets", String.format("%s/Assets('%s')", createBatchOperation + .getServiceUri().toString(), inputMediaAsset.toString()), "application/atom+xml;type=feed", + "http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets"); + } + createBatchOperation.addContentObject(jobType); return createBatchOperation; } + /** + * Gets the service uri. + * + * @return the service uri + */ + public URI getServiceUri() { + return this.serviceUri; + } + /** The job info. */ private JobInfo jobInfo; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 87dd11655f09e..39965212768e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -17,6 +17,7 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; @@ -26,17 +27,28 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.api.client.GenericType; +// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate Task entities. * */ public class Task { + + /** The Constant ENTITY_SET. */ private static final String ENTITY_SET = "Tasks"; // Prevent instantiation + /** + * Instantiates a new task. + */ private Task() { } + /** + * Creates the. + * + * @return the creates the batch operation + */ public static CreateBatchOperation create() { return new CreateBatchOperation(); } @@ -63,7 +75,7 @@ public static EntityListOperation<TaskInfo> list() { } /** - * Create an operation that will list all the tasks which match the given query parameters + * Create an operation that will list all the tasks which match the given query parameters. * * @param queryParameters * query parameters to pass to the server. @@ -74,48 +86,111 @@ public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> }, queryParameters); } + /** + * The Class CreateBatchOperation. + */ public static class CreateBatchOperation extends EntityBatchOperation { - private String configuration; - private String mediaProcessorId; - private String name; - private String taskBody; + /** The task type. */ + private final TaskType taskType; + + /** + * Instantiates a new creates the batch operation. + */ + public CreateBatchOperation() { + this.verb = "POST"; + taskType = new TaskType(); + addContentObject(taskType); + } + + /** + * Sets the configuration. + * + * @param configuration + * the configuration + * @return the creates the batch operation + */ public CreateBatchOperation setConfiguration(String configuration) { - this.configuration = configuration; + this.taskType.setConfiguration(configuration); return this; } + /** + * Gets the configuration. + * + * @return the configuration + */ public String getConfiguration() { - return this.configuration; - } - - public CreateBatchOperation setMediaProcessorId(String mediaProcessorId) { - this.mediaProcessorId = mediaProcessorId; - return this; + return this.taskType.getConfiguration(); } + /** + * Sets the name. + * + * @param name + * the name + * @return the creates the batch operation + */ public CreateBatchOperation setName(String name) { - this.name = name; + this.taskType.setName(name); return this; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { - return this.name; + return this.taskType.getName(); } + /** + * Sets the task body. + * + * @param taskBody + * the task body + * @return the creates the batch operation + */ public CreateBatchOperation setTaskBody(String taskBody) { - this.taskBody = taskBody; + this.taskType.setTaskBody(taskBody); return this; } + /** + * Gets the task body. + * + * @return the task body + */ public String getTaskBody() { - return this.taskBody; + return this.taskType.getTaskBody(); + } + + /** + * Gets the media processor id. + * + * @return the media processor id + */ + public String getMediaProcessorId() { + return this.taskType.getMediaProcessorId(); + } + + /** + * Sets the media processor id. + * + * @param mediaProcessorId + * the media processor id + * @return the creates the batch operation + */ + public CreateBatchOperation setMediaProcessorId(String mediaProcessorId) { + this.taskType.setMediaProcessorId(mediaProcessorId); + return this; } } /** - * Create an operation to delete the given task + * Create an operation to delete the given task. * * @param taskId * id of task to delete From a1d90298ffff9201298ef8339a062a1dd20135b4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 13:45:17 -0800 Subject: [PATCH 488/664] all the unit tests passes. --- .../entities/EntityCreationOperation.java | 17 ++++- .../entities/EntityOperation.java | 1 + .../EntityOperationSingleResultBase.java | 5 ++ .../entities/EntityRestProxy.java | 5 +- .../services/media/models/Job.java | 62 +++++++++++++++++-- .../services/media/JobIntegrationTest.java | 2 +- 6 files changed, 84 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java index 7627e8b7d97a1..aeef692228d90 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java @@ -17,9 +17,12 @@ import com.microsoft.windowsazure.services.core.ServiceException; +// TODO: Auto-generated Javadoc /** + * The Interface EntityCreationOperation. * - * + * @param <T> + * the generic type */ public interface EntityCreationOperation<T> extends EntityOperationSingleResult<T> { @@ -29,6 +32,18 @@ public interface EntityCreationOperation<T> extends EntityOperationSingleResult< * * @return The payload to be marshalled and sent to the server. * @throws ServiceException + * the service exception */ Object getRequestContents() throws ServiceException; + + /** + * Post response process. + * + * @param rawResponse + * the raw response + * @return the object + * @throws ServiceException + * the service exception + */ + Object processResponse(Object rawResponse) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index b474575b11d4e..290e0f7af6442 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -40,4 +40,5 @@ public interface EntityOperation { * Get the MIME type that we're expecting the server to send back. */ public abstract MediaType getAcceptType(); + } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java index d819987c3c581..e1fcc2a9456d3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation.entities; +import com.microsoft.windowsazure.services.core.ServiceException; /** * @@ -43,4 +44,8 @@ public EntityOperationSingleResultBase(EntityOperationBase.EntityUriBuilder uriB public Class<T> getResponseClass() { return responseClass; } + + public Object processResponse(Object rawResponse) throws ServiceException { + return rawResponse; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 00276f839dc4d..5000dab062aef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -96,9 +96,12 @@ private Builder getResource(EntityOperation operation) throws ServiceException { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation) */ + @SuppressWarnings("unchecked") @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { - return getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); + Object rawResponse = getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); + Object processedResponse = creator.processResponse(rawResponse); + return (T) processedResponse; } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index ba37f86e1dda7..d4d56f17fb8e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -42,8 +42,10 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; +// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate Job entities. * @@ -98,12 +100,23 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp /** The task create batch operations. */ private final List<Task.CreateBatchOperation> taskCreateBatchOperations; + /** The fresh. */ private Boolean fresh; + /** The mime multipart. */ private MimeMultipart mimeMultipart;; + /** The media batch operations. */ + private MediaBatchOperations mediaBatchOperations; + + /** + * Builds the mime multipart. + * + * @throws ServiceException + * the service exception + */ private void buildMimeMultipart() throws ServiceException { - MediaBatchOperations mediaBatchOperations = null; + mediaBatchOperations = null; try { mediaBatchOperations = new MediaBatchOperations(serviceUri); @@ -136,7 +149,7 @@ private void buildMimeMultipart() throws ServiceException { } this.contentType = mediaBatchOperations.getContentType(); - fresh = false; + this.fresh = false; } /** @@ -164,6 +177,36 @@ public Object getRequestContents() throws ServiceException { return mimeMultipart; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase#getResponseClass() + */ + @Override + public Class getResponseClass() { + return ClientResponse.class; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#processResponse(java.lang.Object) + */ + @Override + public Object processResponse(Object clientResponse) throws ServiceException { + try { + this.mediaBatchOperations.parseBatchResult((ClientResponse) clientResponse); + } + catch (IOException e) { + throw new ServiceException(e); + } + JobInfo jobInfo = null; + for (EntityBatchOperation entityBatchOperation : this.mediaBatchOperations.getOperations()) { + if (entityBatchOperation instanceof Job.CreateBatchOperation) { + jobInfo = ((Job.CreateBatchOperation) entityBatchOperation).getJobInfo(); + break; + } + } + return jobInfo; + + } + /** * Adds the task creator. * @@ -324,6 +367,9 @@ public static class CreateBatchOperation extends EntityBatchOperation { /** The service uri. */ private final URI serviceUri; + /** The job info. */ + private JobInfo jobInfo; + /** * Instantiates a new creates the batch operation. * @@ -368,9 +414,6 @@ public URI getServiceUri() { return this.serviceUri; } - /** The job info. */ - private JobInfo jobInfo; - /** * Sets the job info. * @@ -383,6 +426,15 @@ public CreateBatchOperation setJobInfo(JobInfo jobInfo) { return this; } + /** + * Gets the job info. + * + * @return the job info + */ + public JobInfo getJobInfo() { + return this.jobInfo; + } + } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index aff73f1250c88..c8af7c80b23f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -159,7 +159,7 @@ public void canListJobsWithOptions() throws ServiceException { } MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); - queryParameters.add("top", "2"); + queryParameters.add("$top", "2"); ListResult<JobInfo> listJobsResult = service.list(Job.list(queryParameters)); // Assert From a4de7463c81684cca2169a2ea74d82e0906c5752 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 22:55:44 -0800 Subject: [PATCH 489/664] code review feedback. --- .../entities/EntityBatchOperation.java | 10 ++++++---- .../implementation/entities/EntityRestProxy.java | 2 +- .../services/media/models/AssetInfo.java | 2 +- .../windowsazure/services/media/models/Job.java | 16 +++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index 722f5593de5d2..1d8931c5dd676 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -36,19 +36,21 @@ public EntryType getEntryType() { return entryType; } - public void setEntityType(EntryType entryType) { + public EntityBatchOperation setEntityType(EntryType entryType) { this.entryType = entryType; + return this; } - protected void setVerb(String verb) { + protected EntityBatchOperation setVerb(String verb) { this.verb = verb; + return this; } public String getVerb() { return this.verb; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public void addContentObject(Object contentObject) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); @@ -60,7 +62,7 @@ public void addContentObject(Object contentObject) { new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) protected void addLink(String title, String href, String type, String rel) { LinkType linkType = new LinkType(); linkType.setTitle(title); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 5000dab062aef..29ec3958793e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -144,7 +144,7 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ @Override - public void action(EntityActionOperation entityActionOperation) { + public void action(EntityActionOperation entityActionOperation) throws ServiceException { ClientResponse clientResponse = getResource(entityActionOperation.getUri()).queryParams( entityActionOperation.getQueryParameters()).get(ClientResponse.class); entityActionOperation.processResponse(clientResponse); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 7f0332b953153..e187f252f9b29 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -182,7 +182,7 @@ public EncryptionOption getOptions() { } /** - * Sets the options. + * Set the options. * * @param encryptionOption * the encryption option diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index d4d56f17fb8e7..6fcab901b0ff8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -45,7 +45,6 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; -// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate Job entities. * @@ -115,21 +114,20 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp * @throws ServiceException * the service exception */ - private void buildMimeMultipart() throws ServiceException { + private void buildMimeMultipart() { mediaBatchOperations = null; + CreateBatchOperation createJobBatchOperation = CreateBatchOperation.create(this); try { mediaBatchOperations = new MediaBatchOperations(serviceUri); } catch (JAXBException e) { - throw new ServiceException(e); + throw new RuntimeException(e); } catch (ParserConfigurationException e) { - throw new ServiceException(e); + throw new RuntimeException(e); } - CreateBatchOperation createJobBatchOperation = CreateBatchOperation.create(this); - mediaBatchOperations.addOperation(createJobBatchOperation); for (Task.CreateBatchOperation taskCreateBatchOperation : taskCreateBatchOperations) { mediaBatchOperations.addOperation(taskCreateBatchOperation); @@ -139,13 +137,13 @@ private void buildMimeMultipart() throws ServiceException { mimeMultipart = mediaBatchOperations.getMimeMultipart(); } catch (MessagingException e) { - throw new ServiceException(e); + throw new RuntimeException(e); } catch (IOException e) { - throw new ServiceException(e); + throw new RuntimeException(e); } catch (JAXBException e) { - throw new ServiceException(e); + throw new RuntimeException(e); } this.contentType = mediaBatchOperations.getContentType(); From 2c92755aa46775b60835fb670af0975a0a350dc4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 14 Nov 2012 23:19:06 -0800 Subject: [PATCH 490/664] code review feedback. --- .../windowsazure/services/media/models/Job.java | 1 + .../windowsazure/services/media/models/Task.java | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 6fcab901b0ff8..2ce4b9a72edbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -178,6 +178,7 @@ public Object getRequestContents() throws ServiceException { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase#getResponseClass() */ + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Class getResponseClass() { return ClientResponse.class; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 39965212768e0..634d63149a0b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -19,15 +19,12 @@ import com.microsoft.windowsazure.services.media.implementation.content.TaskType; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.api.client.GenericType; -// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate Task entities. * @@ -53,17 +50,6 @@ public static CreateBatchOperation create() { return new CreateBatchOperation(); } - /** - * Create an operation object that will get the state of the given task. - * - * @param taskId - * id of task to retrieve - * @return the get operation - */ - public static EntityGetOperation<TaskInfo> get(String taskId) { - return new DefaultGetOperation<TaskInfo>(ENTITY_SET, taskId, TaskInfo.class); - } - /** * Create an operation that will list all the tasks. * From 4bed358396070e402aa935d48d964447656784f3 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 16 Nov 2012 14:27:48 -0800 Subject: [PATCH 491/664] address the code review feedback. --- .../implementation/MediaBatchOperations.java | 6 +- .../media/implementation/atom/EntryType.java | 113 ++++++++++-------- .../entities/EntityBatchOperation.java | 6 +- .../entities/EntityOperation.java | 2 +- .../entities/EntityOperationBase.java | 4 +- .../services/media/models/Job.java | 2 +- 6 files changed, 73 insertions(+), 60 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 74fc65eef6df6..37496ac8c84e8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -370,7 +370,7 @@ else if (entityBatchOperation instanceof Task.CreateBatchOperation) { * the ds * @return the internet headers */ - public InternetHeaders parseHeaders(DataSource ds) { + private InternetHeaders parseHeaders(DataSource ds) { try { return new InternetHeaders(ds.getInputStream()); } @@ -389,7 +389,7 @@ public InternetHeaders parseHeaders(DataSource ds) { * the ds * @return the input stream */ - public InputStream parseEntity(DataSource ds) { + private InputStream parseEntity(DataSource ds) { try { return ds.getInputStream(); } @@ -407,7 +407,7 @@ public InputStream parseEntity(DataSource ds) { * the content type * @return the list */ - public List<DataSource> parseParts(final InputStream entityInputStream, final String contentType) { + private List<DataSource> parseParts(final InputStream entityInputStream, final String contentType) { try { return parsePartsCore(entityInputStream, contentType); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index 12a7ab6afa5a0..d3244af70517d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -1,18 +1,17 @@ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -27,16 +26,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom entry construct is defined in section 4.1.2 of the format spec. + * The Atom entry construct is defined in section 4.1.2 of the format spec. + * * + * <p>Java class for entryType complex type. * - * <p> - * Java class for entryType complex type. - * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="entryType"> @@ -67,22 +65,25 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "entryType", propOrder = { "entryChildren" }) +@XmlType(name = "entryType", propOrder = { + "entryChildren" +}) public class EntryType { @XmlElementRefs({ - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) @XmlAnyElement(lax = true) protected List<Object> entryChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -93,32 +94,39 @@ public class EntryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the entryChildren property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the entryChildren property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the entryChildren property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getEntryChildren().add(newItem); + * getEntryChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link ContentType }{@code >} {@link Object } + * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link ContentType }{@code >} + * {@link Object } * * */ @@ -133,8 +141,9 @@ public List<Object> getEntryChildren() { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -144,8 +153,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -155,8 +165,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -166,8 +177,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -177,14 +189,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index 1d8931c5dd676..fcc3a6dd43871 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -51,7 +51,7 @@ public String getVerb() { } @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addContentObject(Object contentObject) { + public EntityBatchOperation addContentObject(Object contentObject) { ContentType atomContent = new ContentType(); atomContent.setType("application/xml"); atomContent.getContent().add( @@ -60,10 +60,11 @@ public void addContentObject(Object contentObject) { this.entryType.getEntryChildren().add( new JAXBElement(new QName(Constants.ATOM_NS, "content"), ContentType.class, atomContent)); + return this; } @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void addLink(String title, String href, String type, String rel) { + protected EntityBatchOperation addLink(String title, String href, String type, String rel) { LinkType linkType = new LinkType(); linkType.setTitle(title); linkType.setHref(href); @@ -71,6 +72,7 @@ protected void addLink(String title, String href, String type, String rel) { linkType.setRel(rel); this.entryType.getEntryChildren().add( new JAXBElement(new QName(Constants.ATOM_NS, "link"), LinkType.class, linkType)); + return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 290e0f7af6442..6a6993f8dd02a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -34,7 +34,7 @@ public interface EntityOperation { * @return The MIME type * @throws ServiceException */ - public abstract MediaType getContentType() throws ServiceException; + public abstract MediaType getContentType(); /** * Get the MIME type that we're expecting the server to send back. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index 2c9944d23f861..bca283be61829 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -21,8 +21,6 @@ import javax.ws.rs.core.MediaType; -import com.microsoft.windowsazure.services.core.ServiceException; - /** * Default implementation of EntityOperation<T> to provide * default values for common methods. @@ -59,7 +57,7 @@ public String getUri() { * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getContentType() */ @Override - public MediaType getContentType() throws ServiceException { + public MediaType getContentType() { return MediaType.APPLICATION_ATOM_XML_TYPE; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 2ce4b9a72edbf..9bc5d0519cd80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -342,7 +342,7 @@ public Creator setServiceUri(URI serviceUri) { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getContentType() */ @Override - public MediaType getContentType() throws ServiceException { + public MediaType getContentType() { if (fresh) { buildMimeMultipart(); } From d35b12bf1f6f94f8e715dd8649b0af6650b137b6 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 20 Nov 2012 11:43:44 -0800 Subject: [PATCH 492/664] initial check in for content key. --- .../content/ContentKeyRestType.java | 257 ++++++++++++++++++ .../services/media/models/ContentKey.java | 146 ++++++++++ .../services/media/models/ContentKeyInfo.java | 124 ++++----- .../services/media/models/ContentKeyType.java | 23 ++ .../media/models/ProtectionKeyType.java | 19 ++ .../media/ContentKeyIntegrationTest.java | 212 +++++++++++++++ 6 files changed, 712 insertions(+), 69 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java new file mode 100644 index 0000000000000..08c1470690716 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -0,0 +1,257 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +// TODO: Auto-generated Javadoc +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ContentKeyRestType implements MediaServiceDTO { + + /** The id. */ + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + /** The created. */ + @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + protected Date created; + + /** The last modified. */ + @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + protected Date lastModified; + + /** The content key type. */ + @XmlElement(name = "ContentKeyType", namespace = Constants.ODATA_DATA_NS) + protected Integer contentKeyType; + + /** The encrypted content key. */ + @XmlElement(name = "EncryptedContentKey", namespace = Constants.ODATA_DATA_NS) + protected String encryptedContentKey; + + /** The name. */ + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + /** The protection key id. */ + @XmlElement(name = "ProtectionKeyId", namespace = Constants.ODATA_DATA_NS) + protected String protectionKeyId; + + /** The protection key type. */ + @XmlElement(name = "ProtectionKeyType", namespace = Constants.ODATA_DATA_NS) + private Integer protectionKeyType; + + /** The checksum. */ + @XmlElement(name = "Checksum", namespace = Constants.ODATA_DATA_NS) + protected String checksum; + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id + * the id to set + * @return the content key rest type + */ + public ContentKeyRestType setId(String id) { + this.id = id; + return this; + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * Sets the created. + * + * @param created + * the created to set + * @return the content key rest type + */ + public ContentKeyRestType setCreated(Date created) { + this.created = created; + return this; + } + + /** + * Gets the last modified. + * + * @return the lastModified + */ + public Date getLastModified() { + return lastModified; + } + + /** + * Sets the last modified. + * + * @param lastModified + * the lastModified to set + * @return the content key rest type + */ + public ContentKeyRestType setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * Gets the content key type. + * + * @return the content key type + */ + public Integer getContentKeyType() { + return contentKeyType; + } + + /** + * Sets the content key type. + * + * @param contentKeyType + * the new content key type + * @return the content key rest type + */ + public ContentKeyRestType setContentKeyType(Integer contentKeyType) { + this.contentKeyType = contentKeyType; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name + * the name to set + * @return the content key rest type + */ + public ContentKeyRestType setName(String name) { + this.name = name; + return this; + } + + /** + * Sets the checksum. + * + * @param checksum + * the new checksum + * @return the content key rest type + */ + public ContentKeyRestType setChecksum(String checksum) { + this.checksum = checksum; + return this; + } + + /** + * Gets the checksum. + * + * @return the checksum + */ + public String getChecksum() { + return this.checksum; + } + + /** + * Sets the protection key type. + * + * @param protectionKeyType + * the new protection key type + * @return the content key rest type + */ + public ContentKeyRestType setProtectionKeyType(Integer protectionKeyType) { + this.protectionKeyType = protectionKeyType; + return this; + } + + /** + * Gets the protection key type. + * + * @return the protection key type + */ + public Integer getProtectionKeyType() { + return this.protectionKeyType; + } + + /** + * Sets the protection key id. + * + * @param protectionKeyId + * the new protection key id + * @return the content key rest type + */ + public ContentKeyRestType setProtectionKeyId(String protectionKeyId) { + this.protectionKeyId = protectionKeyId; + return this; + } + + /** + * Gets the protection key id. + * + * @return the protection key id + */ + public String getProtectionKeyId() { + return this.protectionKeyId; + } + + /** + * Sets the encrypted content key. + * + * @param encryptedContentKey + * the encrypted content key + * @return the content key rest type + */ + public ContentKeyRestType setEncryptedContentKey(String encryptedContentKey) { + this.encryptedContentKey = encryptedContentKey; + return this; + } + + /** + * Gets the encrypted content key. + * + * @return the encrypted content key + */ + public String getEncryptedContentKey() { + return this.encryptedContentKey; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java new file mode 100644 index 0000000000000..ecfc4b696cf92 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -0,0 +1,146 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.sun.jersey.api.client.GenericType; + +/** + * Class for creating operations to manipulate Access Policy entities. + * + */ +public class ContentKey { + + private static final String ENTITY_SET = "AccessPolicies"; + + private ContentKey() { + } + + /** + * Creates an operation to create a new access policy + * + * @param name + * name of the access policy + * @param durationInMinutes + * how long the access policy will be in force + * @param permissions + * permissions allowed by this access policy + * @return The operation + */ + public static EntityCreationOperation<ContentKeyInfo> create(String id, ContentKeyType contentKeyType, + String encryptedContentKey) { + return new Creator(id, contentKeyType, encryptedContentKey); + } + + private static class Creator extends EntityOperationSingleResultBase<ContentKeyInfo> implements + EntityCreationOperation<ContentKeyInfo> { + private final String id; + private ContentKeyType contentKeyType; + private final String encryptedContentKey; + private String name; + private String checksum; + + public Creator(String id, ContentKeyType contentKeyType, String encryptedContentKey) { + + super(ENTITY_SET, ContentKeyInfo.class); + + this.id = id; + this.contentKeyType = contentKeyType; + this.encryptedContentKey = encryptedContentKey; + } + + @Override + public Object getRequestContents() { + ContentKeyRestType contentKeyRestType = new ContentKeyRestType(); + contentKeyRestType.setId(id); + if (contentKeyType != null) { + contentKeyRestType.setContentKeyType(contentKeyType.getCode()); + } + contentKeyRestType.setEncryptedContentKey(encryptedContentKey); + contentKeyRestType.setName(name); + contentKeyRestType.setChecksum(checksum); + return contentKeyRestType; + } + + public ContentKeyType getContentKeyType() { + return contentKeyType; + } + + public EntityOperationSingleResultBase<ContentKeyInfo> setContentKeyType(ContentKeyType contentKeyType) { + this.contentKeyType = contentKeyType; + return this; + } + + public String getEncryptedContentKey() { + return encryptedContentKey; + } + + } + + /** + * Create an operation that will retrieve the given access policy + * + * @param ContentKeyId + * id of access policy to retrieve + * @return the operation + */ + public static EntityGetOperation<ContentKeyInfo> get(String ContentKeyId) { + return new DefaultGetOperation<ContentKeyInfo>(ENTITY_SET, ContentKeyId, ContentKeyInfo.class); + } + + /** + * Create an operation that will retrieve all access policies + * + * @return the operation + */ + public static EntityListOperation<ContentKeyInfo> list() { + return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() { + }); + } + + /** + * Create an operation that will retrieve all access policies that match the given query parameters + * + * @param queryParameters + * query parameters to add to the request + * @return the operation + */ + public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) { + return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() { + }, queryParameters); + } + + /** + * Create an operation to delete the given access policy + * + * @param ContentKeyId + * id of access policy to delete + * @return the delete operation + */ + public static EntityDeleteOperation delete(String ContentKeyId) { + return new DefaultDeleteOperation(ENTITY_SET, ContentKeyId); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 3fbf2e76c1579..1c59a4116cf62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -17,37 +17,26 @@ import java.util.Date; +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; + /** * The Class ContentKeyInfo. */ -public class ContentKeyInfo { - - /** The id. */ - private String id; - - /** The created. */ - private Date created; - - /** The last modified. */ - private Date lastModified; - - /** The content key type. */ - private ContentKeyType contentKeyType; - - /** The encrypted content key. */ - private String encryptedContentKey; +public class ContentKeyInfo extends ODataEntity<ContentKeyRestType> { - /** The name. */ - private String name; - - /** The protection key id. */ - private String protectionKeyId; - - /** The check sum. */ - private String checkSum; - - /** The protection key type. */ - private ProtectionKeyType protectionKeyType; + /** + * Instantiates a new content key info. + * + * @param entry + * the entry + * @param content + * the content + */ + public ContentKeyInfo(EntryType entry, ContentKeyRestType content) { + super(entry, content); + } /** * Gets the id. @@ -55,7 +44,7 @@ public class ContentKeyInfo { * @return the id */ public String getId() { - return this.id; + return getContent().getId(); } /** @@ -66,7 +55,7 @@ public String getId() { * @return the content key info */ public ContentKeyInfo setId(String id) { - this.id = id; + getContent().setId(id); return this; } @@ -77,18 +66,27 @@ public ContentKeyInfo setId(String id) { * the created * @return the content key info */ - public ContentKeyInfo setCreate(Date created) { - this.created = created; + public ContentKeyInfo setCreated(Date created) { + getContent().setCreated(created); return this; } + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return getContent().getCreated(); + } + /** * Gets the last modified. * * @return the last modified */ public Date getLastModified() { - return this.lastModified; + return getContent().getLastModified(); } /** @@ -99,7 +97,7 @@ public Date getLastModified() { * @return the content key info */ public ContentKeyInfo setLastModified(Date lastModified) { - this.lastModified = lastModified; + getContent().setLastModified(lastModified); return this; } @@ -109,7 +107,7 @@ public ContentKeyInfo setLastModified(Date lastModified) { * @return the name */ public String getName() { - return this.name; + return getContent().getName(); } /** @@ -120,19 +118,19 @@ public String getName() { * @return the content key info */ public ContentKeyInfo setName(String name) { - this.name = name; + getContent().setName(name); return this; } /** * Sets the check sum. * - * @param checkSum + * @param checksum * the check sum * @return the content key info */ - public ContentKeyInfo setCheckSum(String checkSum) { - this.checkSum = checkSum; + public ContentKeyInfo setChecksum(String checksum) { + getContent().setChecksum(checksum); return this; } @@ -142,7 +140,7 @@ public ContentKeyInfo setCheckSum(String checkSum) { * @return the check sum */ public String getCheckSum() { - return this.checkSum; + return getContent().getChecksum(); } /** @@ -153,7 +151,7 @@ public String getCheckSum() { * @return the content key info */ public ContentKeyInfo setProtectionKeyType(ProtectionKeyType protectionKeyType) { - this.protectionKeyType = protectionKeyType; + getContent().setProtectionKeyType(protectionKeyType.getCode()); return this; } @@ -163,7 +161,7 @@ public ContentKeyInfo setProtectionKeyType(ProtectionKeyType protectionKeyType) * @return the protection key type */ public ProtectionKeyType getProtectionKeyType() { - return this.protectionKeyType; + return ProtectionKeyType.fromCode(getContent().getProtectionKeyType()); } /** @@ -174,7 +172,7 @@ public ProtectionKeyType getProtectionKeyType() { * @return the content key info */ public ContentKeyInfo setProtectionKeyId(String protectionKeyId) { - this.protectionKeyId = protectionKeyId; + getContent().setProtectionKeyId(protectionKeyId); return this; } @@ -184,7 +182,7 @@ public ContentKeyInfo setProtectionKeyId(String protectionKeyId) { * @return the protection key id */ public String getProtectionKeyId() { - return this.protectionKeyId; + return getContent().getProtectionKeyId(); } /** @@ -195,7 +193,7 @@ public String getProtectionKeyId() { * @return the content key info */ public ContentKeyInfo setEncryptedContentKey(String encryptedContentKey) { - this.encryptedContentKey = encryptedContentKey; + getContent().setEncryptedContentKey(encryptedContentKey); return this; } @@ -205,7 +203,7 @@ public ContentKeyInfo setEncryptedContentKey(String encryptedContentKey) { * @return the encrypted content key */ public String getEncryptedContentKey() { - return this.encryptedContentKey; + return getContent().getEncryptedContentKey(); } /** @@ -216,7 +214,12 @@ public String getEncryptedContentKey() { * @return the content key info */ public ContentKeyInfo setContentKeyType(ContentKeyType contentKeyType) { - this.contentKeyType = contentKeyType; + if (contentKeyType == null) { + getContent().setContentKeyType(null); + } + else { + getContent().setContentKeyType(contentKeyType.getCode()); + } return this; } @@ -226,28 +229,11 @@ public ContentKeyInfo setContentKeyType(ContentKeyType contentKeyType) { * @return the content key type */ public ContentKeyType getContentKeyType() { - return this.contentKeyType; - } - - /** - * Sets the created. - * - * @param created - * the created - * @return the content key info - */ - public ContentKeyInfo setCreated(Date created) { - this.created = created; - return this; - } - - /** - * Gets the created. - * - * @return the created - */ - public Date getCreated() { - return this.created; + Integer contentKeyTypeInteger = getContent().getContentKeyType(); + ContentKeyType contentKeyType = null; + if (contentKeyTypeInteger != null) { + contentKeyType = ContentKeyType.fromCode(contentKeyTypeInteger); + } + return contentKeyType; } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java index 5bfaf65f9030e..d1798b3ff7183 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -15,6 +15,9 @@ package com.microsoft.windowsazure.services.media.models; +import java.security.InvalidParameterException; + +// TODO: Auto-generated Javadoc /** * * Specifies the type of a content key. @@ -50,4 +53,24 @@ private ContentKeyType(int contentKeyTypeCode) { public int getCode() { return contentKeyTypeCode; } + + /** + * From code. + * + * @param code + * the code + * @return the content key type + */ + public static ContentKeyType fromCode(int code) { + switch (code) { + case 0: + return ContentKeyType.CommonEncryption; + case 1: + return ContentKeyType.StorageEncryption; + case 2: + return ContentKeyType.ConfigurationEncryption; + default: + throw new InvalidParameterException("code"); + } + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java index e0ddb7911c4d2..a3c7f714eb4b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.models; +import java.security.InvalidParameterException; + /** * The Enum ProtectionKeyType. */ @@ -44,4 +46,21 @@ private ProtectionKeyType(int protectionKeyTypeCode) { public int getCode() { return protectionKeyTypeCode; } + + /** + * Create an ProtectionKeyType instance from the corresponding int. + * + * @param protectionKeyTypeCode + * protectionKeyTypeCode as integer + * @return new ProtectionKeyType instance + */ + public static ProtectionKeyType fromCode(int protectionKeyTypeCode) { + switch (protectionKeyTypeCode) { + case 0: + return ProtectionKeyType.X509CertificateThumbprint; + default: + throw new InvalidParameterException("state"); + } + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java new file mode 100644 index 0000000000000..785835e255a31 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -0,0 +1,212 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; +import com.microsoft.windowsazure.services.core.RetryPolicyFilter; +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.ContentKey; +import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class ContentKeyIntegrationTest extends IntegrationTestBase { + private void verifyInfosEqual(String message, ContentKeyInfo expected, ContentKeyInfo actual) { + verifyPolicyProperties(message, expected.getName(), expected.getDurationInMinutes(), expected.getPermissions(), + actual); + } + + private void verifyPolicyProperties(String message, String testName, double duration, + ContentKeyPermission permission, ContentKeyInfo policy) { + verifyPolicyProperties(message, testName, duration, EnumSet.of(permission), policy); + } + + private void verifyPolicyProperties(String message, String testName, double duration, + EnumSet<ContentKeyPermission> permissions, ContentKeyInfo policy) { + assertNotNull(message, policy); + assertEquals(message + " Name", testName, policy.getName()); + assertEquals(message + " DurationInMinutes", duration, policy.getDurationInMinutes(), 0.00001); + for (ContentKeyPermission permission : permissions) { + if (permission != ContentKeyPermission.NONE) { + assertTrue(message + "permissions should contain " + permission, + policy.getPermissions().contains(permission)); + } + } + assertEquals(message + " Permissions", permissions, policy.getPermissions()); + + assertNotNull(message + " Id", policy.getId()); + assertNotNull(message + " Created", policy.getCreated()); + assertNotNull(message + " LastModified", policy.getLastModified()); + assertEquals(message + " Created & LastModified", policy.getCreated(), policy.getLastModified()); + } + + @Test + public void canCreateContentKey() throws Exception { + String testName = testPolicyPrefix + "CanCreate"; + double duration = 5; + + ContentKeyInfo policy = service.create(ContentKey.create(testName, duration, + EnumSet.of(ContentKeyPermission.WRITE))); + + verifyPolicyProperties("policy", testName, duration, ContentKeyPermission.WRITE, policy); + } + + @Test + public void canCreateContentKeyWithReadPermissions() throws Exception { + String testName = testPolicyPrefix + "CanCreateRead"; + double duration = 5; + + ContentKeyInfo policy = service.create(ContentKey.create(testName, duration, + EnumSet.of(ContentKeyPermission.READ))); + + verifyPolicyProperties("policy", testName, duration, ContentKeyPermission.READ, policy); + } + + // TODO: Null name or duration? + + @Test + public void canGetSinglePolicyById() throws Exception { + String expectedName = testPolicyPrefix + "GetOne"; + double duration = 1; + ContentKeyInfo policyToGet = service.create(ContentKey.create(expectedName, duration, + EnumSet.of(ContentKeyPermission.WRITE))); + + ContentKeyInfo retrievedPolicy = service.get(ContentKey.get(policyToGet.getId())); + + assertEquals(policyToGet.getId(), retrievedPolicy.getId()); + verifyPolicyProperties("retrievedPolicy", expectedName, duration, ContentKeyPermission.WRITE, retrievedPolicy); + } + + @Test + public void canGetSinglePolicyByInvalidId() throws Exception { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.get(ContentKey.get(invalidId)); + } + + @Test + public void canGetSinglePolicyByNonexistId() throws Exception { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.get(ContentKey.get(validButNonexistContentKeyId)); + } + + @Test + public void canRetrieveListOfAccessPolicies() throws Exception { + String[] policyNames = new String[] { testPolicyPrefix + "ListOne", testPolicyPrefix + "ListTwo" }; + double duration = 3; + EnumSet<ContentKeyPermission> permissions = EnumSet.of(ContentKeyPermission.WRITE, ContentKeyPermission.LIST); + + List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); + for (int i = 0; i < policyNames.length; i++) { + ContentKeyInfo policy = service.create(ContentKey.create(policyNames[i], duration, permissions)); + expectedAccessPolicies.add(policy); + } + + List<ContentKeyInfo> actualAccessPolicies = service.list(ContentKey.list()); + + verifyListResultContains("listAccessPolicies", expectedAccessPolicies, actualAccessPolicies, + new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyInfosEqual(message, (ContentKeyInfo) expected, (ContentKeyInfo) actual); + } + }); + } + + @Test + public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { + String[] policyNames = new String[] { testPolicyPrefix + "ListThree", testPolicyPrefix + "ListFour", + testPolicyPrefix + "ListFive", testPolicyPrefix + "ListSix", testPolicyPrefix + "ListSeven" }; + + double duration = 3; + EnumSet<ContentKeyPermission> permissions = EnumSet.of(ContentKeyPermission.WRITE, ContentKeyPermission.LIST); + + List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); + for (int i = 0; i < policyNames.length; i++) { + ContentKeyInfo policy = service.create(ContentKey.create(policyNames[i], duration, permissions)); + expectedAccessPolicies.add(policy); + } + + MultivaluedMap<String, String> options = new MultivaluedMapImpl(); + options.add("$top", "2"); + + List<ContentKeyInfo> actualAccessPolicies = service.list(ContentKey.list(options)); + + assertEquals(2, actualAccessPolicies.size()); + } + + // Note: Access Policy cannot be updated. + + @Test + public void canDeleteContentKeyById() throws Exception { + String policyName = testPolicyPrefix + "ToDelete"; + double duration = 1; + ContentKeyInfo policyToDelete = service.create(ContentKey.create(policyName, duration, + EnumSet.of(ContentKeyPermission.WRITE))); + List<ContentKeyInfo> listPoliciesResult = service.list(ContentKey.list()); + int policyCountBaseline = listPoliciesResult.size(); + + service.delete(ContentKey.delete(policyToDelete.getId())); + + listPoliciesResult = service.list(ContentKey.list()); + assertEquals("listPoliciesResult.size", policyCountBaseline - 1, listPoliciesResult.size()); + + for (ContentKeyInfo policy : service.list(ContentKey.list())) { + assertFalse(policyToDelete.getId().equals(policy.getId())); + } + + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.get(ContentKey.get(policyToDelete.getId())); + } + + @Test + public void canDeleteContentKeyByInvalidId() throws Exception { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(500)); + service.delete(ContentKey.delete(invalidId)); + } + + @Test + public void canDeleteContentKeyByNonexistId() throws Exception { + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.delete(ContentKey.delete(validButNonexistContentKeyId)); + } + + @Test + public void canRetryContentKeyCreation() throws Exception { + String name = testPolicyPrefix + "canRetryContentKeyCreationPolicy"; + double duration = 1; + EnumSet<ContentKeyPermission> write = EnumSet.of(ContentKeyPermission.WRITE); + service.create(ContentKey.create(name + "1", duration, write)); + + ExponentialRetryPolicy forceRetryPolicy = new ExponentialRetryPolicy(1, 1, new int[] { 201 }); + MediaContract forceRetryService = service.withFilter(new RetryPolicyFilter(forceRetryPolicy)); + + forceRetryService.create(ContentKey.create(name + "2", duration, write)); + } +} From c6424bd5983d07e80b20d5f9b3c931bc8a984476 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 20 Nov 2012 11:53:45 -0800 Subject: [PATCH 493/664] all ContentKeyInfoTest passes. --- .../services/media/models/ContentKeyInfo.java | 8 ++++++++ .../services/media/models/ContentKeyInfoTest.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 1c59a4116cf62..21eba3aa39244 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -21,6 +21,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; +// TODO: Auto-generated Javadoc /** * The Class ContentKeyInfo. */ @@ -38,6 +39,13 @@ public ContentKeyInfo(EntryType entry, ContentKeyRestType content) { super(entry, content); } + /** + * Instantiates a new content key info. + */ + public ContentKeyInfo() { + super(new ContentKeyRestType()); + } + /** * Gets the id. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index eddd15aad4e1f..6c1bf339642b9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -138,7 +138,7 @@ public void testGetSetCheckSum() { ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualCheckSum = contentKeyInfo.setCheckSum(expectedCheckSum).getCheckSum(); + String actualCheckSum = contentKeyInfo.setChecksum(expectedCheckSum).getCheckSum(); // Assert assertEquals(expectedCheckSum, actualCheckSum); From e128738d71039822cda97a316e7876748e4bac42 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 20 Nov 2012 18:51:32 -0800 Subject: [PATCH 494/664] All the content key integration tests can run. --- .../services/media/models/ContentKey.java | 158 ++++++++++++++-- .../services/media/models/ContentKeyInfo.java | 2 +- .../media/ContentKeyIntegrationTest.java | 170 +++++++----------- .../services/media/IntegrationTestBase.java | 1 + .../media/models/ContentKeyInfoTest.java | 2 +- 5 files changed, 210 insertions(+), 123 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index ecfc4b696cf92..e4004644ba07c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -29,40 +29,66 @@ import com.sun.jersey.api.client.GenericType; /** - * Class for creating operations to manipulate Access Policy entities. + * Class for creating operations to manipulate content key entities. * */ public class ContentKey { + /** The Constant ENTITY_SET. */ private static final String ENTITY_SET = "AccessPolicies"; + /** + * Instantiates a new content key. + */ private ContentKey() { } /** - * Creates an operation to create a new access policy + * Creates an operation to create a new content key. * - * @param name - * name of the access policy - * @param durationInMinutes - * how long the access policy will be in force - * @param permissions - * permissions allowed by this access policy + * @param id + * the id + * @param contentKeyType + * the content key type + * @param encryptedContentKey + * the encrypted content key * @return The operation */ - public static EntityCreationOperation<ContentKeyInfo> create(String id, ContentKeyType contentKeyType, - String encryptedContentKey) { + public static Creator create(String id, ContentKeyType contentKeyType, String encryptedContentKey) { return new Creator(id, contentKeyType, encryptedContentKey); } + /** + * The Class Creator. + */ private static class Creator extends EntityOperationSingleResultBase<ContentKeyInfo> implements EntityCreationOperation<ContentKeyInfo> { - private final String id; + + /** The id. */ + private String id; + + /** The content key type. */ private ContentKeyType contentKeyType; - private final String encryptedContentKey; + + /** The encrypted content key. */ + private String encryptedContentKey; + + /** The name. */ private String name; + + /** The checksum. */ private String checksum; + /** + * Instantiates a new creator. + * + * @param id + * the id + * @param contentKeyType + * the content key type + * @param encryptedContentKey + * the encrypted content key + */ public Creator(String id, ContentKeyType contentKeyType, String encryptedContentKey) { super(ENTITY_SET, ContentKeyInfo.class); @@ -72,6 +98,9 @@ public Creator(String id, ContentKeyType contentKeyType, String encryptedContent this.encryptedContentKey = encryptedContentKey; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + */ @Override public Object getRequestContents() { ContentKeyRestType contentKeyRestType = new ContentKeyRestType(); @@ -85,26 +114,117 @@ public Object getRequestContents() { return contentKeyRestType; } + /** + * Gets the content key type. + * + * @return the content key type + */ public ContentKeyType getContentKeyType() { return contentKeyType; } - public EntityOperationSingleResultBase<ContentKeyInfo> setContentKeyType(ContentKeyType contentKeyType) { + /** + * Sets the content key type. + * + * @param contentKeyType + * the content key type + * @return the creator + */ + public Creator setContentKeyType(ContentKeyType contentKeyType) { this.contentKeyType = contentKeyType; return this; } + /** + * Gets the encrypted content key. + * + * @return the encrypted content key + */ public String getEncryptedContentKey() { return encryptedContentKey; } + /** + * Sets the encrypted content key. + * + * @param encryptedContentKey + * the encrypted content key + * @return the creator + */ + public Creator setEncryptedContentKey(String encryptedContentKey) { + this.encryptedContentKey = encryptedContentKey; + return this; + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id + * the id + * @return the creator + */ + public Creator setId(String id) { + this.id = id; + return this; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name + * the name + * @return the creator + */ + public Creator setName(String name) { + this.name = name; + return this; + } + + /** + * Gets the checksum. + * + * @return the checksum + */ + public String getChecksum() { + return checksum; + } + + /** + * Sets the checksum. + * + * @param checksum + * the checksum + * @return the creator + */ + public Creator setChecksum(String checksum) { + this.checksum = checksum; + return this; + } } /** - * Create an operation that will retrieve the given access policy + * Create an operation that will retrieve the given content key. * * @param ContentKeyId - * id of access policy to retrieve + * id of content key to retrieve * @return the operation */ public static EntityGetOperation<ContentKeyInfo> get(String ContentKeyId) { @@ -112,7 +232,7 @@ public static EntityGetOperation<ContentKeyInfo> get(String ContentKeyId) { } /** - * Create an operation that will retrieve all access policies + * Create an operation that will retrieve all access policies. * * @return the operation */ @@ -122,7 +242,7 @@ public static EntityListOperation<ContentKeyInfo> list() { } /** - * Create an operation that will retrieve all access policies that match the given query parameters + * Create an operation that will retrieve all access policies that match the given query parameters. * * @param queryParameters * query parameters to add to the request @@ -134,10 +254,10 @@ public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, St } /** - * Create an operation to delete the given access policy + * Create an operation to delete the given content key. * * @param ContentKeyId - * id of access policy to delete + * id of content key to delete * @return the delete operation */ public static EntityDeleteOperation delete(String ContentKeyId) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 21eba3aa39244..85b4eca7176f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -147,7 +147,7 @@ public ContentKeyInfo setChecksum(String checksum) { * * @return the check sum */ - public String getCheckSum() { + public String getChecksum() { return getContent().getChecksum(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 785835e255a31..ed8482e639c1b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -18,111 +18,92 @@ import static org.junit.Assert.*; import java.util.ArrayList; -import java.util.EnumSet; import java.util.List; import javax.ws.rs.core.MultivaluedMap; import org.junit.Test; -import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; -import com.microsoft.windowsazure.services.core.RetryPolicyFilter; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; +import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.ProtectionKeyType; import com.sun.jersey.core.util.MultivaluedMapImpl; public class ContentKeyIntegrationTest extends IntegrationTestBase { - private void verifyInfosEqual(String message, ContentKeyInfo expected, ContentKeyInfo actual) { - verifyPolicyProperties(message, expected.getName(), expected.getDurationInMinutes(), expected.getPermissions(), - actual); - } - private void verifyPolicyProperties(String message, String testName, double duration, - ContentKeyPermission permission, ContentKeyInfo policy) { - verifyPolicyProperties(message, testName, duration, EnumSet.of(permission), policy); - } + private final String validButNonexistContentKeyId = "nb:kid:80dfe751-e5a1-4b29-a992-4a75276473af"; + private final String testName = testContentKeyPrefix + "CanCreate"; + private final String testContentKeyId = "nb:kid:80dfe751-e5a1-4b29-a992-4a75276473ae"; + private final ContentKeyType testContentKeyType = ContentKeyType.ConfigurationEncryption; + private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; - private void verifyPolicyProperties(String message, String testName, double duration, - EnumSet<ContentKeyPermission> permissions, ContentKeyInfo policy) { - assertNotNull(message, policy); - assertEquals(message + " Name", testName, policy.getName()); - assertEquals(message + " DurationInMinutes", duration, policy.getDurationInMinutes(), 0.00001); - for (ContentKeyPermission permission : permissions) { - if (permission != ContentKeyPermission.NONE) { - assertTrue(message + "permissions should contain " + permission, - policy.getPermissions().contains(permission)); - } - } - assertEquals(message + " Permissions", permissions, policy.getPermissions()); - - assertNotNull(message + " Id", policy.getId()); - assertNotNull(message + " Created", policy.getCreated()); - assertNotNull(message + " LastModified", policy.getLastModified()); - assertEquals(message + " Created & LastModified", policy.getCreated(), policy.getLastModified()); + private void verifyInfosEqual(String message, ContentKeyInfo expected, ContentKeyInfo actual) { + verifyContentKeyProperties(message, expected.getId(), expected.getContentKeyType(), + expected.getEncryptedContentKey(), expected.getName(), expected.getProtectionKeyId(), + expected.getProtectionKeyType(), expected.getChecksum(), actual); } - @Test - public void canCreateContentKey() throws Exception { - String testName = testPolicyPrefix + "CanCreate"; - double duration = 5; - - ContentKeyInfo policy = service.create(ContentKey.create(testName, duration, - EnumSet.of(ContentKeyPermission.WRITE))); - - verifyPolicyProperties("policy", testName, duration, ContentKeyPermission.WRITE, policy); + private void verifyContentKeyProperties(String message, String id, ContentKeyType contentKeyType, + String encryptedContentKey, String name, String protectionKeyId, ProtectionKeyType protectionKeyType, + String checksum, ContentKeyInfo actual) { + assertNotNull(message, actual); + assertEquals(message + " Id", id, actual.getId()); + assertEquals(message + " ContentKeyType", contentKeyType, actual.getContentKeyType()); + assertEquals(message + " EncryptedContentKey", encryptedContentKey, actual.getEncryptedContentKey()); + assertEquals(message + " Name", name, actual.getName()); + assertEquals(message + " ProtectionKeyId", actual.getProtectionKeyId()); + assertEquals(message + " ProtectionKeyType", actual.getProtectionKeyType()); + assertEquals(message + " Checksum", actual.getChecksum()); } @Test - public void canCreateContentKeyWithReadPermissions() throws Exception { - String testName = testPolicyPrefix + "CanCreateRead"; - double duration = 5; + public void canCreateContentKey() throws Exception { + // Arrange - ContentKeyInfo policy = service.create(ContentKey.create(testName, duration, - EnumSet.of(ContentKeyPermission.READ))); + // Act + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey)); - verifyPolicyProperties("policy", testName, duration, ContentKeyPermission.READ, policy); + // Assert + verifyContentKeyProperties("ContentKey", testContentKeyId, testContentKeyType, testEncryptedContentKey, + testName, null, null, "", contentKeyInfo); } - // TODO: Null name or duration? - @Test - public void canGetSinglePolicyById() throws Exception { - String expectedName = testPolicyPrefix + "GetOne"; - double duration = 1; - ContentKeyInfo policyToGet = service.create(ContentKey.create(expectedName, duration, - EnumSet.of(ContentKeyPermission.WRITE))); - - ContentKeyInfo retrievedPolicy = service.get(ContentKey.get(policyToGet.getId())); - - assertEquals(policyToGet.getId(), retrievedPolicy.getId()); - verifyPolicyProperties("retrievedPolicy", expectedName, duration, ContentKeyPermission.WRITE, retrievedPolicy); + public void canGetSingleContentKeyById() throws Exception { + // Arrange + String expectedName = testContentKeyPrefix + "GetOne"; + ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey)); + + // Act + ContentKeyInfo retrievedContentKeyInfo = service.get(ContentKey.get(ContentKeyToGet.getId())); + + // Assert + assertEquals(ContentKeyToGet.getId(), retrievedContentKeyInfo.getId()); + verifyContentKeyProperties("ContentKey", testContentKeyId, testContentKeyType, testEncryptedContentKey, + testName, null, null, "", retrievedContentKeyInfo); } @Test - public void canGetSinglePolicyByInvalidId() throws Exception { + public void cannotGetSingleContentKeyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); service.get(ContentKey.get(invalidId)); } @Test - public void canGetSinglePolicyByNonexistId() throws Exception { - expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); - service.get(ContentKey.get(validButNonexistContentKeyId)); - } - - @Test - public void canRetrieveListOfAccessPolicies() throws Exception { - String[] policyNames = new String[] { testPolicyPrefix + "ListOne", testPolicyPrefix + "ListTwo" }; + public void canRetrieveListOfContentKeys() throws Exception { + String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListOne", testContentKeyPrefix + "ListTwo" }; double duration = 3; - EnumSet<ContentKeyPermission> permissions = EnumSet.of(ContentKeyPermission.WRITE, ContentKeyPermission.LIST); List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); - for (int i = 0; i < policyNames.length; i++) { - ContentKeyInfo policy = service.create(ContentKey.create(policyNames[i], duration, permissions)); - expectedAccessPolicies.add(policy); + for (int i = 0; i < ContentKeyNames.length; i++) { + ContentKeyInfo contentKey = service.create(ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey)); + expectedAccessPolicies.add(contentKey); } List<ContentKeyInfo> actualAccessPolicies = service.list(ContentKey.list()); @@ -137,17 +118,16 @@ public void verifyEquals(String message, Object expected, Object actual) { } @Test - public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { - String[] policyNames = new String[] { testPolicyPrefix + "ListThree", testPolicyPrefix + "ListFour", - testPolicyPrefix + "ListFive", testPolicyPrefix + "ListSix", testPolicyPrefix + "ListSeven" }; - - double duration = 3; - EnumSet<ContentKeyPermission> permissions = EnumSet.of(ContentKeyPermission.WRITE, ContentKeyPermission.LIST); + public void canUseQueryParametersWhenListingContentKeys() throws Exception { + String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListThree", + testContentKeyPrefix + "ListFour", testContentKeyPrefix + "ListFive", testContentKeyPrefix + "ListSix", + testContentKeyPrefix + "ListSeven" }; List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); - for (int i = 0; i < policyNames.length; i++) { - ContentKeyInfo policy = service.create(ContentKey.create(policyNames[i], duration, permissions)); - expectedAccessPolicies.add(policy); + for (int i = 0; i < ContentKeyNames.length; i++) { + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey)); + expectedAccessPolicies.add(contentKeyInfo); } MultivaluedMap<String, String> options = new MultivaluedMapImpl(); @@ -158,33 +138,31 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { assertEquals(2, actualAccessPolicies.size()); } - // Note: Access Policy cannot be updated. - @Test public void canDeleteContentKeyById() throws Exception { - String policyName = testPolicyPrefix + "ToDelete"; + String ContentKeyName = testContentKeyPrefix + "ToDelete"; double duration = 1; - ContentKeyInfo policyToDelete = service.create(ContentKey.create(policyName, duration, - EnumSet.of(ContentKeyPermission.WRITE))); + ContentKeyInfo ContentKeyToDelete = service.create(ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey)); List<ContentKeyInfo> listPoliciesResult = service.list(ContentKey.list()); - int policyCountBaseline = listPoliciesResult.size(); + int ContentKeyCountBaseline = listPoliciesResult.size(); - service.delete(ContentKey.delete(policyToDelete.getId())); + service.delete(ContentKey.delete(ContentKeyToDelete.getId())); listPoliciesResult = service.list(ContentKey.list()); - assertEquals("listPoliciesResult.size", policyCountBaseline - 1, listPoliciesResult.size()); + assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listPoliciesResult.size()); - for (ContentKeyInfo policy : service.list(ContentKey.list())) { - assertFalse(policyToDelete.getId().equals(policy.getId())); + for (ContentKeyInfo contentKey : service.list(ContentKey.list())) { + assertFalse(ContentKeyToDelete.getId().equals(contentKey.getId())); } expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.get(ContentKey.get(policyToDelete.getId())); + service.get(ContentKey.get(ContentKeyToDelete.getId())); } @Test - public void canDeleteContentKeyByInvalidId() throws Exception { + public void cannotDeleteContentKeyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(500)); service.delete(ContentKey.delete(invalidId)); @@ -197,16 +175,4 @@ public void canDeleteContentKeyByNonexistId() throws Exception { service.delete(ContentKey.delete(validButNonexistContentKeyId)); } - @Test - public void canRetryContentKeyCreation() throws Exception { - String name = testPolicyPrefix + "canRetryContentKeyCreationPolicy"; - double duration = 1; - EnumSet<ContentKeyPermission> write = EnumSet.of(ContentKeyPermission.WRITE); - service.create(ContentKey.create(name + "1", duration, write)); - - ExponentialRetryPolicy forceRetryPolicy = new ExponentialRetryPolicy(1, 1, new int[] { 201 }); - MediaContract forceRetryService = service.withFilter(new RetryPolicyFilter(forceRetryPolicy)); - - forceRetryService.create(ContentKey.create(name + "2", duration, write)); - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 07ffd3010988d..3b9c3b8125c45 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -28,6 +28,7 @@ public abstract class IntegrationTestBase { protected static final String testAssetPrefix = "testAsset"; protected static final String testPolicyPrefix = "testPolicy"; + protected static final String testContentKeyPrefix = "testContentKey"; protected static final String validButNonexistAssetId = "nb:cid:UUID:0239f11f-2d36-4e5f-aa35-44d58ccc0973"; protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:38dcb3a0-ef64-4ad0-bbb5-67a14c6df2f7"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index 6c1bf339642b9..0e9a21e3cdc83 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -138,7 +138,7 @@ public void testGetSetCheckSum() { ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); // Act - String actualCheckSum = contentKeyInfo.setChecksum(expectedCheckSum).getCheckSum(); + String actualCheckSum = contentKeyInfo.setChecksum(expectedCheckSum).getChecksum(); // Assert assertEquals(expectedCheckSum, actualCheckSum); From 9c728cf8a063b551aaa53612f78808a219a63232 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 20 Nov 2012 18:57:16 -0800 Subject: [PATCH 495/664] three ContentKey Unit tests passes. --- .../services/media/implementation/ODataAtomMarshaller.java | 2 ++ .../windowsazure/services/media/models/ContentKey.java | 2 +- .../services/media/ContentKeyIntegrationTest.java | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 6bf10801b9e28..ecf5726e6e230 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -36,6 +36,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; @@ -129,6 +130,7 @@ private static Class<?>[] getMarshalledClasses() { classes.add(JobType.class); classes.add(LocatorRestType.class); classes.add(TaskType.class); + classes.add(ContentKeyRestType.class); return classes.toArray(new Class<?>[0]); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index e4004644ba07c..22f810762a6f8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -35,7 +35,7 @@ public class ContentKey { /** The Constant ENTITY_SET. */ - private static final String ENTITY_SET = "AccessPolicies"; + private static final String ENTITY_SET = "ContentKeys"; /** * Instantiates a new content key. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index ed8482e639c1b..b0d155121c330 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -90,7 +90,7 @@ public void canGetSingleContentKeyById() throws Exception { @Test public void cannotGetSingleContentKeyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.get(ContentKey.get(invalidId)); } @@ -164,14 +164,14 @@ public void canDeleteContentKeyById() throws Exception { @Test public void cannotDeleteContentKeyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.delete(ContentKey.delete(invalidId)); } @Test public void canDeleteContentKeyByNonexistId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.delete(ContentKey.delete(validButNonexistContentKeyId)); } From acf5f19cc09404569a4a8360d42ae85c418233d2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 21 Nov 2012 17:30:38 -0800 Subject: [PATCH 496/664] passing all the unit tests for content keys. --- .../implementation/content/ObjectFactory.java | 32 ++++-- .../services/media/models/ContentKey.java | 3 +- .../media/ContentKeyIntegrationTest.java | 101 ++++++++++-------- .../services/media/IntegrationTestBase.java | 16 +++ 4 files changed, 94 insertions(+), 58 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index b08fb967170e2..57234e67c5fbd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -17,6 +17,7 @@ import javax.xml.bind.annotation.XmlRegistry; +// TODO: Auto-generated Javadoc /** * Class used by JAXB to instantiate the types in this package. * @@ -33,7 +34,7 @@ public ObjectFactory() { } /** - * Create an instance of {@link AssetType } + * Create an instance of {@link AssetType }. * * @return a new AssetType instance. */ @@ -42,7 +43,7 @@ public AssetType createAssetType() { } /** - * Create an instance of {@link ODataActionType } + * Create an instance of {@link ODataActionType }. * * @return a new ODataActionType instance. */ @@ -51,7 +52,7 @@ public ODataActionType createODataActionType() { } /** - * Create an instance of {@link AccessPolicyType } + * Create an instance of {@link AccessPolicyType }. * * @return a new AccessPolicyType instance. */ @@ -60,8 +61,8 @@ public AccessPolicyType createAccessPolicyType() { } /** - * Create an instance of {@link LocatorRestType } - * + * Create an instance of {@link LocatorRestType }. + * * @return a new LocatorRestType instance. */ public LocatorRestType createLocatorRestType() { @@ -69,8 +70,8 @@ public LocatorRestType createLocatorRestType() { } /** - * Create an instance of {@link MediaProcessorType } - * + * Create an instance of {@link MediaProcessorType }. + * * @return a new MediaProcessorType instance. */ public MediaProcessorType createMediaProcessorType() { @@ -78,8 +79,8 @@ public MediaProcessorType createMediaProcessorType() { } /** - * Create an instance of {@link JobType} - * + * Create an instance of {@link JobType}. + * * @return a new JobType instance. */ public JobType createJobType() { @@ -87,11 +88,20 @@ public JobType createJobType() { } /** - * Create an instance of {@link TaskType} - * + * Create an instance of {@link TaskType}. + * * @return a new TaskType instance. */ public TaskType createTaskType() { return new TaskType(); } + + /** + * Creates a new Object object. + * + * @return the content key rest type + */ + public ContentKeyRestType createContentKeyRestType() { + return new ContentKeyRestType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 22f810762a6f8..6bcf84e5eefc5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -28,6 +28,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; +// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate content key entities. * @@ -61,7 +62,7 @@ public static Creator create(String id, ContentKeyType contentKeyType, String en /** * The Class Creator. */ - private static class Creator extends EntityOperationSingleResultBase<ContentKeyInfo> implements + public static class Creator extends EntityOperationSingleResultBase<ContentKeyInfo> implements EntityCreationOperation<ContentKeyInfo> { /** The id. */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index b0d155121c330..7dd023ace0168 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; import javax.ws.rs.core.MultivaluedMap; @@ -33,12 +34,18 @@ public class ContentKeyIntegrationTest extends IntegrationTestBase { - private final String validButNonexistContentKeyId = "nb:kid:80dfe751-e5a1-4b29-a992-4a75276473af"; + private final String validButNonexistContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473af"; private final String testName = testContentKeyPrefix + "CanCreate"; - private final String testContentKeyId = "nb:kid:80dfe751-e5a1-4b29-a992-4a75276473ae"; - private final ContentKeyType testContentKeyType = ContentKeyType.ConfigurationEncryption; + private final String testContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473ae"; + private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; + private String createRandomContentKeyId() { + UUID uuid = UUID.randomUUID(); + String randomContentKey = String.format("nb:kid:UUID:%s", uuid); + return randomContentKey; + } + private void verifyInfosEqual(String message, ContentKeyInfo expected, ContentKeyInfo actual) { verifyContentKeyProperties(message, expected.getId(), expected.getContentKeyType(), expected.getEncryptedContentKey(), expected.getName(), expected.getProtectionKeyId(), @@ -53,38 +60,42 @@ private void verifyContentKeyProperties(String message, String id, ContentKeyTyp assertEquals(message + " ContentKeyType", contentKeyType, actual.getContentKeyType()); assertEquals(message + " EncryptedContentKey", encryptedContentKey, actual.getEncryptedContentKey()); assertEquals(message + " Name", name, actual.getName()); - assertEquals(message + " ProtectionKeyId", actual.getProtectionKeyId()); - assertEquals(message + " ProtectionKeyType", actual.getProtectionKeyType()); - assertEquals(message + " Checksum", actual.getChecksum()); + assertEquals(message + " ProtectionKeyId", protectionKeyId, actual.getProtectionKeyId()); + assertEquals(message + " ProtectionKeyType", protectionKeyType, actual.getProtectionKeyType()); + assertEquals(message + " Checksum", checksum, actual.getChecksum()); } @Test public void canCreateContentKey() throws Exception { // Arrange + String testCanCreateContentKeyId = createRandomContentKeyId(); + String testCanCreateContentKeyName = "testCanCreateContentKey"; // Act - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testContentKeyId, testContentKeyType, - testEncryptedContentKey)); + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testCanCreateContentKeyId, testContentKeyType, + testEncryptedContentKey).setName(testCanCreateContentKeyName)); // Assert - verifyContentKeyProperties("ContentKey", testContentKeyId, testContentKeyType, testEncryptedContentKey, - testName, null, null, "", contentKeyInfo); + verifyContentKeyProperties("ContentKey", testCanCreateContentKeyId, testContentKeyType, + testEncryptedContentKey, testCanCreateContentKeyName, "", ProtectionKeyType.fromCode(0), "", + contentKeyInfo); } @Test public void canGetSingleContentKeyById() throws Exception { // Arrange String expectedName = testContentKeyPrefix + "GetOne"; - ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testContentKeyId, testContentKeyType, - testEncryptedContentKey)); + String testGetSingleContentKeyByIdId = createRandomContentKeyId(); + ContentKeyInfo ContentKeyToGet = service.create(ContentKey.create(testGetSingleContentKeyByIdId, + testContentKeyType, testEncryptedContentKey).setName(expectedName)); // Act ContentKeyInfo retrievedContentKeyInfo = service.get(ContentKey.get(ContentKeyToGet.getId())); // Assert assertEquals(ContentKeyToGet.getId(), retrievedContentKeyInfo.getId()); - verifyContentKeyProperties("ContentKey", testContentKeyId, testContentKeyType, testEncryptedContentKey, - testName, null, null, "", retrievedContentKeyInfo); + verifyContentKeyProperties("ContentKey", testGetSingleContentKeyByIdId, testContentKeyType, + testEncryptedContentKey, expectedName, "", ProtectionKeyType.fromCode(0), "", retrievedContentKeyInfo); } @Test @@ -97,24 +108,23 @@ public void cannotGetSingleContentKeyByInvalidId() throws Exception { @Test public void canRetrieveListOfContentKeys() throws Exception { String[] ContentKeyNames = new String[] { testContentKeyPrefix + "ListOne", testContentKeyPrefix + "ListTwo" }; - double duration = 3; - List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); + List<ContentKeyInfo> expectedContentKeys = new ArrayList<ContentKeyInfo>(); for (int i = 0; i < ContentKeyNames.length; i++) { - ContentKeyInfo contentKey = service.create(ContentKey.create(testContentKeyId, testContentKeyType, - testEncryptedContentKey)); - expectedAccessPolicies.add(contentKey); + String testCanRetrieveListOfContentKeysId = createRandomContentKeyId(); + ContentKeyInfo contentKey = service.create(ContentKey.create(testCanRetrieveListOfContentKeysId, + testContentKeyType, testEncryptedContentKey)); + expectedContentKeys.add(contentKey); } - List<ContentKeyInfo> actualAccessPolicies = service.list(ContentKey.list()); + List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list()); - verifyListResultContains("listAccessPolicies", expectedAccessPolicies, actualAccessPolicies, - new ComponentDelegate() { - @Override - public void verifyEquals(String message, Object expected, Object actual) { - verifyInfosEqual(message, (ContentKeyInfo) expected, (ContentKeyInfo) actual); - } - }); + verifyListResultContains("listContentKeyss", expectedContentKeys, actualContentKeys, new ComponentDelegate() { + @Override + public void verifyEquals(String message, Object expected, Object actual) { + verifyInfosEqual(message, (ContentKeyInfo) expected, (ContentKeyInfo) actual); + } + }); } @Test @@ -123,42 +133,41 @@ public void canUseQueryParametersWhenListingContentKeys() throws Exception { testContentKeyPrefix + "ListFour", testContentKeyPrefix + "ListFive", testContentKeyPrefix + "ListSix", testContentKeyPrefix + "ListSeven" }; - List<ContentKeyInfo> expectedAccessPolicies = new ArrayList<ContentKeyInfo>(); + List<ContentKeyInfo> expectedContentKeys = new ArrayList<ContentKeyInfo>(); for (int i = 0; i < ContentKeyNames.length; i++) { - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(testContentKeyId, testContentKeyType, - testEncryptedContentKey)); - expectedAccessPolicies.add(contentKeyInfo); + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(createRandomContentKeyId(), + testContentKeyType, testEncryptedContentKey)); + expectedContentKeys.add(contentKeyInfo); } MultivaluedMap<String, String> options = new MultivaluedMapImpl(); options.add("$top", "2"); - List<ContentKeyInfo> actualAccessPolicies = service.list(ContentKey.list(options)); + List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list(options)); - assertEquals(2, actualAccessPolicies.size()); + assertEquals(2, actualContentKeys.size()); } @Test public void canDeleteContentKeyById() throws Exception { - String ContentKeyName = testContentKeyPrefix + "ToDelete"; - double duration = 1; - ContentKeyInfo ContentKeyToDelete = service.create(ContentKey.create(testContentKeyId, testContentKeyType, - testEncryptedContentKey)); - List<ContentKeyInfo> listPoliciesResult = service.list(ContentKey.list()); - int ContentKeyCountBaseline = listPoliciesResult.size(); + String contentKeyName = testContentKeyPrefix + "ToDelete"; + ContentKeyInfo contentKeyToDelete = service.create(ContentKey.create(createRandomContentKeyId(), + testContentKeyType, testEncryptedContentKey)); + List<ContentKeyInfo> listContentKeysResult = service.list(ContentKey.list()); + int ContentKeyCountBaseline = listContentKeysResult.size(); - service.delete(ContentKey.delete(ContentKeyToDelete.getId())); + service.delete(ContentKey.delete(contentKeyToDelete.getId())); - listPoliciesResult = service.list(ContentKey.list()); - assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listPoliciesResult.size()); + listContentKeysResult = service.list(ContentKey.list()); + assertEquals("listPoliciesResult.size", ContentKeyCountBaseline - 1, listContentKeysResult.size()); for (ContentKeyInfo contentKey : service.list(ContentKey.list())) { - assertFalse(ContentKeyToDelete.getId().equals(contentKey.getId())); + assertFalse(contentKeyToDelete.getId().equals(contentKey.getId())); } expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(404)); - service.get(ContentKey.get(ContentKeyToDelete.getId())); + service.get(ContentKey.get(contentKeyToDelete.getId())); } @Test @@ -169,9 +178,9 @@ public void cannotDeleteContentKeyByInvalidId() throws Exception { } @Test - public void canDeleteContentKeyByNonexistId() throws Exception { + public void cannotDeleteContentKeyByNonexistId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(400)); + expectedException.expect(new ServiceExceptionMatcher(404)); service.delete(ContentKey.delete(validButNonexistContentKeyId)); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 3b9c3b8125c45..512b5e67c4e26 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -18,6 +18,8 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ContentKey; +import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -74,6 +76,20 @@ private static void cleanupEnvironment() { removeAllTestLocators(); removeAllTestAssets(); removeAllTestAccessPolicies(); + removeAllTestContentKeys(); + } + + private static void removeAllTestContentKeys() { + try { + List<ContentKeyInfo> contentKeyInfos = service.list(ContentKey.list()); + + for (ContentKeyInfo contentKeyInfo : contentKeyInfos) { + service.delete(ContentKey.delete(contentKeyInfo.getId())); + } + } + catch (Exception e) { + e.printStackTrace(); + } } private static void removeAllTestAccessPolicies() { From 28e389293ee1401f9d3c9717223ec8428040241d Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 26 Nov 2012 16:29:26 -0800 Subject: [PATCH 497/664] Making asset option Integer instead of int so it doesn't go up on an update --- .../implementation/content/AssetType.java | 20 +++---------------- .../services/media/AssetIntegrationTest.java | 2 +- .../media/models/AssetEntityTest.java | 6 ++---- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 1ba35bb91d954..7cc7b9bd3cf22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -21,8 +21,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import com.microsoft.windowsazure.services.media.models.AssetInfo; - /** * This type maps the XML returned in the odata ATOM serialization * for Asset entities. @@ -50,7 +48,7 @@ public class AssetType implements MediaServiceDTO { protected String name; @XmlElement(name = "Options", namespace = Constants.ODATA_DATA_NS) - protected int options; + protected Integer options; /** * @return the id @@ -145,7 +143,7 @@ public void setName(String name) { /** * @return the options */ - public int getOptions() { + public Integer getOptions() { return options; } @@ -153,19 +151,7 @@ public int getOptions() { * @param options * the options to set */ - public void setOptions(int options) { + public void setOptions(Integer options) { this.options = options; } - - public static AssetType create(AssetInfo assetInfo) { - AssetType assetType = new AssetType(); - assetType.setAlternateId(assetInfo.getAlternateId()); - assetType.setCreated(assetInfo.getCreated()); - assetType.setId(assetInfo.getId()); - assetType.setLastModified(assetInfo.getLastModified()); - assetType.setName(assetInfo.getName()); - assetType.setOptions(assetInfo.getOptions().getCode()); - assetType.setState(assetInfo.getState().getCode()); - return assetType; - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index e76056ba44a5d..b6ba98ac94d9a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -140,7 +140,7 @@ public void getAssetSuccess() throws Exception { @Test public void getAssetInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.get(Asset.get(invalidId)); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 8cf88ca8c00a9..57ffe163e3c7c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -28,8 +28,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; -import com.microsoft.windowsazure.services.media.models.Asset; -import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -53,7 +51,7 @@ public void assetCreateReturnsDefaultCreatePayload() { assertNull(payload.getLastModified()); assertNull(payload.getAlternateId()); assertNull(payload.getName()); - assertEquals(0, payload.getOptions()); + assertNull(payload.getOptions()); } @Test @@ -71,7 +69,7 @@ public void assetCreateCanSetAssetName() { assertNull(payload.getLastModified()); assertNull(payload.getAlternateId()); assertEquals(name, payload.getName()); - assertEquals(0, payload.getOptions()); + assertNull(payload.getOptions()); } @Test From 862cddb486deeb1abde1c0c7b0a9cb0863625d47 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 26 Nov 2012 16:31:53 -0800 Subject: [PATCH 498/664] Fixed locator tests --- .../services/media/LocatorIntegrationTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 2a2d7be24c7f2..2004f583d5b90 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -174,7 +174,7 @@ public void getLocatorSuccess() throws ServiceException { @Test public void getLocatorInvalidId() throws ServiceException { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.get(Locator.get(invalidId)); } @@ -191,8 +191,8 @@ public void listLocatorsSuccess() throws ServiceException { LocatorType locatorType = LocatorType.SAS; List<LocatorInfo> expectedLocators = new ArrayList<LocatorInfo>(); for (int i = 0; i < 2; i++) { - expectedLocators.add(service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), - locatorType))); + expectedLocators + .add(service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), locatorType))); } // Act @@ -294,7 +294,7 @@ public void deleteLocatorSuccess() throws ServiceException { @Test public void deleteLocatorInvalidIdFailed() throws ServiceException { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.delete(Locator.delete(invalidId)); } } From 21a3c9a5db601d63d2365ca29eb2f68bdfeebe31 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 26 Nov 2012 17:02:40 -0800 Subject: [PATCH 499/664] fix three failed unit tests. --- .../windowsazure/services/media/JobIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index c8af7c80b23f0..8e9c4498df2fb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -123,7 +123,7 @@ public void getJobSuccess() throws Exception { @Test public void getJobInvalidIdFailed() throws ServiceException { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.get(Job.get(invalidId)); } @@ -184,7 +184,7 @@ public void cancelJobSuccess() throws Exception { public void cancelJobFailedWithInvalidId() throws ServiceException { // Arrange expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); // Act service.action(Job.cancel(invalidId)); @@ -215,7 +215,7 @@ public void deleteJobSuccess() throws ServiceException { public void deleteJobIvalidIdFail() throws ServiceException { // Arrange expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); // Act service.delete(Job.delete(invalidId)); From 10c6a3b4e4230ed7dea76f3af20e3ebcd7075a36 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 26 Nov 2012 17:09:32 -0800 Subject: [PATCH 500/664] disable failed unit tests tracked in issue 480. --- .../windowsazure/services/media/JobIntegrationTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 8e9c4498df2fb..9a820dbf5897f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -23,6 +23,7 @@ import javax.ws.rs.core.MultivaluedMap; +import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -75,6 +76,7 @@ private JobInfo createJob(String name) throws ServiceException { .setName("My encoding Task").setTaskBody(taskBody))); } + @Ignore("due to issue 480") @Test public void createJobSuccess() throws Exception { // Arrange @@ -102,6 +104,7 @@ public void createJobSuccess() throws Exception { verifyJobInfoEqual("actualJob", expectedJob, actualJob); } + @Ignore("due to issue 480") @Test public void getJobSuccess() throws Exception { // Arrange @@ -127,6 +130,7 @@ public void getJobInvalidIdFailed() throws ServiceException { service.get(Job.get(invalidId)); } + @Ignore("due to issue 480") @Test public void listJobSuccess() throws ServiceException { // Arrange @@ -147,6 +151,7 @@ public void verifyEquals(String message, Object expected, Object actual) { }); } + @Ignore("due to issue 480") @Test public void canListJobsWithOptions() throws ServiceException { String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", @@ -166,6 +171,7 @@ public void canListJobsWithOptions() throws ServiceException { assertEquals(2, listJobsResult.size()); } + @Ignore("due to issue 480") @Test public void cancelJobSuccess() throws Exception { // Arrange @@ -192,6 +198,7 @@ public void cancelJobFailedWithInvalidId() throws ServiceException { // Assert } + @Ignore("due to issue 480") @Test public void deleteJobSuccess() throws ServiceException { // Arrange From 3085ec9deed4e6a602c306e6cd90f823a32dc60f Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 27 Nov 2012 22:26:25 -0800 Subject: [PATCH 501/664] take code review feedback. --- .../content/ContentKeyRestType.java | 1 - .../implementation/content/ObjectFactory.java | 1 - .../services/media/models/ContentKey.java | 82 -------------- .../media/ContentKeyIntegrationTest.java | 2 - .../media/models/ContentKeyEntityTest.java | 103 ++++++++++++++++++ 5 files changed, 103 insertions(+), 86 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java index 08c1470690716..5e5325703017e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -21,7 +21,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -// TODO: Auto-generated Javadoc /** * This type maps the XML returned in the odata ATOM serialization * for Asset entities. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index 57234e67c5fbd..624f562f76bbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -17,7 +17,6 @@ import javax.xml.bind.annotation.XmlRegistry; -// TODO: Auto-generated Javadoc /** * Class used by JAXB to instantiate the types in this package. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 6bcf84e5eefc5..b32ac551a3709 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -28,7 +28,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; -// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate content key entities. * @@ -115,78 +114,6 @@ public Object getRequestContents() { return contentKeyRestType; } - /** - * Gets the content key type. - * - * @return the content key type - */ - public ContentKeyType getContentKeyType() { - return contentKeyType; - } - - /** - * Sets the content key type. - * - * @param contentKeyType - * the content key type - * @return the creator - */ - public Creator setContentKeyType(ContentKeyType contentKeyType) { - this.contentKeyType = contentKeyType; - return this; - } - - /** - * Gets the encrypted content key. - * - * @return the encrypted content key - */ - public String getEncryptedContentKey() { - return encryptedContentKey; - } - - /** - * Sets the encrypted content key. - * - * @param encryptedContentKey - * the encrypted content key - * @return the creator - */ - public Creator setEncryptedContentKey(String encryptedContentKey) { - this.encryptedContentKey = encryptedContentKey; - return this; - } - - /** - * Gets the id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id - * the id - * @return the creator - */ - public Creator setId(String id) { - this.id = id; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - /** * Sets the name. * @@ -199,15 +126,6 @@ public Creator setName(String name) { return this; } - /** - * Gets the checksum. - * - * @return the checksum - */ - public String getChecksum() { - return checksum; - } - /** * Sets the checksum. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 7dd023ace0168..6c2c30176e9ec 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -35,8 +35,6 @@ public class ContentKeyIntegrationTest extends IntegrationTestBase { private final String validButNonexistContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473af"; - private final String testName = testContentKeyPrefix + "CanCreate"; - private final String testContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473ae"; private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java new file mode 100644 index 0000000000000..bcf84bc5b159a --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -0,0 +1,103 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.net.URLEncoder; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the ContentKey entity + * + */ +public class ContentKeyEntityTest { + private final String testContentKeyId = "nb:kid:UUID:c82307be-1a81-4554-ba7d-cf6dfa735a5a"; + private final ContentKeyType testContentKeyType = ContentKeyType.StorageEncryption; + private final String testEncryptedContentKey = "testEncryptedContentKey"; + private final String testExpectedContentKeyUri = String.format("ContentKeys('%s')", + URLEncoder.encode(testContentKeyId, "UTF-8")); + + public ContentKeyEntityTest() throws Exception { + + } + + @Test + public void createContentKeyHasCorrectUrl() throws Exception { + EntityCreationOperation<ContentKeyInfo> creator = ContentKey.create(testContentKeyId, testContentKeyType, + testEncryptedContentKey); + + assertEquals("ContentKeys", creator.getUri()); + } + + @Test + public void createContentKeyHasCorrectPayload() throws Exception { + ContentKeyRestType contentKeyRestType = (ContentKeyRestType) ContentKey.create(testContentKeyId, + testContentKeyType, testEncryptedContentKey).getRequestContents(); + + assertEquals(testContentKeyId, contentKeyRestType.getId()); + assertEquals(testContentKeyType.getCode(), contentKeyRestType.getContentKeyType().intValue()); + assertEquals(testEncryptedContentKey, contentKeyRestType.getEncryptedContentKey()); + assertNull(contentKeyRestType.getChecksum()); + assertNull(contentKeyRestType.getCreated()); + assertNull(contentKeyRestType.getLastModified()); + assertNull(contentKeyRestType.getName()); + assertNull(contentKeyRestType.getProtectionKeyId()); + assertNull(contentKeyRestType.getProtectionKeyType()); + } + + @Test + public void getContentKeyGivesExpectedUri() throws Exception { + assertEquals(testExpectedContentKeyUri, ContentKey.get(testContentKeyId).getUri()); + } + + @Test + public void listContentKeyReturnsExpectedUri() { + EntityListOperation<ContentKeyInfo> lister = ContentKey.list(); + + assertEquals("ContentKeys", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void listContentKeyCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<ContentKeyInfo> lister = ContentKey.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void ContentKeyDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = ContentKey.delete(testContentKeyId); + assertEquals(testExpectedContentKeyUri, deleter.getUri()); + } +} From 04e6b9da3a8fca1a4e112c3d8a07c62d2e1d679b Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 28 Nov 2012 10:58:30 -0800 Subject: [PATCH 502/664] update locator --- .../content/LocatorRestType.java | 68 ++++++++-- .../services/media/models/Locator.java | 119 +++++++++++++++--- .../services/media/models/LocatorInfo.java | 42 +++++++ .../services/media/models/LocatorType.java | 6 +- .../media/models/LocatorEntityTest.java | 45 ++++++- .../media/models/LocatorInfoTest.java | 29 ++++- 6 files changed, 279 insertions(+), 30 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index f498cc765474b..63b0cbee4aa1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -56,6 +56,14 @@ public class LocatorRestType implements MediaServiceDTO { @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) protected Date startTime; + /** The base uri. */ + @XmlElement(name = "BaseUri", namespace = Constants.ODATA_DATA_NS) + private String baseUri; + + /** The content access component. */ + @XmlElement(name = "ContentAccessComponent", namespace = Constants.ODATA_DATA_NS) + private String contentAccessComponent; + /** * Gets the id. * @@ -119,15 +127,6 @@ public LocatorRestType setType(int type) { return this; } - /** - * Gets the path. - * - * @return the path - */ - public String getPath() { - return this.path; - } - /** * Gets the access policy id. * @@ -191,6 +190,15 @@ public LocatorRestType setStartTime(Date startTime) { return this; } + /** + * Gets the path. + * + * @return the path + */ + public String getPath() { + return this.path; + } + /** * Sets the path. * @@ -202,4 +210,46 @@ public LocatorRestType setPath(String path) { this.path = path; return this; } + + /** + * Gets the base uri. + * + * @return the base uri + */ + public String getBaseUri() { + return this.baseUri; + } + + /** + * Sets the base uri. + * + * @param baseUri + * the base uri + * @return the locator rest type + */ + public LocatorRestType setBaseUri(String baseUri) { + this.baseUri = baseUri; + return this; + } + + /** + * Gets the content access component. + * + * @return the content access component + */ + public String getContentAccessComponent() { + return this.contentAccessComponent; + } + + /** + * Sets the content access component. + * + * @param contentAccessComponent + * the content access component + * @return the locator rest type + */ + public LocatorRestType setContentAccessComponent(String contentAccessComponent) { + this.contentAccessComponent = contentAccessComponent; + return this; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 6684aa1f8a56f..c03c6d34b4cf1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -31,19 +31,23 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; +// TODO: Auto-generated Javadoc /** - * Implementation of Locator entity - * + * Implementation of Locator entity. */ public class Locator { + /** The Constant ENTITY_SET. */ private final static String ENTITY_SET = "Locators"; + /** + * Instantiates a new locator. + */ private Locator() { } /** - * Create an operation to create a new locator entity + * Create an operation to create a new locator entity. * * @param accessPolicyId * id of access policy for locator @@ -57,14 +61,46 @@ public static Creator create(String accessPolicyId, String assetId, LocatorType return new Creator(accessPolicyId, assetId, locatorType); } + /** + * The Class Creator. + */ public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements EntityCreationOperation<LocatorInfo> { + + /** The access policy id. */ private final String accessPolicyId; + + /** The asset id. */ private final String assetId; + + /** The base uri. */ + private String baseUri; + + /** The content access token. */ + private String contentAccessComponent; + + /** The expiration date time. */ + private Date expirationDateTime; + + /** The locator type. */ private final LocatorType locatorType; + + /** The path. */ + private String path; + + /** The start date time. */ private Date startDateTime; - private Date expirationDateTime; + /** + * Instantiates a new creator. + * + * @param accessPolicyId + * the access policy id + * @param assetId + * the asset id + * @param locatorType + * the locator type + */ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType) { super(ENTITY_SET, LocatorInfo.class); this.accessPolicyId = accessPolicyId; @@ -72,15 +108,43 @@ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType this.locatorType = locatorType; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + */ @Override public Object getRequestContents() { return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId) .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) - .setType(locatorType.getCode()); + .setType(locatorType.getCode()).setBaseUri(baseUri) + .setContentAccessComponent(contentAccessComponent).setPath(path); } /** - * Set the date and time for when the locator starts to be available + * Sets the base uri. + * + * @param baseUri + * the base uri + * @return the creator + */ + public Creator setBaseUri(String baseUri) { + this.baseUri = baseUri; + return this; + } + + /** + * Sets the path. + * + * @param path + * the path + * @return the creator + */ + public Creator setPath(String path) { + this.path = path; + return this; + } + + /** + * Set the date and time for when the locator starts to be available. * * @param startDateTime * The date/time @@ -92,7 +156,7 @@ public Creator setStartDateTime(Date startDateTime) { } /** - * Set the date and time at which the locator will expire + * Set the date and time at which the locator will expire. * * @param expirationDateTime * Expiration date and time @@ -102,10 +166,21 @@ public Creator setExpirationDateTime(Date expirationDateTime) { this.expirationDateTime = expirationDateTime; return this; } + + /** + * Sets the content access component. + * + * @param contentAccessComponent + * @return The creator instance + */ + public Creator setContentAccessComponent(String contentAccessComponent) { + this.contentAccessComponent = contentAccessComponent; + return this; + } } /** - * Create an operation to get the given locator + * Create an operation to get the given locator. * * @param locatorId * id of locator to retrieve @@ -116,7 +191,7 @@ public static EntityGetOperation<LocatorInfo> get(String locatorId) { } /** - * Create an operation to list all locators + * Create an operation to list all locators. * * @return the list operation */ @@ -126,7 +201,7 @@ public static EntityListOperation<LocatorInfo> list() { } /** - * Create an operation to list all locators matching the given query parameters + * Create an operation to list all locators matching the given query parameters. * * @param queryParameters * query parameters to send with the request @@ -138,7 +213,7 @@ public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, Strin } /** - * Create an operation to update the given locator + * Create an operation to update the given locator. * * @param locatorId * id of locator to update @@ -148,21 +223,37 @@ public static Updater update(String locatorId) { return new Updater(locatorId); } + /** + * The Class Updater. + */ public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + + /** The start date time. */ private Date startDateTime; + + /** The expiration date time. */ private Date expirationDateTime; + /** + * Instantiates a new updater. + * + * @param locatorId + * the locator id + */ public Updater(String locatorId) { super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, locatorId)); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents() + */ @Override public Object getRequestContents() { return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); } /** - * Set when the locator will become available + * Set when the locator will become available. * * @param startDateTime * the date & time @@ -174,7 +265,7 @@ public Updater setStartDateTime(Date startDateTime) { } /** - * Set when the locator will expire + * Set when the locator will expire. * * @param expirationDateTime * the expiration date & time @@ -188,7 +279,7 @@ public Updater setExpirationDateTime(Date expirationDateTime) { } /** - * Create an operation to delete the given locator + * Create an operation to delete the given locator. * * @param locatorId * id of locator to delete diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index 272afc1981231..7c164b6385e61 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -192,4 +192,46 @@ public Date getStartTime() { return getContent().getStartTime(); } + /** + * Gets the base uri. + * + * @return the base uri + */ + public String getBaseUri() { + return getContent().getBaseUri(); + } + + /** + * Sets the base uri. + * + * @param baseUri + * the base uri + * @return the locator info + */ + public LocatorInfo setBaseUri(String baseUri) { + this.getContent().setBaseUri(baseUri); + return this; + } + + /** + * Sets the content access component. + * + * @param contentAccessComponent + * the content access component + * @return the locator info + */ + public LocatorInfo setContentAccessComponent(String contentAccessComponent) { + this.getContent().setContentAccessComponent(contentAccessComponent); + return this; + } + + /** + * Gets the content access token. + * + * @return the content access token + */ + public String getContentAccessToken() { + return this.getContent().getContentAccessComponent(); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index b06a5b30518a8..c88ea29782302 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -28,8 +28,8 @@ public enum LocatorType { SAS(1), /** The Origin. */ Origin(2), - /** The Windows azure cdn. */ - WindowsAzureCDN(3); + /** The third party locator. */ + ThirdParty(3); /** The locator type code. */ private int locatorTypeCode; @@ -69,7 +69,7 @@ public static LocatorType fromCode(int type) { case 2: return LocatorType.Origin; case 3: - return LocatorType.WindowsAzureCDN; + return LocatorType.ThirdParty; default: throw new InvalidParameterException("type"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 4dc816de535b6..82fa8faed1fc5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -29,9 +29,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; -import com.microsoft.windowsazure.services.media.models.Locator; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -87,6 +84,48 @@ public void createLocatorCanSetTimes() throws Exception { assertEquals(tomorrow, locatorType.getExpirationDateTime()); } + @Test + public void createLocatorCanSetPath() throws Exception { + + String expectedPath = "testExpectedPath"; + + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).setPath(expectedPath); + + LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); + + assertEquals(expectedPath, locatorType.getPath()); + + } + + @Test + public void createLocatorCanSetBaseUri() throws Exception { + + String expectedBaseUri = "testExpectedBaseUri"; + + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).setBaseUri(expectedBaseUri); + + LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); + + assertEquals(expectedBaseUri, locatorType.getBaseUri()); + + } + + @Test + public void createLocatorCanSetContentAccessComponent() throws Exception { + + String expectedContentAccessComponent = "testExpectedContentAccessComponent"; + + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).setContentAccessComponent(expectedContentAccessComponent); + + LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); + + assertEquals(expectedContentAccessComponent, locatorType.getContentAccessComponent()); + + } + @Test public void getLocatorGivesExpectedUri() throws Exception { assertEquals(expectedLocatorUri, Locator.get(exampleLocatorId).getUri()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index c749bd1b23cb5..5fbc6ae4abd4e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -52,7 +52,7 @@ public void testGetSetExpirationDateTime() { @Test public void testGetSetType() { // Arrange - LocatorType expectedLocatorType = LocatorType.WindowsAzureCDN; + LocatorType expectedLocatorType = LocatorType.Origin; LocatorInfo locatorInfo = new LocatorInfo(); // Act @@ -114,4 +114,31 @@ public void testGetSetStartTime() { assertEquals(expectedStartTime, actualStartTime); } + @Test + public void testGetSetBaseUri() { + // Arrange + String expectedBaseUri = "testBaseUri"; + LocatorInfo locatorInfo = new LocatorInfo(); + + // Act + String actualBaseUri = locatorInfo.setBaseUri(expectedBaseUri).getBaseUri(); + + // Assert + assertEquals(expectedBaseUri, actualBaseUri); + } + + @Test + public void testGetSetContentAccessComponent() { + // Arrange + String expectedContentAccessComponent = "testContentAccessToken"; + LocatorInfo locatorInfo = new LocatorInfo(); + + // Act + String actualContentAccessComponent = locatorInfo.setContentAccessComponent(expectedContentAccessComponent) + .getContentAccessToken(); + + // Assert + assertEquals(expectedContentAccessComponent, actualContentAccessComponent); + + } } From edc0219d403ee9818877aca696ad38207555e610 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 28 Nov 2012 15:34:29 -0800 Subject: [PATCH 503/664] Implmentation of AssetFile entity CRUD operations. --- .../services/core/utils/pipeline/Exports.java | 3 +- .../implementation/ODataAtomMarshaller.java | 2 + .../implementation/content/AssetFileType.java | 297 ++++++++++++++ .../implementation/content/ObjectFactory.java | 9 + .../services/media/models/AssetFile.java | 336 ++++++++++++++++ .../services/media/models/AssetFileInfo.java | 162 ++++++++ .../services/media/models/FileInfo.java | 373 ------------------ .../media/AssetFileIntegrationTest.java | 235 +++++++++++ .../media/models/AssetFileEntityTest.java | 135 +++++++ ...leInfoTest.java => AssetFileInfoTest.java} | 94 ++--- .../services/scenarios/MediaServiceMocks.java | 12 +- .../scenarios/MediaServiceValidation.java | 16 +- .../scenarios/MediaServiceWrapper.java | 12 +- 13 files changed, 1232 insertions(+), 454 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java rename microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/{FileInfoTest.java => AssetFileInfoTest.java} (54%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index d5b9ddc05ce9f..e6a97e159afbc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -73,6 +73,7 @@ public ClientConfig create(String profile, Builder builder, Map<String, Object> public Client create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); Client client = Client.create(clientConfig); + // client.addFilter(new LoggingFilter()); return client; } }); @@ -82,7 +83,7 @@ public Client create(String profile, Builder builder, Map<String, Object> proper public HttpURLConnectionClient create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); - //client.addFilter(new LoggingFilter()); + // client.addFilter(new LoggingFilter()); return client; } }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index ecf5726e6e230..2d9735db12f98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -34,6 +34,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.FeedType; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; @@ -131,6 +132,7 @@ private static Class<?>[] getMarshalledClasses() { classes.add(LocatorRestType.class); classes.add(TaskType.class); classes.add(ContentKeyRestType.class); + classes.add(AssetFileType.class); return classes.toArray(new Class<?>[0]); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java new file mode 100644 index 0000000000000..55e9664bdff7d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java @@ -0,0 +1,297 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * Serialization for the AssetFile entity + * + */ + +@XmlAccessorType(XmlAccessType.FIELD) +public class AssetFileType implements MediaServiceDTO { + + @XmlElement(name = "Id", namespace = Constants.ODATA_DATA_NS) + protected String id; + + @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) + protected String name; + + @XmlElement(name = "ContentFileSize", namespace = Constants.ODATA_DATA_NS) + protected Long contentFileSize; + + @XmlElement(name = "ParentAssetId", namespace = Constants.ODATA_DATA_NS) + protected String parentAssetId; + + @XmlElement(name = "EncryptionVersion", namespace = Constants.ODATA_DATA_NS) + protected String encryptionVersion; + + @XmlElement(name = "EncryptionScheme", namespace = Constants.ODATA_DATA_NS) + protected String encryptionScheme; + + @XmlElement(name = "IsEncrypted", namespace = Constants.ODATA_DATA_NS) + protected Boolean isEncrypted; + + @XmlElement(name = "EncryptionKeyId", namespace = Constants.ODATA_DATA_NS) + protected String encryptionKeyId; + + @XmlElement(name = "InitializationVector", namespace = Constants.ODATA_DATA_NS) + protected String initializationVector; + + @XmlElement(name = "IsPrimary", namespace = Constants.ODATA_DATA_NS) + protected Boolean isPrimary; + + @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + protected Date lastModified; + + @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + protected Date created; + + @XmlElement(name = "MimeType", namespace = Constants.ODATA_DATA_NS) + protected String mimeType; + + @XmlElement(name = "ContentChecksum", namespace = Constants.ODATA_DATA_NS) + protected String contentChecksum; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public AssetFileType setId(String id) { + this.id = id; + return this; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public AssetFileType setName(String name) { + this.name = name; + return this; + } + + /** + * @return the contentFileSize + */ + public Long getContentFileSize() { + return contentFileSize; + } + + /** + * @param contentFileSize + * the contentFileSize to set + */ + public AssetFileType setContentFileSize(Long contentFileSize) { + this.contentFileSize = contentFileSize; + return this; + } + + /** + * @return the parentAssetId + */ + public String getParentAssetId() { + return parentAssetId; + } + + /** + * @param parentAssetId + * the parentAssetId to set + */ + public AssetFileType setParentAssetId(String parentAssetId) { + this.parentAssetId = parentAssetId; + return this; + } + + /** + * @return the encryptionVersion + */ + public String getEncryptionVersion() { + return encryptionVersion; + } + + /** + * @param encryptionVersion + * the encryptionVersion to set + */ + public AssetFileType setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + /** + * @return the encryptionScheme + */ + public String getEncryptionScheme() { + return encryptionScheme; + } + + /** + * @param encryptionScheme + * the encryptionScheme to set + */ + public AssetFileType setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + /** + * @return the isEncrypted + */ + public Boolean getIsEncrypted() { + return isEncrypted; + } + + /** + * @param isEncrypted + * the isEncrypted to set + */ + public AssetFileType setIsEncrypted(Boolean isEncrypted) { + this.isEncrypted = isEncrypted; + return this; + } + + /** + * @return the encryptionKeyId + */ + public String getEncryptionKeyId() { + return encryptionKeyId; + } + + /** + * @param encryptionKeyId + * the encryptionKeyId to set + */ + public AssetFileType setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + /** + * @return the initializationVector + */ + public String getInitializationVector() { + return initializationVector; + } + + /** + * @param initializationVector + * the initializationVector to set + */ + public AssetFileType setInitializationVector(String initializationVector) { + this.initializationVector = initializationVector; + return this; + } + + /** + * @return the isPrimary + */ + public Boolean getIsPrimary() { + return isPrimary; + } + + /** + * @param isPrimary + * the isPrimary to set + */ + public AssetFileType setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + return this; + } + + /** + * @return the lastModified + */ + public Date getLastModified() { + return lastModified; + } + + /** + * @param lastModified + * the lastModified to set + */ + public AssetFileType setLastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * @return the created + */ + public Date getCreated() { + return created; + } + + /** + * @param created + * the created to set + */ + public AssetFileType setCreated(Date created) { + this.created = created; + return this; + } + + /** + * @return the mimeType + */ + public String getMimeType() { + return mimeType; + } + + /** + * @param mimeType + * the mimeType to set + */ + public AssetFileType setMimeType(String mimeType) { + this.mimeType = mimeType; + return this; + } + + /** + * @return the contentChecksum + */ + public String getContentChecksum() { + return contentChecksum; + } + + /** + * @param contentChecksum + * the contentChecksum to set + */ + public AssetFileType setContentChecksum(String contentChecksum) { + this.contentChecksum = contentChecksum; + return this; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index 624f562f76bbf..e6fb9ff83c151 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -103,4 +103,13 @@ public TaskType createTaskType() { public ContentKeyRestType createContentKeyRestType() { return new ContentKeyRestType(); } + + /** + * Create an instance of {@link AssetFileType} + * + * @return a new AssetFileType instance. + */ + public AssetFileType createAssetFileType() { + return new AssetFileType(); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java new file mode 100644 index 0000000000000..0d6e6c884f598 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -0,0 +1,336 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.sun.jersey.api.client.GenericType; + +public class AssetFile { + private static final String ENTITY_SET = "Files"; + + // Prevent instantiation + private AssetFile() { + } + + public static Creator create(String parentAssetId, String name) { + return new Creator(parentAssetId, name); + } + + public static class Creator extends EntityOperationSingleResultBase<AssetFileInfo> implements + EntityCreationOperation<AssetFileInfo> { + private final String parentAssetId; + private final String name; + private String contentChecksum; + private Long contentFileSize; + private String encryptionKeyId; + private String encryptionScheme; + private String encryptionVersion; + private String initializationVector; + private Boolean isEncrypted; + private Boolean isPrimary; + private String mimeType; + + private Creator(String parentAssetId, String name) { + super(ENTITY_SET, AssetFileInfo.class); + this.parentAssetId = parentAssetId; + this.name = name; + } + + @Override + public Object getRequestContents() throws ServiceException { + AssetFileType content = new AssetFileType().setName(name).setParentAssetId(parentAssetId) + .setContentChecksum(contentChecksum).setContentFileSize(contentFileSize) + .setEncryptionKeyId(encryptionKeyId).setEncryptionScheme(encryptionScheme) + .setEncryptionVersion(encryptionVersion).setInitializationVector(initializationVector) + .setIsEncrypted(isEncrypted).setIsPrimary(isPrimary).setMimeType(mimeType); + + return content; + } + + /** + * @param contentChecksum + * the contentChecksum to set + */ + public Creator setContentChecksum(String contentChecksum) { + this.contentChecksum = contentChecksum; + return this; + } + + /** + * @param contentFileSize + * the contentFileSize to set + */ + public Creator setContentFileSize(Long contentFileSize) { + this.contentFileSize = contentFileSize; + return this; + } + + /** + * @param encryptionKeyId + * the encryptionKeyId to set + */ + public Creator setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + /** + * @param encryptionScheme + * the encryptionScheme to set + */ + public Creator setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + /** + * @param encryptionVersion + * the encryptionVersion to set + */ + public Creator setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + /** + * @param initializationVector + * the initializationVector to set + */ + public Creator setInitializationVector(String initializationVector) { + this.initializationVector = initializationVector; + return this; + } + + /** + * @param isEncrypted + * the isEncrypted to set + */ + public Creator setIsEncrypted(Boolean isEncrypted) { + this.isEncrypted = isEncrypted; + return this; + } + + /** + * @param isPrimary + * the isPrimary to set + */ + public Creator setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + return this; + } + + /** + * @param mimeType + * the mimeType to set + */ + public Creator setMimeType(String mimeType) { + this.mimeType = mimeType; + return this; + } + + } + + /** + * Call the CreateFileInfos action on the server for the given asset + * + * @param assetId + * asset to create file infos for + * @return The action operation object to pass to rest proxy. + * @throws UnsupportedEncodingException + */ + public static EntityActionOperation createFileInfos(String assetId) { + String encodedId; + try { + encodedId = URLEncoder.encode(assetId, "UTF-8"); + } + catch (UnsupportedEncodingException ex) { + // This can never happen unless JVM is broken + throw new RuntimeException(ex); + } + return new DefaultActionOperation("CreateFileInfos").addQueryParameter("assetid", "'" + encodedId + "'"); + } + + /** + * Call the service to get a single asset file entity + * + * @param assetFileId + * id of file to get + * @return the get operation to pass to rest proxy + */ + public static EntityGetOperation<AssetFileInfo> get(String assetFileId) { + return new DefaultGetOperation<AssetFileInfo>(ENTITY_SET, assetFileId, AssetFileInfo.class); + } + + /** + * Calls the service to list all files + * + * @return The list operation to pass to rest proxy. + */ + public static EntityListOperation<AssetFileInfo> list() { + return new DefaultListOperation<AssetFileInfo>(ENTITY_SET, new GenericType<ListResult<AssetFileInfo>>() { + }); + } + + /** + * Calls the service to list files for an asset + * + * @param assetId + * asset to list files for + * @return the list operation object + */ + public static EntityListOperation<AssetFileInfo> list(String assetId) { + String assetUri = new EntityOperationBase.EntityIdUriBuilder("Assets", assetId).getUri() + "/Files"; + return new DefaultListOperation<AssetFileInfo>(assetUri, new GenericType<ListResult<AssetFileInfo>>() { + }); + } + + public static Updater update(String assetFileId) { + return new Updater(assetFileId); + } + + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + private String contentChecksum; + private Long contentFileSize; + private String encryptionKeyId; + private String encryptionScheme; + private String encryptionVersion; + private String initializationVector; + private Boolean isEncrypted; + private Boolean isPrimary; + private String mimeType; + + private Updater(String assetFileId) { + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, assetFileId)); + } + + @Override + public Object getRequestContents() { + return new AssetFileType().setContentChecksum(contentChecksum).setContentFileSize(contentFileSize) + .setEncryptionKeyId(encryptionKeyId).setEncryptionScheme(encryptionScheme) + .setEncryptionVersion(encryptionVersion).setInitializationVector(initializationVector) + .setIsEncrypted(isEncrypted).setIsPrimary(isPrimary).setMimeType(mimeType); + } + + /** + * @param contentChecksum + * the contentChecksum to set + */ + public Updater setContentChecksum(String contentChecksum) { + this.contentChecksum = contentChecksum; + return this; + } + + /** + * @param contentFileSize + * the contentFileSize to set + */ + public Updater setContentFileSize(Long contentFileSize) { + this.contentFileSize = contentFileSize; + return this; + } + + /** + * @param encryptionKeyId + * the encryptionKeyId to set + */ + public Updater setEncryptionKeyId(String encryptionKeyId) { + this.encryptionKeyId = encryptionKeyId; + return this; + } + + /** + * @param encryptionScheme + * the encryptionScheme to set + */ + public Updater setEncryptionScheme(String encryptionScheme) { + this.encryptionScheme = encryptionScheme; + return this; + } + + /** + * @param encryptionVersion + * the encryptionVersion to set + */ + public Updater setEncryptionVersion(String encryptionVersion) { + this.encryptionVersion = encryptionVersion; + return this; + } + + /** + * @param initializationVector + * the initializationVector to set + */ + public Updater setInitializationVector(String initializationVector) { + this.initializationVector = initializationVector; + return this; + } + + /** + * @param isEncrypted + * the isEncrypted to set + */ + public Updater setIsEncrypted(Boolean isEncrypted) { + this.isEncrypted = isEncrypted; + return this; + } + + /** + * @param isPrimary + * the isPrimary to set + */ + public Updater setIsPrimary(Boolean isPrimary) { + this.isPrimary = isPrimary; + return this; + } + + /** + * @param mimeType + * the mimeType to set + */ + public Updater setMimeType(String mimeType) { + this.mimeType = mimeType; + return this; + } + + } + + /** + * Calls the service to delete an asset file entity + * + * @param assetFileId + * file to delete + * @return the delete operation object + */ + public static EntityDeleteOperation delete(String assetFileId) { + return new DefaultDeleteOperation(ENTITY_SET, assetFileId); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java new file mode 100644 index 0000000000000..b4ca2ee5add04 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java @@ -0,0 +1,162 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.util.Date; + +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; + +/** + * The Class AssetFileInfo. + */ +public class AssetFileInfo extends ODataEntity<AssetFileType> { + + public AssetFileInfo(EntryType entry, AssetFileType content) { + super(entry, content); + } + + public AssetFileInfo() { + super(new AssetFileType()); + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return this.getContent().getId(); + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return this.getContent().getName(); + } + + /** + * Gets the content file size. + * + * @return the content file size + */ + public Long getContentFileSize() { + return this.getContent().getContentFileSize(); + } + + /** + * Gets the parent asset id. + * + * @return the parent asset id + */ + public String getParentAssetId() { + return this.getContent().getParentAssetId(); + } + + /** + * Gets the encryption version. + * + * @return the encryption version + */ + public String getEncryptionVersion() { + return this.getContent().getEncryptionVersion(); + } + + /** + * Gets the encryption scheme. + * + * @return the encryption scheme + */ + public String getEncryptionScheme() { + return this.getContent().getEncryptionScheme(); + } + + /** + * Gets the checks if is encrypted. + * + * @return the checks if is encrypted + */ + public Boolean getIsEncrypted() { + return this.getContent().getIsEncrypted(); + } + + /** + * Gets the encryption key id. + * + * @return the encryption key id + */ + public String getEncryptionKeyId() { + return this.getContent().getEncryptionKeyId(); + } + + /** + * Gets the initialization vector. + * + * @return the initialization vector + */ + public String getInitializationVector() { + return this.getContent().getInitializationVector(); + } + + /** + * Gets the checks if is primary. + * + * @return the checks if is primary + */ + public Boolean getIsPrimary() { + return this.getContent().getIsPrimary(); + } + + /** + * Gets the last modified. + * + * @return the last modified + */ + public Date getLastModified() { + return this.getContent().getLastModified(); + } + + /** + * Gets the created. + * + * @return the created + */ + public Date getCreated() { + return this.getContent().getCreated(); + } + + /** + * Gets the mime type. + * + * @return the mime type + */ + public String getMimeType() { + return this.getContent().getMimeType(); + } + + /** + * Gets the content checksum. + * + * @return the content checksum + */ + public String getContentChecksum() { + return this.getContent().getContentChecksum(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java deleted file mode 100644 index 9585a76233a67..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/FileInfo.java +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.media.models; - -import java.util.Date; - -/** - * The Class FileInfo. - */ -public class FileInfo { - - /** The id. */ - private String id; - - /** The name. */ - private String name; - - /** The content file size. */ - private int contentFileSize; - - /** The parent asset id. */ - private String parentAssetId; - - /** The encryption version. */ - private String encryptionVersion; - - /** The encryption scheme. */ - private String encryptionScheme; - - /** The is encrypted. */ - private Boolean isEncrypted; - - /** The encryption key id. */ - private String encryptionKeyId; - - /** The initialization vector. */ - private String initializationVector; - - /** The is primary. */ - private Boolean isPrimary; - - /** The last modified. */ - private Date lastModified; - - /** The created. */ - private Date created; - - /** The mime type. */ - private String mimeType; - - /** The content checksum. */ - private String contentChecksum; - - /** - * Gets the id. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Sets the id. - * - * @param id - * the id - * @return the file info - */ - public FileInfo setId(String id) { - this.id = id; - return this; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param name - * the name - * @return the file info - */ - public FileInfo setName(String name) { - this.name = name; - return this; - } - - /** - * Gets the content file size. - * - * @return the content file size - */ - public int getContentFileSize() { - return this.contentFileSize; - } - - /** - * Sets the content file size. - * - * @param contentFileSize - * the content file size - * @return the file info - */ - public FileInfo setContentFileSize(int contentFileSize) { - this.contentFileSize = contentFileSize; - return this; - } - - /** - * Gets the parent asset id. - * - * @return the parent asset id - */ - public String getParentAssetId() { - return this.parentAssetId; - } - - /** - * Sets the parent asset id. - * - * @param parentAssetId - * the parent asset id - * @return the file info - */ - public FileInfo setParentAssetId(String parentAssetId) { - this.parentAssetId = parentAssetId; - return this; - } - - /** - * Gets the created. - * - * @return the created - */ - public Date getCreated() { - return this.created; - } - - /** - * Sets the create. - * - * @param created - * the created - * @return the file info - */ - public FileInfo setCreate(Date created) { - this.created = created; - return this; - } - - /** - * Gets the last modified. - * - * @return the last modified - */ - public Date getLastModified() { - return this.lastModified; - } - - /** - * Sets the last modified. - * - * @param lastModified - * the last modified - * @return the file info - */ - public FileInfo setLastModified(Date lastModified) { - this.lastModified = lastModified; - return this; - } - - /** - * Sets the encryption version. - * - * @param encryptionVersion - * the encryption version - * @return the file info - */ - public FileInfo setEncryptionVersion(String encryptionVersion) { - this.encryptionVersion = encryptionVersion; - return this; - } - - /** - * Gets the encryption version. - * - * @return the encryption version - */ - public String getEncryptionVersion() { - return this.encryptionVersion; - } - - /** - * Sets the encryption scheme. - * - * @param encryptionScheme - * the encryption scheme - * @return the file info - */ - public FileInfo setEncryptionScheme(String encryptionScheme) { - this.encryptionScheme = encryptionScheme; - return this; - } - - /** - * Gets the encryption scheme. - * - * @return the encryption scheme - */ - public String getEncryptionScheme() { - return this.encryptionScheme; - } - - /** - * Sets the is encrypted. - * - * @param isEncrypted - * the is encrypted - * @return the file info - */ - public FileInfo setIsEncrypted(Boolean isEncrypted) { - this.isEncrypted = isEncrypted; - return this; - } - - /** - * Gets the checks if is encrypted. - * - * @return the checks if is encrypted - */ - public Boolean getIsEncrypted() { - return this.isEncrypted; - } - - /** - * Sets the encryption key id. - * - * @param encryptionKeyId - * the encryption key id - * @return the file info - */ - public FileInfo setEncryptionKeyId(String encryptionKeyId) { - this.encryptionKeyId = encryptionKeyId; - return this; - } - - /** - * Gets the encryption key id. - * - * @return the encryption key id - */ - public String getEncryptionKeyId() { - return this.encryptionKeyId; - } - - /** - * Sets the initialization vector. - * - * @param expectedInitializationVector - * the expected initialization vector - * @return the file info - */ - public FileInfo setInitializationVector(String expectedInitializationVector) { - this.initializationVector = expectedInitializationVector; - return this; - } - - /** - * Gets the initialization vector. - * - * @return the initialization vector - */ - public String getInitializationVector() { - return this.initializationVector; - } - - /** - * Sets the is primary. - * - * @param isPrimary - * the is primary - * @return the file info - */ - public FileInfo setIsPrimary(Boolean isPrimary) { - this.isPrimary = isPrimary; - return this; - } - - /** - * Gets the checks if is primary. - * - * @return the checks if is primary - */ - public Boolean getIsPrimary() { - return this.isPrimary; - } - - /** - * Sets the created. - * - * @param created - * the created - * @return the file info - */ - public FileInfo setCreated(Date created) { - this.created = created; - return this; - } - - /** - * Sets the mime type. - * - * @param mimeType - * the mime type - * @return the file info - */ - public FileInfo setMimeType(String mimeType) { - this.mimeType = mimeType; - return this; - } - - /** - * Gets the mime type. - * - * @return the mime type - */ - public String getMimeType() { - return this.mimeType; - } - - /** - * Sets the content checksum. - * - * @param contentChecksum - * the content checksum - * @return the file info - */ - public FileInfo setContentChecksum(String contentChecksum) { - this.contentChecksum = contentChecksum; - return this; - } - - /** - * Gets the content checksum. - * - * @return the content checksum - */ - public String getContentChecksum() { - return this.contentChecksum; - } - -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java new file mode 100644 index 0000000000000..4e7ba9b5fff2b --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -0,0 +1,235 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.EnumSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; + +public class AssetFileIntegrationTest extends IntegrationTestBase { + + // Some dummy binary data for uploading + private static byte[] firstPrimes = new byte[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 }; + private static byte[] onesAndZeros = new byte[] { 1, 0, 1, 0, 1, 0, 1, 0 }; + private static byte[] countingUp = new byte[] { 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + + private static final String BLOB_NAME = "primes.bin"; + private static final String BLOB_NAME_2 = "primes2.bin"; + + private static AccessPolicyInfo writePolicy; + + @BeforeClass + public static void setup() throws Exception { + IntegrationTestBase.setup(); + + writePolicy = createWritePolicy("uploadWritePolicy", 30); + } + + @Test + public void canCreateFileForUploadedBlob() throws Exception { + AssetInfo asset = createTestAsset("createFileForUploadedBlob"); + LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + createAndUploadBlob(blobWriter, BLOB_NAME, firstPrimes); + + service.action(AssetFile.createFileInfos(asset.getId())); + + ListResult<AssetFileInfo> files = service.list(AssetFile.list()); + + assertEquals(1, files.size()); + AssetFileInfo file = files.get(0); + assertEquals(BLOB_NAME, file.getName()); + } + + @Test + public void canCreateFileEntityDirectly() throws Exception { + AssetInfo asset = createTestAsset("createFileEntityDirectly"); + LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + createAndUploadBlob(blobWriter, BLOB_NAME_2, firstPrimes); + + service.create(AssetFile.create(asset.getId(), BLOB_NAME_2)); + + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); + + boolean found = false; + for (AssetFileInfo file : files) { + if (file.getName().equals(BLOB_NAME_2)) { + found = true; + break; + } + } + + assertTrue(found); + } + + @Test + public void canCreateAssetWithMultipleFiles() throws Exception { + AssetInfo asset = createTestAsset("createWithMultipleFiles"); + AccessPolicyInfo policy = createWritePolicy("createWithMultipleFiles", 10); + LocatorInfo locator = createLocator(policy, asset, 5, 10); + + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + createAndUploadBlob(blobWriter, "blob1.bin", firstPrimes); + createAndUploadBlob(blobWriter, "blob2.bin", onesAndZeros); + createAndUploadBlob(blobWriter, "blob3.bin", countingUp); + + AssetFileInfo file1 = service.create(AssetFile.create(asset.getId(), "blob1.bin").setIsPrimary(true) + .setIsEncrypted(false).setContentFileSize(new Long(firstPrimes.length))); + + AssetFileInfo file2 = service.create(AssetFile.create(asset.getId(), "blob2.bin").setIsPrimary(false) + .setIsEncrypted(false).setContentFileSize(new Long(onesAndZeros.length))); + + AssetFileInfo file3 = service.create(AssetFile.create(asset.getId(), "blob3.bin").setIsPrimary(false) + .setIsEncrypted(false).setContentFileSize(new Long(countingUp.length))); + + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); + + assertEquals(3, files.size()); + + ArrayList<AssetFileInfo> results = new ArrayList<AssetFileInfo>(files); + Collections.sort(results, new Comparator<AssetFileInfo>() { + @Override + public int compare(AssetFileInfo o1, AssetFileInfo o2) { + return o1.getName().compareTo(o2.getName()); + } + }); + + assertAssetFileInfoEquals(file1, results.get(0)); + assertAssetFileInfoEquals(file2, results.get(1)); + assertAssetFileInfoEquals(file3, results.get(2)); + } + + @Test + public void canCreateFileAndThenUpdateIt() throws Exception { + AssetInfo asset = createTestAsset("createAndUpdate"); + AccessPolicyInfo policy = createWritePolicy("createAndUpdate", 10); + LocatorInfo locator = createLocator(policy, asset, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + createAndUploadBlob(blobWriter, "toUpdate.bin", firstPrimes); + + AssetFileInfo file = service.create(AssetFile.create(asset.getId(), "toUpdate.bin")); + + service.update(AssetFile.update(file.getId()).setMimeType("application/octet-stream")); + + AssetFileInfo fromServer = service.get(AssetFile.get(file.getId())); + + assertEquals("application/octet-stream", fromServer.getMimeType()); + } + + @Test + public void canDeleteFileFromAsset() throws Exception { + AssetInfo asset = createTestAsset("deleteFile"); + AccessPolicyInfo policy = createWritePolicy("deleteFile", 10); + LocatorInfo locator = createLocator(policy, asset, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + + createAndUploadBlob(blobWriter, "todelete.bin", firstPrimes); + createAndUploadBlob(blobWriter, "tokeep.bin", onesAndZeros); + + service.action(AssetFile.createFileInfos(asset.getId())); + + ListResult<AssetFileInfo> originalFiles = service.list(AssetFile.list(asset.getId())); + assertEquals(2, originalFiles.size()); + + for (AssetFileInfo file : originalFiles) { + if (file.getName().equals("todelete.bin")) { + service.delete(AssetFile.delete(file.getId())); + break; + } + } + + ListResult<AssetFileInfo> newFiles = service.list(AssetFile.list(asset.getId())); + assertEquals(1, newFiles.size()); + assertEquals("tokeep.bin", newFiles.get(0).getName()); + } + + // + // Helper functions to create various media services entities + // + private static AssetInfo createTestAsset(String name) throws ServiceException { + return service.create(Asset.create().setName(testAssetPrefix + name)); + } + + private static AccessPolicyInfo createWritePolicy(String name, int durationInMinutes) throws ServiceException { + return service.create(AccessPolicy.create(testPolicyPrefix + name, durationInMinutes, + EnumSet.of(AccessPolicyPermission.WRITE))); + } + + private static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, + int expirationDeltaMinutes) throws ServiceException { + + Date now = new Date(); + Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); + Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); + + return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) + .setStartDateTime(start).setExpirationDateTime(expire)); + } + + private static void createAndUploadBlob(WritableBlobContainerContract blobWriter, String blobName, byte[] data) + throws ServiceException { + InputStream blobContent = new ByteArrayInputStream(data); + blobWriter.createBlockBlob(blobName, blobContent); + } + + // + // Assertion helpers + // + + private void assertAssetFileInfoEquals(AssetFileInfo expected, AssetFileInfo actual) { + assertEquals(expected.getId(), actual.getId()); + assertEquals(expected.getName(), actual.getName()); + assertEquals(expected.getParentAssetId(), actual.getParentAssetId()); + assertEquals(expected.getIsPrimary(), actual.getIsPrimary()); + assertEquals(expected.getIsEncrypted(), actual.getIsEncrypted()); + assertEquals(expected.getEncryptionKeyId(), actual.getEncryptionKeyId()); + assertEquals(expected.getEncryptionScheme(), actual.getEncryptionScheme()); + assertEquals(expected.getEncryptionVersion(), actual.getEncryptionVersion()); + assertEquals(expected.getInitializationVector(), actual.getInitializationVector()); + // TODO: Turn these checks back on after we fix the date timezone serialization issue #413 + //assertEquals(expected.getCreated(), actual.getCreated()); + //assertEquals(expected.getLastModified(), actual.getLastModified()); + assertEquals(expected.getMimeType(), actual.getMimeType()); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java new file mode 100644 index 0000000000000..299eb71440775 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java @@ -0,0 +1,135 @@ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; + +public class AssetFileEntityTest { + private final String exampleAssetId = "nb:cid:UUID:bfe1c840-36c3-4a78-9b63-38e6eebd94c2"; + private final String exampleFileId = "nb:cid:UUID:49a229ad-8cc5-470f-9e0b-11838283aa58"; + private final String encodedAssetId = "'nb%3Acid%3AUUID%3Abfe1c840-36c3-4a78-9b63-38e6eebd94c2'"; + private final String encodedFileId = "'nb%3Acid%3AUUID%3A49a229ad-8cc5-470f-9e0b-11838283aa58'"; + + public AssetFileEntityTest() throws Exception { + + } + + @Test + public void createFileInfosHasExpectedUri() throws Exception { + EntityActionOperation action = AssetFile.createFileInfos(exampleAssetId); + + assertEquals("CreateFileInfos", action.getUri()); + assertEquals(encodedAssetId, action.getQueryParameters().getFirst("assetid")); + } + + @Test + public void createWithOptionsSetsOptionsAsExpected() throws Exception { + String expectedName = "newFile.mp4"; + Long expectedSize = 65432L; + String expectedChecksum = "check"; + String expectedEncryptionKey = "ooh, secret!"; + String expectedEncryptionScheme = "scheme"; + String expectedEncryptionVersion = "some version"; + String expectedInitializationVector = "cross product"; + Boolean expectedIsEncrypted = true; + Boolean expectedIsPrimary = true; + String expectedMimeType = "application/octet-stream"; + + EntityCreationOperation<AssetFileInfo> creator = AssetFile.create(exampleAssetId, expectedName) + .setContentChecksum(expectedChecksum).setContentFileSize(expectedSize) + .setEncryptionKeyId(expectedEncryptionKey).setEncryptionScheme(expectedEncryptionScheme) + .setEncryptionVersion(expectedEncryptionVersion).setInitializationVector(expectedInitializationVector) + .setIsEncrypted(expectedIsEncrypted).setIsPrimary(expectedIsPrimary).setMimeType(expectedMimeType); + + AssetFileType payload = (AssetFileType) creator.getRequestContents(); + + assertEquals(expectedName, payload.getName()); + assertEquals(exampleAssetId, payload.getParentAssetId()); + assertEquals(expectedSize, payload.getContentFileSize()); + assertEquals(expectedChecksum, payload.getContentChecksum()); + assertEquals(expectedEncryptionKey, payload.getEncryptionKeyId()); + assertEquals(expectedEncryptionScheme, payload.getEncryptionScheme()); + assertEquals(expectedEncryptionVersion, payload.getEncryptionVersion()); + assertEquals(expectedInitializationVector, payload.getInitializationVector()); + assertEquals(expectedIsEncrypted, payload.getIsEncrypted()); + assertEquals(expectedIsPrimary, payload.getIsPrimary()); + assertEquals(expectedMimeType, payload.getMimeType()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + } + + @Test + public void getByIdHasCorrectUri() throws Exception { + String expectedUri = String.format("Files(%s)", encodedFileId); + EntityGetOperation<AssetFileInfo> getter = AssetFile.get(exampleFileId); + + assertEquals(expectedUri, getter.getUri()); + } + + @Test + public void listFileInfosForAnAssetHasCorrectUri() throws Exception { + String expectedUri = String.format("Assets(%s)/Files", encodedAssetId); + EntityListOperation<AssetFileInfo> lister = AssetFile.list(exampleAssetId); + + assertEquals(expectedUri, lister.getUri()); + } + + @Test + public void listAllFileInfosHasCorrectUri() throws Exception { + String expectedUri = "Files"; + EntityListOperation<AssetFileInfo> lister = AssetFile.list(); + assertEquals(expectedUri, lister.getUri()); + } + + @Test + public void updateWithAllOptionsHasCorrectPayload() throws Exception { + Long expectedSize = 65432L; + String expectedChecksum = "check"; + String expectedEncryptionKey = "ooh, secret!"; + String expectedEncryptionScheme = "scheme"; + String expectedEncryptionVersion = "some version"; + String expectedInitializationVector = "cross product"; + Boolean expectedIsEncrypted = true; + Boolean expectedIsPrimary = true; + String expectedMimeType = "application/octet-stream"; + + EntityUpdateOperation updater = AssetFile.update(exampleFileId).setContentChecksum(expectedChecksum) + .setContentFileSize(expectedSize).setEncryptionKeyId(expectedEncryptionKey) + .setEncryptionScheme(expectedEncryptionScheme).setEncryptionVersion(expectedEncryptionVersion) + .setInitializationVector(expectedInitializationVector).setIsEncrypted(expectedIsEncrypted) + .setIsPrimary(expectedIsPrimary).setMimeType(expectedMimeType); + + AssetFileType payload = (AssetFileType) updater.getRequestContents(); + + assertNull(payload.getName()); + assertNull(payload.getId()); + assertNull(payload.getParentAssetId()); + assertEquals(expectedSize, payload.getContentFileSize()); + assertEquals(expectedChecksum, payload.getContentChecksum()); + assertEquals(expectedEncryptionKey, payload.getEncryptionKeyId()); + assertEquals(expectedEncryptionScheme, payload.getEncryptionScheme()); + assertEquals(expectedEncryptionVersion, payload.getEncryptionVersion()); + assertEquals(expectedInitializationVector, payload.getInitializationVector()); + assertEquals(expectedIsEncrypted, payload.getIsEncrypted()); + assertEquals(expectedIsPrimary, payload.getIsPrimary()); + assertEquals(expectedMimeType, payload.getMimeType()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + } + + @Test + public void deleteHasCorrectUri() throws Exception { + String expectedUri = String.format("Files(%s)", encodedFileId); + EntityDeleteOperation deleter = AssetFile.delete(exampleFileId); + + assertEquals(expectedUri, deleter.getUri()); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java similarity index 54% rename from microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java rename to microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java index 3e32e0626a7ab..455fc336ebf6c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/FileInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java @@ -20,16 +20,16 @@ import org.junit.Test; -public class FileInfoTest { +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; + +public class AssetFileInfoTest { @Test public void testGetSetId() { - // Arrange String expectedId = "testId"; - FileInfo file = new FileInfo(); + AssetFileInfo file = new AssetFileInfo(null, new AssetFileType().setId(expectedId)); - // Act - String actualId = file.setId(expectedId).getId(); + String actualId = file.getId(); // Assert assertEquals(expectedId, actualId); @@ -37,12 +37,10 @@ public void testGetSetId() { @Test public void testGetSetName() { - // Arrange String expectedName = "testName"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setName(expectedName)); - // Act - String actualName = fileInfo.setName(expectedName).getName(); + String actualName = fileInfo.getName(); // Assert assertEquals(expectedName, actualName); @@ -51,41 +49,34 @@ public void testGetSetName() { @Test public void testGetSetContentFileSize() { // Arrange - int expectedContentFileSize = 1234; - FileInfo fileInfo = new FileInfo(); + Long expectedContentFileSize = 1234l; + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setContentFileSize(expectedContentFileSize)); // Act - int actualContentFileSize = fileInfo.setContentFileSize(expectedContentFileSize).getContentFileSize(); + long actualContentFileSize = fileInfo.getContentFileSize().longValue(); // Assert - assertEquals(expectedContentFileSize, actualContentFileSize); + assertEquals(expectedContentFileSize.longValue(), actualContentFileSize); } @Test public void testGetSetParentAssetId() { - // Arrange String expectedParentAssetId = "testParentAssetId"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setParentAssetId(expectedParentAssetId)); - // Act - String actualParentAssetId = fileInfo.setParentAssetId(expectedParentAssetId).getParentAssetId(); + String actualParentAssetId = fileInfo.getParentAssetId(); - // Assert assertEquals(expectedParentAssetId, actualParentAssetId); } @Test public void testGetSetEncryptionVersion() { - // Arrange String expectedEncryptionVersion = "testEncryptionVersion"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionVersion(expectedEncryptionVersion)); - // Act - String actualEncryptionVersion = fileInfo.setEncryptionVersion(expectedEncryptionVersion) - .getEncryptionVersion(); + String actualEncryptionVersion = fileInfo.getEncryptionVersion(); - // Assert assertEquals(expectedEncryptionVersion, actualEncryptionVersion); } @@ -93,10 +84,10 @@ public void testGetSetEncryptionVersion() { public void testGetSetEncryptionScheme() { // Arrange String expectedEncryptionScheme = "testEncryptionScheme"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionScheme(expectedEncryptionScheme)); // Act - String actualEncryptionScheme = fileInfo.setEncryptionScheme(expectedEncryptionScheme).getEncryptionScheme(); + String actualEncryptionScheme = fileInfo.getEncryptionScheme(); // Assert assertEquals(expectedEncryptionScheme, actualEncryptionScheme); @@ -106,10 +97,10 @@ public void testGetSetEncryptionScheme() { public void testGetSetIsEncrypted() { // Arrange Boolean expectedIsEncrypted = true; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setIsEncrypted(expectedIsEncrypted)); // Act - Boolean actualIsEncrypted = fileInfo.setIsEncrypted(expectedIsEncrypted).getIsEncrypted(); + Boolean actualIsEncrypted = fileInfo.getIsEncrypted(); // Assert assertEquals(expectedIsEncrypted, actualIsEncrypted); @@ -117,28 +108,21 @@ public void testGetSetIsEncrypted() { @Test public void testGetSetEncryptionKeyId() { - // Arrange String expectedEncryptionKeyId = "testEncryptionKeyId"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionKeyId(expectedEncryptionKeyId)); - // Act - String actualEncryptionKeyId = fileInfo.setEncryptionKeyId(expectedEncryptionKeyId).getEncryptionKeyId(); + String actualEncryptionKeyId = fileInfo.getEncryptionKeyId(); - // Assert assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); } @Test public void testGetSetInitializationVector() { - // Arrange String expectedInitializationVector = "testInitializationVector"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setInitializationVector(expectedInitializationVector)); - // Act - String actualInitializationVector = fileInfo.setInitializationVector(expectedInitializationVector) - .getInitializationVector(); + String actualInitializationVector = fileInfo.getInitializationVector(); - // Assert assertEquals(expectedInitializationVector, actualInitializationVector); } @@ -147,10 +131,10 @@ public void testGetSetInitializationVector() { public void testGetSetIsPrimary() { // Arrange Boolean expectedIsPrimary = true; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setIsPrimary(expectedIsPrimary)); // Act - Boolean actualIsPrimary = fileInfo.setIsPrimary(expectedIsPrimary).getIsPrimary(); + Boolean actualIsPrimary = fileInfo.getIsPrimary(); // Assert assertEquals(expectedIsPrimary, actualIsPrimary); @@ -158,53 +142,41 @@ public void testGetSetIsPrimary() { @Test public void testGetSetLastModified() { - // Arrange Date expectedLastModified = new Date(); - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setLastModified(expectedLastModified)); - // Act - Date actualLastModified = fileInfo.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = fileInfo.getLastModified(); - // Assert assertEquals(expectedLastModified, actualLastModified); } @Test public void testGetSetCreated() { - // Arrange Date expectedCreated = new Date(); - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setCreated(expectedCreated)); - // Act - Date actualCreated = fileInfo.setCreated(expectedCreated).getCreated(); + Date actualCreated = fileInfo.getCreated(); - // Assert assertEquals(expectedCreated, actualCreated); } @Test public void testGetSetMimeType() { - // Arrange String expectedMimeType = "testMimeType"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setMimeType(expectedMimeType)); - // Act - String actualMimeType = fileInfo.setMimeType(expectedMimeType).getMimeType(); + String actualMimeType = fileInfo.getMimeType(); - // Assert assertEquals(expectedMimeType, actualMimeType); } @Test public void testGetSetContentChecksum() { - // Arrange String expectedContentChecksum = "testContentChecksum"; - FileInfo fileInfo = new FileInfo(); + AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setContentChecksum(expectedContentChecksum)); - // Act - String actualContentChecksum = fileInfo.setContentChecksum(expectedContentChecksum).getContentChecksum(); + String actualContentChecksum = fileInfo.getContentChecksum(); - // Assert assertEquals(expectedContentChecksum, actualContentChecksum); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java index 5703a8d6e4c01..cfedb89502d4c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java @@ -19,15 +19,15 @@ import java.util.List; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.FileInfo; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; // TODO: Remove when no longer needed. // Tracked by https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/457 class MediaServiceMocks { static class MockMediaContract { - public List<FileInfo> getAssetFiles(String id) { - return new ArrayList<FileInfo>(); + public List<AssetFileInfo> getAssetFiles(String id) { + return new ArrayList<AssetFileInfo>(); } public JobInfo createJob(CreateJobOptions jobOptions) { @@ -45,11 +45,11 @@ public List<AssetInfo> getJobOutputMediaAssets(String id) { public void cancelJob(String id) { } - public List<FileInfo> getFiles() { - return new ArrayList<FileInfo>(); + public List<AssetFileInfo> getFiles() { + return new ArrayList<AssetFileInfo>(); } - public FileInfo createFileInfo(FileInfo fi) { + public AssetFileInfo createFileInfo(AssetFileInfo fi) { return null; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 4a442a3c89b7b..c2517b8d8c8f2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -32,7 +32,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.FileInfo; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.JobInfo; @@ -55,7 +55,7 @@ public void validateAsset(AssetInfo asset, String name, EncryptionOption encrypt assertEquals("asset.getOptions", encryption, asset.getOptions()); // Verify no files by default. - List<FileInfo> initialFiles = serviceMock.getAssetFiles(asset.getId()); + List<AssetFileInfo> initialFiles = serviceMock.getAssetFiles(asset.getId()); assertNotNull("initialFiles", initialFiles); assertEquals("initialFiles.size", 0, initialFiles.size()); @@ -91,7 +91,7 @@ public void validateAssetSortedPages(List<ListResult<AssetInfo>> pages, List<Str public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> inputFiles) throws ServiceException, IOException, NoSuchAlgorithmException { - List<FileInfo> assetFiles = serviceMock.getAssetFiles(asset.getId()); + List<AssetFileInfo> assetFiles = serviceMock.getAssetFiles(asset.getId()); assertNotNull("assetFiles", assetFiles); assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); @@ -107,11 +107,11 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i // * Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion // Compare the asset files with all files - List<FileInfo> allFiles = serviceMock.getFiles(); - for (FileInfo assetFile : assetFiles) { + List<AssetFileInfo> allFiles = serviceMock.getFiles(); + for (AssetFileInfo assetFile : assetFiles) { assertEquals("fi.getParentAssetId", asset.getId(), assetFile.getParentAssetId()); - FileInfo match = null; - for (FileInfo aFile : allFiles) { + AssetFileInfo match = null; + for (AssetFileInfo aFile : allFiles) { if (aFile.getId().equals(assetFile.getId())) { match = aFile; break; @@ -175,7 +175,7 @@ private InputStream getInputStreamWithRetry(URL file) throws InterruptedExceptio return reader; } - public void assertFileInfosEqual(String message, FileInfo fi, FileInfo match) { + public void assertFileInfosEqual(String message, AssetFileInfo fi, AssetFileInfo match) { assertNotNull(message + ":fi", fi); assertNotNull(message + ":match", match); assertEquals(message + ":getContentChecksum", fi.getContentChecksum(), match.getContentChecksum()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index a13be128cb899..8c6aa7d32e56d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -32,6 +32,7 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; @@ -39,7 +40,7 @@ import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.FileInfo; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -155,8 +156,9 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht String md5 = Base64.encode(md5hash); System.out.println("md5: " + md5); - FileInfo fi = new FileInfo().setContentChecksum(md5).setContentFileSize(countingStream.getCount()) - .setIsPrimary(isFirst).setName(fileName).setParentAssetId(asset.getAlternateId()); + AssetFileInfo fi = new AssetFileInfo(null, new AssetFileType().setContentChecksum(md5) + .setContentFileSize(new Long(countingStream.getCount())).setIsPrimary(isFirst).setName(fileName) + .setParentAssetId(asset.getAlternateId())); serviceMock.createFileInfo(fi); isFirst = false; @@ -301,8 +303,8 @@ private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), locatorType)); - List<FileInfo> publishedFiles = serviceMock.getAssetFiles(asset.getId()); - for (FileInfo fi : publishedFiles) { + List<AssetFileInfo> publishedFiles = serviceMock.getAssetFiles(asset.getId()); + for (AssetFileInfo fi : publishedFiles) { if (isSmooth) { // Smooth Streaming format ends with ".ism*" int index = fi.getName().lastIndexOf('.'); From cb49df0ad9454f42ffa6aa63986146ab10ee60a8 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 29 Nov 2012 09:24:56 -0800 Subject: [PATCH 504/664] Added adapter to handle odata timezone logic --- .../implementation/ODataDateAdapter.java | 57 +++++++++++ .../content/AccessPolicyType.java | 5 + .../implementation/content/AssetFileType.java | 5 + .../implementation/content/AssetType.java | 5 + .../content/ContentKeyRestType.java | 5 + .../media/implementation/content/JobType.java | 7 ++ .../content/LocatorRestType.java | 5 + .../implementation/content/TaskType.java | 5 + .../media/AssetFileIntegrationTest.java | 5 +- .../services/media/IntegrationTestBase.java | 7 -- .../implementation/ODataDateParsingTest.java | 97 +++++++++++++++++++ 11 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java new file mode 100644 index 0000000000000..bc495dc0e46a4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java @@ -0,0 +1,57 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import java.util.Calendar; +import java.util.Date; +import java.util.regex.Pattern; + +import javax.xml.bind.DatatypeConverter; +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * Adapter to convert OData time zone conventions into Java + * Dates and back. + * + */ +public class ODataDateAdapter extends XmlAdapter<String, Date> { + + private final static Pattern hasTimezoneRegex; + + static { + hasTimezoneRegex = Pattern.compile("^.*(\\+|-)\\d\\d:\\d\\d$"); + } + + @Override + public Date unmarshal(String dateString) throws Exception { + if (!hasTimezone(dateString)) { + dateString += "Z"; + } + Calendar parsedDate = DatatypeConverter.parseDateTime(dateString); + return parsedDate.getTime(); + } + + @Override + public String marshal(Date date) throws Exception { + Calendar dateToMarshal = Calendar.getInstance(); + dateToMarshal.setTime(date); + return DatatypeConverter.printDateTime(dateToMarshal); + } + + private boolean hasTimezone(String dateString) { + return dateString.endsWith("Z") || hasTimezoneRegex.matcher(dateString).matches(); + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java index 219a65b668f16..7a51ad3434842 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -20,6 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Wrapper DTO for Media Services access policies. @@ -32,9 +35,11 @@ public class AccessPolicyType implements MediaServiceDTO { protected String id; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java index 55e9664bdff7d..7017c0bd1fac1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java @@ -20,6 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Serialization for the AssetFile entity @@ -60,9 +63,11 @@ public class AssetFileType implements MediaServiceDTO { protected Boolean isPrimary; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "MimeType", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 7cc7b9bd3cf22..abd8210d1e39c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -20,6 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -36,9 +39,11 @@ public class AssetType implements MediaServiceDTO { protected int state; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "AlternateId", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java index 5e5325703017e..f5dee8ea239d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -20,6 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -35,10 +38,12 @@ public class ContentKeyRestType implements MediaServiceDTO { /** The created. */ @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; /** The last modified. */ @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; /** The content key type. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index eb274041985fa..764453363e06a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -21,6 +21,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -40,14 +43,17 @@ public class JobType implements MediaServiceDTO { /** The created. */ @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; /** The last modified. */ @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; /** The end time. */ @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date endTime; /** The priority. */ @@ -60,6 +66,7 @@ public class JobType implements MediaServiceDTO { /** The start time. */ @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; /** The state. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index 63b0cbee4aa1d..2d1487017a0e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -20,6 +20,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Wrapper DTO for Media Services Locator. @@ -34,6 +37,7 @@ public class LocatorRestType implements MediaServiceDTO { /** The expiration date time. */ @XmlElement(name = "ExpirationDateTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date expirationDateTime; /** The type. */ @@ -54,6 +58,7 @@ public class LocatorRestType implements MediaServiceDTO { /** The start time. */ @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; /** The base uri. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 67d92f8620b72..71c1648e05e33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -21,6 +21,9 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -37,6 +40,7 @@ public class TaskType implements MediaServiceDTO { protected String configuration; @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date endTime; @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) @@ -61,6 +65,7 @@ public class TaskType implements MediaServiceDTO { protected Double runningDuration; @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) + @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 4e7ba9b5fff2b..093dbcf246295 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -226,9 +226,8 @@ private void assertAssetFileInfoEquals(AssetFileInfo expected, AssetFileInfo act assertEquals(expected.getEncryptionScheme(), actual.getEncryptionScheme()); assertEquals(expected.getEncryptionVersion(), actual.getEncryptionVersion()); assertEquals(expected.getInitializationVector(), actual.getInitializationVector()); - // TODO: Turn these checks back on after we fix the date timezone serialization issue #413 - //assertEquals(expected.getCreated(), actual.getCreated()); - //assertEquals(expected.getLastModified(), actual.getLastModified()); + assertDateApproxEquals(expected.getCreated(), actual.getCreated()); + assertDateApproxEquals(expected.getLastModified(), actual.getLastModified()); assertEquals(expected.getMimeType(), actual.getMimeType()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 512b5e67c4e26..d7a2a9c13e846 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -194,13 +194,6 @@ protected void assertDateApproxEquals(String message, Date expected, Date actual else { long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); - // TODO: Remove this time-zone workaround when fixed: - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/413 - if (diffInMilliseconds > deltaInMilliseconds) { - // Just hard-code time-zone offset of 8 hours for now. - diffInMilliseconds = Math.abs(diffInMilliseconds - 8 * 60 * 60 * 1000); - } - if (diffInMilliseconds > deltaInMilliseconds) { assertEquals(message, expected, actual); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java new file mode 100644 index 0000000000000..a4a84954a541b --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -0,0 +1,97 @@ +/** + * Copyright 2011 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import org.junit.Test; + +/** + * Tests around parsing dates - OData requires date + * strings without timezones be treated as UTC. + * ISO spec, and Java default, is to use local timezone. + * So we need to plug in to tweak Jaxb to use OData + * conventions. + * + */ +public class ODataDateParsingTest { + + @Test + public void canConvertDateToString() throws Exception { + TimeZone utc = TimeZone.getDefault(); + //utc.setRawOffset(0); + + Calendar sampleTime = new GregorianCalendar(2012, 11, 28, 17, 43, 12); + sampleTime.setTimeZone(utc); + + Date sampleDate = sampleTime.getTime(); + + String formatted = new ODataDateAdapter().marshal(sampleDate); + + assertTrue(formatted.contains("2012")); + + } + + @Test + public void stringWithTimezoneRoundTripsCorrectly() throws Exception { + String exampleDate = "2012-11-28T17:43:12-08:00"; + + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + TimeZone pst = TimeZone.getDefault(); + pst.setRawOffset(-8 * 60 * 60 * 1000); + + Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); + expectedTime.setTimeZone(pst); + + assertEquals(expectedTime.getTimeInMillis(), parsedTime.getTime()); + } + + @Test + public void stringWithUTCTimezoneRoundTripsCorrectly() throws Exception { + String exampleDate = "2012-11-28T17:43:12Z"; + + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + TimeZone utc = TimeZone.getDefault(); + utc.setRawOffset(0); + + Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); + expectedTime.setTimeZone(utc); + + assertEquals(expectedTime.getTimeInMillis(), parsedTime.getTime()); + } + + @Test + public void stringWithNoTimezoneActsAsUTC() throws Exception { + String exampleDate = "2012-11-28T17:43:12"; + + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + TimeZone utc = TimeZone.getDefault(); + utc.setRawOffset(0); + + Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); + expectedTime.setTimeZone(utc); + + assertEquals(expectedTime.getTimeInMillis(), parsedTime.getTime()); + } +} From 5ef95d68984af65b7225f69de05c97661f7abf54 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 29 Nov 2012 09:55:56 -0800 Subject: [PATCH 505/664] Set adapter for dates once for the package, not on each field --- .../content/AccessPolicyType.java | 5 ----- .../implementation/content/AssetFileType.java | 5 ----- .../implementation/content/AssetType.java | 5 ----- .../content/ContentKeyRestType.java | 5 ----- .../media/implementation/content/JobType.java | 7 ------ .../content/LocatorRestType.java | 5 ----- .../implementation/content/TaskType.java | 5 ----- .../implementation/content/package-info.java | 22 +++++++++++++++++++ 8 files changed, 22 insertions(+), 37 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java index 7a51ad3434842..219a65b668f16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -20,9 +20,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Wrapper DTO for Media Services access policies. @@ -35,11 +32,9 @@ public class AccessPolicyType implements MediaServiceDTO { protected String id; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "Name", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java index 7017c0bd1fac1..55e9664bdff7d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java @@ -20,9 +20,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Serialization for the AssetFile entity @@ -63,11 +60,9 @@ public class AssetFileType implements MediaServiceDTO { protected Boolean isPrimary; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "MimeType", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index abd8210d1e39c..7cc7b9bd3cf22 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -20,9 +20,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -39,11 +36,9 @@ public class AssetType implements MediaServiceDTO { protected int state; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; @XmlElement(name = "AlternateId", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java index f5dee8ea239d4..5e5325703017e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -20,9 +20,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -38,12 +35,10 @@ public class ContentKeyRestType implements MediaServiceDTO { /** The created. */ @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; /** The last modified. */ @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; /** The content key type. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 764453363e06a..eb274041985fa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -21,9 +21,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -43,17 +40,14 @@ public class JobType implements MediaServiceDTO { /** The created. */ @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date created; /** The last modified. */ @XmlElement(name = "LastModified", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date lastModified; /** The end time. */ @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date endTime; /** The priority. */ @@ -66,7 +60,6 @@ public class JobType implements MediaServiceDTO { /** The start time. */ @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; /** The state. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index 2d1487017a0e2..63b0cbee4aa1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -20,9 +20,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * Wrapper DTO for Media Services Locator. @@ -37,7 +34,6 @@ public class LocatorRestType implements MediaServiceDTO { /** The expiration date time. */ @XmlElement(name = "ExpirationDateTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date expirationDateTime; /** The type. */ @@ -58,7 +54,6 @@ public class LocatorRestType implements MediaServiceDTO { /** The start time. */ @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; /** The base uri. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 71c1648e05e33..67d92f8620b72 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -21,9 +21,6 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; /** * This type maps the XML returned in the odata ATOM serialization @@ -40,7 +37,6 @@ public class TaskType implements MediaServiceDTO { protected String configuration; @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date endTime; @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) @@ -65,7 +61,6 @@ public class TaskType implements MediaServiceDTO { protected Double runningDuration; @XmlElement(name = "StartTime", namespace = Constants.ODATA_DATA_NS) - @XmlJavaTypeAdapter(ODataDateAdapter.class) protected Date startTime; @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java new file mode 100644 index 0000000000000..74e691082fe56 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java @@ -0,0 +1,22 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@XmlJavaTypeAdapter(value = ODataDateAdapter.class, type = java.util.Date.class) +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import com.microsoft.windowsazure.services.media.implementation.ODataDateAdapter; + From 670cc145d40ee79bbd16c7b0a727cdc6668cb36f Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 29 Nov 2012 11:17:38 -0800 Subject: [PATCH 506/664] Added test case for sub-second date precision parsing --- .../implementation/ODataDateParsingTest.java | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java index a4a84954a541b..a27be0737646d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -22,6 +22,7 @@ import java.util.GregorianCalendar; import java.util.TimeZone; +import org.junit.BeforeClass; import org.junit.Test; /** @@ -33,11 +34,20 @@ * */ public class ODataDateParsingTest { + private static TimeZone utc; + private static TimeZone pst; + + @BeforeClass + public static void setupClass() { + utc = TimeZone.getDefault(); + utc.setRawOffset(0); + + pst = TimeZone.getDefault(); + pst.setRawOffset(-8 * 60 * 60 * 1000); + } @Test public void canConvertDateToString() throws Exception { - TimeZone utc = TimeZone.getDefault(); - //utc.setRawOffset(0); Calendar sampleTime = new GregorianCalendar(2012, 11, 28, 17, 43, 12); sampleTime.setTimeZone(utc); @@ -56,9 +66,6 @@ public void stringWithTimezoneRoundTripsCorrectly() throws Exception { Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); - TimeZone pst = TimeZone.getDefault(); - pst.setRawOffset(-8 * 60 * 60 * 1000); - Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); expectedTime.setTimeZone(pst); @@ -71,9 +78,6 @@ public void stringWithUTCTimezoneRoundTripsCorrectly() throws Exception { Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); - TimeZone utc = TimeZone.getDefault(); - utc.setRawOffset(0); - Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); expectedTime.setTimeZone(utc); @@ -86,12 +90,41 @@ public void stringWithNoTimezoneActsAsUTC() throws Exception { Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); - TimeZone utc = TimeZone.getDefault(); - utc.setRawOffset(0); - Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); expectedTime.setTimeZone(utc); assertEquals(expectedTime.getTimeInMillis(), parsedTime.getTime()); } + + @Test + public void stringWithFractionalTimeReturnsCorrectMillisecondsTo100nsBoundary() throws Exception { + String exampleDate = "2012-11-28T17:43:12.1234567Z"; + + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + Calendar timeToNearestSecond = Calendar.getInstance(); + timeToNearestSecond.setTimeZone(utc); + timeToNearestSecond.set(2012, 10, 28, 17, 43, 12); + timeToNearestSecond.set(Calendar.MILLISECOND, 0); + + long millis = parsedTime.getTime() - timeToNearestSecond.getTimeInMillis(); + + assertEquals(123, millis); + } + + @Test + public void stringWithFractionalTimeReturnsCorrectMillisecondsAsFractionNotCount() throws Exception { + String exampleDate = "2012-11-28T17:43:12.1Z"; + + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + Calendar timeToNearestSecond = Calendar.getInstance(); + timeToNearestSecond.setTimeZone(utc); + timeToNearestSecond.set(2012, 10, 28, 17, 43, 12); + timeToNearestSecond.set(Calendar.MILLISECOND, 0); + + long millis = parsedTime.getTime() - timeToNearestSecond.getTimeInMillis(); + assertEquals(100, millis); + + } } From 0583f9073a418c74dc53cd6b1955815a5cecb6ce Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 29 Nov 2012 11:23:12 -0800 Subject: [PATCH 507/664] Added test to verify parsing of date with fractional seconds and explicit timezone offset --- .../media/implementation/ODataDateParsingTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java index a27be0737646d..06ecfdc4292ea 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -127,4 +127,17 @@ public void stringWithFractionalTimeReturnsCorrectMillisecondsAsFractionNotCount assertEquals(100, millis); } + + @Test + public void stringWithFractionalSecondsAndTimezoneOffsetParses() throws Exception { + String exampleDate = "2012-11-28T17:43:12.1-08:00"; + Date parsedTime = new ODataDateAdapter().unmarshal(exampleDate); + + Calendar expectedTime = new GregorianCalendar(2012, 10, 28, 17, 43, 12); + expectedTime.setTimeZone(pst); + expectedTime.set(Calendar.MILLISECOND, 100); + + assertEquals(expectedTime.getTimeInMillis(), parsedTime.getTime()); + + } } From a23f76bcdea4de013ab6d52ee8bab2406da0443b Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 29 Nov 2012 11:39:29 -0800 Subject: [PATCH 508/664] Confirming proper formatting when sending dates --- .../services/media/implementation/ODataDateAdapter.java | 6 ++++++ .../services/media/implementation/ODataDateParsingTest.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java index bc495dc0e46a4..51c7c368152dd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java @@ -17,6 +17,7 @@ import java.util.Calendar; import java.util.Date; +import java.util.TimeZone; import java.util.regex.Pattern; import javax.xml.bind.DatatypeConverter; @@ -30,9 +31,13 @@ public class ODataDateAdapter extends XmlAdapter<String, Date> { private final static Pattern hasTimezoneRegex; + private final static TimeZone utc; static { hasTimezoneRegex = Pattern.compile("^.*(\\+|-)\\d\\d:\\d\\d$"); + + utc = TimeZone.getDefault(); + utc.setRawOffset(0); } @Override @@ -48,6 +53,7 @@ public Date unmarshal(String dateString) throws Exception { public String marshal(Date date) throws Exception { Calendar dateToMarshal = Calendar.getInstance(); dateToMarshal.setTime(date); + dateToMarshal.setTimeZone(utc); return DatatypeConverter.printDateTime(dateToMarshal); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java index 06ecfdc4292ea..a6c39586bcd7a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -56,7 +56,7 @@ public void canConvertDateToString() throws Exception { String formatted = new ODataDateAdapter().marshal(sampleDate); - assertTrue(formatted.contains("2012")); + assertEquals("2012-12-28T17:43:12Z", formatted); } From e9cc3655d6661ed6ece3786242d67222a75627c0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 3 Dec 2012 16:34:45 -0800 Subject: [PATCH 509/664] re-enable job integration test. --- .../services/media/JobIntegrationTest.java | 72 ++++++++++++++++--- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 9a820dbf5897f..f19a3ae176f05 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -17,27 +17,38 @@ import static org.junit.Assert.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.net.URI; import java.util.ArrayList; +import java.util.Date; +import java.util.EnumSet; import java.util.List; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.Task; import com.sun.jersey.core.util.MultivaluedMapImpl; public class JobIntegrationTest extends IntegrationTestBase { private final String testJobPrefix = "testJobPrefix"; + private final byte[] testBlobData = new byte[] { 0, 1, 2 }; private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; @@ -47,6 +58,43 @@ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual expected.getOutputMediaAssets(), actual); } + private AccessPolicyInfo createWritableAccessPolicy(String name, int durationInMinutes) throws ServiceException { + return service.create(AccessPolicy.create(testPolicyPrefix + name, durationInMinutes, + EnumSet.of(AccessPolicyPermission.WRITE))); + } + + private void createAndUploadBlob(WritableBlobContainerContract blobWriter, String blobName, byte[] blobData) + throws ServiceException { + InputStream blobContent = new ByteArrayInputStream(blobData); + blobWriter.createBlockBlob(blobName, blobContent); + } + + private String createFileAsset(String name) throws ServiceException { + String testBlobName = "test" + name + ".bin"; + AssetInfo assetInfo = service.create(Asset.create().setName(name)); + AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy(name, 10); + LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + createAndUploadBlob(blobWriter, testBlobName, testBlobData); + + service.create(AssetFile.create(assetInfo.getId(), testBlobName).setIsPrimary(true).setIsEncrypted(false) + .setContentFileSize(new Long(testBlobData.length))); + + service.action(AssetFile.createFileInfos(assetInfo.getId())); + return assetInfo.getId(); + } + + private LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, + int expirationDeltaMinutes) throws ServiceException { + + Date now = new Date(); + Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); + Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); + + return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) + .setStartDateTime(start).setExpirationDateTime(expire)); + } + private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, Integer state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { @@ -63,20 +111,19 @@ private void verifyJobProperties(String message, String testName, Integer priori } private JobInfo createJob(String name) throws ServiceException { - AssetInfo assetInfo = service.create(Asset.create().setName(name)); + String assetId = createFileAsset(name); URI serviceUri = service.getRestServiceUri(); return service.create(Job .create(serviceUri) .setName("My Encoding Job") .setPriority(3) - .addInputMediaAsset(assetInfo.getId()) + .addInputMediaAsset(assetId) .addTaskCreator( Task.create().setConfiguration("H.264 256k DSL CBR") .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") .setName("My encoding Task").setTaskBody(taskBody))); } - @Ignore("due to issue 480") @Test public void createJobSuccess() throws Exception { // Arrange @@ -87,6 +134,17 @@ public void createJobSuccess() throws Exception { expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); expectedJob.setState(0); + + AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy("createJobSuccess", 10); + LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + createAndUploadBlob(blobWriter, "blob1.bin", testBlobData); + + service.create(AssetFile.create(assetInfo.getId(), "blob1.bin").setIsPrimary(true).setIsEncrypted(false) + .setContentFileSize(new Long(testBlobData.length))); + + service.action(AssetFile.createFileInfos(assetInfo.getId())); + URI serviceURI = service.getRestServiceUri(); // Act @@ -104,11 +162,9 @@ public void createJobSuccess() throws Exception { verifyJobInfoEqual("actualJob", expectedJob, actualJob); } - @Ignore("due to issue 480") @Test public void getJobSuccess() throws Exception { // Arrange - JobInfo expectedJob = new JobInfo(); expectedJob.setName("My Encoding Job"); expectedJob.setPriority(3); @@ -130,7 +186,6 @@ public void getJobInvalidIdFailed() throws ServiceException { service.get(Job.get(invalidId)); } - @Ignore("due to issue 480") @Test public void listJobSuccess() throws ServiceException { // Arrange @@ -151,7 +206,6 @@ public void verifyEquals(String message, Object expected, Object actual) { }); } - @Ignore("due to issue 480") @Test public void canListJobsWithOptions() throws ServiceException { String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", @@ -171,7 +225,6 @@ public void canListJobsWithOptions() throws ServiceException { assertEquals(2, listJobsResult.size()); } - @Ignore("due to issue 480") @Test public void cancelJobSuccess() throws Exception { // Arrange @@ -198,7 +251,6 @@ public void cancelJobFailedWithInvalidId() throws ServiceException { // Assert } - @Ignore("due to issue 480") @Test public void deleteJobSuccess() throws ServiceException { // Arrange From 766ef32782e4a8dc51b7a6f58b034e4d69c53ccb Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 3 Dec 2012 17:39:52 -0800 Subject: [PATCH 510/664] locator update according to latest info. --- .../windowsazure/services/media/models/LocatorType.java | 8 ++------ .../services/media/LocatorIntegrationTests.java | 6 +++--- .../services/media/models/LocatorInfoTest.java | 2 +- .../services/scenarios/MediaServiceWrapper.java | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index c88ea29782302..b1dae412b2a09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -27,9 +27,7 @@ public enum LocatorType { /** The sas. */ SAS(1), /** The Origin. */ - Origin(2), - /** The third party locator. */ - ThirdParty(3); + OnDemandOrigin(2); /** The locator type code. */ private int locatorTypeCode; @@ -67,9 +65,7 @@ public static LocatorType fromCode(int type) { case 1: return LocatorType.SAS; case 2: - return LocatorType.Origin; - case 3: - return LocatorType.ThirdParty; + return LocatorType.OnDemandOrigin; default: throw new InvalidParameterException("type"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 2004f583d5b90..fa1d1b4e46763 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -106,7 +106,7 @@ public void instanceSetup() throws Exception { @Test public void createLocatorSuccess() throws ServiceException { // Arrange - LocatorType locatorType = LocatorType.Origin; + LocatorType locatorType = LocatorType.SAS; Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act @@ -229,7 +229,7 @@ public void listLocatorsWithOptions() throws ServiceException { @Test public void updateLocatorSuccess() throws ServiceException { // Arrange - LocatorType locatorType = LocatorType.Origin; + LocatorType locatorType = LocatorType.OnDemandOrigin; LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType)); @@ -252,7 +252,7 @@ public void updateLocatorSuccess() throws ServiceException { @Test public void updateLocatorNoChangesSuccess() throws ServiceException { // Arrange - LocatorType locatorType = LocatorType.Origin; + LocatorType locatorType = LocatorType.OnDemandOrigin; Date expirationDateTime = new Date(); expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index 5fbc6ae4abd4e..5b5c4ab547698 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -52,7 +52,7 @@ public void testGetSetExpirationDateTime() { @Test public void testGetSetType() { // Arrange - LocatorType expectedLocatorType = LocatorType.Origin; + LocatorType expectedLocatorType = LocatorType.SAS; LocatorInfo locatorInfo = new LocatorInfo(); // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 8c6aa7d32e56d..6348f3b135eff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -38,9 +38,9 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -278,14 +278,14 @@ public void cancelJob(JobInfo job) throws InterruptedException { public List<URL> createOriginUrlsForStreamingContent(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, MalformedURLException { return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, "", - LocatorType.Origin); + LocatorType.OnDemandOrigin); } // Deliver public List<URL> createOriginUrlsForAppleHLSContent(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, MalformedURLException { return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, - "(format=m3u8-aapl)", LocatorType.Origin); + "(format=m3u8-aapl)", LocatorType.OnDemandOrigin); } // Deliver From 75fa3e17625ac415a68f812a8c231df863f4ef4f Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 4 Dec 2012 21:59:53 -0800 Subject: [PATCH 511/664] initial checkin for link --- .../entities/DefaultActionOperation.java | 18 +++- .../entities/EntityActionOperation.java | 4 + .../entities/EntityRestProxy.java | 6 +- .../services/media/models/Asset.java | 87 +++++++++++++++++-- .../services/media/models/AssetInfo.java | 7 ++ .../services/media/AssetIntegrationTest.java | 45 ++++++++++ 6 files changed, 157 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index baa0332169ced..6b267146a7a61 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -28,10 +28,10 @@ public class DefaultActionOperation implements EntityActionOperation { /** The name. */ - private final String name; + protected String name; /** The query parameters. */ - private final MultivaluedMap<String, String> queryParameters; + protected final MultivaluedMap<String, String> queryParameters; /** * The default action operation. @@ -40,7 +40,11 @@ public class DefaultActionOperation implements EntityActionOperation { * the name */ public DefaultActionOperation(String name) { + this(); this.name = name; + } + + public DefaultActionOperation() { this.queryParameters = new MultivaluedMapImpl(); } @@ -92,4 +96,14 @@ public MediaType getAcceptType() { public void processResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); } + + @Override + public String getVerb() { + return "GET"; + } + + @Override + public Object getRequestContents() { + return null; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 5b575ab34896e..570ea107dd325 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -49,4 +49,8 @@ public interface EntityActionOperation extends EntityOperation { * the client response */ void processResponse(ClientResponse clientResponse); + + String getVerb(); + + Object getRequestContents(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 29ec3958793e4..11ce9ffe98d24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -145,8 +145,10 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { */ @Override public void action(EntityActionOperation entityActionOperation) throws ServiceException { - ClientResponse clientResponse = getResource(entityActionOperation.getUri()).queryParams( - entityActionOperation.getQueryParameters()).get(ClientResponse.class); + WebResource webResource = getResource(entityActionOperation.getUri()).queryParams( + entityActionOperation.getQueryParameters()); + ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class, + entityActionOperation.getRequestContents()); entityActionOperation.processResponse(clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 172470300362e..6b176b611ac6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; + import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; @@ -24,6 +26,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; @@ -35,27 +38,54 @@ * */ public class Asset { + + /** The Constant ENTITY_SET. */ private static final String ENTITY_SET = "Assets"; // Prevent instantiation + /** + * Instantiates a new asset. + */ private Asset() { } + /** + * Creates the. + * + * @return the creator + */ public static Creator create() { return new Creator(); } + /** + * The Class Creator. + */ public static class Creator extends EntityOperationSingleResultBase<AssetInfo> implements EntityCreationOperation<AssetInfo> { + + /** The name. */ private String name; + + /** The alternate id. */ private String alternateId; + + /** The options. */ private EncryptionOption options; + + /** The state. */ private AssetState state; + /** + * Instantiates a new creator. + */ public Creator() { super(ENTITY_SET, AssetInfo.class); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + */ @Override public Object getRequestContents() { AssetType assetType = new AssetType(); @@ -71,7 +101,7 @@ public Object getRequestContents() { } /** - * Set the name of the asset to be created + * Set the name of the asset to be created. * * @param name * The name @@ -95,11 +125,25 @@ public Creator setAlternateId(String alternateId) { return this; } + /** + * Sets the options. + * + * @param options + * the options + * @return the creator + */ public Creator setOptions(EncryptionOption options) { this.options = options; return this; } + /** + * Sets the state. + * + * @param state + * the state + * @return the creator + */ public Creator setState(AssetState state) { this.state = state; return this; @@ -128,7 +172,7 @@ public static EntityListOperation<AssetInfo> list() { } /** - * Create an operation that will list all the assets which match the given query parameters + * Create an operation that will list all the assets which match the given query parameters. * * @param queryParameters * query parameters to pass to the server. @@ -140,7 +184,7 @@ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> } /** - * Create an operation that will update the given asset + * Create an operation that will update the given asset. * * @param assetId * id of the asset to update @@ -150,14 +194,30 @@ public static Updater update(String assetId) { return new Updater(assetId); } + /** + * The Class Updater. + */ public static class Updater extends EntityOperationBase implements EntityUpdateOperation { + + /** The name. */ private String name; + + /** The alternate id. */ private String alternateId; + /** + * Instantiates a new updater. + * + * @param assetId + * the asset id + */ protected Updater(String assetId) { super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, assetId)); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents() + */ @Override public Object getRequestContents() { AssetType assetType = new AssetType(); @@ -167,7 +227,7 @@ public Object getRequestContents() { } /** - * Sets new name for asset + * Sets new name for asset. * * @param name * The new name @@ -179,7 +239,7 @@ public Updater setName(String name) { } /** - * Sets new alternate id for asset + * Sets new alternate id for asset. * * @param alternateId * the new alternate id @@ -192,7 +252,7 @@ public Updater setAlternateId(String alternateId) { } /** - * Create an operation to delete the given asset + * Create an operation to delete the given asset. * * @param assetId * id of asset to delete @@ -201,4 +261,19 @@ public Updater setAlternateId(String alternateId) { public static EntityDeleteOperation delete(String assetId) { return new DefaultDeleteOperation(ENTITY_SET, assetId); } + + /** + * Link content key. + * + * @param assetId + * the asset id + * @param contentKeyUri + * the content key uri + * @return the entity action operation + */ + public static EntityLinkOperation linkContentKey(String assetId, URI contentKeyUri) { + + return new EntityLinkOperation("Assets", assetId, "ContentKeys", contentKeyUri); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index e187f252f9b29..be05f46b66a7b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,10 +15,13 @@ package com.microsoft.windowsazure.services.media.models; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; /** @@ -193,4 +196,8 @@ public AssetInfo setOptions(EncryptionOption encryptionOption) { return this; } + public List<LinkType> getLinkedContentKeys() { + return new ArrayList<LinkType>(); + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index b6ba98ac94d9a..c8153ddf875b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -17,17 +17,24 @@ import static org.junit.Assert.*; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.UUID; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; +import com.microsoft.windowsazure.services.media.models.ContentKey; +import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; +import com.microsoft.windowsazure.services.media.models.ContentKeyType; import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -268,4 +275,42 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { expectedException.expect(new ServiceExceptionMatcher(404)); service.delete(Asset.delete(validButNonexistAssetId)); } + + @Test + public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { + // Arrange + String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; + AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName)); + String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); + String encryptedContentKey = "dummyEncryptedContentKey"; + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, ContentKeyType.CommonEncryption, + encryptedContentKey)); + URI serviceUri = service.getRestServiceUri(); + URI contentKeyUri = new URI(String.format("%s/ContentKeys('%s')", serviceUri, contentKeyId)); + + // Act + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); + + // Assert + AssetInfo retrievedAssetInfo = service.get(Asset.get(assetInfo.getId())); + List<LinkType> links = retrievedAssetInfo.getLinkedContentKeys(); + LinkType contentKeyLink = links.get(0); + assertEquals(contentKeyUri, contentKeyLink.getHref()); + + } + + @Test + public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyntaxException { + // Arrange + String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; + URI invalidContentKeyUri = new URI("https://server/api/ContentKeys('nb:kid:UUID:invalidContentKeyId')"); + + // Act + expectedException.expect(ServiceException.class); + expectedException.expect(new ServiceExceptionMatcher(404)); + service.action(Asset.linkContentKey(validButNonexistAssetId, invalidContentKeyUri)); + + // Assert + + } } From 4af123acb03d0c7612b3ff21f5ce1ec0c1f17dc7 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 4 Dec 2012 22:01:53 -0800 Subject: [PATCH 512/664] adds EntityLinkOperation --- .../entities/EntityLinkOperation.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java new file mode 100644 index 0000000000000..c1a2f05a76ebe --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -0,0 +1,79 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.entities; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URLEncoder; +import java.security.InvalidParameterException; + +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.sun.jersey.api.client.ClientResponse; + +/** + * Generic implementation of Delete operation usable by most entities. + */ +public class EntityLinkOperation extends DefaultActionOperation { + + private final String masterEntitySet; + private final String masterEntityId; + private final String slaveEntitySet; + private final URI slaveEntityUri; + + public EntityLinkOperation(String masterEntitySet, String masterEntityId, String slaveEntitySet, URI slaveEntityUri) { + super(); + this.masterEntitySet = masterEntitySet; + this.masterEntityId = masterEntityId; + this.slaveEntitySet = slaveEntitySet; + this.slaveEntityUri = slaveEntityUri; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation#getUri() + */ + @Override + public String getUri() { + String escapedEntityId; + try { + escapedEntityId = URLEncoder.encode(masterEntityId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(masterEntityId); + } + return String.format("%s('%s')/%s", masterEntitySet, escapedEntityId, slaveEntitySet); + } + + @Override + public String getVerb() { + return "POST"; + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + */ + @Override + public void processResponse(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + } + + @Override + public Object getRequestContents() { + EntryType entryType = new EntryType(); + return entryType; + + } +} From d4039db2eb1001e7ea81a99ce3f590d05808bf03 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 6 Dec 2012 22:36:32 -0800 Subject: [PATCH 513/664] implementing GetProtectionKeyId and GetProtectionKey --- .../MediaExceptionProcessor.java | 4 +- .../media/implementation/MediaRestProxy.java | 7 +- .../content/ProtectionKeyIdType.java | 50 +++++ .../content/ProtectionKeyRestType.java | 49 +++++ .../entities/DefaultActionOperation.java | 40 +++- .../entities/EntityActionOperation.java | 3 +- .../entities/EntityContract.java | 3 +- .../entities/EntityRestProxy.java | 9 +- .../services/media/models/ContentKey.java | 7 +- .../services/media/models/ProtectionKey.java | 202 ++++++++++++++++++ .../media/ContentKeyIntegrationTest.java | 2 +- 11 files changed, 358 insertions(+), 18 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 9f827fe02a0dd..cc8ad049d972f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -176,9 +176,9 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ @Override - public void action(EntityActionOperation action) throws ServiceException { + public Object action(EntityActionOperation action) throws ServiceException { try { - service.action(action); + return service.action(action); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 166f4ea47275c..3952c822c88f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -29,13 +29,13 @@ import com.sun.jersey.api.client.Client; /** - * - * + * The Class MediaRestProxy. */ public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The log. */ static Log log = LogFactory.getLog(MediaContract.class); + /** The redirect filter. */ private RedirectFilter redirectFilter; /** @@ -84,6 +84,9 @@ public MediaContract withFilter(ServiceFilter filter) { return new MediaRestProxy(getChannel(), newFilters); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#getRestServiceUri() + */ @Override public URI getRestServiceUri() { return this.redirectFilter.getBaseURI(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java new file mode 100644 index 0000000000000..b59c6f2e157b4 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java @@ -0,0 +1,50 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "GetProtectionKeyId", namespace = Constants.ODATA_DATA_NS) +public class ProtectionKeyIdType implements MediaServiceDTO { + @XmlValue + String protectionKeyId; + + /** + * @return the protection key id + */ + public String getProtectionKeyId() { + return protectionKeyId; + } + + /** + * @param protection + * key id + * the protection key id to set + */ + public void setProtectionKeyId(String protectionKeyId) { + this.protectionKeyId = protectionKeyId; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java new file mode 100644 index 0000000000000..7d08a6b780b40 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java @@ -0,0 +1,49 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +/** + * This type maps the XML returned in protection key. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "GetProtectionKey", namespace = Constants.ODATA_DATA_NS) +public class ProtectionKeyRestType implements MediaServiceDTO { + @XmlValue + String protectionKey; + + /** + * @return the protection key + */ + public String getProtectionKey() { + return protectionKey; + } + + /** + * @param protection + * key id + * the protection key id to set + */ + public void setProtectionKey(String protectionKey) { + this.protectionKey = protectionKey; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index baa0332169ced..0da3c95815eec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -30,6 +30,12 @@ public class DefaultActionOperation implements EntityActionOperation { /** The name. */ private final String name; + /** The content type. */ + private MediaType contentType = MediaType.APPLICATION_ATOM_XML_TYPE; + + /** The accept type. */ + private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE; + /** The query parameters. */ private final MultivaluedMap<String, String> queryParameters; @@ -64,7 +70,7 @@ public MultivaluedMap<String, String> getQueryParameters() { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) */ @Override - public EntityActionOperation addQueryParameter(String key, String value) { + public DefaultActionOperation addQueryParameter(String key, String value) { this.queryParameters.add(key, value); return this; } @@ -74,7 +80,19 @@ public EntityActionOperation addQueryParameter(String key, String value) { */ @Override public MediaType getContentType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; + return this.contentType; + } + + /** + * Sets the content type. + * + * @param contentType + * the content type + * @return the default action operation + */ + public DefaultActionOperation setContentType(MediaType contentType) { + this.contentType = contentType; + return this; } /* (non-Javadoc) @@ -82,14 +100,28 @@ public MediaType getContentType() { */ @Override public MediaType getAcceptType() { - return MediaType.APPLICATION_ATOM_XML_TYPE; + return this.acceptType; + } + + /** + * Sets the accept type. + * + * @param acceptType + * the accept type + * @return the default action operation + */ + public DefaultActionOperation setAcceptType(MediaType acceptType) { + this.acceptType = acceptType; + return this; } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override - public void processResponse(ClientResponse clientResponse) { + public Object processResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); + return null; } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 5b575ab34896e..b62a74ad1da1c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -47,6 +47,7 @@ public interface EntityActionOperation extends EntityOperation { * * @param clientResponse * the client response + * @return */ - void processResponse(ClientResponse clientResponse); + Object processResponse(ClientResponse clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index 7919309a56b99..e317ba1065244 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -79,8 +79,9 @@ public interface EntityContract { * * @param action * Object providing details of the action + * @return * @throws ServiceException */ - public abstract void action(EntityActionOperation action) throws ServiceException; + public abstract Object action(EntityActionOperation action) throws ServiceException; } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 29ec3958793e4..240fe5ed6892c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -144,10 +144,11 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ @Override - public void action(EntityActionOperation entityActionOperation) throws ServiceException { - ClientResponse clientResponse = getResource(entityActionOperation.getUri()).queryParams( - entityActionOperation.getQueryParameters()).get(ClientResponse.class); - entityActionOperation.processResponse(clientResponse); + public Object action(EntityActionOperation entityActionOperation) throws ServiceException { + ClientResponse clientResponse = getResource(entityActionOperation.getUri()) + .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType()) + .get(ClientResponse.class); + return entityActionOperation.processResponse(clientResponse); } } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index b32ac551a3709..1ca7827c3be8d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -65,13 +65,13 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn EntityCreationOperation<ContentKeyInfo> { /** The id. */ - private String id; + private final String id; /** The content key type. */ - private ContentKeyType contentKeyType; + private final ContentKeyType contentKeyType; /** The encrypted content key. */ - private String encryptedContentKey; + private final String encryptedContentKey; /** The name. */ private String name; @@ -182,4 +182,5 @@ public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, St public static EntityDeleteOperation delete(String ContentKeyId) { return new DefaultDeleteOperation(ENTITY_SET, ContentKeyId); } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java new file mode 100644 index 0000000000000..5c3dbf79171fd --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -0,0 +1,202 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.io.InputStream; + +import javax.ws.rs.core.MediaType; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; + +import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyIdType; +import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyRestType; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; +import com.sun.jersey.api.client.ClientResponse; + +/** + * Class for creating operations to manipulate protection key pseudo-entities. + * + */ +public class ProtectionKey { + + /** + * Gets the protection key id. + * + * @param contentKeyType + * the content key type + * @return the protection key id + */ + public static EntityActionOperation getProtectionKeyId(ContentKeyType contentKeyType) { + return new GetProtectionKeyIdActionOperation("GetProtectionKeyId").addQueryParameter("contentKeyType", + String.format("%d", contentKeyType.getCode())).setAcceptType(MediaType.APPLICATION_XML_TYPE); + } + + /** + * Gets the protection key. + * + * @param protectionKeyId + * the protection key id + * @return the protection key + */ + public static EntityActionOperation getProtectionKey(String protectionKeyId) { + return new GetProtectionKeyActionOperation("GetProtectionKey").addQueryParameter("ProtectionKeyId", + String.format("'%s'", protectionKeyId)).setAcceptType(MediaType.APPLICATION_XML_TYPE); + } + + /** + * The Class GetProtectionKeyIdActionOperation. + */ + private static class GetProtectionKeyIdActionOperation extends DefaultActionOperation { + + /** The jaxb context. */ + private final JAXBContext jaxbContext; + + /** The unmarshaller. */ + private final Unmarshaller unmarshaller; + + /** + * Instantiates a new gets the protection key id action operation. + * + * @param name + * the name + */ + public GetProtectionKeyIdActionOperation(String name) { + super(name); + try { + jaxbContext = JAXBContext.newInstance(ProtectionKeyIdType.class); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + + try { + unmarshaller = jaxbContext.createUnmarshaller(); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + */ + @Override + public Object processResponse(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + ProtectionKeyIdType protectionKeyIdType; + try { + protectionKeyIdType = parseResponse(clientResponse); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + + return protectionKeyIdType.getProtectionKeyId(); + } + + /** + * Parses the response. + * + * @param clientResponse + * the client response + * @return the protection key id type + * @throws JAXBException + * the jAXB exception + */ + private ProtectionKeyIdType parseResponse(ClientResponse clientResponse) throws JAXBException { + + InputStream inputStream = clientResponse.getEntityInputStream(); + JAXBElement<ProtectionKeyIdType> protectionKeyIdTypeJaxbElement = unmarshaller.unmarshal(new StreamSource( + inputStream), ProtectionKeyIdType.class); + return protectionKeyIdTypeJaxbElement.getValue(); + + } + } + + /** + * The Class GetProtectionKeyActionOperation. + */ + private static class GetProtectionKeyActionOperation extends DefaultActionOperation { + + /** The jaxb context. */ + private final JAXBContext jaxbContext; + + /** The unmarshaller. */ + private final Unmarshaller unmarshaller; + + /** + * Instantiates a new gets the protection key action operation. + * + * @param name + * the name + */ + public GetProtectionKeyActionOperation(String name) { + super(name); + try { + jaxbContext = JAXBContext.newInstance(ProtectionKeyRestType.class); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + + try { + unmarshaller = jaxbContext.createUnmarshaller(); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + */ + @Override + public Object processResponse(ClientResponse clientResponse) { + PipelineHelpers.ThrowIfNotSuccess(clientResponse); + ProtectionKeyRestType protectionKeyRestType; + try { + protectionKeyRestType = parseResponse(clientResponse); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + + return protectionKeyRestType.getProtectionKey(); + } + + /** + * Parses the response. + * + * @param clientResponse + * the client response + * @return the protection key rest type + * @throws JAXBException + * the jAXB exception + */ + private ProtectionKeyRestType parseResponse(ClientResponse clientResponse) throws JAXBException { + InputStream inputStream = clientResponse.getEntityInputStream(); + JAXBElement<ProtectionKeyRestType> protectionKeyTypeJaxbElement = unmarshaller.unmarshal(new StreamSource( + inputStream), ProtectionKeyRestType.class); + return protectionKeyTypeJaxbElement.getValue(); + + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 6c2c30176e9ec..4f5975be291c8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -150,7 +150,7 @@ public void canUseQueryParametersWhenListingContentKeys() throws Exception { public void canDeleteContentKeyById() throws Exception { String contentKeyName = testContentKeyPrefix + "ToDelete"; ContentKeyInfo contentKeyToDelete = service.create(ContentKey.create(createRandomContentKeyId(), - testContentKeyType, testEncryptedContentKey)); + testContentKeyType, testEncryptedContentKey).setName(contentKeyName)); List<ContentKeyInfo> listContentKeysResult = service.list(ContentKey.list()); int ContentKeyCountBaseline = listContentKeysResult.size(); From 084783330fed764d56c40fbb6324547bcf9ed7a1 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 6 Dec 2012 22:37:00 -0800 Subject: [PATCH 514/664] add unit test for ProtectionKeyIntegrationTest.java --- .../media/ProtectionKeyIntegrationTest.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java new file mode 100644 index 0000000000000..f3f1f07f4e724 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java @@ -0,0 +1,53 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; + +public class ProtectionKeyIntegrationTest extends IntegrationTestBase { + + @Test + public void canGetProtectionKeyId() throws ServiceException { + // Arrange + + // Act + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.CommonEncryption)); + + // Assert + assertNotNull(protectionKeyId); + } + + @Test + public void canGetProtectionKey() throws ServiceException { + // Arrange + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.CommonEncryption)); + + // Act + String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + + // Assert + assertNotNull(protectionKey); + } + +} From d9d0aade332375a5a98b39a187e1fc3a9bb6639e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 9 Dec 2012 18:54:51 -0800 Subject: [PATCH 515/664] implementation of the content key linking. --- .../entities/EntityLinkOperation.java | 11 ++++--- .../entities/EntityRestProxy.java | 13 +++++--- .../services/media/models/AssetInfo.java | 21 +++++++++++-- .../services/media/models/ContentKey.java | 6 ++-- .../services/media/AssetIntegrationTest.java | 30 +++++++++++++------ 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index c1a2f05a76ebe..ce70fa9a9c288 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -21,7 +21,6 @@ import java.security.InvalidParameterException; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; -import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.sun.jersey.api.client.ClientResponse; /** @@ -54,7 +53,7 @@ public String getUri() { catch (UnsupportedEncodingException e) { throw new InvalidParameterException(masterEntityId); } - return String.format("%s('%s')/%s", masterEntitySet, escapedEntityId, slaveEntitySet); + return String.format("%s('%s')/$links/%s", masterEntitySet, escapedEntityId, slaveEntitySet); } @Override @@ -72,8 +71,12 @@ public void processResponse(ClientResponse clientResponse) { @Override public Object getRequestContents() { - EntryType entryType = new EntryType(); - return entryType; + // EntryType entryType = new EntryType(); + // return entryType; + String result = String + .format("<?xml version=\"1.0\" encoding=\"utf-8\"?><uri xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">%s</uri>", + this.slaveEntityUri); + return result; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 11ce9ffe98d24..df2d540e4a082 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media.implementation.entities; +import javax.ws.rs.core.MediaType; + import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.pipeline.ClientFilterAdapter; @@ -145,10 +147,13 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { */ @Override public void action(EntityActionOperation entityActionOperation) throws ServiceException { - WebResource webResource = getResource(entityActionOperation.getUri()).queryParams( - entityActionOperation.getQueryParameters()); - ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class, - entityActionOperation.getRequestContents()); + Builder webResource = getResource(entityActionOperation.getUri()) + .queryParams(entityActionOperation.getQueryParameters()).accept(MediaType.APPLICATION_ATOM_XML_TYPE) + .accept(MediaType.APPLICATION_XML_TYPE) + .entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); + ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class); + //, + // entityActionOperation.getRequestContents()); entityActionOperation.processResponse(clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index be05f46b66a7b..dee28d95ba8f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,10 +15,13 @@ package com.microsoft.windowsazure.services.media.models; +import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.List; +import javax.xml.bind.JAXBElement; + import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; @@ -196,8 +199,22 @@ public AssetInfo setOptions(EncryptionOption encryptionOption) { return this; } - public List<LinkType> getLinkedContentKeys() { - return new ArrayList<LinkType>(); + public List<URI> getContentKeyLinks() { + List<Object> children = getEntry().getEntryChildren(); + List<URI> contentKeyLinks = new ArrayList<URI>(); + for (Object object : children) { + if (object instanceof JAXBElement<?>) { + Object valueObject = ((JAXBElement) object).getValue(); + if (valueObject instanceof LinkType) { + LinkType linkType = (LinkType) valueObject; + if ((linkType != null) && (linkType.getTitle().equals("ContentKeys"))) { + URI uri = URI.create(linkType.getHref()); + contentKeyLinks.add(uri); + } + } + } + } + return contentKeyLinks; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index b32ac551a3709..2b6b5b4d9f627 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -65,13 +65,13 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn EntityCreationOperation<ContentKeyInfo> { /** The id. */ - private String id; + private final String id; /** The content key type. */ - private ContentKeyType contentKeyType; + private final ContentKeyType contentKeyType; /** The encrypted content key. */ - private String encryptedContentKey; + private final String encryptedContentKey; /** The name. */ private String name; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index c8153ddf875b7..606d53dd22c8d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -17,18 +17,21 @@ import static org.junit.Assert.*; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import java.util.UUID; +import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; @@ -276,26 +279,35 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { service.delete(Asset.delete(validButNonexistAssetId)); } + @Ignore("due to issue 507") @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; - AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName)); + AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) + .setOptions(EncryptionOption.StorageEncrypted)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, ContentKeyType.CommonEncryption, - encryptedContentKey)); + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, + ContentKeyType.StorageEncryption, encryptedContentKey)); URI serviceUri = service.getRestServiceUri(); - URI contentKeyUri = new URI(String.format("%s/ContentKeys('%s')", serviceUri, contentKeyId)); + String escapedContentKeyId; + try { + escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException(contentKeyId); + } + URI contentKeyUri = new URI(String.format("%sContentKeys('%s')", serviceUri, escapedContentKeyId)); // Act service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); // Assert - AssetInfo retrievedAssetInfo = service.get(Asset.get(assetInfo.getId())); - List<LinkType> links = retrievedAssetInfo.getLinkedContentKeys(); - LinkType contentKeyLink = links.get(0); - assertEquals(contentKeyUri, contentKeyLink.getHref()); + + // List<ContentKeyInfo> contentKeyInfos = service.list(ContentKey.list(assetInfo.getId())); + // ContentKeyInfo contentKeyInfo = contentKeyInfos.get(0) + // assertEquals(contentKeyId, contentKeyInfo.getId()); } From ffbd4b32b86272259afd541a7ffba2cd649261b5 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 9 Dec 2012 18:58:29 -0800 Subject: [PATCH 516/664] self code review feedback. --- .../entities/EntityRestProxy.java | 2 -- .../services/media/models/AssetInfo.java | 24 ------------------- 2 files changed, 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index df2d540e4a082..94f4d9b9e607d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -152,8 +152,6 @@ public void action(EntityActionOperation entityActionOperation) throws ServiceEx .accept(MediaType.APPLICATION_XML_TYPE) .entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class); - //, - // entityActionOperation.getRequestContents()); entityActionOperation.processResponse(clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index dee28d95ba8f3..e187f252f9b29 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -15,16 +15,10 @@ package com.microsoft.windowsazure.services.media.models; -import java.net.URI; -import java.util.ArrayList; import java.util.Date; -import java.util.List; - -import javax.xml.bind.JAXBElement; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; -import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; /** @@ -199,22 +193,4 @@ public AssetInfo setOptions(EncryptionOption encryptionOption) { return this; } - public List<URI> getContentKeyLinks() { - List<Object> children = getEntry().getEntryChildren(); - List<URI> contentKeyLinks = new ArrayList<URI>(); - for (Object object : children) { - if (object instanceof JAXBElement<?>) { - Object valueObject = ((JAXBElement) object).getValue(); - if (valueObject instanceof LinkType) { - LinkType linkType = (LinkType) valueObject; - if ((linkType != null) && (linkType.getTitle().equals("ContentKeys"))) { - URI uri = URI.create(linkType.getHref()); - contentKeyLinks.add(uri); - } - } - } - } - return contentKeyLinks; - } - } From 515218daeb4895325c85dee0819589c9e4d1c49b Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 9 Dec 2012 19:53:09 -0800 Subject: [PATCH 517/664] resolving differences during code merging. --- .../entities/DefaultActionOperation.java | 12 ++++++-- .../entities/EntityLinkOperation.java | 30 +++++++++++++++++-- .../entities/EntityRestProxy.java | 2 +- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index f756ce0fee5dc..58733f37cd53c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -50,6 +50,9 @@ public DefaultActionOperation(String name) { this.name = name; } + /** + * Instantiates a new default action operation. + */ public DefaultActionOperation() { this.queryParameters = new MultivaluedMapImpl(); } @@ -128,16 +131,19 @@ public Object processResponse(ClientResponse clientResponse) { return null; } -<<<<<<< HEAD + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getVerb() + */ @Override public String getVerb() { return "GET"; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getRequestContents() + */ @Override public Object getRequestContents() { return null; } -======= ->>>>>>> 56132c721e587657bb3708b9589313b1e7366bea } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index ce70fa9a9c288..92407d2b44567 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -28,11 +28,30 @@ */ public class EntityLinkOperation extends DefaultActionOperation { + /** The master entity set. */ private final String masterEntitySet; + + /** The master entity id. */ private final String masterEntityId; + + /** The slave entity set. */ private final String slaveEntitySet; + + /** The slave entity uri. */ private final URI slaveEntityUri; + /** + * Instantiates a new entity link operation. + * + * @param masterEntitySet + * the master entity set + * @param masterEntityId + * the master entity id + * @param slaveEntitySet + * the slave entity set + * @param slaveEntityUri + * the slave entity uri + */ public EntityLinkOperation(String masterEntitySet, String masterEntityId, String slaveEntitySet, URI slaveEntityUri) { super(); this.masterEntitySet = masterEntitySet; @@ -56,6 +75,9 @@ public String getUri() { return String.format("%s('%s')/$links/%s", masterEntitySet, escapedEntityId, slaveEntitySet); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#getVerb() + */ @Override public String getVerb() { return "POST"; @@ -65,14 +87,16 @@ public String getVerb() { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override - public void processResponse(ClientResponse clientResponse) { + public Object processResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); + return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#getRequestContents() + */ @Override public Object getRequestContents() { - // EntryType entryType = new EntryType(); - // return entryType; String result = String .format("<?xml version=\"1.0\" encoding=\"utf-8\"?><uri xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">%s</uri>", this.slaveEntityUri); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 484117ff364d5..cfa4f2e5183f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -146,7 +146,7 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ @Override - public void action(EntityActionOperation entityActionOperation) throws ServiceException { + public Object action(EntityActionOperation entityActionOperation) throws ServiceException { Builder webResource = getResource(entityActionOperation.getUri()) .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType()) .accept(MediaType.APPLICATION_XML_TYPE) From ab24a571fad362a5a60f667c28c0f3a6cc3c4d4b Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 9 Dec 2012 20:03:29 -0800 Subject: [PATCH 518/664] harmonize a failed unit test. --- .../windowsazure/services/media/AssetIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 606d53dd22c8d..8696fb1819bdb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -319,7 +319,7 @@ public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyn // Act expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(404)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.action(Asset.linkContentKey(validButNonexistAssetId, invalidContentKeyUri)); // Assert From 6b8529166ceaa611784bbcba8c0a6373fc838a44 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 9 Dec 2012 22:03:31 -0800 Subject: [PATCH 519/664] implementation of job state --- .../services/media/models/JobInfo.java | 8 +- .../services/media/models/JobState.java | 94 +++++++++++++++++++ .../services/media/JobIntegrationTest.java | 11 ++- 3 files changed, 104 insertions(+), 9 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index a1a2e53b8a149..627081d001de7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -219,8 +219,8 @@ public JobInfo setStartTime(Date startTime) { * * @return the state */ - public Integer getState() { - return getContent().getState(); + public JobState getState() { + return JobState.fromCode(getContent().getState()); } /** @@ -230,8 +230,8 @@ public Integer getState() { * the state * @return the job info */ - public JobInfo setState(Integer state) { - getContent().setState(state); + public JobInfo setState(JobState state) { + getContent().setState(state.getCode()); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java new file mode 100644 index 0000000000000..f4a4428c4d24c --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java @@ -0,0 +1,94 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.security.InvalidParameterException; + +/** + * The Enum JobState. + */ +public enum JobState { + /** The Queued. */ + Queued(0), + + /** The Scheduled. */ + Scheduled(1), + + /** The Processing. */ + Processing(2), + + /** The Finished. */ + Finished(3), + + /** The Error. */ + Error(4), + + /** The Canceled. */ + Canceled(5), + + /** The Canceling. */ + Canceling(6); + + /** The job state code. */ + private int jobStateCode; + + /** + * Instantiates a new job state. + * + * @param jobStateCode + * the job state code + */ + private JobState(int jobStateCode) { + this.jobStateCode = jobStateCode; + } + + /** + * Gets the code. + * + * @return the code + */ + public int getCode() { + return this.jobStateCode; + } + + /** + * From code. + * + * @param jobStateCode + * the job state code + * @return the job state + */ + public static JobState fromCode(int jobStateCode) { + switch (jobStateCode) { + case 0: + return JobState.Queued; + case 1: + return JobState.Scheduled; + case 2: + return JobState.Processing; + case 3: + return JobState.Finished; + case 4: + return JobState.Error; + case 5: + return JobState.Canceled; + case 6: + return JobState.Canceling; + default: + throw new InvalidParameterException("jobStateCode"); + } + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index f19a3ae176f05..e21f95db164a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -38,6 +38,7 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -96,7 +97,7 @@ private LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset } private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, - Integer state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, + JobState state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { assertNotNull(message, actualJob); assertEquals(message + " Name", testName, actualJob.getName()); @@ -133,7 +134,7 @@ public void createJobSuccess() throws Exception { expectedJob.setName("My Encoding Job"); expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); - expectedJob.setState(0); + expectedJob.setState(JobState.Queued); AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy("createJobSuccess", 10); LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); @@ -169,7 +170,7 @@ public void getJobSuccess() throws Exception { expectedJob.setName("My Encoding Job"); expectedJob.setPriority(3); expectedJob.setRunningDuration(0.0); - expectedJob.setState(0); + expectedJob.setState(JobState.Queued); String jobId = createJob("getJobSuccess").getId(); // Act @@ -235,7 +236,7 @@ public void cancelJobSuccess() throws Exception { // Assert JobInfo canceledJob = service.get(Job.get(jobInfo.getId())); - assertEquals((Integer) 6, canceledJob.getState()); + assertEquals(6, canceledJob.getState()); } @@ -257,7 +258,7 @@ public void deleteJobSuccess() throws ServiceException { JobInfo jobInfo = createJob("deleteJobSuccess"); service.action(Job.cancel(jobInfo.getId())); JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); - while (cancellingJobInfo.getState() == 6) { + while (cancellingJobInfo.getState() == JobState.Canceling) { cancellingJobInfo = service.get(Job.get(jobInfo.getId())); } From d9732c8ea7f67244558c1dd857362bd2456b069c Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 10 Dec 2012 10:21:38 -0800 Subject: [PATCH 520/664] enable specifying id during locator creation. --- .../services/media/models/Locator.java | 19 +++++++++++++++++-- .../media/LocatorIntegrationTests.java | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index c03c6d34b4cf1..51a391c89e805 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -31,7 +31,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; -// TODO: Auto-generated Javadoc /** * Implementation of Locator entity. */ @@ -91,6 +90,9 @@ public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> /** The start date time. */ private Date startDateTime; + /** The id. */ + private String id; + /** * Instantiates a new creator. * @@ -113,7 +115,7 @@ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType */ @Override public Object getRequestContents() { - return new LocatorRestType().setAccessPolicyId(accessPolicyId).setAssetId(assetId) + return new LocatorRestType().setId(id).setAccessPolicyId(accessPolicyId).setAssetId(assetId) .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) .setType(locatorType.getCode()).setBaseUri(baseUri) .setContentAccessComponent(contentAccessComponent).setPath(path); @@ -171,12 +173,25 @@ public Creator setExpirationDateTime(Date expirationDateTime) { * Sets the content access component. * * @param contentAccessComponent + * the content access component * @return The creator instance */ public Creator setContentAccessComponent(String contentAccessComponent) { this.contentAccessComponent = contentAccessComponent; return this; } + + /** + * Sets the id. + * + * @param id + * the id + * @return the entity creation operation + */ + public EntityCreationOperation<LocatorInfo> setId(String id) { + this.id = id; + return this; + } } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index fa1d1b4e46763..9ed949a1b0704 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -21,6 +21,7 @@ import java.util.Date; import java.util.EnumSet; import java.util.List; +import java.util.UUID; import org.junit.Before; import org.junit.BeforeClass; @@ -118,6 +119,21 @@ public void createLocatorSuccess() throws ServiceException { expectedExpirationDateTime, locatorInfo); } + @Test + public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { + // Arrange + LocatorType locatorType = LocatorType.SAS; + Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); + + // Act + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), + locatorType).setId(UUID.randomUUID().toString())); + + // Assert + verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, + expectedExpirationDateTime, locatorInfo); + } + @Ignore("due to media service bug 596240") @Test public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceException { From 479ca37efdb54027d7e977441aed87cbbacf3163 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 10 Dec 2012 10:51:56 -0800 Subject: [PATCH 521/664] initial check in for security tests. --- microsoft-azure-api/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b2a77405955dd..7f077b98424eb 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -104,6 +104,12 @@ <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency> + <dependency> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk16</artifactId> + <version>1.46</version> + <scope>test</scope> + </dependency> </dependencies> <build> From c06cf8319d7debbcaf5c947b6885181b41573194 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 10 Dec 2012 12:04:30 -0800 Subject: [PATCH 522/664] locatorid update. --- .../windowsazure/services/media/LocatorIntegrationTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 9ed949a1b0704..3b2f8b23c2b92 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -127,7 +127,7 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), - locatorType).setId(UUID.randomUUID().toString())); + locatorType).setId(String.format("nb:lid:UUID:%s", UUID.randomUUID().toString()))); // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, From 7476d7dfdb1f55ce40f5ea3cf164ef103b94f82a Mon Sep 17 00:00:00 2001 From: "Justin Yu (Microsoft)" <justinyu@microsoft.com> Date: Mon, 10 Dec 2012 15:05:18 -0800 Subject: [PATCH 523/664] CurrentOperationByteCount --- .../core/storage/OperationContext.java | 6 +-- .../blob/client/CloudBlobContainerTests.java | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 9d6ce173b063f..3a385289d1dd4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -92,7 +92,7 @@ public final class OperationContext { * Reserved for internal use. */ // Used internally for download resume. - private volatile int currentOperationByteCount; + private volatile long currentOperationByteCount; /** * Creates an instance of the <code>OperationContext</code> class. @@ -112,7 +112,7 @@ public long getClientTimeInMs() { /** * @return the currentOperationByteCount */ - public int getCurrentOperationByteCount() { + public long getCurrentOperationByteCount() { return this.currentOperationByteCount; } @@ -203,7 +203,7 @@ public void setClientTimeInMs(final long clientTimeInMs) { * @param currentOperationByteCount * the currentOperationByteCount to set */ - public void setCurrentOperationByteCount(final int currentOperationByteCount) { + public void setCurrentOperationByteCount(final long currentOperationByteCount) { this.currentOperationByteCount = currentOperationByteCount; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index 658e878eb9cf9..1a360a6c62acf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -38,6 +38,7 @@ import com.microsoft.windowsazure.services.core.storage.AccessCondition; import com.microsoft.windowsazure.services.core.storage.OperationContext; import com.microsoft.windowsazure.services.core.storage.ResultSegment; +import com.microsoft.windowsazure.services.core.storage.RetryNoRetry; import com.microsoft.windowsazure.services.core.storage.SendingRequestEvent; import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature; import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings; @@ -50,6 +51,7 @@ public class CloudBlobContainerTests extends BlobTestBase { /** * test SharedAccess of container. + * d * * @XSCLCaseName ContainerInfoSharedAccess */ @@ -717,4 +719,56 @@ public void eventOccurred(SendingRequestEvent eventArg) { newContainer.deleteIfExists(); } } + + @Test + public void testCurrentOperationByteCount() throws URISyntaxException, StorageException, IOException { + final int blockLength = 4 * 1024 * 1024; + final Random randGenerator = new Random(); + String blobName = "testblob" + Integer.toString(randGenerator.nextInt(50000)); + blobName = blobName.replace('-', '_'); + + final CloudBlobContainer containerRef = bClient.getContainerReference(BlobTestBase.testSuiteContainerName); + + final CloudBlockBlob blobRef = containerRef.getBlockBlobReference(blobName); + + final ArrayList<byte[]> byteList = new ArrayList<byte[]>(); + final ArrayList<BlockEntry> blockList = new ArrayList<BlockEntry>(); + + int numberOfBlocks = 4; + + for (int m = 0; m < numberOfBlocks; m++) { + final byte[] buff = new byte[blockLength]; + randGenerator.nextBytes(buff); + byteList.add(buff); + blobRef.uploadBlock("ABC" + m, new ByteArrayInputStream(buff), blockLength); + + blockList.add(new BlockEntry("ABC" + m, BlockSearchMode.LATEST)); + } + + blobRef.commitBlockList(blockList); + + OperationContext operationContext = new OperationContext(); + BlobRequestOptions options = new BlobRequestOptions(); + options.setTimeoutIntervalInMs(1000); + options.setRetryPolicyFactory(new RetryNoRetry()); + try { + final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); + blobRef.download(downloadedDataStream, null, options, operationContext); + } + catch (Exception e) { + Assert.assertEquals(0, operationContext.getCurrentOperationByteCount()); + } + + operationContext = new OperationContext(); + options = new BlobRequestOptions(); + options.setTimeoutIntervalInMs(90000); + + final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); + blobRef.download(downloadedDataStream, null, options, operationContext); + + Assert.assertEquals(blockLength * numberOfBlocks, operationContext.getCurrentOperationByteCount()); + + blobRef.delete(); + } + } From 97a58bb66dea046cb1ef79db71574866a05fc4bf Mon Sep 17 00:00:00 2001 From: "Justin Yu (Microsoft)" <justinyu@microsoft.com> Date: Mon, 10 Dec 2012 15:07:55 -0800 Subject: [PATCH 524/664] remove no needed "d" --- .../services/blob/client/CloudBlobContainerTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index 1a360a6c62acf..9d945f61a53a9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -51,7 +51,6 @@ public class CloudBlobContainerTests extends BlobTestBase { /** * test SharedAccess of container. - * d * * @XSCLCaseName ContainerInfoSharedAccess */ From 9dcce983228df6e5c7980d318a3b04ab98c86e05 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 10 Dec 2012 15:11:52 -0800 Subject: [PATCH 525/664] Changed oauth env. variable names to media.oauth --- .../services/media/MediaConfiguration.java | 8 ++++---- .../media/MediaConfigurationTest.java | 20 +++++++++---------- .../com.microsoft.windowsazure.properties | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index b9b9d0e74aff8..e3d207f848ed9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -32,24 +32,24 @@ public class MediaConfiguration { * Defines the OAUTH configuration URI constant. * */ - public static final String OAUTH_URI = "oauth.uri"; + public static final String OAUTH_URI = "media.oauth.uri"; /** * Defines the OAUTH configuration client ID constant. * */ - public static final String OAUTH_CLIENT_ID = "oauth.client.id"; + public static final String OAUTH_CLIENT_ID = "media.oauth.client.id"; /** * Defines the OAUTH configuration client secret constant. * */ - public static final String OAUTH_CLIENT_SECRET = "oauth.client.secret"; + public static final String OAUTH_CLIENT_SECRET = "media.oauth.client.secret"; /** * Defines the SCOPE of the media service sent to OAUTH. */ - public static final String OAUTH_SCOPE = "oauth.scope"; + public static final String OAUTH_SCOPE = "media.oauth.scope"; /** * Creates a media service configuration using the specified media service base URI, OAUTH URI, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java index ccc8c5ca54016..4842f9e3a1434 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -33,10 +33,10 @@ public void createMediaConfigurationTestSuccess() { // Assert assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); - assertEquals("testOAuthUri", configuration.getProperty("oauth.uri")); - assertEquals("testClientId", configuration.getProperty("oauth.client.id")); - assertEquals("testClientSecret", configuration.getProperty("oauth.client.secret")); - assertEquals("testScope", configuration.getProperty("oauth.scope")); + assertEquals("testOAuthUri", configuration.getProperty("media.oauth.uri")); + assertEquals("testClientId", configuration.getProperty("media.oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("media.oauth.client.secret")); + assertEquals("testScope", configuration.getProperty("media.oauth.scope")); } @Test @@ -52,9 +52,9 @@ public void createMediaConfigurationPassingExistingConfigurationSuccess() { // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); - assertEquals("testOAuthUri", configuration.getProperty("oauth.uri")); - assertEquals("testClientId", configuration.getProperty("oauth.client.id")); - assertEquals("testClientSecret", configuration.getProperty("oauth.client.secret")); + assertEquals("testOAuthUri", configuration.getProperty("media.oauth.uri")); + assertEquals("testClientId", configuration.getProperty("media.oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("media.oauth.client.secret")); } @@ -72,9 +72,9 @@ public void createMediaConfigurationWithProfileConfigurationSuccess() { // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("testProfile.media.uri")); - assertEquals("testOAuthUri", configuration.getProperty("testProfile.oauth.uri")); - assertEquals("testClientId", configuration.getProperty("testProfile.oauth.client.id")); - assertEquals("testClientSecret", configuration.getProperty("testProfile.oauth.client.secret")); + assertEquals("testOAuthUri", configuration.getProperty("testProfile.media.oauth.uri")); + assertEquals("testClientId", configuration.getProperty("testProfile.media.oauth.client.id")); + assertEquals("testClientSecret", configuration.getProperty("testProfile.media.oauth.client.secret")); } } diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index dccc767257e8b..7c3399f882ebf 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -12,9 +12,9 @@ table.accountName=%TABLE_ACCOUNTNAME% table.accountKey=%TABLE_ACCOUNTKEY% table.uri=http://%TABLE_ACCOUNTNAME%.table.core.windows.net media.uri=%MEDIA.URI% -oauth.uri=%OAUTH.URI% -oauth.client.id=%OAUTH.CLIENT.ID% -oauth.client.secret=%OAUTH.CLIENT.SECRET% -oauth.scope=urn:WindowsAzureMediaServices +media.oauth.uri=%MEDIA.OAUTH.URI% +media.oauth.client.id=%OMEDIA.AUTH.CLIENT.ID% +media.oauth.client.secret=%MEDIA.OAUTH.CLIENT.SECRET% +media.oauth.scope=urn:WindowsAzureMediaServices testprefix.com.microsoft.windowsazure.services.core.Configuration.connectTimeout=3 testprefix.com.microsoft.windowsazure.services.core.Configuration.readTimeout=7 From 549837205e8301caf170f1fd030b2843044d5aa5 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 10 Dec 2012 15:34:34 -0800 Subject: [PATCH 526/664] Should list files for the specific asset, not all of them --- .../windowsazure/services/media/AssetFileIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 093dbcf246295..467224a5b6d0b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -70,7 +70,7 @@ public void canCreateFileForUploadedBlob() throws Exception { service.action(AssetFile.createFileInfos(asset.getId())); - ListResult<AssetFileInfo> files = service.list(AssetFile.list()); + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); assertEquals(1, files.size()); AssetFileInfo file = files.get(0); From 1e51c0f8737280bf6f9d73228866c04075cf3661 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 10 Dec 2012 15:48:15 -0800 Subject: [PATCH 527/664] Updated test to check enum value, not integer --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index e21f95db164a3..be809bf9bb06c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -236,7 +236,7 @@ public void cancelJobSuccess() throws Exception { // Assert JobInfo canceledJob = service.get(Job.get(jobInfo.getId())); - assertEquals(6, canceledJob.getState()); + assertEquals(JobState.Canceling, canceledJob.getState()); } From 3d28aaaa2ef0b63e128dcde8e0cdb94bd2b31e54 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 10 Dec 2012 21:22:45 -0800 Subject: [PATCH 528/664] Refactor sceanrio code to target real classes instead of mocks. Fixes #457. --- .../media/LocatorIntegrationTests.java | 3 - .../services/scenarios/MediaServiceMocks.java | 113 ------------- .../scenarios/MediaServiceScenarioTest.java | 26 +-- .../scenarios/MediaServiceValidation.java | 74 ++++++--- .../scenarios/MediaServiceWrapper.java | 157 +++++++++++------- .../services/scenarios/ScenarioTestBase.java | 3 +- 6 files changed, 165 insertions(+), 211 deletions(-) delete mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 3b2f8b23c2b92..5a1237b462ccb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -25,7 +25,6 @@ import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -134,7 +133,6 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { expectedExpirationDateTime, locatorInfo); } - @Ignore("due to media service bug 596240") @Test public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceException { // Arrange @@ -150,7 +148,6 @@ public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceExc expectedExpirationDateTime, locatorInfo); } - @Ignore("due to media service bug 596240") @Test public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Arrange diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java deleted file mode 100644 index cfedb89502d4c..0000000000000 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceMocks.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2012 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.microsoft.windowsazure.services.scenarios; - -import java.util.ArrayList; -import java.util.List; - -import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.AssetFileInfo; - -// TODO: Remove when no longer needed. -// Tracked by https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/457 -class MediaServiceMocks { - - static class MockMediaContract { - public List<AssetFileInfo> getAssetFiles(String id) { - return new ArrayList<AssetFileInfo>(); - } - - public JobInfo createJob(CreateJobOptions jobOptions) { - return new JobInfo(); - } - - public JobInfo getJob(String id) { - return new JobInfo(); - } - - public List<AssetInfo> getJobOutputMediaAssets(String id) { - return new ArrayList<AssetInfo>(); - } - - public void cancelJob(String id) { - } - - public List<AssetFileInfo> getFiles() { - return new ArrayList<AssetFileInfo>(); - } - - public AssetFileInfo createFileInfo(AssetFileInfo fi) { - return null; - } - } - - static enum JobState { - Finished, Canceled, Error - } - - static class JobInfo { - - public String getId() { - return null; - } - - public JobState getState() { - return JobState.Finished; - } - } - - static class CreateTaskOptions { - - public CreateTaskOptions setName(String string) { - return this; - } - - public CreateTaskOptions setProcessorId(String id) { - return this; - } - - public CreateTaskOptions setConfiguration(String string) { - return this; - } - - public CreateTaskOptions setTaskBody(String string) { - return this; - } - - public CreateTaskOptions setTaskCreationOptions(TaskCreationOptions options) { - return this; - } - } - - static class CreateJobOptions { - - public CreateJobOptions setName(String jobName) { - return this; - } - - public CreateJobOptions addInputMediaAsset(String id) { - return this; - } - - public CreateJobOptions addTask(CreateTaskOptions task) { - return this; - } - } - - static enum TaskCreationOptions { - ProtectedConfiguration - } -} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 1ff39bcc28c73..fa213a687e31f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -26,7 +26,6 @@ import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -34,7 +33,9 @@ import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Task; public class MediaServiceScenarioTest extends ScenarioTestBase { private static final String rootTestAssetPrefix = "testAssetPrefix-"; @@ -77,7 +78,6 @@ public void pageOverAssets() throws ServiceException { validator.validateAssetSortedPages(pages, assetNames, 3); } - @Ignore("Needs https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/277") @Test public void uploadFiles() throws Exception { signalSetupStarting(); @@ -88,7 +88,6 @@ public void uploadFiles() throws Exception { validator.validateAssetFiles(asset, getTestAssetFiles()); } - @Ignore("Needs https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/277") @Test public void downloadFiles() throws Exception { signalSetupStarting(); @@ -107,8 +106,9 @@ public void createJob() throws Exception { wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); - MediaServiceMocks.JobInfo job = wrapper.createJob("my job createJob", asset, createTasks()); - validator.validateJob(job, "my job", asset, createTasks()); + String jobName = "my job createJob"; + JobInfo job = wrapper.createJob(jobName, asset, createTasks()); + validator.validateJob(job, jobName, asset, createTasks()); } @Test @@ -116,7 +116,8 @@ public void transformAsset() throws Exception { signalSetupStarting(); AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", EncryptionOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); - MediaServiceMocks.JobInfo job = wrapper.createJob("my job transformAsset", asset, createTasks()); + String jobName = "my job transformAsset"; + JobInfo job = wrapper.createJob(jobName, asset, createTasks()); signalSetupFinished(); waitForJobToFinish(job); @@ -124,19 +125,20 @@ public void transformAsset() throws Exception { validator.validateOutputAssets(outputAssets); } - private void waitForJobToFinish(MediaServiceMocks.JobInfo job) throws InterruptedException { + private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { for (int counter = 0; !wrapper.isJobFinished(job); counter++) { if (counter > 10) { fail("Took took long for the job to finish"); } - Thread.sleep(20000); + Thread.sleep(10000); } } - private List<MediaServiceMocks.CreateTaskOptions> createTasks() throws ServiceException { - List<MediaServiceMocks.CreateTaskOptions> tasks = new ArrayList<MediaServiceMocks.CreateTaskOptions>(); - tasks.add(wrapper.createTaskOptionsMp4ToSmoothStreams("MP4 to SS")); - tasks.add(wrapper.createTaskOptionsSmoothStreamsToHls("SS to HLS")); + private List<Task.CreateBatchOperation> createTasks() throws ServiceException { + List<Task.CreateBatchOperation> tasks = new ArrayList<Task.CreateBatchOperation>(); + + tasks.add(wrapper.createTaskOptionsMp4ToSmoothStreams("MP4 to SS", 0, 0)); + tasks.add(wrapper.createTaskOptionsSmoothStreamsToHls("SS to HLS", 0, 1)); return tasks; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index c2517b8d8c8f2..4579a543a39cb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -19,31 +19,30 @@ import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URL; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.Date; import java.util.Hashtable; import java.util.List; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.EncryptionOption; -import com.microsoft.windowsazure.services.media.models.AssetFileInfo; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.JobInfo; +import com.microsoft.windowsazure.services.media.models.Task; class MediaServiceValidation { private final MediaContract service; - private final MediaServiceMocks.MockMediaContract serviceMock; public MediaServiceValidation(MediaContract service) { this.service = service; - this.serviceMock = new MediaServiceMocks.MockMediaContract(); } public void validateAsset(AssetInfo asset, String name, EncryptionOption encryption) throws ServiceException { @@ -55,7 +54,7 @@ public void validateAsset(AssetInfo asset, String name, EncryptionOption encrypt assertEquals("asset.getOptions", encryption, asset.getOptions()); // Verify no files by default. - List<AssetFileInfo> initialFiles = serviceMock.getAssetFiles(asset.getId()); + List<AssetFileInfo> initialFiles = service.list(AssetFile.list(asset.getId())); assertNotNull("initialFiles", initialFiles); assertEquals("initialFiles.size", 0, initialFiles.size()); @@ -83,15 +82,15 @@ public void validateAssetSortedPages(List<ListResult<AssetInfo>> pages, List<Str assertEquals("sumSizeOfPages", assetNames.size(), sumSizeOfPages); assertEquals("size of last page", 0, pages.get(pages.size() - 1).size()); - // Can do this comparison directly because the incoming pages are assumed to be sorted. - for (int i = 0; i < assetNames.size(); i++) { - assertEquals("Asset name:" + i, assetNames.get(i), actualAssetNames.get(i)); - } + + // Do not worry about comparing the details of the sorted pages, + // because Media Services splits on the internal order, then sorts + // each page individually. } public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> inputFiles) throws ServiceException, IOException, NoSuchAlgorithmException { - List<AssetFileInfo> assetFiles = serviceMock.getAssetFiles(asset.getId()); + List<AssetFileInfo> assetFiles = service.list(AssetFile.list(asset.getId())); assertNotNull("assetFiles", assetFiles); assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); @@ -107,7 +106,7 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i // * Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion // Compare the asset files with all files - List<AssetFileInfo> allFiles = serviceMock.getFiles(); + List<AssetFileInfo> allFiles = service.list(AssetFile.list()); for (AssetFileInfo assetFile : assetFiles) { assertEquals("fi.getParentAssetId", asset.getId(), assetFile.getParentAssetId()); AssetFileInfo match = null; @@ -132,22 +131,29 @@ public void validateAssetFileUrls(List<URL> fileUrls, Hashtable<String, InputStr } } - public void validateJob(JobInfo job, String string, AssetInfo asset, List<CreateTaskOptions> createTasks) { - // Add validation + public void validateJob(JobInfo job, String name, AssetInfo asset, List<Task.CreateBatchOperation> createTasks) { + assertDateApproxEquals("getEndTime", new Date(), job.getCreated()); + assertEquals("job.getName", name, job.getName()); + + // TODO: Uncomment when fixed: + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 + // List<String> inputAssets = job.getInputMediaAssets(); + // assertNotNull("inputAssets", inputAssets); + // assertEquals("inputAssets.size()", 1, inputAssets.size()); + // assertEquals("inputAssets.get(0)", asset.getId(), inputAssets.get(0)); + // + // List<String> outputAssets = job.getOutputMediaAssets(); + // assertNotNull("outputAssets", outputAssets); + // assertEquals("outputAssets.size()", createTasks.size(), outputAssets.size()); } - public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException, MalformedURLException { - // Add validation for the output assets. Will be simple to do once + public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException { + // TODO: Uncomment when fixed: + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 - // for (AssetInfo outputAsset : outputAssets) { - // List<URL> urls = wrapper.createOriginUrlsForAppleHLSContent(outputAsset, 1000); - // for (URL url : urls) { - // System.out.println(url); - // } - // } - // - // for (URL url : wrapper.createOriginUrlsForStreamingContent(asset, 10)) { - // // TODO: What to verify here? + // assertNotNull("outputAssets", outputAssets); + // for (AssetInfo asset : outputAssets) { + // this.validateAsset(asset, null, null); // } } @@ -193,6 +199,22 @@ public void assertFileInfosEqual(String message, AssetFileInfo fi, AssetFileInfo assertEquals(message + ":getParentAssetId", fi.getParentAssetId(), match.getParentAssetId()); } + protected void assertDateApproxEquals(String message, Date expected, Date actual) { + // Default allows for a 30 seconds difference in dates, for clock skew, network delays, etc. + long deltaInMilliseconds = 30000; + + if (expected == null || actual == null) { + assertEquals(message, expected, actual); + } + else { + long diffInMilliseconds = Math.abs(expected.getTime() - actual.getTime()); + + if (diffInMilliseconds > deltaInMilliseconds) { + assertEquals(message, expected, actual); + } + } + } + private void assertStreamsEqual(InputStream inputStream1, InputStream inputStream2) throws IOException { byte[] buffer1 = new byte[1024]; byte[] buffer2 = new byte[1024]; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 6348f3b135eff..13ee4bc9dc7a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -38,24 +38,23 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.Job.Creator; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateJobOptions; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.CreateTaskOptions; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.JobInfo; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.MockMediaContract; -import com.microsoft.windowsazure.services.scenarios.MediaServiceMocks.TaskCreationOptions; +import com.microsoft.windowsazure.services.media.models.Task; class MediaServiceWrapper { private final MediaContract service; - private final MockMediaContract serviceMock; private static final String accessPolicyPrefix = "scenarioTestPrefix"; @@ -106,7 +105,6 @@ class MediaServiceWrapper { public MediaServiceWrapper(MediaContract service) { this.service = service; - this.serviceMock = new MockMediaContract(); } // Manage @@ -141,6 +139,9 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); LocatorInfo locator = service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS)); WritableBlobContainerContract uploader = MediaService.createBlobWriter(locator); + + Hashtable<String, AssetFileInfo> infoToUpload = new Hashtable<String, AssetFileInfo>(); + boolean isFirst = true; for (String fileName : inputFiles.keySet()) { MessageDigest digest = MessageDigest.getInstance("MD5"); @@ -159,10 +160,22 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht AssetFileInfo fi = new AssetFileInfo(null, new AssetFileType().setContentChecksum(md5) .setContentFileSize(new Long(countingStream.getCount())).setIsPrimary(isFirst).setName(fileName) .setParentAssetId(asset.getAlternateId())); - serviceMock.createFileInfo(fi); + infoToUpload.put(fileName, fi); isFirst = false; } + + service.action(AssetFile.createFileInfos(asset.getId())); + for (AssetFileInfo assetFile : service.list(AssetFile.list(asset.getId()))) { + + AssetFileInfo x = infoToUpload.get(assetFile.getName()); + System.out.println(x); + service.update(AssetFile.update(assetFile.getId()).setContentChecksum(x.getContentChecksum()) + .setContentFileSize(x.getContentFileSize()).setIsPrimary(x.getIsPrimary())); + } + + service.list(AssetFile.list(asset.getId())); + service.delete(Locator.delete(locator.getId())); service.delete(AccessPolicy.delete(accessPolicy.getId())); } @@ -188,60 +201,66 @@ public int getCount() { } // Process - public JobInfo createJob(String jobName, AssetInfo inputAsset, List<CreateTaskOptions> tasks) { - CreateJobOptions jobOptions = new CreateJobOptions().setName(jobName).addInputMediaAsset(inputAsset.getId()); + public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateBatchOperation> tasks) + throws ServiceException { + Creator jobCreator = Job.create(service.getRestServiceUri()).setName(jobName) + .addInputMediaAsset(inputAsset.getId()).setPriority(2); - for (CreateTaskOptions task : tasks) { - jobOptions.addTask(task); + for (Task.CreateBatchOperation task : tasks) { + jobCreator.addTaskCreator(task); } - return serviceMock.createJob(jobOptions); + return service.create(jobCreator); } // Process - public CreateTaskOptions createTaskOptionsWindowsAzureMediaEncoder(String taskName) throws ServiceException { - return new CreateTaskOptions() - .setName(taskName) - .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER)) - .setConfiguration("H.264 256k DSL CBR") - .setTaskBody( - "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" - + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + public Task.CreateBatchOperation createTaskOptionsWindowsAzureMediaEncoder(String taskName, int inputAssetId, + int outputAssetId) throws ServiceException { + Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) + .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER)) + .setConfiguration("H.264 256k DSL CBR"); + setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } // Process - public CreateTaskOptions createTaskOptionsPlayReadyProtection(String taskName, String playReadyConfiguration) - throws ServiceException { - return new CreateTaskOptions() + public Task.CreateBatchOperation createTaskOptionsPlayReadyProtection(String taskName, + String playReadyConfiguration, int inputAssetId, int outputAssetId) throws ServiceException { + Task.CreateBatchOperation taskCreate = Task + .create() .setName(taskName) - .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration) - .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION)) - .setConfiguration(playReadyConfiguration) - .setTaskBody( - "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" - + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + // TODO: Re-enable + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/499 + // .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration) + .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION)) + .setConfiguration(playReadyConfiguration); + setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } // Process - public CreateTaskOptions createTaskOptionsMp4ToSmoothStreams(String taskName) throws ServiceException { - return new CreateTaskOptions() - .setName(taskName) - .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS)) - .setConfiguration(configMp4ToSmoothStreams) - .setTaskBody( - "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" - + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + public Task.CreateBatchOperation createTaskOptionsMp4ToSmoothStreams(String taskName, int inputAssetId, + int outputAssetId) throws ServiceException { + Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) + .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS)) + .setConfiguration(configMp4ToSmoothStreams); + setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } // Process - public CreateTaskOptions createTaskOptionsSmoothStreamsToHls(String taskName) throws ServiceException { - return new CreateTaskOptions() - .setName(taskName) - .setProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS)) - .setConfiguration(configSmoothStreamsToAppleHttpLiveStreams) - .setTaskBody( - "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" - + "<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"); + public Task.CreateBatchOperation createTaskOptionsSmoothStreamsToHls(String taskName, int inputAssetId, + int outputAssetId) throws ServiceException { + Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) + .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS)) + .setConfiguration(configSmoothStreamsToAppleHttpLiveStreams); + setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; + } + + private void setTaskBody(Task.CreateBatchOperation taskCreate, int inputAssetId, int outputAssetId) { + taskCreate.setTaskBody("<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>" + + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>"); } private String getMediaProcessorIdByName(String processorName) throws ServiceException { @@ -252,8 +271,8 @@ private String getMediaProcessorIdByName(String processorName) throws ServiceExc } // Process - public boolean isJobFinished(JobInfo initialJobInfo) { - JobInfo currentJob = serviceMock.getJob(initialJobInfo.getId()); + public boolean isJobFinished(JobInfo initialJobInfo) throws ServiceException { + JobInfo currentJob = service.get(Job.get(initialJobInfo.getId())); switch (currentJob.getState()) { case Finished: case Canceled: @@ -264,14 +283,22 @@ public boolean isJobFinished(JobInfo initialJobInfo) { } } - public List<AssetInfo> getJobOutputMediaAssets(JobInfo job) { - return serviceMock.getJobOutputMediaAssets(job.getId()); + public List<AssetInfo> getJobOutputMediaAssets(JobInfo job) throws ServiceException { + List<String> outputMediaAssets = job.getOutputMediaAssets(); + if (outputMediaAssets == null) { + return null; + } + List<AssetInfo> ret = new ArrayList<AssetInfo>(); + for (String assetId : outputMediaAssets) { + ret.add(service.get(Asset.get(assetId))); + } + return ret; } // Process - public void cancelJob(JobInfo job) throws InterruptedException { + public void cancelJob(JobInfo job) throws ServiceException { // Use the service function - serviceMock.cancelJob(job.getId()); + service.action(Job.cancel(job.getId())); } // Deliver @@ -303,7 +330,7 @@ private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), locatorType)); - List<AssetFileInfo> publishedFiles = serviceMock.getAssetFiles(asset.getId()); + List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getId())); for (AssetFileInfo fi : publishedFiles) { if (isSmooth) { // Smooth Streaming format ends with ".ism*" @@ -343,11 +370,23 @@ public void removeAllAssetsWithPrefix(String assetPrefix) throws ServiceExceptio && asset.getName().substring(0, assetPrefix.length()).equals(assetPrefix)) { for (LocatorInfo locator : locators) { if (locator.getAssetId().equals(asset.getId())) { - service.delete(Locator.delete(locator.getId())); + try { + service.delete(Locator.delete(locator.getId())); + } + catch (ServiceException e) { + // Don't worry if cannot delete now. + // Might be held on to by a running job + } } } - service.delete(Asset.delete(asset.getId())); + try { + service.delete(Asset.delete(asset.getId())); + } + catch (ServiceException e) { + // Don't worry if cannot delete now. + // Might be held on to by a running job + } } } } @@ -357,7 +396,13 @@ public void removeAllAccessPoliciesWithPrefix() throws ServiceException { for (AccessPolicyInfo accessPolicy : accessPolicies) { if (accessPolicy.getName().length() > accessPolicyPrefix.length() && accessPolicy.getName().substring(0, accessPolicyPrefix.length()).equals(accessPolicyPrefix)) { - service.delete(AccessPolicy.delete(accessPolicy.getId())); + try { + service.delete(AccessPolicy.delete(accessPolicy.getId())); + } + catch (ServiceException e) { + // Don't worry if cannot delete now. + // Might be held on to by a running job + } } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java index 0d471e7da87ec..6875d11095297 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java @@ -109,7 +109,8 @@ public void evaluate() throws Throwable { } catch (Throwable e) { if (shouldCapture) { - fail("Error occured during setup: " + e); + e.printStackTrace(); + fail("Error occured during setup: " + e.getMessage()); } else { throw e; From ca898f8b2f5bc46b3f5155aaef3f9fc1a3b2a7ef Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 10 Dec 2012 21:46:40 -0800 Subject: [PATCH 529/664] Enhancing unit tests for #277 Refactoring `createLocator` (used in three classes) to the base class. --- .../media/AssetFileIntegrationTest.java | 64 ++++++++++--------- .../services/media/IntegrationTestBase.java | 13 ++++ .../services/media/JobIntegrationTest.java | 14 ---- .../media/UploadingIntegrationTest.java | 10 +-- 4 files changed, 48 insertions(+), 53 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 467224a5b6d0b..27fe6c4181838 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -37,9 +37,7 @@ import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; public class AssetFileIntegrationTest extends IntegrationTestBase { @@ -119,7 +117,7 @@ public void canCreateAssetWithMultipleFiles() throws Exception { .setIsEncrypted(false).setContentFileSize(new Long(onesAndZeros.length))); AssetFileInfo file3 = service.create(AssetFile.create(asset.getId(), "blob3.bin").setIsPrimary(false) - .setIsEncrypted(false).setContentFileSize(new Long(countingUp.length))); + .setIsEncrypted(false).setContentFileSize(new Long(countingUp.length)).setContentChecksum("1234")); ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); @@ -133,9 +131,9 @@ public int compare(AssetFileInfo o1, AssetFileInfo o2) { } }); - assertAssetFileInfoEquals(file1, results.get(0)); - assertAssetFileInfoEquals(file2, results.get(1)); - assertAssetFileInfoEquals(file3, results.get(2)); + assertAssetFileInfoEquals("results.get(0)", file1, results.get(0)); + assertAssetFileInfoEquals("results.get(1)", file2, results.get(1)); + assertAssetFileInfoEquals("results.get(2)", file3, results.get(2)); } @Test @@ -195,17 +193,6 @@ private static AccessPolicyInfo createWritePolicy(String name, int durationInMin EnumSet.of(AccessPolicyPermission.WRITE))); } - private static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, - int expirationDeltaMinutes) throws ServiceException { - - Date now = new Date(); - Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); - Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); - - return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) - .setStartDateTime(start).setExpirationDateTime(expire)); - } - private static void createAndUploadBlob(WritableBlobContainerContract blobWriter, String blobName, byte[] data) throws ServiceException { InputStream blobContent = new ByteArrayInputStream(data); @@ -216,19 +203,36 @@ private static void createAndUploadBlob(WritableBlobContainerContract blobWriter // Assertion helpers // - private void assertAssetFileInfoEquals(AssetFileInfo expected, AssetFileInfo actual) { - assertEquals(expected.getId(), actual.getId()); - assertEquals(expected.getName(), actual.getName()); - assertEquals(expected.getParentAssetId(), actual.getParentAssetId()); - assertEquals(expected.getIsPrimary(), actual.getIsPrimary()); - assertEquals(expected.getIsEncrypted(), actual.getIsEncrypted()); - assertEquals(expected.getEncryptionKeyId(), actual.getEncryptionKeyId()); - assertEquals(expected.getEncryptionScheme(), actual.getEncryptionScheme()); - assertEquals(expected.getEncryptionVersion(), actual.getEncryptionVersion()); - assertEquals(expected.getInitializationVector(), actual.getInitializationVector()); - assertDateApproxEquals(expected.getCreated(), actual.getCreated()); - assertDateApproxEquals(expected.getLastModified(), actual.getLastModified()); - assertEquals(expected.getMimeType(), actual.getMimeType()); + private void assertAssetFileInfoEquals(String message, AssetFileInfo expected, AssetFileInfo actual) { + verifyAssetInfoProperties(message, expected.getId(), expected.getName(), expected.getParentAssetId(), + expected.getIsPrimary(), expected.getIsEncrypted(), expected.getEncryptionKeyId(), + expected.getEncryptionScheme(), expected.getEncryptionVersion(), expected.getInitializationVector(), + expected.getCreated(), expected.getLastModified(), expected.getContentChecksum(), + expected.getMimeType(), actual); + } + + private void verifyAssetInfoProperties(String message, String id, String name, String parentAssetId, + boolean isPrimary, boolean isEncrypted, String encryptionKeyId, String encryptionScheme, + String encryptionVersion, String initializationVector, Date created, Date lastModified, + String contentChecksum, String mimeType, AssetFileInfo assetFile) { + assertNotNull(message, assetFile); + + assertEquals(message + ".getId", id, assetFile.getId()); + assertEquals(message + ".getName", name, assetFile.getName()); + assertEquals(message + ".getParentAssetId", parentAssetId, assetFile.getParentAssetId()); + assertEquals(message + ".getIsPrimary", isPrimary, assetFile.getIsPrimary()); + + assertEquals(message + ".getIsEncrypted", isEncrypted, assetFile.getIsEncrypted()); + assertEquals(message + ".getEncryptionKeyId", encryptionKeyId, assetFile.getEncryptionKeyId()); + assertEquals(message + ".getEncryptionScheme", encryptionScheme, assetFile.getEncryptionScheme()); + assertEquals(message + ".getEncryptionVersion", encryptionVersion, assetFile.getEncryptionVersion()); + assertEquals(message + ".getInitializationVector", initializationVector, assetFile.getInitializationVector()); + + assertDateApproxEquals(message + ".getCreated", created, assetFile.getCreated()); + assertDateApproxEquals(message + ".getLastModified", lastModified, assetFile.getLastModified()); + assertEquals(message + ".getContentChecksum", contentChecksum, assetFile.getContentChecksum()); + assertEquals(message + ".getMimeType", mimeType, assetFile.getMimeType()); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index d7a2a9c13e846..71972f3ee6c28 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -14,6 +14,7 @@ import org.junit.rules.ExpectedException; import com.microsoft.windowsazure.services.core.Configuration; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.Asset; @@ -23,6 +24,7 @@ import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; public abstract class IntegrationTestBase { protected static MediaContract service; @@ -140,6 +142,17 @@ interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } + protected static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, + int expirationDeltaMinutes) throws ServiceException { + + Date now = new Date(); + Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); + Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); + + return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) + .setStartDateTime(start).setExpirationDateTime(expire)); + } + protected <T> void verifyListResultContains(List<T> expectedInfos, Collection<T> actualInfos, ComponentDelegate delegate) { verifyListResultContains("", expectedInfos, actualInfos, delegate); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index be809bf9bb06c..83777e3ec31da 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -21,7 +21,6 @@ import java.io.InputStream; import java.net.URI; import java.util.ArrayList; -import java.util.Date; import java.util.EnumSet; import java.util.List; @@ -40,9 +39,7 @@ import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.Task; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -85,17 +82,6 @@ private String createFileAsset(String name) throws ServiceException { return assetInfo.getId(); } - private LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, - int expirationDeltaMinutes) throws ServiceException { - - Date now = new Date(); - Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); - Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); - - return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) - .setStartDateTime(start).setExpirationDateTime(expire)); - } - private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, JobState state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 55e3aa790b12b..9c6239d8538c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -17,7 +17,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.util.Date; import java.util.EnumSet; import org.junit.BeforeClass; @@ -34,9 +33,7 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; /** * Testing uploading in various permutations. @@ -55,12 +52,7 @@ public static void setup() throws Exception { AccessPolicyInfo policy = service.create(AccessPolicy.create(testPolicyPrefix + "uploadWritePolicy", 10, EnumSet.of(AccessPolicyPermission.WRITE))); - Date now = new Date(); - Date fiveMinutesAgo = new Date(now.getTime() - (5 * 60 * 1000)); - Date tenMinutesFromNow = new Date(now.getTime() + (10 * 60 * 1000)); - - LocatorInfo locator = service.create(Locator.create(policy.getId(), asset.getId(), LocatorType.SAS) - .setStartDateTime(fiveMinutesAgo).setExpirationDateTime(tenMinutesFromNow)); + LocatorInfo locator = createLocator(policy, asset, 5, 10); blobWriter = MediaService.createBlobWriter(locator); From 192deaaf331bc9ed046b9c8c921c6c217e7b54e5 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Mon, 10 Dec 2012 18:13:22 -0800 Subject: [PATCH 530/664] Refactored implementation of settting timeout into specific TimeoutSettings class. This way the timeouts can be injected, and at the same time centralizes the logic of choosing timeout defaults. --- .../services/core/utils/pipeline/Exports.java | 37 +++++------ .../core/utils/pipeline/TimeoutSettings.java | 64 +++++++++++++++++++ 2 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index e6a97e159afbc..1826719d3a593 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -32,39 +32,34 @@ public void register(Registry registry) { @Override public ClientConfig create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = new DefaultClientConfig(); - profile = normalizeProfile(profile); + TimeoutSettings timeoutSettings = builder.build(profile, TimeoutSettings.class, properties); + timeoutSettings.applyTimeout(clientConfig); + return clientConfig; + } + }); - // Lower levels of the stack assume timeouts are set. - // Set default timeout on clientConfig in case user - // hasn't set it yet in their configuration + registry.add(new Builder.Factory<TimeoutSettings>() { - clientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, new Integer(90 * 1000)); - clientConfig.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, new Integer(90 * 1000)); + @Override + public TimeoutSettings create(String profile, Builder builder, Map<String, Object> properties) { + Object connectTimeout = null; + Object readTimeout = null; + + profile = normalizeProfile(profile); for (Entry<String, Object> entry : properties.entrySet()) { Object propertyValue = entry.getValue(); String propertyKey = entry.getKey(); if (propertyKey.equals(profile + Configuration.PROPERTY_CONNECT_TIMEOUT)) { - propertyKey = ClientConfig.PROPERTY_CONNECT_TIMEOUT; + connectTimeout = propertyValue; } if (propertyKey.equals(profile + Configuration.PROPERTY_READ_TIMEOUT)) { - propertyKey = ClientConfig.PROPERTY_READ_TIMEOUT; - } - - // ClientConfig requires instance of Integer to properly set - // timeouts, but config file will deliver strings. Special - // case these timeout properties and convert them to Integer - // if necessary. - if (propertyKey.equals(ClientConfig.PROPERTY_CONNECT_TIMEOUT) - || propertyKey.equals(ClientConfig.PROPERTY_READ_TIMEOUT)) { - if (propertyValue instanceof String) { - propertyValue = Integer.valueOf((String) propertyValue); - } + readTimeout = propertyValue; } - clientConfig.getProperties().put(propertyKey, propertyValue); } - return clientConfig; + + return new TimeoutSettings(connectTimeout, readTimeout); } }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java new file mode 100644 index 0000000000000..9a671ba0a745d --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java @@ -0,0 +1,64 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.core.utils.pipeline; + +import com.sun.jersey.api.client.config.ClientConfig; + +/** + * Class used for injecting timeout settings into the various places that need it. + * + */ +public class TimeoutSettings { + private static final int DEFAULT_TIMEOUT_MS = 90 * 1000; + + private final Integer connectTimeout; + private final Integer readTimeout; + + /** + * Construct a {@link TimeoutSettings} object with the default + * timeout. + */ + public TimeoutSettings() { + connectTimeout = Integer.valueOf(null); + readTimeout = Integer.valueOf(null); + } + + public TimeoutSettings(Object connectTimeout, Object readTimeout) { + this.connectTimeout = getTimeout(connectTimeout); + this.readTimeout = getTimeout(readTimeout); + } + + public void applyTimeout(ClientConfig clientConfig) { + clientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectTimeout); + clientConfig.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout); + } + + private Integer getTimeout(Object timeoutValue) { + if (timeoutValue == null) { + return new Integer(DEFAULT_TIMEOUT_MS); + } + + if (timeoutValue instanceof Integer) { + return (Integer) timeoutValue; + } + + if (timeoutValue instanceof String) { + return Integer.valueOf((String) timeoutValue); + } + + throw new IllegalArgumentException("timeoutValue"); + } +} From 82602ca0cd903bf1ffad32697aea6501644c6778 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 11 Dec 2012 09:47:39 -0800 Subject: [PATCH 531/664] Get blob writer from service instance, not static factory, so that timeouts are passed through --- .../services/media/MediaContract.java | 10 +++ .../services/media/MediaService.java | 57 --------------- .../MediaExceptionProcessor.java | 10 +++ .../media/implementation/MediaRestProxy.java | 72 +++++++++++++++++-- .../media/AssetFileIntegrationTest.java | 10 +-- .../services/media/JobIntegrationTest.java | 4 +- .../media/UploadingIntegrationTest.java | 2 +- .../scenarios/MediaServiceWrapper.java | 4 +- 8 files changed, 98 insertions(+), 71 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index 47ddbbac61b5f..f6a80ea5ffc80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -19,6 +19,7 @@ import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; /** * Contract for interacting with the back end of Media Services @@ -28,4 +29,13 @@ public interface MediaContract extends FilterableService<MediaContract>, EntityC URI getRestServiceUri(); + /** + * Creates an instance of the <code>WritableBlobContainerContract</code> API that will + * write to the blob container given by the provided locator. + * + * @param locator + * locator specifying where to upload to + * @return the implementation of <code>WritableBlobContainerContract</code> + */ + WritableBlobContainerContract createBlobWriter(LocatorInfo locator); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index bc2d5d54e2a19..9cf13258bab88 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -14,13 +14,7 @@ */ package com.microsoft.windowsazure.services.media; -import java.net.URI; - import com.microsoft.windowsazure.services.core.Configuration; -import com.microsoft.windowsazure.services.media.implementation.MediaBlobContainerWriter; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; -import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.sun.jersey.api.client.Client; /** * @@ -70,55 +64,4 @@ public static MediaContract create(String profile) { public static MediaContract create(String profile, Configuration config) { return config.create(profile, MediaContract.class); } - - /** - * Creates an instance of the <code>WritableBlobContainerContract</code> API that will - * write to the blob container given by the provided locator. - * - * @param locator - * locator specifying where to upload to - * @return the implementation of <code>WritableBlobContainerContract</code> - */ - public static WritableBlobContainerContract createBlobWriter(LocatorInfo locator) { - if (locator.getLocatorType() != LocatorType.SAS) { - throw new IllegalArgumentException("Can only write to SAS locators"); - } - - LocatorParser p = new LocatorParser(locator); - - return new MediaBlobContainerWriter(createUploaderClient(), p.getAccountName(), p.getStorageUri(), - p.getContainer(), p.getSASToken()); - } - - /** - * Helper class to encapsulate pulling information out of the locator. - */ - private static class LocatorParser { - URI locatorPath; - - LocatorParser(LocatorInfo locator) { - locatorPath = URI.create(locator.getPath()); - } - - String getAccountName() { - return locatorPath.getHost().split("\\.")[0]; - } - - String getStorageUri() { - return locatorPath.getScheme() + "://" + locatorPath.getAuthority(); - } - - String getContainer() { - return locatorPath.getPath().substring(1); - } - - String getSASToken() { - return locatorPath.getRawQuery(); - } - } - - private static Client createUploaderClient() { - Client client = Client.create(); - return client; - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index cc8ad049d972f..5301f415a80a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -26,6 +26,7 @@ import com.microsoft.windowsazure.services.core.ServiceFilter; import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; @@ -33,6 +34,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.sun.jersey.api.client.ClientHandlerException; import com.sun.jersey.api.client.UniformInterfaceException; @@ -196,4 +198,12 @@ public URI getRestServiceUri() { return service.getRestServiceUri(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createBlobWriter(com.microsoft.windowsazure.services.media.models.LocatorInfo) + */ + @Override + public WritableBlobContainerContract createBlobWriter(LocatorInfo locator) { + return service.createBlobWriter(locator); + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 3952c822c88f0..850cb69c74ca6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -24,9 +24,15 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.services.core.ServiceFilter; +import com.microsoft.windowsazure.services.core.utils.pipeline.TimeoutSettings; import com.microsoft.windowsazure.services.media.MediaContract; +import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.config.DefaultClientConfig; /** * The Class MediaRestProxy. @@ -38,6 +44,8 @@ public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The redirect filter. */ private RedirectFilter redirectFilter; + private final TimeoutSettings timeoutSettings; + /** * Instantiates a new media rest proxy. * @@ -49,12 +57,16 @@ public class MediaRestProxy extends EntityRestProxy implements MediaContract { * the redirect filter * @param versionHeadersFilter * the version headers filter + * @param timeoutSettings + * Currently configured HTTP client timeouts + * */ @Inject public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, - VersionHeadersFilter versionHeadersFilter) { + VersionHeadersFilter versionHeadersFilter, TimeoutSettings timeoutSettings) { super(channel, new ServiceFilter[0]); + this.timeoutSettings = timeoutSettings; this.redirectFilter = redirectFilter; channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -68,9 +80,12 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red * the channel * @param filters * the filters + * @param timeoutSettings + * currently configured HTTP client timeouts */ - private MediaRestProxy(Client channel, ServiceFilter[] filters) { + private MediaRestProxy(Client channel, ServiceFilter[] filters, TimeoutSettings timeoutSettings) { super(channel, filters); + this.timeoutSettings = timeoutSettings; } /* (non-Javadoc) @@ -81,7 +96,7 @@ public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new MediaRestProxy(getChannel(), newFilters); + return new MediaRestProxy(getChannel(), newFilters, timeoutSettings); } /* (non-Javadoc) @@ -91,4 +106,53 @@ public MediaContract withFilter(ServiceFilter filter) { public URI getRestServiceUri() { return this.redirectFilter.getBaseURI(); } -} + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.MediaContract#createBlobWriter(com.microsoft.windowsazure.services.media.models.LocatorInfo) + */ + @Override + public WritableBlobContainerContract createBlobWriter(LocatorInfo locator) { + if (locator.getLocatorType() != LocatorType.SAS) { + throw new IllegalArgumentException("Can only write to SAS locators"); + } + + LocatorParser p = new LocatorParser(locator); + + return new MediaBlobContainerWriter(createUploaderClient(), p.getAccountName(), p.getStorageUri(), + p.getContainer(), p.getSASToken()); + } + + /** + * Helper class to encapsulate pulling information out of the locator. + */ + private static class LocatorParser { + URI locatorPath; + + LocatorParser(LocatorInfo locator) { + locatorPath = URI.create(locator.getPath()); + } + + String getAccountName() { + return locatorPath.getHost().split("\\.")[0]; + } + + String getStorageUri() { + return locatorPath.getScheme() + "://" + locatorPath.getAuthority(); + } + + String getContainer() { + return locatorPath.getPath().substring(1); + } + + String getSASToken() { + return locatorPath.getRawQuery(); + } + } + + private Client createUploaderClient() { + ClientConfig clientConfig = new DefaultClientConfig(); + timeoutSettings.applyTimeout(clientConfig); + Client client = Client.create(clientConfig); + return client; + } +} \ No newline at end of file diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 27fe6c4181838..458b8a5da8588 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -62,7 +62,7 @@ public static void setup() throws Exception { public void canCreateFileForUploadedBlob() throws Exception { AssetInfo asset = createTestAsset("createFileForUploadedBlob"); LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, BLOB_NAME, firstPrimes); @@ -79,7 +79,7 @@ public void canCreateFileForUploadedBlob() throws Exception { public void canCreateFileEntityDirectly() throws Exception { AssetInfo asset = createTestAsset("createFileEntityDirectly"); LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, BLOB_NAME_2, firstPrimes); @@ -104,7 +104,7 @@ public void canCreateAssetWithMultipleFiles() throws Exception { AccessPolicyInfo policy = createWritePolicy("createWithMultipleFiles", 10); LocatorInfo locator = createLocator(policy, asset, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "blob1.bin", firstPrimes); createAndUploadBlob(blobWriter, "blob2.bin", onesAndZeros); @@ -141,7 +141,7 @@ public void canCreateFileAndThenUpdateIt() throws Exception { AssetInfo asset = createTestAsset("createAndUpdate"); AccessPolicyInfo policy = createWritePolicy("createAndUpdate", 10); LocatorInfo locator = createLocator(policy, asset, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "toUpdate.bin", firstPrimes); @@ -159,7 +159,7 @@ public void canDeleteFileFromAsset() throws Exception { AssetInfo asset = createTestAsset("deleteFile"); AccessPolicyInfo policy = createWritePolicy("deleteFile", 10); LocatorInfo locator = createLocator(policy, asset, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "todelete.bin", firstPrimes); createAndUploadBlob(blobWriter, "tokeep.bin", onesAndZeros); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 83777e3ec31da..cfcc0a909d6c2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -72,7 +72,7 @@ private String createFileAsset(String name) throws ServiceException { AssetInfo assetInfo = service.create(Asset.create().setName(name)); AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy(name, 10); LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, testBlobName, testBlobData); service.create(AssetFile.create(assetInfo.getId(), testBlobName).setIsPrimary(true).setIsEncrypted(false) @@ -124,7 +124,7 @@ public void createJobSuccess() throws Exception { AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy("createJobSuccess", 10); LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locator); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "blob1.bin", testBlobData); service.create(AssetFile.create(assetInfo.getId(), "blob1.bin").setIsPrimary(true).setIsEncrypted(false) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 9c6239d8538c4..652901696fc95 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -54,7 +54,7 @@ public static void setup() throws Exception { LocatorInfo locator = createLocator(policy, asset, 5, 10); - blobWriter = MediaService.createBlobWriter(locator); + blobWriter = service.createBlobWriter(locator); ExponentialRetryPolicy retryPolicy = new ExponentialRetryPolicy(5000, 5, new int[] { 400, 404 }); blobWriter = blobWriter.withFilter(new RetryPolicyFilter(retryPolicy)); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 13ee4bc9dc7a3..0ff1dc01cda9b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -30,7 +30,6 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.media.MediaContract; -import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; @@ -138,7 +137,8 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht AccessPolicyInfo accessPolicy = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); LocatorInfo locator = service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS)); - WritableBlobContainerContract uploader = MediaService.createBlobWriter(locator); + + WritableBlobContainerContract uploader = service.createBlobWriter(locator); Hashtable<String, AssetFileInfo> infoToUpload = new Hashtable<String, AssetFileInfo>(); From eaa19742fa8a70fc1c0e84f0580c513e79459825 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 11 Dec 2012 11:24:11 -0800 Subject: [PATCH 532/664] Final sweep - serialization types now use all nullable members --- .../media/implementation/content/AccessPolicyType.java | 10 +++++----- .../media/implementation/content/AssetType.java | 6 +++--- .../media/implementation/content/LocatorRestType.java | 6 +++--- .../media/implementation/content/TaskType.java | 2 +- .../services/media/models/AccessPolicyEntityTest.java | 5 +---- .../services/media/models/AssetEntityTest.java | 4 ++-- .../services/media/models/LocatorEntityTest.java | 4 ++-- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java index 219a65b668f16..6fe22bad67aac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -41,10 +41,10 @@ public class AccessPolicyType implements MediaServiceDTO { protected String name; @XmlElement(name = "DurationInMinutes", namespace = Constants.ODATA_DATA_NS) - protected double durationInMinutes; + protected Double durationInMinutes; @XmlElement(name = "Permissions", namespace = Constants.ODATA_DATA_NS) - protected int permissions; + protected Integer permissions; /** * @return the id @@ -113,7 +113,7 @@ public AccessPolicyType setName(String name) { /** * @return the durationInMinutes */ - public double getDurationInMinutes() { + public Double getDurationInMinutes() { return durationInMinutes; } @@ -129,7 +129,7 @@ public AccessPolicyType setDurationInMinutes(double durationInMinutes) { /** * @return the permissions */ - public int getPermissions() { + public Integer getPermissions() { return permissions; } @@ -137,7 +137,7 @@ public int getPermissions() { * @param permissions * the permissions to set */ - public AccessPolicyType setPermissions(int permissions) { + public AccessPolicyType setPermissions(Integer permissions) { this.permissions = permissions; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 7cc7b9bd3cf22..c341ab099a63b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -33,7 +33,7 @@ public class AssetType implements MediaServiceDTO { protected String id; @XmlElement(name = "State", namespace = Constants.ODATA_DATA_NS) - protected int state; + protected Integer state; @XmlElement(name = "Created", namespace = Constants.ODATA_DATA_NS) protected Date created; @@ -68,7 +68,7 @@ public void setId(String id) { /** * @return the state */ - public int getState() { + public Integer getState() { return state; } @@ -76,7 +76,7 @@ public int getState() { * @param state * the state to set */ - public void setState(int state) { + public void setState(Integer state) { this.state = state; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index 63b0cbee4aa1d..5dc08a2776268 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -38,7 +38,7 @@ public class LocatorRestType implements MediaServiceDTO { /** The type. */ @XmlElement(name = "Type", namespace = Constants.ODATA_DATA_NS) - protected int type; + protected Integer type; /** The path. */ @XmlElement(name = "Path", namespace = Constants.ODATA_DATA_NS) @@ -111,7 +111,7 @@ public LocatorRestType setExpirationDateTime(Date expirationDateTime) { * * @return the type */ - public int getType() { + public Integer getType() { return this.type; } @@ -122,7 +122,7 @@ public int getType() { * the type * @return the locator rest type */ - public LocatorRestType setType(int type) { + public LocatorRestType setType(Integer type) { this.type = type; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 67d92f8620b72..743316ae27528 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -70,7 +70,7 @@ public class TaskType implements MediaServiceDTO { protected String taskBody; @XmlElement(name = "Options", namespace = Constants.ODATA_DATA_NS) - protected int options; + protected Integer options; @XmlElement(name = "EncryptionKeyId", namespace = Constants.ODATA_DATA_NS) protected String encryptionKeyId; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index b3ba31d391914..c3533b379c4cc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -28,9 +28,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.models.AccessPolicy; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -58,7 +55,7 @@ public void createAccessPolicyProvidesExpectedPayload() throws Exception { assertEquals(name, payload.getName()); assertEquals(duration, payload.getDurationInMinutes(), 0.0); - assertEquals(AccessPolicyPermission.bitsFromPermissions(permissions), payload.getPermissions()); + assertEquals(AccessPolicyPermission.bitsFromPermissions(permissions), payload.getPermissions().intValue()); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 57ffe163e3c7c..5ec15ac69f1ac 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -46,7 +46,7 @@ public void assetCreateReturnsDefaultCreatePayload() { assertNotNull(payload); assertNull(payload.getId()); - assertEquals(0, payload.getState()); + assertNull(payload.getState()); assertNull(payload.getCreated()); assertNull(payload.getLastModified()); assertNull(payload.getAlternateId()); @@ -64,7 +64,7 @@ public void assetCreateCanSetAssetName() { assertNotNull(payload); assertNull(payload.getId()); - assertEquals(0, payload.getState()); + assertNull(payload.getState()); assertNull(payload.getCreated()); assertNull(payload.getLastModified()); assertNull(payload.getAlternateId()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 82fa8faed1fc5..41734de3972a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -61,7 +61,7 @@ public void createLocatorHasCorrectPayload() throws Exception { assertEquals(exampleAssetId, locatorType.getAssetId()); assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); - assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType().intValue()); assertNull(locatorType.getStartTime()); assertNull(locatorType.getExpirationDateTime()); } @@ -79,7 +79,7 @@ public void createLocatorCanSetTimes() throws Exception { assertEquals(exampleAssetId, locatorType.getAssetId()); assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); - assertEquals(LocatorType.SAS.getCode(), locatorType.getType()); + assertEquals(LocatorType.SAS.getCode(), locatorType.getType().intValue()); assertEquals(now, locatorType.getStartTime()); assertEquals(tomorrow, locatorType.getExpirationDateTime()); } From 69444b1654cdd0869e19645d51ee7ef45f4b29fb Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 11 Dec 2012 11:50:44 -0800 Subject: [PATCH 533/664] incorporate code review feedback. --- .../implementation/content/MediaUriType.java | 49 ++++++++++ .../entities/EntityActionOperation.java | 14 ++- .../entities/EntityLinkOperation.java | 98 ++++++++++++++----- .../services/media/models/Asset.java | 1 - .../services/media/AssetIntegrationTest.java | 3 +- 5 files changed, 138 insertions(+), 27 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java new file mode 100644 index 0000000000000..03ded08bb7492 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java @@ -0,0 +1,49 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; + +/** + * This type maps the URI. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "uri", namespace = Constants.ODATA_DATA_NS) +public class MediaUriType implements MediaServiceDTO { + @XmlValue + String uri; + + /** + * @return the uri. + */ + public String getUri() { + return uri; + } + + /** + * @param uri + * uri + * the uri to set + */ + public void setUri(String uri) { + this.uri = uri; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 868cc200e5807..019285038dac1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -47,12 +47,22 @@ public interface EntityActionOperation extends EntityOperation { * * @param clientResponse * the client response - * @return + * @return the object */ + Object processResponse(ClientResponse clientResponse); + /** + * Gets the verb. + * + * @return the verb + */ String getVerb(); + /** + * Gets the request contents. + * + * @return the request contents + */ Object getRequestContents(); - Object processResponse(ClientResponse clientResponse); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index 92407d2b44567..95ebbb27c40ea 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -20,44 +20,90 @@ import java.net.URLEncoder; import java.security.InvalidParameterException; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; + import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.MediaUriType; import com.sun.jersey.api.client.ClientResponse; /** - * Generic implementation of Delete operation usable by most entities. + * Generic implementation of $link operation of two entities. */ public class EntityLinkOperation extends DefaultActionOperation { /** The master entity set. */ - private final String masterEntitySet; + private final String primaryEntitySet; /** The master entity id. */ - private final String masterEntityId; + private final String primaryEntityId; /** The slave entity set. */ - private final String slaveEntitySet; + private final String secondaryEntitySet; /** The slave entity uri. */ - private final URI slaveEntityUri; + private final URI secondaryEntityUri; + + /** The jaxb context. */ + private final JAXBContext jaxbContext; + + /** The marshaller. */ + private final Marshaller marshaller; + + /** The document builder. */ + private final DocumentBuilder documentBuilder; + + /** The document builder factory. */ + private final DocumentBuilderFactory documentBuilderFactory; /** * Instantiates a new entity link operation. * - * @param masterEntitySet + * @param primaryEntitySet * the master entity set - * @param masterEntityId + * @param primaryEntityId * the master entity id - * @param slaveEntitySet + * @param secondaryEntitySet * the slave entity set - * @param slaveEntityUri + * @param secondaryEntityUri * the slave entity uri */ - public EntityLinkOperation(String masterEntitySet, String masterEntityId, String slaveEntitySet, URI slaveEntityUri) { + public EntityLinkOperation(String primaryEntitySet, String primaryEntityId, String secondaryEntitySet, + URI secondaryEntityUri) { super(); - this.masterEntitySet = masterEntitySet; - this.masterEntityId = masterEntityId; - this.slaveEntitySet = slaveEntitySet; - this.slaveEntityUri = slaveEntityUri; + this.primaryEntitySet = primaryEntitySet; + this.primaryEntityId = primaryEntityId; + this.secondaryEntitySet = secondaryEntitySet; + this.secondaryEntityUri = secondaryEntityUri; + try { + jaxbContext = JAXBContext.newInstance(MediaUriType.class); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + try { + marshaller = jaxbContext.createMarshaller(); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + documentBuilderFactory = DocumentBuilderFactory.newInstance(); + try { + documentBuilder = documentBuilderFactory.newDocumentBuilder(); + } + catch (ParserConfigurationException e) { + throw new RuntimeException(e); + } + } /* (non-Javadoc) @@ -67,12 +113,12 @@ public EntityLinkOperation(String masterEntitySet, String masterEntityId, String public String getUri() { String escapedEntityId; try { - escapedEntityId = URLEncoder.encode(masterEntityId, "UTF-8"); + escapedEntityId = URLEncoder.encode(primaryEntityId, "UTF-8"); } catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(masterEntityId); + throw new InvalidParameterException("UTF-8 encoding is not supported."); } - return String.format("%s('%s')/$links/%s", masterEntitySet, escapedEntityId, slaveEntitySet); + return String.format("%s('%s')/$links/%s", primaryEntitySet, escapedEntityId, secondaryEntitySet); } /* (non-Javadoc) @@ -97,10 +143,18 @@ public Object processResponse(ClientResponse clientResponse) { */ @Override public Object getRequestContents() { - String result = String - .format("<?xml version=\"1.0\" encoding=\"utf-8\"?><uri xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">%s</uri>", - this.slaveEntityUri); - - return result; + MediaUriType mediaUriType = new MediaUriType(); + mediaUriType.setUri(this.secondaryEntityUri.toString()); + JAXBElement<MediaUriType> mediaUriTypeElement = new JAXBElement<MediaUriType>(new QName( + Constants.ODATA_DATA_NS, "uri"), MediaUriType.class, mediaUriType); + Document document = documentBuilder.newDocument(); + document.setXmlStandalone(true); + try { + marshaller.marshal(mediaUriTypeElement, document); + } + catch (JAXBException e) { + throw new RuntimeException(e); + } + return document; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 6b176b611ac6e..aea5c606241d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -272,7 +272,6 @@ public static EntityDeleteOperation delete(String assetId) { * @return the entity action operation */ public static EntityLinkOperation linkContentKey(String assetId, URI contentKeyUri) { - return new EntityLinkOperation("Assets", assetId, "ContentKeys", contentKeyUri); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 8696fb1819bdb..b9d28161b7f58 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.UUID; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -279,7 +278,7 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { service.delete(Asset.delete(validButNonexistAssetId)); } - @Ignore("due to issue 507") + // @Ignore("due to issue 507") @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange From 612939eee88325bbe4ddfa13f835f7e891cfb3e2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 11 Dec 2012 11:51:44 -0800 Subject: [PATCH 534/664] code review feedback --- .../windowsazure/services/media/AssetIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index b9d28161b7f58..d2281b314fe40 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -278,7 +278,7 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { service.delete(Asset.delete(validButNonexistAssetId)); } - // @Ignore("due to issue 507") + @Ignore("due to issue 507") @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange From 3428beac09d492479d1ecec553b485173dd4f8fb Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 11 Dec 2012 11:52:12 -0800 Subject: [PATCH 535/664] code review feedback --- .../windowsazure/services/media/AssetIntegrationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index d2281b314fe40..8696fb1819bdb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.UUID; +import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; From a724c23e84e8eed2a29019540c4307c0e24297ea Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 11 Dec 2012 15:11:47 -0800 Subject: [PATCH 536/664] Removed setters from public Info classes - they are now immutable. --- .../implementation/content/AssetType.java | 21 +- .../content/MediaProcessorType.java | 18 +- .../media/models/AccessPolicyInfo.java | 77 +++--- .../services/media/models/AssetInfo.java | 92 -------- .../services/media/models/ContentKeyInfo.java | 120 ---------- .../services/media/models/JobInfo.java | 163 ------------- .../services/media/models/LocatorInfo.java | 116 --------- .../media/models/MediaProcessorInfo.java | 79 ------- .../services/media/models/TaskInfo.java | 223 ------------------ .../services/media/JobIntegrationTest.java | 16 +- .../media/models/AccessPolicyInfoTest.java | 28 ++- .../services/media/models/AssetInfoTest.java | 30 +-- .../media/models/ContentKeyInfoTest.java | 46 ++-- .../media/models/LocatorInfoTest.java | 43 ++-- .../media/models/MediaProcessorInfoTest.java | 31 ++- 15 files changed, 173 insertions(+), 930 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index c341ab099a63b..6563c1e08ffd8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -61,8 +61,9 @@ public String getId() { * @param id * the id to set */ - public void setId(String id) { + public AssetType setId(String id) { this.id = id; + return this; } /** @@ -76,8 +77,9 @@ public Integer getState() { * @param state * the state to set */ - public void setState(Integer state) { + public AssetType setState(Integer state) { this.state = state; + return this; } /** @@ -91,8 +93,9 @@ public Date getCreated() { * @param created * the created to set */ - public void setCreated(Date created) { + public AssetType setCreated(Date created) { this.created = created; + return this; } /** @@ -106,8 +109,9 @@ public Date getLastModified() { * @param lastModified * the lastModified to set */ - public void setLastModified(Date lastModified) { + public AssetType setLastModified(Date lastModified) { this.lastModified = lastModified; + return this; } /** @@ -121,8 +125,9 @@ public String getAlternateId() { * @param alternateId * the alternateId to set */ - public void setAlternateId(String alternateId) { + public AssetType setAlternateId(String alternateId) { this.alternateId = alternateId; + return this; } /** @@ -136,8 +141,9 @@ public String getName() { * @param name * the name to set */ - public void setName(String name) { + public AssetType setName(String name) { this.name = name; + return this; } /** @@ -151,7 +157,8 @@ public Integer getOptions() { * @param options * the options to set */ - public void setOptions(Integer options) { + public AssetType setOptions(Integer options) { this.options = options; + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java index de8338173a9b8..ec1966c204117 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -56,8 +56,9 @@ public String getId() { * @param id * the id to set */ - public void setId(String id) { + public MediaProcessorType setId(String id) { this.id = id; + return this; } /** @@ -71,39 +72,44 @@ public String getName() { * @param name * the name to set */ - public void setName(String name) { + public MediaProcessorType setName(String name) { this.name = name; + return this; } public String getDescription() { return this.description; } - public void setDescription(String description) { + public MediaProcessorType setDescription(String description) { this.description = description; + return this; } public String getSku() { return this.sku; } - public void setSku(String sku) { + public MediaProcessorType setSku(String sku) { this.sku = sku; + return this; } public String getVendor() { return vendor; } - public void setVendor(String vendor) { + public MediaProcessorType setVendor(String vendor) { this.vendor = vendor; + return this; } public String getVersion() { return this.version; } - public void setVersion(String version) { + public MediaProcessorType setVersion(String version) { this.version = version; + return this; } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java index f4d608dd712a5..09647b8a9711d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -22,67 +22,76 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; +/** + * Type containing data about access policies. + * + */ public class AccessPolicyInfo extends ODataEntity<AccessPolicyType> { + /** + * Creates a new {@link AccessPolicyInfo} wrapping the given ATOM + * entry and content objects. + * + * @param entry + * Entry containing this AccessPolicy data + * @param content + * Content with the AccessPolicy data + */ public AccessPolicyInfo(EntryType entry, AccessPolicyType content) { super(entry, content); } - public AccessPolicyInfo() { - super(new AccessPolicyType()); - } - + /** + * Get the access policy id. + * + * @return the id. + */ public String getId() { return getContent().getId(); } - public AccessPolicyInfo setId(String id) { - getContent().setId(id); - return this; - } - + /** + * Get the creation date. + * + * @return the date. + */ public Date getCreated() { return getContent().getCreated(); } - public AccessPolicyInfo setCreated(Date created) { - getContent().setCreated(created); - return this; - } - + /** + * Get the last modified date. + * + * @return the date. + */ public Date getLastModified() { return getContent().getLastModified(); } - public AccessPolicyInfo setLastModified(Date lastModified) { - getContent().setLastModified(lastModified); - return this; - } - + /** + * Get the name. + * + * @return the name. + */ public String getName() { return getContent().getName(); } - public AccessPolicyInfo setName(String name) { - getContent().setName(name); - return this; - } - + /** + * Get the duration. + * + * @return the duration. + */ public double getDurationInMinutes() { return getContent().getDurationInMinutes(); } - public AccessPolicyInfo setDurationInMinutes(double durationInMinutes) { - getContent().setDurationInMinutes(durationInMinutes); - return this; - } - + /** + * Get the permissions. + * + * @return the permissions. + */ public EnumSet<AccessPolicyPermission> getPermissions() { return AccessPolicyPermission.permissionsFromBits(getContent().getPermissions()); } - - public AccessPolicyInfo setPermissions(EnumSet<AccessPolicyPermission> permissions) { - getContent().setPermissions(AccessPolicyPermission.bitsFromPermissions(permissions)); - return this; - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index e187f252f9b29..f403eb492d91d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -39,13 +39,6 @@ public AssetInfo(EntryType entry, AssetType content) { super(entry, content); } - /** - * Instantiates a new asset info. - */ - public AssetInfo() { - super(new AssetType()); - } - /** * Get the asset id. * @@ -55,18 +48,6 @@ public String getId() { return getContent().getId(); } - /** - * Set the id. - * - * @param id - * the id - * @return the asset info - */ - public AssetInfo setId(String id) { - getContent().setId(id); - return this; - } - /** * Get the asset name. * @@ -76,18 +57,6 @@ public String getName() { return this.getContent().getName(); } - /** - * set the name. - * - * @param name - * the name - * @return the asset info - */ - public AssetInfo setName(String name) { - this.getContent().setName(name); - return this; - } - /** * Get the asset state. * @@ -97,18 +66,6 @@ public AssetState getState() { return AssetState.fromCode(getContent().getState()); } - /** - * Set the state. - * - * @param state - * the state - * @return the asset info - */ - public AssetInfo setState(AssetState state) { - getContent().setState(state.getCode()); - return this; - } - /** * Get the creation date. * @@ -118,18 +75,6 @@ public Date getCreated() { return this.getContent().getCreated(); } - /** - * Set creation date. - * - * @param created - * the date - * @return the asset info - */ - public AssetInfo setCreated(Date created) { - getContent().setCreated(created); - return this; - } - /** * Get last modified date. * @@ -139,18 +84,6 @@ public Date getLastModified() { return getContent().getLastModified(); } - /** - * Set last modified date. - * - * @param lastModified - * the date - * @return the asset info - */ - public AssetInfo setLastModified(Date lastModified) { - getContent().setLastModified(lastModified); - return this; - } - /** * Get the alternate id. * @@ -160,18 +93,6 @@ public String getAlternateId() { return getContent().getAlternateId(); } - /** - * Set the alternate id. - * - * @param alternateId - * the id - * @return the asset info - */ - public AssetInfo setAlternateId(String alternateId) { - getContent().setAlternateId(alternateId); - return this; - } - /** * Get the options. * @@ -180,17 +101,4 @@ public AssetInfo setAlternateId(String alternateId) { public EncryptionOption getOptions() { return EncryptionOption.fromCode(getContent().getOptions()); } - - /** - * Set the options. - * - * @param encryptionOption - * the encryption option - * @return the asset info - */ - public AssetInfo setOptions(EncryptionOption encryptionOption) { - getContent().setOptions(encryptionOption.getCode()); - return this; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 85b4eca7176f3..b03dd95a53c1d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -39,13 +39,6 @@ public ContentKeyInfo(EntryType entry, ContentKeyRestType content) { super(entry, content); } - /** - * Instantiates a new content key info. - */ - public ContentKeyInfo() { - super(new ContentKeyRestType()); - } - /** * Gets the id. * @@ -55,30 +48,6 @@ public String getId() { return getContent().getId(); } - /** - * Sets the id. - * - * @param id - * the id - * @return the content key info - */ - public ContentKeyInfo setId(String id) { - getContent().setId(id); - return this; - } - - /** - * Sets the create. - * - * @param created - * the created - * @return the content key info - */ - public ContentKeyInfo setCreated(Date created) { - getContent().setCreated(created); - return this; - } - /** * Gets the created. * @@ -97,18 +66,6 @@ public Date getLastModified() { return getContent().getLastModified(); } - /** - * Sets the last modified. - * - * @param lastModified - * the last modified - * @return the content key info - */ - public ContentKeyInfo setLastModified(Date lastModified) { - getContent().setLastModified(lastModified); - return this; - } - /** * Gets the name. * @@ -118,30 +75,6 @@ public String getName() { return getContent().getName(); } - /** - * Sets the name. - * - * @param name - * the name - * @return the content key info - */ - public ContentKeyInfo setName(String name) { - getContent().setName(name); - return this; - } - - /** - * Sets the check sum. - * - * @param checksum - * the check sum - * @return the content key info - */ - public ContentKeyInfo setChecksum(String checksum) { - getContent().setChecksum(checksum); - return this; - } - /** * Gets the check sum. * @@ -151,18 +84,6 @@ public String getChecksum() { return getContent().getChecksum(); } - /** - * Sets the protection key type. - * - * @param protectionKeyType - * the protection key type - * @return the content key info - */ - public ContentKeyInfo setProtectionKeyType(ProtectionKeyType protectionKeyType) { - getContent().setProtectionKeyType(protectionKeyType.getCode()); - return this; - } - /** * Gets the protection key type. * @@ -172,18 +93,6 @@ public ProtectionKeyType getProtectionKeyType() { return ProtectionKeyType.fromCode(getContent().getProtectionKeyType()); } - /** - * Sets the protection key id. - * - * @param protectionKeyId - * the protection key id - * @return the content key info - */ - public ContentKeyInfo setProtectionKeyId(String protectionKeyId) { - getContent().setProtectionKeyId(protectionKeyId); - return this; - } - /** * Gets the protection key id. * @@ -193,18 +102,6 @@ public String getProtectionKeyId() { return getContent().getProtectionKeyId(); } - /** - * Sets the encrypted content key. - * - * @param encryptedContentKey - * the encrypted content key - * @return the content key info - */ - public ContentKeyInfo setEncryptedContentKey(String encryptedContentKey) { - getContent().setEncryptedContentKey(encryptedContentKey); - return this; - } - /** * Gets the encrypted content key. * @@ -214,23 +111,6 @@ public String getEncryptedContentKey() { return getContent().getEncryptedContentKey(); } - /** - * Sets the content key type. - * - * @param contentKeyType - * the content key type - * @return the content key info - */ - public ContentKeyInfo setContentKeyType(ContentKeyType contentKeyType) { - if (contentKeyType == null) { - getContent().setContentKeyType(null); - } - else { - getContent().setContentKeyType(contentKeyType.getCode()); - } - return this; - } - /** * Gets the content key type. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 627081d001de7..23f9c36de43e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -39,13 +39,6 @@ public JobInfo(EntryType entry, JobType content) { super(entry, content); } - /** - * Instantiates a new job info. - */ - public JobInfo() { - super(new EntryType(), new JobType()); - } - /** * Gets the id. * @@ -55,18 +48,6 @@ public String getId() { return getContent().getId(); } - /** - * Sets the id. - * - * @param id - * the id - * @return the job info - */ - public JobInfo setId(String id) { - getContent().setId(id); - return this; - } - /** * Gets the name. * @@ -76,18 +57,6 @@ public String getName() { return getContent().getName(); } - /** - * Sets the name. - * - * @param name - * the name - * @return the job info - */ - public JobInfo setName(String name) { - getContent().setName(name); - return this; - } - /** * Gets the created. * @@ -97,18 +66,6 @@ public Date getCreated() { return getContent().getCreated(); } - /** - * Sets the created. - * - * @param created - * the created - * @return the job info - */ - public JobInfo setCreated(Date created) { - getContent().setCreated(created); - return this; - } - /** * Gets the last modified. * @@ -118,18 +75,6 @@ public Date getLastModified() { return getContent().getLastModified(); } - /** - * Sets the last modified. - * - * @param lastModified - * the last modified - * @return the job info - */ - public JobInfo setLastModified(Date lastModified) { - getContent().setLastModified(lastModified); - return this; - } - /** * Gets the end time. * @@ -139,18 +84,6 @@ public Date getEndTime() { return getContent().getEndTime(); } - /** - * Sets the end time. - * - * @param endTime - * the end time - * @return the job info - */ - public JobInfo setEndTime(Date endTime) { - getContent().setEndTime(endTime); - return this; - } - /** * Gets the priority. * @@ -160,18 +93,6 @@ public Integer getPriority() { return getContent().getPriority(); } - /** - * Sets the priority. - * - * @param priority - * the priority - * @return the job info - */ - public JobInfo setPriority(Integer priority) { - getContent().setPriority(priority); - return this; - } - /** * Gets the running duration. * @@ -181,18 +102,6 @@ public Double getRunningDuration() { return getContent().getRunningDuration(); } - /** - * Sets the running duration. - * - * @param runningDuration - * the running duration - * @return the job info - */ - public JobInfo setRunningDuration(Double runningDuration) { - getContent().setRunningDuration(runningDuration); - return this; - } - /** * Gets the start time. * @@ -202,18 +111,6 @@ public Date getStartTime() { return getContent().getStartTime(); } - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the job info - */ - public JobInfo setStartTime(Date startTime) { - getContent().setStartTime(startTime); - return this; - } - /** * Gets the state. * @@ -223,18 +120,6 @@ public JobState getState() { return JobState.fromCode(getContent().getState()); } - /** - * Sets the state. - * - * @param state - * the state - * @return the job info - */ - public JobInfo setState(JobState state) { - getContent().setState(state.getCode()); - return this; - } - /** * Gets the template id. * @@ -244,18 +129,6 @@ public String getTemplateId() { return getContent().getTemplateId(); } - /** - * Sets the template id. - * - * @param templateId - * the template id - * @return the job info - */ - public JobInfo setTemplateId(String templateId) { - getContent().setTemplateId(templateId); - return this; - } - /** * Gets the input media assets. * @@ -265,18 +138,6 @@ public List<String> getInputMediaAssets() { return getContent().getInputMediaAssets(); } - /** - * Sets the input media assets. - * - * @param inputMediaAssets - * the input media assets - * @return the job info - */ - public JobInfo setInputMediaAssets(List<String> inputMediaAssets) { - getContent().setInputMediaAssets(inputMediaAssets); - return this; - } - /** * Gets the output media assets. * @@ -286,18 +147,6 @@ public List<String> getOutputMediaAssets() { return getContent().getOutputMediaAssets(); } - /** - * Sets the output media assets. - * - * @param outputMediaAssets - * the output media assets - * @return the job info - */ - public JobInfo setOutputMediaAssets(List<String> outputMediaAssets) { - getContent().setOutputMediaAssets(outputMediaAssets); - return this; - } - /** * Gets the task body. * @@ -306,16 +155,4 @@ public JobInfo setOutputMediaAssets(List<String> outputMediaAssets) { public String getTaskBody() { return getContent().getTaskBody(); } - - /** - * Sets the tasks. - * - * @param tasks - * the tasks - * @return the job info - */ - public JobInfo setTaskBody(String taskBody) { - getContent().setTaskBody(taskBody); - return this; - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index 7c164b6385e61..b5ed565f80334 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -38,13 +38,6 @@ public LocatorInfo(EntryType entry, LocatorRestType content) { super(entry, content); } - /** - * Instantiates a new locator info. - */ - public LocatorInfo() { - super(new LocatorRestType()); - } - /** * Gets the id. * @@ -54,18 +47,6 @@ public String getId() { return getContent().getId(); } - /** - * Sets the id. - * - * @param id - * the id - * @return the locator info - */ - public LocatorInfo setId(String id) { - getContent().setId(id); - return this; - } - /** * Gets the expiration date time. * @@ -75,30 +56,6 @@ public Date getExpirationDateTime() { return getContent().getExpirationDateTime(); } - /** - * Sets the expiration date time. - * - * @param expirationDateTime - * the expiration date time - * @return the locator info - */ - public LocatorInfo setExpirationDateTime(Date expirationDateTime) { - getContent().setExpirationDateTime(expirationDateTime); - return this; - } - - /** - * Sets the locator type. - * - * @param locatorType - * the locator type - * @return the locator info - */ - public LocatorInfo setLocatorType(LocatorType locatorType) { - getContent().setType(locatorType.getCode()); - return this; - } - /** * Gets the locator type. * @@ -108,18 +65,6 @@ public LocatorType getLocatorType() { return LocatorType.fromCode(getContent().getType()); } - /** - * Sets the path. - * - * @param path - * the path - * @return the locator info - */ - public LocatorInfo setPath(String path) { - getContent().setPath(path); - return this; - } - /** * Gets the path. * @@ -129,18 +74,6 @@ public String getPath() { return getContent().getPath(); } - /** - * Sets the access policy id. - * - * @param accessPolicyId - * the access policy id - * @return the locator info - */ - public LocatorInfo setAccessPolicyId(String accessPolicyId) { - getContent().setAccessPolicyId(accessPolicyId); - return this; - } - /** * Gets the access policy id. * @@ -150,18 +83,6 @@ public String getAccessPolicyId() { return getContent().getAccessPolicyId(); } - /** - * Sets the asset id. - * - * @param assetId - * the asset id - * @return the locator info - */ - public LocatorInfo setAssetId(String assetId) { - getContent().setAssetId(assetId); - return this; - } - /** * Gets the asset id. * @@ -171,18 +92,6 @@ public String getAssetId() { return getContent().getAssetId(); } - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the locator info - */ - public LocatorInfo setStartTime(Date startTime) { - getContent().setStartTime(startTime); - return this; - } - /** * Gets the start time. * @@ -201,30 +110,6 @@ public String getBaseUri() { return getContent().getBaseUri(); } - /** - * Sets the base uri. - * - * @param baseUri - * the base uri - * @return the locator info - */ - public LocatorInfo setBaseUri(String baseUri) { - this.getContent().setBaseUri(baseUri); - return this; - } - - /** - * Sets the content access component. - * - * @param contentAccessComponent - * the content access component - * @return the locator info - */ - public LocatorInfo setContentAccessComponent(String contentAccessComponent) { - this.getContent().setContentAccessComponent(contentAccessComponent); - return this; - } - /** * Gets the content access token. * @@ -233,5 +118,4 @@ public LocatorInfo setContentAccessComponent(String contentAccessComponent) { public String getContentAccessToken() { return this.getContent().getContentAccessComponent(); } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java index 3fedc21bca39c..8d6ec26235a9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java @@ -38,13 +38,6 @@ public MediaProcessorInfo(EntryType entry, MediaProcessorType content) { super(entry, content); } - /** - * Instantiates a new media processor info. - */ - public MediaProcessorInfo() { - super(new MediaProcessorType()); - } - /** * Get the asset id. * @@ -54,18 +47,6 @@ public String getId() { return getContent().getId(); } - /** - * Set the id. - * - * @param id - * the id - * @return the asset info - */ - public MediaProcessorInfo setId(String id) { - getContent().setId(id); - return this; - } - /** * Get the asset name. * @@ -75,18 +56,6 @@ public String getName() { return this.getContent().getName(); } - /** - * set the name. - * - * @param name - * the name - * @return the asset info - */ - public MediaProcessorInfo setName(String name) { - this.getContent().setName(name); - return this; - } - /** * Gets the description. * @@ -96,18 +65,6 @@ public String getDescription() { return this.getContent().getDescription(); } - /** - * Sets the description. - * - * @param description - * the description - * @return the media processor info - */ - public MediaProcessorInfo setDescription(String description) { - this.getContent().setDescription(description); - return this; - } - /** * Gets the sku. * @@ -117,18 +74,6 @@ public String getSku() { return this.getContent().getSku(); } - /** - * Sets the sku. - * - * @param sku - * the sku - * @return the media processor info - */ - public MediaProcessorInfo setSku(String sku) { - this.getContent().setSku(sku); - return this; - } - /** * Gets the vendor. * @@ -138,18 +83,6 @@ public String getVendor() { return this.getContent().getVendor(); } - /** - * Sets the vendor. - * - * @param vendor - * the vendor - * @return the media processor info - */ - public MediaProcessorInfo setVendor(String vendor) { - this.getContent().setVendor(vendor); - return this; - } - /** * Gets the version. * @@ -158,16 +91,4 @@ public MediaProcessorInfo setVendor(String vendor) { public String getVersion() { return this.getContent().getVersion(); } - - /** - * Sets the version. - * - * @param version - * the version - * @return the media processor info - */ - public MediaProcessorInfo setVersion(String version) { - this.getContent().setVersion(version); - return this; - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index dda71ca5e6ea2..3ed2fc51d31d1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -38,13 +38,6 @@ public TaskInfo(EntryType entry, TaskType content) { super(entry, content); } - /** - * Instantiates a new task info. - */ - public TaskInfo() { - super(new TaskType()); - } - /** * Gets the id. * @@ -54,18 +47,6 @@ public String getId() { return getContent().getId(); } - /** - * Sets the id. - * - * @param id - * the id - * @return the task info - */ - public TaskInfo setId(String id) { - getContent().setId(id); - return this; - } - /** * Gets the configuration. * @@ -75,18 +56,6 @@ public String getConfiguration() { return getContent().getConfiguration(); } - /** - * Sets the configuration. - * - * @param configuration - * the configuration - * @return the task info - */ - public TaskInfo setConfiguration(String configuration) { - getContent().setConfiguration(configuration); - return this; - } - /** * Gets the end time. * @@ -96,18 +65,6 @@ public Date getEndTime() { return getContent().getEndTime(); } - /** - * Sets the end time. - * - * @param endTime - * the end time - * @return the task info - */ - public TaskInfo setEndTime(Date endTime) { - getContent().setEndTime(endTime); - return this; - } - /** * Gets the error details. * @@ -117,18 +74,6 @@ public String getErrorDetails() { return getContent().getErrorDetails(); } - /** - * Sets the error details. - * - * @param errorDetails - * the error details - * @return the task info - */ - public TaskInfo setErrorDetails(String errorDetails) { - getContent().setErrorDetails(errorDetails); - return this; - } - /** * Gets the media processor id. * @@ -138,18 +83,6 @@ public String getMediaProcessorId() { return getContent().getMediaProcessorId(); } - /** - * Sets the media processor id. - * - * @param mediaProcessorId - * the media processor id - * @return the task info - */ - public TaskInfo setMediaProcessorId(String mediaProcessorId) { - getContent().setMediaProcessorId(mediaProcessorId); - return this; - } - /** * Gets the name. * @@ -159,18 +92,6 @@ public String getName() { return getContent().getName(); } - /** - * Sets the name. - * - * @param name - * the name - * @return the task info - */ - public TaskInfo setName(String name) { - getContent().setName(name); - return this; - } - /** * Gets the perf message. * @@ -180,18 +101,6 @@ public String getPerfMessage() { return getContent().getPerfMessage(); } - /** - * Sets the perf message. - * - * @param perfMessage - * the perf message - * @return the task info - */ - public TaskInfo setPerfMessage(String perfMessage) { - getContent().setPerfMessage(perfMessage); - return this; - } - /** * Gets the priority. * @@ -201,18 +110,6 @@ public Integer getPriority() { return getContent().getPriority(); } - /** - * Sets the priority. - * - * @param priority - * the priority - * @return the task info - */ - public TaskInfo setPriority(Integer priority) { - getContent().setPriority(priority); - return this; - } - /** * Gets the progress. * @@ -222,17 +119,6 @@ public Double getProgress() { return getContent().getProgress(); } - /** - * - * @param progress - * the progress - * @return the task info - */ - public TaskInfo setProgress(Double progress) { - getContent().setProgress(progress); - return this; - } - /** * Gets the running duration. * @@ -242,18 +128,6 @@ public double getRunningDuration() { return getContent().getRunningDuration(); } - /** - * Sets the running duration. - * - * @param runningDuration - * the running duration - * @return the task info - */ - public TaskInfo setRunningDuration(double runningDuration) { - getContent().setRunningDuration(runningDuration); - return this; - } - /** * Gets the start time. * @@ -263,18 +137,6 @@ public Date getStartTime() { return getContent().getStartTime(); } - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the task info - */ - public TaskInfo setStartTime(Date startTime) { - getContent().setStartTime(startTime); - return this; - } - /** * Gets the state. * @@ -284,18 +146,6 @@ public Integer getState() { return getContent().getState(); } - /** - * Sets the state. - * - * @param state - * the state - * @return the task info - */ - public TaskInfo setState(Integer state) { - getContent().setState(state); - return this; - } - /** * Gets the task body. * @@ -305,18 +155,6 @@ public String getTaskBody() { return getContent().getTaskBody(); } - /** - * Sets the task body. - * - * @param taskBody - * the task body - * @return the task info - */ - public TaskInfo setTaskBody(String taskBody) { - getContent().setTaskBody(taskBody); - return this; - } - /** * Gets the options. * @@ -326,18 +164,6 @@ public Integer getOptions() { return getContent().getOptions(); } - /** - * Sets the options. - * - * @param options - * the options - * @return the task info - */ - public TaskInfo setOptions(Integer options) { - getContent().setOptions(options); - return this; - } - /** * Gets the encryption key id. * @@ -347,18 +173,6 @@ public String getEncryptionKeyId() { return getContent().getEncryptionKeyId(); } - /** - * Sets the encryption key id. - * - * @param encryptionKeyId - * the encryption key id - * @return the task info - */ - public TaskInfo setEncryptionKeyId(String encryptionKeyId) { - getContent().setEncryptionKeyId(encryptionKeyId); - return this; - } - /** * Gets the encryption scheme. * @@ -368,18 +182,6 @@ public String getEncryptionScheme() { return getContent().getEncryptionScheme(); } - /** - * Sets the encryption scheme. - * - * @param encryptionScheme - * the encryption scheme - * @return the task info - */ - public TaskInfo setEncryptionScheme(String encryptionScheme) { - getContent().setEncryptionScheme(encryptionScheme); - return this; - } - /** * Gets the encryption version. * @@ -389,18 +191,6 @@ public String getEncryptionVersion() { return getContent().getEncryptionVersion(); } - /** - * Sets the encryption version. - * - * @param encryptionVersion - * the encryption version - * @return the task info - */ - public TaskInfo setEncryptionVersion(String encryptionVersion) { - getContent().setEncryptionVersion(encryptionVersion); - return this; - } - /** * Gets the initialization vector. * @@ -409,17 +199,4 @@ public TaskInfo setEncryptionVersion(String encryptionVersion) { public String getInitializationVector() { return getContent().getInitializationVector(); } - - /** - * Sets the initialization vector. - * - * @param initializationVector - * the initialization vector - * @return the task info - */ - public TaskInfo setInitializationVector(String initializationVector) { - getContent().setInitializationVector(initializationVector); - return this; - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index cfcc0a909d6c2..90d4992ba4a44 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; @@ -116,11 +117,8 @@ public void createJobSuccess() throws Exception { // Arrange AssetInfo assetInfo = service.create(Asset.create()); - JobInfo expectedJob = new JobInfo(); - expectedJob.setName("My Encoding Job"); - expectedJob.setPriority(3); - expectedJob.setRunningDuration(0.0); - expectedJob.setState(JobState.Queued); + JobInfo expectedJob = new JobInfo(null, new JobType().setName("My Encoding Job").setPriority(3) + .setRunningDuration(0.0).setState(JobState.Queued.getCode())); AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy("createJobSuccess", 10); LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); @@ -152,11 +150,9 @@ public void createJobSuccess() throws Exception { @Test public void getJobSuccess() throws Exception { // Arrange - JobInfo expectedJob = new JobInfo(); - expectedJob.setName("My Encoding Job"); - expectedJob.setPriority(3); - expectedJob.setRunningDuration(0.0); - expectedJob.setState(JobState.Queued); + JobInfo expectedJob = new JobInfo(null, new JobType().setName("My Encoding Job").setPriority(3) + .setRunningDuration(0.0).setState(JobState.Queued.getCode())); + String jobId = createJob("getJobSuccess").getId(); // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java index c18e9a5297c56..6a1764eee282d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java @@ -21,65 +21,69 @@ import org.junit.Assert; import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; + public class AccessPolicyInfoTest { @Test public void getSetId() { - AccessPolicyInfo policy = new AccessPolicyInfo(); String expected = "expectedId"; - String actual = policy.setId(expected).getId(); + AccessPolicyInfo policy = new AccessPolicyInfo(null, new AccessPolicyType().setId(expected)); + + String actual = policy.getId(); Assert.assertEquals(expected, actual); } @Test public void getSetCreated() { - AccessPolicyInfo policy = new AccessPolicyInfo(); Date expected = new Date(); + AccessPolicyInfo policy = new AccessPolicyInfo(null, new AccessPolicyType().setCreated(expected)); - Date actual = policy.setCreated(expected).getCreated(); + Date actual = policy.getCreated(); Assert.assertEquals(expected, actual); } @Test public void getSetLastModified() { - AccessPolicyInfo policy = new AccessPolicyInfo(); Date expected = new Date(); + AccessPolicyInfo policy = new AccessPolicyInfo(null, new AccessPolicyType().setLastModified(expected)); - Date actual = policy.setLastModified(expected).getLastModified(); + Date actual = policy.getLastModified(); Assert.assertEquals(expected, actual); } @Test public void getSetName() { - AccessPolicyInfo policy = new AccessPolicyInfo(); String expected = "policy name goes here"; + AccessPolicyInfo policy = new AccessPolicyInfo(null, new AccessPolicyType().setName(expected)); - String actual = policy.setName(expected).getName(); + String actual = policy.getName(); Assert.assertEquals(expected, actual); } @Test public void getSetDurationInMinutes() { - AccessPolicyInfo policy = new AccessPolicyInfo(); double expected = 60; // arbitrary value + AccessPolicyInfo policy = new AccessPolicyInfo(null, new AccessPolicyType().setDurationInMinutes(expected)); - double actual = policy.setDurationInMinutes(expected).getDurationInMinutes(); + double actual = policy.getDurationInMinutes(); Assert.assertEquals(expected, actual, 0.0); } @Test public void getSetPermissions() { - AccessPolicyInfo policy = new AccessPolicyInfo(); EnumSet<AccessPolicyPermission> expected = EnumSet .of(AccessPolicyPermission.LIST, AccessPolicyPermission.WRITE); + AccessPolicyInfo policy = new AccessPolicyInfo(null, + new AccessPolicyType().setPermissions(AccessPolicyPermission.bitsFromPermissions(expected))); - EnumSet<AccessPolicyPermission> actual = policy.setPermissions(expected).getPermissions(); + EnumSet<AccessPolicyPermission> actual = policy.getPermissions(); Assert.assertEquals(expected, actual); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index 2e974c81773c9..3f794f40d6127 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -20,16 +20,18 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.AssetType; + public class AssetInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "expectedId"; - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setId(expectedId)); // Act - String actualId = assetInfo.setId(expectedId).getId(); + String actualId = assetInfo.getId(); // Assert assertEquals(expectedId, actualId); @@ -40,10 +42,10 @@ public void testGetSetId() { public void testGetSetState() { // Arrange AssetState expectedState = AssetState.Published; - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setState(expectedState.getCode())); // Act - AssetState actualState = assetInfo.setState(expectedState).getState(); + AssetState actualState = assetInfo.getState(); // Assert assertEquals(expectedState, actualState); @@ -54,10 +56,10 @@ public void testGetSetCreated() throws Exception { // Arrange Date expectedCreated = new Date(); - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setCreated(expectedCreated)); // Act - Date actualCreated = assetInfo.setCreated(expectedCreated).getCreated(); + Date actualCreated = assetInfo.getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -68,10 +70,10 @@ public void testGetSetCreated() throws Exception { public void testGetSetLastModified() throws Exception { // Arrange Date expectedLastModified = new Date(); - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setLastModified(expectedLastModified)); // Act - Date actualLastModified = assetInfo.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = assetInfo.getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); @@ -81,10 +83,10 @@ public void testGetSetLastModified() throws Exception { public void testGetSetAlternateId() { // Arrange String expectedAlternateId = "testAlternateId"; - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setAlternateId(expectedAlternateId)); // Act - String actualAlternateId = assetInfo.setAlternateId(expectedAlternateId).getAlternateId(); + String actualAlternateId = assetInfo.getAlternateId(); // Assert assertEquals(expectedAlternateId, actualAlternateId); @@ -94,10 +96,10 @@ public void testGetSetAlternateId() { public void testGetSetName() { // Arrange String expectedName = "testName"; - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setName(expectedName)); // Act - String actualName = assetInfo.setName(expectedName).getName(); + String actualName = assetInfo.getName(); // Assert assertEquals(expectedName, actualName); @@ -107,10 +109,10 @@ public void testGetSetName() { public void testGetSetOptions() { // Arrange EncryptionOption expectedOptions = EncryptionOption.None; - AssetInfo assetInfo = new AssetInfo(); + AssetInfo assetInfo = new AssetInfo(null, new AssetType().setOptions(expectedOptions.getCode())); // Act - EncryptionOption actualOptions = assetInfo.setOptions(expectedOptions).getOptions(); + EncryptionOption actualOptions = assetInfo.getOptions(); // Assert assertEquals(expectedOptions, actualOptions); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index 0e9a21e3cdc83..675b3dc090b02 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -20,16 +20,18 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; + public class ContentKeyInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "expectedId"; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, new ContentKeyRestType().setId(expectedId)); // Act - String actualId = contentKeyInfo.setId(expectedId).getId(); + String actualId = contentKeyInfo.getId(); // Assert assertEquals(expectedId, actualId); @@ -39,10 +41,10 @@ public void testGetSetId() { public void testGetSetCreated() { // Arrange Date expectedCreated = new Date(); - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, new ContentKeyRestType().setCreated(expectedCreated)); // Act - Date actualCreated = contentKeyInfo.setCreated(expectedCreated).getCreated(); + Date actualCreated = contentKeyInfo.getCreated(); // Assert assertEquals(expectedCreated, actualCreated); @@ -52,10 +54,11 @@ public void testGetSetCreated() { public void testGetSetLastModified() { // Arrange Date expectedLastModified = new Date(); - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, + new ContentKeyRestType().setLastModified(expectedLastModified)); // Act - Date actualLastModified = contentKeyInfo.setLastModified(expectedLastModified).getLastModified(); + Date actualLastModified = contentKeyInfo.getLastModified(); // Assert assertEquals(expectedLastModified, actualLastModified); @@ -65,11 +68,11 @@ public void testGetSetLastModified() { public void testGetSetContentKeyType() { // Arrange ContentKeyType expectedContentKeyType = ContentKeyType.ConfigurationEncryption; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, + new ContentKeyRestType().setContentKeyType(expectedContentKeyType.getCode())); // Act - ContentKeyType actualContentKeyType = contentKeyInfo.setContentKeyType(expectedContentKeyType) - .getContentKeyType(); + ContentKeyType actualContentKeyType = contentKeyInfo.getContentKeyType(); // Assert assertEquals(expectedContentKeyType, actualContentKeyType); @@ -80,11 +83,11 @@ public void testGetSetContentKeyType() { public void testGetSetEncryptedContentKey() { // Arrange String expectedEncryptedContentKey = "testX509Certificate"; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, + new ContentKeyRestType().setEncryptedContentKey(expectedEncryptedContentKey)); // Act - String actualEncryptedContentKey = contentKeyInfo.setEncryptedContentKey(expectedEncryptedContentKey) - .getEncryptedContentKey(); + String actualEncryptedContentKey = contentKeyInfo.getEncryptedContentKey(); // Assert assertEquals(expectedEncryptedContentKey, actualEncryptedContentKey); @@ -94,10 +97,10 @@ public void testGetSetEncryptedContentKey() { public void testGetSetName() { // Arrange String expectedName = "expectedName"; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, new ContentKeyRestType().setName(expectedName)); // Act - String actualName = contentKeyInfo.setName(expectedName).getName(); + String actualName = contentKeyInfo.getName(); // Assert assertEquals(expectedName, actualName); @@ -107,10 +110,11 @@ public void testGetSetName() { public void testGetSetProtectionKeyId() { // Arrange String expectedProtectionKeyId = "expectedProtectionKeyId"; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, + new ContentKeyRestType().setProtectionKeyId(expectedProtectionKeyId)); // Act - String actualProtectionKeyId = contentKeyInfo.setProtectionKeyId(expectedProtectionKeyId).getProtectionKeyId(); + String actualProtectionKeyId = contentKeyInfo.getProtectionKeyId(); // Assert assertEquals(expectedProtectionKeyId, actualProtectionKeyId); @@ -121,11 +125,11 @@ public void testGetSetProtectionKeyId() { public void testGetSetProtectionKeyType() { // Arrange ProtectionKeyType expectedProtectionKeyType = ProtectionKeyType.X509CertificateThumbprint; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, + new ContentKeyRestType().setProtectionKeyType(expectedProtectionKeyType.getCode())); // Act - ProtectionKeyType actualProtectionKeyType = contentKeyInfo.setProtectionKeyType(expectedProtectionKeyType) - .getProtectionKeyType(); + ProtectionKeyType actualProtectionKeyType = contentKeyInfo.getProtectionKeyType(); // Assert assertEquals(expectedProtectionKeyType, actualProtectionKeyType); @@ -135,10 +139,10 @@ public void testGetSetProtectionKeyType() { public void testGetSetCheckSum() { // Arrange String expectedCheckSum = "testCheckSum"; - ContentKeyInfo contentKeyInfo = new ContentKeyInfo(); + ContentKeyInfo contentKeyInfo = new ContentKeyInfo(null, new ContentKeyRestType().setChecksum(expectedCheckSum)); // Act - String actualCheckSum = contentKeyInfo.setChecksum(expectedCheckSum).getChecksum(); + String actualCheckSum = contentKeyInfo.getChecksum(); // Assert assertEquals(expectedCheckSum, actualCheckSum); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index 5b5c4ab547698..ab5ef0cf27206 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -20,16 +20,18 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; + public class LocatorInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "testId"; - LocatorInfo locator = new LocatorInfo(); + LocatorInfo locator = new LocatorInfo(null, new LocatorRestType().setId(expectedId)); // Act - String actualId = locator.setId(expectedId).getId(); + String actualId = locator.getId(); // Assert assertEquals(expectedId, actualId); @@ -39,11 +41,11 @@ public void testGetSetId() { public void testGetSetExpirationDateTime() { // Arrange Date expectedExpirationDateTime = new Date(); - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, + new LocatorRestType().setExpirationDateTime(expectedExpirationDateTime)); // Act - Date actualExpirationDateTime = locatorInfo.setExpirationDateTime(expectedExpirationDateTime) - .getExpirationDateTime(); + Date actualExpirationDateTime = locatorInfo.getExpirationDateTime(); // Assert assertEquals(expectedExpirationDateTime, actualExpirationDateTime); @@ -53,10 +55,10 @@ public void testGetSetExpirationDateTime() { public void testGetSetType() { // Arrange LocatorType expectedLocatorType = LocatorType.SAS; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setType(expectedLocatorType.getCode())); // Act - LocatorType actualLocatorType = locatorInfo.setLocatorType(expectedLocatorType).getLocatorType(); + LocatorType actualLocatorType = locatorInfo.getLocatorType(); // Assert assertEquals(expectedLocatorType, actualLocatorType); @@ -66,10 +68,10 @@ public void testGetSetType() { public void testGetSetPath() { // Arrange String expectedPath = "testPath"; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setPath(expectedPath)); // Act - String actualPath = locatorInfo.setPath(expectedPath).getPath(); + String actualPath = locatorInfo.getPath(); // Assert assertEquals(expectedPath, actualPath); @@ -79,10 +81,10 @@ public void testGetSetPath() { public void testGetSetAccessPolicyId() { // Arrange String expectedAccessPolicyId = "testAccessPolicyId"; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setAccessPolicyId(expectedAccessPolicyId)); // Act - String actualAccessPolicyId = locatorInfo.setAccessPolicyId(expectedAccessPolicyId).getAccessPolicyId(); + String actualAccessPolicyId = locatorInfo.getAccessPolicyId(); // Assert assertEquals(expectedAccessPolicyId, actualAccessPolicyId); @@ -92,10 +94,10 @@ public void testGetSetAccessPolicyId() { public void testGetSetAssetId() { // Arrange String expectedAssetId = "testAssetId"; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setAssetId(expectedAssetId)); // Act - String actualAssetId = locatorInfo.setAssetId(expectedAssetId).getAssetId(); + String actualAssetId = locatorInfo.getAssetId(); // Assert assertEquals(expectedAssetId, actualAssetId); @@ -105,10 +107,10 @@ public void testGetSetAssetId() { public void testGetSetStartTime() { // Arrange Date expectedStartTime = new Date(); - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setStartTime(expectedStartTime)); // Act - Date actualStartTime = locatorInfo.setStartTime(expectedStartTime).getStartTime(); + Date actualStartTime = locatorInfo.getStartTime(); // Assert assertEquals(expectedStartTime, actualStartTime); @@ -118,10 +120,10 @@ public void testGetSetStartTime() { public void testGetSetBaseUri() { // Arrange String expectedBaseUri = "testBaseUri"; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, new LocatorRestType().setBaseUri(expectedBaseUri)); // Act - String actualBaseUri = locatorInfo.setBaseUri(expectedBaseUri).getBaseUri(); + String actualBaseUri = locatorInfo.getBaseUri(); // Assert assertEquals(expectedBaseUri, actualBaseUri); @@ -131,14 +133,13 @@ public void testGetSetBaseUri() { public void testGetSetContentAccessComponent() { // Arrange String expectedContentAccessComponent = "testContentAccessToken"; - LocatorInfo locatorInfo = new LocatorInfo(); + LocatorInfo locatorInfo = new LocatorInfo(null, + new LocatorRestType().setContentAccessComponent(expectedContentAccessComponent)); // Act - String actualContentAccessComponent = locatorInfo.setContentAccessComponent(expectedContentAccessComponent) - .getContentAccessToken(); + String actualContentAccessComponent = locatorInfo.getContentAccessToken(); // Assert assertEquals(expectedContentAccessComponent, actualContentAccessComponent); - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java index c247486b1c482..4e05b0f5e4538 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -18,16 +18,18 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType; + public class MediaProcessorInfoTest { @Test public void testGetSetId() { // Arrange String expectedId = "expectedId"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, new MediaProcessorType().setId(expectedId)); // Act - String actualId = mediaProcessorInfo.setId(expectedId).getId(); + String actualId = mediaProcessorInfo.getId(); // Assert assertEquals(expectedId, actualId); @@ -38,10 +40,11 @@ public void testGetSetId() { public void testGetSetName() { // Arrange String expectedName = "testName"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, + new MediaProcessorType().setName(expectedName)); // Act - String actualName = mediaProcessorInfo.setName(expectedName).getName(); + String actualName = mediaProcessorInfo.getName(); // Assert assertEquals(expectedName, actualName); @@ -52,10 +55,11 @@ public void testGetSetDescription() throws Exception { // Arrange String expectedDescription = "testDescription"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, + new MediaProcessorType().setDescription(expectedDescription)); // Act - String actualDescription = mediaProcessorInfo.setDescription(expectedDescription).getDescription(); + String actualDescription = mediaProcessorInfo.getDescription(); // Assert assertEquals(expectedDescription, actualDescription); @@ -66,10 +70,11 @@ public void testGetSetDescription() throws Exception { public void testGetSetSku() throws Exception { // Arrange String expectedSku = "testSku"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, + new MediaProcessorType().setSku(expectedSku)); // Act - String actualSku = mediaProcessorInfo.setSku(expectedSku).getSku(); + String actualSku = mediaProcessorInfo.getSku(); // Assert assertEquals(expectedSku, actualSku); @@ -79,10 +84,11 @@ public void testGetSetSku() throws Exception { public void testGetSetVendor() { // Arrange String expectedVendor = "testVendor"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, + new MediaProcessorType().setVendor(expectedVendor)); // Act - String actualVendor = mediaProcessorInfo.setVendor(expectedVendor).getVendor(); + String actualVendor = mediaProcessorInfo.getVendor(); // Assert assertEquals(expectedVendor, actualVendor); @@ -92,10 +98,11 @@ public void testGetSetVendor() { public void testGetSetVersion() { // Arrange String expectedVersion = "testVersion"; - MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(); + MediaProcessorInfo mediaProcessorInfo = new MediaProcessorInfo(null, + new MediaProcessorType().setVersion(expectedVersion)); // Act - String actualVersion = mediaProcessorInfo.setVersion(expectedVersion).getVersion(); + String actualVersion = mediaProcessorInfo.getVersion(); // Assert assertEquals(expectedVersion, actualVersion); From b90716a62089caffa2d5fda391e8127f03ce928a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 11 Dec 2012 15:49:16 -0800 Subject: [PATCH 537/664] initial check in for encryption integration test. --- .../services/media/EncryptionHelper.java | 114 ++++++++++++++++++ .../media/EncryptionIntegrationTest.java | 99 +++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java new file mode 100644 index 0000000000000..0bc9e2fc06653 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -0,0 +1,114 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.Security; +import java.util.Random; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.CipherInputStream; +import javax.crypto.CipherOutputStream; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +public class EncryptionHelper { + public static void RSAOAEP() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, + InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + + byte[] input = "abc".getBytes(); + Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding", "BC"); + SecureRandom random = new SecureRandom(); + KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC"); + + generator.initialize(386, random); + + KeyPair pair = generator.generateKeyPair(); + Key pubKey = pair.getPublic(); + + Key privKey = pair.getPrivate(); + + cipher.init(Cipher.ENCRYPT_MODE, pubKey, random); + byte[] cipherText = cipher.doFinal(input); + System.out.println("cipher: " + new String(cipherText)); + + cipher.init(Cipher.DECRYPT_MODE, privKey); + byte[] plainText = cipher.doFinal(cipherText); + System.out.println("plain : " + new String(plainText)); + } + + public static byte[] create256BitRandomVector() { + int numberOfBits = 256; + int numberOfBytes = numberOfBits / 8; + byte[] aesKey = new byte[numberOfBytes]; + Random random = new Random(); + random.nextBytes(aesKey); + return aesKey; + } + + public static void AESCTR() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, + InvalidKeyException, InvalidAlgorithmParameterException, IOException { + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + byte[] input = "www.java2s.com".getBytes(); + byte[] keyBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] ivBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01 }; + + SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); + IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); + System.out.println("input : " + new String(input)); + + // encryption pass + cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); + ByteArrayInputStream bIn = new ByteArrayInputStream(input); + CipherInputStream cIn = new CipherInputStream(bIn, cipher); + ByteArrayOutputStream bOut = new ByteArrayOutputStream(); + + int ch; + while ((ch = cIn.read()) >= 0) { + bOut.write(ch); + } + + byte[] cipherText = bOut.toByteArray(); + + System.out.println("cipher: " + new String(cipherText)); + + // decryption pass + cipher.init(Cipher.DECRYPT_MODE, key, ivSpec); + bOut = new ByteArrayOutputStream(); + CipherOutputStream cOut = new CipherOutputStream(bOut, cipher); + cOut.write(cipherText); + cOut.close(); + System.out.println("plain : " + new String(bOut.toByteArray())); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java new file mode 100644 index 0000000000000..ef6a74f05e699 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -0,0 +1,99 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import java.util.UUID; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFileInfo; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; +import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; + +public class EncryptionIntegrationTest extends IntegrationTestBase { + + private final String validButNonexistContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473af"; + private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; + private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; + + private String createRandomContentKeyId() { + UUID uuid = UUID.randomUUID(); + String randomContentKey = String.format("nb:kid:UUID:%s", uuid); + return randomContentKey; + } + + private String getProtectionKey(ContentKeyType contentKeyType) { + String protectionKeyId = null; + try { + protectionKeyId = (String) service.action(ProtectionKey.getProtectionKeyId(contentKeyType)); + } + catch (ServiceException e) { + throw new RuntimeException(e); + } + String protectionKey; + try { + protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + } + catch (ServiceException e) { + throw new RuntimeException(e); + } + return protectionKey; + } + + @Test + public void uploadAesProtectedAssetAndDecryptSuccess() throws Exception { + // Arrange + + // Act + byte[] aesKey = EncryptionHelper.create256BitRandomVector(); + byte[] initializationVector = EncryptionHelper.create256BitRandomVector(); + + AssetInfo assetInfo = createAsset("uploadAesProtectedAssetSuccess"); + String protectionKey = getProtectionKey(ContentKeyType.StorageEncryption); + AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, protectionKey, assetFileName); + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, initializationVector); + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyInfo.getId())); + + // Assert + + } + + private ContentKeyInfo createContentKey(byte[] aesKey, byte[] initializationVector) { + // TODO Auto-generated method stub + return null; + } + + private String getProtectionKey(EncryptionOption storageencrypted) { + // TODO Auto-generated method stub + return null; + } + + private AssetInfo createAsset(String string) { + // TODO Auto-generated method stub + return null; + } + + private String createRandomInitializationVector() { + // TODO Auto-generated method stub + return null; + } + +} From 9977e8f9a4cc6acefad1e1cdcb790c42aa075c7a Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 11 Dec 2012 15:46:31 -0800 Subject: [PATCH 538/664] Renamed EncryptionOption to AssetOption --- .../services/media/models/Asset.java | 4 ++-- .../services/media/models/AssetInfo.java | 4 ++-- ...{EncryptionOption.java => AssetOption.java} | 16 ++++++++-------- .../services/media/AssetIntegrationTest.java | 18 +++++++++--------- .../services/media/models/AssetInfoTest.java | 5 +++-- .../scenarios/MediaServiceScenarioTest.java | 16 ++++++++-------- .../scenarios/MediaServiceValidation.java | 4 ++-- .../scenarios/MediaServiceWrapper.java | 4 ++-- 8 files changed, 36 insertions(+), 35 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/{EncryptionOption.java => AssetOption.java} (80%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index aea5c606241d0..e736b536d9e0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -71,7 +71,7 @@ public static class Creator extends EntityOperationSingleResultBase<AssetInfo> i private String alternateId; /** The options. */ - private EncryptionOption options; + private AssetOption options; /** The state. */ private AssetState state; @@ -132,7 +132,7 @@ public Creator setAlternateId(String alternateId) { * the options * @return the creator */ - public Creator setOptions(EncryptionOption options) { + public Creator setOptions(AssetOption options) { this.options = options; return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index f403eb492d91d..7572827f3c411 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -98,7 +98,7 @@ public String getAlternateId() { * * @return the options */ - public EncryptionOption getOptions() { - return EncryptionOption.fromCode(getContent().getOptions()); + public AssetOption getOptions() { + return AssetOption.fromCode(getContent().getOptions()); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java similarity index 80% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java index 6b989e3aa279d..6acd1f144c41f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/EncryptionOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java @@ -20,7 +20,7 @@ /** * Specifies the options for encryption. */ -public enum EncryptionOption { +public enum AssetOption { /** The None. */ None(0), @@ -38,7 +38,7 @@ public enum EncryptionOption { * @param encryptionOptionCode * the encryption option code */ - private EncryptionOption(int encryptionOptionCode) { + private AssetOption(int encryptionOptionCode) { this.encryptionOptionCode = encryptionOptionCode; } @@ -52,21 +52,21 @@ public int getCode() { } /** - * Create an EncryptionOption instance based on the + * Create an AssetOption instance based on the * given integer. * * @param option * the integer value of option - * @return The EncryptionOption + * @return The AssetOption */ - public static EncryptionOption fromCode(int option) { + public static AssetOption fromCode(int option) { switch (option) { case 0: - return EncryptionOption.None; + return AssetOption.None; case 1: - return EncryptionOption.StorageEncrypted; + return AssetOption.StorageEncrypted; case 2: - return EncryptionOption.CommonEncryptionProtected; + return AssetOption.CommonEncryptionProtected; default: throw new InvalidParameterException("option"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 8696fb1819bdb..acfbfa7868271 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -38,7 +38,7 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.sun.jersey.core.util.MultivaluedMapImpl; public class AssetIntegrationTest extends IntegrationTestBase { @@ -49,12 +49,12 @@ private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actu } private void verifyAssetProperties(String message, String testName, String altId, - EncryptionOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + AssetOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { verifyAssetProperties(message, testName, altId, encryptionOption, assetState, null, null, null, actualAsset); } private void verifyAssetProperties(String message, String testName, String altId, - EncryptionOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, + AssetOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, AssetInfo actualAsset) { assertNotNull(message, actualAsset); assertEquals(message + " Name", testName, actualAsset.getName()); @@ -77,7 +77,7 @@ public void createAssetOptionsSuccess() throws Exception { // Arrange String testName = testAssetPrefix + "createAssetOptionsSuccess"; String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetOption encryptionOption = AssetOption.StorageEncrypted; AssetState assetState = AssetState.Published; // Act @@ -113,7 +113,7 @@ public void createAssetNullNameSuccess() throws Exception { try { actualAsset = service.create(Asset.create()); // Assert - verifyAssetProperties("actualAsset", "", "", EncryptionOption.None, AssetState.Initialized, actualAsset); + verifyAssetProperties("actualAsset", "", "", AssetOption.None, AssetState.Initialized, actualAsset); } finally { // Clean up the anonymous asset now while we have the id, because we @@ -134,7 +134,7 @@ public void getAssetSuccess() throws Exception { // Arrange String testName = testAssetPrefix + "GetAssetSuccess"; String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetOption encryptionOption = AssetOption.StorageEncrypted; AssetState assetState = AssetState.Published; AssetInfo assetInfo = service.create(Asset.create().setName(testName).setAlternateId(altId) @@ -165,7 +165,7 @@ public void getAssetNonexistId() throws ServiceException { public void listAssetSuccess() throws ServiceException { // Arrange String altId = "altId"; - EncryptionOption encryptionOption = EncryptionOption.StorageEncrypted; + AssetOption encryptionOption = AssetOption.StorageEncrypted; AssetState assetState = AssetState.Published; String[] assetNames = new String[] { testAssetPrefix + "assetA", testAssetPrefix + "assetB" }; @@ -213,7 +213,7 @@ public void canListAssetsWithOptions() throws ServiceException { public void updateAssetSuccess() throws Exception { // Arrange String originalTestName = testAssetPrefix + "updateAssetSuccessOriginal"; - EncryptionOption originalEncryptionOption = EncryptionOption.StorageEncrypted; + AssetOption originalEncryptionOption = AssetOption.StorageEncrypted; AssetState originalAssetState = AssetState.Initialized; AssetInfo originalAsset = service.create(Asset.create().setName(originalTestName).setAlternateId("altId") .setOptions(originalEncryptionOption)); @@ -285,7 +285,7 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep // Arrange String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; AssetInfo assetInfo = service.create(Asset.create().setName(originalTestName) - .setOptions(EncryptionOption.StorageEncrypted)); + .setOptions(AssetOption.StorageEncrypted)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index 3f794f40d6127..21eba4a11ded9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -108,11 +108,12 @@ public void testGetSetName() { @Test public void testGetSetOptions() { // Arrange - EncryptionOption expectedOptions = EncryptionOption.None; + + AssetOption expectedOptions = AssetOption.None; AssetInfo assetInfo = new AssetInfo(null, new AssetType().setOptions(expectedOptions.getCode())); // Act - EncryptionOption actualOptions = assetInfo.getOptions(); + AssetOption actualOptions = assetInfo.getOptions(); // Assert assertEquals(expectedOptions, actualOptions); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index fa213a687e31f..55dca19d3a94c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -32,7 +32,7 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.MediaService; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; @@ -60,8 +60,8 @@ public static void cleanup() throws ServiceException { @Test public void newAsset() throws Exception { - AssetInfo asset = wrapper.createAsset(testAssetPrefix + "newAsset", EncryptionOption.None); - validator.validateAsset(asset, testAssetPrefix + "newAsset", EncryptionOption.None); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "newAsset", AssetOption.None); + validator.validateAsset(asset, testAssetPrefix + "newAsset", AssetOption.None); } @Test @@ -70,7 +70,7 @@ public void pageOverAssets() throws ServiceException { String rootName = testAssetPrefix + "pageOverAssets"; List<String> assetNames = createListOfAssetNames(rootName, 4); for (String assetName : assetNames) { - wrapper.createAsset(assetName, EncryptionOption.None); + wrapper.createAsset(assetName, AssetOption.None); } signalSetupFinished(); @@ -81,7 +81,7 @@ public void pageOverAssets() throws ServiceException { @Test public void uploadFiles() throws Exception { signalSetupStarting(); - AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadFiles", EncryptionOption.None); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadFiles", AssetOption.None); signalSetupFinished(); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); @@ -91,7 +91,7 @@ public void uploadFiles() throws Exception { @Test public void downloadFiles() throws Exception { signalSetupStarting(); - AssetInfo asset = wrapper.createAsset(testAssetPrefix + "downloadFiles", EncryptionOption.None); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "downloadFiles", AssetOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); @@ -102,7 +102,7 @@ public void downloadFiles() throws Exception { @Test public void createJob() throws Exception { signalSetupStarting(); - AssetInfo asset = wrapper.createAsset(testAssetPrefix + "createJob", EncryptionOption.None); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "createJob", AssetOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); @@ -114,7 +114,7 @@ public void createJob() throws Exception { @Test public void transformAsset() throws Exception { signalSetupStarting(); - AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", EncryptionOption.None); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", AssetOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); String jobName = "my job transformAsset"; JobInfo job = wrapper.createJob(jobName, asset, createTasks()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 4579a543a39cb..7de78be033c23 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -33,7 +33,7 @@ import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetState; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; @@ -45,7 +45,7 @@ public MediaServiceValidation(MediaContract service) { this.service = service; } - public void validateAsset(AssetInfo asset, String name, EncryptionOption encryption) throws ServiceException { + public void validateAsset(AssetInfo asset, String name, AssetOption encryption) throws ServiceException { // Check the asset state. assertNotNull("asset", asset); assertNotNull("asset.getId", asset.getId()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 0ff1dc01cda9b..c0d85220473ed 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -40,7 +40,7 @@ import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.Job.Creator; import com.microsoft.windowsazure.services.media.models.JobInfo; @@ -107,7 +107,7 @@ public MediaServiceWrapper(MediaContract service) { } // Manage - public AssetInfo createAsset(String name, EncryptionOption encryption) throws ServiceException { + public AssetInfo createAsset(String name, AssetOption encryption) throws ServiceException { // Create asset. The SDK's top-level method is the simplest way to do that. return service.create(Asset.create().setName(name).setAlternateId("altId").setOptions(encryption)); } From 7a6e5c1fa248d28a68ff3545969e133ee30990c2 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Tue, 11 Dec 2012 17:24:47 -0800 Subject: [PATCH 539/664] Turn on HTTP logging via configuration --- .../services/core/Configuration.java | 6 +++ ...ettings.java => ClientConfigSettings.java} | 47 ++++++++++++++++--- .../services/core/utils/pipeline/Exports.java | 47 +++++++++---------- .../media/implementation/MediaRestProxy.java | 25 +++++----- .../com.microsoft.windowsazure.properties | 1 + 5 files changed, 83 insertions(+), 43 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/{TimeoutSettings.java => ClientConfigSettings.java} (57%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java index e5afff9047a29..4eb524c6e10b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java @@ -35,6 +35,12 @@ public class Configuration { */ public static final String PROPERTY_READ_TIMEOUT = "com.microsoft.windowsazure.services.core.Configuration.readTimeout"; + /** + * Property name to control if HTTP logging to console is on or off. If property is set, logging is on, regardless + * of value. + */ + public static final String PROPERTY_LOG_HTTP_REQUESTS = "com.microsoft.windowsazure.services.core.Configuration.logHttpRequests"; + private static Configuration instance; Map<String, Object> properties; Builder builder; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java similarity index 57% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java index 9a671ba0a745d..75cfa5ef47828 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/TimeoutSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java @@ -15,37 +15,72 @@ package com.microsoft.windowsazure.services.core.utils.pipeline; +import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.config.ClientConfig; +import com.sun.jersey.api.client.filter.LoggingFilter; /** * Class used for injecting timeout settings into the various places that need it. * */ -public class TimeoutSettings { +public class ClientConfigSettings { private static final int DEFAULT_TIMEOUT_MS = 90 * 1000; private final Integer connectTimeout; private final Integer readTimeout; + private final boolean shouldLog; /** - * Construct a {@link TimeoutSettings} object with the default - * timeout. + * Construct a {@link ClientConfigSettings} object with the default + * settings. */ - public TimeoutSettings() { + public ClientConfigSettings() { connectTimeout = Integer.valueOf(null); readTimeout = Integer.valueOf(null); + shouldLog = false; } - public TimeoutSettings(Object connectTimeout, Object readTimeout) { + /** + * Construct a {@link ClientConfigSettings} object wit the given + * settings. + * + * @param connectTimeout + * Connection timeout in milliseconds + * @param readTimeout + * read timeout in milliseconds + * @param shouldLog + * if true, add logging filter to clients. + */ + public ClientConfigSettings(Object connectTimeout, Object readTimeout, boolean shouldLog) { this.connectTimeout = getTimeout(connectTimeout); this.readTimeout = getTimeout(readTimeout); + this.shouldLog = shouldLog; } - public void applyTimeout(ClientConfig clientConfig) { + /** + * Update the given {@link ClientConfig} object with the appropriate + * settings from configuration. + * + * @param clientConfig + * object to update. + */ + public void applyConfig(ClientConfig clientConfig) { clientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectTimeout); clientConfig.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout); } + /** + * Update the given {@link client} object with the appropriate settings + * from configuration. + * + * @param client + */ + public void applyConfig(Client client) { + if (shouldLog) { + client.addFilter(new LoggingFilter()); + } + } + private Integer getTimeout(Object timeoutValue) { if (timeoutValue == null) { return new Integer(DEFAULT_TIMEOUT_MS); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index 1826719d3a593..fc565c3dde132 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.core.utils.pipeline; import java.util.Map; -import java.util.Map.Entry; import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.core.Builder.Registry; @@ -32,34 +31,21 @@ public void register(Registry registry) { @Override public ClientConfig create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = new DefaultClientConfig(); - TimeoutSettings timeoutSettings = builder.build(profile, TimeoutSettings.class, properties); - timeoutSettings.applyTimeout(clientConfig); + ClientConfigSettings settings = builder.build(profile, ClientConfigSettings.class, properties); + settings.applyConfig(clientConfig); return clientConfig; } }); - registry.add(new Builder.Factory<TimeoutSettings>() { + registry.add(new Builder.Factory<ClientConfigSettings>() { @Override - public TimeoutSettings create(String profile, Builder builder, Map<String, Object> properties) { - Object connectTimeout = null; - Object readTimeout = null; + public ClientConfigSettings create(String profile, Builder builder, Map<String, Object> properties) { + Object connectTimeout = getPropertyIfExists(profile, properties, Configuration.PROPERTY_CONNECT_TIMEOUT); + Object readTimeout = getPropertyIfExists(profile, properties, Configuration.PROPERTY_READ_TIMEOUT); - profile = normalizeProfile(profile); - - for (Entry<String, Object> entry : properties.entrySet()) { - Object propertyValue = entry.getValue(); - String propertyKey = entry.getKey(); - - if (propertyKey.equals(profile + Configuration.PROPERTY_CONNECT_TIMEOUT)) { - connectTimeout = propertyValue; - } - if (propertyKey.equals(profile + Configuration.PROPERTY_READ_TIMEOUT)) { - readTimeout = propertyValue; - } - } - - return new TimeoutSettings(connectTimeout, readTimeout); + return new ClientConfigSettings(connectTimeout, readTimeout, getPropertyIfExists(profile, properties, + Configuration.PROPERTY_LOG_HTTP_REQUESTS) != null); } }); @@ -67,8 +53,9 @@ public TimeoutSettings create(String profile, Builder builder, Map<String, Objec @Override public Client create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); + ClientConfigSettings settings = builder.build(profile, ClientConfigSettings.class, properties); Client client = Client.create(clientConfig); - // client.addFilter(new LoggingFilter()); + settings.applyConfig(client); return client; } }); @@ -77,15 +64,16 @@ public Client create(String profile, Builder builder, Map<String, Object> proper @Override public HttpURLConnectionClient create(String profile, Builder builder, Map<String, Object> properties) { ClientConfig clientConfig = builder.build(profile, ClientConfig.class, properties); + ClientConfigSettings settings = builder.build(profile, ClientConfigSettings.class, properties); HttpURLConnectionClient client = HttpURLConnectionClient.create(clientConfig); - // client.addFilter(new LoggingFilter()); + settings.applyConfig(client); return client; } }); } private static String normalizeProfile(String profile) { - if (profile == null) { + if (profile == null || profile.equals("")) { return ""; } @@ -95,4 +83,13 @@ private static String normalizeProfile(String profile) { return profile + "."; } + + private static Object getPropertyIfExists(String profile, Map<String, Object> properties, String propertyName) { + String fullPropertyName = normalizeProfile(profile) + propertyName; + + if (properties.containsKey(fullPropertyName)) { + return properties.get(fullPropertyName); + } + return null; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 850cb69c74ca6..68240cdcc2578 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; import com.microsoft.windowsazure.services.core.ServiceFilter; -import com.microsoft.windowsazure.services.core.utils.pipeline.TimeoutSettings; +import com.microsoft.windowsazure.services.core.utils.pipeline.ClientConfigSettings; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; @@ -44,7 +44,7 @@ public class MediaRestProxy extends EntityRestProxy implements MediaContract { /** The redirect filter. */ private RedirectFilter redirectFilter; - private final TimeoutSettings timeoutSettings; + private final ClientConfigSettings clientConfigSettings; /** * Instantiates a new media rest proxy. @@ -57,16 +57,16 @@ public class MediaRestProxy extends EntityRestProxy implements MediaContract { * the redirect filter * @param versionHeadersFilter * the version headers filter - * @param timeoutSettings - * Currently configured HTTP client timeouts + * @param clientConfigSettings + * Currently configured HTTP client settings * */ @Inject public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter redirectFilter, - VersionHeadersFilter versionHeadersFilter, TimeoutSettings timeoutSettings) { + VersionHeadersFilter versionHeadersFilter, ClientConfigSettings clientConfigSettings) { super(channel, new ServiceFilter[0]); - this.timeoutSettings = timeoutSettings; + this.clientConfigSettings = clientConfigSettings; this.redirectFilter = redirectFilter; channel.addFilter(redirectFilter); channel.addFilter(authFilter); @@ -80,12 +80,12 @@ public MediaRestProxy(Client channel, OAuthFilter authFilter, RedirectFilter red * the channel * @param filters * the filters - * @param timeoutSettings - * currently configured HTTP client timeouts + * @param clientConfigSettings + * currently configured HTTP client settings */ - private MediaRestProxy(Client channel, ServiceFilter[] filters, TimeoutSettings timeoutSettings) { + private MediaRestProxy(Client channel, ServiceFilter[] filters, ClientConfigSettings clientConfigSettings) { super(channel, filters); - this.timeoutSettings = timeoutSettings; + this.clientConfigSettings = clientConfigSettings; } /* (non-Javadoc) @@ -96,7 +96,7 @@ public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; - return new MediaRestProxy(getChannel(), newFilters, timeoutSettings); + return new MediaRestProxy(getChannel(), newFilters, clientConfigSettings); } /* (non-Javadoc) @@ -151,8 +151,9 @@ String getSASToken() { private Client createUploaderClient() { ClientConfig clientConfig = new DefaultClientConfig(); - timeoutSettings.applyTimeout(clientConfig); + clientConfigSettings.applyConfig(clientConfig); Client client = Client.create(clientConfig); + clientConfigSettings.applyConfig(client); return client; } } \ No newline at end of file diff --git a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties index 7c3399f882ebf..1abb40b2238c1 100644 --- a/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties +++ b/microsoft-azure-api/src/test/resources/META-INF/com.microsoft.windowsazure.properties @@ -18,3 +18,4 @@ media.oauth.client.secret=%MEDIA.OAUTH.CLIENT.SECRET% media.oauth.scope=urn:WindowsAzureMediaServices testprefix.com.microsoft.windowsazure.services.core.Configuration.connectTimeout=3 testprefix.com.microsoft.windowsazure.services.core.Configuration.readTimeout=7 + From 2def69f2b2d3bbfa9874b43e648f2da890b404d9 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 11 Dec 2012 23:11:26 -0800 Subject: [PATCH 540/664] Update Job tests for #467 --- .../services/media/IntegrationTestBase.java | 19 +- .../services/media/JobIntegrationTest.java | 204 +++++++++++------- 2 files changed, 141 insertions(+), 82 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 71972f3ee6c28..df6918a26e466 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -21,6 +21,8 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -33,6 +35,7 @@ public abstract class IntegrationTestBase { protected static final String testAssetPrefix = "testAsset"; protected static final String testPolicyPrefix = "testPolicy"; protected static final String testContentKeyPrefix = "testContentKey"; + protected static final String testJobPrefix = "testJobPrefix"; protected static final String validButNonexistAssetId = "nb:cid:UUID:0239f11f-2d36-4e5f-aa35-44d58ccc0973"; protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:38dcb3a0-ef64-4ad0-bbb5-67a14c6df2f7"; @@ -52,7 +55,6 @@ public static void setup() throws Exception { overrideWithEnv(config, MediaConfiguration.OAUTH_CLIENT_SECRET); overrideWithEnv(config, MediaConfiguration.OAUTH_SCOPE); - // TODO: Replace with call to MediaService.create once that's updated service = MediaService.create(config); cleanupEnvironment(); @@ -79,6 +81,7 @@ private static void cleanupEnvironment() { removeAllTestAssets(); removeAllTestAccessPolicies(); removeAllTestContentKeys(); + removeAllTestJobs(); } private static void removeAllTestContentKeys() { @@ -138,6 +141,20 @@ private static void removeAllTestLocators() { } } + private static void removeAllTestJobs() { + try { + ListResult<JobInfo> jobs = service.list(Job.list()); + for (JobInfo job : jobs) { + if (job.getName().startsWith(testAssetPrefix)) { + service.delete(Job.delete(job.getId())); + } + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 90d4992ba4a44..dd1dd75ad32f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -21,15 +21,17 @@ import java.io.InputStream; import java.net.URI; import java.util.ArrayList; +import java.util.Date; import java.util.EnumSet; import java.util.List; +import java.util.UUID; import javax.ws.rs.core.MultivaluedMap; +import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; @@ -42,124 +44,166 @@ import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; public class JobIntegrationTest extends IntegrationTestBase { - private final String testJobPrefix = "testJobPrefix"; - private final byte[] testBlobData = new byte[] { 0, 1, 2 }; - private final String taskBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>"; + private static AssetInfo assetInfo; + private static final byte[] testBlobData = new byte[] { 0, 1, 2 }; private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), - expected.getState(), expected.getTemplateId(), expected.getInputMediaAssets(), + expected.getState(), expected.getTemplateId(), expected.getCreated(), expected.getLastModified(), + expected.getStartTime(), expected.getEndTime(), expected.getInputMediaAssets(), expected.getOutputMediaAssets(), actual); } - private AccessPolicyInfo createWritableAccessPolicy(String name, int durationInMinutes) throws ServiceException { - return service.create(AccessPolicy.create(testPolicyPrefix + name, durationInMinutes, - EnumSet.of(AccessPolicyPermission.WRITE))); - } - - private void createAndUploadBlob(WritableBlobContainerContract blobWriter, String blobName, byte[] blobData) - throws ServiceException { - InputStream blobContent = new ByteArrayInputStream(blobData); - blobWriter.createBlockBlob(blobName, blobContent); - } - - private String createFileAsset(String name) throws ServiceException { - String testBlobName = "test" + name + ".bin"; - AssetInfo assetInfo = service.create(Asset.create().setName(name)); - AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy(name, 10); - LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); - WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); - createAndUploadBlob(blobWriter, testBlobName, testBlobData); - - service.create(AssetFile.create(assetInfo.getId(), testBlobName).setIsPrimary(true).setIsEncrypted(false) - .setContentFileSize(new Long(testBlobData.length))); - - service.action(AssetFile.createFileInfos(assetInfo.getId())); - return assetInfo.getId(); - } - private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, - JobState state, String templateId, List<String> inputMediaAssets, List<String> outputMediaAssets, - JobInfo actualJob) { + JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime, + List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { assertNotNull(message, actualJob); + + assertNotNull(message + "Id", actualJob.getId()); + assertEquals(message + " Name", testName, actualJob.getName()); // comment out due to issue 464 // assertEquals(message + " Priority", priority, actualJob.getPriority()); assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); assertEquals(message + " State", state, actualJob.getState()); - // commented out due to issue 463 - // assertEquals(message + " TemplateId", templateId, actualJob.getTemplateId()); + assertEqualsNullEmpty(message + " TemplateId", templateId, actualJob.getTemplateId()); + + assertDateApproxEquals(message + " Created", created, actualJob.getCreated()); + assertDateApproxEquals(message + " LastModified", lastModified, actualJob.getLastModified()); + assertDateApproxEquals(message + " StartTime", startTime, actualJob.getStartTime()); + assertDateApproxEquals(message + " EndTime", endTime, actualJob.getEndTime()); + + // TODO: Add test for accessing the input and output media assets when fixed: + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); + + // TODO: Add test for accessing the tasks when fixed: + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/531 + } + + private void assertEqualsNullEmpty(String message, String expected, String actual) { + if ((expected == null || expected.length() == 0) && (actual == null || actual.length() == 0)) { + // both nullOrEmpty, so match. + } + else { + assertEquals(message, expected, actual); + } } private JobInfo createJob(String name) throws ServiceException { - String assetId = createFileAsset(name); URI serviceUri = service.getRestServiceUri(); - return service.create(Job - .create(serviceUri) - .setName("My Encoding Job") - .setPriority(3) - .addInputMediaAsset(assetId) - .addTaskCreator( - Task.create().setConfiguration("H.264 256k DSL CBR") - .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") - .setName("My encoding Task").setTaskBody(taskBody))); + return service.create(Job.create(serviceUri).setName(name).setPriority(3).addInputMediaAsset(assetInfo.getId()) + .addTaskCreator(getTaskCreator(0))); } - @Test - public void createJobSuccess() throws Exception { - // Arrange - AssetInfo assetInfo = service.create(Asset.create()); + private CreateBatchOperation getTaskCreator(int outputAssetPosition) { + return Task + .create() + .setConfiguration("H.264 256k DSL CBR") + .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") + .setName("My encoding Task") + .setTaskBody( + "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset(" + + outputAssetPosition + ")</outputAsset>" + "</taskBody>"); + } + + @BeforeClass + public static void setup() throws Exception { + IntegrationTestBase.setup(); - JobInfo expectedJob = new JobInfo(null, new JobType().setName("My Encoding Job").setPriority(3) - .setRunningDuration(0.0).setState(JobState.Queued.getCode())); + String name = UUID.randomUUID().toString(); + String testBlobName = "test" + name + ".bin"; + assetInfo = service.create(Asset.create().setName(testAssetPrefix + name)); - AccessPolicyInfo accessPolicyInfo = createWritableAccessPolicy("createJobSuccess", 10); + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + name, 10, + EnumSet.of(AccessPolicyPermission.WRITE))); LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); - createAndUploadBlob(blobWriter, "blob1.bin", testBlobData); - - service.create(AssetFile.create(assetInfo.getId(), "blob1.bin").setIsPrimary(true).setIsEncrypted(false) - .setContentFileSize(new Long(testBlobData.length))); + InputStream blobContent = new ByteArrayInputStream(testBlobData); + blobWriter.createBlockBlob(testBlobName, blobContent); service.action(AssetFile.createFileInfos(assetInfo.getId())); + } - URI serviceURI = service.getRestServiceUri(); + @Test + public void createJobSuccess() throws Exception { + // Arrange + String name = testJobPrefix + "createJobSuccess"; + int priority = 3; + double duration = 0.0; + JobState state = JobState.Queued; + String templateId = null; + List<String> inputMediaAssets = null; + List<String> outputMediaAssets = null; + Date created = new Date(); + Date lastModified = new Date(); + Date stateTime = null; + Date endTime = null; // Act - JobInfo actualJob = service.create(Job - .create(serviceURI) - .setName("My Encoding Job") - .setPriority(3) - .addInputMediaAsset(assetInfo.getId()) - .addTaskCreator( - Task.create().setConfiguration("H.264 256k DSL CBR") - .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") - .setName("My encoding Task").setTaskBody(taskBody))); + JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); // Assert - verifyJobInfoEqual("actualJob", expectedJob, actualJob); + verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, + endTime, inputMediaAssets, outputMediaAssets, actualJob); } @Test - public void getJobSuccess() throws Exception { + public void createJobTwoTasksSuccess() throws Exception { // Arrange - JobInfo expectedJob = new JobInfo(null, new JobType().setName("My Encoding Job").setPriority(3) - .setRunningDuration(0.0).setState(JobState.Queued.getCode())); + String name = testJobPrefix + "createJobSuccess"; + int priority = 3; + double duration = 0.0; + JobState state = JobState.Queued; + String templateId = null; + List<String> inputMediaAssets = null; + List<String> outputMediaAssets = null; + Date created = new Date(); + Date lastModified = new Date(); + Date stateTime = null; + Date endTime = null; + List<CreateBatchOperation> tasks = new ArrayList<CreateBatchOperation>(); + tasks.add(getTaskCreator(0)); + tasks.add(getTaskCreator(1)); + + // Act + JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); + + // Assert + verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, + endTime, inputMediaAssets, outputMediaAssets, actualJob); + } - String jobId = createJob("getJobSuccess").getId(); + @Test + public void getJobSuccess() throws Exception { + // Arrange + String name = testJobPrefix + "getJobSuccess"; + int priority = 3; + double duration = 0.0; + JobState state = JobState.Queued; + String templateId = null; + List<String> inputMediaAssets = null; + List<String> outputMediaAssets = null; + String jobId = createJob(name).getId(); + Date created = new Date(); + Date lastModified = new Date(); + Date stateTime = null; + Date endTime = null; // Act JobInfo actualJob = service.get(Job.get(jobId)); // Assert - verifyJobInfoEqual("actualJob", expectedJob, actualJob); + verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, + endTime, inputMediaAssets, outputMediaAssets, actualJob); } @Test @@ -172,7 +216,7 @@ public void getJobInvalidIdFailed() throws ServiceException { @Test public void listJobSuccess() throws ServiceException { // Arrange - JobInfo jobInfo = createJob("listJobSuccess"); + JobInfo jobInfo = createJob(testJobPrefix + "listJobSuccess"); List<JobInfo> jobInfos = new ArrayList<JobInfo>(); jobInfos.add(jobInfo); ListResult<JobInfo> expectedListJobsResult = new ListResult<JobInfo>(jobInfos); @@ -191,12 +235,10 @@ public void verifyEquals(String message, Object expected, Object actual) { @Test public void canListJobsWithOptions() throws ServiceException { - String[] assetNames = new String[] { testJobPrefix + "assetListOptionsA", testJobPrefix + "assetListOptionsB", - testJobPrefix + "assetListOptionsC", testJobPrefix + "assetListOptionsD" }; + String[] assetNameSuffixes = new String[] { "A", "B", "C", "D" }; List<JobInfo> expectedJobs = new ArrayList<JobInfo>(); - for (int i = 0; i < assetNames.length; i++) { - String name = assetNames[i]; - JobInfo jobInfo = createJob(name); + for (String suffix : assetNameSuffixes) { + JobInfo jobInfo = createJob(testJobPrefix + "assetListOptions" + suffix); expectedJobs.add(jobInfo); } @@ -211,7 +253,7 @@ public void canListJobsWithOptions() throws ServiceException { @Test public void cancelJobSuccess() throws Exception { // Arrange - JobInfo jobInfo = createJob("cancelJobSuccess"); + JobInfo jobInfo = createJob(testJobPrefix + "cancelJobSuccess"); // Act service.action(Job.cancel(jobInfo.getId())); @@ -237,7 +279,7 @@ public void cancelJobFailedWithInvalidId() throws ServiceException { @Test public void deleteJobSuccess() throws ServiceException { // Arrange - JobInfo jobInfo = createJob("deleteJobSuccess"); + JobInfo jobInfo = createJob(testJobPrefix + "deleteJobSuccess"); service.action(Job.cancel(jobInfo.getId())); JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); while (cancellingJobInfo.getState() == JobState.Canceling) { From e9e52f7cbf1e17a4d36a216956d5f657f09a2034 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 11 Dec 2012 23:55:29 -0800 Subject: [PATCH 541/664] secondary check in of security integration test. --- .../services/media/EncryptionHelper.java | 25 ++++++ .../media/EncryptionIntegrationTest.java | 85 ++++++++++++++---- .../src/test/resources/media/SmallWMV.wmv | Bin 0 -> 261862 bytes 3 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 microsoft-azure-api/src/test/resources/media/SmallWMV.wmv diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 0bc9e2fc06653..2999a790961b8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -21,12 +21,16 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; +import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; +import java.security.PublicKey; import java.security.SecureRandom; import java.security.Security; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.X509EncodedKeySpec; import java.util.Random; import javax.crypto.BadPaddingException; @@ -38,6 +42,8 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; + public class EncryptionHelper { public static void RSAOAEP() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { @@ -111,4 +117,23 @@ public static void AESCTR() throws NoSuchAlgorithmException, NoSuchProviderExcep System.out.println("plain : " + new String(bOut.toByteArray())); } + public static byte[] EncryptSymmetricKey(String publicKeyString, byte[] inputData) throws InvalidKeySpecException, + NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, NoSuchPaddingException, + IllegalBlockSizeException, BadPaddingException { + PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic( + new X509EncodedKeySpec(Base64.decode(publicKeyString))); + return EncryptSymmetricKey(publicKey, inputData); + + } + + public static byte[] EncryptSymmetricKey(Key publicKey, byte[] inputData) throws NoSuchAlgorithmException, + NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, + BadPaddingException { + Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding", "BC"); + SecureRandom secureRandom = new SecureRandom(); + cipher.init(Cipher.ENCRYPT_MODE, publicKey, secureRandom); + byte[] cipherText = cipher.doFinal(inputData); + return cipherText; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index ef6a74f05e699..f034e3498b49c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -15,17 +15,35 @@ package com.microsoft.windowsazure.services.media; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.spec.InvalidKeySpecException; import java.util.UUID; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.CipherInputStream; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.ProtectionKey; public class EncryptionIntegrationTest extends IntegrationTestBase { @@ -59,39 +77,76 @@ private String getProtectionKey(ContentKeyType contentKeyType) { } @Test - public void uploadAesProtectedAssetAndDecryptSuccess() throws Exception { + public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange + InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); // Act byte[] aesKey = EncryptionHelper.create256BitRandomVector(); byte[] initializationVector = EncryptionHelper.create256BitRandomVector(); - AssetInfo assetInfo = createAsset("uploadAesProtectedAssetSuccess"); - String protectionKey = getProtectionKey(ContentKeyType.StorageEncryption); - AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, protectionKey, assetFileName); - ContentKeyInfo contentKeyInfo = createContentKey(aesKey, initializationVector); - service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyInfo.getId())); + AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess")); + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.StorageEncryption)); + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId); + URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); + + byte[] encryptedContent = EncryptFile(smallWMVInputStream, aesKey, initializationVector); + AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, protectionKeyId, encryptedContent, aesKey, + initializationVector); + + // executeDecodingJob(assetInfo); // Assert + // verify the file downloaded is identical to the one that is uploaded. } - private ContentKeyInfo createContentKey(byte[] aesKey, byte[] initializationVector) { + private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, String protectionKeyId, + byte[] encryptedContent, byte[] aesKey, byte[] initializationVector) { // TODO Auto-generated method stub return null; } - private String getProtectionKey(EncryptionOption storageencrypted) { - // TODO Auto-generated method stub - return null; + private URI createContentKeyUri(URI rootUri, String contentKeyId) { + return URI.create(String.format("%s/ContentKeys('%s')", contentKeyId)); } - private AssetInfo createAsset(String string) { - // TODO Auto-generated method stub - return null; + private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) + throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, + InvalidAlgorithmParameterException, IOException { + // preparation + SecretKeySpec key = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector); + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); + + // encryption + cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); + // teArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input); + CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + int ch; + while ((ch = cipherInputStream.read()) >= 0) { + byteArrayOutputStream.write(ch); + } + + byte[] cipherText = byteArrayOutputStream.toByteArray(); + return cipherText; } - private String createRandomInitializationVector() { + private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId) + throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException, + NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ServiceException { + String contentKeyId = createRandomContentKeyId(); + byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKeyId, aesKey); + ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, contentKeyType, + Base64.encode(encryptedContentKey))); + return contentKeyInfo; + } + + private AssetInfo createAsset(String string) { // TODO Auto-generated method stub return null; } diff --git a/microsoft-azure-api/src/test/resources/media/SmallWMV.wmv b/microsoft-azure-api/src/test/resources/media/SmallWMV.wmv new file mode 100644 index 0000000000000000000000000000000000000000..4a87490e1d15b7ea2a2b01ec13a0c393bbddcb4b GIT binary patch literal 261862 zcmeFZbyOY8)-T#D2=4AI+}+(>LvVt-ySsaWTd*WpAh<*D0Kwfo1Pd;~<*sD!bHDSQ z@xJlKc;nr_?(QC4Rb5kR)~}1zU9)P!MpNtY#&R5^co8TAOvmh%aDhJuJS2qzasCID z;V&Wp`uqI*7Lth-PE5gVO<`o50tJJHrD{`ulVAWUKpRj7SOGP_1aJi`07t+bQnCls zA*nlH1G%^Q!wZ6>#D92YfLDMNpa^I|xLpA^2#*tl>-RwlutQE3fDLl-K+@mm?-D1# z0dPU+g#S%m1tM<&nE$zcOXL3G{w?v>^_M&VAOrG{R<r;Kh)n>bXE48+0WtN-ND}r5 z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RhB^r$48(ia1T|7}?@v z1IY~()xdo-$!L&s)eX}$pQY(L2je1V>e|{xG%Ebt1QZjz0fyDAr%!8$QYB-drx`&^ zy`z*&l&bnmDBt;|GXhX?+ruHWF+OB|!}`@cPTKHlsvGXaMzsnm)<;am!tV$HPu1ke z+)N=8s)6>DhOCNQh<kgn+G3+@Ja9Ea-!G{6=!KF~TC=DxJ1(T9G1Kh=M9q9p(Mhk5 z=acix(=CZYY&M6c6Gm=5YWwWJ8@~UZe+m3c;9mm&68M+E|DOPw4j@_acj!j=0U)cF z3fli4PtoPGw?aleJnGG~(p0hEf62u$1}1*_Pch)7(*18)%KzN|xBmAwbs*q>^uGWL CeN#yQ literal 0 HcmV?d00001 From e00f3f84176feef12590e2866298e66253d55839 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 12 Dec 2012 14:32:46 -0800 Subject: [PATCH 542/664] Update test data with something a little more distinct, so it is clearer that it is from this process --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index dd1dd75ad32f0..bfa003d0cc98d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -50,7 +50,7 @@ public class JobIntegrationTest extends IntegrationTestBase { private static AssetInfo assetInfo; - private static final byte[] testBlobData = new byte[] { 0, 1, 2 }; + private static final byte[] testBlobData = new byte[] { 4, 8, 15, 16, 23, 42 }; private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), From 3494e055414d8a7c63fedf87355c20a46e3becb6 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 12 Dec 2012 16:25:50 -0800 Subject: [PATCH 543/664] Exposing links from ODataEntity class --- .../media/implementation/ODataEntity.java | 64 ++++++++++ .../implementation/LinkRetrievalTest.java | 112 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 4d3ce09d1dc96..3cea0cd4c1ad4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -17,11 +17,14 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.JAXBElement; import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.models.ListResult; @@ -40,6 +43,7 @@ protected ODataEntity(EntryType entry, T content) { this.content = content; } + @SuppressWarnings({ "unchecked", "rawtypes" }) protected ODataEntity(T content) { this.content = content; @@ -65,6 +69,66 @@ protected T getContent() { return content; } + /** + * Test if the entity contains a link with the given title. + * + * @param title + * Title of link to check for + * @return True if link is included, false if not. + */ + public boolean hasLink(String title) { + return getLink(title) != null; + } + + /** + * Get the link with the given title + * + * @param title + * Title of link to retrieve + * @return The link if found, null if not. + */ + public LinkType getLink(String title) { + for (Object child : entry.getEntryChildren()) { + + LinkType link = LinkFromChild(child); + if (link != null && link.getTitle().equals(title)) { + return link; + } + } + return null; + } + + /** + * Return the links from this entry + * + * @return List of the links. + */ + public List<LinkType> getLinks() { + ArrayList<LinkType> links = new ArrayList<LinkType>(); + for (Object child : entry.getEntryChildren()) { + LinkType link = LinkFromChild(child); + if (link != null) { + links.add(link); + } + } + return links; + } + + @SuppressWarnings("rawtypes") + private static LinkType LinkFromChild(Object child) { + if (child instanceof JAXBElement) { + return LinkFromElement((JAXBElement) child); + } + return null; + } + + private static LinkType LinkFromElement(@SuppressWarnings("rawtypes") JAXBElement element) { + if (element.getDeclaredType() == LinkType.class) { + return (LinkType) element.getValue(); + } + return null; + } + /** * Is the given type inherited from ODataEntity * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java new file mode 100644 index 0000000000000..7e4180eb6da20 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -0,0 +1,112 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation; + +import static org.junit.Assert.*; + +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.junit.Before; +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; + +/** + * Testing retrieval of links from ATOM entities + * + */ +public class LinkRetrievalTest { + private static QName linkName = new QName("link", Constants.ATOM_NS); + private MediaProcessorInfo info; + private LinkType link1; + private LinkType link2; + + @Before + public void setup() { + EntryType entry = new EntryType(); + + link1 = new LinkType(); + link1.setTitle("someLink"); + link1.setRel("Related/something"); + link1.setHref("some/uri/somewhere"); + + link2 = new LinkType(); + link2.setTitle("someOtherLink"); + link2.setRel("Related/else"); + link2.setHref("some/other/href/somewhere"); + + entry.getEntryChildren().add(new JAXBElement<LinkType>(linkName, LinkType.class, link1)); + entry.getEntryChildren().add(new JAXBElement<LinkType>(linkName, LinkType.class, link2)); + + MediaProcessorType payload = new MediaProcessorType().setId("DummyId").setName("Dummy Name") + .setVersion("0.0.0").setVendor("Contoso").setSku("sku skiddo").setDescription("For testing links only"); + + ContentType contentElement = new ContentType(); + contentElement.getContent().add( + new JAXBElement<MediaProcessorType>(Constants.ODATA_PROPERTIES_ELEMENT_NAME, MediaProcessorType.class, + payload)); + + entry.getEntryChildren().add( + new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentElement)); + + info = new MediaProcessorInfo(entry, payload); + } + + @Test + public void canRetrieveSingleLinkFromEntity() { + assertTrue(info.hasLink("someLink")); + } + + @Test + public void getFalseWhenLinkIsntThere() { + assertFalse(info.hasLink("noSuchLink")); + } + + @Test + public void canRetrieveEntireLinkByTitle() { + LinkType link = info.getLink("someOtherLink"); + + assertLinksEqual(link2, link); + } + + @Test + public void getNullWhenLinkIsntThere() { + assertNull(info.getLink("noSuchLink")); + } + + @Test + public void getLinksReturnsTwoExpectedLinksInOrder() { + List<LinkType> links = info.getLinks(); + + assertEquals(2, links.size()); + assertLinksEqual(link1, links.get(0)); + assertLinksEqual(link2, links.get(1)); + } + + private static void assertLinksEqual(LinkType expected, LinkType actual) { + assertEquals(expected.getTitle(), actual.getTitle()); + assertEquals(expected.getRel(), actual.getRel()); + assertEquals(expected.getHref(), actual.getHref()); + } +} From c1e21262eac469d936c55e2c7f02fa79765455c2 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 12 Dec 2012 16:34:01 -0800 Subject: [PATCH 544/664] Looking for links based on rel, not title --- .../media/implementation/ODataEntity.java | 22 +++++++++---------- .../implementation/LinkRetrievalTest.java | 6 ++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 3cea0cd4c1ad4..a77f800b6c0f9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -70,28 +70,28 @@ protected T getContent() { } /** - * Test if the entity contains a link with the given title. + * Test if the entity contains a link with the given rel attribute. * - * @param title - * Title of link to check for - * @return True if link is included, false if not. + * @param rel + * Rel of link to check for + * @return True if link is found, false if not. */ - public boolean hasLink(String title) { - return getLink(title) != null; + public boolean hasLink(String rel) { + return getLink(rel) != null; } /** - * Get the link with the given title + * Get the link with the given rel attribute * - * @param title - * Title of link to retrieve + * @param rel + * rel of link to retrieve * @return The link if found, null if not. */ - public LinkType getLink(String title) { + public LinkType getLink(String rel) { for (Object child : entry.getEntryChildren()) { LinkType link = LinkFromChild(child); - if (link != null && link.getTitle().equals(title)) { + if (link != null && link.getRel().equals(rel)) { return link; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 7e4180eb6da20..a0dac584bcdc0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -75,7 +75,7 @@ public void setup() { @Test public void canRetrieveSingleLinkFromEntity() { - assertTrue(info.hasLink("someLink")); + assertTrue(info.hasLink(link1.getRel())); } @Test @@ -84,8 +84,8 @@ public void getFalseWhenLinkIsntThere() { } @Test - public void canRetrieveEntireLinkByTitle() { - LinkType link = info.getLink("someOtherLink"); + public void canRetrieveEntireLinkByRel() { + LinkType link = info.getLink(link2.getRel()); assertLinksEqual(link2, link); } From 8cdcb8bdb71152b09c3b9d5ab55cd40f7feb3afb Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 12 Dec 2012 16:41:28 -0800 Subject: [PATCH 545/664] Exposing immutable LinkInfo from public API, with only properties OData sets. --- .../media/implementation/ODataEntity.java | 11 +-- .../services/media/models/LinkInfo.java | 69 +++++++++++++++++++ .../implementation/LinkRetrievalTest.java | 8 ++- 3 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index a77f800b6c0f9..fa1a382f72117 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -26,6 +26,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.models.LinkInfo; import com.microsoft.windowsazure.services.media.models.ListResult; /** @@ -87,12 +88,12 @@ public boolean hasLink(String rel) { * rel of link to retrieve * @return The link if found, null if not. */ - public LinkType getLink(String rel) { + public LinkInfo getLink(String rel) { for (Object child : entry.getEntryChildren()) { LinkType link = LinkFromChild(child); if (link != null && link.getRel().equals(rel)) { - return link; + return new LinkInfo(link); } } return null; @@ -103,12 +104,12 @@ public LinkType getLink(String rel) { * * @return List of the links. */ - public List<LinkType> getLinks() { - ArrayList<LinkType> links = new ArrayList<LinkType>(); + public List<LinkInfo> getLinks() { + ArrayList<LinkInfo> links = new ArrayList<LinkInfo>(); for (Object child : entry.getEntryChildren()) { LinkType link = LinkFromChild(child); if (link != null) { - links.add(link); + links.add(new LinkInfo(link)); } } return links; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java new file mode 100644 index 0000000000000..0acf7e6b2e431 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -0,0 +1,69 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; + +/** + * Provides access to OData links + * + */ +public class LinkInfo { + private final LinkType rawLink; + + /** + * Construct a new {@link LinkInfo} instance + */ + public LinkInfo(LinkType rawLink) { + this.rawLink = rawLink; + } + + /** + * Get link rel + * + * @return the rel + */ + public String getRel() { + return rawLink.getRel(); + } + + /** + * Get link type + * + * @return the type + */ + public String getType() { + return rawLink.getType(); + } + + /** + * Get link href + * + * @return the href + */ + public String getHref() { + return rawLink.getHref(); + } + + /** + * Get link title + * + * @return the title + */ + public String getTitle() { + return rawLink.getTitle(); + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index a0dac584bcdc0..56ff698b68c32 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -30,6 +30,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType; +import com.microsoft.windowsazure.services.media.models.LinkInfo; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; /** @@ -85,7 +86,7 @@ public void getFalseWhenLinkIsntThere() { @Test public void canRetrieveEntireLinkByRel() { - LinkType link = info.getLink(link2.getRel()); + LinkInfo link = info.getLink(link2.getRel()); assertLinksEqual(link2, link); } @@ -97,16 +98,17 @@ public void getNullWhenLinkIsntThere() { @Test public void getLinksReturnsTwoExpectedLinksInOrder() { - List<LinkType> links = info.getLinks(); + List<LinkInfo> links = info.getLinks(); assertEquals(2, links.size()); assertLinksEqual(link1, links.get(0)); assertLinksEqual(link2, links.get(1)); } - private static void assertLinksEqual(LinkType expected, LinkType actual) { + private static void assertLinksEqual(LinkType expected, LinkInfo actual) { assertEquals(expected.getTitle(), actual.getTitle()); assertEquals(expected.getRel(), actual.getRel()); assertEquals(expected.getHref(), actual.getHref()); + assertEquals(expected.getType(), actual.getType()); } } From 6a0a9304fdeca47bffc790483f8e46a8df933339 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 12 Dec 2012 18:01:47 -0800 Subject: [PATCH 546/664] get the content key encryption part working. --- .../services/media/EncryptionHelper.java | 29 ++++++++++++------- .../media/EncryptionIntegrationTest.java | 23 ++++++++++----- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 2999a790961b8..8b553362d139b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -21,16 +21,16 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; -import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.PublicKey; import java.security.SecureRandom; import java.security.Security; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; import java.security.spec.InvalidKeySpecException; -import java.security.spec.X509EncodedKeySpec; import java.util.Random; import javax.crypto.BadPaddingException; @@ -70,8 +70,7 @@ public static void RSAOAEP() throws NoSuchAlgorithmException, NoSuchProviderExce System.out.println("plain : " + new String(plainText)); } - public static byte[] create256BitRandomVector() { - int numberOfBits = 256; + public static byte[] createRandomVector(int numberOfBits) { int numberOfBytes = numberOfBits / 8; byte[] aesKey = new byte[numberOfBytes]; Random random = new Random(); @@ -117,12 +116,22 @@ public static void AESCTR() throws NoSuchAlgorithmException, NoSuchProviderExcep System.out.println("plain : " + new String(bOut.toByteArray())); } - public static byte[] EncryptSymmetricKey(String publicKeyString, byte[] inputData) throws InvalidKeySpecException, + public static byte[] EncryptSymmetricKey(String protectionKey, byte[] inputData) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, NoSuchPaddingException, - IllegalBlockSizeException, BadPaddingException { - PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic( - new X509EncodedKeySpec(Base64.decode(publicKeyString))); - return EncryptSymmetricKey(publicKey, inputData); + IllegalBlockSizeException, BadPaddingException, CertificateException { + + X509Certificate x509Certificate = createX509CertificateFromString(protectionKey); + //X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decode(publicKeyString)); + // PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(x509EncodedKeySpec); + return EncryptSymmetricKey(x509Certificate.getPublicKey(), inputData); + + } + + private static X509Certificate createX509CertificateFromString(String protectionKey) throws CertificateException { + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Base64.decode(protectionKey)); + X509Certificate x509cert = (X509Certificate) certificateFactory.generateCertificate(byteArrayInputStream); + return x509cert; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index f034e3498b49c..5f0ec48f00c15 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -23,6 +23,8 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; +import java.security.Security; +import java.security.cert.CertificateException; import java.security.spec.InvalidKeySpecException; import java.util.UUID; @@ -44,6 +46,7 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.ProtectionKey; public class EncryptionIntegrationTest extends IntegrationTestBase { @@ -79,16 +82,19 @@ private String getProtectionKey(ContentKeyType contentKeyType) { @Test public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); // Act - byte[] aesKey = EncryptionHelper.create256BitRandomVector(); - byte[] initializationVector = EncryptionHelper.create256BitRandomVector(); + byte[] aesKey = EncryptionHelper.createRandomVector(128); + byte[] initializationVector = EncryptionHelper.createRandomVector(128); - AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess")); + AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") + .setOptions(EncryptionOption.StorageEncrypted)); String protectionKeyId = (String) service.action(ProtectionKey .getProtectionKeyId(ContentKeyType.StorageEncryption)); - ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId); + String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKey); URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); @@ -110,7 +116,7 @@ private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, String prote } private URI createContentKeyUri(URI rootUri, String contentKeyId) { - return URI.create(String.format("%s/ContentKeys('%s')", contentKeyId)); + return URI.create(String.format("%s/ContentKeys('%s')", rootUri, contentKeyId)); } private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) @@ -136,11 +142,12 @@ private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initia return cipherText; } - private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId) + private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKey) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException, - NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ServiceException { + NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ServiceException, + CertificateException { String contentKeyId = createRandomContentKeyId(); - byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKeyId, aesKey); + byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKey, aesKey); ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, contentKeyType, Base64.encode(encryptedContentKey))); return contentKeyInfo; From 05103a423e897a074a20aff5b98047fd53636421 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 12 Dec 2012 18:25:07 -0800 Subject: [PATCH 547/664] Deleted ListTasksResult --- .../media/models/ListTasksResult.java | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java deleted file mode 100644 index 55f4360a27910..0000000000000 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListTasksResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2011 Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.microsoft.windowsazure.services.media.models; - -import java.util.List; - -/** - * The Class ListTasksResult. - */ -public class ListTasksResult { - - /** The task infos. */ - private List<TaskInfo> taskInfos; - - /** - * Gets the task infos. - * - * @return the task infos - */ - public List<TaskInfo> getTaskInfos() { - return taskInfos; - } - - /** - * Sets the task infos. - * - * @param taskInfos - * the task infos - * @return the list tasks result - */ - public ListTasksResult setTaskInfos(List<TaskInfo> taskInfos) { - this.taskInfos = taskInfos; - return this; - } - -} From 8ffec2ff44c55c2f06f56ce45030b9aac9aa6e59 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 12 Dec 2012 18:45:26 -0800 Subject: [PATCH 548/664] Fixed token manager cache poisoning bug --- .../implementation/OAuthTokenManager.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 7e5df57b529ca..58afef9d1ad1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -89,22 +89,16 @@ public OAuthTokenManager(OAuthContract contract, DateFactory dateFactory, */ public String getAccessToken() throws ServiceException, URISyntaxException { Date now = dateFactory.getDate(); - OAuthTokenResponse oAuth2TokenResponse = null; + if (this.activeToken == null || now.after(this.activeToken.getExpiresUtc())) { + OAuthTokenResponse oAuth2TokenResponse = contract.getAccessToken(acsBaseUri, clientId, clientSecret, scope); + Date expiresUtc = new Date(now.getTime() + oAuth2TokenResponse.getExpiresIn() * Timer.ONE_SECOND / 2); - if (this.activeToken == null) { - this.activeToken = new ActiveToken(); - } - else if (now.before(this.activeToken.getExpiresUtc())) { - return this.activeToken.getAccessToken(); - } - - oAuth2TokenResponse = contract.getAccessToken(acsBaseUri, clientId, clientSecret, scope); - Date expiresUtc = new Date(now.getTime() + oAuth2TokenResponse.getExpiresIn() * Timer.ONE_SECOND / 2); + ActiveToken newToken = new ActiveToken(); + newToken.setAccessToken(oAuth2TokenResponse.getAccessToken()); + newToken.setExpiresUtc(expiresUtc); - this.activeToken.setAccessToken(oAuth2TokenResponse.getAccessToken()); - this.activeToken.setExpiresUtc(expiresUtc); - - return oAuth2TokenResponse.getAccessToken(); + this.activeToken = newToken; + } + return this.activeToken.getAccessToken(); } - } From 91fdd2225892480fa09acf21744d111f5b948535 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 09:46:04 -0800 Subject: [PATCH 549/664] Can now list input and output assets for jobs --- .../media/implementation/ODataEntity.java | 11 ++++ .../media/implementation/content/JobType.java | 47 ---------------- .../services/media/models/Asset.java | 12 +++++ .../services/media/models/Job.java | 2 +- .../services/media/models/JobInfo.java | 25 +++++---- .../services/media/JobIntegrationTest.java | 49 ++++++++++------- .../media/models/AssetEntityTest.java | 54 +++++++++++++++++++ .../scenarios/MediaServiceWrapper.java | 10 +--- 8 files changed, 122 insertions(+), 88 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index fa1a382f72117..fac9d627b7826 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -99,6 +99,17 @@ public LinkInfo getLink(String rel) { return null; } + /** + * Get the link to navigate an OData relationship + * + * @param relationName + * name of the OData relationship + * @return the link if found, null if not. + */ + public LinkInfo getRelationLink(String relationName) { + return getLink(Constants.ODATA_DATA_NS + "/related/" + relationName); + } + /** * Return the links from this entry * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index eb274041985fa..6ae248b7e5db5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -16,7 +16,6 @@ package com.microsoft.windowsazure.services.media.implementation.content; import java.util.Date; -import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -70,12 +69,6 @@ public class JobType implements MediaServiceDTO { @XmlElement(name = "TemplateId", namespace = Constants.ODATA_DATA_NS) protected String templateId; - /** The output media assets. */ - protected List<String> outputMediaAssets; - - /** The input media assets. */ - protected List<String> inputMediaAssets; - /** The tasks. */ @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) protected String taskBody; @@ -280,46 +273,6 @@ public JobType setTemplateId(String templateId) { return this; } - /** - * Gets the output media assets. - * - * @return the output media assets - */ - public List<String> getOutputMediaAssets() { - return outputMediaAssets; - } - - /** - * Sets the output media assets. - * - * @param uriList - * the new output media assets - */ - public JobType setOutputMediaAssets(List<String> outputMediaAssets) { - this.outputMediaAssets = outputMediaAssets; - return this; - } - - /** - * Gets the input media assets. - * - * @return the input media assets - */ - public List<String> getInputMediaAssets() { - return inputMediaAssets; - } - - /** - * Sets the input media assets. - * - * @param uriList - * the new input media assets - */ - public JobType setInputMediaAssets(List<String> inputMediaAssets) { - this.inputMediaAssets = inputMediaAssets; - return this; - } - /** * Gets the tasks. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index e736b536d9e0e..a82eb3edd1d18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -183,6 +183,18 @@ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> }, queryParameters); } + /** + * Create an operation that will list all the assets at the given link. + * + * @param link + * Link to request assets from. + * @return The list operation. + */ + public static EntityListOperation<AssetInfo> list(LinkInfo link) { + return new DefaultListOperation<AssetInfo>(link.getHref(), new GenericType<ListResult<AssetInfo>>() { + }); + } + /** * Create an operation that will update the given asset. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 9bc5d0519cd80..fb6d50b632ba7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -62,7 +62,7 @@ private Job() { } /** - * Creates the. + * Creates an operation to create a new job. * * @param serviceUri * the service uri diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 23f9c36de43e0..f4c6c97f27110 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -16,7 +16,6 @@ package com.microsoft.windowsazure.services.media.models; import java.util.Date; -import java.util.List; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; @@ -130,29 +129,29 @@ public String getTemplateId() { } /** - * Gets the input media assets. + * Gets the task body. * - * @return the input media assets + * @return the task body */ - public List<String> getInputMediaAssets() { - return getContent().getInputMediaAssets(); + public String getTaskBody() { + return getContent().getTaskBody(); } /** - * Gets the output media assets. + * Get a link which, when listed, will return the input assets for the job * - * @return the output media assets + * @return Link if found, null if not. */ - public List<String> getOutputMediaAssets() { - return getContent().getOutputMediaAssets(); + public LinkInfo getInputAssetsLink() { + return getRelationLink("InputMediaAssets"); } /** - * Gets the task body. + * Get a link which, when listed, will return the output assets for the job * - * @return the task body + * @return Link if found, null if not. */ - public String getTaskBody() { - return getContent().getTaskBody(); + public LinkInfo getOutputAssetsLink() { + return getRelationLink("OutputMediaAssets"); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index bfa003d0cc98d..96f4fe07a3d8a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -55,13 +55,12 @@ public class JobIntegrationTest extends IntegrationTestBase { private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), expected.getState(), expected.getTemplateId(), expected.getCreated(), expected.getLastModified(), - expected.getStartTime(), expected.getEndTime(), expected.getInputMediaAssets(), - expected.getOutputMediaAssets(), actual); + expected.getStartTime(), expected.getEndTime(), actual); } private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime, - List<String> inputMediaAssets, List<String> outputMediaAssets, JobInfo actualJob) { + JobInfo actualJob) { assertNotNull(message, actualJob); assertNotNull(message + "Id", actualJob.getId()); @@ -78,11 +77,6 @@ private void verifyJobProperties(String message, String testName, Integer priori assertDateApproxEquals(message + " StartTime", startTime, actualJob.getStartTime()); assertDateApproxEquals(message + " EndTime", endTime, actualJob.getEndTime()); - // TODO: Add test for accessing the input and output media assets when fixed: - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 - assertEquals(message + " InputMediaAssets", inputMediaAssets, actualJob.getInputMediaAssets()); - assertEquals(message + " OutputMediaAssets", outputMediaAssets, actualJob.getOutputMediaAssets()); - // TODO: Add test for accessing the tasks when fixed: // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/531 } @@ -139,8 +133,6 @@ public void createJobSuccess() throws Exception { double duration = 0.0; JobState state = JobState.Queued; String templateId = null; - List<String> inputMediaAssets = null; - List<String> outputMediaAssets = null; Date created = new Date(); Date lastModified = new Date(); Date stateTime = null; @@ -152,7 +144,7 @@ public void createJobSuccess() throws Exception { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, inputMediaAssets, outputMediaAssets, actualJob); + endTime, actualJob); } @Test @@ -163,8 +155,6 @@ public void createJobTwoTasksSuccess() throws Exception { double duration = 0.0; JobState state = JobState.Queued; String templateId = null; - List<String> inputMediaAssets = null; - List<String> outputMediaAssets = null; Date created = new Date(); Date lastModified = new Date(); Date stateTime = null; @@ -179,7 +169,7 @@ public void createJobTwoTasksSuccess() throws Exception { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, inputMediaAssets, outputMediaAssets, actualJob); + endTime, actualJob); } @Test @@ -190,8 +180,6 @@ public void getJobSuccess() throws Exception { double duration = 0.0; JobState state = JobState.Queued; String templateId = null; - List<String> inputMediaAssets = null; - List<String> outputMediaAssets = null; String jobId = createJob(name).getId(); Date created = new Date(); Date lastModified = new Date(); @@ -203,7 +191,7 @@ public void getJobSuccess() throws Exception { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, inputMediaAssets, outputMediaAssets, actualJob); + endTime, actualJob); } @Test @@ -296,7 +284,7 @@ public void deleteJobSuccess() throws ServiceException { } @Test - public void deleteJobIvalidIdFail() throws ServiceException { + public void deleteJobInvalidIdFail() throws ServiceException { // Arrange expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(400)); @@ -306,4 +294,29 @@ public void deleteJobIvalidIdFail() throws ServiceException { // Assert } + + @Test + public void canGetInputOutputAssetsFromJob() throws Exception { + String name = testJobPrefix + "canGetInputOutputAssetsFromJob"; + int priority = 3; + double duration = 0.0; + JobState state = JobState.Queued; + String templateId = null; + Date created = new Date(); + Date lastModified = new Date(); + Date stateTime = null; + Date endTime = null; + + JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); + + ListResult<AssetInfo> inputs = service.list(Asset.list(actualJob.getInputAssetsLink())); + ListResult<AssetInfo> outputs = service.list(Asset.list(actualJob.getOutputAssetsLink())); + + assertEquals(1, inputs.size()); + assertEquals(assetInfo.getId(), inputs.get(0).getId()); + + assertEquals(1, outputs.size()); + assertTrue(outputs.get(0).getName().contains(name)); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 5ec15ac69f1ac..9c5fcc892eebb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -20,10 +20,17 @@ import java.net.URLEncoder; import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; @@ -130,4 +137,51 @@ public void assetDeleteReturnsExpectedUri() throws Exception { assertEquals(expectedUri, deleter.getUri()); } + private static final String expectedOutputAsset = "Job(someJobId)/OutputAssets"; + private static final String expectedInputAsset = "Job(someJobId)/InputAssets"; + + @Test + public void listForLinkReturnsExpectedUri() throws Exception { + JobInfo fakeJob = createJob(); + + EntityListOperation<AssetInfo> lister = Asset.list(fakeJob.getInputAssetsLink()); + + assertEquals(lister.getUri(), expectedInputAsset); + } + + private JobInfo createJob() { + EntryType fakeJobEntry = new EntryType(); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/OutputMediaAssets", expectedOutputAsset, + "application/atom+xml;type=feed", "OutputAssets"); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/InputMediaAssets", expectedInputAsset, + "application/atom+xml;type=feed", "InputAssets"); + + JobType payload = new JobType().setId("SomeId").setName("FakeJob"); + addEntryContent(fakeJobEntry, payload); + + return new JobInfo(fakeJobEntry, payload); + } + + private void addEntryLink(EntryType entry, String rel, String href, String type, String title) { + LinkType link = new LinkType(); + link.setRel(rel); + link.setHref(href); + link.setType(type); + link.setTitle(title); + + JAXBElement<LinkType> linkElement = new JAXBElement<LinkType>(new QName("link", Constants.ATOM_NS), + LinkType.class, link); + entry.getEntryChildren().add(linkElement); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private ContentType addEntryContent(EntryType entry, Object content) { + ContentType contentWrapper = new ContentType(); + contentWrapper.getContent().add( + new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); + + entry.getEntryChildren().add( + new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentWrapper)); + return contentWrapper; + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index c0d85220473ed..0cc41917282f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -284,15 +284,7 @@ public boolean isJobFinished(JobInfo initialJobInfo) throws ServiceException { } public List<AssetInfo> getJobOutputMediaAssets(JobInfo job) throws ServiceException { - List<String> outputMediaAssets = job.getOutputMediaAssets(); - if (outputMediaAssets == null) { - return null; - } - List<AssetInfo> ret = new ArrayList<AssetInfo>(); - for (String assetId : outputMediaAssets) { - ret.add(service.get(Asset.get(assetId))); - } - return ret; + return service.list(Asset.list(job.getOutputAssetsLink())); } // Process From 65afafc714b5ba022fc9be3f686b623e6a32a3c7 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 11:21:09 -0800 Subject: [PATCH 550/664] get upload encrypted file working properly. --- .../services/media/EncryptionHelper.java | 16 +++++ .../media/EncryptionIntegrationTest.java | 69 ++++++++++++++----- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 8b553362d139b..787e627b2bc97 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -32,6 +32,7 @@ import java.security.cert.X509Certificate; import java.security.spec.InvalidKeySpecException; import java.util.Random; +import java.util.UUID; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -145,4 +146,19 @@ public static byte[] EncryptSymmetricKey(Key publicKey, byte[] inputData) throws return cipherText; } + public static String calculateChecksum(UUID uuid, byte[] aesKey) throws NoSuchAlgorithmException, + NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, + InvalidKeyException { + SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING", "BC"); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + byte[] encryptionResult = cipher.doFinal(uuid.toString().getBytes()); + byte[] checksumByteArray = new byte[8]; + for (int i = 0; i < 8; i++) { + checksumByteArray[i] = encryptionResult[i]; + } + String checksum = Base64.encode(checksumByteArray); + return checksum; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 5f0ec48f00c15..7b448a8d0f7e6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -26,6 +27,7 @@ import java.security.Security; import java.security.cert.CertificateException; import java.security.spec.InvalidKeySpecException; +import java.util.EnumSet; import java.util.UUID; import javax.crypto.BadPaddingException; @@ -40,13 +42,20 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; import com.microsoft.windowsazure.services.media.models.EncryptionOption; +import com.microsoft.windowsazure.services.media.models.Locator; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.ProtectionKey; public class EncryptionIntegrationTest extends IntegrationTestBase { @@ -55,8 +64,7 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; - private String createRandomContentKeyId() { - UUID uuid = UUID.randomUUID(); + private String createContentKeyId(UUID uuid) { String randomContentKey = String.format("nb:kid:UUID:%s", uuid); return randomContentKey; } @@ -84,23 +92,29 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); - - // Act byte[] aesKey = EncryptionHelper.createRandomVector(128); byte[] initializationVector = EncryptionHelper.createRandomVector(128); + int durationInMinutes = 10; + // Act AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") .setOptions(EncryptionOption.StorageEncrypted)); - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); - String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", + durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS)); + + String protectionKey = getProtectionKey(); + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKey); - URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); - service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); + + linkContentKey(assetInfo, contentKeyInfo); byte[] encryptedContent = EncryptFile(smallWMVInputStream, aesKey, initializationVector); - AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, protectionKeyId, encryptedContent, aesKey, - initializationVector); + AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, + "uploadAesProtectedAssetSuccess", encryptedContent); // executeDecodingJob(assetInfo); @@ -109,10 +123,28 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { } - private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, String protectionKeyId, - byte[] encryptedContent, byte[] aesKey, byte[] initializationVector) { - // TODO Auto-generated method stub - return null; + private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException { + URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); + } + + private String getProtectionKey() throws ServiceException { + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + return protectionKey; + } + + private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, LocatorInfo locatorInfo, + ContentKeyInfo contentKeyInfo, String blobName, byte[] encryptedContent) throws ServiceException { + WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locatorInfo); + InputStream blobContent = new ByteArrayInputStream(encryptedContent); + blobWriter.createBlockBlob(blobName, blobContent); + AssetFileInfo assetFileInfo = service.create(AssetFile.create(assetInfo.getId(), blobName).setIsPrimary(true) + .setIsEncrypted(true).setContentFileSize(new Long(encryptedContent.length)) + .setEncryptionScheme("StorageEncryption").setEncryptionVersion("1.0") + .setEncryptionKeyId(contentKeyInfo.getId())); + return assetFileInfo; } private URI createContentKeyUri(URI rootUri, String contentKeyId) { @@ -146,10 +178,13 @@ private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKey throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ServiceException, CertificateException { - String contentKeyId = createRandomContentKeyId(); + UUID contentKeyIdUuid = UUID.randomUUID(); + String contentKeyId = createContentKeyId(contentKeyIdUuid); byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKey, aesKey); + String encryptedContentKeyString = Base64.encode(encryptedContentKey); + String checksum = EncryptionHelper.calculateChecksum(contentKeyIdUuid, aesKey); ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, contentKeyType, - Base64.encode(encryptedContentKey))); + encryptedContentKeyString).setChecksum(checksum)); return contentKeyInfo; } From a2e7de4f2724cd6930c4f160be32140618913130 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 11:23:29 -0800 Subject: [PATCH 551/664] resolve merge conflict --- .../services/media/EncryptionIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 7b448a8d0f7e6..69d9680a672c2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -49,10 +49,10 @@ import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; -import com.microsoft.windowsazure.services.media.models.EncryptionOption; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -98,7 +98,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Act AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") - .setOptions(EncryptionOption.StorageEncrypted)); + .setOptions(AssetOption.StorageEncrypted)); AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); @@ -137,7 +137,7 @@ private String getProtectionKey() throws ServiceException { private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, LocatorInfo locatorInfo, ContentKeyInfo contentKeyInfo, String blobName, byte[] encryptedContent) throws ServiceException { - WritableBlobContainerContract blobWriter = MediaService.createBlobWriter(locatorInfo); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locatorInfo); InputStream blobContent = new ByteArrayInputStream(encryptedContent); blobWriter.createBlockBlob(blobName, blobContent); AssetFileInfo assetFileInfo = service.create(AssetFile.create(assetInfo.getId(), blobName).setIsPrimary(true) From e2c798079406ad856cd1a48490604e1268d85bec Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 14:09:50 -0800 Subject: [PATCH 552/664] add tasks list to job --- .../media/implementation/content/JobType.java | 24 ------------------- .../services/media/models/JobInfo.java | 23 +++++++++--------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 6ae248b7e5db5..8493154ddbd3f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -69,10 +69,6 @@ public class JobType implements MediaServiceDTO { @XmlElement(name = "TemplateId", namespace = Constants.ODATA_DATA_NS) protected String templateId; - /** The tasks. */ - @XmlElement(name = "TaskBody", namespace = Constants.ODATA_DATA_NS) - protected String taskBody; - /** * Gets the id. * @@ -273,24 +269,4 @@ public JobType setTemplateId(String templateId) { return this; } - /** - * Gets the tasks. - * - * @return the tasks - */ - public String getTaskBody() { - return taskBody; - } - - /** - * Sets the tasks. - * - * @param tasks - * the new tasks - */ - public JobType setTaskBody(String taskBody) { - this.taskBody = taskBody; - return this; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index f4c6c97f27110..16cb8149547a1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -21,6 +21,7 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; +// TODO: Auto-generated Javadoc /** * The Class JobInfo. */ @@ -129,16 +130,7 @@ public String getTemplateId() { } /** - * Gets the task body. - * - * @return the task body - */ - public String getTaskBody() { - return getContent().getTaskBody(); - } - - /** - * Get a link which, when listed, will return the input assets for the job + * Get a link which, when listed, will return the input assets for the job. * * @return Link if found, null if not. */ @@ -147,11 +139,20 @@ public LinkInfo getInputAssetsLink() { } /** - * Get a link which, when listed, will return the output assets for the job + * Get a link which, when listed, will return the output assets for the job. * * @return Link if found, null if not. */ public LinkInfo getOutputAssetsLink() { return getRelationLink("OutputMediaAssets"); } + + /** + * Gets the tasks link. + * + * @return the tasks link + */ + public LinkInfo getTasksLink() { + return getRelationLink("Tasks"); + } } From 2827c0e8714757472ae7f7f62a69674aa40b2ad8 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 14:42:15 -0800 Subject: [PATCH 553/664] Removed getRestServiceUri from contract, public API. --- .../services/media/MediaContract.java | 5 --- .../MediaExceptionProcessor.java | 10 ----- .../media/implementation/MediaRestProxy.java | 12 +++-- .../entities/DefaultActionOperation.java | 18 ++++++++ .../entities/DefaultDeleteOperation.java | 19 +++++++- .../entities/EntityDeleteOperation.java | 8 ++++ .../entities/EntityLinkOperation.java | 2 +- .../entities/EntityListOperation.java | 2 + .../entities/EntityOperation.java | 10 ++++- .../entities/EntityOperationBase.java | 18 ++++++++ .../entities/EntityOperationSingleResult.java | 1 - .../entities/EntityProxyData.java | 33 ++++++++++++++ .../entities/EntityRestProxy.java | 36 ++++++++++----- .../entities/EntityUpdateOperation.java | 1 - .../services/media/models/Asset.java | 10 ++++- .../services/media/models/AssetFile.java | 9 ++++ .../services/media/models/Job.java | 44 ++++--------------- .../services/media/models/Locator.java | 9 ++++ .../services/media/AssetIntegrationTest.java | 16 +++---- .../services/media/JobIntegrationTest.java | 8 ++-- .../scenarios/MediaServiceWrapper.java | 3 +- 21 files changed, 188 insertions(+), 86 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index f6a80ea5ffc80..e2ff92104a159 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media; -import java.net.URI; - import com.microsoft.windowsazure.services.core.FilterableService; import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -26,9 +24,6 @@ * */ public interface MediaContract extends FilterableService<MediaContract>, EntityContract { - - URI getRestServiceUri(); - /** * Creates an instance of the <code>WritableBlobContainerContract</code> API that will * write to the blob container given by the provided locator. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 5301f415a80a0..2476b8d196b18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation; -import java.net.URI; - import javax.inject.Inject; import org.apache.commons.logging.Log; @@ -190,14 +188,6 @@ public Object action(EntityActionOperation action) throws ServiceException { } } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getRestServiceUri() - */ - @Override - public URI getRestServiceUri() { - return service.getRestServiceUri(); - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.MediaContract#createBlobWriter(com.microsoft.windowsazure.services.media.models.LocatorInfo) */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 68240cdcc2578..1df8d5c468a16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.ClientConfigSettings; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -100,11 +101,16 @@ public MediaContract withFilter(ServiceFilter filter) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.MediaContract#getRestServiceUri() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy#createProxyData() */ @Override - public URI getRestServiceUri() { - return this.redirectFilter.getBaseURI(); + protected EntityProxyData createProxyData() { + return new EntityProxyData() { + @Override + public URI getServiceUri() { + return redirectFilter.getBaseURI(); + } + }; } /* (non-Javadoc) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index 58733f37cd53c..80cea7a458940 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -26,6 +26,7 @@ * Generic implementation of Delete operation usable by most entities. */ public class DefaultActionOperation implements EntityActionOperation { + private EntityProxyData proxyData; /** The name. */ protected String name; @@ -57,6 +58,23 @@ public DefaultActionOperation() { this.queryParameters = new MultivaluedMapImpl(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } + + /** + * Get the current proxy data + * + * @return the proxy data + */ + protected EntityProxyData getProxyData() { + return proxyData; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation#getUri() */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java index cb1675e490627..8f7f60520b8f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java @@ -15,13 +15,13 @@ package com.microsoft.windowsazure.services.media.implementation.entities; - /** * Generic implementation of Delete operation usable by most entities * */ public class DefaultDeleteOperation implements EntityDeleteOperation { private final EntityOperationBase.EntityUriBuilder uriBuilder; + private EntityProxyData proxyData; /** * @@ -30,6 +30,23 @@ public DefaultDeleteOperation(String entityUri, String entityId) { uriBuilder = new EntityOperationBase.EntityIdUriBuilder(entityUri, entityId); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } + + /** + * Get currently set proxy data + * + * @return the proxyData + */ + protected EntityProxyData getProxyData() { + return proxyData; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityDeleteOperation#getUri() */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java index 56c1e0de70352..ae0c8ff6b6715 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java @@ -1,6 +1,14 @@ package com.microsoft.windowsazure.services.media.implementation.entities; public interface EntityDeleteOperation { + + /** + * Supplies the current proxy information to the action. + * + * @param proxyData + */ + void setProxyData(EntityProxyData proxyData); + /** * Get the URI to use to delete an entity * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index 95ebbb27c40ea..92e8cd2ce8662 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -144,7 +144,7 @@ public Object processResponse(ClientResponse clientResponse) { @Override public Object getRequestContents() { MediaUriType mediaUriType = new MediaUriType(); - mediaUriType.setUri(this.secondaryEntityUri.toString()); + mediaUriType.setUri(getProxyData().getServiceUri().toString() + this.secondaryEntityUri.toString()); JAXBElement<MediaUriType> mediaUriTypeElement = new JAXBElement<MediaUriType>(new QName( Constants.ODATA_DATA_NS, "uri"), MediaUriType.class, mediaUriType); Document document = documentBuilder.newDocument(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java index 07f71c5b5d712..7a5d576c2a30e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java @@ -35,6 +35,8 @@ public interface EntityListOperation<T> extends EntityOperation { /** * Get a GenericType object representing the result list type + * + * @return the type of the operation's result */ GenericType<ListResult<T>> getResponseGenericType(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 6a6993f8dd02a..83e0f68019c14 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -21,6 +21,13 @@ public interface EntityOperation { + /** + * Supplies the current proxy information to the action. + * + * @param proxyData + */ + void setProxyData(EntityProxyData proxyData); + /** * Get the URI the creation request should be sent to. * @@ -40,5 +47,4 @@ public interface EntityOperation { * Get the MIME type that we're expecting the server to send back. */ public abstract MediaType getAcceptType(); - -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index bca283be61829..3f5a99567f3b8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -28,6 +28,7 @@ */ public abstract class EntityOperationBase implements EntityOperation { private final EntityUriBuilder uriBuilder; + private EntityProxyData proxyData; /** * @@ -45,6 +46,23 @@ protected EntityOperationBase(EntityUriBuilder uriBuilder) { this.uriBuilder = uriBuilder; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } + + /** + * Get the currently set proxy data + * + * @return the proxy data + */ + protected EntityProxyData getProxyData() { + return proxyData; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityOperation#getUri() */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java index 36f8e9a0c8a90..370741e5b3b96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation.entities; - public interface EntityOperationSingleResult<T> extends EntityOperation { /** * Get the Java class object for the type that the response should diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java new file mode 100644 index 0000000000000..751b92b094005 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.entities; + +import java.net.URI; + +/** + * Interface used to communicate details about the proxy to + * the operations, if they need it. + * + */ +public interface EntityProxyData { + /** + * Gets the absolute URI currently being + * used by proxy. + * + * @return The URI + */ + URI getServiceUri(); +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index cfa4f2e5183f9..f2b8fdf039f82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -30,7 +30,7 @@ /** * The Class EntityRestProxy. */ -public class EntityRestProxy implements EntityContract { +public abstract class EntityRestProxy implements EntityContract { /** The channel. */ private final Client channel; @@ -68,6 +68,13 @@ protected ServiceFilter[] getFilters() { return filters; } + /** + * Get the proxy data to pass to operations. + * + * @return The proxy data. + */ + protected abstract EntityProxyData createProxyData(); + /** * Gets the resource. * @@ -92,7 +99,8 @@ private WebResource getResource(String entityName) { * @throws ServiceException */ private Builder getResource(EntityOperation operation) throws ServiceException { - return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); + return getResource(operation.getUri()).type(operation.getContentType()).accept( + operation.getAcceptType()); } /* (non-Javadoc) @@ -101,7 +109,9 @@ private Builder getResource(EntityOperation operation) throws ServiceException { @SuppressWarnings("unchecked") @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { - Object rawResponse = getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); + creator.setProxyData(createProxyData()); + Object rawResponse = getResource(creator).post(creator.getResponseClass(), + creator.getRequestContents()); Object processedResponse = creator.processResponse(rawResponse); return (T) processedResponse; } @@ -111,6 +121,7 @@ public <T> T create(EntityCreationOperation<T> creator) throws ServiceException */ @Override public <T> T get(EntityGetOperation<T> getter) throws ServiceException { + getter.setProxyData(createProxyData()); return getResource(getter).get(getter.getResponseClass()); } @@ -119,8 +130,10 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { */ @Override public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { - return getResource(lister.getUri()).queryParams(lister.getQueryParameters()).type(lister.getContentType()) - .accept(lister.getAcceptType()).get(lister.getResponseGenericType()); + lister.setProxyData(createProxyData()); + return getResource(lister.getUri()).queryParams(lister.getQueryParameters()) + .type(lister.getContentType()).accept(lister.getAcceptType()) + .get(lister.getResponseGenericType()); } /* (non-Javadoc) @@ -128,8 +141,9 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep */ @Override public void update(EntityUpdateOperation updater) throws ServiceException { - ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, - updater.getRequestContents()); + updater.setProxyData(createProxyData()); + ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post( + ClientResponse.class, updater.getRequestContents()); PipelineHelpers.ThrowIfNotSuccess(response); } @@ -139,6 +153,7 @@ public void update(EntityUpdateOperation updater) throws ServiceException { */ @Override public void delete(EntityDeleteOperation deleter) throws ServiceException { + deleter.setProxyData(createProxyData()); getResource(deleter.getUri()).delete(); } @@ -147,12 +162,13 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { */ @Override public Object action(EntityActionOperation entityActionOperation) throws ServiceException { + entityActionOperation.setProxyData(createProxyData()); + Builder webResource = getResource(entityActionOperation.getUri()) - .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType()) - .accept(MediaType.APPLICATION_XML_TYPE) + .queryParams(entityActionOperation.getQueryParameters()) + .accept(entityActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE) .entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class); return entityActionOperation.processResponse(clientResponse); } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java index 598964145229f..90314d099ccde 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation.entities; - /** * * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index a82eb3edd1d18..840499cde7732 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -30,6 +30,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; @@ -227,6 +228,14 @@ protected Updater(String assetId) { super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, assetId)); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + // Deliberately empty + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents() */ @@ -286,5 +295,4 @@ public static EntityDeleteOperation delete(String assetId) { public static EntityLinkOperation linkContentKey(String assetId, URI contentKeyUri) { return new EntityLinkOperation("Assets", assetId, "ContentKeys", contentKeyUri); } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index 0d6e6c884f598..b56f63db4875b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -31,6 +31,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; @@ -240,6 +241,14 @@ public Object getRequestContents() { .setIsEncrypted(isEncrypted).setIsPrimary(isPrimary).setMimeType(mimeType); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + // Deliberately empty + } + /** * @param contentChecksum * the contentChecksum to set diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index fb6d50b632ba7..aeb08a0a2bec8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -68,8 +68,8 @@ private Job() { * the service uri * @return the creator */ - public static Creator create(URI serviceUri) { - return new Creator(serviceUri); + public static Creator create() { + return new Creator(); } /** @@ -90,9 +90,6 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp /** The input media assets. */ private final List<String> inputMediaAssets; - /** The service uri. */ - private URI serviceUri; - /** The content type. */ private MediaType contentType; @@ -114,9 +111,9 @@ public static class Creator extends EntityOperationSingleResultBase<JobInfo> imp * @throws ServiceException * the service exception */ - private void buildMimeMultipart() { + private void buildMimeMultipart(URI serviceUri) { mediaBatchOperations = null; - CreateBatchOperation createJobBatchOperation = CreateBatchOperation.create(this); + CreateBatchOperation createJobBatchOperation = CreateBatchOperation.create(serviceUri, this); try { mediaBatchOperations = new MediaBatchOperations(serviceUri); @@ -156,9 +153,8 @@ private void buildMimeMultipart() { * @param serviceUri * the service uri */ - public Creator(URI serviceUri) { + public Creator() { super(ENTITY_SET, JobInfo.class); - this.serviceUri = serviceUri; this.inputMediaAssets = new ArrayList<String>(); this.taskCreateBatchOperations = new ArrayList<Task.CreateBatchOperation>(); this.fresh = true; @@ -170,7 +166,7 @@ public Creator(URI serviceUri) { @Override public Object getRequestContents() throws ServiceException { if (fresh) { - buildMimeMultipart(); + buildMimeMultipart(getProxyData().getServiceUri()); } return mimeMultipart; } @@ -316,35 +312,13 @@ public Creator addInputMediaAsset(String assetId) { return this; } - /** - * Gets the service uri. - * - * @return the service uri - */ - public URI getServiceUri() { - return this.serviceUri; - } - - /** - * Sets the service uri. - * - * @param serviceUri - * the service uri - * @return the creator - */ - public Creator setServiceUri(URI serviceUri) { - this.serviceUri = serviceUri; - this.fresh = true; - return this; - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getContentType() */ @Override public MediaType getContentType() { if (fresh) { - buildMimeMultipart(); + buildMimeMultipart(getProxyData().getServiceUri()); } return this.contentType; } @@ -387,8 +361,8 @@ public CreateBatchOperation(URI serviceUri) { * the creator * @return the creates the batch operation */ - public static CreateBatchOperation create(Creator creator) { - CreateBatchOperation createBatchOperation = new CreateBatchOperation(creator.getServiceUri()); + public static CreateBatchOperation create(URI serviceUri, Creator creator) { + CreateBatchOperation createBatchOperation = new CreateBatchOperation(serviceUri); JobType jobType = new JobType(); jobType.setStartTime(creator.getStartTime()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 51a391c89e805..effbfc6a194a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -28,6 +28,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; @@ -267,6 +268,14 @@ public Object getRequestContents() { return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ + @Override + public void setProxyData(EntityProxyData proxyData) { + // Deliberately empty + } + /** * Set when the locator will become available. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index acfbfa7868271..b4d9678c5349a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -34,11 +34,11 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; -import com.microsoft.windowsazure.services.media.models.AssetOption; import com.sun.jersey.core.util.MultivaluedMapImpl; public class AssetIntegrationTest extends IntegrationTestBase { @@ -48,14 +48,13 @@ private void verifyInfosEqual(String message, AssetInfo expected, AssetInfo actu expected.getState(), actual); } - private void verifyAssetProperties(String message, String testName, String altId, - AssetOption encryptionOption, AssetState assetState, AssetInfo actualAsset) { + private void verifyAssetProperties(String message, String testName, String altId, AssetOption encryptionOption, + AssetState assetState, AssetInfo actualAsset) { verifyAssetProperties(message, testName, altId, encryptionOption, assetState, null, null, null, actualAsset); } - private void verifyAssetProperties(String message, String testName, String altId, - AssetOption encryptionOption, AssetState assetState, String id, Date created, Date lastModified, - AssetInfo actualAsset) { + private void verifyAssetProperties(String message, String testName, String altId, AssetOption encryptionOption, + AssetState assetState, String id, Date created, Date lastModified, AssetInfo actualAsset) { assertNotNull(message, actualAsset); assertEquals(message + " Name", testName, actualAsset.getName()); assertEquals(message + " AlternateId", altId, actualAsset.getAlternateId()); @@ -290,7 +289,6 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep String encryptedContentKey = "dummyEncryptedContentKey"; ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)); - URI serviceUri = service.getRestServiceUri(); String escapedContentKeyId; try { escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); @@ -298,7 +296,7 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep catch (UnsupportedEncodingException e) { throw new InvalidParameterException(contentKeyId); } - URI contentKeyUri = new URI(String.format("%sContentKeys('%s')", serviceUri, escapedContentKeyId)); + URI contentKeyUri = new URI(String.format("ContentKeys('%s')", escapedContentKeyId)); // Act service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); @@ -315,7 +313,7 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyntaxException { // Arrange String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; - URI invalidContentKeyUri = new URI("https://server/api/ContentKeys('nb:kid:UUID:invalidContentKeyId')"); + URI invalidContentKeyUri = new URI("ContentKeys('nb%3akid%3aUUID%3ainvalidContentKeyId')"); // Act expectedException.expect(ServiceException.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 96f4fe07a3d8a..a6a1c3919260c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.net.URI; import java.util.ArrayList; import java.util.Date; import java.util.EnumSet; @@ -91,8 +90,7 @@ private void assertEqualsNullEmpty(String message, String expected, String actua } private JobInfo createJob(String name) throws ServiceException { - URI serviceUri = service.getRestServiceUri(); - return service.create(Job.create(serviceUri).setName(name).setPriority(3).addInputMediaAsset(assetInfo.getId()) + return service.create(Job.create().setName(name).setPriority(3).addInputMediaAsset(assetInfo.getId()) .addTaskCreator(getTaskCreator(0))); } @@ -139,7 +137,7 @@ public void createJobSuccess() throws Exception { Date endTime = null; // Act - JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); // Assert @@ -164,7 +162,7 @@ public void createJobTwoTasksSuccess() throws Exception { tasks.add(getTaskCreator(1)); // Act - JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) .addInputMediaAsset(assetInfo.getId()).addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 0cc41917282f0..3eb9c37522950 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -203,8 +203,7 @@ public int getCount() { // Process public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateBatchOperation> tasks) throws ServiceException { - Creator jobCreator = Job.create(service.getRestServiceUri()).setName(jobName) - .addInputMediaAsset(inputAsset.getId()).setPriority(2); + Creator jobCreator = Job.create().setName(jobName).addInputMediaAsset(inputAsset.getId()).setPriority(2); for (Task.CreateBatchOperation task : tasks) { jobCreator.addTaskCreator(task); From 60eb02f78ac23d9af721292fcbff84d156b1810a Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 14:55:18 -0800 Subject: [PATCH 554/664] Fixed access policy integration test failures --- .../services/media/AccessPolicyIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index f7de5b1026065..1975e6f220857 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -103,7 +103,7 @@ public void canGetSinglePolicyById() throws Exception { @Test public void canGetSinglePolicyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.get(AccessPolicy.get(invalidId)); } @@ -189,7 +189,7 @@ public void canDeleteAccessPolicyById() throws Exception { @Test public void canDeleteAccessPolicyByInvalidId() throws Exception { expectedException.expect(ServiceException.class); - expectedException.expect(new ServiceExceptionMatcher(500)); + expectedException.expect(new ServiceExceptionMatcher(400)); service.delete(AccessPolicy.delete(invalidId)); } From c864a9c7eb763c5e8a02a5deff73a8c8678c7625 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 15:22:41 -0800 Subject: [PATCH 555/664] Fixed two test breaks, removed expiration as a settable property for locator --- .../services/media/models/Locator.java | 18 +----------- .../media/AssetFileIntegrationTest.java | 12 ++++---- .../services/media/IntegrationTestBase.java | 9 +++--- .../services/media/JobIntegrationTest.java | 2 +- .../media/LocatorIntegrationTests.java | 29 ++++--------------- .../media/UploadingIntegrationTest.java | 2 +- .../media/models/LocatorEntityTest.java | 9 ++---- 7 files changed, 21 insertions(+), 60 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 51a391c89e805..8224579d75e60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -78,9 +78,6 @@ public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> /** The content access token. */ private String contentAccessComponent; - /** The expiration date time. */ - private Date expirationDateTime; - /** The locator type. */ private final LocatorType locatorType; @@ -116,8 +113,7 @@ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType @Override public Object getRequestContents() { return new LocatorRestType().setId(id).setAccessPolicyId(accessPolicyId).setAssetId(assetId) - .setStartTime(startDateTime).setExpirationDateTime(expirationDateTime) - .setType(locatorType.getCode()).setBaseUri(baseUri) + .setStartTime(startDateTime).setType(locatorType.getCode()).setBaseUri(baseUri) .setContentAccessComponent(contentAccessComponent).setPath(path); } @@ -157,18 +153,6 @@ public Creator setStartDateTime(Date startDateTime) { return this; } - /** - * Set the date and time at which the locator will expire. - * - * @param expirationDateTime - * Expiration date and time - * @return The creator instance (for function chaining) - */ - public Creator setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - /** * Sets the content access component. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 458b8a5da8588..173ebf8d53b71 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -61,7 +61,7 @@ public static void setup() throws Exception { @Test public void canCreateFileForUploadedBlob() throws Exception { AssetInfo asset = createTestAsset("createFileForUploadedBlob"); - LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); + LocatorInfo locator = createLocator(writePolicy, asset, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, BLOB_NAME, firstPrimes); @@ -78,7 +78,7 @@ public void canCreateFileForUploadedBlob() throws Exception { @Test public void canCreateFileEntityDirectly() throws Exception { AssetInfo asset = createTestAsset("createFileEntityDirectly"); - LocatorInfo locator = createLocator(writePolicy, asset, 5, 10); + LocatorInfo locator = createLocator(writePolicy, asset, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, BLOB_NAME_2, firstPrimes); @@ -102,7 +102,7 @@ public void canCreateFileEntityDirectly() throws Exception { public void canCreateAssetWithMultipleFiles() throws Exception { AssetInfo asset = createTestAsset("createWithMultipleFiles"); AccessPolicyInfo policy = createWritePolicy("createWithMultipleFiles", 10); - LocatorInfo locator = createLocator(policy, asset, 5, 10); + LocatorInfo locator = createLocator(policy, asset, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); @@ -140,7 +140,7 @@ public int compare(AssetFileInfo o1, AssetFileInfo o2) { public void canCreateFileAndThenUpdateIt() throws Exception { AssetInfo asset = createTestAsset("createAndUpdate"); AccessPolicyInfo policy = createWritePolicy("createAndUpdate", 10); - LocatorInfo locator = createLocator(policy, asset, 5, 10); + LocatorInfo locator = createLocator(policy, asset, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "toUpdate.bin", firstPrimes); @@ -158,7 +158,7 @@ public void canCreateFileAndThenUpdateIt() throws Exception { public void canDeleteFileFromAsset() throws Exception { AssetInfo asset = createTestAsset("deleteFile"); AccessPolicyInfo policy = createWritePolicy("deleteFile", 10); - LocatorInfo locator = createLocator(policy, asset, 5, 10); + LocatorInfo locator = createLocator(policy, asset, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); createAndUploadBlob(blobWriter, "todelete.bin", firstPrimes); @@ -232,7 +232,5 @@ private void verifyAssetInfoProperties(String message, String id, String name, S assertDateApproxEquals(message + ".getLastModified", lastModified, assetFile.getLastModified()); assertEquals(message + ".getContentChecksum", contentChecksum, assetFile.getContentChecksum()); assertEquals(message + ".getMimeType", mimeType, assetFile.getMimeType()); - } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index df6918a26e466..bef05b619af63 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -159,15 +159,14 @@ interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } - protected static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes, - int expirationDeltaMinutes) throws ServiceException { + protected static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes) + throws ServiceException { Date now = new Date(); Date start = new Date(now.getTime() - (startDeltaMinutes * 60 * 1000)); - Date expire = new Date(now.getTime() + (expirationDeltaMinutes * 60 * 1000)); - return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS) - .setStartDateTime(start).setExpirationDateTime(expire)); + return service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS).setStartDateTime( + start)); } protected <T> void verifyListResultContains(List<T> expectedInfos, Collection<T> actualInfos, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 96f4fe07a3d8a..37cf892cf9a4a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -117,7 +117,7 @@ public static void setup() throws Exception { AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + name, 10, EnumSet.of(AccessPolicyPermission.WRITE))); - LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5, 10); + LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5); WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); InputStream blobContent = new ByteArrayInputStream(testBlobData); blobWriter.createBlockBlob(testBlobName, blobContent); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 5a1237b462ccb..feb4b2bd7decd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -133,28 +133,14 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { expectedExpirationDateTime, locatorInfo); } - @Test - public void createLocatorOptionsSetExpirationDateTimeSuccess() throws ServiceException { - // Arrange - Date expectedExpirationDateTime = new Date(); - expectedExpirationDateTime.setTime(expectedExpirationDateTime.getTime() + tenMinutesInMS); - LocatorType locatorType = LocatorType.SAS; - - // Act - LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), - locatorType).setExpirationDateTime(expectedExpirationDateTime)); - // Assert - verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, null, - expectedExpirationDateTime, locatorInfo); - } - @Test public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Arrange Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfo, assetInfo); + Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + + (long) accessPolicyInfo.getDurationInMinutes() * minuteInMS); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), @@ -171,11 +157,9 @@ public void getLocatorSuccess() throws ServiceException { LocatorType locatorType = LocatorType.SAS; Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); - Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() + tenMinutesInMS); - LocatorInfo expectedLocatorInfo = service.create(Locator - .create(accessPolicyInfo.getId(), assetInfo.getId(), locatorType) - .setStartDateTime(expectedStartDateTime).setExpirationDateTime(expectedExpirationDateTime)); + LocatorInfo expectedLocatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + locatorType).setStartDateTime(expectedStartDateTime)); // Act LocatorInfo actualLocatorInfo = service.get(Locator.get(expectedLocatorInfo.getId())); @@ -271,9 +255,8 @@ public void updateLocatorNoChangesSuccess() throws ServiceException { Date startTime = new Date(); startTime.setTime(startTime.getTime() - tenMinutesInMS); - LocatorInfo locatorInfo = service.create(Locator - .create(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType) - .setExpirationDateTime(expirationDateTime).setStartDateTime(startTime)); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), + locatorType).setStartDateTime(startTime)); // Act service.update(Locator.update(locatorInfo.getId())); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 652901696fc95..25ee429108f49 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -52,7 +52,7 @@ public static void setup() throws Exception { AccessPolicyInfo policy = service.create(AccessPolicy.create(testPolicyPrefix + "uploadWritePolicy", 10, EnumSet.of(AccessPolicyPermission.WRITE))); - LocatorInfo locator = createLocator(policy, asset, 5, 10); + LocatorInfo locator = createLocator(policy, asset, 5); blobWriter = service.createBlobWriter(locator); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 41734de3972a4..6008fcd16371f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -67,13 +67,11 @@ public void createLocatorHasCorrectPayload() throws Exception { } @Test - public void createLocatorCanSetTimes() throws Exception { + public void createLocatorCanSetStartTime() throws Exception { Date now = new Date(); - Date tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000); - EntityCreationOperation<LocatorInfo> creator = Locator - .create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setStartDateTime(now) - .setExpirationDateTime(tomorrow); + EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + LocatorType.SAS).setStartDateTime(now); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); @@ -81,7 +79,6 @@ public void createLocatorCanSetTimes() throws Exception { assertEquals(exampleAccessPolicyId, locatorType.getAccessPolicyId()); assertEquals(LocatorType.SAS.getCode(), locatorType.getType().intValue()); assertEquals(now, locatorType.getStartTime()); - assertEquals(tomorrow, locatorType.getExpirationDateTime()); } @Test From bab9d5541ab22c22ecd4831d87ae0ba529c946cf Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 15:55:32 -0800 Subject: [PATCH 556/664] add getters and setters to task --- .../services/media/models/Task.java | 147 +++++++++++++++++- 1 file changed, 144 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 634d63149a0b9..d3367ca54e008 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -44,10 +44,16 @@ private Task() { /** * Creates the. * + * @param mediaProcessorId + * the media processor id + * @param taskBody + * the task body + * @param options + * the options * @return the creates the batch operation */ - public static CreateBatchOperation create() { - return new CreateBatchOperation(); + public static CreateBatchOperation create(String mediaProcessorId, String taskBody, int options) { + return new CreateBatchOperation(mediaProcessorId, taskBody, options); } /** @@ -82,11 +88,42 @@ public static class CreateBatchOperation extends EntityBatchOperation { /** * Instantiates a new creates the batch operation. + * + * @param mediaProcessorId + * the media processor id + * @param taskBody + * the task body + * @param options + * the options */ - public CreateBatchOperation() { + public CreateBatchOperation(String mediaProcessorId, String taskBody, int options) { this.verb = "POST"; taskType = new TaskType(); addContentObject(taskType); + this.taskType.setMediaProcessorId(mediaProcessorId); + this.taskType.setTaskBody(taskBody); + this.taskType.setOptions(options); + } + + /** + * Gets the options. + * + * @return the options + */ + public int getOptions() { + return this.taskType.getOptions(); + } + + /** + * Sets the options. + * + * @param options + * the options + * @return the creates the batch operation + */ + public CreateBatchOperation setOptions(int options) { + this.taskType.setOptions(options); + return this; } /** @@ -173,6 +210,110 @@ public CreateBatchOperation setMediaProcessorId(String mediaProcessorId) { return this; } + /** + * Gets the priority. + * + * @return the priority + */ + public Integer getPriority() { + return this.taskType.getPriority(); + } + + /** + * Sets the priority. + * + * @param priority + * the priority + * @return the creates the batch operation + */ + public CreateBatchOperation setPriority(int priority) { + this.taskType.setPriority(priority); + return this; + } + + /** + * Gets the encryption key id. + * + * @return the encryption key id + */ + public String getEncryptionKeyId() { + return this.taskType.getEncryptionKeyId(); + } + + /** + * Sets the encryption key id. + * + * @param encryptionKeyId + * the encryption key id + * @return the creates the batch operation + */ + public CreateBatchOperation setEncryptionKeyId(String encryptionKeyId) { + this.taskType.setEncryptionKeyId(encryptionKeyId); + return this; + } + + /** + * Gets the encryption scheme. + * + * @return the encryption scheme + */ + public String getEncryptionScheme() { + return this.taskType.getEncryptionScheme(); + } + + /** + * Sets the encryption scheme. + * + * @param encryptionScheme + * the encryption scheme + * @return the creates the batch operation + */ + public CreateBatchOperation setEncryptionScheme(String encryptionScheme) { + this.taskType.setEncryptionScheme(encryptionScheme); + return this; + } + + /** + * Gets the encryption version. + * + * @return the encryption version + */ + public String getEncryptionVersion() { + return this.taskType.getEncryptionVersion(); + } + + /** + * Sets the encryption version. + * + * @param encryptionVersion + * the encryption version + * @return the creates the batch operation + */ + public CreateBatchOperation setEncryptionVersion(String encryptionVersion) { + this.taskType.setEncryptionVersion(encryptionVersion); + return this; + } + + /** + * Gets the initialization vector. + * + * @return the initialization vector + */ + public String getInitializationVector() { + return this.taskType.getInitializationVector(); + } + + /** + * Sets the initialization vector. + * + * @param initializationVector + * the initialization vector + * @return the creates the batch operation + */ + public CreateBatchOperation setInitializationVector(String initializationVector) { + this.taskType.setInitializationVector(initializationVector); + return this; + } } /** From 656e49124bec64ccf3c469169a6bd4579666ea46 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 16:06:31 -0800 Subject: [PATCH 557/664] fix task unit tests --- .../services/media/models/Task.java | 7 ++-- .../services/media/JobIntegrationTest.java | 9 ++--- .../MediaBatchOperationsTest.java | 9 +++-- .../scenarios/MediaServiceWrapper.java | 36 ++++++++++--------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index d3367ca54e008..4c37c6350b1c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -52,8 +52,8 @@ private Task() { * the options * @return the creates the batch operation */ - public static CreateBatchOperation create(String mediaProcessorId, String taskBody, int options) { - return new CreateBatchOperation(mediaProcessorId, taskBody, options); + public static CreateBatchOperation create(String mediaProcessorId, String taskBody) { + return new CreateBatchOperation(mediaProcessorId, taskBody); } /** @@ -96,13 +96,12 @@ public static class CreateBatchOperation extends EntityBatchOperation { * @param options * the options */ - public CreateBatchOperation(String mediaProcessorId, String taskBody, int options) { + public CreateBatchOperation(String mediaProcessorId, String taskBody) { this.verb = "POST"; taskType = new TaskType(); addContentObject(taskType); this.taskType.setMediaProcessorId(mediaProcessorId); this.taskType.setTaskBody(taskBody); - this.taskType.setOptions(options); } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 96f4fe07a3d8a..05a630e4d62fe 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -98,13 +98,10 @@ private JobInfo createJob(String name) throws ServiceException { private CreateBatchOperation getTaskCreator(int outputAssetPosition) { return Task - .create() - .setConfiguration("H.264 256k DSL CBR") - .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5") - .setName("My encoding Task") - .setTaskBody( + .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5", "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset(" - + outputAssetPosition + ")</outputAsset>" + "</taskBody>"); + + outputAssetPosition + ")</outputAsset>" + "</taskBody>") + .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task"); } @BeforeClass diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index c74ea57762d9d..f46863d2bdb89 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -80,7 +80,10 @@ public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBExc ParserConfigurationException { // Arrange URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(); + String mediaProcessorId = "testMediaProcessorId"; + String taskBody = "testTaskBody"; + + Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(mediaProcessorId, taskBody); // Act MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); @@ -95,8 +98,10 @@ public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBExc public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationException, MessagingException, IOException { // Arrange + String mediaProcessorId = "testMediaProcessorId"; + String taskBody = "testTaskBody"; URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build(); - Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(); + Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(mediaProcessorId, taskBody); Job.CreateBatchOperation jobCreateBatchOperation = new Job.CreateBatchOperation(serviceUri); // Act diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 0cc41917282f0..4736b8d52c171 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -216,51 +216,53 @@ public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateB // Process public Task.CreateBatchOperation createTaskOptionsWindowsAzureMediaEncoder(String taskName, int inputAssetId, int outputAssetId) throws ServiceException { - Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) - .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER)) - .setConfiguration("H.264 256k DSL CBR"); - setTaskBody(taskCreate, inputAssetId, outputAssetId); + String taskBody = getTaskBody(inputAssetId, outputAssetId); + Task.CreateBatchOperation taskCreate = Task + .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER), taskBody) + .setName(taskName).setConfiguration("H.264 256k DSL CBR"); + return taskCreate; } // Process public Task.CreateBatchOperation createTaskOptionsPlayReadyProtection(String taskName, String playReadyConfiguration, int inputAssetId, int outputAssetId) throws ServiceException { + String taskBody = getTaskBody(inputAssetId, outputAssetId); Task.CreateBatchOperation taskCreate = Task - .create() - .setName(taskName) + .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION), taskBody).setName(taskName) // TODO: Re-enable // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/499 // .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration) - .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION)) .setConfiguration(playReadyConfiguration); - setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } // Process public Task.CreateBatchOperation createTaskOptionsMp4ToSmoothStreams(String taskName, int inputAssetId, int outputAssetId) throws ServiceException { - Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) - .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS)) + String taskBody = getTaskBody(inputAssetId, outputAssetId); + Task.CreateBatchOperation taskCreate = Task + .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS), taskBody).setName(taskName) .setConfiguration(configMp4ToSmoothStreams); - setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } // Process public Task.CreateBatchOperation createTaskOptionsSmoothStreamsToHls(String taskName, int inputAssetId, int outputAssetId) throws ServiceException { - Task.CreateBatchOperation taskCreate = Task.create().setName(taskName) - .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS)) + String taskBody = getTaskBody(inputAssetId, outputAssetId); + Task.CreateBatchOperation taskCreate = Task + .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS), taskBody).setName(taskName) .setConfiguration(configSmoothStreamsToAppleHttpLiveStreams); - setTaskBody(taskCreate, inputAssetId, outputAssetId); + return taskCreate; } - private void setTaskBody(Task.CreateBatchOperation taskCreate, int inputAssetId, int outputAssetId) { - taskCreate.setTaskBody("<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>" - + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>"); + private String getTaskBody(int inputAssetId, int outputAssetId) { + return "<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>" + + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>"; } private String getMediaProcessorIdByName(String processorName) throws ServiceException { From 1c7153cbbff604f29accbe07699d6d9bd3b092d7 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 16:33:07 -0800 Subject: [PATCH 558/664] Added enums for state, options --- .../services/media/models/TaskInfo.java | 8 +- .../services/media/models/TaskOption.java | 69 ++++++++++++++++ .../services/media/models/TaskState.java | 81 +++++++++++++++++++ 3 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 3ed2fc51d31d1..52d996cb64631 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -142,8 +142,8 @@ public Date getStartTime() { * * @return the state */ - public Integer getState() { - return getContent().getState(); + public TaskState getState() { + return TaskState.fromCode(getContent().getState()); } /** @@ -160,8 +160,8 @@ public String getTaskBody() { * * @return the options */ - public Integer getOptions() { - return getContent().getOptions(); + public TaskOption getOptions() { + return TaskOption.fromCode(getContent().getOptions()); } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java new file mode 100644 index 0000000000000..657ff247def2b --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java @@ -0,0 +1,69 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.security.InvalidParameterException; + +/** + * Enum describing options for creating tasks + * + */ +public enum TaskOption { + + /** + * None + */ + None(0), + + /** + * Encrypt task configuration + */ + ProtectedConfiguration(1); + + private int code; + + private TaskOption(int code) { + this.code = code; + } + + /** + * Get integer code corresponding to enum value + * + * @return the code + */ + public int getCode() { + return code; + } + + /** + * Return enum value corresponding to integer code + * + * @param code + * the code + * @return the enum value + */ + public static TaskOption fromCode(int code) { + switch (code) { + case 0: + return None; + case 1: + return ProtectedConfiguration; + + default: + throw new InvalidParameterException("code"); + } + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java new file mode 100644 index 0000000000000..922840fd4a299 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java @@ -0,0 +1,81 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import java.security.InvalidParameterException; + +/** + * Enum defining the state of various tasks + * + */ +public enum TaskState { + /** + * No state + */ + None(0), + + /** + * Active + */ + Active(1), + + /** + * Running + */ + Running(2), + + /** + * Completed + */ + Completed(3); + + private int code; + + private TaskState(int code) { + this.code = code; + } + + /** + * Get integer code corresponding to enum value + * + * @return the code + */ + public int getCode() { + return code; + } + + /** + * Convert code into enum value + * + * @param code + * the code + * @return the corresponding enum value + */ + public static TaskState fromCode(int code) { + switch (code) { + case 0: + return None; + case 1: + return Active; + case 2: + return Running; + case 3: + return Completed; + default: + throw new InvalidParameterException("code"); + } + } +} From 89eb936175841f9504b1a5abcfabf4bd98d9355c Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 17:19:36 -0800 Subject: [PATCH 559/664] Fixing breakage caused by merge issues --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 24760081cd142..21e687662d70a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -305,7 +305,7 @@ public void canGetInputOutputAssetsFromJob() throws Exception { Date stateTime = null; Date endTime = null; - JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) + JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); ListResult<AssetInfo> inputs = service.list(Asset.list(actualJob.getInputAssetsLink())); From 8062bc63c810c924347c4ef4bdd5eef20d023594 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 17:46:56 -0800 Subject: [PATCH 560/664] Added fluent setters for list query params --- .../entities/DefaultListOperation.java | 38 +++++++++++++++++++ .../services/media/models/AccessPolicy.java | 5 +-- .../services/media/models/Asset.java | 7 ++-- .../services/media/models/AssetFile.java | 5 +-- .../services/media/models/ContentKey.java | 5 +-- .../services/media/models/Job.java | 5 +-- .../services/media/models/Locator.java | 5 +-- .../services/media/models/MediaProcessor.java | 5 +-- .../services/media/models/Task.java | 5 +-- .../media/AccessPolicyIntegrationTest.java | 8 +--- .../services/media/AssetIntegrationTest.java | 5 +-- .../media/ContentKeyIntegrationTest.java | 8 +--- .../services/media/EntityProxyTest.java | 12 ++---- .../services/media/JobIntegrationTest.java | 7 +--- .../media/LocatorIntegrationTests.java | 13 +++---- .../media/MediaProcessorIntegrationTest.java | 14 +------ .../media/models/AssetEntityTest.java | 10 +++++ .../scenarios/MediaServiceWrapper.java | 8 ++-- 18 files changed, 83 insertions(+), 82 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index 128dce080b1e8..6b83791ebe7e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -41,6 +41,44 @@ public DefaultListOperation(String entityUri, GenericType<ListResult<T>> respons this.queryParameters.putAll(queryParameters); } + /** + * Add a "$top" query parameter to set the number of values to return + * + * @param topValue + * number of values to return + * @return this + */ + public DefaultListOperation<T> setTop(int topValue) { + queryParameters.add("$top", Integer.toString(topValue)); + return this; + } + + /** + * Add a "$skip" query parameter to set the number of values to skip + * + * @param skipValue + * the number of values to skip + * @return this + */ + public DefaultListOperation<T> setSkip(int skipValue) { + queryParameters.add("$skip", Integer.toString(skipValue)); + return this; + } + + /** + * Add an arbitrary query parameter + * + * @param parameterName + * name of query parameter + * @param parameterValue + * value for query parameter + * @return this + */ + public DefaultListOperation<T> set(String parameterName, String parameterValue) { + queryParameters.add(parameterName, parameterValue); + return this; + } + /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.entities.EntityListOperation#getQueryParameters() */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index a0d7cb38e9475..bb3ab2c2bd3c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -26,7 +26,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; @@ -96,7 +95,7 @@ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { * * @return the operation */ - public static EntityListOperation<AccessPolicyInfo> list() { + public static DefaultListOperation<AccessPolicyInfo> list() { return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() { }); } @@ -108,7 +107,7 @@ public static EntityListOperation<AccessPolicyInfo> list() { * query parameters to add to the request * @return the operation */ - public static EntityListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() { }, queryParameters); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 840499cde7732..a55aeff0c7359 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -27,7 +27,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; @@ -167,7 +166,7 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { * * @return The list operation */ - public static EntityListOperation<AssetInfo> list() { + public static DefaultListOperation<AssetInfo> list() { return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() { }); } @@ -179,7 +178,7 @@ public static EntityListOperation<AssetInfo> list() { * query parameters to pass to the server. * @return the list operation. */ - public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() { }, queryParameters); } @@ -191,7 +190,7 @@ public static EntityListOperation<AssetInfo> list(MultivaluedMap<String, String> * Link to request assets from. * @return The list operation. */ - public static EntityListOperation<AssetInfo> list(LinkInfo link) { + public static DefaultListOperation<AssetInfo> list(LinkInfo link) { return new DefaultListOperation<AssetInfo>(link.getHref(), new GenericType<ListResult<AssetInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index b56f63db4875b..a02c252484d09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -28,7 +28,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; @@ -196,7 +195,7 @@ public static EntityGetOperation<AssetFileInfo> get(String assetFileId) { * * @return The list operation to pass to rest proxy. */ - public static EntityListOperation<AssetFileInfo> list() { + public static DefaultListOperation<AssetFileInfo> list() { return new DefaultListOperation<AssetFileInfo>(ENTITY_SET, new GenericType<ListResult<AssetFileInfo>>() { }); } @@ -208,7 +207,7 @@ public static EntityListOperation<AssetFileInfo> list() { * asset to list files for * @return the list operation object */ - public static EntityListOperation<AssetFileInfo> list(String assetId) { + public static DefaultListOperation<AssetFileInfo> list(String assetId) { String assetUri = new EntityOperationBase.EntityIdUriBuilder("Assets", assetId).getUri() + "/Files"; return new DefaultListOperation<AssetFileInfo>(assetUri, new GenericType<ListResult<AssetFileInfo>>() { }); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 1ca7827c3be8d..090bf8e4e511f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -24,7 +24,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; @@ -155,7 +154,7 @@ public static EntityGetOperation<ContentKeyInfo> get(String ContentKeyId) { * * @return the operation */ - public static EntityListOperation<ContentKeyInfo> list() { + public static DefaultListOperation<ContentKeyInfo> list() { return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() { }); } @@ -167,7 +166,7 @@ public static EntityListOperation<ContentKeyInfo> list() { * query parameters to add to the request * @return the operation */ - public static EntityListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() { }, queryParameters); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index aeb08a0a2bec8..52a5238fcd264 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -40,7 +40,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; @@ -426,7 +425,7 @@ public static EntityGetOperation<JobInfo> get(String jobId) { * * @return The list operation */ - public static EntityListOperation<JobInfo> list() { + public static DefaultListOperation<JobInfo> list() { return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() { }); } @@ -438,7 +437,7 @@ public static EntityListOperation<JobInfo> list() { * query parameters to pass to the server. * @return the list operation. */ - public static EntityListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() { }, queryParameters); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 6f213b9a5f083..69c346e6fd88e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -25,7 +25,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; @@ -195,7 +194,7 @@ public static EntityGetOperation<LocatorInfo> get(String locatorId) { * * @return the list operation */ - public static EntityListOperation<LocatorInfo> list() { + public static DefaultListOperation<LocatorInfo> list() { return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { }); } @@ -207,7 +206,7 @@ public static EntityListOperation<LocatorInfo> list() { * query parameters to send with the request * @return the list operation */ - public static EntityListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { }, queryParameters); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index efb94a0e29734..ca12e47c3ebbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -18,7 +18,6 @@ import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.api.client.GenericType; /** @@ -37,7 +36,7 @@ private MediaProcessor() { * * @return the list operation */ - public static EntityListOperation<MediaProcessorInfo> list() { + public static DefaultListOperation<MediaProcessorInfo> list() { return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, new GenericType<ListResult<MediaProcessorInfo>>() { }); @@ -50,7 +49,7 @@ public static EntityListOperation<MediaProcessorInfo> list() { * query parameters to pass with the request * @return the list operation */ - public static EntityListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, new GenericType<ListResult<MediaProcessorInfo>>() { }, queryParameters); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 634d63149a0b9..27874d8df7a25 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -22,7 +22,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.api.client.GenericType; /** @@ -55,7 +54,7 @@ public static CreateBatchOperation create() { * * @return The list operation */ - public static EntityListOperation<TaskInfo> list() { + public static DefaultListOperation<TaskInfo> list() { return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() { }); } @@ -67,7 +66,7 @@ public static EntityListOperation<TaskInfo> list() { * query parameters to pass to the server. * @return the list operation. */ - public static EntityListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) { + public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) { return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() { }, queryParameters); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 1975e6f220857..b81665c3f7f9f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -21,8 +21,6 @@ import java.util.EnumSet; import java.util.List; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.core.ExponentialRetryPolicy; @@ -31,7 +29,6 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class AccessPolicyIntegrationTest extends IntegrationTestBase { private void verifyInfosEqual(String message, AccessPolicyInfo expected, AccessPolicyInfo actual) { @@ -153,10 +150,7 @@ public void canUseQueryParametersWhenListingAccessPolicies() throws Exception { expectedAccessPolicies.add(policy); } - MultivaluedMap<String, String> options = new MultivaluedMapImpl(); - options.add("$top", "2"); - - List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list(options)); + List<AccessPolicyInfo> actualAccessPolicies = service.list(AccessPolicy.list().setTop(2)); assertEquals(2, actualAccessPolicies.size()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index b4d9678c5349a..e03efc3be81de 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -39,7 +39,6 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class AssetIntegrationTest extends IntegrationTestBase { @@ -199,9 +198,7 @@ public void canListAssetsWithOptions() throws ServiceException { expectedAssets.add(service.create(Asset.create().setName(name))); } - MultivaluedMapImpl options = new MultivaluedMapImpl(); - options.add("$top", "2"); - Collection<AssetInfo> listAssetResult = service.list(Asset.list(options)); + Collection<AssetInfo> listAssetResult = service.list(Asset.list().setTop(2)); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 4f5975be291c8..6344a294abd0c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -21,8 +21,6 @@ import java.util.List; import java.util.UUID; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -30,7 +28,6 @@ import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; import com.microsoft.windowsazure.services.media.models.ProtectionKeyType; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class ContentKeyIntegrationTest extends IntegrationTestBase { @@ -138,10 +135,7 @@ public void canUseQueryParametersWhenListingContentKeys() throws Exception { expectedContentKeys.add(contentKeyInfo); } - MultivaluedMap<String, String> options = new MultivaluedMapImpl(); - options.add("$top", "2"); - - List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list(options)); + List<ContentKeyInfo> actualContentKeys = service.list(ContentKey.list().setTop(2)); assertEquals(2, actualContentKeys.size()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index 11f3870db5c6d..f047b48a9071b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -5,15 +5,12 @@ import java.util.HashSet; import java.util.Set; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class EntityProxyTest extends IntegrationTestBase { private static MediaContract entityService; @@ -80,10 +77,7 @@ public void canListAllAssets() throws Exception { public void canListAssetsWithQueryParameters() throws Exception { createTestAssets(4, "withQuery"); - MultivaluedMap<String, String> params = new MultivaluedMapImpl(); - params.add("$top", "2"); - - ListResult<AssetInfo> assets = entityService.list(Asset.list(params)); + ListResult<AssetInfo> assets = entityService.list(Asset.list().setTop(2)); assertEquals(2, assets.size()); } @@ -130,8 +124,8 @@ private Set<String> createTestAssets(int numAssets, String namePart) throws Exce Set<String> expectedAssets = new HashSet<String>(); for (int i = 0; i < numAssets; ++i) { - AssetInfo asset = entityService.create(Asset.create() - .setName(testAssetPrefix + namePart + Integer.toString(i))); + AssetInfo asset = entityService.create(Asset.create().setName( + testAssetPrefix + namePart + Integer.toString(i))); expectedAssets.add(asset.getId()); } return expectedAssets; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 21e687662d70a..185e16fa76f43 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -25,8 +25,6 @@ import java.util.List; import java.util.UUID; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.BeforeClass; import org.junit.Test; @@ -44,7 +42,6 @@ import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class JobIntegrationTest extends IntegrationTestBase { @@ -228,9 +225,7 @@ public void canListJobsWithOptions() throws ServiceException { expectedJobs.add(jobInfo); } - MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); - queryParameters.add("$top", "2"); - ListResult<JobInfo> listJobsResult = service.list(Job.list(queryParameters)); + ListResult<JobInfo> listJobsResult = service.list(Job.list().setTop(2)); // Assert assertEquals(2, listJobsResult.size()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index feb4b2bd7decd..8b3a6094f63d5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -37,7 +37,6 @@ import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class LocatorIntegrationTests extends IntegrationTestBase { @@ -213,12 +212,12 @@ public void listLocatorsWithOptions() throws ServiceException { LocatorType.SAS))); } - MultivaluedMapImpl options = new MultivaluedMapImpl(); - options.add("$filter", "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '" - + expectedLocators.get(3).getId() + "')"); - options.add("$top", "3"); - - ListResult<LocatorInfo> result = service.list(Locator.list(options)); + ListResult<LocatorInfo> result = service.list(Locator + .list() + .setTop(3) + .set("$filter", + "(Id eq '" + expectedLocators.get(1).getId() + "') or (" + "Id eq '" + + expectedLocators.get(3).getId() + "')")); assertEquals(2, result.size()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index d2a4a0de9882e..6ca7d6c679a82 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -19,15 +19,12 @@ import java.util.List; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class MediaProcessorIntegrationTest extends IntegrationTestBase { @@ -69,16 +66,9 @@ public void listMediaProcessorsSuccess() throws ServiceException { @Test public void listMediaProcessorWithOptionSuccess() throws ServiceException { - // Arrange - MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); - queryParameters.add("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'"); - queryParameters.add("$top", "2"); + ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor.list().setTop(2) + .set("$filter", "Id eq 'nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10'")); - // Act - ListResult<MediaProcessorInfo> listMediaProcessorsResult = service.list(MediaProcessor - .list(queryParameters)); - - // Assert assertNotNull("listMediaProcessorsResult", listMediaProcessorsResult); assertEquals("listMediaProcessors size", 1, listMediaProcessorsResult.size()); MediaProcessorInfo mediaProcessorInfo = listMediaProcessorsResult.get(0); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 9c5fcc892eebb..c543b5767be56 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -110,6 +110,16 @@ public void assetListCanTakeQueryParameters() { assertEquals(2, lister.getQueryParameters().size()); } + @Test + public void assetListCanTakeQueryParametersChained() { + EntityListOperation<AssetInfo> lister = Asset.list().setTop(10).setSkip(2).set("filter", "something"); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals("something", lister.getQueryParameters().getFirst("filter")); + assertEquals(3, lister.getQueryParameters().size()); + } + @Test public void assetUpdateReturnsExpectedUri() throws Exception { EntityUpdateOperation updater = Asset.update(sampleAssetId); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 3eb9c37522950..a5eaf3d6d6e15 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -116,11 +116,9 @@ public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, i throws ServiceException { List<ListResult<AssetInfo>> pages = new ArrayList<ListResult<AssetInfo>>(); for (int skip = 0; true; skip += pageSize) { - EntityListOperation<AssetInfo> listOperation = Asset.list(); - listOperation.getQueryParameters().add("$skip", skip + ""); - listOperation.getQueryParameters().add("$top", pageSize + ""); - listOperation.getQueryParameters().add("$filter", "startswith(Name,'" + rootName + "')"); - listOperation.getQueryParameters().add("$orderby", "Name"); + EntityListOperation<AssetInfo> listOperation = Asset.list().setTop(pageSize).setSkip(skip) + .set("$filter", "startswith(Name,'" + rootName + "')").set("$orderby", "Name"); + ListResult<AssetInfo> listAssetResult = service.list(listOperation); pages.add(listAssetResult); if (listAssetResult.size() == 0) { From fc05523656bf7e671698245ede7f795be1f1ea97 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 21:24:00 -0800 Subject: [PATCH 561/664] code review feedback. --- .../services/media/models/Task.java | 90 ------------------- 1 file changed, 90 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 4c37c6350b1c5..883cd1b7284e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -104,15 +104,6 @@ public CreateBatchOperation(String mediaProcessorId, String taskBody) { this.taskType.setTaskBody(taskBody); } - /** - * Gets the options. - * - * @return the options - */ - public int getOptions() { - return this.taskType.getOptions(); - } - /** * Sets the options. * @@ -137,15 +128,6 @@ public CreateBatchOperation setConfiguration(String configuration) { return this; } - /** - * Gets the configuration. - * - * @return the configuration - */ - public String getConfiguration() { - return this.taskType.getConfiguration(); - } - /** * Sets the name. * @@ -158,15 +140,6 @@ public CreateBatchOperation setName(String name) { return this; } - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return this.taskType.getName(); - } - /** * Sets the task body. * @@ -179,24 +152,6 @@ public CreateBatchOperation setTaskBody(String taskBody) { return this; } - /** - * Gets the task body. - * - * @return the task body - */ - public String getTaskBody() { - return this.taskType.getTaskBody(); - } - - /** - * Gets the media processor id. - * - * @return the media processor id - */ - public String getMediaProcessorId() { - return this.taskType.getMediaProcessorId(); - } - /** * Sets the media processor id. * @@ -209,15 +164,6 @@ public CreateBatchOperation setMediaProcessorId(String mediaProcessorId) { return this; } - /** - * Gets the priority. - * - * @return the priority - */ - public Integer getPriority() { - return this.taskType.getPriority(); - } - /** * Sets the priority. * @@ -230,15 +176,6 @@ public CreateBatchOperation setPriority(int priority) { return this; } - /** - * Gets the encryption key id. - * - * @return the encryption key id - */ - public String getEncryptionKeyId() { - return this.taskType.getEncryptionKeyId(); - } - /** * Sets the encryption key id. * @@ -251,15 +188,6 @@ public CreateBatchOperation setEncryptionKeyId(String encryptionKeyId) { return this; } - /** - * Gets the encryption scheme. - * - * @return the encryption scheme - */ - public String getEncryptionScheme() { - return this.taskType.getEncryptionScheme(); - } - /** * Sets the encryption scheme. * @@ -272,15 +200,6 @@ public CreateBatchOperation setEncryptionScheme(String encryptionScheme) { return this; } - /** - * Gets the encryption version. - * - * @return the encryption version - */ - public String getEncryptionVersion() { - return this.taskType.getEncryptionVersion(); - } - /** * Sets the encryption version. * @@ -293,15 +212,6 @@ public CreateBatchOperation setEncryptionVersion(String encryptionVersion) { return this; } - /** - * Gets the initialization vector. - * - * @return the initialization vector - */ - public String getInitializationVector() { - return this.taskType.getInitializationVector(); - } - /** * Sets the initialization vector. * From a09614c75a815f61373b6c1db8b88c7900c42c55 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 13 Dec 2012 21:29:50 -0800 Subject: [PATCH 562/664] code review feedback. --- .../services/media/EncryptionIntegrationTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 69d9680a672c2..3f0d6e5ffaaf4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -53,10 +53,13 @@ import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.ProtectionKey; +import com.microsoft.windowsazure.services.media.models.Task; public class EncryptionIntegrationTest extends IntegrationTestBase { @@ -116,13 +119,18 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, "uploadAesProtectedAssetSuccess", encryptedContent); - // executeDecodingJob(assetInfo); + decodeAsset(assetInfo); // Assert // verify the file downloaded is identical to the one that is uploaded. } + private void decodeAsset(AssetInfo assetInfo) throws ServiceException { + JobInfo jobInfo = service.create(Job.create(service.getRestServiceUri()).addInputMediaAsset(assetInfo.getId()) + .addTaskCreator(Task.create())); + } + private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException { URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); @@ -188,9 +196,4 @@ private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKey return contentKeyInfo; } - private AssetInfo createAsset(String string) { - // TODO Auto-generated method stub - return null; - } - } From ab3a2abe8f6b33cfbc131675bfa7b01795caabff Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 13 Dec 2012 16:04:32 -0800 Subject: [PATCH 563/664] Added getters for links --- .../services/media/models/TaskInfo.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 52d996cb64631..9dbe9d7983676 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -199,4 +199,22 @@ public String getEncryptionVersion() { public String getInitializationVector() { return getContent().getInitializationVector(); } + + /** + * Gets link to the task's input assets + * + * @return the link + */ + public LinkInfo getInputAssetsLink() { + return getRelationLink("InputMediaAssets"); + } + + /** + * Gets link to the task's output assets + * + * @return the link + */ + public LinkInfo getOutputAssetsLink() { + return getRelationLink("OutputMediaAssets"); + } } From 809002d6acc037b4fc5b6e8f0e189f163add3d02 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 10:38:51 -0800 Subject: [PATCH 564/664] Can now get tasks from job --- .../services/media/models/Task.java | 12 +++++++++++ .../services/media/JobIntegrationTest.java | 21 ++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index f224c7cfbbcce..97e828f435d94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -77,6 +77,18 @@ public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> }, queryParameters); } + /** + * Create an operation that will list the tasks pointed to by the given link + * + * @param link + * link to tasks + * @return the list operation. + */ + public static DefaultListOperation<TaskInfo> list(LinkInfo link) { + return new DefaultListOperation<TaskInfo>(link.getHref(), new GenericType<ListResult<TaskInfo>>() { + }); + } + /** * The Class CreateBatchOperation. */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 212a48a87d6e3..231292f8ebfa3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -42,6 +42,7 @@ import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; +import com.microsoft.windowsazure.services.media.models.TaskInfo; public class JobIntegrationTest extends IntegrationTestBase { @@ -289,13 +290,6 @@ public void deleteJobInvalidIdFail() throws ServiceException { public void canGetInputOutputAssetsFromJob() throws Exception { String name = testJobPrefix + "canGetInputOutputAssetsFromJob"; int priority = 3; - double duration = 0.0; - JobState state = JobState.Queued; - String templateId = null; - Date created = new Date(); - Date lastModified = new Date(); - Date stateTime = null; - Date endTime = null; JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); @@ -309,4 +303,17 @@ public void canGetInputOutputAssetsFromJob() throws Exception { assertEquals(1, outputs.size()); assertTrue(outputs.get(0).getName().contains(name)); } + + @Test + public void canGetTasksFromJob() throws Exception { + String name = testJobPrefix + "canGetTaskAssetsFromJob"; + int priority = 3; + + JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); + + ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink())); + + assertEquals(1, tasks.size()); + } } From 319a564f13e778245030dd223607cfaef00b812c Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 10:49:08 -0800 Subject: [PATCH 565/664] Successfully retrieving input/output assets from task --- .../services/media/JobIntegrationTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 231292f8ebfa3..6f9fcf7874c2a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -316,4 +316,24 @@ public void canGetTasksFromJob() throws Exception { assertEquals(1, tasks.size()); } + + @Test + public void canGetInputOutputAssetsFromTask() throws Exception { + String name = testJobPrefix + "canGetInputOutputAssetsFromTask"; + int priority = 3; + + JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) + .addInputMediaAsset(assetInfo.getId()).addTaskCreator(getTaskCreator(0))); + + ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink())); + ListResult<AssetInfo> inputs = service.list(Asset.list(tasks.get(0).getInputAssetsLink())); + ListResult<AssetInfo> outputs = service.list(Asset.list(tasks.get(0).getOutputAssetsLink())); + + assertEquals(1, inputs.size()); + assertEquals(assetInfo.getId(), inputs.get(0).getId()); + + assertEquals(1, outputs.size()); + assertTrue(outputs.get(0).getName().contains(name)); + } + } From eadf37cf16f616684f02bf40854958e40dfe6ca2 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 12:17:30 -0800 Subject: [PATCH 566/664] Removing setExpirationTime from locator update, and removing verification since we have no control over it any more --- .../services/media/models/Locator.java | 18 +-------- .../media/LocatorIntegrationTests.java | 39 +++++++------------ .../media/models/LocatorEntityTest.java | 7 +--- 3 files changed, 16 insertions(+), 48 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 69c346e6fd88e..5d68ec9b6e305 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -230,9 +230,6 @@ public static class Updater extends EntityOperationBase implements EntityUpdateO /** The start date time. */ private Date startDateTime; - /** The expiration date time. */ - private Date expirationDateTime; - /** * Instantiates a new updater. * @@ -248,7 +245,7 @@ public Updater(String locatorId) { */ @Override public Object getRequestContents() { - return new LocatorRestType().setStartTime(startDateTime).setExpirationDateTime(expirationDateTime); + return new LocatorRestType().setStartTime(startDateTime); } /* (non-Javadoc) @@ -270,19 +267,6 @@ public Updater setStartDateTime(Date startDateTime) { this.startDateTime = startDateTime; return this; } - - /** - * Set when the locator will expire. - * - * @param expirationDateTime - * the expiration date & time - * @return Updater instance - */ - public Updater setExpirationDateTime(Date expirationDateTime) { - this.expirationDateTime = expirationDateTime; - return this; - } - } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 8b3a6094f63d5..7faea174f2464 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -46,33 +46,24 @@ public class LocatorIntegrationTests extends IntegrationTestBase { private static int minuteInMS = 60 * 1000; private static int tenMinutesInMS = 10 * 60 * 1000; - private Date calculateDefaultExpectedExpDate(AccessPolicyInfo accessPolicy, AssetInfo asset) { - return new Date(asset.getLastModified().getTime() + (long) accessPolicy.getDurationInMinutes() * minuteInMS); - } - private void verifyLocatorInfosEqual(String message, LocatorInfo expected, LocatorInfo actual) { verifyLocatorProperties(message, expected.getAccessPolicyId(), expected.getAssetId(), - expected.getLocatorType(), expected.getStartTime(), expected.getExpirationDateTime(), expected.getId(), - expected.getPath(), actual); + expected.getLocatorType(), expected.getStartTime(), expected.getId(), expected.getPath(), actual); } private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, - LocatorType locatorType, Date startTime, Date expirationDateTime, LocatorInfo actualLocator) { - verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, expirationDateTime, null, - null, actualLocator); + LocatorType locatorType, Date startTime, LocatorInfo actualLocator) { + verifyLocatorProperties(message, accessPolicyId, assetId, locatorType, startTime, null, null, actualLocator); } private void verifyLocatorProperties(String message, String accessPolicyId, String assetId, - LocatorType locatorType, Date startTime, Date expirationDateTime, String id, String path, - LocatorInfo actualLocator) { + LocatorType locatorType, Date startTime, String id, String path, LocatorInfo actualLocator) { assertNotNull(message, actualLocator); assertEquals(message + " accessPolicyId", accessPolicyId, actualLocator.getAccessPolicyId()); assertEquals(message + " assetId", assetId, actualLocator.getAssetId()); assertEquals(message + " locatorType", locatorType, actualLocator.getLocatorType()); assertDateApproxEquals(message + " startTime", startTime, actualLocator.getStartTime()); - assertDateApproxEquals(message + " expirationDateTime", expirationDateTime, - actualLocator.getExpirationDateTime()); if (id == null) { assertNotNull(message + " Id", actualLocator.getId()); @@ -106,7 +97,6 @@ public void instanceSetup() throws Exception { public void createLocatorSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), @@ -114,14 +104,13 @@ public void createLocatorSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, - expectedExpirationDateTime, locatorInfo); + locatorInfo); } @Test public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { // Arrange LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = calculateDefaultExpectedExpDate(accessPolicyInfoRead, assetInfo); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), @@ -129,7 +118,7 @@ public void createLocatorWithSpecifiedIdSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType, null, - expectedExpirationDateTime, locatorInfo); + locatorInfo); } @Test @@ -138,8 +127,6 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { Date expectedStartDateTime = new Date(); expectedStartDateTime.setTime(expectedStartDateTime.getTime() + tenMinutesInMS); LocatorType locatorType = LocatorType.SAS; - Date expectedExpirationDateTime = new Date(expectedStartDateTime.getTime() - + (long) accessPolicyInfo.getDurationInMinutes() * minuteInMS); // Act LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), @@ -147,7 +134,7 @@ public void createLocatorOptionsSetStartTimeSuccess() throws ServiceException { // Assert verifyLocatorProperties("locatorInfo", accessPolicyInfo.getId(), assetInfo.getId(), locatorType, - expectedStartDateTime, expectedExpirationDateTime, locatorInfo); + expectedStartDateTime, locatorInfo); } @Test @@ -229,20 +216,20 @@ public void updateLocatorSuccess() throws ServiceException { LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfoRead.getId(), assetInfo.getId(), locatorType)); - Date expirationDateTime = new Date(); - expirationDateTime.setTime(expirationDateTime.getTime() + tenMinutesInMS); Date startTime = new Date(); startTime.setTime(startTime.getTime() - tenMinutesInMS); // Act - service.update(Locator.update(locatorInfo.getId()).setExpirationDateTime(expirationDateTime) - .setStartDateTime(startTime)); + service.update(Locator.update(locatorInfo.getId()).setStartDateTime(startTime)); LocatorInfo updatedLocatorInfo = service.get(Locator.get(locatorInfo.getId())); // Assert + Date expectedExpiration = new Date(); + expectedExpiration.setTime(startTime.getTime() + (long) accessPolicyInfoRead.getDurationInMinutes() + * minuteInMS); + verifyLocatorProperties("updatedLocatorInfo", locatorInfo.getAccessPolicyId(), locatorInfo.getAssetId(), - locatorInfo.getLocatorType(), startTime, expirationDateTime, locatorInfo.getId(), - locatorInfo.getPath(), updatedLocatorInfo); + locatorInfo.getLocatorType(), startTime, locatorInfo.getId(), locatorInfo.getPath(), updatedLocatorInfo); } @Test diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 6008fcd16371f..699ba22876597 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -157,19 +157,16 @@ public void locatorUpdateReturnsExpectedUri() throws Exception { } @Test - public void locatorUpdateCanStartAndExpirationTime() throws Exception { + public void locatorUpdateCanSetStarTime() throws Exception { Date now = new Date(); Date tenMinutesAgo = new Date(now.getTime() - 10 * 60 * 1000); - Date twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000); - EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo) - .setExpirationDateTime(twoHoursFromNow); + EntityUpdateOperation updater = Locator.update(exampleLocatorId).setStartDateTime(tenMinutesAgo); LocatorRestType payload = (LocatorRestType) updater.getRequestContents(); assertEquals(tenMinutesAgo, payload.getStartTime()); - assertEquals(twoHoursFromNow, payload.getExpirationDateTime()); } @Test From d9960487aefbc708f778eb821a9db9974dca4712 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 14 Dec 2012 13:22:27 -0800 Subject: [PATCH 567/664] no start time. --- .../services/media/models/Job.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index fb6d50b632ba7..3e20c4e8c1fa3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; -import java.util.Date; import java.util.List; import javax.mail.MessagingException; @@ -78,9 +77,6 @@ public static Creator create(URI serviceUri) { public static class Creator extends EntityOperationSingleResultBase<JobInfo> implements EntityCreationOperation<JobInfo> { - /** The start time. */ - private Date startTime; - /** The name. */ private String name; @@ -263,28 +259,6 @@ public Integer getPriority() { return this.priority; } - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime - * the start time - * @return the creator - */ - public Creator setStartTime(Date startTime) { - this.startTime = startTime; - this.fresh = true; - return this; - } - /** * Gets the input media assets. * @@ -391,7 +365,6 @@ public static CreateBatchOperation create(Creator creator) { CreateBatchOperation createBatchOperation = new CreateBatchOperation(creator.getServiceUri()); JobType jobType = new JobType(); - jobType.setStartTime(creator.getStartTime()); jobType.setName(creator.getName()); jobType.setPriority(creator.getPriority()); From 0f59a00098d3abad6275793eb944793e31688f9d Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 15:07:45 -0800 Subject: [PATCH 568/664] Listing content keys for assets --- .../services/media/models/AssetInfo.java | 9 +++++++++ .../services/media/models/ContentKey.java | 12 ++++++++++++ .../services/media/AssetIntegrationTest.java | 13 ++++--------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 7572827f3c411..236bb05bf6fb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -101,4 +101,13 @@ public String getAlternateId() { public AssetOption getOptions() { return AssetOption.fromCode(getContent().getOptions()); } + + /** + * Get a link to the asset's content keys + * + * @return the link + */ + public LinkInfo getContentKeysLink() { + return getRelationLink("ContentKeys"); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 090bf8e4e511f..67155985932c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -171,6 +171,18 @@ public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, S }, queryParameters); } + /** + * Create an operation that will list all the content keys at the given link. + * + * @param link + * Link to request content keys from. + * @return The list operation. + */ + public static DefaultListOperation<ContentKeyInfo> list(LinkInfo link) { + return new DefaultListOperation<ContentKeyInfo>(link.getHref(), new GenericType<ListResult<ContentKeyInfo>>() { + }); + } + /** * Create an operation to delete the given content key. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index e03efc3be81de..80955cd2a18ef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.UUID; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -275,7 +274,6 @@ public void deleteAssetFailedWithInvalidId() throws ServiceException { service.delete(Asset.delete(validButNonexistAssetId)); } - @Ignore("due to issue 507") @Test public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxException { // Arrange @@ -284,8 +282,7 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep .setOptions(AssetOption.StorageEncrypted)); String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, - ContentKeyType.StorageEncryption, encryptedContentKey)); + service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)); String escapedContentKeyId; try { escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); @@ -300,16 +297,14 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep // Assert - // List<ContentKeyInfo> contentKeyInfos = service.list(ContentKey.list(assetInfo.getId())); - // ContentKeyInfo contentKeyInfo = contentKeyInfos.get(0) - // assertEquals(contentKeyId, contentKeyInfo.getId()); - + List<ContentKeyInfo> contentKeys = service.list(ContentKey.list(assetInfo.getContentKeysLink())); + assertEquals(1, contentKeys.size()); + assertEquals(contentKeyId, contentKeys.get(0).getId()); } @Test public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyntaxException { // Arrange - String originalTestName = testAssetPrefix + "linkAssetContentKeyInvalidIdFailed"; URI invalidContentKeyUri = new URI("ContentKeys('nb%3akid%3aUUID%3ainvalidContentKeyId')"); // Act From be1c86fbf6fc6adda281e2e03d3ab336f9fee9cf Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 15:34:56 -0800 Subject: [PATCH 569/664] Removed AssetFile.list(assetId), added AssetFile.list(link) and AssetInfo.getAssetFilesLink() --- .../services/media/models/AssetFile.java | 13 ++++++------- .../services/media/models/AssetInfo.java | 9 +++++++++ .../services/media/AssetFileIntegrationTest.java | 10 +++++----- .../services/media/models/AssetFileEntityTest.java | 8 -------- .../services/scenarios/MediaServiceValidation.java | 6 +++--- .../services/scenarios/MediaServiceWrapper.java | 6 +++--- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index a02c252484d09..64744b6c14428 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -201,15 +201,14 @@ public static DefaultListOperation<AssetFileInfo> list() { } /** - * Calls the service to list files for an asset + * Create an operation that will list all the AssetFiles at the given link. * - * @param assetId - * asset to list files for - * @return the list operation object + * @param link + * Link to request AssetFiles from. + * @return The list operation. */ - public static DefaultListOperation<AssetFileInfo> list(String assetId) { - String assetUri = new EntityOperationBase.EntityIdUriBuilder("Assets", assetId).getUri() + "/Files"; - return new DefaultListOperation<AssetFileInfo>(assetUri, new GenericType<ListResult<AssetFileInfo>>() { + public static DefaultListOperation<AssetFileInfo> list(LinkInfo link) { + return new DefaultListOperation<AssetFileInfo>(link.getHref(), new GenericType<ListResult<AssetFileInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 236bb05bf6fb3..d28d857c9ddb7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -102,6 +102,15 @@ public AssetOption getOptions() { return AssetOption.fromCode(getContent().getOptions()); } + /** + * Get a link to the asset's files + * + * @return the link + */ + public LinkInfo getAssetFilesLink() { + return getRelationLink("Files"); + } + /** * Get a link to the asset's content keys * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index 173ebf8d53b71..e151ba5c58802 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -68,7 +68,7 @@ public void canCreateFileForUploadedBlob() throws Exception { service.action(AssetFile.createFileInfos(asset.getId())); - ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getAssetFilesLink())); assertEquals(1, files.size()); AssetFileInfo file = files.get(0); @@ -85,7 +85,7 @@ public void canCreateFileEntityDirectly() throws Exception { service.create(AssetFile.create(asset.getId(), BLOB_NAME_2)); - ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getAssetFilesLink())); boolean found = false; for (AssetFileInfo file : files) { @@ -119,7 +119,7 @@ public void canCreateAssetWithMultipleFiles() throws Exception { AssetFileInfo file3 = service.create(AssetFile.create(asset.getId(), "blob3.bin").setIsPrimary(false) .setIsEncrypted(false).setContentFileSize(new Long(countingUp.length)).setContentChecksum("1234")); - ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getId())); + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getAssetFilesLink())); assertEquals(3, files.size()); @@ -166,7 +166,7 @@ public void canDeleteFileFromAsset() throws Exception { service.action(AssetFile.createFileInfos(asset.getId())); - ListResult<AssetFileInfo> originalFiles = service.list(AssetFile.list(asset.getId())); + ListResult<AssetFileInfo> originalFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); assertEquals(2, originalFiles.size()); for (AssetFileInfo file : originalFiles) { @@ -176,7 +176,7 @@ public void canDeleteFileFromAsset() throws Exception { } } - ListResult<AssetFileInfo> newFiles = service.list(AssetFile.list(asset.getId())); + ListResult<AssetFileInfo> newFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); assertEquals(1, newFiles.size()); assertEquals("tokeep.bin", newFiles.get(0).getName()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java index 299eb71440775..441ae2b603dbb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java @@ -74,14 +74,6 @@ public void getByIdHasCorrectUri() throws Exception { assertEquals(expectedUri, getter.getUri()); } - @Test - public void listFileInfosForAnAssetHasCorrectUri() throws Exception { - String expectedUri = String.format("Assets(%s)/Files", encodedAssetId); - EntityListOperation<AssetFileInfo> lister = AssetFile.list(exampleAssetId); - - assertEquals(expectedUri, lister.getUri()); - } - @Test public void listAllFileInfosHasCorrectUri() throws Exception { String expectedUri = "Files"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 7de78be033c23..164f54ff8385c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -32,8 +32,8 @@ import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; -import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.AssetOption; +import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; @@ -54,7 +54,7 @@ public void validateAsset(AssetInfo asset, String name, AssetOption encryption) assertEquals("asset.getOptions", encryption, asset.getOptions()); // Verify no files by default. - List<AssetFileInfo> initialFiles = service.list(AssetFile.list(asset.getId())); + List<AssetFileInfo> initialFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); assertNotNull("initialFiles", initialFiles); assertEquals("initialFiles.size", 0, initialFiles.size()); @@ -90,7 +90,7 @@ public void validateAssetSortedPages(List<ListResult<AssetInfo>> pages, List<Str public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> inputFiles) throws ServiceException, IOException, NoSuchAlgorithmException { - List<AssetFileInfo> assetFiles = service.list(AssetFile.list(asset.getId())); + List<AssetFileInfo> assetFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); assertNotNull("assetFiles", assetFiles); assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 85217106b5a63..0ad9ea9fa68b7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -164,7 +164,7 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht } service.action(AssetFile.createFileInfos(asset.getId())); - for (AssetFileInfo assetFile : service.list(AssetFile.list(asset.getId()))) { + for (AssetFileInfo assetFile : service.list(AssetFile.list(asset.getAssetFilesLink()))) { AssetFileInfo x = infoToUpload.get(assetFile.getName()); System.out.println(x); @@ -172,7 +172,7 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht .setContentFileSize(x.getContentFileSize()).setIsPrimary(x.getIsPrimary())); } - service.list(AssetFile.list(asset.getId())); + service.list(AssetFile.list(asset.getAssetFilesLink())); service.delete(Locator.delete(locator.getId())); service.delete(AccessPolicy.delete(accessPolicy.getId())); @@ -321,7 +321,7 @@ private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), locatorType)); - List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getId())); + List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); for (AssetFileInfo fi : publishedFiles) { if (isSmooth) { // Smooth Streaming format ends with ".ism*" From 21ca170033dd65a39d54ccf3ff65bcdea8fd0d22 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 15:45:00 -0800 Subject: [PATCH 570/664] Getting locators from assets --- .../services/media/models/AssetInfo.java | 9 +++++++++ .../windowsazure/services/media/models/Locator.java | 12 ++++++++++++ .../services/media/LocatorIntegrationTests.java | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index d28d857c9ddb7..71e6ee99f54af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -119,4 +119,13 @@ public LinkInfo getAssetFilesLink() { public LinkInfo getContentKeysLink() { return getRelationLink("ContentKeys"); } + + /** + * Get a link to the asset's locators + * + * @return the link + */ + public LinkInfo getLocatorsLink() { + return getRelationLink("Locators"); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 69c346e6fd88e..d4926218f4fef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -211,6 +211,18 @@ public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, Stri }, queryParameters); } + /** + * Create an operation that will list all the locators at the given link. + * + * @param link + * Link to request locators from. + * @return The list operation. + */ + public static DefaultListOperation<LocatorInfo> list(LinkInfo link) { + return new DefaultListOperation<LocatorInfo>(link.getHref(), new GenericType<ListResult<LocatorInfo>>() { + }); + } + /** * Create an operation to update the given locator. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index 8b3a6094f63d5..d75d45f5d1399 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -292,4 +292,16 @@ public void deleteLocatorInvalidIdFailed() throws ServiceException { expectedException.expect(new ServiceExceptionMatcher(400)); service.delete(Locator.delete(invalidId)); } + + @Test + public void canGetLocatorBackFromAsset() throws Exception { + LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS)); + + ListResult<LocatorInfo> locators = service.list(Locator.list(assetInfo.getLocatorsLink())); + + assertEquals(1, locators.size()); + assertEquals(locator.getId(), locators.get(0).getId()); + + } } From a11747dae8da661856cbe434bc62e06c4ab7fcbc Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 15:46:59 -0800 Subject: [PATCH 571/664] Added parent assets link --- .../windowsazure/services/media/models/AssetInfo.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 71e6ee99f54af..f7bb8e4f5bf37 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -128,4 +128,14 @@ public LinkInfo getContentKeysLink() { public LinkInfo getLocatorsLink() { return getRelationLink("Locators"); } + + /** + * Get a link to the asset's locators + * + * @return the link + */ + public LinkInfo getParentAssetsLink() { + // TODO: NEEDS TESTS once we figure out how to create assets with parents + return getRelationLink("ParentAssets"); + } } From d9dc999ca0aa94b3bb985be029a9572254227bab Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 16:09:03 -0800 Subject: [PATCH 572/664] Locator relationships added --- .../entities/DefaultGetOperation.java | 21 +++++++++++++++++-- .../services/media/models/AccessPolicy.java | 11 ++++++++++ .../services/media/models/Asset.java | 11 ++++++++++ .../services/media/models/LocatorInfo.java | 18 ++++++++++++++++ .../media/LocatorIntegrationTests.java | 21 +++++++++++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java index 9f24fb969af87..a4ffb02bc109f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java @@ -15,7 +15,6 @@ package com.microsoft.windowsazure.services.media.implementation.entities; - /** * Generic implementation of the get operation usable for most entities * @@ -23,10 +22,28 @@ public class DefaultGetOperation<T> extends EntityOperationSingleResultBase<T> implements EntityGetOperation<T> { /** - * @param uri + * Construct a new DefaultGetOperation to return the given entity id + * + * @param entityTypeUri + * Entity set URI + * @param entityId + * id of entity * @param responseClass + * class to return from the get operation */ public DefaultGetOperation(String entityTypeUri, String entityId, Class<T> responseClass) { super(new EntityOperationBase.EntityIdUriBuilder(entityTypeUri, entityId), responseClass); } + + /** + * Construct a new DefaultGetOperation to return the entity from the given uri + * + * @param uri + * Uri for entity + * @param responseClass + * class to return from the get operation + */ + public DefaultGetOperation(String uri, Class<T> responseClass) { + super(uri, responseClass); + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index bb3ab2c2bd3c3..e2b6088814b0b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -90,6 +90,17 @@ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { return new DefaultGetOperation<AccessPolicyInfo>(ENTITY_SET, accessPolicyId, AccessPolicyInfo.class); } + /** + * Create an operation that will retrieve the access policy at the given link + * + * @param link + * the link + * @return the operation + */ + public static EntityGetOperation<AccessPolicyInfo> get(LinkInfo link) { + return new DefaultGetOperation<AccessPolicyInfo>(link.getHref(), AccessPolicyInfo.class); + } + /** * Create an operation that will retrieve all access policies * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index a55aeff0c7359..40faa4870351a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -161,6 +161,17 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { return new DefaultGetOperation<AssetInfo>(ENTITY_SET, assetId, AssetInfo.class); } + /** + * Get the asset at the given link + * + * @param link + * the link + * @return the get operation + */ + public static EntityGetOperation<AssetInfo> get(LinkInfo link) { + return new DefaultGetOperation<AssetInfo>(link.getHref(), AssetInfo.class); + } + /** * Create an operation that will list all the assets. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index b5ed565f80334..f36023ae7d89c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -118,4 +118,22 @@ public String getBaseUri() { public String getContentAccessToken() { return this.getContent().getContentAccessComponent(); } + + /** + * Return a link that gets this locator's access policy + * + * @return the link + */ + public LinkInfo getAccessPolicyLink() { + return getRelationLink("AccessPolicy"); + } + + /** + * Return a link that gets this locator's asset + * + * @return the link + */ + public LinkInfo getAssetLink() { + return getRelationLink("Asset"); + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index d75d45f5d1399..756e7bf154c5c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -304,4 +304,25 @@ public void canGetLocatorBackFromAsset() throws Exception { assertEquals(locator.getId(), locators.get(0).getId()); } + + @Test + public void canGetAssetFromLocator() throws Exception { + LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS)); + + AssetInfo asset = service.get(Asset.get(locator.getAssetLink())); + + assertEquals(assetInfo.getId(), asset.getId()); + } + + @Test + public void canGetAccessPolicyFromLocator() throws Exception { + LocatorInfo locator = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS)); + + AccessPolicyInfo accessPolicy = service.get(AccessPolicy.get(locator.getAccessPolicyLink())); + + assertEquals(accessPolicyInfo.getId(), accessPolicy.getId()); + + } } From 6b1b52b88ba34affb33669dab6369837cf739633 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 16:22:46 -0800 Subject: [PATCH 573/664] Updating api version header to 2.0 --- .../services/media/implementation/VersionHeadersFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index 6dea13fc4f30d..4fcb7aa6eb9cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -37,7 +37,7 @@ public ClientResponse doHandle(ClientRequest cr) throws ClientHandlerException { MultivaluedMap<String, Object> headers = cr.getHeaders(); headers.add("DataServiceVersion", "3.0"); headers.add("MaxDataServiceVersion", "3.0"); - headers.add("x-ms-version", "1.0"); + headers.add("x-ms-version", "2.0"); return getNext().handle(cr); } } From 2825f3cd8e805ba864a61c98173f450a69be5d68 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 16:36:41 -0800 Subject: [PATCH 574/664] Renaming EntityCreationOperation to EntityCreateOperation for consistency --- .../implementation/MediaExceptionProcessor.java | 6 +++--- .../implementation/entities/EntityContract.java | 2 +- ...tionOperation.java => EntityCreateOperation.java} | 5 ++--- .../implementation/entities/EntityRestProxy.java | 4 ++-- .../services/media/models/AccessPolicy.java | 6 +++--- .../windowsazure/services/media/models/Asset.java | 6 +++--- .../services/media/models/AssetFile.java | 4 ++-- .../services/media/models/ContentKey.java | 6 +++--- .../windowsazure/services/media/models/Job.java | 8 ++++---- .../windowsazure/services/media/models/Locator.java | 8 ++++---- .../media/models/AccessPolicyEntityTest.java | 4 ++-- .../services/media/models/AssetFileEntityTest.java | 4 ++-- .../services/media/models/ContentKeyEntityTest.java | 4 ++-- .../services/media/models/LocatorEntityTest.java | 12 ++++++------ 14 files changed, 39 insertions(+), 40 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/{EntityCreationOperation.java => EntityCreateOperation.java} (89%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 2476b8d196b18..b69a4a7074ddd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -26,7 +26,7 @@ import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; @@ -92,10 +92,10 @@ private ServiceException processCatch(ServiceException e) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation) */ @Override - public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { + public <T> T create(EntityCreateOperation<T> creator) throws ServiceException { try { return service.create(creator); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index e317ba1065244..930ef1e5a0a69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -34,7 +34,7 @@ public interface EntityContract { * @return * The created entity */ - public abstract <T> T create(EntityCreationOperation<T> creator) throws ServiceException; + public abstract <T> T create(EntityCreateOperation<T> creator) throws ServiceException; /** * Retrieve an existing entity by id diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java similarity index 89% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java index aeef692228d90..3faec46b9d1f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java @@ -17,14 +17,13 @@ import com.microsoft.windowsazure.services.core.ServiceException; -// TODO: Auto-generated Javadoc /** - * The Interface EntityCreationOperation. + * The Interface EntityCreateOperation. * * @param <T> * the generic type */ -public interface EntityCreationOperation<T> extends EntityOperationSingleResult<T> { +public interface EntityCreateOperation<T> extends EntityOperationSingleResult<T> { /** * Get the object to be sent to the server containing diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index f2b8fdf039f82..71075322af9c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -104,11 +104,11 @@ private Builder getResource(EntityOperation operation) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation) */ @SuppressWarnings("unchecked") @Override - public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { + public <T> T create(EntityCreateOperation<T> creator) throws ServiceException { creator.setProxyData(createProxyData()); Object rawResponse = getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index e2b6088814b0b..c1fb8f933e2c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -23,7 +23,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; @@ -51,13 +51,13 @@ private AccessPolicy() { * permissions allowed by this access policy * @return The operation */ - public static EntityCreationOperation<AccessPolicyInfo> create(String name, double durationInMinutes, + public static EntityCreateOperation<AccessPolicyInfo> create(String name, double durationInMinutes, EnumSet<AccessPolicyPermission> permissions) { return new Creator(name, durationInMinutes, permissions); } private static class Creator extends EntityOperationSingleResultBase<AccessPolicyInfo> implements - EntityCreationOperation<AccessPolicyInfo> { + EntityCreateOperation<AccessPolicyInfo> { private final String policyName; private final double durationInMinutes; private final EnumSet<AccessPolicyPermission> permissions; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 40faa4870351a..c75f78f34a34f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -23,7 +23,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation; @@ -62,7 +62,7 @@ public static Creator create() { * The Class Creator. */ public static class Creator extends EntityOperationSingleResultBase<AssetInfo> implements - EntityCreationOperation<AssetInfo> { + EntityCreateOperation<AssetInfo> { /** The name. */ private String name; @@ -84,7 +84,7 @@ public Creator() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index 64744b6c14428..2dd506a577ae2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -25,7 +25,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; @@ -46,7 +46,7 @@ public static Creator create(String parentAssetId, String name) { } public static class Creator extends EntityOperationSingleResultBase<AssetFileInfo> implements - EntityCreationOperation<AssetFileInfo> { + EntityCreateOperation<AssetFileInfo> { private final String parentAssetId; private final String name; private String contentChecksum; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 67155985932c6..5586f0e0f89ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -21,7 +21,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; @@ -61,7 +61,7 @@ public static Creator create(String id, ContentKeyType contentKeyType, String en * The Class Creator. */ public static class Creator extends EntityOperationSingleResultBase<ContentKeyInfo> implements - EntityCreationOperation<ContentKeyInfo> { + EntityCreateOperation<ContentKeyInfo> { /** The id. */ private final String id; @@ -98,7 +98,7 @@ public Creator(String id, ContentKeyType contentKeyType, String encryptedContent } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 5f7de5dd98c43..16def29336f66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -36,7 +36,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; @@ -74,7 +74,7 @@ public static Creator create() { * The Class Creator. */ public static class Creator extends EntityOperationSingleResultBase<JobInfo> implements - EntityCreationOperation<JobInfo> { + EntityCreateOperation<JobInfo> { /** The name. */ private String name; @@ -156,7 +156,7 @@ public Creator() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() throws ServiceException { @@ -176,7 +176,7 @@ public Class getResponseClass() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#processResponse(java.lang.Object) */ @Override public Object processResponse(Object clientResponse) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index d4926218f4fef..f8f465cb41737 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -22,7 +22,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; @@ -64,7 +64,7 @@ public static Creator create(String accessPolicyId, String assetId, LocatorType * The Class Creator. */ public static class Creator extends EntityOperationSingleResultBase<LocatorInfo> implements - EntityCreationOperation<LocatorInfo> { + EntityCreateOperation<LocatorInfo> { /** The access policy id. */ private final String accessPolicyId; @@ -108,7 +108,7 @@ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -172,7 +172,7 @@ public Creator setContentAccessComponent(String contentAccessComponent) { * the id * @return the entity creation operation */ - public EntityCreationOperation<LocatorInfo> setId(String id) { + public EntityCreateOperation<LocatorInfo> setId(String id) { this.id = id; return this; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index c3533b379c4cc..bd5a7229192c3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -49,7 +49,7 @@ public void createAccessPolicyProvidesExpectedPayload() throws Exception { EnumSet<AccessPolicyPermission> permissions = EnumSet.of(AccessPolicyPermission.READ, AccessPolicyPermission.LIST); - EntityCreationOperation<AccessPolicyInfo> creator = AccessPolicy.create(name, duration, permissions); + EntityCreateOperation<AccessPolicyInfo> creator = AccessPolicy.create(name, duration, permissions); AccessPolicyType payload = (AccessPolicyType) creator.getRequestContents(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java index 441ae2b603dbb..c663c0b6dd2b2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java @@ -6,7 +6,7 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; @@ -43,7 +43,7 @@ public void createWithOptionsSetsOptionsAsExpected() throws Exception { Boolean expectedIsPrimary = true; String expectedMimeType = "application/octet-stream"; - EntityCreationOperation<AssetFileInfo> creator = AssetFile.create(exampleAssetId, expectedName) + EntityCreateOperation<AssetFileInfo> creator = AssetFile.create(exampleAssetId, expectedName) .setContentChecksum(expectedChecksum).setContentFileSize(expectedSize) .setEncryptionKeyId(expectedEncryptionKey).setEncryptionScheme(expectedEncryptionScheme) .setEncryptionVersion(expectedEncryptionVersion).setInitializationVector(expectedInitializationVector) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index bcf84bc5b159a..b453a421f1540 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -24,7 +24,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -46,7 +46,7 @@ public ContentKeyEntityTest() throws Exception { @Test public void createContentKeyHasCorrectUrl() throws Exception { - EntityCreationOperation<ContentKeyInfo> creator = ContentKey.create(testContentKeyId, testContentKeyType, + EntityCreateOperation<ContentKeyInfo> creator = ContentKey.create(testContentKeyId, testContentKeyType, testEncryptedContentKey); assertEquals("ContentKeys", creator.getUri()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 6008fcd16371f..1f4a0e65148da 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreationOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; @@ -48,7 +48,7 @@ public LocatorEntityTest() throws Exception { @Test public void createLocatorHasCorrectUrl() throws Exception { - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + EntityCreateOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS); assertEquals("Locators", creator.getUri()); @@ -70,7 +70,7 @@ public void createLocatorHasCorrectPayload() throws Exception { public void createLocatorCanSetStartTime() throws Exception { Date now = new Date(); - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + EntityCreateOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setStartDateTime(now); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); @@ -86,7 +86,7 @@ public void createLocatorCanSetPath() throws Exception { String expectedPath = "testExpectedPath"; - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + EntityCreateOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setPath(expectedPath); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); @@ -100,7 +100,7 @@ public void createLocatorCanSetBaseUri() throws Exception { String expectedBaseUri = "testExpectedBaseUri"; - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + EntityCreateOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setBaseUri(expectedBaseUri); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); @@ -114,7 +114,7 @@ public void createLocatorCanSetContentAccessComponent() throws Exception { String expectedContentAccessComponent = "testExpectedContentAccessComponent"; - EntityCreationOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, + EntityCreateOperation<LocatorInfo> creator = Locator.create(exampleAccessPolicyId, exampleAssetId, LocatorType.SAS).setContentAccessComponent(expectedContentAccessComponent); LocatorRestType locatorType = (LocatorRestType) creator.getRequestContents(); From 59c9897378dd638c13efc34fdf3430ecd0ced9ef Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 14 Dec 2012 16:40:00 -0800 Subject: [PATCH 575/664] enable the submission of decryption job. --- .../media/EncryptionIntegrationTest.java | 69 +++++++++++++++++-- .../services/media/JobIntegrationTest.java | 5 +- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 3f0d6e5ffaaf4..61c88d594d24e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -15,6 +15,8 @@ package com.microsoft.windowsazure.services.media; +import static org.junit.Assert.*; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -28,6 +30,7 @@ import java.security.cert.CertificateException; import java.security.spec.InvalidKeySpecException; import java.util.EnumSet; +import java.util.List; import java.util.UUID; import javax.crypto.BadPaddingException; @@ -55,9 +58,12 @@ import com.microsoft.windowsazure.services.media.models.ContentKeyType; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.MediaProcessor; +import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; @@ -66,6 +72,10 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { private final String validButNonexistContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473af"; private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; + private final String expressionEncoder = "Windows Azure Media Encoder"; + private final String wameV1Preset = "H.264 256k DSL CBR"; + private final String wameV2Preset = "H264 Broadband SD 4x3"; + private final String strorageDecryptionProcessor = "Storage Decryption"; private String createContentKeyId(UUID uuid) { String randomContentKey = String.format("nb:kid:UUID:%s", uuid); @@ -100,35 +110,82 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { int durationInMinutes = 10; // Act + + // creates asset AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") .setOptions(AssetOption.StorageEncrypted)); + // creates writable access policy AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + // creates locator for the input media asset LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), LocatorType.SAS)); + // gets the public key for storage encryption. + String protectionKey = getProtectionKey(); + // creates the content key with encrypted ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKey); + // link the content key with the asset. linkContentKey(assetInfo, contentKeyInfo); + // encrypt the file. byte[] encryptedContent = EncryptFile(smallWMVInputStream, aesKey, initializationVector); + + // upload the encrypted file to the server. AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, "uploadAesProtectedAssetSuccess", encryptedContent); - decodeAsset(assetInfo); + // submit and execute the decoding job. + JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); + + // assert + assertEquals(JobState.Finished, jobInfo.getState()); + + } - // Assert - // verify the file downloaded is identical to the one that is uploaded. + private JobInfo decodeAsset(String name, AssetInfo assetInfo) throws ServiceException, InterruptedException { + MediaProcessorInfo mediaProcessorInfo = GetMediaProcessor(strorageDecryptionProcessor); + JobInfo jobInfo = createJob(name, assetInfo, mediaProcessorInfo); + return waitJobForCompletion(jobInfo); } - private void decodeAsset(AssetInfo assetInfo) throws ServiceException { - JobInfo jobInfo = service.create(Job.create(service.getRestServiceUri()).addInputMediaAsset(assetInfo.getId()) - .addTaskCreator(Task.create())); + private JobInfo createJob(String name, AssetInfo assetInfo, MediaProcessorInfo mediaProcessorInfo) + throws ServiceException { + String configuration = "H.264 256k DSL CBR"; + String taskBody = "<taskBody>" + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"; + JobInfo jobInfo = service.create(Job + .create(service.getRestServiceUri()) + .addInputMediaAsset(assetInfo.getId()) + .addTaskCreator( + Task.create().setMediaProcessorId(mediaProcessorInfo.getId()).setName(name) + .setConfiguration(configuration).setTaskBody(taskBody))); + return jobInfo; + } + + private JobInfo waitJobForCompletion(JobInfo jobInfo) throws ServiceException, InterruptedException { + JobInfo currentJobInfo = jobInfo; + while (currentJobInfo.getState().getCode() < 3) { + currentJobInfo = service.get(Job.get(jobInfo.getId())); + Thread.sleep(4000); + } + return currentJobInfo; + } + + private MediaProcessorInfo GetMediaProcessor(String mediaProcessorName) throws ServiceException { + List<MediaProcessorInfo> mediaProcessorInfos = service.list(MediaProcessor.list()); + for (MediaProcessorInfo mediaProcessorInfo : mediaProcessorInfos) { + if (mediaProcessorInfo.getName().equals(mediaProcessorName)) { + return mediaProcessorInfo; + } + } + return null; } private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index bfa003d0cc98d..81201da9f3863 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -174,8 +174,9 @@ public void createJobTwoTasksSuccess() throws Exception { tasks.add(getTaskCreator(1)); // Act - JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name).setPriority(priority) - .addInputMediaAsset(assetInfo.getId()).addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); + JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name) + .setStartTime(new Date()).setPriority(priority).addInputMediaAsset(assetInfo.getId()) + .addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, From d5dde5505f9569d3cca11bf94a79124af2dae482 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 14 Dec 2012 18:21:45 -0800 Subject: [PATCH 576/664] Update TaskState according to feedback from nimbus team. --- .../services/media/models/Job.java | 2 - .../services/media/models/TaskState.java | 48 ++++++++++++------- .../media/EncryptionIntegrationTest.java | 32 ++++++++----- .../services/media/JobIntegrationTest.java | 6 --- 4 files changed, 51 insertions(+), 37 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 5f7de5dd98c43..c040f7423ab16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -62,8 +62,6 @@ private Job() { /** * Creates an operation to create a new job. * - * @param serviceUri - * the service uri * @return the creator */ public static Creator create() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java index 922840fd4a299..40280c8d338cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java @@ -18,38 +18,46 @@ import java.security.InvalidParameterException; /** - * Enum defining the state of various tasks - * + * Enum defining the state of various tasks. */ public enum TaskState { - /** - * No state - */ + + /** No state. */ None(0), - /** - * Active - */ + /** Active. */ Active(1), - /** - * Running - */ + /** Running. */ Running(2), - /** - * Completed - */ - Completed(3); + /** Completed. */ + Completed(3), + + /** Error. */ + Error(4), + + /** The Canceled. */ + Canceled(5), + /** The Canceling. */ + Canceling(6); + + /** The code. */ private int code; + /** + * Instantiates a new task state. + * + * @param code + * the code + */ private TaskState(int code) { this.code = code; } /** - * Get integer code corresponding to enum value + * Get integer code corresponding to enum value. * * @return the code */ @@ -58,7 +66,7 @@ public int getCode() { } /** - * Convert code into enum value + * Convert code into enum value. * * @param code * the code @@ -74,6 +82,12 @@ public static TaskState fromCode(int code) { return Running; case 3: return Completed; + case 4: + return Error; + case 5: + return Canceled; + case 6: + return Canceling; default: throw new InvalidParameterException("code"); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 61c88d594d24e..c78f603e46e61 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -21,7 +21,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URLEncoder; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -59,6 +61,7 @@ import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; +import com.microsoft.windowsazure.services.media.models.LinkInfo; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -66,6 +69,8 @@ import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.TaskInfo; +import com.microsoft.windowsazure.services.media.models.TaskState; public class EncryptionIntegrationTest extends IntegrationTestBase { @@ -144,6 +149,11 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); // assert + LinkInfo taskLinkInfo = jobInfo.getTasksLink(); + List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); + for (TaskInfo taskInfo : taskInfos) { + assertEquals(TaskState.Completed, taskInfo.getState()); + } assertEquals(JobState.Finished, jobInfo.getState()); } @@ -157,15 +167,11 @@ private JobInfo decodeAsset(String name, AssetInfo assetInfo) throws ServiceExce private JobInfo createJob(String name, AssetInfo assetInfo, MediaProcessorInfo mediaProcessorInfo) throws ServiceException { - String configuration = "H.264 256k DSL CBR"; + // String configuration = "H.264 256k DSL CBR"; String taskBody = "<taskBody>" - + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset>JobOutputAsset(0)</outputAsset></taskBody>"; - JobInfo jobInfo = service.create(Job - .create(service.getRestServiceUri()) - .addInputMediaAsset(assetInfo.getId()) - .addTaskCreator( - Task.create().setMediaProcessorId(mediaProcessorInfo.getId()).setName(name) - .setConfiguration(configuration).setTaskBody(taskBody))); + + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset assetCreationOptions=\"0\" assetName=\"Output\">JobOutputAsset(0)</outputAsset></taskBody>"; + JobInfo jobInfo = service.create(Job.create().addInputMediaAsset(assetInfo.getId()) + .addTaskCreator(Task.create(mediaProcessorInfo.getId(), taskBody).setName(name))); return jobInfo; } @@ -188,8 +194,9 @@ private MediaProcessorInfo GetMediaProcessor(String mediaProcessorName) throws S return null; } - private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException { - URI contentKeyUri = createContentKeyUri(service.getRestServiceUri(), contentKeyInfo.getId()); + private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException, + UnsupportedEncodingException { + URI contentKeyUri = createContentKeyUri(contentKeyInfo.getId()); service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); } @@ -212,8 +219,9 @@ private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, LocatorInfo return assetFileInfo; } - private URI createContentKeyUri(URI rootUri, String contentKeyId) { - return URI.create(String.format("%s/ContentKeys('%s')", rootUri, contentKeyId)); + private URI createContentKeyUri(String contentKeyId) throws UnsupportedEncodingException { + String escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); + return URI.create(String.format("ContentKeys('%s')", escapedContentKeyId)); } private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index e9a36fa7f7386..6f9fcf7874c2a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -157,14 +157,8 @@ public void createJobTwoTasksSuccess() throws Exception { tasks.add(getTaskCreator(1)); // Act -<<<<<<< HEAD - JobInfo actualJob = service.create(Job.create(service.getRestServiceUri()).setName(name) - .setStartTime(new Date()).setPriority(priority).addInputMediaAsset(assetInfo.getId()) - .addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); -======= JobInfo actualJob = service.create(Job.create().setName(name).setPriority(priority) .addInputMediaAsset(assetInfo.getId()).addTaskCreator(tasks.get(0)).addTaskCreator(tasks.get(1))); ->>>>>>> 4b6de12d6114e1b5ce13e5e4a360d8717cf87708 // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, From c192e969ec720450527c116541f0e7de73d8a0e2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Sun, 16 Dec 2012 20:37:20 -0800 Subject: [PATCH 577/664] add protection key id to content key implementation. --- .../services/media/models/ContentKey.java | 18 +++++++++++- .../media/EncryptionIntegrationTest.java | 29 ++++++++++++------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 67155985932c6..cd3ee1792b7bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -27,6 +27,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; +// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate content key entities. * @@ -78,6 +79,9 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn /** The checksum. */ private String checksum; + /** The protection key id. */ + private String protectionKeyId; + /** * Instantiates a new creator. * @@ -89,7 +93,6 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn * the encrypted content key */ public Creator(String id, ContentKeyType contentKeyType, String encryptedContentKey) { - super(ENTITY_SET, ContentKeyInfo.class); this.id = id; @@ -110,6 +113,7 @@ public Object getRequestContents() { contentKeyRestType.setEncryptedContentKey(encryptedContentKey); contentKeyRestType.setName(name); contentKeyRestType.setChecksum(checksum); + contentKeyRestType.setProtectionKeyId(protectionKeyId); return contentKeyRestType; } @@ -136,6 +140,18 @@ public Creator setChecksum(String checksum) { this.checksum = checksum; return this; } + + /** + * Sets the protection key id. + * + * @param protectionKeyId + * the protection key id + * @return the creator + */ + public Creator setProtectionKeyId(String protectionKeyId) { + this.protectionKeyId = protectionKeyId; + return this; + } } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index c78f603e46e61..717eab1cabc95 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -130,10 +130,12 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // gets the public key for storage encryption. - String protectionKey = getProtectionKey(); + String protectionKeyId = getProtectionKeyId(); + String protectionKey = getProtectionKey(protectionKeyId); // creates the content key with encrypted - ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKey); + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId, + protectionKey); // link the content key with the asset. linkContentKey(assetInfo, contentKeyInfo); @@ -158,6 +160,12 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { } + private String getProtectionKeyId() throws ServiceException { + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.StorageEncryption)); + return protectionKeyId; + } + private JobInfo decodeAsset(String name, AssetInfo assetInfo) throws ServiceException, InterruptedException { MediaProcessorInfo mediaProcessorInfo = GetMediaProcessor(strorageDecryptionProcessor); JobInfo jobInfo = createJob(name, assetInfo, mediaProcessorInfo); @@ -200,9 +208,7 @@ private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); } - private String getProtectionKey() throws ServiceException { - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); + private String getProtectionKey(String protectionKeyId) throws ServiceException { String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); return protectionKey; } @@ -247,17 +253,18 @@ private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initia return cipherText; } - private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKey) - throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException, - NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, ServiceException, - CertificateException { + private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId, + String protectionKey) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, + NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, + ServiceException, CertificateException { UUID contentKeyIdUuid = UUID.randomUUID(); String contentKeyId = createContentKeyId(contentKeyIdUuid); byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKey, aesKey); String encryptedContentKeyString = Base64.encode(encryptedContentKey); String checksum = EncryptionHelper.calculateChecksum(contentKeyIdUuid, aesKey); - ContentKeyInfo contentKeyInfo = service.create(ContentKey.create(contentKeyId, contentKeyType, - encryptedContentKeyString).setChecksum(checksum)); + ContentKeyInfo contentKeyInfo = service.create(ContentKey + .create(contentKeyId, contentKeyType, encryptedContentKeyString).setChecksum(checksum) + .setProtectionKeyId(protectionKeyId)); return contentKeyInfo; } From c3404df9389cf7ef5f760e48568cfc2575b4a624 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 10:57:23 -0800 Subject: [PATCH 578/664] let the encryption integration test pass. --- .../content/ErrorDetailType.java | 68 +++++++++++++++++++ .../implementation/content/TaskType.java | 6 +- .../services/media/models/ErrorDetail.java | 34 ++++++++++ .../services/media/models/TaskInfo.java | 16 ++++- .../services/media/EncryptionHelper.java | 25 +++++++ .../media/EncryptionIntegrationTest.java | 34 +--------- .../services/media/JobIntegrationTest.java | 15 ++++ 7 files changed, 161 insertions(+), 37 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java new file mode 100644 index 0000000000000..0c0f7288b5c32 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java @@ -0,0 +1,68 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.implementation.content; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; + +/** + * This type maps the XML returned in the odata ATOM serialization + * for Asset entities. + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +public class ErrorDetailType implements MediaServiceDTO { + + @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) + protected String code; + + @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) + protected String message; + + /** + * @return the code + */ + public String getCode() { + return code; + } + + /** + * @param code + * the id to set + */ + public ErrorDetailType setCode(String code) { + this.code = code; + return this; + } + + /** + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * @param message + * the message to set + */ + public ErrorDetailType setMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 743316ae27528..0b950dfb9ae20 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -40,7 +40,7 @@ public class TaskType implements MediaServiceDTO { protected Date endTime; @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) - protected String errorDetails; + protected List<ErrorDetailType> errorDetails; @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) protected String mediaProcessorId; @@ -112,11 +112,11 @@ public void setEndTime(Date endTime) { this.endTime = endTime; } - public String getErrorDetails() { + public List<ErrorDetailType> getErrorDetails() { return errorDetails; } - public void setErrorDetails(String errorDetails) { + public void setErrorDetails(List<ErrorDetailType> errorDetails) { this.errorDetails = errorDetails; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java new file mode 100644 index 0000000000000..5599b5ad9a967 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +public class ErrorDetail { + private final String code; + private final String message; + + public ErrorDetail(String code, String message) { + this.code = code; + this.message = message; + } + + public String getCode() { + return this.code; + } + + public String getMessage() { + return this.message; + } +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 9dbe9d7983676..fc74be02f1cb1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -15,10 +15,13 @@ package com.microsoft.windowsazure.services.media.models; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; /** @@ -70,8 +73,17 @@ public Date getEndTime() { * * @return the error details */ - public String getErrorDetails() { - return getContent().getErrorDetails(); + public List<ErrorDetail> getErrorDetails() { + List<ErrorDetail> result = new ArrayList<ErrorDetail>(); + List<ErrorDetailType> errorDetailTypes = getContent().getErrorDetails(); + if (errorDetailTypes != null) { + for (ErrorDetailType errorDetailType : getContent().getErrorDetails()) { + ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); + result.add(errorDetail); + } + return result; + } + return null; } /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 787e627b2bc97..669a64e33e360 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -18,6 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; @@ -161,4 +162,28 @@ public static String calculateChecksum(UUID uuid, byte[] aesKey) throws NoSuchAl return checksum; } + public static byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) + throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, + InvalidAlgorithmParameterException, IOException { + // preparation + SecretKeySpec key = new SecretKeySpec(aesKey, "AES"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector); + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); + + // encryption + cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); + int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); + // teArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input); + CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + int ch; + while ((ch = cipherInputStream.read()) >= 0) { + byteArrayOutputStream.write(ch); + } + + byte[] cipherText = byteArrayOutputStream.toByteArray(); + return cipherText; + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 717eab1cabc95..7952ac338922c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -18,13 +18,10 @@ import static org.junit.Assert.*; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; -import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; @@ -36,12 +33,8 @@ import java.util.UUID; import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.CipherInputStream; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; import org.junit.Test; @@ -110,7 +103,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); - byte[] aesKey = EncryptionHelper.createRandomVector(128); + byte[] aesKey = EncryptionHelper.createRandomVector(256); byte[] initializationVector = EncryptionHelper.createRandomVector(128); int durationInMinutes = 10; @@ -141,7 +134,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { linkContentKey(assetInfo, contentKeyInfo); // encrypt the file. - byte[] encryptedContent = EncryptFile(smallWMVInputStream, aesKey, initializationVector); + byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); // upload the encrypted file to the server. AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, @@ -230,29 +223,6 @@ private URI createContentKeyUri(String contentKeyId) throws UnsupportedEncodingE return URI.create(String.format("ContentKeys('%s')", escapedContentKeyId)); } - private byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) - throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, - InvalidAlgorithmParameterException, IOException { - // preparation - SecretKeySpec key = new SecretKeySpec(aesKey, "AES"); - IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector); - Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); - - // encryption - cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); - // teArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input); - CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - int ch; - while ((ch = cipherInputStream.read()) >= 0) { - byteArrayOutputStream.write(ch); - } - - byte[] cipherText = byteArrayOutputStream.toByteArray(); - return cipherText; - } - private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId, String protectionKey) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 6f9fcf7874c2a..547c92ce37a8d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -35,6 +35,7 @@ import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.ErrorDetail; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; @@ -317,6 +318,20 @@ public void canGetTasksFromJob() throws Exception { assertEquals(1, tasks.size()); } + @Test + public void canGetErrorDetailsFromTask() throws Exception { + String name = testJobPrefix + "canGetErrorDetailsFromTask"; + + JobInfo actualJob = service.create(Job.create().setName(name).addInputMediaAsset(assetInfo.getId()) + .addTaskCreator(getTaskCreator(0))); + + ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink())); + TaskInfo taskInfo = tasks.get(0); + List<ErrorDetail> errorDetails = taskInfo.getErrorDetails(); + + assertEquals(1, errorDetails.size()); + } + @Test public void canGetInputOutputAssetsFromTask() throws Exception { String name = testJobPrefix + "canGetInputOutputAssetsFromTask"; From ad4570e486b905cf1c7da68261ce12c71ad0894e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 11:31:37 -0800 Subject: [PATCH 579/664] remove unused code. --- .../services/media/models/ErrorDetail.java | 25 +++++++ .../services/media/models/TaskInfo.java | 6 +- .../services/media/EncryptionHelper.java | 71 ------------------- .../media/EncryptionIntegrationTest.java | 3 + .../services/media/JobIntegrationTest.java | 9 +++ 5 files changed, 41 insertions(+), 73 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java index 5599b5ad9a967..9e18b1ffdeffb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java @@ -15,19 +15,44 @@ package com.microsoft.windowsazure.services.media.models; +/** + * The Class ErrorDetail. + */ public class ErrorDetail { + + /** The code. */ private final String code; + + /** The message. */ private final String message; + /** + * Instantiates a new error detail. + * + * @param code + * the code + * @param message + * the message + */ public ErrorDetail(String code, String message) { this.code = code; this.message = message; } + /** + * Gets the code. + * + * @return the code + */ public String getCode() { return this.code; } + /** + * Gets the message. + * + * @return the message + */ public String getMessage() { return this.message; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index fc74be02f1cb1..e4214a8664eb5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -78,8 +78,10 @@ public List<ErrorDetail> getErrorDetails() { List<ErrorDetailType> errorDetailTypes = getContent().getErrorDetails(); if (errorDetailTypes != null) { for (ErrorDetailType errorDetailType : getContent().getErrorDetails()) { - ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); - result.add(errorDetail); + if ((errorDetailType.getCode() != null) || (errorDetailType.getMessage() != null)) { + ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); + result.add(errorDetail); + } } return result; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 669a64e33e360..63e3de57c2463 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -22,12 +22,9 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Key; -import java.security.KeyPair; -import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; -import java.security.Security; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; @@ -38,7 +35,6 @@ import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; -import javax.crypto.CipherOutputStream; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; @@ -47,30 +43,6 @@ import com.microsoft.windowsazure.services.core.storage.utils.Base64; public class EncryptionHelper { - public static void RSAOAEP() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, - InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); - - byte[] input = "abc".getBytes(); - Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding", "BC"); - SecureRandom random = new SecureRandom(); - KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC"); - - generator.initialize(386, random); - - KeyPair pair = generator.generateKeyPair(); - Key pubKey = pair.getPublic(); - - Key privKey = pair.getPrivate(); - - cipher.init(Cipher.ENCRYPT_MODE, pubKey, random); - byte[] cipherText = cipher.doFinal(input); - System.out.println("cipher: " + new String(cipherText)); - - cipher.init(Cipher.DECRYPT_MODE, privKey); - byte[] plainText = cipher.doFinal(cipherText); - System.out.println("plain : " + new String(plainText)); - } public static byte[] createRandomVector(int numberOfBits) { int numberOfBytes = numberOfBits / 8; @@ -80,53 +52,12 @@ public static byte[] createRandomVector(int numberOfBits) { return aesKey; } - public static void AESCTR() throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, - InvalidKeyException, InvalidAlgorithmParameterException, IOException { - Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); - byte[] input = "www.java2s.com".getBytes(); - byte[] keyBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] ivBytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01 }; - - SecretKeySpec key = new SecretKeySpec(keyBytes, "AES"); - IvParameterSpec ivSpec = new IvParameterSpec(ivBytes); - Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); - System.out.println("input : " + new String(input)); - - // encryption pass - cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec); - ByteArrayInputStream bIn = new ByteArrayInputStream(input); - CipherInputStream cIn = new CipherInputStream(bIn, cipher); - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); - - int ch; - while ((ch = cIn.read()) >= 0) { - bOut.write(ch); - } - - byte[] cipherText = bOut.toByteArray(); - - System.out.println("cipher: " + new String(cipherText)); - - // decryption pass - cipher.init(Cipher.DECRYPT_MODE, key, ivSpec); - bOut = new ByteArrayOutputStream(); - CipherOutputStream cOut = new CipherOutputStream(bOut, cipher); - cOut.write(cipherText); - cOut.close(); - System.out.println("plain : " + new String(bOut.toByteArray())); - } - public static byte[] EncryptSymmetricKey(String protectionKey, byte[] inputData) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, CertificateException { X509Certificate x509Certificate = createX509CertificateFromString(protectionKey); - //X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decode(publicKeyString)); - // PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(x509EncodedKeySpec); return EncryptSymmetricKey(x509Certificate.getPublicKey(), inputData); - } private static X509Certificate createX509CertificateFromString(String protectionKey) throws CertificateException { @@ -172,8 +103,6 @@ public static byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] // encryption cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); - int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); - // teArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input); CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 7952ac338922c..1e7fbe11f8e1b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -55,6 +55,7 @@ import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.LinkInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; @@ -148,6 +149,8 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); for (TaskInfo taskInfo : taskInfos) { assertEquals(TaskState.Completed, taskInfo.getState()); + ListResult<AssetInfo> outputs = service.list(Asset.list(taskInfo.getOutputAssetsLink())); + assertEquals(1, outputs.size()); } assertEquals(JobState.Finished, jobInfo.getState()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 547c92ce37a8d..81ec1f70beaf4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -325,11 +325,20 @@ public void canGetErrorDetailsFromTask() throws Exception { JobInfo actualJob = service.create(Job.create().setName(name).addInputMediaAsset(assetInfo.getId()) .addTaskCreator(getTaskCreator(0))); + JobInfo currentJobInfo = actualJob; + while (currentJobInfo.getState().getCode() < 3) { + currentJobInfo = service.get(Job.get(actualJob.getId())); + Thread.sleep(3000); + } + ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink())); TaskInfo taskInfo = tasks.get(0); List<ErrorDetail> errorDetails = taskInfo.getErrorDetails(); assertEquals(1, errorDetails.size()); + ErrorDetail errorDetail = errorDetails.get(0); + assertNotNull(errorDetail.getCode()); + assertNotNull(errorDetail.getMessage()); } @Test From f7f032ed2e2fe1b026986d65178033a5181305b8 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 14:36:43 -0800 Subject: [PATCH 580/664] unmarshall error details correctly. --- .../services/media/implementation/content/TaskType.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 0b950dfb9ae20..5a3ac8a22802c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; /** * This type maps the XML returned in the odata ATOM serialization @@ -39,7 +40,8 @@ public class TaskType implements MediaServiceDTO { @XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS) protected Date endTime; - @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElementWrapper(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS) + @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS) protected List<ErrorDetailType> errorDetails; @XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS) From 53b73c665f970efaba05d064d159149831576ee9 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 14:42:11 -0800 Subject: [PATCH 581/664] self code review. --- .../content/ErrorDetailType.java | 14 ++- .../services/media/models/ContentKeyInfo.java | 1 - .../media/EncryptionIntegrationTest.java | 114 +++++++++--------- 3 files changed, 70 insertions(+), 59 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java index 0c0f7288b5c32..e4133017dcc29 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java @@ -21,19 +21,23 @@ /** * This type maps the XML returned in the odata ATOM serialization - * for Asset entities. + * for ErrorDetail entities. * */ @XmlAccessorType(XmlAccessType.FIELD) public class ErrorDetailType implements MediaServiceDTO { + /** The code. */ @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS) protected String code; + /** The message. */ @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS) protected String message; /** + * Gets the code. + * * @return the code */ public String getCode() { @@ -41,8 +45,11 @@ public String getCode() { } /** + * Sets the code. + * * @param code * the id to set + * @return the error detail type */ public ErrorDetailType setCode(String code) { this.code = code; @@ -50,6 +57,8 @@ public ErrorDetailType setCode(String code) { } /** + * Gets the message. + * * @return the message */ public String getMessage() { @@ -57,8 +66,11 @@ public String getMessage() { } /** + * Sets the message. + * * @param message * the message to set + * @return the error detail type */ public ErrorDetailType setMessage(String message) { this.message = message; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index b03dd95a53c1d..26c3531343437 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -21,7 +21,6 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; -// TODO: Auto-generated Javadoc /** * The Class ContentKeyInfo. */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 1e7fbe11f8e1b..75a0f62f8a52c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -99,63 +99,6 @@ private String getProtectionKey(ContentKeyType contentKeyType) { return protectionKey; } - @Test - public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { - // Arrange - Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); - InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); - byte[] aesKey = EncryptionHelper.createRandomVector(256); - byte[] initializationVector = EncryptionHelper.createRandomVector(128); - int durationInMinutes = 10; - - // Act - - // creates asset - AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") - .setOptions(AssetOption.StorageEncrypted)); - - // creates writable access policy - AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", - durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); - - // creates locator for the input media asset - LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), - LocatorType.SAS)); - - // gets the public key for storage encryption. - - String protectionKeyId = getProtectionKeyId(); - String protectionKey = getProtectionKey(protectionKeyId); - - // creates the content key with encrypted - ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId, - protectionKey); - - // link the content key with the asset. - linkContentKey(assetInfo, contentKeyInfo); - - // encrypt the file. - byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); - - // upload the encrypted file to the server. - AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, - "uploadAesProtectedAssetSuccess", encryptedContent); - - // submit and execute the decoding job. - JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); - - // assert - LinkInfo taskLinkInfo = jobInfo.getTasksLink(); - List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); - for (TaskInfo taskInfo : taskInfos) { - assertEquals(TaskState.Completed, taskInfo.getState()); - ListResult<AssetInfo> outputs = service.list(Asset.list(taskInfo.getOutputAssetsLink())); - assertEquals(1, outputs.size()); - } - assertEquals(JobState.Finished, jobInfo.getState()); - - } - private String getProtectionKeyId() throws ServiceException { String protectionKeyId = (String) service.action(ProtectionKey .getProtectionKeyId(ContentKeyType.StorageEncryption)); @@ -241,4 +184,61 @@ private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKey return contentKeyInfo; } + @Test + public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { + // Arrange + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); + byte[] aesKey = EncryptionHelper.createRandomVector(256); + byte[] initializationVector = EncryptionHelper.createRandomVector(128); + int durationInMinutes = 10; + + // Act + + // creates asset + AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") + .setOptions(AssetOption.StorageEncrypted)); + + // creates writable access policy + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", + durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + + // creates locator for the input media asset + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), + LocatorType.SAS)); + + // gets the public key for storage encryption. + + String protectionKeyId = getProtectionKeyId(); + String protectionKey = getProtectionKey(protectionKeyId); + + // creates the content key with encrypted + ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId, + protectionKey); + + // link the content key with the asset. + linkContentKey(assetInfo, contentKeyInfo); + + // encrypt the file. + byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); + + // upload the encrypted file to the server. + AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, + "uploadAesProtectedAssetSuccess", encryptedContent); + + // submit and execute the decoding job. + JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); + + // assert + LinkInfo taskLinkInfo = jobInfo.getTasksLink(); + List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); + for (TaskInfo taskInfo : taskInfos) { + assertEquals(TaskState.Completed, taskInfo.getState()); + ListResult<AssetInfo> outputs = service.list(Asset.list(taskInfo.getOutputAssetsLink())); + assertEquals(1, outputs.size()); + } + assertEquals(JobState.Finished, jobInfo.getState()); + + } + } From 50fe300688bdf8c6748125a8fae3943793388c88 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 15:16:45 -0800 Subject: [PATCH 582/664] remove task delete method --- .../windowsazure/services/media/models/Task.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 97e828f435d94..2c205a8d302c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -18,10 +18,8 @@ import javax.ws.rs.core.MultivaluedMap; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.sun.jersey.api.client.GenericType; /** @@ -236,14 +234,4 @@ public CreateBatchOperation setInitializationVector(String initializationVector) } } - /** - * Create an operation to delete the given task. - * - * @param taskId - * id of task to delete - * @return the delete operation - */ - public static EntityDeleteOperation delete(String taskId) { - return new DefaultDeleteOperation(ENTITY_SET, taskId); - } } From 9d189ef5b72c09552f7edcccc7ee57aad9969177 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 16:55:36 -0800 Subject: [PATCH 583/664] address code review feedback. --- .../services/media/models/ContentKey.java | 19 +++++++++- .../services/media/models/ContentKeyType.java | 1 - .../services/media/models/TaskInfo.java | 8 ++-- .../services/media/EncryptionHelper.java | 11 ++---- .../media/EncryptionIntegrationTest.java | 37 +------------------ 5 files changed, 26 insertions(+), 50 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index cd3ee1792b7bd..d9cf17799adb9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -27,7 +27,6 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; -// TODO: Auto-generated Javadoc /** * Class for creating operations to manipulate content key entities. * @@ -82,6 +81,9 @@ public static class Creator extends EntityOperationSingleResultBase<ContentKeyIn /** The protection key id. */ private String protectionKeyId; + /** The protection key type. */ + private ProtectionKeyType protectionKeyType; + /** * Instantiates a new creator. * @@ -110,6 +112,9 @@ public Object getRequestContents() { if (contentKeyType != null) { contentKeyRestType.setContentKeyType(contentKeyType.getCode()); } + if (protectionKeyType != null) { + contentKeyRestType.setProtectionKeyType(protectionKeyType.getCode()); + } contentKeyRestType.setEncryptedContentKey(encryptedContentKey); contentKeyRestType.setName(name); contentKeyRestType.setChecksum(checksum); @@ -152,6 +157,18 @@ public Creator setProtectionKeyId(String protectionKeyId) { this.protectionKeyId = protectionKeyId; return this; } + + /** + * Sets the protection key type. + * + * @param protectionKeyType + * the protection key type + * @return the creator + */ + public Creator setProtectionKeyType(ProtectionKeyType protectionKeyType) { + this.protectionKeyType = protectionKeyType; + return this; + } } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java index d1798b3ff7183..14df526e3224f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -17,7 +17,6 @@ import java.security.InvalidParameterException; -// TODO: Auto-generated Javadoc /** * * Specifies the type of a content key. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index e4214a8664eb5..3de34cdfb716b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -77,11 +77,9 @@ public List<ErrorDetail> getErrorDetails() { List<ErrorDetail> result = new ArrayList<ErrorDetail>(); List<ErrorDetailType> errorDetailTypes = getContent().getErrorDetails(); if (errorDetailTypes != null) { - for (ErrorDetailType errorDetailType : getContent().getErrorDetails()) { - if ((errorDetailType.getCode() != null) || (errorDetailType.getMessage() != null)) { - ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); - result.add(errorDetail); - } + for (ErrorDetailType errorDetailType : errorDetailTypes) { + ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); + result.add(errorDetail); } return result; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 63e3de57c2463..e7c2617372bc8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -28,7 +28,6 @@ import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; -import java.security.spec.InvalidKeySpecException; import java.util.Random; import java.util.UUID; @@ -46,15 +45,13 @@ public class EncryptionHelper { public static byte[] createRandomVector(int numberOfBits) { int numberOfBytes = numberOfBits / 8; - byte[] aesKey = new byte[numberOfBytes]; + byte[] randomVector = new byte[numberOfBytes]; Random random = new Random(); - random.nextBytes(aesKey); - return aesKey; + random.nextBytes(randomVector); + return randomVector; } - public static byte[] EncryptSymmetricKey(String protectionKey, byte[] inputData) throws InvalidKeySpecException, - NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, NoSuchPaddingException, - IllegalBlockSizeException, BadPaddingException, CertificateException { + public static byte[] EncryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { X509Certificate x509Certificate = createX509CertificateFromString(protectionKey); return EncryptSymmetricKey(x509Certificate.getPublicKey(), inputData); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 75a0f62f8a52c..b8f356d44b742 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -22,20 +22,11 @@ import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.Security; -import java.security.cert.CertificateException; -import java.security.spec.InvalidKeySpecException; import java.util.EnumSet; import java.util.List; import java.util.UUID; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -68,12 +59,6 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { - private final String validButNonexistContentKeyId = "nb:kid:UUID:80dfe751-e5a1-4b29-a992-4a75276473af"; - private final ContentKeyType testContentKeyType = ContentKeyType.CommonEncryption; - private final String testEncryptedContentKey = "ThisIsEncryptedContentKey"; - private final String expressionEncoder = "Windows Azure Media Encoder"; - private final String wameV1Preset = "H.264 256k DSL CBR"; - private final String wameV2Preset = "H264 Broadband SD 4x3"; private final String strorageDecryptionProcessor = "Storage Decryption"; private String createContentKeyId(UUID uuid) { @@ -81,24 +66,6 @@ private String createContentKeyId(UUID uuid) { return randomContentKey; } - private String getProtectionKey(ContentKeyType contentKeyType) { - String protectionKeyId = null; - try { - protectionKeyId = (String) service.action(ProtectionKey.getProtectionKeyId(contentKeyType)); - } - catch (ServiceException e) { - throw new RuntimeException(e); - } - String protectionKey; - try { - protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); - } - catch (ServiceException e) { - throw new RuntimeException(e); - } - return protectionKey; - } - private String getProtectionKeyId() throws ServiceException { String protectionKeyId = (String) service.action(ProtectionKey .getProtectionKeyId(ContentKeyType.StorageEncryption)); @@ -170,9 +137,7 @@ private URI createContentKeyUri(String contentKeyId) throws UnsupportedEncodingE } private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId, - String protectionKey) throws InvalidKeyException, InvalidKeySpecException, NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, - ServiceException, CertificateException { + String protectionKey) throws Exception { UUID contentKeyIdUuid = UUID.randomUUID(); String contentKeyId = createContentKeyId(contentKeyIdUuid); byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKey, aesKey); From f6a3bf530558995129b1f3cf1c904afa1928f9d0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 17 Dec 2012 17:09:30 -0800 Subject: [PATCH 584/664] remove documentation for unused parameter. --- .../services/media/WritableBlobContainerContract.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java index 808e5c0460ece..412d7dc2fc0f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java @@ -35,8 +35,6 @@ public interface WritableBlobContainerContract extends FilterableService<Writabl /** * Creates a block blob from a content stream. * - * @param container - * A {@link String} containing the name of the container to create the blob in. * @param blob * A {@link String} containing the name of the blob to create. A blob name can contain any combination of * characters, but reserved URL characters must be properly escaped. A blob name must be at least one From 1bdbc7c8b59924e3e07ce3329d856ff4471e4ca4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 18 Dec 2012 15:24:46 -0800 Subject: [PATCH 585/664] initial check in for remaining model unit tests. --- .../implementation/content/TaskType.java | 60 ++++-- .../services/media/models/JobEntityTest.java | 117 ++++++++++ .../services/media/models/JobInfoTest.java | 134 ++++++++++++ .../media/models/ProtectionKeyEntityTest.java | 199 ++++++++++++++++++ .../services/media/models/TaskEntityTest.java | 197 +++++++++++++++++ .../services/media/models/TaskInfoTest.java | 186 ++++++++++++++++ 6 files changed, 873 insertions(+), 20 deletions(-) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 743316ae27528..4f301e4c7614a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -92,159 +92,179 @@ public String getId() { return id; } - public void setId(String id) { + public TaskType setId(String id) { this.id = id; + return this; } public String getConfiguration() { return configuration; } - public void setConfiguration(String configuration) { + public TaskType setConfiguration(String configuration) { this.configuration = configuration; + return this; } public Date getEndTime() { return endTime; } - public void setEndTime(Date endTime) { + public TaskType setEndTime(Date endTime) { this.endTime = endTime; + return this; } public String getErrorDetails() { return errorDetails; } - public void setErrorDetails(String errorDetails) { + public TaskType setErrorDetails(String errorDetails) { this.errorDetails = errorDetails; + return this; } public String getMediaProcessorId() { return mediaProcessorId; } - public void setMediaProcessorId(String mediaProcessorId) { + public TaskType setMediaProcessorId(String mediaProcessorId) { this.mediaProcessorId = mediaProcessorId; + return this; } public String getName() { return name; } - public void setName(String name) { + public TaskType setName(String name) { this.name = name; + return this; } public String getPerfMessage() { return perfMessage; } - public void setPerfMessage(String perfMessage) { + public TaskType setPerfMessage(String perfMessage) { this.perfMessage = perfMessage; + return this; } public Integer getPriority() { return priority; } - public void setPriority(Integer priority) { + public TaskType setPriority(Integer priority) { this.priority = priority; + return this; } public Double getProgress() { return progress; } - public void setProgress(Double progress) { + public TaskType setProgress(Double progress) { this.progress = progress; + return this; } public Double getRunningDuration() { return runningDuration; } - public void setRunningDuration(Double runningDuration) { + public TaskType setRunningDuration(Double runningDuration) { this.runningDuration = runningDuration; + return this; } public Date getStartTime() { return startTime; } - public void setStartTime(Date startTime) { + public TaskType setStartTime(Date startTime) { this.startTime = startTime; + return this; } public Integer getState() { return state; } - public void setState(Integer state) { + public TaskType setState(Integer state) { this.state = state; + return this; } public String getTaskBody() { return taskBody; } - public void setTaskBody(String taskBody) { + public TaskType setTaskBody(String taskBody) { this.taskBody = taskBody; + return this; } public Integer getOptions() { return options; } - public void setOptions(Integer options) { + public TaskType setOptions(Integer options) { this.options = options; + return this; } public String getEncryptionKeyId() { return encryptionKeyId; } - public void setEncryptionKeyId(String encryptionKeyId) { + public TaskType setEncryptionKeyId(String encryptionKeyId) { this.encryptionKeyId = encryptionKeyId; + return this; } public String getEncryptionScheme() { return encryptionScheme; } - public void setEncryptionScheme(String encryptionScheme) { + public TaskType setEncryptionScheme(String encryptionScheme) { this.encryptionScheme = encryptionScheme; + return this; } public String getEncryptionVersion() { return encryptionVersion; } - public void setEncryptionVersion(String encryptionVersion) { + public TaskType setEncryptionVersion(String encryptionVersion) { this.encryptionVersion = encryptionVersion; + return this; } public String getInitializationVector() { return initializationVector; } - public void setInitializationVector(String initializationVector) { + public TaskType setInitializationVector(String initializationVector) { this.initializationVector = initializationVector; + return this; } public List<String> getOutputMediaAssets() { return outputMediaAssets; } - public void setOutputMediaAssets(List<String> outputMediaAssets) { + public TaskType setOutputMediaAssets(List<String> outputMediaAssets) { this.outputMediaAssets = outputMediaAssets; + return this; } public List<String> getInputMediaAssets() { return inputMediaAssets; } - public void setInputMediaAssets(List<String> inputMediaAssets) { + public TaskType setInputMediaAssets(List<String> inputMediaAssets) { this.inputMediaAssets = inputMediaAssets; + return this; } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java new file mode 100644 index 0000000000000..ba1a76356a88b --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -0,0 +1,117 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; + +import javax.mail.BodyPart; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMultipart; +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBException; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.implementation.ODataAtomUnmarshaller; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the methods and factories of the Job entity. + */ +public class JobEntityTest { + + private JobInfo getJobInfo(MimeMultipart payload) throws MessagingException, IOException, JAXBException, + ServiceException { + for (int i = 0; i < payload.getCount(); i++) { + BodyPart bodyPart = payload.getBodyPart(i); + JobInfo jobInfo = parseBodyPart(bodyPart); + if (jobInfo != null) { + return jobInfo; + } + } + + return null; + } + + private JobInfo parseBodyPart(BodyPart bodyPart) throws IOException, MessagingException, JAXBException, + ServiceException { + JobInfo jobInfo = null; + ODataAtomUnmarshaller oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); + InputStream inputStream = bodyPart.getInputStream(); + jobInfo = oDataAtomUnmarshaller.unmarshalEntry(inputStream, JobInfo.class); + return jobInfo; + } + + public JobEntityTest() throws Exception { + } + + @Test + public void JobCreateReturnsDefaultCreatePayload() throws ServiceException { + MimeMultipart payload = (MimeMultipart) Job.create().getRequestContents(); + assertNotNull(payload); + } + + @Test + public void JobCreateCanSetJobName() throws ServiceException, MessagingException, IOException, JAXBException { + String expectedName = "JobCreateCanSetJobName"; + + Job.Creator creator = Job.create().setName(expectedName); + + MimeMultipart payload = (MimeMultipart) creator.getRequestContents(); + + JobInfo jobInfo = getJobInfo(payload); + + assertEquals(expectedName, jobInfo.getName()); + } + + @Test + public void JobListReturnsExpectedUri() { + EntityListOperation<JobInfo> lister = Job.list(); + + assertEquals("Jobs", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void JobListCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<JobInfo> lister = Job.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void JobListCanTakeQueryParametersChained() { + EntityListOperation<JobInfo> lister = Job.list().setTop(10).setSkip(2).set("filter", "something"); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals("something", lister.getQueryParameters().getFirst("filter")); + assertEquals(3, lister.getQueryParameters().size()); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java new file mode 100644 index 0000000000000..9f90ab4aa2e34 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java @@ -0,0 +1,134 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.JobType; + +public class JobInfoTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + JobInfo JobInfo = new JobInfo(null, new JobType().setId(expectedId)); + + // Act + String actualId = JobInfo.getId(); + + // Assert + assertEquals(expectedId, actualId); + + } + + @Test + public void testGetSetName() { + // Arrange + String expectedName = "testGetSetName"; + JobInfo JobInfo = new JobInfo(null, new JobType().setName(expectedName)); + + // Act + String actualName = JobInfo.getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetCreated() throws Exception { + // Arrange + Date expectedCreated = new Date(); + + JobInfo JobInfo = new JobInfo(null, new JobType().setCreated(expectedCreated)); + + // Act + Date actualCreated = JobInfo.getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + + } + + @Test + public void testGetSetLastModified() throws Exception { + // Arrange + Date expectedLastModified = new Date(); + JobInfo JobInfo = new JobInfo(null, new JobType().setLastModified(expectedLastModified)); + + // Act + Date actualLastModified = JobInfo.getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetPriority() { + // Arrange + int expectedPriority = 3; + JobInfo JobInfo = new JobInfo(null, new JobType().setPriority(expectedPriority)); + + // Act + int actualPriority = JobInfo.getPriority(); + + // Assert + assertEquals(expectedPriority, actualPriority); + } + + @Test + public void testGetSetRunningDuration() { + // Arrange + Double expectedRunningDuration = 1234.5; + JobInfo JobInfo = new JobInfo(null, new JobType().setRunningDuration(expectedRunningDuration)); + + // Act + Double actualRunningDuration = JobInfo.getRunningDuration(); + + // Assert + assertEquals(expectedRunningDuration, actualRunningDuration); + } + + @Test + public void testGetSetStartTime() { + // Arrange + Date expectedStartTime = new Date(); + JobInfo JobInfo = new JobInfo(null, new JobType().setLastModified(expectedStartTime)); + + // Act + Date actualStartTime = JobInfo.getLastModified(); + + // Assert + assertEquals(expectedStartTime, actualStartTime); + } + + @Test + public void testGetSetState() { + // Arrange + JobState expectedJobState = JobState.Finished; + JobInfo JobInfo = new JobInfo(null, new JobType().setState(expectedJobState.getCode())); + + // Act + JobState actualJobState = JobInfo.getState(); + + // Assert + assertEquals(expectedJobState, actualJobState); + } + +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java new file mode 100644 index 0000000000000..1eaf3c0e896e7 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java @@ -0,0 +1,199 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.net.URLEncoder; + +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the methods and factories of the ProtectionKey entity. + */ +public class ProtectionKeyEntityTest { + static final String sampleProtectionKeyId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; + private final String expectedUri = String.format("ProtectionKeys('%s')", + URLEncoder.encode(sampleProtectionKeyId, "UTF-8")); + + public ProtectionKeyEntityTest() throws Exception { + } + + @Test + public void ProtectionKeyCreateReturnsDefaultCreatePayload() { + ProtectionKeyType payload = (ProtectionKeyType) ProtectionKey.create().getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertNull(payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertNull(payload.getName()); + assertNull(payload.getOptions()); + } + + @Test + public void ProtectionKeyCreateCanSetProtectionKeyName() { + String name = "ProtectionKeyCreateCanSetProtectionKeyName"; + + ProtectionKey.Creator creator = ProtectionKey.create().setName("ProtectionKeyCreateCanSetProtectionKeyName"); + + ProtectionKeyType payload = (ProtectionKeyType) creator.getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertNull(payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertEquals(name, payload.getName()); + assertNull(payload.getOptions()); + } + + @Test + public void ProtectionKeyGetReturnsExpectedUri() throws Exception { + String expectedUri = String.format("ProtectionKeys('%s')", URLEncoder.encode(sampleProtectionKeyId, "UTF-8")); + + EntityGetOperation<ProtectionKeyInfo> getter = ProtectionKey.get(sampleProtectionKeyId); + + assertEquals(expectedUri, getter.getUri()); + } + + @Test + public void ProtectionKeyListReturnsExpectedUri() { + EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(); + + assertEquals("ProtectionKeys", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void ProtectionKeyListCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void ProtectionKeyListCanTakeQueryParametersChained() { + EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list().setTop(10).setSkip(2) + .set("filter", "something"); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals("something", lister.getQueryParameters().getFirst("filter")); + assertEquals(3, lister.getQueryParameters().size()); + } + + @Test + public void ProtectionKeyUpdateReturnsExpectedUri() throws Exception { + EntityUpdateOperation updater = ProtectionKey.update(sampleProtectionKeyId); + assertEquals(expectedUri, updater.getUri()); + } + + @Test + public void ProtectionKeyUpdateCanSetNameAndAltId() throws Exception { + + String expectedName = "newProtectionKeyName"; + String expectedAltId = "newAltId"; + + EntityUpdateOperation updater = ProtectionKey.update(sampleProtectionKeyId).setName(expectedName) + .setAlternateId(expectedAltId); + + ProtectionKeyType payload = (ProtectionKeyType) updater.getRequestContents(); + + assertEquals(expectedName, payload.getName()); + assertEquals(expectedAltId, payload.getAlternateId()); + } + + @Test + public void ProtectionKeyDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = ProtectionKey.delete(sampleProtectionKeyId); + + assertEquals(expectedUri, deleter.getUri()); + } + + private static final String expectedOutputProtectionKey = "Job(someJobId)/OutputProtectionKeys"; + private static final String expectedInputProtectionKey = "Job(someJobId)/InputProtectionKeys"; + + @Test + public void listForLinkReturnsExpectedUri() throws Exception { + JobInfo fakeJob = createJob(); + + EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(fakeJob.getInputProtectionKeysLink()); + + assertEquals(lister.getUri(), expectedInputProtectionKey); + } + + private JobInfo createJob() { + EntryType fakeJobEntry = new EntryType(); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/OutputMediaProtectionKeys", + expectedOutputProtectionKey, "application/atom+xml;type=feed", "OutputProtectionKeys"); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/InputMediaProtectionKeys", + expectedInputProtectionKey, "application/atom+xml;type=feed", "InputProtectionKeys"); + + JobType payload = new JobType().setId("SomeId").setName("FakeJob"); + addEntryContent(fakeJobEntry, payload); + + return new JobInfo(fakeJobEntry, payload); + } + + private void addEntryLink(EntryType entry, String rel, String href, String type, String title) { + LinkType link = new LinkType(); + link.setRel(rel); + link.setHref(href); + link.setType(type); + link.setTitle(title); + + JAXBElement<LinkType> linkElement = new JAXBElement<LinkType>(new QName("link", Constants.ATOM_NS), + LinkType.class, link); + entry.getEntryChildren().add(linkElement); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private ContentType addEntryContent(EntryType entry, Object content) { + ContentType contentWrapper = new ContentType(); + contentWrapper.getContent().add( + new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); + + entry.getEntryChildren().add( + new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentWrapper)); + return contentWrapper; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java new file mode 100644 index 0000000000000..50f2e279ab283 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -0,0 +1,197 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.net.URLEncoder; + +import javax.ws.rs.core.MultivaluedMap; +import javax.xml.bind.JAXBElement; +import javax.xml.namespace.QName; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; +import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; +import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; +import com.microsoft.windowsazure.services.media.implementation.content.Constants; +import com.microsoft.windowsazure.services.media.implementation.content.JobType; +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +/** + * Tests for the methods and factories of the Task entity. + */ +public class TaskEntityTest { + static final String sampleTaskId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; + private final String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8")); + + public TaskEntityTest() throws Exception { + } + + @Test + public void TaskCreateReturnsDefaultCreatePayload() { + TaskType payload = (TaskType) Task.create().getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertNull(payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertNull(payload.getName()); + assertNull(payload.getOptions()); + } + + @Test + public void TaskCreateCanSetTaskName() { + String name = "TaskCreateCanSetTaskName"; + + Task.Creator creator = Task.create().setName("TaskCreateCanSetTaskName"); + + TaskType payload = (TaskType) creator.getRequestContents(); + + assertNotNull(payload); + assertNull(payload.getId()); + assertNull(payload.getState()); + assertNull(payload.getCreated()); + assertNull(payload.getLastModified()); + assertNull(payload.getAlternateId()); + assertEquals(name, payload.getName()); + assertNull(payload.getOptions()); + } + + @Test + public void TaskGetReturnsExpectedUri() throws Exception { + String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8")); + + EntityGetOperation<TaskInfo> getter = Task.get(sampleTaskId); + + assertEquals(expectedUri, getter.getUri()); + } + + @Test + public void TaskListReturnsExpectedUri() { + EntityListOperation<TaskInfo> lister = Task.list(); + + assertEquals("Tasks", lister.getUri()); + assertNotNull(lister.getQueryParameters()); + assertEquals(0, lister.getQueryParameters().size()); + } + + @Test + public void TaskListCanTakeQueryParameters() { + MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); + queryParams.add("$top", "10"); + queryParams.add("$skip", "2"); + + EntityListOperation<TaskInfo> lister = Task.list(queryParams); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals(2, lister.getQueryParameters().size()); + } + + @Test + public void TaskListCanTakeQueryParametersChained() { + EntityListOperation<TaskInfo> lister = Task.list().setTop(10).setSkip(2).set("filter", "something"); + + assertEquals("10", lister.getQueryParameters().getFirst("$top")); + assertEquals("2", lister.getQueryParameters().getFirst("$skip")); + assertEquals("something", lister.getQueryParameters().getFirst("filter")); + assertEquals(3, lister.getQueryParameters().size()); + } + + @Test + public void TaskUpdateReturnsExpectedUri() throws Exception { + EntityUpdateOperation updater = Task.update(sampleTaskId); + assertEquals(expectedUri, updater.getUri()); + } + + @Test + public void TaskUpdateCanSetNameAndAltId() throws Exception { + + String expectedName = "newTaskName"; + String expectedAltId = "newAltId"; + + EntityUpdateOperation updater = Task.update(sampleTaskId).setName(expectedName).setAlternateId(expectedAltId); + + TaskType payload = (TaskType) updater.getRequestContents(); + + assertEquals(expectedName, payload.getName()); + assertEquals(expectedAltId, payload.getAlternateId()); + } + + @Test + public void TaskDeleteReturnsExpectedUri() throws Exception { + EntityDeleteOperation deleter = Task.delete(sampleTaskId); + + assertEquals(expectedUri, deleter.getUri()); + } + + private static final String expectedOutputTask = "Job(someJobId)/OutputTasks"; + private static final String expectedInputTask = "Job(someJobId)/InputTasks"; + + @Test + public void listForLinkReturnsExpectedUri() throws Exception { + JobInfo fakeJob = createJob(); + + EntityListOperation<TaskInfo> lister = Task.list(fakeJob.getInputTasksLink()); + + assertEquals(lister.getUri(), expectedInputTask); + } + + private JobInfo createJob() { + EntryType fakeJobEntry = new EntryType(); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/OutputMediaTasks", expectedOutputTask, + "application/atom+xml;type=feed", "OutputTasks"); + addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/InputMediaTasks", expectedInputTask, + "application/atom+xml;type=feed", "InputTasks"); + + JobType payload = new JobType().setId("SomeId").setName("FakeJob"); + addEntryContent(fakeJobEntry, payload); + + return new JobInfo(fakeJobEntry, payload); + } + + private void addEntryLink(EntryType entry, String rel, String href, String type, String title) { + LinkType link = new LinkType(); + link.setRel(rel); + link.setHref(href); + link.setType(type); + link.setTitle(title); + + JAXBElement<LinkType> linkElement = new JAXBElement<LinkType>(new QName("link", Constants.ATOM_NS), + LinkType.class, link); + entry.getEntryChildren().add(linkElement); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + private ContentType addEntryContent(EntryType entry, Object content) { + ContentType contentWrapper = new ContentType(); + contentWrapper.getContent().add( + new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); + + entry.getEntryChildren().add( + new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentWrapper)); + return contentWrapper; + } +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java new file mode 100644 index 0000000000000..9cbcc10fb0c44 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -0,0 +1,186 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.models; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.Test; + +import com.microsoft.windowsazure.services.media.implementation.content.TaskType; + +public class TaskInfoTest { + + @Test + public void testGetSetId() { + // Arrange + String expectedId = "expectedId"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setId(expectedId)); + + // Act + String actualId = TaskInfo.getId(); + + // Assert + assertEquals(expectedId, actualId); + + } + + @Test + public void testGetSetConfiguration() { + // Arrange + String expectedConfiguration = "expectedConfiguration"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setState(expectedState.getCode())); + + // Act + TaskState actualState = TaskInfo.getState(); + + // Assert + assertEquals(expectedState, actualState); + } + + @Test + public void testGetSetEndTime() throws Exception { + // Arrange + Date expectedCreated = new Date(); + + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setCreated(expectedCreated)); + + // Act + Date actualCreated = TaskInfo.getCreated(); + + // Assert + assertEquals(expectedCreated, actualCreated); + + } + + @Test + public void testGetSetErrorDetails() throws Exception { + // Arrange + Date expectedLastModified = new Date(); + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setLastModified(expectedLastModified)); + + // Act + Date actualLastModified = TaskInfo.getLastModified(); + + // Assert + assertEquals(expectedLastModified, actualLastModified); + } + + @Test + public void testGetSetHistoricalEvents() { + // Arrange + String expectedAlternateId = "testAlternateId"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setAlternateId(expectedAlternateId)); + + // Act + String actualAlternateId = TaskInfo.getAlternateId(); + + // Assert + assertEquals(expectedAlternateId, actualAlternateId); + } + + @Test + public void testGetSetMediaProcessorId() { + // Arrange + String expectedName = "testName"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setName(expectedName)); + + // Act + String actualName = TaskInfo.getName(); + + // Assert + assertEquals(expectedName, actualName); + } + + @Test + public void testGetSetName() { + // Arrange + + TaskOption expectedOptions = TaskOption.None; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setOptions(expectedOptions.getCode())); + + // Act + TaskOption actualOptions = TaskInfo.getOptions(); + + // Assert + assertEquals(expectedOptions, actualOptions); + } + + public void testGetSetPerfMessage() { + // Arrange + + String expectedPerfMessage = "testGetSetPerfMessage"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setPerfMessage(expectedPerfMessage)); + + // Act + String actualPerfMessage = TaskInfo.getPerfMessage(); + + // Assert + assertEquals(expectedPerfMessage, actualPerfMessage); + } + + public void testGetSetPriority() { + + } + + public void testGetSetProgress() { + + } + + public void testGetSetRunningDuration() { + + } + + public void testGetSetStartTime() { + + } + + public void testGetSetState() { + + } + + public void testGetSetTaskBody() { + + } + + public void testGetSetOptions() { + + } + + public void testGetSetEncryptionKeyId() { + + } + + public void testGetSetEncryptionScheme() { + + } + + public void testGetSetEncryptionVersion() { + + } + + public void testGetSetInitializationVector() { + + } + + public void testGetSetOutputMediaAssets() { + + } + + public void testGetSetInputMediaAssets() { + + } +} From 240e522753542812f5e6f3818a3ca52c127f97e0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 18 Dec 2012 18:03:21 -0800 Subject: [PATCH 586/664] key in more unit tests --- .../media/models/ProtectionKeyEntityTest.java | 172 ++---------------- .../services/media/models/TaskInfoTest.java | 115 ++++++++++-- 2 files changed, 109 insertions(+), 178 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java index 1eaf3c0e896e7..0fcc79a85f546 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java @@ -17,183 +17,33 @@ import static org.junit.Assert.*; -import java.net.URLEncoder; - -import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; +import java.util.List; import org.junit.Test; -import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; -import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; -import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; -import com.microsoft.windowsazure.services.media.implementation.content.Constants; -import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; -import com.sun.jersey.core.util.MultivaluedMapImpl; - /** * Tests for the methods and factories of the ProtectionKey entity. */ public class ProtectionKeyEntityTest { - static final String sampleProtectionKeyId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; - private final String expectedUri = String.format("ProtectionKeys('%s')", - URLEncoder.encode(sampleProtectionKeyId, "UTF-8")); public ProtectionKeyEntityTest() throws Exception { } @Test - public void ProtectionKeyCreateReturnsDefaultCreatePayload() { - ProtectionKeyType payload = (ProtectionKeyType) ProtectionKey.create().getRequestContents(); - - assertNotNull(payload); - assertNull(payload.getId()); - assertNull(payload.getState()); - assertNull(payload.getCreated()); - assertNull(payload.getLastModified()); - assertNull(payload.getAlternateId()); - assertNull(payload.getName()); - assertNull(payload.getOptions()); - } - - @Test - public void ProtectionKeyCreateCanSetProtectionKeyName() { - String name = "ProtectionKeyCreateCanSetProtectionKeyName"; - - ProtectionKey.Creator creator = ProtectionKey.create().setName("ProtectionKeyCreateCanSetProtectionKeyName"); - - ProtectionKeyType payload = (ProtectionKeyType) creator.getRequestContents(); - - assertNotNull(payload); - assertNull(payload.getId()); - assertNull(payload.getState()); - assertNull(payload.getCreated()); - assertNull(payload.getLastModified()); - assertNull(payload.getAlternateId()); - assertEquals(name, payload.getName()); - assertNull(payload.getOptions()); - } - - @Test - public void ProtectionKeyGetReturnsExpectedUri() throws Exception { - String expectedUri = String.format("ProtectionKeys('%s')", URLEncoder.encode(sampleProtectionKeyId, "UTF-8")); - - EntityGetOperation<ProtectionKeyInfo> getter = ProtectionKey.get(sampleProtectionKeyId); - - assertEquals(expectedUri, getter.getUri()); - } - - @Test - public void ProtectionKeyListReturnsExpectedUri() { - EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(); - - assertEquals("ProtectionKeys", lister.getUri()); - assertNotNull(lister.getQueryParameters()); - assertEquals(0, lister.getQueryParameters().size()); - } - - @Test - public void ProtectionKeyListCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); - - EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(queryParams); - - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals(2, lister.getQueryParameters().size()); - } - - @Test - public void ProtectionKeyListCanTakeQueryParametersChained() { - EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list().setTop(10).setSkip(2) - .set("filter", "something"); + public void ProtectionKeyIdReturnsPayloadWithTheRightProtectionKeyType() { + List<String> contentKeyTypeArray = ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption) + .getQueryParameters().get("contentKeyType"); + String actualContentKeyType = contentKeyTypeArray.get(0); - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals("something", lister.getQueryParameters().getFirst("filter")); - assertEquals(3, lister.getQueryParameters().size()); + assertEquals(ContentKeyType.StorageEncryption.getCode(), Integer.parseInt(actualContentKeyType)); } @Test - public void ProtectionKeyUpdateReturnsExpectedUri() throws Exception { - EntityUpdateOperation updater = ProtectionKey.update(sampleProtectionKeyId); - assertEquals(expectedUri, updater.getUri()); - } - - @Test - public void ProtectionKeyUpdateCanSetNameAndAltId() throws Exception { - - String expectedName = "newProtectionKeyName"; - String expectedAltId = "newAltId"; - - EntityUpdateOperation updater = ProtectionKey.update(sampleProtectionKeyId).setName(expectedName) - .setAlternateId(expectedAltId); - - ProtectionKeyType payload = (ProtectionKeyType) updater.getRequestContents(); - - assertEquals(expectedName, payload.getName()); - assertEquals(expectedAltId, payload.getAlternateId()); - } - - @Test - public void ProtectionKeyDeleteReturnsExpectedUri() throws Exception { - EntityDeleteOperation deleter = ProtectionKey.delete(sampleProtectionKeyId); - - assertEquals(expectedUri, deleter.getUri()); - } - - private static final String expectedOutputProtectionKey = "Job(someJobId)/OutputProtectionKeys"; - private static final String expectedInputProtectionKey = "Job(someJobId)/InputProtectionKeys"; - - @Test - public void listForLinkReturnsExpectedUri() throws Exception { - JobInfo fakeJob = createJob(); - - EntityListOperation<ProtectionKeyInfo> lister = ProtectionKey.list(fakeJob.getInputProtectionKeysLink()); - - assertEquals(lister.getUri(), expectedInputProtectionKey); - } - - private JobInfo createJob() { - EntryType fakeJobEntry = new EntryType(); - addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/OutputMediaProtectionKeys", - expectedOutputProtectionKey, "application/atom+xml;type=feed", "OutputProtectionKeys"); - addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/InputMediaProtectionKeys", - expectedInputProtectionKey, "application/atom+xml;type=feed", "InputProtectionKeys"); - - JobType payload = new JobType().setId("SomeId").setName("FakeJob"); - addEntryContent(fakeJobEntry, payload); - - return new JobInfo(fakeJobEntry, payload); - } - - private void addEntryLink(EntryType entry, String rel, String href, String type, String title) { - LinkType link = new LinkType(); - link.setRel(rel); - link.setHref(href); - link.setType(type); - link.setTitle(title); - - JAXBElement<LinkType> linkElement = new JAXBElement<LinkType>(new QName("link", Constants.ATOM_NS), - LinkType.class, link); - entry.getEntryChildren().add(linkElement); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private ContentType addEntryContent(EntryType entry, Object content) { - ContentType contentWrapper = new ContentType(); - contentWrapper.getContent().add( - new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); + public void ProtectionKeyReturnsPayloadWithTheRightProtectionKeyId() { + String expectedProtectionKey = "expectedProtectionKey"; + String actualProtectionKey = ProtectionKey.getProtectionKey(expectedProtectionKey).getQueryParameters() + .getFirst("ProtectionKeyId"); - entry.getEntryChildren().add( - new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentWrapper)); - return contentWrapper; + assertEquals(expectedProtectionKey, actualProtectionKey); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java index 9cbcc10fb0c44..3da83fbd0da39 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.*; +import java.util.ArrayList; import java.util.Date; import org.junit.Test; @@ -28,10 +29,10 @@ public class TaskInfoTest { public void testGetSetId() { // Arrange String expectedId = "expectedId"; - TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setId(expectedId)); + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setId(expectedId)); // Act - String actualId = TaskInfo.getId(); + String actualId = taskInfo.getId(); // Assert assertEquals(expectedId, actualId); @@ -42,34 +43,34 @@ public void testGetSetId() { public void testGetSetConfiguration() { // Arrange String expectedConfiguration = "expectedConfiguration"; - TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setState(expectedState.getCode())); + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setConfiguration(expectedConfiguration)); // Act - TaskState actualState = TaskInfo.getState(); + String actualConfiguration = taskInfo.getConfiguration(); // Assert - assertEquals(expectedState, actualState); + assertEquals(expectedConfiguration, actualConfiguration); } @Test public void testGetSetEndTime() throws Exception { // Arrange - Date expectedCreated = new Date(); + Date expectedEndTime = new Date(); - TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setCreated(expectedCreated)); + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setEndTime(expectedEndTime)); // Act - Date actualCreated = TaskInfo.getCreated(); + Date actualEndTime = taskInfo.getEndTime(); // Assert - assertEquals(expectedCreated, actualCreated); + assertEquals(expectedEndTime, actualEndTime); } @Test public void testGetSetErrorDetails() throws Exception { // Arrange - Date expectedLastModified = new Date(); + List<ErrorDetail> errorDetails = new ArrayList<ErrorDetail>(); TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setLastModified(expectedLastModified)); // Act @@ -121,7 +122,6 @@ public void testGetSetName() { public void testGetSetPerfMessage() { // Arrange - String expectedPerfMessage = "testGetSetPerfMessage"; TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setPerfMessage(expectedPerfMessage)); @@ -133,54 +133,135 @@ public void testGetSetPerfMessage() { } public void testGetSetPriority() { + // Arrange + int expectedPriority = 3; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setPriority(expectedPriority)); + + // Act + int actualPriority = TaskInfo.getPriority(); + // Assert + assertEquals(expectedPriority, actualPriority); } public void testGetSetProgress() { + // Arrange + double expectedProgress = 3; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setProgress(expectedProgress)); + + // Act + double actualProgress = TaskInfo.getProgress(); + // Assert + assertEquals(expectedProgress, actualProgress, 0.00001); } public void testGetSetRunningDuration() { + // Arrange + double expectedRunningDuration = 3; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setRunningDuration(expectedRunningDuration)); + // Act + double actualRunningDuration = TaskInfo.getRunningDuration(); + + // Assert + assertEquals(expectedRunningDuration, actualRunningDuration, 0.00001); } public void testGetSetStartTime() { + // Arrange + Date expectedStartTime = new Date(); + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setStartTime(expectedStartTime)); + // Act + Date actualStartTime = TaskInfo.getStartTime(); + + // Assert + assertEquals(expectedStartTime, actualStartTime); } public void testGetSetState() { + // Arrange + TaskState expectedState = TaskState.Completed; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setState(expectedState.getCode())); + + // Act + TaskState actualState = TaskInfo.getState(); + // Assert + assertEquals(expectedState, actualState); } public void testGetSetTaskBody() { + // Arrange + String expectedTaskBody = "getSetTaskBody"; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setTaskBody(expectedTaskBody)); + + // Act + String actualTaskBody = TaskInfo.getTaskBody(); + // Assert + assertEquals(expectedTaskBody, actualTaskBody); } public void testGetSetOptions() { + // Arrange + TaskOption expectedTaskOption = TaskOption.ProtectedConfiguration; + TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setOptions(expectedTaskOption.getCode())); + + // Act + TaskOption actualTaskOption = TaskInfo.getOptions(); + // Assert + assertEquals(expectedTaskOption, actualTaskOption); } public void testGetSetEncryptionKeyId() { + // Arrange + String expectedEncryptionKeyId = "getSetEncryptionKeyId"; + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setEncryptionKeyId(expectedEncryptionKeyId)); + + // Act + String actualEncryptionKeyId = taskInfo.getEncryptionKeyId(); + // Assert + assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); } public void testGetSetEncryptionScheme() { + // Arrange + String expectedEncryptionScheme = "getSetEncryptionScheme"; + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setEncryptionScheme(expectedEncryptionScheme)); + // Act + String actualEncryptionScheme = taskInfo.getEncryptionScheme(); + + // Assert + assertEquals(expectedEncryptionScheme, actualEncryptionScheme); } public void testGetSetEncryptionVersion() { + // Arrange + String expectedEncryptionVersion = "1.5"; + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setEncryptionVersion(expectedEncryptionVersion)); + // Act + String actualEncryptionVersion = taskInfo.getEncryptionVersion(); + + // Assert + assertEquals(expectedEncryptionVersion, actualEncryptionVersion); } public void testGetSetInitializationVector() { + // Arrange + String expectedInitializationVector = "testInitializationVector"; + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setEncryptionVersion(expectedInitializationVector)); - } - - public void testGetSetOutputMediaAssets() { + // Act + String actualInitializationVector = taskInfo.getEncryptionVersion(); + // Assert + assertEquals(expectedInitializationVector, actualInitializationVector); } - public void testGetSetInputMediaAssets() { - - } } From 2811704b8a0af0256ee7368b8e8581ea42773d83 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 18 Dec 2012 18:41:43 -0800 Subject: [PATCH 587/664] Completes the unit test for task info class. --- .../services/media/models/TaskEntityTest.java | 4 ++- .../services/media/models/TaskInfoTest.java | 28 ++++++++----------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index 50f2e279ab283..7a8278604b876 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -49,7 +49,9 @@ public TaskEntityTest() throws Exception { @Test public void TaskCreateReturnsDefaultCreatePayload() { - TaskType payload = (TaskType) Task.create().getRequestContents(); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; + TaskType payload = Task.create(expectedMediaProcessorId, expectedTaskBody); assertNotNull(payload); assertNull(payload.getId()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java index 3da83fbd0da39..ca13178d0c5f7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -18,9 +18,11 @@ import java.util.ArrayList; import java.util.Date; +import java.util.List; import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; public class TaskInfoTest { @@ -70,27 +72,19 @@ public void testGetSetEndTime() throws Exception { @Test public void testGetSetErrorDetails() throws Exception { // Arrange - List<ErrorDetail> errorDetails = new ArrayList<ErrorDetail>(); - TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setLastModified(expectedLastModified)); + List<ErrorDetail> expectedErrorDetails = new ArrayList<ErrorDetail>(); + List<ErrorDetailType> expectedErrorDetailsType = new ArrayList<ErrorDetailType>(); + for (ErrorDetailType errorDetailType : expectedErrorDetailsType) { + ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage()); + expectedErrorDetails.add(errorDetail); + } + TaskInfo taskInfo = new TaskInfo(null, new TaskType().setErrorDetails(expectedErrorDetailsType)); // Act - Date actualLastModified = TaskInfo.getLastModified(); + List<ErrorDetail> actualErrorDetails = taskInfo.getErrorDetails(); // Assert - assertEquals(expectedLastModified, actualLastModified); - } - - @Test - public void testGetSetHistoricalEvents() { - // Arrange - String expectedAlternateId = "testAlternateId"; - TaskInfo TaskInfo = new TaskInfo(null, new TaskType().setAlternateId(expectedAlternateId)); - - // Act - String actualAlternateId = TaskInfo.getAlternateId(); - - // Assert - assertEquals(expectedAlternateId, actualAlternateId); + assertEquals(expectedErrorDetails, actualErrorDetails); } @Test From 87dcf5459d6f11943e1bcb6a645240ca89768e43 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 19 Dec 2012 11:19:49 -0800 Subject: [PATCH 588/664] update task entity test --- .../services/media/models/TaskEntityTest.java | 87 ++++++------------- 1 file changed, 26 insertions(+), 61 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index 7a8278604b876..087a7aab2aed8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -21,15 +21,10 @@ import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBElement; -import javax.xml.namespace.QName; import org.junit.Test; -import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; -import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; -import com.microsoft.windowsazure.services.media.implementation.content.Constants; -import com.microsoft.windowsazure.services.media.implementation.content.JobType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; @@ -44,6 +39,19 @@ public class TaskEntityTest { static final String sampleTaskId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; private final String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8")); + private TaskType getTaskType(EntryType entryType) { + for (Object child : entryType.getEntryChildren()) { + if (child instanceof JAXBElement) { + @SuppressWarnings("rawtypes") + JAXBElement element = (JAXBElement) child; + if (element.getDeclaredType() == TaskType.class) { + return (TaskType) element.getValue(); + } + } + } + return null; + } + public TaskEntityTest() throws Exception { } @@ -51,34 +59,26 @@ public TaskEntityTest() throws Exception { public void TaskCreateReturnsDefaultCreatePayload() { String expectedMediaProcessorId = "expectedMediaProcessorId"; String expectedTaskBody = "expectedTaskBody"; - TaskType payload = Task.create(expectedMediaProcessorId, expectedTaskBody); - - assertNotNull(payload); - assertNull(payload.getId()); - assertNull(payload.getState()); - assertNull(payload.getCreated()); - assertNull(payload.getLastModified()); - assertNull(payload.getAlternateId()); - assertNull(payload.getName()); - assertNull(payload.getOptions()); + + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody).getEntryType()); + + assertNotNull(taskType); + assertEquals(expectedMediaProcessorId, taskType.getMediaProcessorId()); + assertEquals(expectedTaskBody, taskType.getTaskBody()); } @Test public void TaskCreateCanSetTaskName() { - String name = "TaskCreateCanSetTaskName"; + String expectedName = "TaskCreateCanSetTaskName"; - Task.Creator creator = Task.create().setName("TaskCreateCanSetTaskName"); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - TaskType payload = (TaskType) creator.getRequestContents(); + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody).setName(expectedName) + .getEntryType()); - assertNotNull(payload); - assertNull(payload.getId()); - assertNull(payload.getState()); - assertNull(payload.getCreated()); - assertNull(payload.getLastModified()); - assertNull(payload.getAlternateId()); - assertEquals(name, payload.getName()); - assertNull(payload.getOptions()); + assertNotNull(taskType); + assertEquals(expectedName, taskType.getName()); } @Test @@ -161,39 +161,4 @@ public void listForLinkReturnsExpectedUri() throws Exception { assertEquals(lister.getUri(), expectedInputTask); } - private JobInfo createJob() { - EntryType fakeJobEntry = new EntryType(); - addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/OutputMediaTasks", expectedOutputTask, - "application/atom+xml;type=feed", "OutputTasks"); - addEntryLink(fakeJobEntry, Constants.ODATA_DATA_NS + "/related/InputMediaTasks", expectedInputTask, - "application/atom+xml;type=feed", "InputTasks"); - - JobType payload = new JobType().setId("SomeId").setName("FakeJob"); - addEntryContent(fakeJobEntry, payload); - - return new JobInfo(fakeJobEntry, payload); - } - - private void addEntryLink(EntryType entry, String rel, String href, String type, String title) { - LinkType link = new LinkType(); - link.setRel(rel); - link.setHref(href); - link.setType(type); - link.setTitle(title); - - JAXBElement<LinkType> linkElement = new JAXBElement<LinkType>(new QName("link", Constants.ATOM_NS), - LinkType.class, link); - entry.getEntryChildren().add(linkElement); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private ContentType addEntryContent(EntryType entry, Object content) { - ContentType contentWrapper = new ContentType(); - contentWrapper.getContent().add( - new JAXBElement(Constants.ODATA_PROPERTIES_ELEMENT_NAME, content.getClass(), content)); - - entry.getEntryChildren().add( - new JAXBElement<ContentType>(Constants.ATOM_CONTENT_ELEMENT_NAME, ContentType.class, contentWrapper)); - return contentWrapper; - } } From eca474166880de4688056f9deadcdaa16b8ce176 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 19 Dec 2012 12:19:20 -0800 Subject: [PATCH 589/664] fix broken unit tests --- .../media/models/ProtectionKeyEntityTest.java | 7 +- .../services/media/models/TaskEntityTest.java | 121 ++++++++++-------- 2 files changed, 70 insertions(+), 58 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java index 0fcc79a85f546..98c43e656a6a7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java @@ -40,10 +40,11 @@ public void ProtectionKeyIdReturnsPayloadWithTheRightProtectionKeyType() { @Test public void ProtectionKeyReturnsPayloadWithTheRightProtectionKeyId() { - String expectedProtectionKey = "expectedProtectionKey"; - String actualProtectionKey = ProtectionKey.getProtectionKey(expectedProtectionKey).getQueryParameters() + String expectedProtectionKeyId = "expectedProtectionKey"; + String actualProtectionKeyId = ProtectionKey.getProtectionKey(expectedProtectionKeyId).getQueryParameters() .getFirst("ProtectionKeyId"); + expectedProtectionKeyId = String.format("'%s'", expectedProtectionKeyId); - assertEquals(expectedProtectionKey, actualProtectionKey); + assertEquals(expectedProtectionKeyId, actualProtectionKeyId); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index 087a7aab2aed8..ba9bb9c6d5175 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -19,18 +19,12 @@ import java.net.URLEncoder; -import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBElement; import org.junit.Test; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the methods and factories of the Task entity. @@ -56,7 +50,7 @@ public TaskEntityTest() throws Exception { } @Test - public void TaskCreateReturnsDefaultCreatePayload() { + public void taskCreateReturnsDefaultCreatePayload() { String expectedMediaProcessorId = "expectedMediaProcessorId"; String expectedTaskBody = "expectedTaskBody"; @@ -68,7 +62,7 @@ public void TaskCreateReturnsDefaultCreatePayload() { } @Test - public void TaskCreateCanSetTaskName() { + public void taskCreateCanSetTaskName() { String expectedName = "TaskCreateCanSetTaskName"; String expectedMediaProcessorId = "expectedMediaProcessorId"; @@ -82,83 +76,100 @@ public void TaskCreateCanSetTaskName() { } @Test - public void TaskGetReturnsExpectedUri() throws Exception { - String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8")); + public void taskCreateCanSetConfiguration() { + String expectedConfiguration = "TaskCreateCanSetTaskCofniguration"; - EntityGetOperation<TaskInfo> getter = Task.get(sampleTaskId); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; + + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setConfiguration(expectedConfiguration).getEntryType()); - assertEquals(expectedUri, getter.getUri()); + assertNotNull(taskType); + assertEquals(expectedConfiguration, taskType.getConfiguration()); } @Test - public void TaskListReturnsExpectedUri() { - EntityListOperation<TaskInfo> lister = Task.list(); + public void taskCreateCanSetPriority() { + Integer expectedPriority = 3; - assertEquals("Tasks", lister.getUri()); - assertNotNull(lister.getQueryParameters()); - assertEquals(0, lister.getQueryParameters().size()); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; + + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setPriority(expectedPriority).getEntryType()); + + assertNotNull(taskType); + assertEquals(expectedPriority, taskType.getPriority()); } @Test - public void TaskListCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); + public void taskCreateCanSetTaskBody() { + String expectedTaskBodyResult = "expectedTaskBodyResult"; - EntityListOperation<TaskInfo> lister = Task.list(queryParams); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals(2, lister.getQueryParameters().size()); + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setTaskBody(expectedTaskBodyResult).getEntryType()); + + assertNotNull(taskType); + assertEquals(expectedTaskBodyResult, taskType.getTaskBody()); } @Test - public void TaskListCanTakeQueryParametersChained() { - EntityListOperation<TaskInfo> lister = Task.list().setTop(10).setSkip(2).set("filter", "something"); + public void taskCreateCanSetEncryptionKeyId() { + String expectedEncryptionKeyId = "expectedEncryptionKeyId"; - assertEquals("10", lister.getQueryParameters().getFirst("$top")); - assertEquals("2", lister.getQueryParameters().getFirst("$skip")); - assertEquals("something", lister.getQueryParameters().getFirst("filter")); - assertEquals(3, lister.getQueryParameters().size()); - } + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - @Test - public void TaskUpdateReturnsExpectedUri() throws Exception { - EntityUpdateOperation updater = Task.update(sampleTaskId); - assertEquals(expectedUri, updater.getUri()); + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setEncryptionKeyId(expectedEncryptionKeyId).getEntryType()); + + assertNotNull(taskType); + assertEquals(expectedEncryptionKeyId, taskType.getTaskBody()); } @Test - public void TaskUpdateCanSetNameAndAltId() throws Exception { - - String expectedName = "newTaskName"; - String expectedAltId = "newAltId"; + public void taskCreateCanSetEncryptionScheme() { + String expectedEncryptionScheme = "expectedEncryptionScheme"; - EntityUpdateOperation updater = Task.update(sampleTaskId).setName(expectedName).setAlternateId(expectedAltId); + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - TaskType payload = (TaskType) updater.getRequestContents(); + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setEncryptionScheme(expectedEncryptionScheme).getEntryType()); - assertEquals(expectedName, payload.getName()); - assertEquals(expectedAltId, payload.getAlternateId()); + assertNotNull(taskType); + assertEquals(expectedEncryptionScheme, taskType.getEncryptionScheme()); } @Test - public void TaskDeleteReturnsExpectedUri() throws Exception { - EntityDeleteOperation deleter = Task.delete(sampleTaskId); + public void taskCreateCanSetEncryptionVersion() { + String expectedEncryptionVersion = "expectedEncryptionVersion"; - assertEquals(expectedUri, deleter.getUri()); - } + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - private static final String expectedOutputTask = "Job(someJobId)/OutputTasks"; - private static final String expectedInputTask = "Job(someJobId)/InputTasks"; + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setEncryptionVersion(expectedEncryptionVersion).getEntryType()); + + assertNotNull(taskType); + assertEquals(expectedEncryptionVersion, taskType.getTaskBody()); + } @Test - public void listForLinkReturnsExpectedUri() throws Exception { - JobInfo fakeJob = createJob(); + public void taskCreateCanSetInitializationVector() { + String expectedInitializationVector = "expectedEncryptionKeyId"; + + String expectedMediaProcessorId = "expectedMediaProcessorId"; + String expectedTaskBody = "expectedTaskBody"; - EntityListOperation<TaskInfo> lister = Task.list(fakeJob.getInputTasksLink()); + TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) + .setEncryptionKeyId(expectedInitializationVector).getEntryType()); - assertEquals(lister.getUri(), expectedInputTask); + assertNotNull(taskType); + assertEquals(expectedInitializationVector, taskType.getTaskBody()); } - } From af0855a6ca54b2220ad2cd844ffaedc6be2377ee Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 19 Dec 2012 12:33:43 -0800 Subject: [PATCH 590/664] fix a broken unit test. --- .../services/media/models/TaskEntityTest.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index ba9bb9c6d5175..982b1b548cf67 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -23,6 +23,7 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; @@ -38,8 +39,16 @@ private TaskType getTaskType(EntryType entryType) { if (child instanceof JAXBElement) { @SuppressWarnings("rawtypes") JAXBElement element = (JAXBElement) child; - if (element.getDeclaredType() == TaskType.class) { - return (TaskType) element.getValue(); + if (element.getDeclaredType() == ContentType.class) { + ContentType contentType = (ContentType) element.getValue(); + for (Object grandChild : contentType.getContent()) { + if (grandChild instanceof JAXBElement) { + JAXBElement contentElement = (JAXBElement) grandChild; + TaskType taskType = (TaskType) contentElement.getValue(); + return taskType; + } + } + return null; } } } @@ -128,7 +137,7 @@ public void taskCreateCanSetEncryptionKeyId() { .setEncryptionKeyId(expectedEncryptionKeyId).getEntryType()); assertNotNull(taskType); - assertEquals(expectedEncryptionKeyId, taskType.getTaskBody()); + assertEquals(expectedEncryptionKeyId, taskType.getEncryptionKeyId()); } @Test @@ -156,7 +165,7 @@ public void taskCreateCanSetEncryptionVersion() { .setEncryptionVersion(expectedEncryptionVersion).getEntryType()); assertNotNull(taskType); - assertEquals(expectedEncryptionVersion, taskType.getTaskBody()); + assertEquals(expectedEncryptionVersion, taskType.getEncryptionVersion()); } @Test @@ -170,6 +179,6 @@ public void taskCreateCanSetInitializationVector() { .setEncryptionKeyId(expectedInitializationVector).getEntryType()); assertNotNull(taskType); - assertEquals(expectedInitializationVector, taskType.getTaskBody()); + assertEquals(expectedInitializationVector, taskType.getInitializationVector()); } } From 96bf978f54b4d9eb2ca0e6424b5e288b34c84b0c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 19 Dec 2012 13:11:42 -0800 Subject: [PATCH 591/664] Adding Task integration tests --- .../services/media/TaskIntegrationTest.java | 298 ++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100644 microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java new file mode 100644 index 0000000000000..e1c23729712a5 --- /dev/null +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -0,0 +1,298 @@ +/** + * Copyright 2012 Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.microsoft.windowsazure.services.media; + +import static org.junit.Assert.*; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.core.MultivaluedMap; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetInfo; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.Job.Creator; +import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.JobState; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; +import com.microsoft.windowsazure.services.media.models.TaskInfo; +import com.microsoft.windowsazure.services.media.models.TaskOption; +import com.microsoft.windowsazure.services.media.models.TaskState; +import com.sun.jersey.core.util.Base64; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class TaskIntegrationTest extends IntegrationTestBase { + private static AssetInfo assetInfo; + private Creator jobCreator; + + private static final String commonMediaProcessorId = "nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"; + private static final String commonConfiguration = "H.264 256k DSL CBR"; + + @BeforeClass + public static void setup() throws Exception { + IntegrationTestBase.setup(); + assetInfo = setupAssetWithFile(); + } + + @Before + public void instanceSetup() { + this.jobCreator = Job.create().setName(testJobPrefix + UUID.randomUUID().toString()).setPriority(3) + .addInputMediaAsset(assetInfo.getId()); + } + + @Test + public void createTaskSuccess() throws ServiceException, UnsupportedEncodingException { + // Arrange + + // Required + String mediaProcessorId = commonMediaProcessorId; + String taskBody = constructTaskBody(0); + + // Optional parameters + String configuration = new String(Base64.encode(commonConfiguration), "UTF8"); + String name = "My encoding Task " + UUID.randomUUID().toString(); + int priority = 0; + TaskOption options = TaskOption.ProtectedConfiguration; + // Use a fake id, to simulate real use. + String encryptionKeyId = "nb:kid:UUID:" + UUID.randomUUID().toString(); + String encryptionScheme = "ConfigurationEncryption"; + String encryptionVersion = "1.0"; + // Use a trivial vector, 16 bytes of zeros, base-64 encoded. + String initializationVector = new String(Base64.encode(new byte[16]), "UTF8"); + + CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBody).setConfiguration(configuration) + .setName(name).setPriority(priority).setOptions(options).setEncryptionKeyId(encryptionKeyId) + .setEncryptionScheme(encryptionScheme).setEncryptionVersion(encryptionVersion) + .setInitializationVector(initializationVector); + jobCreator.addTaskCreator(taskCreator); + + // Act + JobInfo job = service.create(jobCreator); + List<TaskInfo> taskInfos = service.list(Task.list(job.getTasksLink())); + + // Assert + assertEquals("taskInfos count", 1, taskInfos.size()); + verifyTaskPropertiesJustStarted("taskInfo", mediaProcessorId, options, taskBody, configuration, name, priority, + encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, taskInfos.get(0)); + } + + @Test + public void createTwoTasksSuccess() throws ServiceException { + // Arrange + + // Required + String mediaProcessorId = commonMediaProcessorId; + String[] taskBodies = new String[] { constructTaskBody(0), constructTaskBody(1) }; + + // Optional parameters + String configuration = commonConfiguration; + String baseName = "My encoding Task " + UUID.randomUUID().toString(); + String[] suffixes = new String[] { " 1", " 2" }; + int priority = 0; + TaskOption options = TaskOption.None; + + List<CreateBatchOperation> taskCreators = new ArrayList<CreateBatchOperation>(); + + for (int i = 0; i < taskBodies.length; i++) { + CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBodies[i]) + .setConfiguration(configuration).setName(baseName + suffixes[i]); + taskCreators.add(taskCreator); + jobCreator.addTaskCreator(taskCreator); + } + + // Act + JobInfo job = service.create(jobCreator); + List<TaskInfo> taskInfos = service.list(Task.list(job.getTasksLink())); + + // Assert + assertEquals("taskInfos count", taskCreators.size(), taskInfos.size()); + for (int i = 0; i < taskCreators.size(); i++) { + verifyTaskPropertiesJustStartedNoEncryption("taskInfo", mediaProcessorId, options, taskBodies[i], + configuration, baseName + suffixes[i], priority, taskInfos.get(i)); + } + } + + @Test + public void canListTasksWithOptions() throws ServiceException { + // Arrange + String mediaProcessorId = commonMediaProcessorId; + String configuration = commonConfiguration; + String[] taskNameSuffixes = new String[] { "A", "B", "C", "D" }; + String baseName = "My encoding Task " + UUID.randomUUID().toString(); + int taskCounter = 0; + for (String suffix : taskNameSuffixes) { + CreateBatchOperation taskCreator = Task.create(mediaProcessorId, constructTaskBody(taskCounter++)) + .setConfiguration(configuration).setName(baseName + suffix); + jobCreator.addTaskCreator(taskCreator); + } + + service.create(jobCreator); + + // Act + MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); + queryParameters.add("$filter", "startswith(Name, '" + baseName + "') eq true"); + ListResult<TaskInfo> listTaskResult1 = service.list(Task.list(queryParameters)); + + queryParameters.add("$top", "2"); + ListResult<TaskInfo> listTaskResult2 = service.list(Task.list(queryParameters)); + + // Assert + assertEquals("listTaskResult1.size", 4, listTaskResult1.size()); + assertEquals("listTaskResult2.size", 2, listTaskResult2.size()); + } + + @Test + public void cancelTaskSuccess() throws ServiceException, InterruptedException { + // Arrange + String mediaProcessorId = commonMediaProcessorId; + String taskBody = constructTaskBody(0); + String configuration = commonConfiguration; + String name = "My encoding Task " + UUID.randomUUID().toString(); + CreateBatchOperation taskCreator = Task.create(mediaProcessorId, taskBody).setConfiguration(configuration) + .setName(name); + jobCreator.addTaskCreator(taskCreator); + + JobInfo jobInfo = service.create(jobCreator); + + // Act + service.action(Job.cancel(jobInfo.getId())); + JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); + while (cancellingJobInfo.getState() == JobState.Canceling) { + Thread.sleep(2000); + cancellingJobInfo = service.get(Job.get(jobInfo.getId())); + } + + //Assert + List<TaskInfo> taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink())); + for (TaskInfo taskInfo : taskInfos) { + // Replace with enums + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/522 + verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody, + configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); + } + } + + private void verifyTaskProperties(String message, String mediaProcessorId, TaskOption options, String taskBody, + String configuration, String name, int priority, String encryptionKeyId, String encryptionScheme, + String encryptionVersion, String initializationVector, Date endTime, String errorDetails, double progress, + double runningDuration, Date startTime, TaskState state, TaskInfo actual) throws ServiceException { + assertNotNull(message, actual); + assertNotNull(message + " id", actual.getId()); + + // Required fields + assertEquals(message + " getMediaProcessorId", mediaProcessorId, actual.getMediaProcessorId()); + assertEquals(message + " getOptions", options, actual.getOptions()); + assertEquals(message + " getTaskBody", taskBody, actual.getTaskBody()); + + // Optional fields + assertEquals(message + " getConfiguration", configuration, actual.getConfiguration()); + assertEquals(message + " getName", name, actual.getName()); + assertEquals(message + " getPriority", priority, actual.getPriority().intValue()); + + // Optional encryption fields + assertEqualsNullEmpty(message + " getEncryptionKeyId", encryptionKeyId, actual.getEncryptionKeyId()); + assertEqualsNullEmpty(message + " getEncryptionScheme", encryptionScheme, actual.getEncryptionScheme()); + assertEqualsNullEmpty(message + " getEncryptionVersion", encryptionVersion, actual.getEncryptionVersion()); + assertEqualsNullEmpty(message + " getInitializationVector", initializationVector, + actual.getInitializationVector()); + + // Read-only fields + assertDateApproxEquals(message + " getEndTime", endTime, actual.getEndTime()); + assertNotNull(message + " getErrorDetails", actual.getErrorDetails()); + assertEquals(message + " getErrorDetails.size", 0, actual.getErrorDetails().size()); + + // TODO: Add tests for Historical events when added + // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/494 + + ListResult<AssetInfo> inputAssets = service.list(Asset.list(actual.getInputAssetsLink())); + ListResult<AssetInfo> outputAssets = service.list(Asset.list(actual.getOutputAssetsLink())); + + assertEquals(message + " inputAssets.size", 1, inputAssets.size()); + assertEquals(message + " inputAssets.get(0).getId", assetInfo.getId(), inputAssets.get(0).getId()); + + assertEquals(message + " outputAssets.size", 1, outputAssets.size()); + // Because this is a new asset, there is not much else to test + assertTrue(message + " outputAssets.get(0).getId != assetInfo.getId", + !assetInfo.getId().equals(outputAssets.get(0).getId())); + + assertEquals(message + " getProgress", progress, actual.getProgress().doubleValue(), 0.01); + assertEquals(message + " getRunningDuration", runningDuration, actual.getRunningDuration(), 0.01); + assertDateApproxEquals(message + " getStartTime", startTime, actual.getStartTime()); + assertEquals(message + " getState", state, actual.getState()); + + // Note: The PerfMessage is not validated because it is server generated. + } + + private void verifyTaskPropertiesJustStarted(String message, String mediaProcessorId, TaskOption options, + String taskBody, String configuration, String name, int priority, String encryptionKeyId, + String encryptionScheme, String encryptionVersion, String initializationVector, TaskInfo actual) + throws ServiceException { + + // Read-only + Date endTime = null; + String errorDetails = null; + double progress = 0.0; + int runningDuration = 0; + Date startTime = null; + TaskState state = TaskState.None; + + verifyTaskProperties(message, mediaProcessorId, options, taskBody, configuration, name, priority, + encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, endTime, errorDetails, + progress, runningDuration, startTime, state, actual); + } + + private void verifyTaskPropertiesJustStartedNoEncryption(String message, String mediaProcessorId, + TaskOption options, String taskBody, String configuration, String name, int priority, TaskInfo actual) + throws ServiceException { + String encryptionKeyId = null; + String encryptionScheme = null; + String encryptionVersion = null; + String initializationVector = null; + + verifyTaskPropertiesJustStarted(message, mediaProcessorId, options, taskBody, configuration, name, priority, + encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, actual); + } + + private void verifyTaskPropertiesNoEncryption(String message, String mediaProcessorId, TaskOption options, + String taskBody, String configuration, String name, int priority, Date endTime, String errorDetails, + double progress, double runningDuration, Date startTime, TaskState state, TaskInfo actual) + throws ServiceException { + String encryptionKeyId = null; + String encryptionScheme = null; + String encryptionVersion = null; + String initializationVector = null; + + verifyTaskProperties(message, mediaProcessorId, options, taskBody, configuration, name, priority, + encryptionKeyId, encryptionScheme, encryptionVersion, initializationVector, endTime, errorDetails, + progress, runningDuration, startTime, state, actual); + } + + private String constructTaskBody(int outputIndex) { + return "<taskBody><inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset(" + outputIndex + + ")</outputAsset></taskBody>"; + } +} From 6c1925f242552d3ab3f24c6af5b95ad30d8e6d69 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 19 Dec 2012 13:19:18 -0800 Subject: [PATCH 592/664] Fix #568 --- .../services/media/models/Asset.java | 13 ++++++++++++- .../services/media/AssetIntegrationTest.java | 18 ++---------------- .../media/EncryptionIntegrationTest.java | 16 +--------------- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index c75f78f34a34f..68b364053ece8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -15,7 +15,10 @@ package com.microsoft.windowsazure.services.media.models; +import java.io.UnsupportedEncodingException; import java.net.URI; +import java.net.URLEncoder; +import java.security.InvalidParameterException; import javax.ws.rs.core.MultivaluedMap; @@ -302,7 +305,15 @@ public static EntityDeleteOperation delete(String assetId) { * the content key uri * @return the entity action operation */ - public static EntityLinkOperation linkContentKey(String assetId, URI contentKeyUri) { + public static EntityLinkOperation linkContentKey(String assetId, String contentKeyId) { + String escapedContentKeyId = null; + try { + escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new InvalidParameterException("contentKeyId"); + } + URI contentKeyUri = URI.create(String.format("ContentKeys('%s')", escapedContentKeyId)); return new EntityLinkOperation("Assets", assetId, "ContentKeys", contentKeyUri); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 80955cd2a18ef..6eedbfa4fc737 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -17,11 +17,7 @@ import static org.junit.Assert.*; -import java.io.UnsupportedEncodingException; -import java.net.URI; import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.security.InvalidParameterException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -283,17 +279,9 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep String contentKeyId = String.format("nb:kid:UUID:%s", UUID.randomUUID()); String encryptedContentKey = "dummyEncryptedContentKey"; service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKey)); - String escapedContentKeyId; - try { - escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new InvalidParameterException(contentKeyId); - } - URI contentKeyUri = new URI(String.format("ContentKeys('%s')", escapedContentKeyId)); // Act - service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyId)); // Assert @@ -305,14 +293,12 @@ public void linkAssetContentKeySuccess() throws ServiceException, URISyntaxExcep @Test public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyntaxException { // Arrange - URI invalidContentKeyUri = new URI("ContentKeys('nb%3akid%3aUUID%3ainvalidContentKeyId')"); // Act expectedException.expect(ServiceException.class); expectedException.expect(new ServiceExceptionMatcher(400)); - service.action(Asset.linkContentKey(validButNonexistAssetId, invalidContentKeyUri)); + service.action(Asset.linkContentKey(validButNonexistAssetId, "nb:kid:UUID:invalidContentKeyId")); // Assert - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index b8f356d44b742..c6f2f0588b05e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -19,9 +19,6 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URLEncoder; import java.security.Security; import java.util.EnumSet; import java.util.List; @@ -108,12 +105,6 @@ private MediaProcessorInfo GetMediaProcessor(String mediaProcessorName) throws S return null; } - private void linkContentKey(AssetInfo assetInfo, ContentKeyInfo contentKeyInfo) throws ServiceException, - UnsupportedEncodingException { - URI contentKeyUri = createContentKeyUri(contentKeyInfo.getId()); - service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyUri)); - } - private String getProtectionKey(String protectionKeyId) throws ServiceException { String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); return protectionKey; @@ -131,11 +122,6 @@ private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, LocatorInfo return assetFileInfo; } - private URI createContentKeyUri(String contentKeyId) throws UnsupportedEncodingException { - String escapedContentKeyId = URLEncoder.encode(contentKeyId, "UTF-8"); - return URI.create(String.format("ContentKeys('%s')", escapedContentKeyId)); - } - private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId, String protectionKey) throws Exception { UUID contentKeyIdUuid = UUID.randomUUID(); @@ -182,7 +168,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { protectionKey); // link the content key with the asset. - linkContentKey(assetInfo, contentKeyInfo); + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyInfo.getId())); // encrypt the file. byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); From 85e893b4b5ce8ffe6eedb4bf420511c229f01fd3 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 19 Dec 2012 13:20:16 -0800 Subject: [PATCH 593/664] Fix #569 --- .../microsoft/windowsazure/services/media/models/Task.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 2c205a8d302c5..0b6429d6c7f35 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -120,8 +120,8 @@ public CreateBatchOperation(String mediaProcessorId, String taskBody) { * the options * @return the creates the batch operation */ - public CreateBatchOperation setOptions(int options) { - this.taskType.setOptions(options); + public CreateBatchOperation setOptions(TaskOption options) { + this.taskType.setOptions(options.getCode()); return this; } From d09c8f0a29dfe9bef8f5023794c2852e2fc8e10d Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 19 Dec 2012 13:29:01 -0800 Subject: [PATCH 594/664] Promoting some Job method to base for use by Task tests Cleanup of "throws" clauses Cleanup of scenario tests for jobs --- .../services/media/IntegrationTestBase.java | 67 +++++++++++++++++-- .../services/media/JobIntegrationTest.java | 44 ++---------- .../scenarios/MediaServiceScenarioTest.java | 6 +- .../scenarios/MediaServiceValidation.java | 17 +++-- 4 files changed, 83 insertions(+), 51 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index bef05b619af63..7bac5e19bb3e3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -2,11 +2,15 @@ import static org.junit.Assert.*; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.EnumSet; import java.util.List; +import java.util.UUID; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -17,12 +21,15 @@ import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Locator; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -116,8 +123,18 @@ private static void removeAllTestAssets() { try { List<AssetInfo> listAssetsResult = service.list(Asset.list()); for (AssetInfo assetInfo : listAssetsResult) { - if (assetInfo.getName().startsWith(testAssetPrefix)) { - service.delete(Asset.delete(assetInfo.getId())); + try { + if (assetInfo.getName().startsWith(testAssetPrefix)) { + service.delete(Asset.delete(assetInfo.getId())); + } + else if (assetInfo.getName().startsWith("JobOutputAsset(") + && assetInfo.getName().contains(testJobPrefix)) { + // Delete the temp assets associated with Job results. + service.delete(Asset.delete(assetInfo.getId())); + } + } + catch (Exception e) { + e.printStackTrace(); } } } @@ -145,8 +162,24 @@ private static void removeAllTestJobs() { try { ListResult<JobInfo> jobs = service.list(Job.list()); for (JobInfo job : jobs) { - if (job.getName().startsWith(testAssetPrefix)) { - service.delete(Job.delete(job.getId())); + if (job.getName().startsWith(testJobPrefix)) { + // Job can't be deleted when it's state is + // canceling, scheduled,queued or processing + try { + if (job.getState() == JobState.Scheduled || job.getState() == JobState.Queued + || job.getState() == JobState.Processing) { + service.action(Job.cancel(job.getId())); + } + else if (job.getState() != JobState.Canceling) { + service.delete(Job.delete(job.getId())); + } + else { + // Not much to do so except wait. + } + } + catch (Exception e) { + e.printStackTrace(); + } } } } @@ -159,6 +192,23 @@ interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } + protected static AssetInfo setupAssetWithFile() throws ServiceException { + String name = UUID.randomUUID().toString(); + String testBlobName = "test" + name + ".bin"; + AssetInfo assetInfo = service.create(Asset.create().setName(testAssetPrefix + name)); + + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + name, 10, + EnumSet.of(AccessPolicyPermission.WRITE))); + LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); + InputStream blobContent = new ByteArrayInputStream(new byte[] { 4, 8, 15, 16, 23, 42 }); + blobWriter.createBlockBlob(testBlobName, blobContent); + + service.action(AssetFile.createFileInfos(assetInfo.getId())); + + return assetInfo; + } + protected static LocatorInfo createLocator(AccessPolicyInfo accessPolicy, AssetInfo asset, int startDeltaMinutes) throws ServiceException { @@ -209,6 +259,15 @@ protected <T> void verifyListResultContains(String message, List<T> expectedInfo } } + protected void assertEqualsNullEmpty(String message, String expected, String actual) { + if ((expected == null || expected.length() == 0) && (actual == null || actual.length() == 0)) { + // both nullOrEmpty, so match. + } + else { + assertEquals(message, expected, actual); + } + } + protected void assertDateApproxEquals(Date expected, Date actual) { assertDateApproxEquals("", expected, actual); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 81ec1f70beaf4..19b14c4653bac 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -17,30 +17,21 @@ import static org.junit.Assert.*; -import java.io.ByteArrayInputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Date; -import java.util.EnumSet; import java.util.List; -import java.util.UUID; import org.junit.BeforeClass; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.models.AccessPolicy; -import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; -import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; -import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.ErrorDetail; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; import com.microsoft.windowsazure.services.media.models.ListResult; -import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; import com.microsoft.windowsazure.services.media.models.TaskInfo; @@ -48,7 +39,6 @@ public class JobIntegrationTest extends IntegrationTestBase { private static AssetInfo assetInfo; - private static final byte[] testBlobData = new byte[] { 4, 8, 15, 16, 23, 42 }; private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), @@ -79,15 +69,6 @@ private void verifyJobProperties(String message, String testName, Integer priori // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/531 } - private void assertEqualsNullEmpty(String message, String expected, String actual) { - if ((expected == null || expected.length() == 0) && (actual == null || actual.length() == 0)) { - // both nullOrEmpty, so match. - } - else { - assertEquals(message, expected, actual); - } - } - private JobInfo createJob(String name) throws ServiceException { return service.create(Job.create().setName(name).setPriority(3).addInputMediaAsset(assetInfo.getId()) .addTaskCreator(getTaskCreator(0))); @@ -104,23 +85,11 @@ private CreateBatchOperation getTaskCreator(int outputAssetPosition) { @BeforeClass public static void setup() throws Exception { IntegrationTestBase.setup(); - - String name = UUID.randomUUID().toString(); - String testBlobName = "test" + name + ".bin"; - assetInfo = service.create(Asset.create().setName(testAssetPrefix + name)); - - AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + name, 10, - EnumSet.of(AccessPolicyPermission.WRITE))); - LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5); - WritableBlobContainerContract blobWriter = service.createBlobWriter(locator); - InputStream blobContent = new ByteArrayInputStream(testBlobData); - blobWriter.createBlockBlob(testBlobName, blobContent); - - service.action(AssetFile.createFileInfos(assetInfo.getId())); + assetInfo = setupAssetWithFile(); } @Test - public void createJobSuccess() throws Exception { + public void createJobSuccess() throws ServiceException { // Arrange String name = testJobPrefix + "createJobSuccess"; int priority = 3; @@ -142,7 +111,7 @@ public void createJobSuccess() throws Exception { } @Test - public void createJobTwoTasksSuccess() throws Exception { + public void createJobTwoTasksSuccess() throws ServiceException { // Arrange String name = testJobPrefix + "createJobSuccess"; int priority = 3; @@ -167,7 +136,7 @@ public void createJobTwoTasksSuccess() throws Exception { } @Test - public void getJobSuccess() throws Exception { + public void getJobSuccess() throws ServiceException { // Arrange String name = testJobPrefix + "getJobSuccess"; int priority = 3; @@ -231,7 +200,7 @@ public void canListJobsWithOptions() throws ServiceException { } @Test - public void cancelJobSuccess() throws Exception { + public void cancelJobSuccess() throws ServiceException { // Arrange JobInfo jobInfo = createJob(testJobPrefix + "cancelJobSuccess"); @@ -257,12 +226,13 @@ public void cancelJobFailedWithInvalidId() throws ServiceException { } @Test - public void deleteJobSuccess() throws ServiceException { + public void deleteJobSuccess() throws ServiceException, InterruptedException { // Arrange JobInfo jobInfo = createJob(testJobPrefix + "deleteJobSuccess"); service.action(Job.cancel(jobInfo.getId())); JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); while (cancellingJobInfo.getState() == JobState.Canceling) { + Thread.sleep(2000); cancellingJobInfo = service.get(Job.get(jobInfo.getId())); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 55dca19d3a94c..2fd63d9b9a0b0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -106,7 +106,7 @@ public void createJob() throws Exception { wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); - String jobName = "my job createJob"; + String jobName = "my job createJob" + UUID.randomUUID().toString(); JobInfo job = wrapper.createJob(jobName, asset, createTasks()); validator.validateJob(job, jobName, asset, createTasks()); } @@ -116,13 +116,13 @@ public void transformAsset() throws Exception { signalSetupStarting(); AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", AssetOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); - String jobName = "my job transformAsset"; + String jobName = "my job transformAsset" + UUID.randomUUID().toString(); JobInfo job = wrapper.createJob(jobName, asset, createTasks()); signalSetupFinished(); waitForJobToFinish(job); List<AssetInfo> outputAssets = wrapper.getJobOutputMediaAssets(job); - validator.validateOutputAssets(outputAssets); + validator.validateOutputAssets(outputAssets, getTestAssetFiles().keys()); } private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 164f54ff8385c..56c20a7ec6d26 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -23,6 +23,7 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Date; +import java.util.Enumeration; import java.util.Hashtable; import java.util.List; @@ -147,14 +148,16 @@ public void validateJob(JobInfo job, String name, AssetInfo asset, List<Task.Cre // assertEquals("outputAssets.size()", createTasks.size(), outputAssets.size()); } - public void validateOutputAssets(List<AssetInfo> outputAssets) throws ServiceException { - // TODO: Uncomment when fixed: - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 + public void validateOutputAssets(List<AssetInfo> outputAssets, Enumeration<String> enumeration) { + assertNotNull("outputAssets", outputAssets); + for (AssetInfo asset : outputAssets) { - // assertNotNull("outputAssets", outputAssets); - // for (AssetInfo asset : outputAssets) { - // this.validateAsset(asset, null, null); - // } + assertNotNull("asset", asset); + assertNotNull("asset.getId", asset.getId()); + assertFalse("asset.getId != ''", "".equals(asset.getId())); + assertEquals("asset.state", AssetState.Initialized, asset.getState()); + assertEquals("asset.getOptions", AssetOption.None, asset.getOptions()); + } } // This method is needed because there can be a delay before a new read locator From 63cc5630cf176f6dd62a230edaf1d238129f84d2 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 19 Dec 2012 16:16:12 -0800 Subject: [PATCH 595/664] Update Job cleanup code to wait until jobs can be deleted. Add counters for loops in Job integration tests, to prevent rogue jobs from makeing test runs hang. --- .../services/media/IntegrationTestBase.java | 19 ++++++++++++++++--- .../services/media/JobIntegrationTest.java | 10 +++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 7bac5e19bb3e3..04aef70e7c403 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -166,11 +166,19 @@ private static void removeAllTestJobs() { // Job can't be deleted when it's state is // canceling, scheduled,queued or processing try { - if (job.getState() == JobState.Scheduled || job.getState() == JobState.Queued - || job.getState() == JobState.Processing) { + if (isJobBusy(job.getState())) { service.action(Job.cancel(job.getId())); + job = service.get(Job.get(job.getId())); } - else if (job.getState() != JobState.Canceling) { + + int retryCounter = 0; + while (isJobBusy(job.getState()) && retryCounter < 10) { + Thread.sleep(2000); + job = service.get(Job.get(job.getId())); + retryCounter++; + } + + if (!isJobBusy(job.getState())) { service.delete(Job.delete(job.getId())); } else { @@ -188,6 +196,11 @@ else if (job.getState() != JobState.Canceling) { } } + private static boolean isJobBusy(JobState state) { + return state == JobState.Canceling || state == JobState.Scheduled || state == JobState.Queued + || state == JobState.Processing; + } + interface ComponentDelegate { void verifyEquals(String message, Object expected, Object actual); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 19b14c4653bac..4db3e29fc44ec 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -231,9 +231,11 @@ public void deleteJobSuccess() throws ServiceException, InterruptedException { JobInfo jobInfo = createJob(testJobPrefix + "deleteJobSuccess"); service.action(Job.cancel(jobInfo.getId())); JobInfo cancellingJobInfo = service.get(Job.get(jobInfo.getId())); - while (cancellingJobInfo.getState() == JobState.Canceling) { + int retryCounter = 0; + while (cancellingJobInfo.getState() == JobState.Canceling && retryCounter < 10) { Thread.sleep(2000); cancellingJobInfo = service.get(Job.get(jobInfo.getId())); + retryCounter++; } // Act @@ -296,9 +298,11 @@ public void canGetErrorDetailsFromTask() throws Exception { .addTaskCreator(getTaskCreator(0))); JobInfo currentJobInfo = actualJob; - while (currentJobInfo.getState().getCode() < 3) { + int retryCounter = 0; + while (currentJobInfo.getState().getCode() < 3 && retryCounter < 10) { + Thread.sleep(10000); currentJobInfo = service.get(Job.get(actualJob.getId())); - Thread.sleep(3000); + retryCounter++; } ListResult<TaskInfo> tasks = service.list(Task.list(actualJob.getTasksLink())); From f6359cc9ac9e2bf5f7147c3bd3d5f6fd425af53a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 19 Dec 2012 16:46:14 -0800 Subject: [PATCH 596/664] fix broken unit tests. --- .../entities/EntityOperation.java | 1 + .../services/media/models/Job.java | 2 - .../services/media/models/JobEntityTest.java | 50 ++++--------------- .../services/media/models/TaskEntityTest.java | 2 +- .../services/media/models/TaskInfoTest.java | 12 +++++ 5 files changed, 25 insertions(+), 42 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 83e0f68019c14..1dd29ef1270fe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -25,6 +25,7 @@ public interface EntityOperation { * Supplies the current proxy information to the action. * * @param proxyData + * @return */ void setProxyData(EntityProxyData proxyData); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index c3981313d10fe..f5de67a6b10a5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -143,8 +143,6 @@ private void buildMimeMultipart(URI serviceUri) { /** * Instantiates a new creator. * - * @param serviceUri - * the service uri */ public Creator() { super(ENTITY_SET, JobInfo.class); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index ba1a76356a88b..7112e586d2bae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -17,20 +17,16 @@ import static org.junit.Assert.*; -import java.io.IOException; -import java.io.InputStream; +import java.net.URI; -import javax.mail.BodyPart; -import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; import javax.ws.rs.core.MultivaluedMap; -import javax.xml.bind.JAXBException; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.implementation.ODataAtomUnmarshaller; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -38,26 +34,13 @@ */ public class JobEntityTest { - private JobInfo getJobInfo(MimeMultipart payload) throws MessagingException, IOException, JAXBException, - ServiceException { - for (int i = 0; i < payload.getCount(); i++) { - BodyPart bodyPart = payload.getBodyPart(i); - JobInfo jobInfo = parseBodyPart(bodyPart); - if (jobInfo != null) { - return jobInfo; + private EntityProxyData createProxyData() { + return new EntityProxyData() { + @Override + public URI getServiceUri() { + return URI.create("http://contoso.com"); } - } - - return null; - } - - private JobInfo parseBodyPart(BodyPart bodyPart) throws IOException, MessagingException, JAXBException, - ServiceException { - JobInfo jobInfo = null; - ODataAtomUnmarshaller oDataAtomUnmarshaller = new ODataAtomUnmarshaller(); - InputStream inputStream = bodyPart.getInputStream(); - jobInfo = oDataAtomUnmarshaller.unmarshalEntry(inputStream, JobInfo.class); - return jobInfo; + }; } public JobEntityTest() throws Exception { @@ -65,23 +48,12 @@ public JobEntityTest() throws Exception { @Test public void JobCreateReturnsDefaultCreatePayload() throws ServiceException { - MimeMultipart payload = (MimeMultipart) Job.create().getRequestContents(); + Job.Creator jobCreator = Job.create(); + jobCreator.setProxyData(createProxyData()); + MimeMultipart payload = (MimeMultipart) jobCreator.getRequestContents(); assertNotNull(payload); } - @Test - public void JobCreateCanSetJobName() throws ServiceException, MessagingException, IOException, JAXBException { - String expectedName = "JobCreateCanSetJobName"; - - Job.Creator creator = Job.create().setName(expectedName); - - MimeMultipart payload = (MimeMultipart) creator.getRequestContents(); - - JobInfo jobInfo = getJobInfo(payload); - - assertEquals(expectedName, jobInfo.getName()); - } - @Test public void JobListReturnsExpectedUri() { EntityListOperation<JobInfo> lister = Job.list(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index 982b1b548cf67..fc67311f4b2ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -176,7 +176,7 @@ public void taskCreateCanSetInitializationVector() { String expectedTaskBody = "expectedTaskBody"; TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody) - .setEncryptionKeyId(expectedInitializationVector).getEntryType()); + .setInitializationVector(expectedInitializationVector).getEntryType()); assertNotNull(taskType); assertEquals(expectedInitializationVector, taskType.getInitializationVector()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java index ca13178d0c5f7..887b8d1357cf8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -114,6 +114,7 @@ public void testGetSetName() { assertEquals(expectedOptions, actualOptions); } + @Test public void testGetSetPerfMessage() { // Arrange String expectedPerfMessage = "testGetSetPerfMessage"; @@ -126,6 +127,7 @@ public void testGetSetPerfMessage() { assertEquals(expectedPerfMessage, actualPerfMessage); } + @Test public void testGetSetPriority() { // Arrange int expectedPriority = 3; @@ -138,6 +140,7 @@ public void testGetSetPriority() { assertEquals(expectedPriority, actualPriority); } + @Test public void testGetSetProgress() { // Arrange double expectedProgress = 3; @@ -150,6 +153,7 @@ public void testGetSetProgress() { assertEquals(expectedProgress, actualProgress, 0.00001); } + @Test public void testGetSetRunningDuration() { // Arrange double expectedRunningDuration = 3; @@ -162,6 +166,7 @@ public void testGetSetRunningDuration() { assertEquals(expectedRunningDuration, actualRunningDuration, 0.00001); } + @Test public void testGetSetStartTime() { // Arrange Date expectedStartTime = new Date(); @@ -174,6 +179,7 @@ public void testGetSetStartTime() { assertEquals(expectedStartTime, actualStartTime); } + @Test public void testGetSetState() { // Arrange TaskState expectedState = TaskState.Completed; @@ -186,6 +192,7 @@ public void testGetSetState() { assertEquals(expectedState, actualState); } + @Test public void testGetSetTaskBody() { // Arrange String expectedTaskBody = "getSetTaskBody"; @@ -198,6 +205,7 @@ public void testGetSetTaskBody() { assertEquals(expectedTaskBody, actualTaskBody); } + @Test public void testGetSetOptions() { // Arrange TaskOption expectedTaskOption = TaskOption.ProtectedConfiguration; @@ -210,6 +218,7 @@ public void testGetSetOptions() { assertEquals(expectedTaskOption, actualTaskOption); } + @Test public void testGetSetEncryptionKeyId() { // Arrange String expectedEncryptionKeyId = "getSetEncryptionKeyId"; @@ -222,6 +231,7 @@ public void testGetSetEncryptionKeyId() { assertEquals(expectedEncryptionKeyId, actualEncryptionKeyId); } + @Test public void testGetSetEncryptionScheme() { // Arrange String expectedEncryptionScheme = "getSetEncryptionScheme"; @@ -234,6 +244,7 @@ public void testGetSetEncryptionScheme() { assertEquals(expectedEncryptionScheme, actualEncryptionScheme); } + @Test public void testGetSetEncryptionVersion() { // Arrange String expectedEncryptionVersion = "1.5"; @@ -246,6 +257,7 @@ public void testGetSetEncryptionVersion() { assertEquals(expectedEncryptionVersion, actualEncryptionVersion); } + @Test public void testGetSetInitializationVector() { // Arrange String expectedInitializationVector = "testInitializationVector"; From be47bb59d79aff1ccef543c0516e6d10e4c2c6ed Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 21 Dec 2012 16:25:16 -0800 Subject: [PATCH 597/664] Update the encryption scenario test to validate that the server can correctly decrypt the file (issue #575) Rework Encryption helper to remove dependency on Bouncy Castle (fewer dependencies are better) Removed "Microsoft-Internal" file, retargeted test to use unrestricted media file (issue #564) --- microsoft-azure-api/pom.xml | 6 - .../services/media/EncryptionHelper.java | 86 ++---- .../media/EncryptionIntegrationTest.java | 259 ++++++++++-------- .../services/media/IntegrationTestBase.java | 7 +- .../src/test/resources/media/SmallWMV.wmv | Bin 261862 -> 0 bytes 5 files changed, 176 insertions(+), 182 deletions(-) delete mode 100644 microsoft-azure-api/src/test/resources/media/SmallWMV.wmv diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 7f077b98424eb..b2a77405955dd 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -104,12 +104,6 @@ <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency> - <dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcprov-jdk16</artifactId> - <version>1.46</version> - <scope>test</scope> - </dependency> </dependencies> <build> diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index e7c2617372bc8..49f9c7f3159d1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -16,100 +16,50 @@ package com.microsoft.windowsazure.services.media; import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.InputStream; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.SecureRandom; -import java.security.cert.CertificateException; +import java.security.cert.Certificate; import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.Random; -import java.util.UUID; -import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import com.microsoft.windowsazure.services.core.storage.utils.Base64; -public class EncryptionHelper { - - public static byte[] createRandomVector(int numberOfBits) { - int numberOfBytes = numberOfBits / 8; - byte[] randomVector = new byte[numberOfBytes]; - Random random = new Random(); - random.nextBytes(randomVector); - return randomVector; - } - - public static byte[] EncryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { - - X509Certificate x509Certificate = createX509CertificateFromString(protectionKey); - return EncryptSymmetricKey(x509Certificate.getPublicKey(), inputData); - } - - private static X509Certificate createX509CertificateFromString(String protectionKey) throws CertificateException { +class EncryptionHelper { + public static byte[] encryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Base64.decode(protectionKey)); - X509Certificate x509cert = (X509Certificate) certificateFactory.generateCertificate(byteArrayInputStream); - return x509cert; - - } - - public static byte[] EncryptSymmetricKey(Key publicKey, byte[] inputData) throws NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, - BadPaddingException { - Cipher cipher = Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding", "BC"); + byte[] protectionKeyBytes = Base64.decode(protectionKey); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(protectionKeyBytes); + Certificate certificate = certificateFactory.generateCertificate(byteArrayInputStream); + Key publicKey = certificate.getPublicKey(); SecureRandom secureRandom = new SecureRandom(); cipher.init(Cipher.ENCRYPT_MODE, publicKey, secureRandom); byte[] cipherText = cipher.doFinal(inputData); return cipherText; } - public static String calculateChecksum(UUID uuid, byte[] aesKey) throws NoSuchAlgorithmException, - NoSuchProviderException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, - InvalidKeyException { + public static String calculateContentKeyChecksum(String uuid, byte[] aesKey) throws Exception { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey, "AES"); - Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING", "BC"); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); - byte[] encryptionResult = cipher.doFinal(uuid.toString().getBytes()); + byte[] encryptionResult = cipher.doFinal(uuid.getBytes("UTF8")); byte[] checksumByteArray = new byte[8]; - for (int i = 0; i < 8; i++) { - checksumByteArray[i] = encryptionResult[i]; - } + System.arraycopy(encryptionResult, 0, checksumByteArray, 0, 8); String checksum = Base64.encode(checksumByteArray); return checksum; } - public static byte[] EncryptFile(InputStream inputStream, byte[] aesKey, byte[] initializationVector) - throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, - InvalidAlgorithmParameterException, IOException { - // preparation - SecretKeySpec key = new SecretKeySpec(aesKey, "AES"); - IvParameterSpec ivParameterSpec = new IvParameterSpec(initializationVector); - Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding", "BC"); - - // encryption - cipher.init(Cipher.ENCRYPT_MODE, key, ivParameterSpec); + public static InputStream encryptFile(InputStream inputStream, byte[] key, byte[] iv) throws Exception { + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); + SecretKeySpec keySpec = new SecretKeySpec(key, "AES"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); + cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivParameterSpec); CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - - int ch; - while ((ch = cipherInputStream.read()) >= 0) { - byteArrayOutputStream.write(ch); - } - - byte[] cipherText = byteArrayOutputStream.toByteArray(); - return cipherText; + return cipherInputStream; } - } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index c6f2f0588b05e..1fd4fa3f36da0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -17,11 +17,13 @@ import static org.junit.Assert.*; -import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; -import java.security.Security; +import java.math.BigInteger; +import java.net.URL; import java.util.EnumSet; import java.util.List; +import java.util.Random; import java.util.UUID; import org.junit.Test; @@ -55,141 +57,184 @@ import com.microsoft.windowsazure.services.media.models.TaskState; public class EncryptionIntegrationTest extends IntegrationTestBase { - private final String strorageDecryptionProcessor = "Storage Decryption"; - private String createContentKeyId(UUID uuid) { - String randomContentKey = String.format("nb:kid:UUID:%s", uuid); - return randomContentKey; - } + @Test + public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { + // Arrange - private String getProtectionKeyId() throws ServiceException { - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); - return protectionKeyId; - } + // Media Services requires 256-bit (32-byte) keys + // and 128-bit (16-byte) initialization vectors (IV) for AES encryption, but also + // that only the first 8 bytes of the IV is is filled. + // Create static ones here for testing purposes. + Random random = new Random(); + byte[] aesKey = new byte[32]; + random.nextBytes(aesKey); + byte[] effectiveIv = new byte[8]; + random.nextBytes(effectiveIv); + byte[] iv = new byte[16]; + System.arraycopy(effectiveIv, 0, iv, 0, effectiveIv.length); + + InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/MPEG4-H264.mp4"); + InputStream encryptedContent = EncryptionHelper.encryptFile(smallWMVInputStream, aesKey, iv); + int durationInMinutes = 10; - private JobInfo decodeAsset(String name, AssetInfo assetInfo) throws ServiceException, InterruptedException { - MediaProcessorInfo mediaProcessorInfo = GetMediaProcessor(strorageDecryptionProcessor); - JobInfo jobInfo = createJob(name, assetInfo, mediaProcessorInfo); - return waitJobForCompletion(jobInfo); + // Act + AssetInfo assetInfo = service.create(Asset.create().setName(testAssetPrefix + "uploadAesProtectedAssetSuccess") + .setOptions(AssetOption.StorageEncrypted)); + WritableBlobContainerContract blobWriter = getBlobWriter(assetInfo.getId(), durationInMinutes); + + // gets the public key for storage encryption. + String contentKeyId = makeContentKeyId(aesKey); + + // link the content key with the asset. + service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyId)); + + // upload the encrypted file to the server. + uploadEncryptedAssetFile(assetInfo, blobWriter, "MPEG4-H264.mp4", encryptedContent, contentKeyId, iv); + + // submit and execute the decoding job. + JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo.getId()); + // assert + LinkInfo taskLinkInfo = jobInfo.getTasksLink(); + List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); + for (TaskInfo taskInfo : taskInfos) { + assertEquals(TaskState.Completed, taskInfo.getState()); + ListResult<AssetInfo> outputs = service.list(Asset.list(taskInfo.getOutputAssetsLink())); + assertEquals(1, outputs.size()); + } + assertEquals(JobState.Finished, jobInfo.getState()); + + // Verify that the contents match + InputStream expected = getClass().getResourceAsStream("/media/MPEG4-H264.mp4"); + + ListResult<AssetInfo> outputAssets = service.list(Asset.list(jobInfo.getOutputAssetsLink())); + assertEquals(1, outputAssets.size()); + AssetInfo outputAsset = outputAssets.get(0); + ListResult<AssetFileInfo> assetFiles = service.list(AssetFile.list(assetInfo.getAssetFilesLink())); + assertEquals(1, assetFiles.size()); + AssetFileInfo outputFile = assetFiles.get(0); + + InputStream actual = getFileContents(outputAsset.getId(), outputFile.getName(), durationInMinutes); + assertStreamsEqual(expected, actual); } - private JobInfo createJob(String name, AssetInfo assetInfo, MediaProcessorInfo mediaProcessorInfo) - throws ServiceException { - // String configuration = "H.264 256k DSL CBR"; + private JobInfo decodeAsset(String name, String inputAssetId) throws ServiceException, InterruptedException { + MediaProcessorInfo mediaProcessorInfo = service.list( + MediaProcessor.list().set("$filter", "Name eq '" + strorageDecryptionProcessor + "'")).get(0); + String taskBody = "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset><outputAsset assetCreationOptions=\"0\" assetName=\"Output\">JobOutputAsset(0)</outputAsset></taskBody>"; - JobInfo jobInfo = service.create(Job.create().addInputMediaAsset(assetInfo.getId()) + JobInfo jobInfo = service.create(Job.create().addInputMediaAsset(inputAssetId) .addTaskCreator(Task.create(mediaProcessorInfo.getId(), taskBody).setName(name))); - return jobInfo; - } - private JobInfo waitJobForCompletion(JobInfo jobInfo) throws ServiceException, InterruptedException { JobInfo currentJobInfo = jobInfo; - while (currentJobInfo.getState().getCode() < 3) { + int retryCounter = 0; + while (currentJobInfo.getState().getCode() < 3 && retryCounter < 10) { + Thread.sleep(10000); currentJobInfo = service.get(Job.get(jobInfo.getId())); - Thread.sleep(4000); + retryCounter++; } return currentJobInfo; } - private MediaProcessorInfo GetMediaProcessor(String mediaProcessorName) throws ServiceException { - List<MediaProcessorInfo> mediaProcessorInfos = service.list(MediaProcessor.list()); - for (MediaProcessorInfo mediaProcessorInfo : mediaProcessorInfos) { - if (mediaProcessorInfo.getName().equals(mediaProcessorName)) { - return mediaProcessorInfo; - } - } - return null; - } - - private String getProtectionKey(String protectionKeyId) throws ServiceException { + private String makeContentKeyId(byte[] aesKey) throws ServiceException, Exception { + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.StorageEncryption)); String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); - return protectionKey; - } - private AssetFileInfo uploadEncryptedAssetFile(AssetInfo assetInfo, LocatorInfo locatorInfo, - ContentKeyInfo contentKeyInfo, String blobName, byte[] encryptedContent) throws ServiceException { - WritableBlobContainerContract blobWriter = service.createBlobWriter(locatorInfo); - InputStream blobContent = new ByteArrayInputStream(encryptedContent); - blobWriter.createBlockBlob(blobName, blobContent); - AssetFileInfo assetFileInfo = service.create(AssetFile.create(assetInfo.getId(), blobName).setIsPrimary(true) - .setIsEncrypted(true).setContentFileSize(new Long(encryptedContent.length)) - .setEncryptionScheme("StorageEncryption").setEncryptionVersion("1.0") - .setEncryptionKeyId(contentKeyInfo.getId())); - return assetFileInfo; - } + String contentKeyIdUuid = UUID.randomUUID().toString(); + String contentKeyId = String.format("nb:kid:UUID:%s", contentKeyIdUuid); - private ContentKeyInfo createContentKey(byte[] aesKey, ContentKeyType contentKeyType, String protectionKeyId, - String protectionKey) throws Exception { - UUID contentKeyIdUuid = UUID.randomUUID(); - String contentKeyId = createContentKeyId(contentKeyIdUuid); - byte[] encryptedContentKey = EncryptionHelper.EncryptSymmetricKey(protectionKey, aesKey); + byte[] encryptedContentKey = EncryptionHelper.encryptSymmetricKey(protectionKey, aesKey); String encryptedContentKeyString = Base64.encode(encryptedContentKey); - String checksum = EncryptionHelper.calculateChecksum(contentKeyIdUuid, aesKey); + String checksum = EncryptionHelper.calculateContentKeyChecksum(contentKeyIdUuid, aesKey); + ContentKeyInfo contentKeyInfo = service.create(ContentKey - .create(contentKeyId, contentKeyType, encryptedContentKeyString).setChecksum(checksum) - .setProtectionKeyId(protectionKeyId)); - return contentKeyInfo; + .create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKeyString) + .setChecksum(checksum).setProtectionKeyId(protectionKeyId)); + return contentKeyInfo.getId(); } - @Test - public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { - // Arrange - Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); - InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/SmallWMV.wmv"); - byte[] aesKey = EncryptionHelper.createRandomVector(256); - byte[] initializationVector = EncryptionHelper.createRandomVector(128); - int durationInMinutes = 10; - - // Act - - // creates asset - AssetInfo assetInfo = service.create(Asset.create().setName("uploadAesProtectedAssetSuccess") - .setOptions(AssetOption.StorageEncrypted)); + private void uploadEncryptedAssetFile(AssetInfo asset, WritableBlobContainerContract blobWriter, String blobName, + InputStream blobContent, String encryptionKeyId, byte[] iv) throws ServiceException { + blobWriter.createBlockBlob(blobName, blobContent); + service.action(AssetFile.createFileInfos(asset.getId())); + ListResult<AssetFileInfo> files = service.list(AssetFile.list(asset.getAssetFilesLink()).set("$filter", + "Name eq '" + blobName + "'")); + assertEquals(1, files.size()); + AssetFileInfo file = files.get(0); + byte[] sub = new byte[9]; + // Offset bytes to ensure that the sign-bit is not set. + // Media Services expects unsigned Int64 values. + System.arraycopy(iv, 0, sub, 1, 8); + BigInteger longIv = new BigInteger(sub); + String initializationVector = longIv.toString(); + + service.update(AssetFile.update(file.getId()).setIsEncrypted(true).setEncryptionKeyId(encryptionKeyId) + .setEncryptionScheme("StorageEncryption").setEncryptionVersion("1.0") + .setInitializationVector(initializationVector)); + } - // creates writable access policy - AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create("uploadAesPortectedAssetSuccess", - durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + private WritableBlobContainerContract getBlobWriter(String assetId, int durationInMinutes) throws ServiceException { + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + + "uploadAesPortectedAssetSuccess", durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); // creates locator for the input media asset - LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetInfo.getId(), - LocatorType.SAS)); - - // gets the public key for storage encryption. - - String protectionKeyId = getProtectionKeyId(); - String protectionKey = getProtectionKey(protectionKeyId); - - // creates the content key with encrypted - ContentKeyInfo contentKeyInfo = createContentKey(aesKey, ContentKeyType.StorageEncryption, protectionKeyId, - protectionKey); - - // link the content key with the asset. - service.action(Asset.linkContentKey(assetInfo.getId(), contentKeyInfo.getId())); - - // encrypt the file. - byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); - - // upload the encrypted file to the server. - AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, - "uploadAesProtectedAssetSuccess", encryptedContent); - - // submit and execute the decoding job. - JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), assetId, LocatorType.SAS)); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locatorInfo); + return blobWriter; + } - // assert - LinkInfo taskLinkInfo = jobInfo.getTasksLink(); - List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); - for (TaskInfo taskInfo : taskInfos) { - assertEquals(TaskState.Completed, taskInfo.getState()); - ListResult<AssetInfo> outputs = service.list(Asset.list(taskInfo.getOutputAssetsLink())); - assertEquals(1, outputs.size()); + private InputStream getFileContents(String assetId, String fileName, int availabilityWindowInMinutes) + throws ServiceException, InterruptedException, IOException { + AccessPolicyInfo readAP = service.create(AccessPolicy.create(testPolicyPrefix + "tempAccessPolicy", + availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); + LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), assetId, LocatorType.SAS)); + URL file = new URL(readLocator.getBaseUri() + "/" + fileName + readLocator.getContentAccessToken()); + + // There can be a delay before a new read locator is applied for the asset files. + InputStream reader = null; + for (int counter = 0; true; counter++) { + try { + reader = file.openConnection().getInputStream(); + break; + } + catch (IOException e) { + System.out.println("Got error, wait a bit and try again"); + if (counter < 6) { + Thread.sleep(10000); + } + else { + // No more retries. + throw e; + } + } } - assertEquals(JobState.Finished, jobInfo.getState()); + return reader; } + private void assertStreamsEqual(InputStream inputStream1, InputStream inputStream2) throws IOException { + byte[] buffer1 = new byte[1024]; + byte[] buffer2 = new byte[1024]; + try { + while (true) { + int n1 = inputStream1.read(buffer1); + int n2 = inputStream2.read(buffer2); + assertEquals("number of bytes read from streams", n1, n2); + if (n1 == -1) { + break; + } + for (int i = 0; i < n1; i++) { + assertEquals("byte " + i + " read from streams", buffer1[i], buffer2[i]); + } + } + } + finally { + inputStream1.close(); + inputStream2.close(); + } + } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 04aef70e7c403..edb7ea64dc0e0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -96,7 +96,12 @@ private static void removeAllTestContentKeys() { List<ContentKeyInfo> contentKeyInfos = service.list(ContentKey.list()); for (ContentKeyInfo contentKeyInfo : contentKeyInfos) { - service.delete(ContentKey.delete(contentKeyInfo.getId())); + try { + service.delete(ContentKey.delete(contentKeyInfo.getId())); + } + catch (Exception e) { + e.printStackTrace(); + } } } catch (Exception e) { diff --git a/microsoft-azure-api/src/test/resources/media/SmallWMV.wmv b/microsoft-azure-api/src/test/resources/media/SmallWMV.wmv deleted file mode 100644 index 4a87490e1d15b7ea2a2b01ec13a0c393bbddcb4b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 261862 zcmeFZbyOY8)-T#D2=4AI+}+(>LvVt-ySsaWTd*WpAh<*D0Kwfo1Pd;~<*sD!bHDSQ z@xJlKc;nr_?(QC4Rb5kR)~}1zU9)P!MpNtY#&R5^co8TAOvmh%aDhJuJS2q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M)RMsw;r-6l|(-_eF=C;4Cf1$ zZo(moOfxBiH4KqJBRpuOR=rT5Dn9YVXelq@?$G{toQKZvANCm|Cgtxbz^YDx$`TrJ zL{t-k9F%qX1{H-0^`tPLfm84Z=dMvw@RigL_R-$|bTE~)-I4|zMDyp!W;3~zM9=aC z`}!&62?q0f)cuCmKdQk-GRT>L?ipSi8rC78UjBn_$J!>XpRhB^r$48(ia1T|7}?@v z1IY~()xdo-$!L&s)eX}$pQY(L2je1V>e|{xG%Ebt1QZjz0fyDAr%!8$QYB-drx`&^ zy`z*&l&bnmDBt;|GXhX?+ruHWF+OB|!}`@cPTKHlsvGXaMzsnm)<;am!tV$HPu1ke z+)N=8s)6>DhOCNQh<kgn+G3+@Ja9Ea-!G{6=!KF~TC=DxJ1(T9G1Kh=M9q9p(Mhk5 z=acix(=CZYY&M6c6Gm=5YWwWJ8@~UZe+m3c;9mm&68M+E|DOPw4j@_acj!j=0U)cF z3fli4PtoPGw?aleJnGG~(p0hEf62u$1}1*_Pch)7(*18)%KzN|xBmAwbs*q>^uGWL CeN#yQ From f88154a4fe536259cc8750d9f91835ea012173f0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 2 Jan 2013 16:22:37 -0800 Subject: [PATCH 598/664] initial check in for processing the response item. --- .../entities/DefaultActionOperation.java | 6 ++++ .../entities/DefaultListOperation.java | 6 ++++ .../entities/EntityCreationOperation.java | 10 ------ .../entities/EntityOperation.java | 11 +++++++ .../entities/EntityOperationBase.java | 7 ++++ .../entities/EntityRestProxy.java | 32 +++++++++++-------- 6 files changed, 48 insertions(+), 24 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index 80cea7a458940..82b0dc8fb2bde 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -18,6 +18,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -164,4 +165,9 @@ public String getVerb() { public Object getRequestContents() { return null; } + + @Override + public Object processResponse(Object rawResponse) throws ServiceException { + return rawResponse; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index 6b83791ebe7e1..7c697912e8c58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -17,6 +17,7 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ListResult; import com.sun.jersey.api.client.GenericType; import com.sun.jersey.core.util.MultivaluedMapImpl; @@ -94,4 +95,9 @@ public MultivaluedMap<String, String> getQueryParameters() { public GenericType<ListResult<T>> getResponseGenericType() { return responseType; } + + @Override + public Object processResponse(Object rawResponse) throws ServiceException { + return rawResponse; + } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java index aeef692228d90..07d489dc820e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreationOperation.java @@ -36,14 +36,4 @@ public interface EntityCreationOperation<T> extends EntityOperationSingleResult< */ Object getRequestContents() throws ServiceException; - /** - * Post response process. - * - * @param rawResponse - * the raw response - * @return the object - * @throws ServiceException - * the service exception - */ - Object processResponse(Object rawResponse) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 83e0f68019c14..26ad48c353108 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -47,4 +47,15 @@ public interface EntityOperation { * Get the MIME type that we're expecting the server to send back. */ public abstract MediaType getAcceptType(); + + /** + * Process response process. + * + * @param rawResponse + * the raw response + * @return the object + * @throws ServiceException + * the service exception + */ + public abstract Object processResponse(Object rawResponse) throws ServiceException; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index 3f5a99567f3b8..cfc5cd64f652a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -21,6 +21,8 @@ import javax.ws.rs.core.MediaType; +import com.microsoft.windowsazure.services.core.ServiceException; + /** * Default implementation of EntityOperation<T> to provide * default values for common methods. @@ -87,6 +89,11 @@ public MediaType getAcceptType() { return MediaType.APPLICATION_ATOM_XML_TYPE; } + @Override + public Object processResponse(Object rawResponse) throws ServiceException { + return rawResponse; + } + public interface EntityUriBuilder { String getUri(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index f2b8fdf039f82..7a46a11dc4994 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -99,8 +99,7 @@ private WebResource getResource(String entityName) { * @throws ServiceException */ private Builder getResource(EntityOperation operation) throws ServiceException { - return getResource(operation.getUri()).type(operation.getContentType()).accept( - operation.getAcceptType()); + return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); } /* (non-Javadoc) @@ -110,8 +109,7 @@ private Builder getResource(EntityOperation operation) throws ServiceException { @Override public <T> T create(EntityCreationOperation<T> creator) throws ServiceException { creator.setProxyData(createProxyData()); - Object rawResponse = getResource(creator).post(creator.getResponseClass(), - creator.getRequestContents()); + Object rawResponse = getResource(creator).post(creator.getResponseClass(), creator.getRequestContents()); Object processedResponse = creator.processResponse(rawResponse); return (T) processedResponse; } @@ -119,21 +117,27 @@ public <T> T create(EntityCreationOperation<T> creator) throws ServiceException /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation) */ + @SuppressWarnings("unchecked") @Override public <T> T get(EntityGetOperation<T> getter) throws ServiceException { getter.setProxyData(createProxyData()); - return getResource(getter).get(getter.getResponseClass()); + Object rawResponse = getResource(getter).get(getter.getResponseClass()); + Object processedResponse = getter.processResponse(rawResponse); + return (T) processedResponse; } /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation) */ + @SuppressWarnings("unchecked") @Override public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { lister.setProxyData(createProxyData()); - return getResource(lister.getUri()).queryParams(lister.getQueryParameters()) - .type(lister.getContentType()).accept(lister.getAcceptType()) - .get(lister.getResponseGenericType()); + Object rawResponse = getResource(lister.getUri()).queryParams(lister.getQueryParameters()) + .type(lister.getContentType()).accept(lister.getAcceptType()).get(lister.getResponseGenericType()); + Object processedResponse = lister.processResponse(rawResponse); + return (ListResult<T>) processedResponse; + } /* (non-Javadoc) @@ -142,10 +146,10 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep @Override public void update(EntityUpdateOperation updater) throws ServiceException { updater.setProxyData(createProxyData()); - ClientResponse response = getResource(updater).header("X-HTTP-METHOD", "MERGE").post( - ClientResponse.class, updater.getRequestContents()); - - PipelineHelpers.ThrowIfNotSuccess(response); + Object rawResponse = getResource(updater).header("X-HTTP-METHOD", "MERGE").post(ClientResponse.class, + updater.getRequestContents()); + PipelineHelpers.ThrowIfNotSuccess((ClientResponse) rawResponse); + updater.processResponse(rawResponse); } /* (non-Javadoc) @@ -165,8 +169,8 @@ public Object action(EntityActionOperation entityActionOperation) throws Service entityActionOperation.setProxyData(createProxyData()); Builder webResource = getResource(entityActionOperation.getUri()) - .queryParams(entityActionOperation.getQueryParameters()) - .accept(entityActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE) + .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType()) + .accept(MediaType.APPLICATION_XML_TYPE) .entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class); return entityActionOperation.processResponse(clientResponse); From 1dc49050d39f5cca5f1e2cc1d48f72d937843a4a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 2 Jan 2013 17:01:13 -0800 Subject: [PATCH 599/664] clean up the code. --- .../entities/DefaultListOperation.java | 3 ++ .../entities/EntityOperationBase.java | 42 ++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index 7c697912e8c58..f55d188492f58 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -96,6 +96,9 @@ public GenericType<ListResult<T>> getResponseGenericType() { return responseType; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#processResponse(java.lang.Object) + */ @Override public Object processResponse(Object rawResponse) throws ServiceException { return rawResponse; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index cfc5cd64f652a..8e68fccb6eadd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -29,11 +29,18 @@ * */ public abstract class EntityOperationBase implements EntityOperation { + + /** The uri builder. */ private final EntityUriBuilder uriBuilder; + + /** The proxy data. */ private EntityProxyData proxyData; /** + * Instantiates a new entity operation base. * + * @param uri + * the uri */ protected EntityOperationBase(final String uri) { this.uriBuilder = new EntityUriBuilder() { @@ -44,6 +51,12 @@ public String getUri() { }; } + /** + * Instantiates a new entity operation base. + * + * @param uriBuilder + * the uri builder + */ protected EntityOperationBase(EntityUriBuilder uriBuilder) { this.uriBuilder = uriBuilder; } @@ -57,7 +70,7 @@ public void setProxyData(EntityProxyData proxyData) { } /** - * Get the currently set proxy data + * Get the currently set proxy data. * * @return the proxy data */ @@ -89,19 +102,46 @@ public MediaType getAcceptType() { return MediaType.APPLICATION_ATOM_XML_TYPE; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + */ @Override public Object processResponse(Object rawResponse) throws ServiceException { return rawResponse; } + /** + * The Interface EntityUriBuilder. + */ public interface EntityUriBuilder { + + /** + * Gets the uri. + * + * @return the uri + */ String getUri(); } + /** + * The Class EntityIdUriBuilder. + */ public static class EntityIdUriBuilder implements EntityUriBuilder { + + /** The entity type. */ private final String entityType; + + /** The entity id. */ private final String entityId; + /** + * Instantiates a new entity id uri builder. + * + * @param entityName + * the entity name + * @param entityId + * the entity id + */ public EntityIdUriBuilder(String entityName, String entityId) { super(); this.entityType = entityName; From 95b5c1b6348be73d9affce167005346cd6018fae Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 3 Jan 2013 15:03:25 -0800 Subject: [PATCH 600/664] initial check in for non-nullable properties. --- .../services/media/models/AssetFileInfo.java | 6 +++--- .../services/media/models/JobInfo.java | 4 ++-- .../services/media/models/TaskInfo.java | 4 ++-- .../services/media/JobIntegrationTest.java | 3 ++- .../media/models/AssetFileInfoTest.java | 20 ++++++++++++------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java index b4ca2ee5add04..efc91b1d671cb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java @@ -57,7 +57,7 @@ public String getName() { * * @return the content file size */ - public Long getContentFileSize() { + public long getContentFileSize() { return this.getContent().getContentFileSize(); } @@ -93,7 +93,7 @@ public String getEncryptionScheme() { * * @return the checks if is encrypted */ - public Boolean getIsEncrypted() { + public boolean getIsEncrypted() { return this.getContent().getIsEncrypted(); } @@ -120,7 +120,7 @@ public String getInitializationVector() { * * @return the checks if is primary */ - public Boolean getIsPrimary() { + public boolean getIsPrimary() { return this.getContent().getIsPrimary(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 16cb8149547a1..36d3ac99e4b93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -89,7 +89,7 @@ public Date getEndTime() { * * @return the priority */ - public Integer getPriority() { + public int getPriority() { return getContent().getPriority(); } @@ -98,7 +98,7 @@ public Integer getPriority() { * * @return the running duration */ - public Double getRunningDuration() { + public double getRunningDuration() { return getContent().getRunningDuration(); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 3de34cdfb716b..fa6cc3ee89dbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -118,7 +118,7 @@ public String getPerfMessage() { * * @return the priority */ - public Integer getPriority() { + public int getPriority() { return getContent().getPriority(); } @@ -127,7 +127,7 @@ public Integer getPriority() { * * @return the progress */ - public Double getProgress() { + public double getProgress() { return getContent().getProgress(); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 81ec1f70beaf4..80d8295afa852 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -56,7 +56,8 @@ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual expected.getStartTime(), expected.getEndTime(), actual); } - private void verifyJobProperties(String message, String testName, Integer priority, Double runningDuration, + @SuppressWarnings("deprecation") + private void verifyJobProperties(String message, String testName, Integer priority, double runningDuration, JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime, JobInfo actualJob) { assertNotNull(message, actualJob); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java index 455fc336ebf6c..28eac36a9ce68 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java @@ -50,10 +50,11 @@ public void testGetSetName() { public void testGetSetContentFileSize() { // Arrange Long expectedContentFileSize = 1234l; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setContentFileSize(expectedContentFileSize)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setContentFileSize(expectedContentFileSize)); // Act - long actualContentFileSize = fileInfo.getContentFileSize().longValue(); + long actualContentFileSize = fileInfo.getContentFileSize(); // Assert assertEquals(expectedContentFileSize.longValue(), actualContentFileSize); @@ -73,7 +74,8 @@ public void testGetSetParentAssetId() { @Test public void testGetSetEncryptionVersion() { String expectedEncryptionVersion = "testEncryptionVersion"; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionVersion(expectedEncryptionVersion)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setEncryptionVersion(expectedEncryptionVersion)); String actualEncryptionVersion = fileInfo.getEncryptionVersion(); @@ -84,7 +86,8 @@ public void testGetSetEncryptionVersion() { public void testGetSetEncryptionScheme() { // Arrange String expectedEncryptionScheme = "testEncryptionScheme"; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionScheme(expectedEncryptionScheme)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setEncryptionScheme(expectedEncryptionScheme)); // Act String actualEncryptionScheme = fileInfo.getEncryptionScheme(); @@ -109,7 +112,8 @@ public void testGetSetIsEncrypted() { @Test public void testGetSetEncryptionKeyId() { String expectedEncryptionKeyId = "testEncryptionKeyId"; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setEncryptionKeyId(expectedEncryptionKeyId)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setEncryptionKeyId(expectedEncryptionKeyId)); String actualEncryptionKeyId = fileInfo.getEncryptionKeyId(); @@ -119,7 +123,8 @@ public void testGetSetEncryptionKeyId() { @Test public void testGetSetInitializationVector() { String expectedInitializationVector = "testInitializationVector"; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setInitializationVector(expectedInitializationVector)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setInitializationVector(expectedInitializationVector)); String actualInitializationVector = fileInfo.getInitializationVector(); @@ -173,7 +178,8 @@ public void testGetSetMimeType() { @Test public void testGetSetContentChecksum() { String expectedContentChecksum = "testContentChecksum"; - AssetFileInfo fileInfo = new AssetFileInfo(null, new AssetFileType().setContentChecksum(expectedContentChecksum)); + AssetFileInfo fileInfo = new AssetFileInfo(null, + new AssetFileType().setContentChecksum(expectedContentChecksum)); String actualContentChecksum = fileInfo.getContentChecksum(); From b515da0f3276c0bc68c569ebb1e78bba6872419e Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 3 Jan 2013 15:39:47 -0800 Subject: [PATCH 601/664] remove unused properties. --- .../services/media/models/LinkInfo.java | 27 ------------------- .../implementation/LinkRetrievalTest.java | 3 --- 2 files changed, 30 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java index 0acf7e6b2e431..9f25a1c1835f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -31,24 +31,6 @@ public LinkInfo(LinkType rawLink) { this.rawLink = rawLink; } - /** - * Get link rel - * - * @return the rel - */ - public String getRel() { - return rawLink.getRel(); - } - - /** - * Get link type - * - * @return the type - */ - public String getType() { - return rawLink.getType(); - } - /** * Get link href * @@ -57,13 +39,4 @@ public String getType() { public String getHref() { return rawLink.getHref(); } - - /** - * Get link title - * - * @return the title - */ - public String getTitle() { - return rawLink.getTitle(); - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 56ff698b68c32..6b050376bc04c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -106,9 +106,6 @@ public void getLinksReturnsTwoExpectedLinksInOrder() { } private static void assertLinksEqual(LinkType expected, LinkInfo actual) { - assertEquals(expected.getTitle(), actual.getTitle()); - assertEquals(expected.getRel(), actual.getRel()); assertEquals(expected.getHref(), actual.getHref()); - assertEquals(expected.getType(), actual.getType()); } } From 67f183da117447e855f961caa4041449af900e5d Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 3 Jan 2013 15:41:53 -0800 Subject: [PATCH 602/664] remove linkinfo properties --- .../services/media/models/LinkInfo.java | 27 ------------------- .../implementation/LinkRetrievalTest.java | 3 --- 2 files changed, 30 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java index 0acf7e6b2e431..9f25a1c1835f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -31,24 +31,6 @@ public LinkInfo(LinkType rawLink) { this.rawLink = rawLink; } - /** - * Get link rel - * - * @return the rel - */ - public String getRel() { - return rawLink.getRel(); - } - - /** - * Get link type - * - * @return the type - */ - public String getType() { - return rawLink.getType(); - } - /** * Get link href * @@ -57,13 +39,4 @@ public String getType() { public String getHref() { return rawLink.getHref(); } - - /** - * Get link title - * - * @return the title - */ - public String getTitle() { - return rawLink.getTitle(); - } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 56ff698b68c32..6b050376bc04c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -106,9 +106,6 @@ public void getLinksReturnsTwoExpectedLinksInOrder() { } private static void assertLinksEqual(LinkType expected, LinkInfo actual) { - assertEquals(expected.getTitle(), actual.getTitle()); - assertEquals(expected.getRel(), actual.getRel()); assertEquals(expected.getHref(), actual.getHref()); - assertEquals(expected.getType(), actual.getType()); } } From 9152051fc6c89f43bd22d7cc5f306b193d2c0469 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 3 Jan 2013 16:51:24 -0800 Subject: [PATCH 603/664] parameter name in the content key should be camel cased. --- .../windowsazure/services/media/models/ContentKey.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index e5ed4d3e4ff97..fbe721ea718d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -178,8 +178,8 @@ public Creator setProtectionKeyType(ProtectionKeyType protectionKeyType) { * id of content key to retrieve * @return the operation */ - public static EntityGetOperation<ContentKeyInfo> get(String ContentKeyId) { - return new DefaultGetOperation<ContentKeyInfo>(ENTITY_SET, ContentKeyId, ContentKeyInfo.class); + public static EntityGetOperation<ContentKeyInfo> get(String contentKeyId) { + return new DefaultGetOperation<ContentKeyInfo>(ENTITY_SET, contentKeyId, ContentKeyInfo.class); } /** @@ -223,8 +223,8 @@ public static DefaultListOperation<ContentKeyInfo> list(LinkInfo link) { * id of content key to delete * @return the delete operation */ - public static EntityDeleteOperation delete(String ContentKeyId) { - return new DefaultDeleteOperation(ENTITY_SET, ContentKeyId); + public static EntityDeleteOperation delete(String contentKeyId) { + return new DefaultDeleteOperation(ENTITY_SET, contentKeyId); } } From 443ee64303d9d0194c27852e1bba8cb3abde0653 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Thu, 3 Jan 2013 17:10:29 -0800 Subject: [PATCH 604/664] entity link operation policheck issue. --- .../implementation/entities/EntityLinkOperation.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index 92e8cd2ce8662..62bcaea346e92 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -47,10 +47,10 @@ public class EntityLinkOperation extends DefaultActionOperation { /** The master entity id. */ private final String primaryEntityId; - /** The slave entity set. */ + /** The secondary entity set. */ private final String secondaryEntitySet; - /** The slave entity uri. */ + /** The secondary entity uri. */ private final URI secondaryEntityUri; /** The jaxb context. */ @@ -69,13 +69,13 @@ public class EntityLinkOperation extends DefaultActionOperation { * Instantiates a new entity link operation. * * @param primaryEntitySet - * the master entity set + * the primary entity set * @param primaryEntityId - * the master entity id + * the primary entity id * @param secondaryEntitySet - * the slave entity set + * the secondary entity set * @param secondaryEntityUri - * the slave entity uri + * the secondary entity uri */ public EntityLinkOperation(String primaryEntitySet, String primaryEntityId, String secondaryEntitySet, URI secondaryEntityUri) { From f67a73358448a3f6bf79284e1c2ba2b5af6e5f40 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 4 Jan 2013 16:09:01 -0800 Subject: [PATCH 605/664] fix the minor javadoc udpate for media service --- .../microsoft/windowsazure/services/media/models/Asset.java | 4 ++-- .../microsoft/windowsazure/services/media/models/Task.java | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 68b364053ece8..63147b5a040ce 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -301,8 +301,8 @@ public static EntityDeleteOperation delete(String assetId) { * * @param assetId * the asset id - * @param contentKeyUri - * the content key uri + * @param contentKeyId + * the content key id * @return the entity action operation */ public static EntityLinkOperation linkContentKey(String assetId, String contentKeyId) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 0b6429d6c7f35..1e8d6734a2ec0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -45,8 +45,6 @@ private Task() { * the media processor id * @param taskBody * the task body - * @param options - * the options * @return the creates the batch operation */ public static CreateBatchOperation create(String mediaProcessorId, String taskBody) { @@ -102,8 +100,6 @@ public static class CreateBatchOperation extends EntityBatchOperation { * the media processor id * @param taskBody * the task body - * @param options - * the options */ public CreateBatchOperation(String mediaProcessorId, String taskBody) { this.verb = "POST"; From b744e44812519e46c07f89eb109821d7d2059d50 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 4 Jan 2013 17:03:03 -0800 Subject: [PATCH 606/664] double retry count to wait a little bit longer. --- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 4db3e29fc44ec..d37d407763051 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -299,7 +299,7 @@ public void canGetErrorDetailsFromTask() throws Exception { JobInfo currentJobInfo = actualJob; int retryCounter = 0; - while (currentJobInfo.getState().getCode() < 3 && retryCounter < 10) { + while (currentJobInfo.getState().getCode() < 3 && retryCounter < 20) { Thread.sleep(10000); currentJobInfo = service.get(Job.get(actualJob.getId())); retryCounter++; From 69aa5114d20d0d9b1670cff16cec6dce08241330 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 4 Jan 2013 17:27:35 -0800 Subject: [PATCH 607/664] stop adding https to media service uri. --- .../services/media/MediaConfiguration.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index e3d207f848ed9..e7e10c686f744 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -55,8 +55,8 @@ public class MediaConfiguration { * Creates a media service configuration using the specified media service base URI, OAUTH URI, * client ID, and client secret. * - * @param mediaServiceBaseUri - * A <code>String</code> object that represents the media service base URI. + * @param mediaServiceUri + * A <code>String</code> object that represents the media service URI. * * @param oAuthUri * A <code>String</code> object that represents the OAUTH URI. @@ -75,9 +75,9 @@ public class MediaConfiguration { * <code>MediaService</code> class. * */ - public static Configuration configureWithOAuthAuthentication(String mediaServiceBaseUri, String oAuthUri, + public static Configuration configureWithOAuthAuthentication(String mediaServiceUri, String oAuthUri, String clientId, String clientSecret, String scope) { - return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceBaseUri, oAuthUri, + return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceUri, oAuthUri, clientId, clientSecret, scope); } @@ -88,8 +88,8 @@ public static Configuration configureWithOAuthAuthentication(String mediaService * @param configuration * A previously instantiated <code>Configuration</code> object. * - * @param mediaServiceBaseUri - * A <code>String</code> object that represents the base URI of Media service. + * @param mediaServiceUri + * A <code>String</code> object that represents the URI of media service. * * @param oAuthUri * A <code>String</code> object that represents the URI of OAuth service. @@ -109,7 +109,7 @@ public static Configuration configureWithOAuthAuthentication(String mediaService * */ public static Configuration configureWithOAuthAuthentication(Configuration configuration, - String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret, String scope) { + String mediaServiceUri, String oAuthUri, String clientId, String clientSecret, String scope) { return configureWithOAuthAuthentication(null, configuration, mediaServiceBaseUri, oAuthUri, clientId, clientSecret, scope); } @@ -124,8 +124,8 @@ public static Configuration configureWithOAuthAuthentication(Configuration confi * @param configuration * A previously instantiated <code>Configuration</code> object. * - * @param mediaServiceBaseUri - * A <code>String</code> object that represents the base URI of media service. + * @param mediaServiceUri + * A <code>String</code> object that represents the URI of media service. * * @param oAuthUri * A <code>String</code> object that represents the URI of OAUTH service. @@ -145,7 +145,7 @@ public static Configuration configureWithOAuthAuthentication(Configuration confi * */ public static Configuration configureWithOAuthAuthentication(String profile, Configuration configuration, - String mediaServiceBaseUri, String oAuthUri, String clientId, String clientSecret, String scope) { + String mediaServiceUri, String oAuthUri, String clientId, String clientSecret, String scope) { if (profile == null) { profile = ""; @@ -154,7 +154,7 @@ else if (profile.length() != 0 && !profile.endsWith(".")) { profile = profile + "."; } - configuration.setProperty(profile + URI, "https://" + mediaServiceBaseUri); + configuration.setProperty(profile + URI, mediaServiceUri); configuration.setProperty(profile + OAUTH_URI, oAuthUri); configuration.setProperty(profile + OAUTH_CLIENT_ID, clientId); configuration.setProperty(profile + OAUTH_CLIENT_SECRET, clientSecret); From 1b0c74eae889befdf2d39af73c62b7200557668f Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 7 Jan 2013 10:30:22 -0800 Subject: [PATCH 608/664] Fixing unclear comment and variable name --- .../services/media/EncryptionIntegrationTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 1fd4fa3f36da0..071d5b7e1c7ba 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -63,10 +63,9 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange - // Media Services requires 256-bit (32-byte) keys - // and 128-bit (16-byte) initialization vectors (IV) for AES encryption, but also - // that only the first 8 bytes of the IV is is filled. - // Create static ones here for testing purposes. + // Media Services requires 256-bit (32-byte) keys and + // 128-bit (16-byte) initialization vectors (IV) for AES encryption, + // and also requires that only the first 8 bytes of the IV is filled. Random random = new Random(); byte[] aesKey = new byte[32]; random.nextBytes(aesKey); @@ -75,8 +74,8 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { byte[] iv = new byte[16]; System.arraycopy(effectiveIv, 0, iv, 0, effectiveIv.length); - InputStream smallWMVInputStream = getClass().getResourceAsStream("/media/MPEG4-H264.mp4"); - InputStream encryptedContent = EncryptionHelper.encryptFile(smallWMVInputStream, aesKey, iv); + InputStream mpeg4H264InputStream = getClass().getResourceAsStream("/media/MPEG4-H264.mp4"); + InputStream encryptedContent = EncryptionHelper.encryptFile(mpeg4H264InputStream, aesKey, iv); int durationInMinutes = 10; // Act From 66360c4f2dac7f6e068e9d883096efc3c91c39a2 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 13:01:08 -0800 Subject: [PATCH 609/664] fix a broken unit test --- .../windowsazure/services/media/TaskIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index e1c23729712a5..e3434db0da597 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -211,7 +211,7 @@ private void verifyTaskProperties(String message, String mediaProcessorId, TaskO // Optional fields assertEquals(message + " getConfiguration", configuration, actual.getConfiguration()); assertEquals(message + " getName", name, actual.getName()); - assertEquals(message + " getPriority", priority, actual.getPriority().intValue()); + assertEquals(message + " getPriority", priority, actual.getPriority()); // Optional encryption fields assertEqualsNullEmpty(message + " getEncryptionKeyId", encryptionKeyId, actual.getEncryptionKeyId()); @@ -239,7 +239,7 @@ private void verifyTaskProperties(String message, String mediaProcessorId, TaskO assertTrue(message + " outputAssets.get(0).getId != assetInfo.getId", !assetInfo.getId().equals(outputAssets.get(0).getId())); - assertEquals(message + " getProgress", progress, actual.getProgress().doubleValue(), 0.01); + assertEquals(message + " getProgress", progress, actual.getProgress(), 0.01); assertEquals(message + " getRunningDuration", runningDuration, actual.getRunningDuration(), 0.01); assertDateApproxEquals(message + " getStartTime", startTime, actual.getStartTime()); assertEquals(message + " getState", state, actual.getState()); From 048b12e362ea30705fa7ab34f85c8dd3e2eaa883 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 13:22:12 -0800 Subject: [PATCH 610/664] a missed file. --- .../services/media/MediaConfiguration.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index e7e10c686f744..da6d1910cacbc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -77,8 +77,8 @@ public class MediaConfiguration { */ public static Configuration configureWithOAuthAuthentication(String mediaServiceUri, String oAuthUri, String clientId, String clientSecret, String scope) { - return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceUri, oAuthUri, - clientId, clientSecret, scope); + return configureWithOAuthAuthentication(null, Configuration.getInstance(), mediaServiceUri, oAuthUri, clientId, + clientSecret, scope); } /** @@ -108,10 +108,10 @@ public static Configuration configureWithOAuthAuthentication(String mediaService * <code>MediaService</code> class. * */ - public static Configuration configureWithOAuthAuthentication(Configuration configuration, - String mediaServiceUri, String oAuthUri, String clientId, String clientSecret, String scope) { - return configureWithOAuthAuthentication(null, configuration, mediaServiceBaseUri, oAuthUri, clientId, - clientSecret, scope); + public static Configuration configureWithOAuthAuthentication(Configuration configuration, String mediaServiceUri, + String oAuthUri, String clientId, String clientSecret, String scope) { + return configureWithOAuthAuthentication(null, configuration, mediaServiceUri, oAuthUri, clientId, clientSecret, + scope); } /** From ccb2460be954143f947080e240be8358e2f6b681 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 13:24:02 -0800 Subject: [PATCH 611/664] a missed unit test file. --- .../services/media/MediaConfigurationTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java index 4842f9e3a1434..a67319c6cf8ab 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -28,8 +28,8 @@ public void createMediaConfigurationTestSuccess() { // Arrange // Act - Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testMediaServiceBaseUri", - "testOAuthUri", "testClientId", "testClientSecret", "testScope"); + Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication( + "https://testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", "testScope"); // Assert assertEquals("https://testMediaServiceBaseUri", configuration.getProperty("media.uri")); @@ -47,7 +47,7 @@ public void createMediaConfigurationPassingExistingConfigurationSuccess() { // Act Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(preConfiguration, - "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", "testScope"); + "https://testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", "testScope"); // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); @@ -66,8 +66,8 @@ public void createMediaConfigurationWithProfileConfigurationSuccess() { // Act Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication("testProfile", - preConfiguration, "testMediaServiceBaseUri", "testOAuthUri", "testClientId", "testClientSecret", - "testScope"); + preConfiguration, "https://testMediaServiceBaseUri", "testOAuthUri", "testClientId", + "testClientSecret", "testScope"); // Assert assertEquals("preexistingValue", configuration.getProperty("preexistingName")); From beab3ca058dd0842fba0c3880a17b2d23012fe64 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 15:41:46 -0800 Subject: [PATCH 612/664] code review feedback. --- .../media/implementation/entities/EntityLinkOperation.java | 4 ++-- .../windowsazure/services/media/JobIntegrationTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index 62bcaea346e92..d726e4f1caf93 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -41,10 +41,10 @@ */ public class EntityLinkOperation extends DefaultActionOperation { - /** The master entity set. */ + /** The primary entity set. */ private final String primaryEntitySet; - /** The master entity id. */ + /** The primary entity id. */ private final String primaryEntityId; /** The secondary entity set. */ diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 6778812a5e579..fcd0f4111099a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -57,7 +57,7 @@ private void verifyJobProperties(String message, String testName, Integer priori assertEquals(message + " Name", testName, actualJob.getName()); // comment out due to issue 464 // assertEquals(message + " Priority", priority, actualJob.getPriority()); - assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration()); + assertEquals(message + " RunningDuration", runningDuration, actualJob.getRunningDuration(), 0.001); assertEquals(message + " State", state, actualJob.getState()); assertEqualsNullEmpty(message + " TemplateId", templateId, actualJob.getTemplateId()); @@ -300,7 +300,7 @@ public void canGetErrorDetailsFromTask() throws Exception { JobInfo currentJobInfo = actualJob; int retryCounter = 0; - while (currentJobInfo.getState().getCode() < 3 && retryCounter < 20) { + while (currentJobInfo.getState().getCode() < 3 && retryCounter < 30) { Thread.sleep(10000); currentJobInfo = service.get(Job.get(actualJob.getId())); retryCounter++; From a90fe56b58553d842b92502cc5e64acf8e067ff4 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 15:59:11 -0800 Subject: [PATCH 613/664] fix the policheck issue for README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a49e66e0493b6..94ab4da4a363b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For documentation please see the [Windows Azure Java Developer Center](http://ww * Retrieve information about the state of your Azure Compute instances * Table * Manage Tables - * Work with Table Entities (CRUD) + * Table Entity Operations * Entity Group Transactions (Batch) #Getting Started From d5d85068646b8ad66a7a4c92b6ce7c8e70a47c72 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 7 Jan 2013 16:25:31 -0800 Subject: [PATCH 614/664] convert to dev style java doc for writeable blob container contract. --- .../media/WritableBlobContainerContract.java | 117 +++++------------- 1 file changed, 32 insertions(+), 85 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java index 412d7dc2fc0f1..811110c669050 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java @@ -26,146 +26,93 @@ import com.microsoft.windowsazure.services.core.ServiceException; /** - * Contract for uploading media files to blob storage managed - * by Media Services. - * + * The Interface WritableBlobContainerContract. */ public interface WritableBlobContainerContract extends FilterableService<WritableBlobContainerContract> { /** - * Creates a block blob from a content stream. + * Creates the block blob. * * @param blob - * A {@link String} containing the name of the blob to create. A blob name can contain any combination of - * characters, but reserved URL characters must be properly escaped. A blob name must be at least one - * character long and cannot be more than 1,024 characters long, and must be unique within the container. + * the blob * @param contentStream - * An {@link InputStream} reference to the content stream to upload to the new blob. + * the content stream + * @return the creates the blob result * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ CreateBlobResult createBlockBlob(String blob, InputStream contentStream) throws ServiceException; /** - * Creates a block blob from a content stream, using the specified options. - * <p> - * Use the {@link CreateBlobOptions options} parameter to optionally specify the server timeout for the operation, - * the MIME content type and content encoding for the blob, the content language, the MD5 hash, a cache control - * value, and blob metadata. + * Creates the block blob. * * @param blob - * A {@link String} containing the name of the blob to create. A blob name can contain any combination of - * characters, but reserved URL characters must be properly escaped. A blob name must be at least one - * character long and cannot be more than 1,024 characters long, and must be unique within the container. + * the blob * @param contentStream - * An {@link InputStream} reference to the content to upload to the new blob. + * the content stream * @param options - * A {@link CreateBlobOptions} instance containing options for the request. + * the options + * @return the creates the blob result * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ CreateBlobResult createBlockBlob(String blob, InputStream contentStream, CreateBlobOptions options) throws ServiceException; /** - * Creates a new uncommited block from a content stream. - * <p> - * This method creates an uncommitted block for a block blob specified by the <em>blob</em> and <em>container</em> - * parameters. The <em>blockId</em> parameter is a client-specified ID for the block, which must be less than or - * equal to 64 bytes in size. For a given blob, the length of the value specified for the <em>blockId</em> parameter - * must be the same size for each block. The <em>contentStream</em> parameter specifies the content to be copied to - * the block. The content for the block must be less than or equal to 4 MB in size. - * <p> - * To create or update a block blob, the blocks that have been successfully written to the server with this method - * must be committed using a call to {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList)} or - * {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList, CommitBlobBlocksOptions)}. + * Creates the blob block. * * @param blob - * A {@link String} containing the name of the blob to create the block for. + * the blob * @param blockId - * A {@link String} containing a client-specified ID for the block. + * the block id * @param contentStream - * An {@link InputStream} reference to the content to copy to the block. + * the content stream * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ void createBlobBlock(String blob, String blockId, InputStream contentStream) throws ServiceException; /** - * Creates a new uncommitted block from a content stream, using the specified options. - * <p> - * This method creates an uncommitted block for a block blob specified by the <em>blob</em> and <em>container</em> - * parameters. The <em>blockId</em> parameter is a client-specified ID for the block, which must be less than or - * equal to 64 bytes in size. For a given blob, the length of the value specified for the <em>blockId</em> parameter - * must be the same size for each block. The <em>contentStream</em> parameter specifies the content to be copied to - * the block. The content for the block must be less than or equal to 4 MB in size. Use the - * {@link CreateBlobBlockOptions options} parameter to optionally specify the server timeout for the operation, the - * lease ID if the blob has an active lease, and the MD5 hash value for the block content. - * <p> - * To create or update a block blob, the blocks that have been successfully written to the server with this method - * must be committed using a call to {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList)} or - * {@link WritableBlobContainerContract#commitBlobBlocks(String, BlockList, CommitBlobBlocksOptions)}. + * Creates the blob block. * * @param blob - * A {@link String} containing the name of the blob to create the block for. + * the blob * @param blockId - * A {@link String} containing a client-specified ID for the block. + * the block id * @param contentStream - * An {@link InputStream} reference to the content to copy to the block. + * the content stream * @param options - * A {@link CreateBlobBlockOptions} instance containing options for the request. + * the options * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ void createBlobBlock(String blob, String blockId, InputStream contentStream, CreateBlobBlockOptions options) throws ServiceException; /** - * Commits a list of blocks to a block blob. - * <p> - * This method creates or updates the block blob specified by the <em>blob</em> and <em>container</em> parameters. - * You can call this method to update a blob by uploading only those blocks that have changed, then committing the - * new and existing blocks together. You can do this with the <em>blockList</em> parameter by specifying whether to - * commit a block from the committed block list or from the uncommitted block list, or to commit the most recently - * uploaded version of the block, whichever list it may belong to. - * <p> - * In order to be written as part of a blob, each block in the list must have been successfully written to the - * server with a call to {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream)} or - * {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream, CreateBlobBlockOptions)}. + * Commit blob blocks. * * @param blob - * A {@link String} containing the name of the block blob to create or update. + * the blob * @param blockList - * A {@link BlockList} containing the list of blocks to commit to the block blob. + * the block list * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ void commitBlobBlocks(String blob, BlockList blockList) throws ServiceException; /** - * Commits a block list to a block blob, using the specified options. - * <p> - * This method creates or updates the block blob specified by the <em>blob</em> and <em>container</em> parameters. - * You can call this method to update a blob by uploading only those blocks that have changed, then committing the - * new and existing blocks together. You can do this with the <em>blockList</em> parameter by specifying whether to - * commit a block from the committed block list or from the uncommitted block list, or to commit the most recently - * uploaded version of the block, whichever list it may belong to. Use the {@link CommitBlobBlocksOptions options} - * parameter to optionally specify the server timeout for the operation, the MIME content type and content encoding - * for the blob, the content language, the MD5 hash, a cache control value, blob metadata, the lease ID if the blob - * has an active lease, and any access conditions for the operation. - * <p> - * In order to be written as part of a blob, each block in the list must have been successfully written to the - * server with a call to {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream)} or - * {@link WritableBlobContainerContract#createBlobBlock(String, String, InputStream, CreateBlobBlockOptions)}. + * Commit blob blocks. * * @param blob - * A {@link String} containing the name of the block blob to create or update. + * the blob * @param blockList - * A {@link BlockList} containing the list of blocks to commit to the block blob. + * the block list * @param options - * A {@link CommitBlobBlocksOptions} instance containing options for the request. + * the options * @throws ServiceException - * if an error occurs accessing the storage service. + * the service exception */ void commitBlobBlocks(String blob, BlockList blockList, CommitBlobBlocksOptions options) throws ServiceException; } From 9958ed2b21d7206cfd6686503c12bd0496aa70be Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 14:26:59 -0800 Subject: [PATCH 615/664] Cleanup TODO for AssetInfo For #593 --- .../services/media/models/AssetInfo.java | 1 - .../services/media/AssetIntegrationTest.java | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index f7bb8e4f5bf37..65fa6108c03ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -135,7 +135,6 @@ public LinkInfo getLocatorsLink() { * @return the link */ public LinkInfo getParentAssetsLink() { - // TODO: NEEDS TESTS once we figure out how to create assets with parents return getRelationLink("ParentAssets"); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 6eedbfa4fc737..e2caeb9c26120 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -17,23 +17,38 @@ import static org.junit.Assert.*; +import java.io.InputStream; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.EnumSet; import java.util.List; import java.util.UUID; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.models.AccessPolicy; +import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; +import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; +import com.microsoft.windowsazure.services.media.models.AssetFile; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.AssetState; import com.microsoft.windowsazure.services.media.models.ContentKey; import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.ContentKeyType; +import com.microsoft.windowsazure.services.media.models.Job; +import com.microsoft.windowsazure.services.media.models.JobInfo; +import com.microsoft.windowsazure.services.media.models.LinkInfo; +import com.microsoft.windowsazure.services.media.models.ListResult; +import com.microsoft.windowsazure.services.media.models.Locator; +import com.microsoft.windowsazure.services.media.models.LocatorInfo; +import com.microsoft.windowsazure.services.media.models.LocatorType; +import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; public class AssetIntegrationTest extends IntegrationTestBase { @@ -301,4 +316,43 @@ public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyn // Assert } + + @Test + public void canGetParentBackFromAsset() throws ServiceException, InterruptedException { + // Arrange + String originalAssetName = testAssetPrefix + "canGetParentBackFromAsset"; + AssetInfo originalAsset = service.create(Asset.create().setName(originalAssetName)); + + int durationInMinutes = 10; + AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix + + "uploadAesPortectedAssetSuccess", durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); + + LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), originalAsset.getId(), + LocatorType.SAS)); + WritableBlobContainerContract blobWriter = service.createBlobWriter(locatorInfo); + + InputStream mpeg4H264InputStream = getClass().getResourceAsStream("/media/MPEG4-H264.mp4"); + blobWriter.createBlockBlob("MPEG4-H264.mp4", mpeg4H264InputStream); + service.action(AssetFile.createFileInfos(originalAsset.getId())); + + String jobName = testJobPrefix + "createJobSuccess"; + CreateBatchOperation taskCreator = Task + .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5", + "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + + "<outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>") + .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task"); + JobInfo jobInfo = service.create(Job.create().setName(jobName).addInputMediaAsset(originalAsset.getId()) + .addTaskCreator(taskCreator)); + + // Act + ListResult<AssetInfo> outputAssets = service.list(Asset.list(jobInfo.getOutputAssetsLink())); + assertEquals(1, outputAssets.size()); + AssetInfo childAsset = outputAssets.get(0); + + LinkInfo parentAssetLink = childAsset.getParentAssetsLink(); + AssetInfo parentAsset = service.get(Asset.get(parentAssetLink)); + + // Assert + assertEquals(originalAsset.getId(), parentAsset.getId()); + } } From 8435e5e8ba176e15df816a052819d64f51d82d62 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 14:45:20 -0800 Subject: [PATCH 616/664] Removing TODO: Auto-generated Javadoc For #593 --- .../microsoft/windowsazure/services/media/models/JobInfo.java | 1 - .../windowsazure/services/media/models/MediaProcessorInfo.java | 1 - 2 files changed, 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 36d3ac99e4b93..5c5525065b47e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -21,7 +21,6 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.JobType; -// TODO: Auto-generated Javadoc /** * The Class JobInfo. */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java index 8d6ec26235a9c..884431f75e9da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java @@ -19,7 +19,6 @@ import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType; -// TODO: Auto-generated Javadoc /** * Data about a Media Processor entity. * From 1e0beaa0441b3093eca8d8b39f4f1c4bc55f0f9f Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 15:12:39 -0800 Subject: [PATCH 617/664] Remove TODO in AccessPolicyIntegrationTest, because the suggestion is not necessary. REmove TODO in IntegrationTestBase, because suggestion would make tests less robust. For #593 --- .../services/media/AccessPolicyIntegrationTest.java | 2 -- .../windowsazure/services/media/IntegrationTestBase.java | 3 --- 2 files changed, 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index b81665c3f7f9f..3f7f2eb2df698 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -82,8 +82,6 @@ public void canCreateAccessPolicyWithReadPermissions() throws Exception { verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.READ, policy); } - // TODO: Null name or duration? - @Test public void canGetSinglePolicyById() throws Exception { String expectedName = testPolicyPrefix + "GetOne"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index edb7ea64dc0e0..07ba51578de65 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -81,9 +81,6 @@ public static void cleanup() throws Exception { } private static void cleanupEnvironment() { - // TODO: This should be removed once cascade delete is implemented for Assets. - // But for now, trying to delete an asset with fail if there are any - // existing Locators associated with it. removeAllTestLocators(); removeAllTestAssets(); removeAllTestAccessPolicies(); From f86ea9cd49f9785dd79a5eae8704cb8d8acc2e7e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 15:15:32 -0800 Subject: [PATCH 618/664] Remove TODO in JobIntegration test by adding validation for the number of tasks. For #593 --- .../services/media/JobIntegrationTest.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index fcd0f4111099a..9bd0954e367ee 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -31,6 +31,7 @@ import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.JobState; +import com.microsoft.windowsazure.services.media.models.LinkInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation; @@ -40,16 +41,16 @@ public class JobIntegrationTest extends IntegrationTestBase { private static AssetInfo assetInfo; - private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) { + private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) throws ServiceException { verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(), expected.getState(), expected.getTemplateId(), expected.getCreated(), expected.getLastModified(), - expected.getStartTime(), expected.getEndTime(), actual); + expected.getStartTime(), expected.getEndTime(), null, actual); } @SuppressWarnings("deprecation") private void verifyJobProperties(String message, String testName, Integer priority, double runningDuration, JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime, - JobInfo actualJob) { + Integer expectedTaskCount, JobInfo actualJob) throws ServiceException { assertNotNull(message, actualJob); assertNotNull(message + "Id", actualJob.getId()); @@ -66,8 +67,11 @@ private void verifyJobProperties(String message, String testName, Integer priori assertDateApproxEquals(message + " StartTime", startTime, actualJob.getStartTime()); assertDateApproxEquals(message + " EndTime", endTime, actualJob.getEndTime()); - // TODO: Add test for accessing the tasks when fixed: - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/531 + if (expectedTaskCount != null) { + LinkInfo tasksLink = actualJob.getTasksLink(); + ListResult<TaskInfo> actualTasks = service.list(Task.list(tasksLink)); + assertEquals(message + " tasks size", expectedTaskCount.intValue(), actualTasks.size()); + } } private JobInfo createJob(String name) throws ServiceException { @@ -108,7 +112,7 @@ public void createJobSuccess() throws ServiceException { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, actualJob); + endTime, 1, actualJob); } @Test @@ -133,7 +137,7 @@ public void createJobTwoTasksSuccess() throws ServiceException { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, actualJob); + endTime, 2, actualJob); } @Test @@ -155,7 +159,7 @@ public void getJobSuccess() throws ServiceException { // Assert verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime, - endTime, actualJob); + endTime, 1, actualJob); } @Test @@ -180,7 +184,12 @@ public void listJobSuccess() throws ServiceException { verifyListResultContains("listJobs", expectedListJobsResult, actualListJobResult, new ComponentDelegate() { @Override public void verifyEquals(String message, Object expected, Object actual) { - verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual); + try { + verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual); + } + catch (ServiceException e) { + fail(e.getMessage()); + } } }); } From c07e6f7db14bd3d8cb41402bc0ca3d7a3d4c5a1d Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 15:19:01 -0800 Subject: [PATCH 619/664] Removing suggestion for where to add tests for future features. We should make those decisions in the future when we add teh features. Also, cleaning out an implicit TODO that is out of date. For #593 --- .../windowsazure/services/media/TaskIntegrationTest.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index e3434db0da597..c9a374a91ced7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -189,8 +189,6 @@ public void cancelTaskSuccess() throws ServiceException, InterruptedException { //Assert List<TaskInfo> taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink())); for (TaskInfo taskInfo : taskInfos) { - // Replace with enums - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/522 verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody, configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo); } @@ -225,9 +223,6 @@ private void verifyTaskProperties(String message, String mediaProcessorId, TaskO assertNotNull(message + " getErrorDetails", actual.getErrorDetails()); assertEquals(message + " getErrorDetails.size", 0, actual.getErrorDetails().size()); - // TODO: Add tests for Historical events when added - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/494 - ListResult<AssetInfo> inputAssets = service.list(Asset.list(actual.getInputAssetsLink())); ListResult<AssetInfo> outputAssets = service.list(Asset.list(actual.getOutputAssetsLink())); From 3f48c8756e357636d4525ba96b98833ce43682b4 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 16:01:04 -0800 Subject: [PATCH 620/664] Add code to cancel current jobs before running the test where the job needs to complete. Also fixes a related failure in the scenario tests. The fix there is simpler, just increasing the max iterations from 10 to 30 (like was done for the JobIntegrationTests). For #581 --- .../windowsazure/services/media/IntegrationTestBase.java | 2 +- .../windowsazure/services/media/JobIntegrationTest.java | 1 + .../services/scenarios/MediaServiceScenarioTest.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 07ba51578de65..94e2b31b8f0a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -80,7 +80,7 @@ public static void cleanup() throws Exception { cleanupEnvironment(); } - private static void cleanupEnvironment() { + protected static void cleanupEnvironment() { removeAllTestLocators(); removeAllTestAssets(); removeAllTestAccessPolicies(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 9bd0954e367ee..1269a018e74c8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -302,6 +302,7 @@ public void canGetTasksFromJob() throws Exception { @Test public void canGetErrorDetailsFromTask() throws Exception { + cleanupEnvironment(); String name = testJobPrefix + "canGetErrorDetailsFromTask"; JobInfo actualJob = service.create(Job.create().setName(name).addInputMediaAsset(assetInfo.getId()) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 2fd63d9b9a0b0..2491a44ceda37 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -127,7 +127,7 @@ public void transformAsset() throws Exception { private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { for (int counter = 0; !wrapper.isJobFinished(job); counter++) { - if (counter > 10) { + if (counter > 30) { fail("Took took long for the job to finish"); } Thread.sleep(10000); From 476b70582904f765e8c310010723170f4a069b4a Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 16:47:16 -0800 Subject: [PATCH 621/664] initial check in for refactoring of action --- .../MediaExceptionProcessor.java | 21 +++- .../entities/DefaultActionOperation.java | 15 +-- .../entities/DefaultTypeActionOperation.java | 99 +++++++++++++++++++ .../entities/EntityActionOperation.java | 3 + .../entities/EntityContract.java | 45 +++++++-- .../entities/EntityRestProxy.java | 22 ++++- .../entities/EntityTypeActionOperation.java | 55 +++++++++++ .../services/media/models/ProtectionKey.java | 19 ++-- .../media/EncryptionIntegrationTest.java | 5 +- 9 files changed, 251 insertions(+), 33 deletions(-) create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java create mode 100644 microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index b69a4a7074ddd..7e327c61ba4c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -30,6 +30,7 @@ import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; @@ -176,9 +177,25 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ @Override - public Object action(EntityActionOperation action) throws ServiceException { + public void action(EntityActionOperation entityActionOperation) throws ServiceException { try { - return service.action(action); + service.action(entityActionOperation); + } + catch (UniformInterfaceException e) { + throw processCatch(new ServiceException(e)); + } + catch (ClientHandlerException e) { + throw processCatch(new ServiceException(e)); + } + } + + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation) + */ + @Override + public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) throws ServiceException { + try { + return service.action(entityTypeActionOperation); } catch (UniformInterfaceException e) { throw processCatch(new ServiceException(e)); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index 82b0dc8fb2bde..ecd252b6ab7cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -39,7 +39,7 @@ public class DefaultActionOperation implements EntityActionOperation { private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE; /** The query parameters. */ - protected final MultivaluedMap<String, String> queryParameters; + protected MultivaluedMap<String, String> queryParameters; /** * The default action operation. @@ -62,10 +62,6 @@ public DefaultActionOperation() { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) */ - @Override - public void setProxyData(EntityProxyData proxyData) { - this.proxyData = proxyData; - } /** * Get the current proxy data @@ -116,6 +112,7 @@ public MediaType getContentType() { * the content type * @return the default action operation */ + @Override public DefaultActionOperation setContentType(MediaType contentType) { this.contentType = contentType; return this; @@ -147,7 +144,7 @@ public DefaultActionOperation setAcceptType(MediaType acceptType) { @Override public Object processResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); - return null; + return clientResponse; } /* (non-Javadoc) @@ -166,8 +163,14 @@ public Object getRequestContents() { return null; } + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } + @Override public Object processResponse(Object rawResponse) throws ServiceException { return rawResponse; } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java new file mode 100644 index 0000000000000..59a7368ca2749 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java @@ -0,0 +1,99 @@ +package com.microsoft.windowsazure.services.media.implementation.entities; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; + +import com.microsoft.windowsazure.services.core.ServiceException; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +public class DefaultTypeActionOperation<T> implements EntityTypeActionOperation<T> { + + private String name; + + /** The content type. */ + private MediaType contentType = MediaType.APPLICATION_ATOM_XML_TYPE; + + /** The accept type. */ + private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE; + + private MultivaluedMapImpl queryParameters; + + private EntityProxyData proxyData; + + public DefaultTypeActionOperation(String name) { + this(); + this.name = name; + } + + public DefaultTypeActionOperation() { + this.queryParameters = new MultivaluedMapImpl(); + } + + @Override + public T processTypeResponse(ClientResponse clientResponse) { + return null; + } + + @Override + public MultivaluedMap<String, String> getQueryParameters() { + return this.queryParameters; + } + + @Override + public String getVerb() { + return "GET"; + } + + @Override + public Object getRequestContents() { + return null; + } + + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } + + @Override + public String getUri() { + return this.name; + } + + @Override + public MediaType getContentType() { + return this.contentType; + } + + @Override + public MediaType getAcceptType() { + return this.acceptType; + } + + @Override + public Object processResponse(Object rawResponse) throws ServiceException { + return null; + } + + @Override + public DefaultTypeActionOperation<T> addQueryParameter(String key, String value) { + this.queryParameters.add(key, value); + return this; + } + + @Override + public void processResponse(ClientResponse clientResponse) { + } + + @Override + public EntityTypeActionOperation<T> setContentType(MediaType contentType) { + this.contentType = contentType; + return this; + } + + public EntityTypeActionOperation<T> setAcceptType(MediaType acceptType) { + this.acceptType = acceptType; + return this; + } + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 019285038dac1..868fa73208da1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -15,6 +15,7 @@ package com.microsoft.windowsazure.services.media.implementation.entities; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import com.sun.jersey.api.client.ClientResponse; @@ -65,4 +66,6 @@ public interface EntityActionOperation extends EntityOperation { */ Object getRequestContents(); + DefaultActionOperation setContentType(MediaType contentType); + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index 930ef1e5a0a69..0fcdb7d1d561e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -26,62 +26,87 @@ public interface EntityContract { /** - * Create a new instance of an entity + * Create a new instance of an entity. * + * @param <T> + * the generic type * @param creator * Object providing the details of the entity to be * created - * @return - * The created entity + * @return the t + * @throws ServiceException + * the service exception + * The created entity */ public abstract <T> T create(EntityCreateOperation<T> creator) throws ServiceException; /** - * Retrieve an existing entity by id + * Retrieve an existing entity by id. * + * @param <T> + * the generic type * @param getter * object providing the details of the entity to be retrieved * @return The retrieved entity * @throws ServiceException + * the service exception */ public abstract <T> T get(EntityGetOperation<T> getter) throws ServiceException; /** - * Retrieve a list of entities + * Retrieve a list of entities. * + * @param <T> + * the generic type * @param lister * object providing details of entities to list * @return The resulting list * @throws ServiceException + * the service exception */ public abstract <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException; /** - * Update an existing entity + * Update an existing entity. * * @param updater * Object providing details of the update * @throws ServiceException + * the service exception */ public abstract void update(EntityUpdateOperation updater) throws ServiceException; /** - * Delete an entity + * Delete an entity. * * @param deleter * Object providing details of the delete * @throws ServiceException + * the service exception */ public abstract void delete(EntityDeleteOperation deleter) throws ServiceException; /** - * Perform an action on an entity + * Perform an action on an entity. * * @param action * Object providing details of the action - * @return * @throws ServiceException + * the service exception + */ + public abstract void action(EntityActionOperation action) throws ServiceException; + + /** + * Action. + * + * @param <T> + * the generic type + * @param entityActionOperation + * the entity action operation + * @return the t + * @throws ServiceException + * the service exception */ - public abstract Object action(EntityActionOperation action) throws ServiceException; + public abstract <T> T action(EntityTypeActionOperation<T> entityActionOperation) throws ServiceException; } \ No newline at end of file diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index a4f6a0d4e070c..168783912406b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -164,15 +164,29 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ + @SuppressWarnings("unchecked") @Override - public Object action(EntityActionOperation entityActionOperation) throws ServiceException { - entityActionOperation.setProxyData(createProxyData()); + public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) throws ServiceException { + entityTypeActionOperation.setProxyData(createProxyData()); + Builder webResource = getResource(entityTypeActionOperation.getUri()) + .queryParams(entityTypeActionOperation.getQueryParameters()) + .accept(entityTypeActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE) + .entity(entityTypeActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); + ClientResponse clientResponse = webResource.method(entityTypeActionOperation.getVerb(), ClientResponse.class); + return entityTypeActionOperation.processTypeResponse(clientResponse); + } + @Override + public void action(EntityActionOperation entityActionOperation) throws ServiceException { + entityActionOperation.processResponse(getActionClientResponse(entityActionOperation)); + } + + private ClientResponse getActionClientResponse(EntityActionOperation entityActionOperation) { + entityActionOperation.setProxyData(createProxyData()); Builder webResource = getResource(entityActionOperation.getUri()) .queryParams(entityActionOperation.getQueryParameters()).accept(entityActionOperation.getAcceptType()) .accept(MediaType.APPLICATION_XML_TYPE) .entity(entityActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); - ClientResponse clientResponse = webResource.method(entityActionOperation.getVerb(), ClientResponse.class); - return entityActionOperation.processResponse(clientResponse); + return webResource.method(entityActionOperation.getVerb(), ClientResponse.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java new file mode 100644 index 0000000000000..c402e37622102 --- /dev/null +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java @@ -0,0 +1,55 @@ +package com.microsoft.windowsazure.services.media.implementation.entities; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; + +import com.sun.jersey.api.client.ClientResponse; + +public interface EntityTypeActionOperation<T> extends EntityOperation { + + T processTypeResponse(ClientResponse clientResponse); + + /** + * Gets the query parameters. + * + * @return the query parameters + */ + MultivaluedMap<String, String> getQueryParameters(); + + /** + * Adds the query parameter. + * + * @param key + * the key + * @param value + * the value + * @return the entity action operation + */ + EntityTypeActionOperation<T> addQueryParameter(String key, String value); + + /** + * Process response. + * + * @param clientResponse + * the client response + * @return the object + */ + void processResponse(ClientResponse clientResponse); + + /** + * Gets the verb. + * + * @return the verb + */ + String getVerb(); + + /** + * Gets the request contents. + * + * @return the request contents + */ + Object getRequestContents(); + + EntityTypeActionOperation<T> setContentType(MediaType contentType); + +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index 5c3dbf79171fd..36686887acf10 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -27,8 +27,8 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyIdType; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultTypeActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation; import com.sun.jersey.api.client.ClientResponse; /** @@ -44,7 +44,7 @@ public class ProtectionKey { * the content key type * @return the protection key id */ - public static EntityActionOperation getProtectionKeyId(ContentKeyType contentKeyType) { + public static EntityTypeActionOperation<String> getProtectionKeyId(ContentKeyType contentKeyType) { return new GetProtectionKeyIdActionOperation("GetProtectionKeyId").addQueryParameter("contentKeyType", String.format("%d", contentKeyType.getCode())).setAcceptType(MediaType.APPLICATION_XML_TYPE); } @@ -56,15 +56,17 @@ public static EntityActionOperation getProtectionKeyId(ContentKeyType contentKey * the protection key id * @return the protection key */ - public static EntityActionOperation getProtectionKey(String protectionKeyId) { + public static EntityTypeActionOperation<String> getProtectionKey(String protectionKeyId) { return new GetProtectionKeyActionOperation("GetProtectionKey").addQueryParameter("ProtectionKeyId", String.format("'%s'", protectionKeyId)).setAcceptType(MediaType.APPLICATION_XML_TYPE); } /** * The Class GetProtectionKeyIdActionOperation. + * + * @param <T> */ - private static class GetProtectionKeyIdActionOperation extends DefaultActionOperation { + private static class GetProtectionKeyIdActionOperation extends DefaultTypeActionOperation<String> { /** The jaxb context. */ private final JAXBContext jaxbContext; @@ -99,7 +101,7 @@ public GetProtectionKeyIdActionOperation(String name) { * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override - public Object processResponse(ClientResponse clientResponse) { + public String processTypeResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); ProtectionKeyIdType protectionKeyIdType; try { @@ -129,12 +131,13 @@ private ProtectionKeyIdType parseResponse(ClientResponse clientResponse) throws return protectionKeyIdTypeJaxbElement.getValue(); } + } /** * The Class GetProtectionKeyActionOperation. */ - private static class GetProtectionKeyActionOperation extends DefaultActionOperation { + private static class GetProtectionKeyActionOperation extends DefaultTypeActionOperation<String> { /** The jaxb context. */ private final JAXBContext jaxbContext; @@ -169,7 +172,7 @@ public GetProtectionKeyActionOperation(String name) { * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override - public Object processResponse(ClientResponse clientResponse) { + public String processTypeResponse(ClientResponse clientResponse) { PipelineHelpers.ThrowIfNotSuccess(clientResponse); ProtectionKeyRestType protectionKeyRestType; try { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index c6f2f0588b05e..ce28ba211d182 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -64,8 +64,7 @@ private String createContentKeyId(UUID uuid) { } private String getProtectionKeyId() throws ServiceException { - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); return protectionKeyId; } @@ -106,7 +105,7 @@ private MediaProcessorInfo GetMediaProcessor(String mediaProcessorName) throws S } private String getProtectionKey(String protectionKeyId) throws ServiceException { - String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); return protectionKey; } From 520185b5f68fb74916b9c7bd74e206f00b148c31 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 17:04:43 -0800 Subject: [PATCH 622/664] update on the action DCR. --- .../entities/DefaultActionOperation.java | 26 +++---- .../entities/DefaultTypeActionOperation.java | 70 +++++++++++++++++-- .../entities/EntityActionOperation.java | 11 --- .../entities/EntityLinkOperation.java | 11 --- .../entities/EntityRestProxy.java | 2 +- .../entities/EntityTypeActionOperation.java | 2 +- 6 files changed, 79 insertions(+), 43 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index ecd252b6ab7cc..b55b083edc087 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -27,6 +27,8 @@ * Generic implementation of Delete operation usable by most entities. */ public class DefaultActionOperation implements EntityActionOperation { + + /** The proxy data. */ private EntityProxyData proxyData; /** The name. */ @@ -62,9 +64,13 @@ public DefaultActionOperation() { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) */ + @Override + public void setProxyData(EntityProxyData proxyData) { + this.proxyData = proxyData; + } /** - * Get the current proxy data + * Get the current proxy data. * * @return the proxy data */ @@ -138,15 +144,6 @@ public DefaultActionOperation setAcceptType(MediaType acceptType) { return this; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) - */ - @Override - public Object processResponse(ClientResponse clientResponse) { - PipelineHelpers.ThrowIfNotSuccess(clientResponse); - return clientResponse; - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getVerb() */ @@ -163,13 +160,12 @@ public Object getRequestContents() { return null; } - @Override - public void setProxyData(EntityProxyData proxyData) { - this.proxyData = proxyData; - } - + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + */ @Override public Object processResponse(Object rawResponse) throws ServiceException { + PipelineHelpers.ThrowIfNotSuccess((ClientResponse) rawResponse); return rawResponse; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java index 59a7368ca2749..b4be157315141 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java @@ -7,8 +7,15 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.core.util.MultivaluedMapImpl; +/** + * The Class DefaultTypeActionOperation. + * + * @param <T> + * the generic type + */ public class DefaultTypeActionOperation<T> implements EntityTypeActionOperation<T> { + /** The name. */ private String name; /** The content type. */ @@ -17,83 +24,138 @@ public class DefaultTypeActionOperation<T> implements EntityTypeActionOperation< /** The accept type. */ private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE; + /** The query parameters. */ private MultivaluedMapImpl queryParameters; + /** The proxy data. */ private EntityProxyData proxyData; + /** + * Instantiates a new default type action operation. + * + * @param name + * the name + */ public DefaultTypeActionOperation(String name) { this(); this.name = name; } + /** + * Instantiates a new default type action operation. + */ public DefaultTypeActionOperation() { this.queryParameters = new MultivaluedMapImpl(); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#processTypeResponse(com.sun.jersey.api.client.ClientResponse) + */ @Override public T processTypeResponse(ClientResponse clientResponse) { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getQueryParameters() + */ @Override public MultivaluedMap<String, String> getQueryParameters() { return this.queryParameters; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getVerb() + */ @Override public String getVerb() { return "GET"; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getRequestContents() + */ @Override public Object getRequestContents() { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + */ @Override public void setProxyData(EntityProxyData proxyData) { this.proxyData = proxyData; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getUri() + */ @Override public String getUri() { return this.name; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() + */ @Override public MediaType getContentType() { return this.contentType; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() + */ @Override public MediaType getAcceptType() { return this.acceptType; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + */ @Override public Object processResponse(Object rawResponse) throws ServiceException { return null; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#addQueryParameter(java.lang.String, java.lang.String) + */ @Override public DefaultTypeActionOperation<T> addQueryParameter(String key, String value) { this.queryParameters.add(key, value); return this; } - @Override - public void processResponse(ClientResponse clientResponse) { - } - + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#setContentType(javax.ws.rs.core.MediaType) + */ @Override public EntityTypeActionOperation<T> setContentType(MediaType contentType) { this.contentType = contentType; return this; } + /** + * Sets the accept type. + * + * @param acceptType + * the accept type + * @return the entity type action operation + */ public EntityTypeActionOperation<T> setAcceptType(MediaType acceptType) { this.acceptType = acceptType; return this; } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + */ + @Override + public Object processResponse(ClientResponse clientResponse) { + return null; + } + } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 868fa73208da1..9c6f06ff37f94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -18,8 +18,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; -import com.sun.jersey.api.client.ClientResponse; - /** * Action operation for Entities. */ @@ -43,15 +41,6 @@ public interface EntityActionOperation extends EntityOperation { */ EntityActionOperation addQueryParameter(String key, String value); - /** - * Process response. - * - * @param clientResponse - * the client response - * @return the object - */ - Object processResponse(ClientResponse clientResponse); - /** * Gets the verb. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index d726e4f1caf93..4567bb40ea03f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -31,10 +31,8 @@ import org.w3c.dom.Document; -import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.MediaUriType; -import com.sun.jersey.api.client.ClientResponse; /** * Generic implementation of $link operation of two entities. @@ -129,15 +127,6 @@ public String getVerb() { return "POST"; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) - */ - @Override - public Object processResponse(ClientResponse clientResponse) { - PipelineHelpers.ThrowIfNotSuccess(clientResponse); - return null; - } - /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#getRequestContents() */ diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 168783912406b..3e19bd8d48179 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -173,7 +173,7 @@ public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) thro .accept(entityTypeActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE) .entity(entityTypeActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); ClientResponse clientResponse = webResource.method(entityTypeActionOperation.getVerb(), ClientResponse.class); - return entityTypeActionOperation.processTypeResponse(clientResponse); + return (T) entityTypeActionOperation.processResponse(clientResponse); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java index c402e37622102..2c39dfa0105db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java @@ -34,7 +34,7 @@ public interface EntityTypeActionOperation<T> extends EntityOperation { * the client response * @return the object */ - void processResponse(ClientResponse clientResponse); + Object processResponse(ClientResponse clientResponse); /** * Gets the verb. From 582439f51f79917ea9f6c241ab56e7aa2efa2f5b Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 17:07:10 -0800 Subject: [PATCH 623/664] rename DefaultEntityTypeActionOperation --- ...eration.java => DefaultEntityTypeActionOperation.java} | 8 ++++---- .../windowsazure/services/media/models/ProtectionKey.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/{DefaultTypeActionOperation.java => DefaultEntityTypeActionOperation.java} (94%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java index b4be157315141..645cefa248392 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java @@ -13,7 +13,7 @@ * @param <T> * the generic type */ -public class DefaultTypeActionOperation<T> implements EntityTypeActionOperation<T> { +public class DefaultEntityTypeActionOperation<T> implements EntityTypeActionOperation<T> { /** The name. */ private String name; @@ -36,7 +36,7 @@ public class DefaultTypeActionOperation<T> implements EntityTypeActionOperation< * @param name * the name */ - public DefaultTypeActionOperation(String name) { + public DefaultEntityTypeActionOperation(String name) { this(); this.name = name; } @@ -44,7 +44,7 @@ public DefaultTypeActionOperation(String name) { /** * Instantiates a new default type action operation. */ - public DefaultTypeActionOperation() { + public DefaultEntityTypeActionOperation() { this.queryParameters = new MultivaluedMapImpl(); } @@ -124,7 +124,7 @@ public Object processResponse(Object rawResponse) throws ServiceException { * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#addQueryParameter(java.lang.String, java.lang.String) */ @Override - public DefaultTypeActionOperation<T> addQueryParameter(String key, String value) { + public DefaultEntityTypeActionOperation<T> addQueryParameter(String key, String value) { this.queryParameters.add(key, value); return this; } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index 36686887acf10..72a01fdc4cf66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -27,7 +27,7 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyIdType; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultTypeActionOperation; +import com.microsoft.windowsazure.services.media.implementation.entities.DefaultEntityTypeActionOperation; import com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation; import com.sun.jersey.api.client.ClientResponse; @@ -66,7 +66,7 @@ public static EntityTypeActionOperation<String> getProtectionKey(String protecti * * @param <T> */ - private static class GetProtectionKeyIdActionOperation extends DefaultTypeActionOperation<String> { + private static class GetProtectionKeyIdActionOperation extends DefaultEntityTypeActionOperation<String> { /** The jaxb context. */ private final JAXBContext jaxbContext; @@ -137,7 +137,7 @@ private ProtectionKeyIdType parseResponse(ClientResponse clientResponse) throws /** * The Class GetProtectionKeyActionOperation. */ - private static class GetProtectionKeyActionOperation extends DefaultTypeActionOperation<String> { + private static class GetProtectionKeyActionOperation extends DefaultEntityTypeActionOperation<String> { /** The jaxb context. */ private final JAXBContext jaxbContext; From e15f49ff9815a271ce64d83951491fbcf82a7921 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 17:19:18 -0800 Subject: [PATCH 624/664] update the entity type action operation. --- .../DefaultEntityTypeActionOperation.java | 36 +++++++------ .../entities/EntityOperation.java | 2 +- .../entities/EntityRestProxy.java | 11 ++++ .../entities/EntityTypeActionOperation.java | 53 +++++++++++++++---- 4 files changed, 76 insertions(+), 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java index 645cefa248392..f27e8bcb84de2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation.entities; import javax.ws.rs.core.MediaType; @@ -25,10 +40,10 @@ public class DefaultEntityTypeActionOperation<T> implements EntityTypeActionOper private MediaType acceptType = MediaType.APPLICATION_ATOM_XML_TYPE; /** The query parameters. */ - private MultivaluedMapImpl queryParameters; + private final MultivaluedMap<String, String> queryParameters; /** The proxy data. */ - private EntityProxyData proxyData; + protected EntityProxyData proxyData; /** * Instantiates a new default type action operation. @@ -138,24 +153,13 @@ public EntityTypeActionOperation<T> setContentType(MediaType contentType) { return this; } - /** - * Sets the accept type. - * - * @param acceptType - * the accept type - * @return the entity type action operation + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#setAcceptType(javax.ws.rs.core.MediaType) */ + @Override public EntityTypeActionOperation<T> setAcceptType(MediaType acceptType) { this.acceptType = acceptType; return this; } - /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) - */ - @Override - public Object processResponse(ClientResponse clientResponse) { - return null; - } - } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index ace576ca41eb6..2efa7e04eee60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -27,7 +27,7 @@ public interface EntityOperation { * @param proxyData * @return */ - void setProxyData(EntityProxyData proxyData); + public void setProxyData(EntityProxyData proxyData); /** * Get the URI the creation request should be sent to. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 3e19bd8d48179..3c3123e442c09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -97,6 +97,7 @@ private WebResource getResource(String entityName) { * the operation * @return the resource * @throws ServiceException + * the service exception */ private Builder getResource(EntityOperation operation) throws ServiceException { return getResource(operation.getUri()).type(operation.getContentType()).accept(operation.getAcceptType()); @@ -176,11 +177,21 @@ public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) thro return (T) entityTypeActionOperation.processResponse(clientResponse); } + /* (non-Javadoc) + * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + */ @Override public void action(EntityActionOperation entityActionOperation) throws ServiceException { entityActionOperation.processResponse(getActionClientResponse(entityActionOperation)); } + /** + * Gets the action client response. + * + * @param entityActionOperation + * the entity action operation + * @return the action client response + */ private ClientResponse getActionClientResponse(EntityActionOperation entityActionOperation) { entityActionOperation.setProxyData(createProxyData()); Builder webResource = getResource(entityActionOperation.getUri()) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java index 2c39dfa0105db..526f4c4268218 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation.entities; import javax.ws.rs.core.MediaType; @@ -5,8 +20,21 @@ import com.sun.jersey.api.client.ClientResponse; +/** + * The Interface EntityTypeActionOperation. + * + * @param <T> + * the generic type + */ public interface EntityTypeActionOperation<T> extends EntityOperation { + /** + * Process type response. + * + * @param clientResponse + * the client response + * @return the t + */ T processTypeResponse(ClientResponse clientResponse); /** @@ -27,15 +55,6 @@ public interface EntityTypeActionOperation<T> extends EntityOperation { */ EntityTypeActionOperation<T> addQueryParameter(String key, String value); - /** - * Process response. - * - * @param clientResponse - * the client response - * @return the object - */ - Object processResponse(ClientResponse clientResponse); - /** * Gets the verb. * @@ -50,6 +69,22 @@ public interface EntityTypeActionOperation<T> extends EntityOperation { */ Object getRequestContents(); + /** + * Sets the content type. + * + * @param contentType + * the content type + * @return the entity type action operation + */ EntityTypeActionOperation<T> setContentType(MediaType contentType); + /** + * Sets the accept type. + * + * @param acceptType + * the accept type + * @return the entity type action operation + */ + EntityTypeActionOperation<T> setAcceptType(MediaType acceptType); + } From aa8609bb8361db25d06a172b7c69c752cbc3da04 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 17:26:25 -0800 Subject: [PATCH 625/664] final touch on the action DCR. --- .../implementation/entities/EntityActionOperation.java | 9 ++++++++- .../media/implementation/entities/EntityRestProxy.java | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 9c6f06ff37f94..47907dac79154 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -55,6 +55,13 @@ public interface EntityActionOperation extends EntityOperation { */ Object getRequestContents(); - DefaultActionOperation setContentType(MediaType contentType); + /** + * Sets the content type. + * + * @param contentType + * the content type + * @return the default action operation + */ + EntityActionOperation setContentType(MediaType contentType); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 3c3123e442c09..07ffdb38c5a3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -165,7 +165,6 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { /* (non-Javadoc) * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) */ - @SuppressWarnings("unchecked") @Override public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) throws ServiceException { entityTypeActionOperation.setProxyData(createProxyData()); @@ -174,7 +173,7 @@ public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) thro .accept(entityTypeActionOperation.getAcceptType()).accept(MediaType.APPLICATION_XML_TYPE) .entity(entityTypeActionOperation.getRequestContents(), MediaType.APPLICATION_XML_TYPE); ClientResponse clientResponse = webResource.method(entityTypeActionOperation.getVerb(), ClientResponse.class); - return (T) entityTypeActionOperation.processResponse(clientResponse); + return entityTypeActionOperation.processTypeResponse(clientResponse); } /* (non-Javadoc) From 681f13ec9e71642b62be4f2febc471ba671b5c34 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 18:04:11 -0800 Subject: [PATCH 626/664] suppress the warnings. --- .../windowsazure/services/media/Exports.java | 1 + .../implementation/MediaBatchOperations.java | 8 +++--- .../implementation/ODataAtomMarshaller.java | 2 +- .../implementation/ODataAtomUnmarshaller.java | 8 ++++++ .../ODataEntityCollectionProvider.java | 1 + .../services/media/models/Task.java | 26 ++++++++++++++++++- .../media/EncryptionIntegrationTest.java | 5 ++-- .../services/media/JobIntegrationTest.java | 1 - .../MediaBatchOperationsTest.java | 1 + .../ODataSerializationTest.java | 1 + 10 files changed, 44 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 558ec8a18a8e2..d5aaa13563f9b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -52,6 +52,7 @@ public void register(Builder.Registry registry) { registry.add(VersionHeadersFilter.class); registry.alter(ClientConfig.class, new Builder.Alteration<ClientConfig>() { + @SuppressWarnings("rawtypes") @Override public ClientConfig alter(ClientConfig instance, Builder builder, Map<String, Object> properties) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 37496ac8c84e8..12c484d12e5de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -49,6 +49,7 @@ import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.TaskInfo; import com.microsoft.windowsazure.services.table.implementation.InputStreamDataSource; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; @@ -298,7 +299,6 @@ private DataSource createBatchCreateEntityPart(String verb, String entityName, E * @throws ServiceException * the service exception */ - @SuppressWarnings("rawtypes") public void parseBatchResult(ClientResponse response) throws IOException, ServiceException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); InputStream inputStream = response.getEntityInputStream(); @@ -316,7 +316,6 @@ public void parseBatchResult(ClientResponse response) throws IOException, Servic entityBatchOperations.size()), response); } - ArrayList<Object> result = new ArrayList<Object>(); for (int i = 0; i < parts.size(); i++) { DataSource ds = parts.get(i); EntityBatchOperation entityBatchOperation = entityBatchOperations.get(i); @@ -352,9 +351,10 @@ else if (entityBatchOperation instanceof Job.CreateBatchOperation) { } } else if (entityBatchOperation instanceof Task.CreateBatchOperation) { - EntryType entryType = null; try { - entryType = oDataAtomUnmarshaller.unmarshalEntry(content); + TaskInfo taskInfo = oDataAtomUnmarshaller.unmarshalEntry(content, TaskInfo.class); + Task.CreateBatchOperation taskCreateBatchOperation = (Task.CreateBatchOperation) entityBatchOperation; + taskCreateBatchOperation.setTaskInfo(taskInfo); } catch (JAXBException e) { throw new ServiceException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 2d9735db12f98..0a2b8e4dabcd5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -104,7 +104,7 @@ public void marshalEntryType(EntryType entryType, OutputStream stream) throws JA new JAXBElement<EntryType>(new QName(Constants.ATOM_NS, "entry"), EntryType.class, entryType), stream); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) private JAXBElement<EntryType> createEntry(Object content) { ContentType atomContent = new ContentType(); EntryType atomEntry = new EntryType(); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 8125cf50a1db9..de843c2c4f2bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -75,6 +75,7 @@ public ODataAtomUnmarshaller() throws JAXBException { * @throws JAXBException * @throws ServiceException */ + @SuppressWarnings("rawtypes") public <T extends ODataEntity> ListResult<T> unmarshalFeed(InputStream stream, Class<T> contentType) throws JAXBException, ServiceException { validateNotNull(stream, "stream"); @@ -105,6 +106,7 @@ public <T extends ODataEntity> ListResult<T> unmarshalFeed(InputStream stream, C * @throws JAXBException * @throws ServiceException */ + @SuppressWarnings("rawtypes") public <T extends ODataEntity> T unmarshalEntry(InputStream stream, Class<T> contentType) throws JAXBException, ServiceException { validateNotNull(stream, "stream"); @@ -116,6 +118,7 @@ public <T extends ODataEntity> T unmarshalEntry(InputStream stream, Class<T> con return contentFromEntry(contentType, marshallingContentType, entry); } + @SuppressWarnings("rawtypes") private <T extends ODataEntity> T contentFromEntry(Class<T> contentType, Class<?> marshallingContentType, EntryType entry) throws JAXBException, ServiceException { unmarshalODataContent(entry, contentType); @@ -126,6 +129,7 @@ private <T extends ODataEntity> T contentFromEntry(Class<T> contentType, Class<? private EntryType asEntry(Object o) { if (o instanceof JAXBElement) { + @SuppressWarnings("rawtypes") JAXBElement e = (JAXBElement) o; if (e.getDeclaredType() == EntryType.class) { return (EntryType) e.getValue(); @@ -154,6 +158,7 @@ private void unmarshalEntryActions(EntryType entry) throws JAXBException { } } + @SuppressWarnings("rawtypes") private void unmarshalEntryContent(EntryType entry, Class<?> contentType) throws JAXBException { Class<?> marshallingContentType = getMarshallingContentType(contentType); ContentType contentElement = getFirstOfType(ContentType.class, entry.getEntryChildren()); @@ -170,9 +175,11 @@ private void unmarshalEntryContent(EntryType entry, Class<?> contentType) throws } } + @SuppressWarnings("unchecked") private <T> T getFirstOfType(Class<T> targetType, List<Object> collection) { for (Object c : collection) { if (c instanceof JAXBElement) { + @SuppressWarnings("rawtypes") JAXBElement e = (JAXBElement) c; if (e.getDeclaredType() == targetType) { return (T) e.getValue(); @@ -182,6 +189,7 @@ private <T> T getFirstOfType(Class<T> targetType, List<Object> collection) { return null; } + @SuppressWarnings("rawtypes") private <T extends ODataEntity> T constructResultObject(Class<T> contentType, EntryType entry, Object contentObject) throws ServiceException { Class<?> marshallingType = getMarshallingContentType(contentType); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java index 403295b7843ff..2478bed435337 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -34,6 +34,7 @@ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotati return ODataEntity.isODataEntityCollectionType(type, genericType); } + @SuppressWarnings("unchecked") @Override public ListResult<ODataEntity<?>> readFrom(Class<ListResult<ODataEntity<?>>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 1e8d6734a2ec0..f1cb7999c0417 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -74,7 +74,7 @@ public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> } /** - * Create an operation that will list the tasks pointed to by the given link + * Create an operation that will list the tasks pointed to by the given link. * * @param link * link to tasks @@ -93,6 +93,9 @@ public static class CreateBatchOperation extends EntityBatchOperation { /** The task type. */ private final TaskType taskType; + /** The task info. */ + private TaskInfo taskInfo; + /** * Instantiates a new creates the batch operation. * @@ -228,6 +231,27 @@ public CreateBatchOperation setInitializationVector(String initializationVector) this.taskType.setInitializationVector(initializationVector); return this; } + + /** + * Sets the task info. + * + * @param taskInfo + * the task info + * @return the creates the batch operation + */ + public CreateBatchOperation setTaskInfo(TaskInfo taskInfo) { + this.taskInfo = taskInfo; + return this; + } + + /** + * Gets the task info. + * + * @return the task info + */ + public TaskInfo getTaskInfo() { + return taskInfo; + } } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index c6f2f0588b05e..cf0ad232707f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -173,9 +173,8 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // encrypt the file. byte[] encryptedContent = EncryptionHelper.EncryptFile(smallWMVInputStream, aesKey, initializationVector); - // upload the encrypted file to the server. - AssetFileInfo assetFileInfo = uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, - "uploadAesProtectedAssetSuccess", encryptedContent); + uploadEncryptedAssetFile(assetInfo, locatorInfo, contentKeyInfo, "uploadAesProtectedAssetSuccess", + encryptedContent); // submit and execute the decoding job. JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index fcd0f4111099a..f56639b27b30f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -46,7 +46,6 @@ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual expected.getStartTime(), expected.getEndTime(), actual); } - @SuppressWarnings("deprecation") private void verifyJobProperties(String message, String testName, Integer priority, double runningDuration, JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime, JobInfo actualJob) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index f46863d2bdb89..cedeb6507dcf9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -52,6 +52,7 @@ public void createMediaBatchOperationFailedWithNullUri() throws JAXBException, P URI serviceUri = null; // Act + @SuppressWarnings("unused") MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 80905eb549c3e..13675babd80fd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -74,6 +74,7 @@ public void canUnmarshallAssetFromFeed() throws Exception { Assert.assertEquals("nb:cid:UUID:1f6c7bb4-8013-486e-b4c9-2e4a6842b9a6", entries.get(0).getId()); } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void canMarshalEntryFromJavaObject() throws Exception { AssetType a = new AssetType(); From 2e240007e77883ab6e8951f8c55d1a9bb52705f7 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 21:16:52 -0800 Subject: [PATCH 627/664] suppress warning after code merge. --- .../windowsazure/services/media/models/TaskEntityTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index fc67311f4b2ae..6174c7e9fb681 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -17,8 +17,6 @@ import static org.junit.Assert.*; -import java.net.URLEncoder; - import javax.xml.bind.JAXBElement; import org.junit.Test; @@ -32,7 +30,6 @@ */ public class TaskEntityTest { static final String sampleTaskId = "nb:cid:UUID:1151b8bd-9ada-4e7f-9787-8dfa49968eab"; - private final String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8")); private TaskType getTaskType(EntryType entryType) { for (Object child : entryType.getEntryChildren()) { @@ -43,6 +40,7 @@ private TaskType getTaskType(EntryType entryType) { ContentType contentType = (ContentType) element.getValue(); for (Object grandChild : contentType.getContent()) { if (grandChild instanceof JAXBElement) { + @SuppressWarnings("rawtypes") JAXBElement contentElement = (JAXBElement) grandChild; TaskType taskType = (TaskType) contentElement.getValue(); return taskType; From 0953d341f8c7d26a212c52d44aa3fc69d633d19d Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 21:37:28 -0800 Subject: [PATCH 628/664] remove dates from the copyright. --- .../com/microsoft/windowsazure/services/media/Exports.java | 2 +- .../windowsazure/services/media/MediaConfiguration.java | 2 +- .../microsoft/windowsazure/services/media/MediaContract.java | 2 +- .../microsoft/windowsazure/services/media/MediaService.java | 2 +- .../services/media/WritableBlobContainerContract.java | 2 +- .../services/media/implementation/ActiveToken.java | 2 +- .../services/media/implementation/MediaBatchOperations.java | 2 +- .../media/implementation/MediaBlobContainerWriter.java | 2 +- .../services/media/implementation/MediaBlobRestProxy.java | 2 +- .../services/media/implementation/MediaContentProvider.java | 2 +- .../media/implementation/MediaExceptionProcessor.java | 2 +- .../services/media/implementation/MediaRestProxy.java | 4 ++-- .../services/media/implementation/OAuthContract.java | 2 +- .../services/media/implementation/OAuthFilter.java | 2 +- .../services/media/implementation/OAuthRestProxy.java | 2 +- .../services/media/implementation/OAuthTokenManager.java | 2 +- .../services/media/implementation/OAuthTokenResponse.java | 2 +- .../services/media/implementation/ODataAtomMarshaller.java | 2 +- .../services/media/implementation/ODataAtomUnmarshaller.java | 2 +- .../services/media/implementation/ODataDateAdapter.java | 2 +- .../services/media/implementation/ODataEntity.java | 2 +- .../services/media/implementation/ODataEntityProvider.java | 2 +- .../services/media/implementation/RedirectFilter.java | 2 +- .../media/implementation/ResourceLocationManager.java | 2 +- .../services/media/implementation/SASTokenFilter.java | 2 +- .../media/implementation/SetBoundaryMultipartDataSource.java | 2 +- .../services/media/implementation/StatusLine.java | 4 ++-- .../services/media/implementation/VersionHeadersFilter.java | 2 +- .../media/implementation/content/AccessPolicyType.java | 2 +- .../services/media/implementation/content/AssetFileType.java | 2 +- .../services/media/implementation/content/AssetType.java | 2 +- .../services/media/implementation/content/Constants.java | 2 +- .../media/implementation/content/ContentKeyRestType.java | 2 +- .../media/implementation/content/ErrorDetailType.java | 2 +- .../services/media/implementation/content/JobType.java | 2 +- .../media/implementation/content/LocatorRestType.java | 2 +- .../media/implementation/content/MediaProcessorType.java | 2 +- .../services/media/implementation/content/MediaUriType.java | 2 +- .../media/implementation/content/ODataActionType.java | 2 +- .../services/media/implementation/content/ObjectFactory.java | 2 +- .../media/implementation/content/ProtectionKeyIdType.java | 2 +- .../media/implementation/content/ProtectionKeyRestType.java | 2 +- .../services/media/implementation/content/TaskType.java | 2 +- .../services/media/implementation/content/package-info.java | 2 +- .../media/implementation/entities/DefaultActionOperation.java | 2 +- .../media/implementation/entities/DefaultDeleteOperation.java | 2 +- .../media/implementation/entities/DefaultGetOperation.java | 2 +- .../media/implementation/entities/DefaultListOperation.java | 2 +- .../media/implementation/entities/EntityActionOperation.java | 2 +- .../media/implementation/entities/EntityBatchOperation.java | 2 +- .../media/implementation/entities/EntityContract.java | 4 ++-- .../media/implementation/entities/EntityCreateOperation.java | 2 +- .../media/implementation/entities/EntityGetOperation.java | 2 +- .../media/implementation/entities/EntityLinkOperation.java | 2 +- .../media/implementation/entities/EntityListOperation.java | 2 +- .../media/implementation/entities/EntityOperation.java | 2 +- .../media/implementation/entities/EntityOperationBase.java | 2 +- .../implementation/entities/EntityOperationSingleResult.java | 2 +- .../entities/EntityOperationSingleResultBase.java | 2 +- .../media/implementation/entities/EntityProxyData.java | 2 +- .../media/implementation/entities/EntityRestProxy.java | 2 +- .../media/implementation/entities/EntityUpdateOperation.java | 2 +- .../windowsazure/services/media/models/AccessPolicy.java | 2 +- .../windowsazure/services/media/models/AccessPolicyInfo.java | 2 +- .../services/media/models/AccessPolicyPermission.java | 2 +- .../microsoft/windowsazure/services/media/models/Asset.java | 2 +- .../windowsazure/services/media/models/AssetFile.java | 2 +- .../windowsazure/services/media/models/AssetFileInfo.java | 2 +- .../windowsazure/services/media/models/AssetInfo.java | 2 +- .../windowsazure/services/media/models/AssetOption.java | 2 +- .../windowsazure/services/media/models/AssetState.java | 2 +- .../windowsazure/services/media/models/ContentKey.java | 2 +- .../windowsazure/services/media/models/ContentKeyInfo.java | 2 +- .../windowsazure/services/media/models/ContentKeyType.java | 2 +- .../windowsazure/services/media/models/ErrorDetail.java | 2 +- .../com/microsoft/windowsazure/services/media/models/Job.java | 2 +- .../microsoft/windowsazure/services/media/models/JobInfo.java | 2 +- .../windowsazure/services/media/models/JobState.java | 2 +- .../windowsazure/services/media/models/LinkInfo.java | 2 +- .../windowsazure/services/media/models/ListResult.java | 2 +- .../microsoft/windowsazure/services/media/models/Locator.java | 2 +- .../windowsazure/services/media/models/LocatorInfo.java | 2 +- .../windowsazure/services/media/models/LocatorType.java | 2 +- .../windowsazure/services/media/models/MediaProcessor.java | 2 +- .../services/media/models/MediaProcessorInfo.java | 2 +- .../windowsazure/services/media/models/ProtectionKey.java | 2 +- .../windowsazure/services/media/models/ProtectionKeyType.java | 2 +- .../microsoft/windowsazure/services/media/models/Task.java | 2 +- .../windowsazure/services/media/models/TaskInfo.java | 2 +- .../windowsazure/services/media/models/TaskOption.java | 2 +- .../windowsazure/services/media/models/TaskState.java | 2 +- .../services/media/AccessPolicyIntegrationTest.java | 2 +- .../windowsazure/services/media/AssetFileIntegrationTest.java | 2 +- .../windowsazure/services/media/AssetIntegrationTest.java | 2 +- .../services/media/ContentKeyIntegrationTest.java | 2 +- .../windowsazure/services/media/EncryptionHelper.java | 2 +- .../services/media/EncryptionIntegrationTest.java | 2 +- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- .../windowsazure/services/media/LocatorIntegrationTests.java | 2 +- .../windowsazure/services/media/MediaConfigurationTest.java | 2 +- .../services/media/MediaProcessorIntegrationTest.java | 2 +- .../windowsazure/services/media/MediaServiceTest.java | 2 +- .../services/media/ProtectionKeyIntegrationTest.java | 2 +- .../windowsazure/services/media/ServiceExceptionMatcher.java | 2 +- .../windowsazure/services/media/TaskIntegrationTest.java | 2 +- .../windowsazure/services/media/UploadingIntegrationTest.java | 2 +- .../services/media/implementation/LinkRetrievalTest.java | 2 +- .../media/implementation/MediaBatchOperationsTest.java | 2 +- .../media/implementation/OAuthRestProxyIntegrationTest.java | 2 +- .../services/media/implementation/OAuthTokenManagerTest.java | 2 +- .../services/media/implementation/ODataDateParsingTest.java | 2 +- .../implementation/ODataSerializationFromJerseyTest.java | 2 +- .../services/media/implementation/ODataSerializationTest.java | 2 +- .../services/media/implementation/SASTokenFilterTest.java | 2 +- .../services/media/implementation/StatusLineTest.java | 2 +- .../services/media/models/AccessPolicyEntityTest.java | 2 +- .../services/media/models/AccessPolicyInfoTest.java | 2 +- .../windowsazure/services/media/models/AssetEntityTest.java | 2 +- .../windowsazure/services/media/models/AssetFileInfoTest.java | 2 +- .../windowsazure/services/media/models/AssetInfoTest.java | 2 +- .../services/media/models/ContentKeyEntityTest.java | 2 +- .../services/media/models/ContentKeyInfoTest.java | 2 +- .../services/media/models/GenericListResultTest.java | 2 +- .../windowsazure/services/media/models/JobEntityTest.java | 2 +- .../windowsazure/services/media/models/JobInfoTest.java | 2 +- .../windowsazure/services/media/models/LocatorEntityTest.java | 2 +- .../windowsazure/services/media/models/LocatorInfoTest.java | 2 +- .../services/media/models/MediaProcessorEntityTest.java | 2 +- .../services/media/models/MediaProcessorInfoTest.java | 2 +- .../services/media/models/ProtectionKeyEntityTest.java | 2 +- .../windowsazure/services/media/models/TaskEntityTest.java | 2 +- .../windowsazure/services/media/models/TaskInfoTest.java | 2 +- 132 files changed, 135 insertions(+), 135 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 558ec8a18a8e2..5a5b67b63ee64 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index da6d1910cacbc..7dff9cbf19121 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index e2ff92104a159..dc5dce0f57203 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 9cf13258bab88..9ddcc0aff4360 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java index 811110c669050..b68ff4ac75417 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java index b38ee70871855..cef5915ae30a6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 37496ac8c84e8..351ae984e9d82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java index d6831a3dc11cf..8fcbd3e63ee4f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java index 3f799b69cd601..62454cf0407ad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java index 4ad8c880c6d4f..5561ff95b9c5c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index b69a4a7074ddd..3863ebee0effb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index 1df8d5c468a16..bab2477c30f38 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,4 +162,4 @@ private Client createUploaderClient() { clientConfigSettings.applyConfig(client); return client; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java index 54091fff05864..f89bf06ddd934 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index addd226b4cd10..40c623bb46ddf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index 6645d55eecdc9..7aadb0bc95704 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 58afef9d1ad1b..62f4b7aa406da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index b8a357d739f95..e1872e3bdc169 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 2d9735db12f98..2fa1d1ecd9696 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index 8125cf50a1db9..e12d3d86a7ffb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java index 51c7c368152dd..9b0ee8683d686 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index fac9d627b7826..50fc8fecb3c4d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 704e0885db0e2..9d0b7084fbc1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index ea09708c970c4..11ad0695468e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index b06051aadebf1..3f83b4d05103d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index 79936ed8f6bf4..bb2fbd0b2ccb9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java index 01d7d1129701b..62cca67b46101 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index 74e30a558c4f4..683c45caa44ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,4 +96,4 @@ public StatusLine setReason(String reason) { this.reason = reason; return this; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index 4fcb7aa6eb9cc..568ea33ae1807 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java index 6fe22bad67aac..ce90170c90b24 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java index 55e9664bdff7d..ae8e4d1245e35 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 6563c1e08ffd8..6384f3f2794f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java index 0e004668e6ac8..b192c1a5a4625 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java index 5e5325703017e..29fe97af5f84a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java index e4133017dcc29..8f0e5faf73e02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 8493154ddbd3f..077c9ff2d9d87 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index 5dc08a2776268..4d0e04ea6d62c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java index ec1966c204117..9f677b7796dc1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java index 03ded08bb7492..c2fbad8366f62 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index 569cd17d4f3f9..a80dac3422963 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index e6fb9ff83c151..d113c34ea6a02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java index b59c6f2e157b4..bb726f381e82b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java index 7d08a6b780b40..3b8d62fc54357 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index fc055e7908237..4f7f119aa1c45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java index 74e691082fe56..8fb78e1dff8c0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index 82b0dc8fb2bde..ac4bde0c8581a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java index 8f7f60520b8f0..f4d5d0e68822e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java index a4ffb02bc109f..c603c55ff5fb7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index f55d188492f58..39b4c3c3ab8b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index 019285038dac1..b967f8565a591 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index fcc3a6dd43871..1da78968840d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index 930ef1e5a0a69..85da037f500c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,4 +84,4 @@ public interface EntityContract { */ public abstract Object action(EntityActionOperation action) throws ServiceException; -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java index c118f77495880..219111a5a9d77 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java index f3a90ade8a5eb..4069ef1315047 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index d726e4f1caf93..32c9063799aa2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java index 7a5d576c2a30e..47187ecf1dcf6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index ace576ca41eb6..86cd67e483384 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index 8e68fccb6eadd..d280d3cdce734 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java index 370741e5b3b96..85c5deb15acab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java index e1fcc2a9456d3..9b5e7341238f3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java index 751b92b094005..1329fbfc1ecbd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index a4f6a0d4e070c..4f898fe12c54c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java index 90314d099ccde..97ea9655f4405 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index c1fb8f933e2c8..4b5ff222d0390 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java index 09647b8a9711d..25de89f482046 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java index b5f7dd0e88699..5401f8c8b4800 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 63147b5a040ce..349be353c87e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index 2dd506a577ae2..e27d6e8430f6d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java index efc91b1d671cb..aa02e7aae47af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 65fa6108c03ac..7022cabefd710 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java index 6acd1f144c41f..54abb5006bb7a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java index d3aeed54cef5b..2f05f73514545 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index fbe721ea718d4..eff004e3c75ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 26c3531343437..85de5856ccf07 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java index 14df526e3224f..dab25dff18130 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java index 9e18b1ffdeffb..3483eef5e5041 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index f5de67a6b10a5..1e371d2447e37 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 5c5525065b47e..567e87df694b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java index f4a4428c4d24c..704236cd907e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java index 9f25a1c1835f4..a5bac0f4ba7b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java index b941db3945a95..066ec3240d89c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 9201bae0fe0dc..a15333578871d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index f36023ae7d89c..a33c49cf56d41 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index b1dae412b2a09..54dae8b213325 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index ca12e47c3ebbf..5179e65f3df0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java index 884431f75e9da..7096df4d29daf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index 5c3dbf79171fd..a54551b5505d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java index a3c7f714eb4b7..2bf1051ae886f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 1e8d6734a2ec0..4ee051c1c8ca1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index fa6cc3ee89dbf..03940ff2e4b04 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java index 657ff247def2b..fd8e2148e5b78 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java index 40280c8d338cf..ad6d4f50c39e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index 3f7f2eb2df698..a37c8a7b076a6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index e151ba5c58802..cc88d6bd1bec3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index e2caeb9c26120..6a3d8f71ed8aa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 6344a294abd0c..210ab75c83fbf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 49f9c7f3159d1..e7253ea00decf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 071d5b7e1c7ba..f623565222d24 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 1269a018e74c8..2969d547ca311 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index f87765a0ad3c0..bd6fde565fbd7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java index a67319c6cf8ab..21777d0d8f0f0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index 6ca7d6c679a82..cf32e7fdc59cd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java index 4d00708f9bdb9..5baed965b0514 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java index f3f1f07f4e724..a18a3ac62a0ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java index ea4135fcb9076..6bdeec2ee85cf 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index c9a374a91ced7..b35911a80cc70 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 25ee429108f49..340fab1feaacd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 6b050376bc04c..80a6d539977ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index f46863d2bdb89..50041ef5f418f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java index 230bcfc1fa6c3..2760db1b9b57f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index 98bd6beeab977..da01dc1f02547 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java index a6c39586bcd7a..c813efdd70e95 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 2d03d319f8b25..7b72db8288434 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 80905eb549c3e..4e6130f58ec7f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java index b4197bbaabedd..8aac300e1cbfd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java index 6ff249b4d069c..2b1e0a8079494 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index bd5a7229192c3..62fe143a38d05 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java index 6a1764eee282d..c50334007419c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index c543b5767be56..20749bf7a2815 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java index 28eac36a9ce68..b3a803d476391 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index 21eba4a11ded9..a3cd6520628fa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index b453a421f1540..e88db97f476ec 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index 675b3dc090b02..b1306a45bb84d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java index b6235a5c17a6d..0bc10ca2dc305 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index 7112e586d2bae..07d5751f468ef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java index 9f90ab4aa2e34..08b3a9dae97c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index df8982f7e0ec8..aad3e43145412 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index ab5ef0cf27206..bd185ae7d8b18 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index e81fbcea76e94..21658017dff87 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java index 4e05b0f5e4538..69160cd7f646d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java index 98c43e656a6a7..02d315e8c59b9 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index fc67311f4b2ae..32298ace76cc3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java index 887b8d1357cf8..dc5958e6f8edc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright 2013 Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 2ba8f9ba0eeb620108c347342d9d114bed921d20 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 21:39:34 -0800 Subject: [PATCH 629/664] remove 2013 from the copyright --- .../java/com/microsoft/windowsazure/services/media/Exports.java | 2 +- .../windowsazure/services/media/MediaConfiguration.java | 2 +- .../microsoft/windowsazure/services/media/MediaContract.java | 2 +- .../com/microsoft/windowsazure/services/media/MediaService.java | 2 +- .../services/media/WritableBlobContainerContract.java | 2 +- .../windowsazure/services/media/implementation/ActiveToken.java | 2 +- .../services/media/implementation/MediaBatchOperations.java | 2 +- .../services/media/implementation/MediaBlobContainerWriter.java | 2 +- .../services/media/implementation/MediaBlobRestProxy.java | 2 +- .../services/media/implementation/MediaContentProvider.java | 2 +- .../services/media/implementation/MediaExceptionProcessor.java | 2 +- .../services/media/implementation/MediaRestProxy.java | 2 +- .../services/media/implementation/OAuthContract.java | 2 +- .../windowsazure/services/media/implementation/OAuthFilter.java | 2 +- .../services/media/implementation/OAuthRestProxy.java | 2 +- .../services/media/implementation/OAuthTokenManager.java | 2 +- .../services/media/implementation/OAuthTokenResponse.java | 2 +- .../services/media/implementation/ODataAtomMarshaller.java | 2 +- .../services/media/implementation/ODataAtomUnmarshaller.java | 2 +- .../services/media/implementation/ODataDateAdapter.java | 2 +- .../windowsazure/services/media/implementation/ODataEntity.java | 2 +- .../services/media/implementation/ODataEntityProvider.java | 2 +- .../services/media/implementation/RedirectFilter.java | 2 +- .../services/media/implementation/ResourceLocationManager.java | 2 +- .../services/media/implementation/SASTokenFilter.java | 2 +- .../media/implementation/SetBoundaryMultipartDataSource.java | 2 +- .../windowsazure/services/media/implementation/StatusLine.java | 2 +- .../services/media/implementation/VersionHeadersFilter.java | 2 +- .../services/media/implementation/content/AccessPolicyType.java | 2 +- .../services/media/implementation/content/AssetFileType.java | 2 +- .../services/media/implementation/content/AssetType.java | 2 +- .../services/media/implementation/content/Constants.java | 2 +- .../media/implementation/content/ContentKeyRestType.java | 2 +- .../services/media/implementation/content/ErrorDetailType.java | 2 +- .../services/media/implementation/content/JobType.java | 2 +- .../services/media/implementation/content/LocatorRestType.java | 2 +- .../media/implementation/content/MediaProcessorType.java | 2 +- .../services/media/implementation/content/MediaUriType.java | 2 +- .../services/media/implementation/content/ODataActionType.java | 2 +- .../services/media/implementation/content/ObjectFactory.java | 2 +- .../media/implementation/content/ProtectionKeyIdType.java | 2 +- .../media/implementation/content/ProtectionKeyRestType.java | 2 +- .../services/media/implementation/content/TaskType.java | 2 +- .../services/media/implementation/content/package-info.java | 2 +- .../media/implementation/entities/DefaultActionOperation.java | 2 +- .../media/implementation/entities/DefaultDeleteOperation.java | 2 +- .../media/implementation/entities/DefaultGetOperation.java | 2 +- .../media/implementation/entities/DefaultListOperation.java | 2 +- .../media/implementation/entities/EntityActionOperation.java | 2 +- .../media/implementation/entities/EntityBatchOperation.java | 2 +- .../services/media/implementation/entities/EntityContract.java | 2 +- .../media/implementation/entities/EntityCreateOperation.java | 2 +- .../media/implementation/entities/EntityGetOperation.java | 2 +- .../media/implementation/entities/EntityLinkOperation.java | 2 +- .../media/implementation/entities/EntityListOperation.java | 2 +- .../services/media/implementation/entities/EntityOperation.java | 2 +- .../media/implementation/entities/EntityOperationBase.java | 2 +- .../implementation/entities/EntityOperationSingleResult.java | 2 +- .../entities/EntityOperationSingleResultBase.java | 2 +- .../services/media/implementation/entities/EntityProxyData.java | 2 +- .../services/media/implementation/entities/EntityRestProxy.java | 2 +- .../media/implementation/entities/EntityUpdateOperation.java | 2 +- .../windowsazure/services/media/models/AccessPolicy.java | 2 +- .../windowsazure/services/media/models/AccessPolicyInfo.java | 2 +- .../services/media/models/AccessPolicyPermission.java | 2 +- .../com/microsoft/windowsazure/services/media/models/Asset.java | 2 +- .../microsoft/windowsazure/services/media/models/AssetFile.java | 2 +- .../windowsazure/services/media/models/AssetFileInfo.java | 2 +- .../microsoft/windowsazure/services/media/models/AssetInfo.java | 2 +- .../windowsazure/services/media/models/AssetOption.java | 2 +- .../windowsazure/services/media/models/AssetState.java | 2 +- .../windowsazure/services/media/models/ContentKey.java | 2 +- .../windowsazure/services/media/models/ContentKeyInfo.java | 2 +- .../windowsazure/services/media/models/ContentKeyType.java | 2 +- .../windowsazure/services/media/models/ErrorDetail.java | 2 +- .../com/microsoft/windowsazure/services/media/models/Job.java | 2 +- .../microsoft/windowsazure/services/media/models/JobInfo.java | 2 +- .../microsoft/windowsazure/services/media/models/JobState.java | 2 +- .../microsoft/windowsazure/services/media/models/LinkInfo.java | 2 +- .../windowsazure/services/media/models/ListResult.java | 2 +- .../microsoft/windowsazure/services/media/models/Locator.java | 2 +- .../windowsazure/services/media/models/LocatorInfo.java | 2 +- .../windowsazure/services/media/models/LocatorType.java | 2 +- .../windowsazure/services/media/models/MediaProcessor.java | 2 +- .../windowsazure/services/media/models/MediaProcessorInfo.java | 2 +- .../windowsazure/services/media/models/ProtectionKey.java | 2 +- .../windowsazure/services/media/models/ProtectionKeyType.java | 2 +- .../com/microsoft/windowsazure/services/media/models/Task.java | 2 +- .../microsoft/windowsazure/services/media/models/TaskInfo.java | 2 +- .../windowsazure/services/media/models/TaskOption.java | 2 +- .../microsoft/windowsazure/services/media/models/TaskState.java | 2 +- .../services/media/AccessPolicyIntegrationTest.java | 2 +- .../windowsazure/services/media/AssetFileIntegrationTest.java | 2 +- .../windowsazure/services/media/AssetIntegrationTest.java | 2 +- .../windowsazure/services/media/ContentKeyIntegrationTest.java | 2 +- .../microsoft/windowsazure/services/media/EncryptionHelper.java | 2 +- .../windowsazure/services/media/EncryptionIntegrationTest.java | 2 +- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- .../windowsazure/services/media/LocatorIntegrationTests.java | 2 +- .../windowsazure/services/media/MediaConfigurationTest.java | 2 +- .../services/media/MediaProcessorIntegrationTest.java | 2 +- .../microsoft/windowsazure/services/media/MediaServiceTest.java | 2 +- .../services/media/ProtectionKeyIntegrationTest.java | 2 +- .../windowsazure/services/media/ServiceExceptionMatcher.java | 2 +- .../windowsazure/services/media/TaskIntegrationTest.java | 2 +- .../windowsazure/services/media/UploadingIntegrationTest.java | 2 +- .../services/media/implementation/LinkRetrievalTest.java | 2 +- .../services/media/implementation/MediaBatchOperationsTest.java | 2 +- .../media/implementation/OAuthRestProxyIntegrationTest.java | 2 +- .../services/media/implementation/OAuthTokenManagerTest.java | 2 +- .../services/media/implementation/ODataDateParsingTest.java | 2 +- .../media/implementation/ODataSerializationFromJerseyTest.java | 2 +- .../services/media/implementation/ODataSerializationTest.java | 2 +- .../services/media/implementation/SASTokenFilterTest.java | 2 +- .../services/media/implementation/StatusLineTest.java | 2 +- .../services/media/models/AccessPolicyEntityTest.java | 2 +- .../services/media/models/AccessPolicyInfoTest.java | 2 +- .../windowsazure/services/media/models/AssetEntityTest.java | 2 +- .../windowsazure/services/media/models/AssetFileInfoTest.java | 2 +- .../windowsazure/services/media/models/AssetInfoTest.java | 2 +- .../services/media/models/ContentKeyEntityTest.java | 2 +- .../windowsazure/services/media/models/ContentKeyInfoTest.java | 2 +- .../services/media/models/GenericListResultTest.java | 2 +- .../windowsazure/services/media/models/JobEntityTest.java | 2 +- .../windowsazure/services/media/models/JobInfoTest.java | 2 +- .../windowsazure/services/media/models/LocatorEntityTest.java | 2 +- .../windowsazure/services/media/models/LocatorInfoTest.java | 2 +- .../services/media/models/MediaProcessorEntityTest.java | 2 +- .../services/media/models/MediaProcessorInfoTest.java | 2 +- .../services/media/models/ProtectionKeyEntityTest.java | 2 +- .../windowsazure/services/media/models/TaskEntityTest.java | 2 +- .../windowsazure/services/media/models/TaskInfoTest.java | 2 +- 132 files changed, 132 insertions(+), 132 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java index 5a5b67b63ee64..6739230f987ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java index 7dff9cbf19121..f25537df87f46 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index dc5dce0f57203..edfb0e4704086 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java index 9ddcc0aff4360..8a90501dc2fe8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaService.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java index b68ff4ac75417..835cc2ec8954a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/WritableBlobContainerContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java index cef5915ae30a6..78efb77135225 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 351ae984e9d82..a9dd3e63cec98 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java index 8fcbd3e63ee4f..87c4f66dde5e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobContainerWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java index 62454cf0407ad..46d0ba286ee96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBlobRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java index 5561ff95b9c5c..9e04edf56d038 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaContentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index 3863ebee0effb..230fdc4369006 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index bab2477c30f38..fdee1c89571ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java index f89bf06ddd934..ef2982aa2c170 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index 40c623bb46ddf..c5083aeeae375 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index 7aadb0bc95704..4f17ae38fb961 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index 62f4b7aa406da..d0d082c5fb21f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index e1872e3bdc169..29131300ac3c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java index 2fa1d1ecd9696..97ea44353600a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomMarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java index e12d3d86a7ffb..372eced0e882c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataAtomUnmarshaller.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java index 9b0ee8683d686..c09aa98d873dc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataDateAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 50fc8fecb3c4d..260ab69221143 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java index 9d0b7084fbc1b..0a21506085605 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java index 11ad0695468e0..433e5ec7e6e89 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/RedirectFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java index 3f83b4d05103d..e1d4807f51a23 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java index bb2fbd0b2ccb9..f5c3ef493a686 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java index 62cca67b46101..98af8d57b1256 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/SetBoundaryMultipartDataSource.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index 683c45caa44ee..65bf31c120f7e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java index 568ea33ae1807..d21e3852162c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/VersionHeadersFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java index ce90170c90b24..b362d17696943 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AccessPolicyType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java index ae8e4d1245e35..fcf17089d2986 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetFileType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java index 6384f3f2794f3..8cbc101c74bd8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/AssetType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java index b192c1a5a4625..b713aedf0961d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java index 29fe97af5f84a..72e0e7261481c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ContentKeyRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java index 8f0e5faf73e02..3a5ffdef35f33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ErrorDetailType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java index 077c9ff2d9d87..18a8d027d0c3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/JobType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java index 4d0e04ea6d62c..1f30a8a6afcdd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/LocatorRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java index 9f677b7796dc1..c79778a5b3417 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaProcessorType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java index c2fbad8366f62..7c612ed67a1a3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaUriType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java index a80dac3422963..bc358a3540b83 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ODataActionType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java index d113c34ea6a02..3769e3a1aa027 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ObjectFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java index bb726f381e82b..3190c34c29077 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyIdType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java index 3b8d62fc54357..d17551fb13fb0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/ProtectionKeyRestType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java index 4f7f119aa1c45..9436ca9ab0255 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/TaskType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java index 8fb78e1dff8c0..1c9ecda9766d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/package-info.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java index ac4bde0c8581a..06db932f75810 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java index f4d5d0e68822e..86c19e48ce891 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java index c603c55ff5fb7..5261caf45d669 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java index 39b4c3c3ab8b2..6236d2ffc64a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java index b967f8565a591..34b35854f8f42 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java index 1da78968840d4..323de86a27040 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java index 85da037f500c4..7da1ee336b22e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java index 219111a5a9d77..45c5a174b9d15 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java index 4069ef1315047..221757ef0884b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java index 32c9063799aa2..a31dee196211f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java index 47187ecf1dcf6..aceec3e0ffa63 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java index 86cd67e483384..62861885ed214 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java index d280d3cdce734..88303b350631d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java index 85c5deb15acab..40fa6464895ac 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java index 9b5e7341238f3..894e786c7295b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java index 1329fbfc1ecbd..3e480f9683439 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java index 4f898fe12c54c..36dde69dad114 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java index 97ea9655f4405..3a4db445cda60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index 4b5ff222d0390..e5b5bb502fee8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java index 25de89f482046..290e1bdcb25d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java index 5401f8c8b4800..d721069e6df8b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermission.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 349be353c87e7..ce0c03277296d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index e27d6e8430f6d..e8525782a58d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java index aa02e7aae47af..813b6567dfe37 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFileInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 7022cabefd710..669d9c16bcefb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java index 54abb5006bb7a..8722e853ffcf5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetOption.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java index 2f05f73514545..8afc9954a8bda 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetState.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index eff004e3c75ab..28076c8dfed42 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java index 85de5856ccf07..33e018dc16744 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java index dab25dff18130..6015424f6e6b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java index 3483eef5e5041..7d3b9344bdf69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ErrorDetail.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 1e371d2447e37..e73940980b0ef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 567e87df694b3..8532808ef4dc5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java index 704236cd907e1..b7bce6a0b273d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobState.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java index a5bac0f4ba7b1..e2558dae5c904 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java index 066ec3240d89c..c60001afd7019 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ListResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index a15333578871d..f5ea7ff16639a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index a33c49cf56d41..57db045931909 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java index 54dae8b213325..d8ade5d01c4ba 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorType.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index 5179e65f3df0c..ffd017e7f0bae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java index 7096df4d29daf..9f3a0df22bcbe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index a54551b5505d2..ec2b343373e12 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java index 2bf1051ae886f..64db9a5327976 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyType.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 4ee051c1c8ca1..ac2672ee19d09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index 03940ff2e4b04..849fee00fc3aa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java index fd8e2148e5b78..cb3dd9ba79420 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskOption.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java index ad6d4f50c39e3..3793e2e606d67 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskState.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java index a37c8a7b076a6..32bfdbe2dfb9a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java index cc88d6bd1bec3..8a9bc1d7b76bd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetFileIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 6a3d8f71ed8aa..f4008661a5992 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java index 210ab75c83fbf..3f479a6ea8b79 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ContentKeyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index e7253ea00decf..aa5ecd55c13c1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index f623565222d24..3b71c7d8e0210 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 2969d547ca311..982c0745ee7f8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java index bd6fde565fbd7..e66162eef69f3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/LocatorIntegrationTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java index 21777d0d8f0f0..ea1f80c485bca 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaConfigurationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java index cf32e7fdc59cd..052fdc0811ef0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaProcessorIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java index 5baed965b0514..59713c861809c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/MediaServiceTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java index a18a3ac62a0ae..972c11f6f20d4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java index 6bdeec2ee85cf..5baee5b57cd2d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ServiceExceptionMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index b35911a80cc70..5ee702540f042 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java index 340fab1feaacd..080fe6fc4cf11 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/UploadingIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 80a6d539977ae..85307cbbfdaf1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java index 50041ef5f418f..89ff3859f8b23 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperationsTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java index 2760db1b9b57f..f559ba17d5a6f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java index da01dc1f02547..50794db32c088 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java index c813efdd70e95..faea8a747fc64 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataDateParsingTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java index 7b72db8288434..580a8909fec5e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationFromJerseyTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java index 4e6130f58ec7f..8605c5938a138 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ODataSerializationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java index 8aac300e1cbfd..ac543d83b54c6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/SASTokenFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java index 2b1e0a8079494..4c5b2d2d2518b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/StatusLineTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index 62fe143a38d05..7cc3019ad1e51 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java index c50334007419c..7e4a488dd9b75 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 20749bf7a2815..455b86a81deea 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java index b3a803d476391..a3e577fa847c0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java index a3cd6520628fa..66d3b0f7e4cee 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index e88db97f476ec..2e46980b2003f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java index b1306a45bb84d..1fd2c0cb267df 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java index 0bc10ca2dc305..7409542605c13 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/GenericListResultTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index 07d5751f468ef..e3cf221464938 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java index 08b3a9dae97c4..6ed12b3649d51 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index aad3e43145412..ea09585143069 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java index bd185ae7d8b18..25f67d48de245 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index 21658017dff87..df381cc73b281 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java index 69160cd7f646d..72d87f2db4c0c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java index 02d315e8c59b9..79991d82f0d2b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ProtectionKeyEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java index 32298ace76cc3..fb09aac45e0c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskEntityTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java index dc5958e6f8edc..a0d32233b9e2b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/TaskInfoTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2013 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 2499d0f540f43f46c279fffb8f656089bc5a2304 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Tue, 8 Jan 2013 21:56:24 -0800 Subject: [PATCH 630/664] add copy right header for the following files. --- .../ODataEntityCollectionProvider.java | 12 ++ .../implementation/atom/CategoryType.java | 98 ++++++------ .../implementation/atom/ContentType.java | 111 ++++++------- .../implementation/atom/DateTimeType.java | 79 +++++----- .../media/implementation/atom/EntryType.java | 129 +++++++-------- .../media/implementation/atom/FeedType.java | 133 ++++++++-------- .../implementation/atom/GeneratorType.java | 103 ++++++------ .../media/implementation/atom/IconType.java | 83 +++++----- .../media/implementation/atom/IdType.java | 83 +++++----- .../media/implementation/atom/LinkType.java | 147 +++++++++--------- .../media/implementation/atom/LogoType.java | 83 +++++----- .../implementation/atom/ObjectFactory.java | 133 ++++++++-------- .../media/implementation/atom/PersonType.java | 98 ++++++------ .../media/implementation/atom/SourceType.java | 129 +++++++-------- .../media/implementation/atom/TextType.java | 101 ++++++------ .../media/implementation/atom/UriType.java | 79 +++++----- .../implementation/atom/package-info.java | 25 ++- .../content/MediaServiceDTO.java | 16 +- .../entities/EntityDeleteOperation.java | 15 ++ .../services/media/EntityProxyTest.java | 15 ++ .../services/media/ExportsTest.java | 15 ++ .../services/media/IntegrationTestBase.java | 15 ++ .../implementation/RedirectionFilterTest.java | 15 ++ .../ResourceLocationManagerTest.java | 15 ++ .../models/AccessPolicyPermissionTest.java | 15 ++ .../media/models/AssetFileEntityTest.java | 15 ++ 26 files changed, 995 insertions(+), 767 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java index 403295b7843ff..b5d4ebaeceddc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntityCollectionProvider.java @@ -1,6 +1,18 @@ /** + * Copyright Microsoft Corporation * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package com.microsoft.windowsazure.services.media.implementation; import java.io.IOException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java index 3e0138fef82c8..6c31c7904783e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java @@ -1,15 +1,29 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // - package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -20,15 +34,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom cagegory construct is defined in section 4.2.2 of the format spec. - * + * The Atom cagegory construct is defined in section 4.2.2 of the format spec. * - * <p>Java class for categoryType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * Java class for categoryType complex type. + * + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="categoryType"> @@ -65,15 +80,14 @@ public class CategoryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the term property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getTerm() { return term; @@ -83,9 +97,8 @@ public String getTerm() { * Sets the value of the term property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setTerm(String value) { this.term = value; @@ -95,9 +108,8 @@ public void setTerm(String value) { * Gets the value of the scheme property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getScheme() { return scheme; @@ -107,9 +119,8 @@ public String getScheme() { * Sets the value of the scheme property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setScheme(String value) { this.scheme = value; @@ -119,9 +130,8 @@ public void setScheme(String value) { * Gets the value of the label property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLabel() { return label; @@ -131,9 +141,8 @@ public String getLabel() { * Sets the value of the label property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLabel(String value) { this.label = value; @@ -143,9 +152,8 @@ public void setLabel(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -155,9 +163,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -167,9 +174,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -179,9 +185,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -191,15 +196,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java index 8e03e7cb2b4a8..e3b955b334b1a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -24,15 +39,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom content construct is defined in section 4.1.3 of the format spec. - * + * The Atom content construct is defined in section 4.1.3 of the format spec. + * * - * <p>Java class for contentType complex type. + * <p> + * Java class for contentType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="contentType"> @@ -53,9 +69,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "contentType", propOrder = { - "content" -}) +@XmlType(name = "contentType", propOrder = { "content" }) public class ContentType { @XmlMixed @@ -74,30 +88,28 @@ public class ContentType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom content construct is defined in section 4.1.3 of the format spec. - * Gets the value of the content property. + * The Atom content construct is defined in section 4.1.3 of the format spec. + * Gets the value of the content property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the content property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the content property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getContent().add(newItem); + * getContent().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link Object } - * {@link String } + * Objects of the following type(s) are allowed in the list {@link Object } {@link String } * * */ @@ -112,9 +124,8 @@ public List<Object> getContent() { * Gets the value of the type property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getType() { return type; @@ -124,9 +135,8 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setType(String value) { this.type = value; @@ -136,9 +146,8 @@ public void setType(String value) { * Gets the value of the src property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getSrc() { return src; @@ -148,9 +157,8 @@ public String getSrc() { * Sets the value of the src property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setSrc(String value) { this.src = value; @@ -160,9 +168,8 @@ public void setSrc(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -172,9 +179,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -184,9 +190,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -196,9 +201,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -208,15 +212,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java index 4232aee1748e1..fb3eef7556a3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -22,11 +37,12 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; - /** - * <p>Java class for dateTimeType complex type. + * <p> + * Java class for dateTimeType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="dateTimeType"> @@ -42,9 +58,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "dateTimeType", propOrder = { - "value" -}) +@XmlType(name = "dateTimeType", propOrder = { "value" }) public class DateTimeType { @XmlValue @@ -58,15 +72,14 @@ public class DateTimeType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link XMLGregorianCalendar } - * + * possible object is {@link XMLGregorianCalendar } + * */ public XMLGregorianCalendar getValue() { return value; @@ -76,9 +89,8 @@ public XMLGregorianCalendar getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link XMLGregorianCalendar } - * + * allowed object is {@link XMLGregorianCalendar } + * */ public void setValue(XMLGregorianCalendar value) { this.value = value; @@ -88,9 +100,8 @@ public void setValue(XMLGregorianCalendar value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -100,9 +111,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -112,9 +122,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -124,9 +133,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -136,15 +144,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index d3244af70517d..ab623248e7a53 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,15 +41,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom entry construct is defined in section 4.1.2 of the format spec. - * + * The Atom entry construct is defined in section 4.1.2 of the format spec. + * * - * <p>Java class for entryType complex type. + * <p> + * Java class for entryType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="entryType"> @@ -65,25 +81,22 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "entryType", propOrder = { - "entryChildren" -}) +@XmlType(name = "entryType", propOrder = { "entryChildren" }) public class EntryType { @XmlElementRefs({ - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) - }) + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) protected List<Object> entryChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -94,39 +107,32 @@ public class EntryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the entryChildren property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the entryChildren property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the entryChildren property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getEntryChildren().add(newItem); + * getEntryChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link ContentType }{@code >} - * {@link Object } + * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link ContentType }{@code >} {@link Object } * * */ @@ -141,9 +147,8 @@ public List<Object> getEntryChildren() { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -153,9 +158,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -165,9 +169,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -177,9 +180,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -189,15 +191,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java index 9c5ea3df46aef..74fd7d373ca17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.18 at 11:05:53 AM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.18 at 11:05:53 AM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,15 +41,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom feed construct is defined in section 4.1.1 of the format spec. - * + * The Atom feed construct is defined in section 4.1.1 of the format spec. + * * - * <p>Java class for feedType complex type. + * <p> + * Java class for feedType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="feedType"> @@ -66,26 +82,23 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "feedType", propOrder = { - "feedChildren" -}) +@XmlType(name = "feedType", propOrder = { "feedChildren" }) public class FeedType { @XmlElementRefs({ - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) - }) + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) protected List<Object> feedChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -96,40 +109,33 @@ public class FeedType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the feedChildren property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the feedChildren property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the feedChildren property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getFeedChildren().add(newItem); + * getFeedChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link Object } - * {@link JAXBElement }{@code <}{@link EntryType }{@code >} - * {@link JAXBElement }{@code <}{@link LogoType }{@code >} - * {@link JAXBElement }{@code <}{@link IconType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link Object } {@link JAXBElement }{@code <}{@link EntryType }{@code >} {@link JAXBElement }{@code <} + * {@link LogoType }{@code >} {@link JAXBElement }{@code <}{@link IconType }{@code >} {@link JAXBElement }{@code <} + * {@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link CategoryType }{@code >} {@link JAXBElement }{@code <} + * {@link TextType }{@code >} * * */ @@ -144,9 +150,8 @@ public List<Object> getFeedChildren() { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -156,9 +161,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -168,9 +172,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -180,9 +183,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -192,15 +194,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java index 08f56f2f84c75..29c20e0988edf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,15 +36,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom generator element is defined in section 4.2.4 of the format spec. - * + * The Atom generator element is defined in section 4.2.4 of the format spec. + * * - * <p>Java class for generatorType complex type. + * <p> + * Java class for generatorType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="generatorType"> @@ -47,9 +63,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "generatorType", propOrder = { - "value" -}) +@XmlType(name = "generatorType", propOrder = { "value" }) public class GeneratorType { @XmlValue @@ -67,15 +81,14 @@ public class GeneratorType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getValue() { return value; @@ -85,9 +98,8 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; @@ -97,9 +109,8 @@ public void setValue(String value) { * Gets the value of the uri property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getUri() { return uri; @@ -109,9 +120,8 @@ public String getUri() { * Sets the value of the uri property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setUri(String value) { this.uri = value; @@ -121,9 +131,8 @@ public void setUri(String value) { * Gets the value of the version property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getVersion() { return version; @@ -133,9 +142,8 @@ public String getVersion() { * Sets the value of the version property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setVersion(String value) { this.version = value; @@ -145,9 +153,8 @@ public void setVersion(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -157,9 +164,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -169,9 +175,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -181,9 +186,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -193,15 +197,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java index 33675d2d588a5..31fcba1199c80 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,15 +36,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom icon construct is defined in section 4.2.5 of the format spec. - * + * The Atom icon construct is defined in section 4.2.5 of the format spec. + * * - * <p>Java class for iconType complex type. + * <p> + * Java class for iconType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="iconType"> @@ -45,9 +61,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "iconType", propOrder = { - "value" -}) +@XmlType(name = "iconType", propOrder = { "value" }) public class IconType { @XmlValue @@ -61,15 +75,14 @@ public class IconType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getValue() { return value; @@ -79,9 +92,8 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; @@ -91,9 +103,8 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -103,9 +114,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -115,9 +125,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -127,9 +136,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -139,15 +147,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java index 0633ac55a4110..e221e7eae9ac6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,15 +36,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom id construct is defined in section 4.2.6 of the format spec. - * + * The Atom id construct is defined in section 4.2.6 of the format spec. + * * - * <p>Java class for idType complex type. + * <p> + * Java class for idType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="idType"> @@ -45,9 +61,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "idType", propOrder = { - "value" -}) +@XmlType(name = "idType", propOrder = { "value" }) public class IdType { @XmlValue @@ -61,15 +75,14 @@ public class IdType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getValue() { return value; @@ -79,9 +92,8 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; @@ -91,9 +103,8 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -103,9 +114,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -115,9 +125,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -127,9 +136,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -139,15 +147,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java index 7ea60224d7f02..8486f4d63a171 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java @@ -1,16 +1,31 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -22,15 +37,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom link construct is defined in section 3.4 of the format spec. - * + * The Atom link construct is defined in section 3.4 of the format spec. + * * - * <p>Java class for linkType complex type. + * <p> + * Java class for linkType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="linkType"> @@ -52,9 +68,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "linkType", propOrder = { - "content" -}) +@XmlType(name = "linkType", propOrder = { "content" }) public class LinkType { @XmlValue @@ -83,17 +97,16 @@ public class LinkType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom link construct is defined in section 3.4 of the format spec. - * + * The Atom link construct is defined in section 3.4 of the format spec. + * * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getContent() { return content; @@ -103,9 +116,8 @@ public String getContent() { * Sets the value of the content property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setContent(String value) { this.content = value; @@ -115,9 +127,8 @@ public void setContent(String value) { * Gets the value of the href property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getHref() { return href; @@ -127,9 +138,8 @@ public String getHref() { * Sets the value of the href property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setHref(String value) { this.href = value; @@ -139,9 +149,8 @@ public void setHref(String value) { * Gets the value of the rel property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getRel() { return rel; @@ -151,9 +160,8 @@ public String getRel() { * Sets the value of the rel property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setRel(String value) { this.rel = value; @@ -163,9 +171,8 @@ public void setRel(String value) { * Gets the value of the type property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getType() { return type; @@ -175,9 +182,8 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setType(String value) { this.type = value; @@ -187,9 +193,8 @@ public void setType(String value) { * Gets the value of the hreflang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getHreflang() { return hreflang; @@ -199,9 +204,8 @@ public String getHreflang() { * Sets the value of the hreflang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setHreflang(String value) { this.hreflang = value; @@ -211,9 +215,8 @@ public void setHreflang(String value) { * Gets the value of the title property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getTitle() { return title; @@ -223,9 +226,8 @@ public String getTitle() { * Sets the value of the title property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setTitle(String value) { this.title = value; @@ -235,9 +237,8 @@ public void setTitle(String value) { * Gets the value of the length property. * * @return - * possible object is - * {@link BigInteger } - * + * possible object is {@link BigInteger } + * */ public BigInteger getLength() { return length; @@ -247,9 +248,8 @@ public BigInteger getLength() { * Sets the value of the length property. * * @param value - * allowed object is - * {@link BigInteger } - * + * allowed object is {@link BigInteger } + * */ public void setLength(BigInteger value) { this.length = value; @@ -259,9 +259,8 @@ public void setLength(BigInteger value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -271,9 +270,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -283,9 +281,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -295,9 +292,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -307,15 +303,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java index 443f58c771070..c492479802111 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,15 +36,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom logo construct is defined in section 4.2.8 of the format spec. - * + * The Atom logo construct is defined in section 4.2.8 of the format spec. + * * - * <p>Java class for logoType complex type. + * <p> + * Java class for logoType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="logoType"> @@ -45,9 +61,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "logoType", propOrder = { - "value" -}) +@XmlType(name = "logoType", propOrder = { "value" }) public class LogoType { @XmlValue @@ -61,15 +75,14 @@ public class LogoType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getValue() { return value; @@ -79,9 +92,8 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; @@ -91,9 +103,8 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -103,9 +114,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -115,9 +125,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -127,9 +136,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -139,15 +147,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java index c620b60d57564..7efa05a7b258b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -15,19 +29,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.microsoft.windowsazure.services.media.implementation.atom package. - * <p>An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.microsoft.windowsazure.services.media.implementation.atom package. + * <p> + * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. + * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in + * this class. * */ @XmlRegistry @@ -56,7 +66,8 @@ public class ObjectFactory { private final static QName _FeedTypeIcon_QNAME = new QName("http://www.w3.org/2005/Atom", "icon"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.windowsazure.services.media.implementation.atom + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: + * com.microsoft.windowsazure.services.media.implementation.atom * */ public ObjectFactory() { @@ -175,7 +186,7 @@ public CategoryType createCategoryType() { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry") @@ -184,7 +195,7 @@ public JAXBElement<EntryType> createEntry(EntryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "feed") @@ -193,7 +204,7 @@ public JAXBElement<FeedType> createFeed(FeedType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "name", scope = PersonType.class) @@ -202,7 +213,7 @@ public JAXBElement<String> createPersonTypeName(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "email", scope = PersonType.class) @@ -212,7 +223,7 @@ public JAXBElement<String> createPersonTypeEmail(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "uri", scope = PersonType.class) @@ -221,7 +232,7 @@ public JAXBElement<UriType> createPersonTypeUri(UriType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = EntryType.class) @@ -230,7 +241,7 @@ public JAXBElement<TextType> createEntryTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = EntryType.class) @@ -239,7 +250,7 @@ public JAXBElement<CategoryType> createEntryTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = EntryType.class) @@ -248,7 +259,7 @@ public JAXBElement<PersonType> createEntryTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "summary", scope = EntryType.class) @@ -257,7 +268,7 @@ public JAXBElement<TextType> createEntryTypeSummary(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = EntryType.class) @@ -266,7 +277,7 @@ public JAXBElement<IdType> createEntryTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "content", scope = EntryType.class) @@ -275,7 +286,7 @@ public JAXBElement<ContentType> createEntryTypeContent(ContentType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = EntryType.class) @@ -284,7 +295,7 @@ public JAXBElement<LinkType> createEntryTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = EntryType.class) @@ -293,7 +304,7 @@ public JAXBElement<PersonType> createEntryTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = EntryType.class) @@ -302,7 +313,7 @@ public JAXBElement<DateTimeType> createEntryTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "source", scope = EntryType.class) @@ -311,7 +322,7 @@ public JAXBElement<TextType> createEntryTypeSource(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = EntryType.class) @@ -320,7 +331,7 @@ public JAXBElement<TextType> createEntryTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "published", scope = EntryType.class) @@ -329,7 +340,7 @@ public JAXBElement<DateTimeType> createEntryTypePublished(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = FeedType.class) @@ -338,7 +349,7 @@ public JAXBElement<CategoryType> createFeedTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = FeedType.class) @@ -347,7 +358,7 @@ public JAXBElement<TextType> createFeedTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = FeedType.class) @@ -356,7 +367,7 @@ public JAXBElement<PersonType> createFeedTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = FeedType.class) @@ -365,7 +376,7 @@ public JAXBElement<IdType> createFeedTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry", scope = FeedType.class) @@ -374,7 +385,7 @@ public JAXBElement<EntryType> createFeedTypeEntry(EntryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = FeedType.class) @@ -383,7 +394,7 @@ public JAXBElement<PersonType> createFeedTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = FeedType.class) @@ -392,7 +403,7 @@ public JAXBElement<DateTimeType> createFeedTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = FeedType.class) @@ -401,7 +412,7 @@ public JAXBElement<GeneratorType> createFeedTypeGenerator(GeneratorType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = FeedType.class) @@ -410,7 +421,7 @@ public JAXBElement<TextType> createFeedTypeSubtitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = FeedType.class) @@ -419,7 +430,7 @@ public JAXBElement<LogoType> createFeedTypeLogo(LogoType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = FeedType.class) @@ -428,7 +439,7 @@ public JAXBElement<IconType> createFeedTypeIcon(IconType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = FeedType.class) @@ -437,7 +448,7 @@ public JAXBElement<LinkType> createFeedTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = FeedType.class) @@ -446,7 +457,7 @@ public JAXBElement<TextType> createFeedTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = SourceType.class) @@ -455,7 +466,7 @@ public JAXBElement<TextType> createSourceTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = SourceType.class) @@ -464,7 +475,7 @@ public JAXBElement<CategoryType> createSourceTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = SourceType.class) @@ -473,7 +484,7 @@ public JAXBElement<IconType> createSourceTypeIcon(IconType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = SourceType.class) @@ -482,7 +493,7 @@ public JAXBElement<PersonType> createSourceTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = SourceType.class) @@ -491,7 +502,7 @@ public JAXBElement<LogoType> createSourceTypeLogo(LogoType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = SourceType.class) @@ -500,7 +511,7 @@ public JAXBElement<IdType> createSourceTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = SourceType.class) @@ -509,7 +520,7 @@ public JAXBElement<LinkType> createSourceTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = SourceType.class) @@ -518,7 +529,7 @@ public JAXBElement<PersonType> createSourceTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = SourceType.class) @@ -527,7 +538,7 @@ public JAXBElement<DateTimeType> createSourceTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = SourceType.class) @@ -536,7 +547,7 @@ public JAXBElement<GeneratorType> createSourceTypeGenerator(GeneratorType value) } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = SourceType.class) @@ -545,7 +556,7 @@ public JAXBElement<TextType> createSourceTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = SourceType.class) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java index 8bd21a51d5ed6..5f87452e190bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,15 +41,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom person construct is defined in section 3.2 of the format spec. - * + * The Atom person construct is defined in section 3.2 of the format spec. + * * - * <p>Java class for personType complex type. + * <p> + * Java class for personType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="personType"> @@ -56,16 +72,13 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "personType", propOrder = { - "nameOrUriOrEmail" -}) +@XmlType(name = "personType", propOrder = { "nameOrUriOrEmail" }) public class PersonType { @XmlElementRefs({ - @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) - }) + @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) protected List<Object> nameOrUriOrEmail; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -76,30 +89,28 @@ public class PersonType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the nameOrUriOrEmail property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the nameOrUriOrEmail property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the nameOrUriOrEmail property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getNameOrUriOrEmail().add(newItem); + * getNameOrUriOrEmail().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link String }{@code >} - * {@link Object } - * {@link JAXBElement }{@code <}{@link String }{@code >} - * {@link JAXBElement }{@code <}{@link UriType }{@code >} + * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link Object } {@link JAXBElement }{@code <}{@link String }{@code >} {@link JAXBElement }{@code <}{@link UriType } + * {@code >} * * */ @@ -114,9 +125,8 @@ public List<Object> getNameOrUriOrEmail() { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -126,9 +136,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -138,9 +147,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -150,9 +158,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -162,15 +169,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java index a5f20de7ae32b..1ed8890f9ea8f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -26,15 +41,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom source construct is defined in section 4.2.11 of the format spec. - * + * The Atom source construct is defined in section 4.2.11 of the format spec. + * * - * <p>Java class for sourceType complex type. + * <p> + * Java class for sourceType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="sourceType"> @@ -65,25 +81,22 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "sourceType", propOrder = { - "authorOrCategoryOrContributor" -}) +@XmlType(name = "sourceType", propOrder = { "authorOrCategoryOrContributor" }) public class SourceType { @XmlElementRefs({ - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) - }) + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) @XmlAnyElement(lax = true) protected List<Object> authorOrCategoryOrContributor; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -94,39 +107,32 @@ public class SourceType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the authorOrCategoryOrContributor property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the authorOrCategoryOrContributor property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the authorOrCategoryOrContributor property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getAuthorOrCategoryOrContributor().add(newItem); + * getAuthorOrCategoryOrContributor().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} - * {@link JAXBElement }{@code <}{@link LogoType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link Object } - * {@link JAXBElement }{@code <}{@link IconType }{@code >} - * {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} {@link JAXBElement }{@code <}{@link CategoryType } + * {@code >} {@link Object } {@link JAXBElement }{@code <}{@link IconType }{@code >} {@link JAXBElement }{@code <} + * {@link LinkType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} * * */ @@ -141,9 +147,8 @@ public List<Object> getAuthorOrCategoryOrContributor() { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -153,9 +158,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -165,9 +169,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -177,9 +180,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -189,15 +191,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java index 6421c6ae97c96..5e9d4399433d7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java @@ -1,10 +1,24 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; @@ -12,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -24,15 +39,16 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** * - * The Atom text construct is defined in section 3.1 of the format spec. - * + * The Atom text construct is defined in section 3.1 of the format spec. * - * <p>Java class for textType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * Java class for textType complex type. + * + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="textType"> @@ -60,9 +76,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "textType", propOrder = { - "content" -}) +@XmlType(name = "textType", propOrder = { "content" }) public class TextType { @XmlMixed @@ -79,30 +93,28 @@ public class TextType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom text construct is defined in section 3.1 of the format spec. - * Gets the value of the content property. + * The Atom text construct is defined in section 3.1 of the format spec. + * Gets the value of the content property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the content property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the content property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getContent().add(newItem); + * getContent().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link Object } - * {@link String } + * Objects of the following type(s) are allowed in the list {@link Object } {@link String } * * */ @@ -117,9 +129,8 @@ public List<Object> getContent() { * Gets the value of the type property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getType() { return type; @@ -129,9 +140,8 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setType(String value) { this.type = value; @@ -141,9 +151,8 @@ public void setType(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -153,9 +162,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -165,9 +173,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -177,9 +184,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -189,15 +195,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java index 07c555c1dd6ee..2df489de61985 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java @@ -1,15 +1,30 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT -// +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -21,11 +36,12 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; - /** - * <p>Java class for uriType complex type. + * <p> + * Java class for uriType complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="uriType"> @@ -41,9 +57,7 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "uriType", propOrder = { - "value" -}) +@XmlType(name = "uriType", propOrder = { "value" }) public class UriType { @XmlValue @@ -57,15 +71,14 @@ public class UriType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getValue() { return value; @@ -75,9 +88,8 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setValue(String value) { this.value = value; @@ -87,9 +99,8 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getBase() { return base; @@ -99,9 +110,8 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setBase(String value) { this.base = value; @@ -111,9 +121,8 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is - * {@link String } - * + * possible object is {@link String } + * */ public String getLang() { return lang; @@ -123,9 +132,8 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is - * {@link String } - * + * allowed object is {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -135,15 +143,14 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and - * the value is the string value of the attribute. + * the map is keyed by the name of the attribute and the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute - * by updating the map directly. Because of this design, there's no setter. + * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of + * this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java index 5fc88fe9c0e0d..760ddca59dfdb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java @@ -1,9 +1,26 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in +// JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/Atom", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package com.microsoft.windowsazure.services.media.implementation.atom; + diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java index 762cae0eed0b7..f99f73b111065 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/content/MediaServiceDTO.java @@ -1,5 +1,19 @@ -package com.microsoft.windowsazure.services.media.implementation.content; +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.microsoft.windowsazure.services.media.implementation.content; /** * Marker interface to mark types as a data transfer object diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java index ae0c8ff6b6715..a0446c897f157 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation.entities; public interface EntityDeleteOperation { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java index f047b48a9071b..0d1ca0c78999b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EntityProxyTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java index c21063c48e261..32c54ede596c0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ExportsTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index 94e2b31b8f0a3..e2e893b86b1f2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java index d1c8fccf600da..32c6f5525cca4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/RedirectionFilterTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java index ed9715a8a10fa..d7c11ae94764a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/ResourceLocationManagerTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.implementation; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java index 2ff5a68665294..90bfb9cf4efe8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyPermissionTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.models; import static org.junit.Assert.*; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java index c663c0b6dd2b2..2b3ec596127e6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.microsoft.windowsazure.services.media.models; import static org.junit.Assert.*; From 9b33725fb80bebb46cffcf662eece179f9fb75fa Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 10:54:20 -0800 Subject: [PATCH 631/664] code review feedback for removing warnings. --- .../implementation/MediaBatchOperations.java | 4 +--- .../services/media/models/Task.java | 23 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 12c484d12e5de..dd22c19c8b8a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -352,9 +352,7 @@ else if (entityBatchOperation instanceof Job.CreateBatchOperation) { } else if (entityBatchOperation instanceof Task.CreateBatchOperation) { try { - TaskInfo taskInfo = oDataAtomUnmarshaller.unmarshalEntry(content, TaskInfo.class); - Task.CreateBatchOperation taskCreateBatchOperation = (Task.CreateBatchOperation) entityBatchOperation; - taskCreateBatchOperation.setTaskInfo(taskInfo); + oDataAtomUnmarshaller.unmarshalEntry(content, TaskInfo.class); } catch (JAXBException e) { throw new ServiceException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index f1cb7999c0417..2c148b7bb5f47 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -93,9 +93,6 @@ public static class CreateBatchOperation extends EntityBatchOperation { /** The task type. */ private final TaskType taskType; - /** The task info. */ - private TaskInfo taskInfo; - /** * Instantiates a new creates the batch operation. * @@ -232,26 +229,6 @@ public CreateBatchOperation setInitializationVector(String initializationVector) return this; } - /** - * Sets the task info. - * - * @param taskInfo - * the task info - * @return the creates the batch operation - */ - public CreateBatchOperation setTaskInfo(TaskInfo taskInfo) { - this.taskInfo = taskInfo; - return this; - } - - /** - * Gets the task info. - * - * @return the task info - */ - public TaskInfo getTaskInfo() { - return taskInfo; - } } } From 9d5b720ef091ae903ec2dc3a4f887cef4bf3989e Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Fri, 14 Dec 2012 22:09:11 -0800 Subject: [PATCH 632/664] Make LinkInfo generic for type safety --- .../media/implementation/ODataEntity.java | 9 +++++---- .../services/media/models/AccessPolicy.java | 2 +- .../services/media/models/Asset.java | 4 ++-- .../services/media/models/AssetFile.java | 2 +- .../services/media/models/AssetInfo.java | 17 +++++++++-------- .../services/media/models/ContentKey.java | 2 +- .../services/media/models/JobInfo.java | 12 ++++++------ .../services/media/models/LinkInfo.java | 3 ++- .../services/media/models/Locator.java | 2 +- .../services/media/models/LocatorInfo.java | 8 ++++---- .../services/media/models/Task.java | 2 +- .../services/media/models/TaskInfo.java | 8 ++++---- 12 files changed, 37 insertions(+), 34 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index fac9d627b7826..4223758765747 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -88,12 +88,12 @@ public boolean hasLink(String rel) { * rel of link to retrieve * @return The link if found, null if not. */ - public LinkInfo getLink(String rel) { + public <U extends ODataEntity<?>> LinkInfo<U> getLink(String rel) { for (Object child : entry.getEntryChildren()) { LinkType link = LinkFromChild(child); if (link != null && link.getRel().equals(rel)) { - return new LinkInfo(link); + return new LinkInfo<U>(link); } } return null; @@ -106,8 +106,8 @@ public LinkInfo getLink(String rel) { * name of the OData relationship * @return the link if found, null if not. */ - public LinkInfo getRelationLink(String relationName) { - return getLink(Constants.ODATA_DATA_NS + "/related/" + relationName); + public <U extends ODataEntity<?>> LinkInfo<U> getRelationLink(String relationName) { + return this.<U> getLink(Constants.ODATA_DATA_NS + "/related/" + relationName); } /** @@ -115,6 +115,7 @@ public LinkInfo getRelationLink(String relationName) { * * @return List of the links. */ + @SuppressWarnings("rawtypes") public List<LinkInfo> getLinks() { ArrayList<LinkInfo> links = new ArrayList<LinkInfo>(); for (Object child : entry.getEntryChildren()) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index c1fb8f933e2c8..2b9a5b904dcbf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -97,7 +97,7 @@ public static EntityGetOperation<AccessPolicyInfo> get(String accessPolicyId) { * the link * @return the operation */ - public static EntityGetOperation<AccessPolicyInfo> get(LinkInfo link) { + public static EntityGetOperation<AccessPolicyInfo> get(LinkInfo<AccessPolicyInfo> link) { return new DefaultGetOperation<AccessPolicyInfo>(link.getHref(), AccessPolicyInfo.class); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index 63147b5a040ce..9d8cdcc0fd864 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -171,7 +171,7 @@ public static EntityGetOperation<AssetInfo> get(String assetId) { * the link * @return the get operation */ - public static EntityGetOperation<AssetInfo> get(LinkInfo link) { + public static EntityGetOperation<AssetInfo> get(LinkInfo<AssetInfo> link) { return new DefaultGetOperation<AssetInfo>(link.getHref(), AssetInfo.class); } @@ -204,7 +204,7 @@ public static DefaultListOperation<AssetInfo> list(MultivaluedMap<String, String * Link to request assets from. * @return The list operation. */ - public static DefaultListOperation<AssetInfo> list(LinkInfo link) { + public static DefaultListOperation<AssetInfo> list(LinkInfo<AssetInfo> link) { return new DefaultListOperation<AssetInfo>(link.getHref(), new GenericType<ListResult<AssetInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index 2dd506a577ae2..75fe8bc54af1c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -207,7 +207,7 @@ public static DefaultListOperation<AssetFileInfo> list() { * Link to request AssetFiles from. * @return The list operation. */ - public static DefaultListOperation<AssetFileInfo> list(LinkInfo link) { + public static DefaultListOperation<AssetFileInfo> list(LinkInfo<AssetFileInfo> link) { return new DefaultListOperation<AssetFileInfo>(link.getHref(), new GenericType<ListResult<AssetFileInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 65fa6108c03ac..549ad8e6cb85b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -107,8 +107,8 @@ public AssetOption getOptions() { * * @return the link */ - public LinkInfo getAssetFilesLink() { - return getRelationLink("Files"); + public LinkInfo<AssetFileInfo> getAssetFilesLink() { + return this.<AssetFileInfo> getRelationLink("Files"); } /** @@ -116,8 +116,8 @@ public LinkInfo getAssetFilesLink() { * * @return the link */ - public LinkInfo getContentKeysLink() { - return getRelationLink("ContentKeys"); + public LinkInfo<ContentKeyInfo> getContentKeysLink() { + return this.<ContentKeyInfo> getRelationLink("ContentKeys"); } /** @@ -125,8 +125,8 @@ public LinkInfo getContentKeysLink() { * * @return the link */ - public LinkInfo getLocatorsLink() { - return getRelationLink("Locators"); + public LinkInfo<LocatorInfo> getLocatorsLink() { + return this.<LocatorInfo> getRelationLink("Locators"); } /** @@ -134,7 +134,8 @@ public LinkInfo getLocatorsLink() { * * @return the link */ - public LinkInfo getParentAssetsLink() { - return getRelationLink("ParentAssets"); + public LinkInfo<AssetInfo> getParentAssetsLink() { + // TODO: NEEDS TESTS once we figure out how to create assets with parents + return this.<AssetInfo> getRelationLink("ParentAssets"); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index fbe721ea718d4..d43e639908d1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -211,7 +211,7 @@ public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, S * Link to request content keys from. * @return The list operation. */ - public static DefaultListOperation<ContentKeyInfo> list(LinkInfo link) { + public static DefaultListOperation<ContentKeyInfo> list(LinkInfo<ContentKeyInfo> link) { return new DefaultListOperation<ContentKeyInfo>(link.getHref(), new GenericType<ListResult<ContentKeyInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java index 5c5525065b47e..c2fb8d53dc9da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java @@ -133,8 +133,8 @@ public String getTemplateId() { * * @return Link if found, null if not. */ - public LinkInfo getInputAssetsLink() { - return getRelationLink("InputMediaAssets"); + public LinkInfo<AssetInfo> getInputAssetsLink() { + return this.<AssetInfo> getRelationLink("InputMediaAssets"); } /** @@ -142,8 +142,8 @@ public LinkInfo getInputAssetsLink() { * * @return Link if found, null if not. */ - public LinkInfo getOutputAssetsLink() { - return getRelationLink("OutputMediaAssets"); + public LinkInfo<AssetInfo> getOutputAssetsLink() { + return this.<AssetInfo> getRelationLink("OutputMediaAssets"); } /** @@ -151,7 +151,7 @@ public LinkInfo getOutputAssetsLink() { * * @return the tasks link */ - public LinkInfo getTasksLink() { - return getRelationLink("Tasks"); + public LinkInfo<TaskInfo> getTasksLink() { + return this.<TaskInfo> getRelationLink("Tasks"); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java index 9f25a1c1835f4..8d1c39a93212f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LinkInfo.java @@ -15,13 +15,14 @@ package com.microsoft.windowsazure.services.media.models; +import com.microsoft.windowsazure.services.media.implementation.ODataEntity; import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; /** * Provides access to OData links * */ -public class LinkInfo { +public class LinkInfo<T extends ODataEntity<?>> { private final LinkType rawLink; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 9201bae0fe0dc..ddd2df7cac472 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -218,7 +218,7 @@ public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, Stri * Link to request locators from. * @return The list operation. */ - public static DefaultListOperation<LocatorInfo> list(LinkInfo link) { + public static DefaultListOperation<LocatorInfo> list(LinkInfo<LocatorInfo> link) { return new DefaultListOperation<LocatorInfo>(link.getHref(), new GenericType<ListResult<LocatorInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java index f36023ae7d89c..399cfbc3d573b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/LocatorInfo.java @@ -124,8 +124,8 @@ public String getContentAccessToken() { * * @return the link */ - public LinkInfo getAccessPolicyLink() { - return getRelationLink("AccessPolicy"); + public LinkInfo<AccessPolicyInfo> getAccessPolicyLink() { + return this.<AccessPolicyInfo> getRelationLink("AccessPolicy"); } /** @@ -133,7 +133,7 @@ public LinkInfo getAccessPolicyLink() { * * @return the link */ - public LinkInfo getAssetLink() { - return getRelationLink("Asset"); + public LinkInfo<AssetInfo> getAssetLink() { + return this.<AssetInfo> getRelationLink("Asset"); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 1e8d6734a2ec0..3aba6c84b1b59 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -80,7 +80,7 @@ public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> * link to tasks * @return the list operation. */ - public static DefaultListOperation<TaskInfo> list(LinkInfo link) { + public static DefaultListOperation<TaskInfo> list(LinkInfo<TaskInfo> link) { return new DefaultListOperation<TaskInfo>(link.getHref(), new GenericType<ListResult<TaskInfo>>() { }); } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java index fa6cc3ee89dbf..a31c7bfa04d2c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/TaskInfo.java @@ -217,8 +217,8 @@ public String getInitializationVector() { * * @return the link */ - public LinkInfo getInputAssetsLink() { - return getRelationLink("InputMediaAssets"); + public LinkInfo<AssetInfo> getInputAssetsLink() { + return this.<AssetInfo> getRelationLink("InputMediaAssets"); } /** @@ -226,7 +226,7 @@ public LinkInfo getInputAssetsLink() { * * @return the link */ - public LinkInfo getOutputAssetsLink() { - return getRelationLink("OutputMediaAssets"); + public LinkInfo<AssetInfo> getOutputAssetsLink() { + return this.<AssetInfo> getRelationLink("OutputMediaAssets"); } } From 7ff6ddb76f8194469f8954a3af8f76a44a94653d Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 11:32:09 -0800 Subject: [PATCH 633/664] revert the changes for autogenerated files. --- .../implementation/atom/CategoryType.java | 98 ++++++------ .../implementation/atom/ContentType.java | 111 +++++++------ .../implementation/atom/DateTimeType.java | 79 +++++----- .../media/implementation/atom/EntryType.java | 129 ++++++++------- .../media/implementation/atom/FeedType.java | 133 ++++++++-------- .../implementation/atom/GeneratorType.java | 103 ++++++------ .../media/implementation/atom/IconType.java | 83 +++++----- .../media/implementation/atom/IdType.java | 83 +++++----- .../media/implementation/atom/LinkType.java | 147 +++++++++--------- .../media/implementation/atom/LogoType.java | 83 +++++----- .../implementation/atom/ObjectFactory.java | 133 ++++++++-------- .../media/implementation/atom/PersonType.java | 98 ++++++------ .../media/implementation/atom/SourceType.java | 129 ++++++++------- .../media/implementation/atom/TextType.java | 101 ++++++------ .../media/implementation/atom/UriType.java | 79 +++++----- .../implementation/atom/package-info.java | 25 +-- 16 files changed, 766 insertions(+), 848 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java index 6c31c7904783e..3e0138fef82c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java @@ -1,29 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -34,16 +20,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom cagegory construct is defined in section 4.2.2 of the format spec. + * The Atom cagegory construct is defined in section 4.2.2 of the format spec. + * * + * <p>Java class for categoryType complex type. * - * <p> - * Java class for categoryType complex type. - * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="categoryType"> @@ -80,14 +65,15 @@ public class CategoryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the term property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getTerm() { return term; @@ -97,8 +83,9 @@ public String getTerm() { * Sets the value of the term property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setTerm(String value) { this.term = value; @@ -108,8 +95,9 @@ public void setTerm(String value) { * Gets the value of the scheme property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getScheme() { return scheme; @@ -119,8 +107,9 @@ public String getScheme() { * Sets the value of the scheme property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setScheme(String value) { this.scheme = value; @@ -130,8 +119,9 @@ public void setScheme(String value) { * Gets the value of the label property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLabel() { return label; @@ -141,8 +131,9 @@ public String getLabel() { * Sets the value of the label property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLabel(String value) { this.label = value; @@ -152,8 +143,9 @@ public void setLabel(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -163,8 +155,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -174,8 +167,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -185,8 +179,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -196,14 +191,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java index e3b955b334b1a..8e03e7cb2b4a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java @@ -1,24 +1,10 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT // +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + package com.microsoft.windowsazure.services.media.implementation.atom; @@ -26,7 +12,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -39,16 +24,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom content construct is defined in section 4.1.3 of the format spec. - * + * The Atom content construct is defined in section 4.1.3 of the format spec. + * * - * <p> - * Java class for contentType complex type. + * <p>Java class for contentType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="contentType"> @@ -69,7 +53,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "contentType", propOrder = { "content" }) +@XmlType(name = "contentType", propOrder = { + "content" +}) public class ContentType { @XmlMixed @@ -88,28 +74,30 @@ public class ContentType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom content construct is defined in section 4.1.3 of the format spec. - * Gets the value of the content property. + * The Atom content construct is defined in section 4.1.3 of the format spec. + * Gets the value of the content property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the content property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the content property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getContent().add(newItem); + * getContent().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link Object } {@link String } + * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link String } * * */ @@ -124,8 +112,9 @@ public List<Object> getContent() { * Gets the value of the type property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getType() { return type; @@ -135,8 +124,9 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setType(String value) { this.type = value; @@ -146,8 +136,9 @@ public void setType(String value) { * Gets the value of the src property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getSrc() { return src; @@ -157,8 +148,9 @@ public String getSrc() { * Sets the value of the src property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setSrc(String value) { this.src = value; @@ -168,8 +160,9 @@ public void setSrc(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -179,8 +172,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -190,8 +184,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -201,8 +196,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -212,14 +208,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java index fb3eef7556a3e..4232aee1748e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -37,12 +22,11 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; + /** - * <p> - * Java class for dateTimeType complex type. + * <p>Java class for dateTimeType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="dateTimeType"> @@ -58,7 +42,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "dateTimeType", propOrder = { "value" }) +@XmlType(name = "dateTimeType", propOrder = { + "value" +}) public class DateTimeType { @XmlValue @@ -72,14 +58,15 @@ public class DateTimeType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link XMLGregorianCalendar } - * + * possible object is + * {@link XMLGregorianCalendar } + * */ public XMLGregorianCalendar getValue() { return value; @@ -89,8 +76,9 @@ public XMLGregorianCalendar getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link XMLGregorianCalendar } - * + * allowed object is + * {@link XMLGregorianCalendar } + * */ public void setValue(XMLGregorianCalendar value) { this.value = value; @@ -100,8 +88,9 @@ public void setValue(XMLGregorianCalendar value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -111,8 +100,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -122,8 +112,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -133,8 +124,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -144,14 +136,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index ab623248e7a53..d3244af70517d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -1,32 +1,17 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -41,16 +26,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom entry construct is defined in section 4.1.2 of the format spec. - * + * The Atom entry construct is defined in section 4.1.2 of the format spec. + * * - * <p> - * Java class for entryType complex type. + * <p>Java class for entryType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="entryType"> @@ -81,22 +65,25 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "entryType", propOrder = { "entryChildren" }) +@XmlType(name = "entryType", propOrder = { + "entryChildren" +}) public class EntryType { @XmlElementRefs({ - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) @XmlAnyElement(lax = true) protected List<Object> entryChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -107,32 +94,39 @@ public class EntryType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the entryChildren property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the entryChildren property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the entryChildren property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getEntryChildren().add(newItem); + * getEntryChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link CategoryType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link IdType }{@code >} - * {@link JAXBElement }{@code <}{@link ContentType }{@code >} {@link Object } + * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link ContentType }{@code >} + * {@link Object } * * */ @@ -147,8 +141,9 @@ public List<Object> getEntryChildren() { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -158,8 +153,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -169,8 +165,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -180,8 +177,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -191,14 +189,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java index 74fd7d373ca17..9c5ea3df46aef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java @@ -1,32 +1,17 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.18 at 11:05:53 AM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.18 at 11:05:53 AM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -41,16 +26,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom feed construct is defined in section 4.1.1 of the format spec. - * + * The Atom feed construct is defined in section 4.1.1 of the format spec. + * * - * <p> - * Java class for feedType complex type. + * <p>Java class for feedType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="feedType"> @@ -82,23 +66,26 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "feedType", propOrder = { "feedChildren" }) +@XmlType(name = "feedType", propOrder = { + "feedChildren" +}) public class FeedType { @XmlElementRefs({ - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) @XmlAnyElement(lax = true) protected List<Object> feedChildren; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -109,33 +96,40 @@ public class FeedType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the feedChildren property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the feedChildren property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the feedChildren property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getFeedChildren().add(newItem); + * getFeedChildren().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} - * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} {@link JAXBElement }{@code <}{@link LinkType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link Object } {@link JAXBElement }{@code <}{@link EntryType }{@code >} {@link JAXBElement }{@code <} - * {@link LogoType }{@code >} {@link JAXBElement }{@code <}{@link IconType }{@code >} {@link JAXBElement }{@code <} - * {@link PersonType }{@code >} {@link JAXBElement }{@code <}{@link CategoryType }{@code >} {@link JAXBElement }{@code <} - * {@link TextType }{@code >} + * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link Object } + * {@link JAXBElement }{@code <}{@link EntryType }{@code >} + * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link IconType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} * * */ @@ -150,8 +144,9 @@ public List<Object> getFeedChildren() { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -161,8 +156,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -172,8 +168,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -183,8 +180,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -194,14 +192,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java index 29c20e0988edf..08f56f2f84c75 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT // +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -36,16 +21,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom generator element is defined in section 4.2.4 of the format spec. - * + * The Atom generator element is defined in section 4.2.4 of the format spec. + * * - * <p> - * Java class for generatorType complex type. + * <p>Java class for generatorType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="generatorType"> @@ -63,7 +47,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "generatorType", propOrder = { "value" }) +@XmlType(name = "generatorType", propOrder = { + "value" +}) public class GeneratorType { @XmlValue @@ -81,14 +67,15 @@ public class GeneratorType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getValue() { return value; @@ -98,8 +85,9 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setValue(String value) { this.value = value; @@ -109,8 +97,9 @@ public void setValue(String value) { * Gets the value of the uri property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getUri() { return uri; @@ -120,8 +109,9 @@ public String getUri() { * Sets the value of the uri property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setUri(String value) { this.uri = value; @@ -131,8 +121,9 @@ public void setUri(String value) { * Gets the value of the version property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getVersion() { return version; @@ -142,8 +133,9 @@ public String getVersion() { * Sets the value of the version property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setVersion(String value) { this.version = value; @@ -153,8 +145,9 @@ public void setVersion(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -164,8 +157,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -175,8 +169,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -186,8 +181,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -197,14 +193,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java index 31fcba1199c80..33675d2d588a5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -36,16 +21,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom icon construct is defined in section 4.2.5 of the format spec. - * + * The Atom icon construct is defined in section 4.2.5 of the format spec. + * * - * <p> - * Java class for iconType complex type. + * <p>Java class for iconType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="iconType"> @@ -61,7 +45,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "iconType", propOrder = { "value" }) +@XmlType(name = "iconType", propOrder = { + "value" +}) public class IconType { @XmlValue @@ -75,14 +61,15 @@ public class IconType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getValue() { return value; @@ -92,8 +79,9 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setValue(String value) { this.value = value; @@ -103,8 +91,9 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -114,8 +103,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -125,8 +115,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -136,8 +127,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -147,14 +139,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java index e221e7eae9ac6..0633ac55a4110 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -36,16 +21,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom id construct is defined in section 4.2.6 of the format spec. - * + * The Atom id construct is defined in section 4.2.6 of the format spec. + * * - * <p> - * Java class for idType complex type. + * <p>Java class for idType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="idType"> @@ -61,7 +45,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "idType", propOrder = { "value" }) +@XmlType(name = "idType", propOrder = { + "value" +}) public class IdType { @XmlValue @@ -75,14 +61,15 @@ public class IdType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getValue() { return value; @@ -92,8 +79,9 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setValue(String value) { this.value = value; @@ -103,8 +91,9 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -114,8 +103,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -125,8 +115,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -136,8 +127,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -147,14 +139,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java index 8486f4d63a171..7ea60224d7f02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java @@ -1,31 +1,16 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -37,16 +22,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom link construct is defined in section 3.4 of the format spec. - * + * The Atom link construct is defined in section 3.4 of the format spec. + * * - * <p> - * Java class for linkType complex type. + * <p>Java class for linkType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="linkType"> @@ -68,7 +52,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "linkType", propOrder = { "content" }) +@XmlType(name = "linkType", propOrder = { + "content" +}) public class LinkType { @XmlValue @@ -97,16 +83,17 @@ public class LinkType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom link construct is defined in section 3.4 of the format spec. - * + * The Atom link construct is defined in section 3.4 of the format spec. + * * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getContent() { return content; @@ -116,8 +103,9 @@ public String getContent() { * Sets the value of the content property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setContent(String value) { this.content = value; @@ -127,8 +115,9 @@ public void setContent(String value) { * Gets the value of the href property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getHref() { return href; @@ -138,8 +127,9 @@ public String getHref() { * Sets the value of the href property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setHref(String value) { this.href = value; @@ -149,8 +139,9 @@ public void setHref(String value) { * Gets the value of the rel property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getRel() { return rel; @@ -160,8 +151,9 @@ public String getRel() { * Sets the value of the rel property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setRel(String value) { this.rel = value; @@ -171,8 +163,9 @@ public void setRel(String value) { * Gets the value of the type property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getType() { return type; @@ -182,8 +175,9 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setType(String value) { this.type = value; @@ -193,8 +187,9 @@ public void setType(String value) { * Gets the value of the hreflang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getHreflang() { return hreflang; @@ -204,8 +199,9 @@ public String getHreflang() { * Sets the value of the hreflang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setHreflang(String value) { this.hreflang = value; @@ -215,8 +211,9 @@ public void setHreflang(String value) { * Gets the value of the title property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getTitle() { return title; @@ -226,8 +223,9 @@ public String getTitle() { * Sets the value of the title property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setTitle(String value) { this.title = value; @@ -237,8 +235,9 @@ public void setTitle(String value) { * Gets the value of the length property. * * @return - * possible object is {@link BigInteger } - * + * possible object is + * {@link BigInteger } + * */ public BigInteger getLength() { return length; @@ -248,8 +247,9 @@ public BigInteger getLength() { * Sets the value of the length property. * * @param value - * allowed object is {@link BigInteger } - * + * allowed object is + * {@link BigInteger } + * */ public void setLength(BigInteger value) { this.length = value; @@ -259,8 +259,9 @@ public void setLength(BigInteger value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -270,8 +271,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -281,8 +283,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -292,8 +295,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -303,14 +307,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java index c492479802111..443f58c771070 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -36,16 +21,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom logo construct is defined in section 4.2.8 of the format spec. - * + * The Atom logo construct is defined in section 4.2.8 of the format spec. + * * - * <p> - * Java class for logoType complex type. + * <p>Java class for logoType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="logoType"> @@ -61,7 +45,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "logoType", propOrder = { "value" }) +@XmlType(name = "logoType", propOrder = { + "value" +}) public class LogoType { @XmlValue @@ -75,14 +61,15 @@ public class LogoType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getValue() { return value; @@ -92,8 +79,9 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setValue(String value) { this.value = value; @@ -103,8 +91,9 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -114,8 +103,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -125,8 +115,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -136,8 +127,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -147,14 +139,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java index 7efa05a7b258b..c620b60d57564 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java @@ -1,25 +1,11 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import javax.xml.bind.JAXBElement; @@ -29,15 +15,19 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the com.microsoft.windowsazure.services.media.implementation.atom package. - * <p> - * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. - * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding - * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in - * this class. + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.microsoft.windowsazure.services.media.implementation.atom package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. * */ @XmlRegistry @@ -66,8 +56,7 @@ public class ObjectFactory { private final static QName _FeedTypeIcon_QNAME = new QName("http://www.w3.org/2005/Atom", "icon"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: - * com.microsoft.windowsazure.services.media.implementation.atom + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.microsoft.windowsazure.services.media.implementation.atom * */ public ObjectFactory() { @@ -186,7 +175,7 @@ public CategoryType createCategoryType() { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry") @@ -195,7 +184,7 @@ public JAXBElement<EntryType> createEntry(EntryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "feed") @@ -204,7 +193,7 @@ public JAXBElement<FeedType> createFeed(FeedType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "name", scope = PersonType.class) @@ -213,7 +202,7 @@ public JAXBElement<String> createPersonTypeName(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "email", scope = PersonType.class) @@ -223,7 +212,7 @@ public JAXBElement<String> createPersonTypeEmail(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "uri", scope = PersonType.class) @@ -232,7 +221,7 @@ public JAXBElement<UriType> createPersonTypeUri(UriType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = EntryType.class) @@ -241,7 +230,7 @@ public JAXBElement<TextType> createEntryTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = EntryType.class) @@ -250,7 +239,7 @@ public JAXBElement<CategoryType> createEntryTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = EntryType.class) @@ -259,7 +248,7 @@ public JAXBElement<PersonType> createEntryTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "summary", scope = EntryType.class) @@ -268,7 +257,7 @@ public JAXBElement<TextType> createEntryTypeSummary(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = EntryType.class) @@ -277,7 +266,7 @@ public JAXBElement<IdType> createEntryTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "content", scope = EntryType.class) @@ -286,7 +275,7 @@ public JAXBElement<ContentType> createEntryTypeContent(ContentType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = EntryType.class) @@ -295,7 +284,7 @@ public JAXBElement<LinkType> createEntryTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = EntryType.class) @@ -304,7 +293,7 @@ public JAXBElement<PersonType> createEntryTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = EntryType.class) @@ -313,7 +302,7 @@ public JAXBElement<DateTimeType> createEntryTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "source", scope = EntryType.class) @@ -322,7 +311,7 @@ public JAXBElement<TextType> createEntryTypeSource(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = EntryType.class) @@ -331,7 +320,7 @@ public JAXBElement<TextType> createEntryTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "published", scope = EntryType.class) @@ -340,7 +329,7 @@ public JAXBElement<DateTimeType> createEntryTypePublished(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = FeedType.class) @@ -349,7 +338,7 @@ public JAXBElement<CategoryType> createFeedTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = FeedType.class) @@ -358,7 +347,7 @@ public JAXBElement<TextType> createFeedTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = FeedType.class) @@ -367,7 +356,7 @@ public JAXBElement<PersonType> createFeedTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = FeedType.class) @@ -376,7 +365,7 @@ public JAXBElement<IdType> createFeedTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry", scope = FeedType.class) @@ -385,7 +374,7 @@ public JAXBElement<EntryType> createFeedTypeEntry(EntryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = FeedType.class) @@ -394,7 +383,7 @@ public JAXBElement<PersonType> createFeedTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = FeedType.class) @@ -403,7 +392,7 @@ public JAXBElement<DateTimeType> createFeedTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = FeedType.class) @@ -412,7 +401,7 @@ public JAXBElement<GeneratorType> createFeedTypeGenerator(GeneratorType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = FeedType.class) @@ -421,7 +410,7 @@ public JAXBElement<TextType> createFeedTypeSubtitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = FeedType.class) @@ -430,7 +419,7 @@ public JAXBElement<LogoType> createFeedTypeLogo(LogoType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = FeedType.class) @@ -439,7 +428,7 @@ public JAXBElement<IconType> createFeedTypeIcon(IconType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = FeedType.class) @@ -448,7 +437,7 @@ public JAXBElement<LinkType> createFeedTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = FeedType.class) @@ -457,7 +446,7 @@ public JAXBElement<TextType> createFeedTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = SourceType.class) @@ -466,7 +455,7 @@ public JAXBElement<TextType> createSourceTypeTitle(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = SourceType.class) @@ -475,7 +464,7 @@ public JAXBElement<CategoryType> createSourceTypeCategory(CategoryType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = SourceType.class) @@ -484,7 +473,7 @@ public JAXBElement<IconType> createSourceTypeIcon(IconType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = SourceType.class) @@ -493,7 +482,7 @@ public JAXBElement<PersonType> createSourceTypeAuthor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = SourceType.class) @@ -502,7 +491,7 @@ public JAXBElement<LogoType> createSourceTypeLogo(LogoType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = SourceType.class) @@ -511,7 +500,7 @@ public JAXBElement<IdType> createSourceTypeId(IdType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = SourceType.class) @@ -520,7 +509,7 @@ public JAXBElement<LinkType> createSourceTypeLink(LinkType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = SourceType.class) @@ -529,7 +518,7 @@ public JAXBElement<PersonType> createSourceTypeContributor(PersonType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = SourceType.class) @@ -538,7 +527,7 @@ public JAXBElement<DateTimeType> createSourceTypeUpdated(DateTimeType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = SourceType.class) @@ -547,7 +536,7 @@ public JAXBElement<GeneratorType> createSourceTypeGenerator(GeneratorType value) } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = SourceType.class) @@ -556,7 +545,7 @@ public JAXBElement<TextType> createSourceTypeRights(TextType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} * */ @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = SourceType.class) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java index 5f87452e190bd..8bd21a51d5ed6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java @@ -1,32 +1,17 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -41,16 +26,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom person construct is defined in section 3.2 of the format spec. - * + * The Atom person construct is defined in section 3.2 of the format spec. + * * - * <p> - * Java class for personType complex type. + * <p>Java class for personType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="personType"> @@ -72,13 +56,16 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "personType", propOrder = { "nameOrUriOrEmail" }) +@XmlType(name = "personType", propOrder = { + "nameOrUriOrEmail" +}) public class PersonType { @XmlElementRefs({ - @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) + @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) @XmlAnyElement(lax = true) protected List<Object> nameOrUriOrEmail; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -89,28 +76,30 @@ public class PersonType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the nameOrUriOrEmail property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the nameOrUriOrEmail property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the nameOrUriOrEmail property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getNameOrUriOrEmail().add(newItem); + * getNameOrUriOrEmail().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link String }{@code >} - * {@link Object } {@link JAXBElement }{@code <}{@link String }{@code >} {@link JAXBElement }{@code <}{@link UriType } - * {@code >} + * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link Object } + * {@link JAXBElement }{@code <}{@link String }{@code >} + * {@link JAXBElement }{@code <}{@link UriType }{@code >} * * */ @@ -125,8 +114,9 @@ public List<Object> getNameOrUriOrEmail() { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -136,8 +126,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -147,8 +138,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -158,8 +150,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -169,14 +162,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java index 1ed8890f9ea8f..a5f20de7ae32b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java @@ -1,32 +1,17 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -41,16 +26,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom source construct is defined in section 4.2.11 of the format spec. - * + * The Atom source construct is defined in section 4.2.11 of the format spec. + * * - * <p> - * Java class for sourceType complex type. + * <p>Java class for sourceType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="sourceType"> @@ -81,22 +65,25 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "sourceType", propOrder = { "authorOrCategoryOrContributor" }) +@XmlType(name = "sourceType", propOrder = { + "authorOrCategoryOrContributor" +}) public class SourceType { @XmlElementRefs({ - @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), - @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) }) + @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class), + @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class) + }) @XmlAnyElement(lax = true) protected List<Object> authorOrCategoryOrContributor; @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace") @@ -107,32 +94,39 @@ public class SourceType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the authorOrCategoryOrContributor property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the authorOrCategoryOrContributor property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the authorOrCategoryOrContributor property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getAuthorOrCategoryOrContributor().add(newItem); + * getAuthorOrCategoryOrContributor().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link TextType }{@code >} {@link JAXBElement }{@code <}{@link PersonType }{@code >} - * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} {@link JAXBElement }{@code <}{@link LogoType }{@code >} - * {@link JAXBElement }{@code <}{@link IdType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} - * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} {@link JAXBElement }{@code <}{@link CategoryType } - * {@code >} {@link Object } {@link JAXBElement }{@code <}{@link IconType }{@code >} {@link JAXBElement }{@code <} - * {@link LinkType }{@code >} {@link JAXBElement }{@code <}{@link TextType }{@code >} + * Objects of the following type(s) are allowed in the list + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link PersonType }{@code >} + * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} + * {@link JAXBElement }{@code <}{@link LogoType }{@code >} + * {@link JAXBElement }{@code <}{@link IdType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} + * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} + * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} + * {@link Object } + * {@link JAXBElement }{@code <}{@link IconType }{@code >} + * {@link JAXBElement }{@code <}{@link LinkType }{@code >} + * {@link JAXBElement }{@code <}{@link TextType }{@code >} * * */ @@ -147,8 +141,9 @@ public List<Object> getAuthorOrCategoryOrContributor() { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -158,8 +153,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -169,8 +165,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -180,8 +177,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -191,14 +189,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java index 5e9d4399433d7..6421c6ae97c96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java @@ -1,24 +1,10 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT // +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT +// + package com.microsoft.windowsazure.services.media.implementation.atom; @@ -26,7 +12,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -39,16 +24,15 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** * - * The Atom text construct is defined in section 3.1 of the format spec. + * The Atom text construct is defined in section 3.1 of the format spec. + * * + * <p>Java class for textType complex type. * - * <p> - * Java class for textType complex type. - * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="textType"> @@ -76,7 +60,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "textType", propOrder = { "content" }) +@XmlType(name = "textType", propOrder = { + "content" +}) public class TextType { @XmlMixed @@ -93,28 +79,30 @@ public class TextType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * - * The Atom text construct is defined in section 3.1 of the format spec. - * Gets the value of the content property. + * The Atom text construct is defined in section 3.1 of the format spec. + * Gets the value of the content property. * * <p> - * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to - * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for - * the content property. + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the content property. * * <p> * For example, to add a new item, do as follows: - * * <pre> - * getContent().add(newItem); + * getContent().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list {@link Object } {@link String } + * Objects of the following type(s) are allowed in the list + * {@link Object } + * {@link String } * * */ @@ -129,8 +117,9 @@ public List<Object> getContent() { * Gets the value of the type property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getType() { return type; @@ -140,8 +129,9 @@ public String getType() { * Sets the value of the type property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setType(String value) { this.type = value; @@ -151,8 +141,9 @@ public void setType(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -162,8 +153,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -173,8 +165,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -184,8 +177,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -195,14 +189,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java index 2df489de61985..07c555c1dd6ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java @@ -1,30 +1,15 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // + package com.microsoft.windowsazure.services.media.implementation.atom; import java.util.HashMap; import java.util.Map; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAnyAttribute; @@ -36,12 +21,11 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.namespace.QName; + /** - * <p> - * Java class for uriType complex type. + * <p>Java class for uriType complex type. * - * <p> - * The following schema fragment specifies the expected content contained within this class. + * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="uriType"> @@ -57,7 +41,9 @@ * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "uriType", propOrder = { "value" }) +@XmlType(name = "uriType", propOrder = { + "value" +}) public class UriType { @XmlValue @@ -71,14 +57,15 @@ public class UriType { @XmlSchemaType(name = "language") protected String lang; @XmlAnyAttribute - private final Map<QName, String> otherAttributes = new HashMap<QName, String>(); + private Map<QName, String> otherAttributes = new HashMap<QName, String>(); /** * Gets the value of the value property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getValue() { return value; @@ -88,8 +75,9 @@ public String getValue() { * Sets the value of the value property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setValue(String value) { this.value = value; @@ -99,8 +87,9 @@ public void setValue(String value) { * Gets the value of the base property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getBase() { return base; @@ -110,8 +99,9 @@ public String getBase() { * Sets the value of the base property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setBase(String value) { this.base = value; @@ -121,8 +111,9 @@ public void setBase(String value) { * Gets the value of the lang property. * * @return - * possible object is {@link String } - * + * possible object is + * {@link String } + * */ public String getLang() { return lang; @@ -132,8 +123,9 @@ public String getLang() { * Sets the value of the lang property. * * @param value - * allowed object is {@link String } - * + * allowed object is + * {@link String } + * */ public void setLang(String value) { this.lang = value; @@ -143,14 +135,15 @@ public void setLang(String value) { * Gets a map that contains attributes that aren't bound to any typed property on this class. * * <p> - * the map is keyed by the name of the attribute and the value is the string value of the attribute. + * the map is keyed by the name of the attribute and + * the value is the string value of the attribute. * - * the map returned by this method is live, and you can add new attribute by updating the map directly. Because of - * this design, there's no setter. + * the map returned by this method is live, and you can add new attribute + * by updating the map directly. Because of this design, there's no setter. * * * @return - * always non-null + * always non-null */ public Map<QName, String> getOtherAttributes() { return otherAttributes; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java index 760ddca59dfdb..5fc88fe9c0e0d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java @@ -1,26 +1,9 @@ -/** - * Copyright Microsoft Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in -// JDK 6 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.09.17 at 02:31:28 PM PDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2012.09.17 at 02:31:28 PM PDT // @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/Atom", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package com.microsoft.windowsazure.services.media.implementation.atom; - From d30e7090848084668c68399e444bfbdc74afaab7 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 11:49:39 -0800 Subject: [PATCH 634/664] add the copy right header for all the files. --- .../media/implementation/atom/CategoryType.java | 15 +++++++++++++++ .../media/implementation/atom/ContentType.java | 15 +++++++++++++++ .../media/implementation/atom/DateTimeType.java | 15 +++++++++++++++ .../media/implementation/atom/EntryType.java | 15 +++++++++++++++ .../media/implementation/atom/FeedType.java | 15 +++++++++++++++ .../media/implementation/atom/GeneratorType.java | 15 +++++++++++++++ .../media/implementation/atom/IconType.java | 15 +++++++++++++++ .../media/implementation/atom/IdType.java | 15 +++++++++++++++ .../media/implementation/atom/LinkType.java | 15 +++++++++++++++ .../media/implementation/atom/LogoType.java | 15 +++++++++++++++ .../media/implementation/atom/ObjectFactory.java | 15 +++++++++++++++ .../media/implementation/atom/PersonType.java | 15 +++++++++++++++ .../media/implementation/atom/SourceType.java | 15 +++++++++++++++ .../media/implementation/atom/TextType.java | 15 +++++++++++++++ .../media/implementation/atom/UriType.java | 15 +++++++++++++++ .../media/implementation/atom/package-info.java | 15 +++++++++++++++ 16 files changed, 240 insertions(+) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java index 3e0138fef82c8..985521f1baf6c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/CategoryType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java index 8e03e7cb2b4a8..d828ce6a922e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ContentType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java index 4232aee1748e1..8097815ad1874 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/DateTimeType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java index d3244af70517d..6b391b9cdd087 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/EntryType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java index 9c5ea3df46aef..38d8fd73331b4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/FeedType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java index 08f56f2f84c75..884122c1dbe02 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/GeneratorType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java index 33675d2d588a5..5ceea0b56e0c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IconType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java index 0633ac55a4110..a32ff13c35437 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/IdType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java index 7ea60224d7f02..7352cb78504b4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LinkType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java index 443f58c771070..8cdff364873f0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/LogoType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java index c620b60d57564..f0e1eb44f3ed1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/ObjectFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java index 8bd21a51d5ed6..b2899d730913e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/PersonType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java index a5f20de7ae32b..db8dcc0b393f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/SourceType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java index 6421c6ae97c96..e9804d1ae3cd9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/TextType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java index 07c555c1dd6ee..a6a8041129892 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/UriType.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java index 5fc88fe9c0e0d..735e1ae1d6241 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/atom/package-info.java @@ -1,3 +1,18 @@ +/** + * Copyright Microsoft Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> From 452e0072912f30ada82deabde49dec55d672f521 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 12:10:49 -0800 Subject: [PATCH 635/664] Fixes for StatusLine resourse-leak warning. Also fixes the original HttpReaderWriter, from which StatusLine was based. Issue #520 --- .../media/implementation/StatusLine.java | 19 ++++++++++++++++++- .../implementation/HttpReaderWriter.java | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index 74e30a558c4f4..749166fe21ace 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.media.implementation; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; import java.io.StringReader; @@ -28,8 +29,16 @@ public class StatusLine { private String reason; public static StatusLine create(DataSource dataSource) { + InputStream inputStream; + try { + inputStream = dataSource.getInputStream(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + + LineInputStream stream = new LineInputStream(inputStream); try { - LineInputStream stream = new LineInputStream(dataSource.getInputStream()); String line = stream.readLine(); StringReader lineReader = new StringReader(line); @@ -43,6 +52,14 @@ public static StatusLine create(DataSource dataSource) { catch (IOException e) { throw new RuntimeException(e); } + finally { + try { + stream.close(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } } private static void expect(Reader reader, String string) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java index 347538853151a..63b5b07d611a3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java @@ -38,8 +38,17 @@ public HttpReaderWriter() { } public StatusLine parseStatusLine(DataSource ds) { + InputStream inputStream; + try { + inputStream = ds.getInputStream(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + + LineInputStream stream = new LineInputStream(inputStream); + try { - LineInputStream stream = new LineInputStream(ds.getInputStream()); String line = stream.readLine(); StringReader lineReader = new StringReader(line); @@ -53,6 +62,14 @@ public StatusLine parseStatusLine(DataSource ds) { catch (IOException e) { throw new RuntimeException(e); } + finally { + try { + stream.close(); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } } public InternetHeaders parseHeaders(DataSource ds) { From 076e66eb1b45e86d21fac686f5536c82c887cc4d Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 12:16:23 -0800 Subject: [PATCH 636/664] remove all the dates --- .../windowsazure/serviceruntime/AcquireCurrentState.java | 2 +- .../windowsazure/serviceruntime/AcquireLeaseInfo.java | 2 +- .../com/microsoft/windowsazure/serviceruntime/Adapter1.java | 2 +- .../serviceruntime/ChunkedGoalStateDeserializer.java | 2 +- .../windowsazure/serviceruntime/ConfigurationSettingInfo.java | 2 +- .../serviceruntime/ConfigurationSettingsInfo.java | 2 +- .../windowsazure/serviceruntime/CurrentRoleInstanceInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/CurrentState.java | 2 +- .../windowsazure/serviceruntime/CurrentStateInfo.java | 2 +- .../windowsazure/serviceruntime/CurrentStateSerializer.java | 2 +- .../microsoft/windowsazure/serviceruntime/CurrentStatus.java | 2 +- .../windowsazure/serviceruntime/CurrentStatusEnum.java | 2 +- .../microsoft/windowsazure/serviceruntime/DeploymentInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/EndpointInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/EndpointsInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/ExpectedState.java | 2 +- .../windowsazure/serviceruntime/ExpectedStateEnum.java | 2 +- .../windowsazure/serviceruntime/FileInputChannel.java | 2 +- .../windowsazure/serviceruntime/FileOutputChannel.java | 2 +- .../com/microsoft/windowsazure/serviceruntime/GoalState.java | 2 +- .../windowsazure/serviceruntime/GoalStateChangedListener.java | 2 +- .../windowsazure/serviceruntime/GoalStateDeserializer.java | 2 +- .../microsoft/windowsazure/serviceruntime/GoalStateInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/InputChannel.java | 2 +- .../microsoft/windowsazure/serviceruntime/LocalResource.java | 2 +- .../windowsazure/serviceruntime/LocalResourceInfo.java | 2 +- .../windowsazure/serviceruntime/LocalResourcesInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/ObjectFactory.java | 2 +- .../microsoft/windowsazure/serviceruntime/OutputChannel.java | 2 +- .../windowsazure/serviceruntime/Protocol1RuntimeClient.java | 2 +- .../serviceruntime/Protocol1RuntimeCurrentStateClient.java | 2 +- .../serviceruntime/Protocol1RuntimeGoalStateClient.java | 2 +- .../microsoft/windowsazure/serviceruntime/ProtocolEnum.java | 2 +- .../windowsazure/serviceruntime/ReleaseCurrentState.java | 2 +- .../java/com/microsoft/windowsazure/serviceruntime/Role.java | 2 +- .../windowsazure/serviceruntime/RoleEnvironment.java | 2 +- .../windowsazure/serviceruntime/RoleEnvironmentChange.java | 2 +- .../serviceruntime/RoleEnvironmentChangedEvent.java | 2 +- .../serviceruntime/RoleEnvironmentChangedListener.java | 2 +- .../serviceruntime/RoleEnvironmentChangingEvent.java | 2 +- .../serviceruntime/RoleEnvironmentChangingListener.java | 2 +- .../RoleEnvironmentConfigurationSettingChange.java | 2 +- .../windowsazure/serviceruntime/RoleEnvironmentData.java | 2 +- .../serviceruntime/RoleEnvironmentDataDeserializer.java | 2 +- .../windowsazure/serviceruntime/RoleEnvironmentInfo.java | 2 +- .../serviceruntime/RoleEnvironmentNotAvailableException.java | 2 +- .../serviceruntime/RoleEnvironmentStoppingListener.java | 2 +- .../serviceruntime/RoleEnvironmentTopologyChange.java | 2 +- .../com/microsoft/windowsazure/serviceruntime/RoleInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/RoleInstance.java | 2 +- .../windowsazure/serviceruntime/RoleInstanceEndpoint.java | 2 +- .../windowsazure/serviceruntime/RoleInstanceInfo.java | 2 +- .../windowsazure/serviceruntime/RoleInstanceStatus.java | 2 +- .../windowsazure/serviceruntime/RoleInstancesInfo.java | 2 +- .../com/microsoft/windowsazure/serviceruntime/RolesInfo.java | 2 +- .../microsoft/windowsazure/serviceruntime/RuntimeClient.java | 2 +- .../windowsazure/serviceruntime/RuntimeClientFactory.java | 2 +- .../serviceruntime/RuntimeCurrentStateClient.java | 2 +- .../windowsazure/serviceruntime/RuntimeGoalStateClient.java | 2 +- .../microsoft/windowsazure/serviceruntime/RuntimeKernel.java | 2 +- .../serviceruntime/RuntimeServerDiscoveryInfo.java | 2 +- .../serviceruntime/RuntimeServerEndpointInfo.java | 2 +- .../serviceruntime/RuntimeServerEndpointsInfo.java | 2 +- .../windowsazure/serviceruntime/RuntimeVersionManager.java | 2 +- .../serviceruntime/RuntimeVersionProtocolClient.java | 2 +- .../windowsazure/serviceruntime/StatusLeaseInfo.java | 2 +- .../serviceruntime/XmlCurrentStateSerializer.java | 2 +- .../windowsazure/serviceruntime/XmlGoalStateDeserializer.java | 2 +- .../serviceruntime/XmlRoleEnvironmentDataDeserializer.java | 2 +- .../windowsazure/services/blob/BlobConfiguration.java | 2 +- .../microsoft/windowsazure/services/blob/BlobContract.java | 2 +- .../com/microsoft/windowsazure/services/blob/BlobService.java | 2 +- .../com/microsoft/windowsazure/services/blob/Exports.java | 2 +- .../services/blob/client/BlobAccessPolicyResponse.java | 2 +- .../windowsazure/services/blob/client/BlobAttributes.java | 2 +- .../windowsazure/services/blob/client/BlobConstants.java | 2 +- .../services/blob/client/BlobContainerAttributes.java | 2 +- .../services/blob/client/BlobContainerPermissions.java | 2 +- .../services/blob/client/BlobContainerProperties.java | 2 +- .../services/blob/client/BlobContainerPublicAccessType.java | 2 +- .../services/blob/client/BlobDeserializationHelper.java | 2 +- .../windowsazure/services/blob/client/BlobInputStream.java | 2 +- .../windowsazure/services/blob/client/BlobListingContext.java | 2 +- .../windowsazure/services/blob/client/BlobListingDetails.java | 2 +- .../windowsazure/services/blob/client/BlobOutputStream.java | 2 +- .../windowsazure/services/blob/client/BlobProperties.java | 2 +- .../windowsazure/services/blob/client/BlobRequest.java | 2 +- .../windowsazure/services/blob/client/BlobRequestOptions.java | 2 +- .../windowsazure/services/blob/client/BlobResponse.java | 2 +- .../microsoft/windowsazure/services/blob/client/BlobType.java | 2 +- .../windowsazure/services/blob/client/BlockEntry.java | 2 +- .../windowsazure/services/blob/client/BlockListingFilter.java | 2 +- .../windowsazure/services/blob/client/BlockSearchMode.java | 2 +- .../windowsazure/services/blob/client/CloudBlob.java | 2 +- .../windowsazure/services/blob/client/CloudBlobClient.java | 2 +- .../windowsazure/services/blob/client/CloudBlobContainer.java | 2 +- .../windowsazure/services/blob/client/CloudBlobDirectory.java | 2 +- .../windowsazure/services/blob/client/CloudBlockBlob.java | 2 +- .../windowsazure/services/blob/client/CloudPageBlob.java | 2 +- .../services/blob/client/ContainerListingDetails.java | 2 +- .../windowsazure/services/blob/client/ContainerRequest.java | 2 +- .../windowsazure/services/blob/client/ContainerResponse.java | 2 +- .../windowsazure/services/blob/client/CopyState.java | 2 +- .../windowsazure/services/blob/client/CopyStatus.java | 2 +- .../services/blob/client/DeleteSnapshotsOption.java | 2 +- .../services/blob/client/GetBlockListResponse.java | 2 +- .../services/blob/client/GetPageRangesResponse.java | 2 +- .../windowsazure/services/blob/client/ListBlobItem.java | 2 +- .../windowsazure/services/blob/client/ListBlobsResponse.java | 2 +- .../services/blob/client/ListContainersResponse.java | 2 +- .../windowsazure/services/blob/client/PageOperationType.java | 2 +- .../windowsazure/services/blob/client/PageProperties.java | 2 +- .../windowsazure/services/blob/client/PageRange.java | 2 +- .../services/blob/client/SharedAccessBlobPermissions.java | 2 +- .../services/blob/client/SharedAccessBlobPolicy.java | 2 +- .../blob/core/storage/SharedAccessSignatureHelper.java | 2 +- .../services/blob/implementation/BlobExceptionProcessor.java | 2 +- .../services/blob/implementation/BlobOperationRestProxy.java | 4 ++-- .../services/blob/implementation/BlobRestProxy.java | 2 +- .../services/blob/implementation/ContainerACLDateAdapter.java | 2 +- .../services/blob/implementation/HmacSHA256Sign.java | 2 +- .../services/blob/implementation/ISO8601DateConverter.java | 2 +- .../services/blob/implementation/MetadataAdapter.java | 2 +- .../services/blob/implementation/RFC1123DateAdapter.java | 2 +- .../services/blob/implementation/RFC1123DateConverter.java | 2 +- .../services/blob/implementation/SharedKeyFilter.java | 2 +- .../services/blob/implementation/SharedKeyLiteFilter.java | 2 +- .../services/blob/implementation/SharedKeyUtils.java | 2 +- .../windowsazure/services/blob/models/AccessCondition.java | 2 +- .../services/blob/models/AccessConditionHeaderType.java | 2 +- .../services/blob/models/AcquireLeaseOptions.java | 2 +- .../windowsazure/services/blob/models/AcquireLeaseResult.java | 2 +- .../windowsazure/services/blob/models/BlobProperties.java | 2 +- .../windowsazure/services/blob/models/BlobServiceOptions.java | 2 +- .../windowsazure/services/blob/models/BlockList.java | 2 +- .../services/blob/models/CommitBlobBlocksOptions.java | 2 +- .../windowsazure/services/blob/models/ContainerACL.java | 2 +- .../windowsazure/services/blob/models/CopyBlobOptions.java | 2 +- .../windowsazure/services/blob/models/CopyBlobResult.java | 2 +- .../services/blob/models/CreateBlobBlockOptions.java | 2 +- .../windowsazure/services/blob/models/CreateBlobOptions.java | 2 +- .../services/blob/models/CreateBlobPagesOptions.java | 2 +- .../services/blob/models/CreateBlobPagesResult.java | 2 +- .../windowsazure/services/blob/models/CreateBlobResult.java | 2 +- .../services/blob/models/CreateBlobSnapshotOptions.java | 2 +- .../services/blob/models/CreateBlobSnapshotResult.java | 2 +- .../services/blob/models/CreateContainerOptions.java | 2 +- .../windowsazure/services/blob/models/DeleteBlobOptions.java | 2 +- .../services/blob/models/DeleteContainerOptions.java | 2 +- .../services/blob/models/GetBlobMetadataOptions.java | 2 +- .../services/blob/models/GetBlobMetadataResult.java | 2 +- .../windowsazure/services/blob/models/GetBlobOptions.java | 2 +- .../services/blob/models/GetBlobPropertiesOptions.java | 2 +- .../services/blob/models/GetBlobPropertiesResult.java | 2 +- .../windowsazure/services/blob/models/GetBlobResult.java | 2 +- .../services/blob/models/GetContainerACLResult.java | 2 +- .../services/blob/models/GetContainerPropertiesResult.java | 2 +- .../services/blob/models/GetServicePropertiesResult.java | 2 +- .../services/blob/models/ListBlobBlocksOptions.java | 2 +- .../services/blob/models/ListBlobBlocksResult.java | 2 +- .../services/blob/models/ListBlobRegionsOptions.java | 2 +- .../services/blob/models/ListBlobRegionsResult.java | 2 +- .../windowsazure/services/blob/models/ListBlobsOptions.java | 2 +- .../windowsazure/services/blob/models/ListBlobsResult.java | 2 +- .../services/blob/models/ListContainersOptions.java | 2 +- .../services/blob/models/ListContainersResult.java | 2 +- .../windowsazure/services/blob/models/PageRange.java | 2 +- .../windowsazure/services/blob/models/ServiceProperties.java | 4 ++-- .../services/blob/models/SetBlobMetadataOptions.java | 2 +- .../services/blob/models/SetBlobMetadataResult.java | 2 +- .../services/blob/models/SetBlobPropertiesOptions.java | 2 +- .../services/blob/models/SetBlobPropertiesResult.java | 2 +- .../services/blob/models/SetContainerMetadataOptions.java | 2 +- .../com/microsoft/windowsazure/services/core/Builder.java | 2 +- .../microsoft/windowsazure/services/core/Configuration.java | 2 +- .../windowsazure/services/core/ConfigurationException.java | 2 +- .../microsoft/windowsazure/services/core/DefaultBuilder.java | 2 +- .../windowsazure/services/core/ExponentialRetryPolicy.java | 2 +- .../windowsazure/services/core/FilterableService.java | 2 +- .../windowsazure/services/core/IdempotentClientFilter.java | 2 +- .../com/microsoft/windowsazure/services/core/RetryPolicy.java | 2 +- .../windowsazure/services/core/RetryPolicyFilter.java | 2 +- .../windowsazure/services/core/ServiceException.java | 2 +- .../microsoft/windowsazure/services/core/ServiceFilter.java | 2 +- .../windowsazure/services/core/ServiceTimeoutException.java | 2 +- .../windowsazure/services/core/storage/AccessCondition.java | 2 +- .../services/core/storage/AccessPolicyResponseBase.java | 2 +- .../services/core/storage/CloudStorageAccount.java | 2 +- .../windowsazure/services/core/storage/Constants.java | 2 +- .../windowsazure/services/core/storage/Credentials.java | 2 +- .../services/core/storage/DoesServiceRequest.java | 2 +- .../windowsazure/services/core/storage/LeaseDuration.java | 2 +- .../windowsazure/services/core/storage/LeaseState.java | 2 +- .../windowsazure/services/core/storage/LeaseStatus.java | 2 +- .../windowsazure/services/core/storage/LoggingOperations.java | 2 +- .../windowsazure/services/core/storage/LoggingProperties.java | 2 +- .../windowsazure/services/core/storage/MetricsLevel.java | 2 +- .../windowsazure/services/core/storage/MetricsProperties.java | 2 +- .../windowsazure/services/core/storage/OperationContext.java | 2 +- .../windowsazure/services/core/storage/RequestOptions.java | 2 +- .../windowsazure/services/core/storage/RequestResult.java | 2 +- .../services/core/storage/ResponseReceivedEvent.java | 2 +- .../services/core/storage/ResultContinuation.java | 2 +- .../services/core/storage/ResultContinuationType.java | 2 +- .../windowsazure/services/core/storage/ResultSegment.java | 2 +- .../services/core/storage/RetryExponentialRetry.java | 2 +- .../windowsazure/services/core/storage/RetryLinearRetry.java | 2 +- .../windowsazure/services/core/storage/RetryNoRetry.java | 2 +- .../windowsazure/services/core/storage/RetryPolicy.java | 2 +- .../services/core/storage/RetryPolicyFactory.java | 2 +- .../windowsazure/services/core/storage/RetryResult.java | 2 +- .../windowsazure/services/core/storage/ServiceClient.java | 2 +- .../windowsazure/services/core/storage/ServiceProperties.java | 2 +- .../services/core/storage/StorageCredentials.java | 2 +- .../core/storage/StorageCredentialsAccountAndKey.java | 2 +- .../services/core/storage/StorageCredentialsAnonymous.java | 2 +- .../core/storage/StorageCredentialsSharedAccessSignature.java | 2 +- .../windowsazure/services/core/storage/StorageErrorCode.java | 2 +- .../services/core/storage/StorageErrorCodeStrings.java | 2 +- .../windowsazure/services/core/storage/StorageEvent.java | 2 +- .../services/core/storage/StorageEventMultiCaster.java | 2 +- .../windowsazure/services/core/storage/StorageException.java | 2 +- .../core/storage/StorageExtendedErrorInformation.java | 2 +- .../windowsazure/services/core/storage/StorageKey.java | 2 +- .../windowsazure/services/core/storage/utils/Base64.java | 2 +- .../windowsazure/services/core/storage/utils/PathUtility.java | 2 +- .../services/core/storage/utils/StreamMd5AndLength.java | 2 +- .../services/core/storage/utils/UriQueryBuilder.java | 2 +- .../windowsazure/services/core/storage/utils/Utility.java | 2 +- .../core/storage/utils/implementation/BaseRequest.java | 2 +- .../core/storage/utils/implementation/BaseResponse.java | 2 +- .../utils/implementation/BlobQueueFullCanonicalizer.java | 2 +- .../utils/implementation/BlobQueueLiteCanonicalizer.java | 2 +- .../core/storage/utils/implementation/Canonicalizer.java | 2 +- .../storage/utils/implementation/CanonicalizerFactory.java | 2 +- .../storage/utils/implementation/DeserializationHelper.java | 2 +- .../core/storage/utils/implementation/ExecutionEngine.java | 2 +- .../storage/utils/implementation/LazySegmentedIterable.java | 2 +- .../storage/utils/implementation/LazySegmentedIterator.java | 2 +- .../core/storage/utils/implementation/LeaseAction.java | 2 +- .../core/storage/utils/implementation/ListingContext.java | 2 +- .../utils/implementation/SegmentedStorageOperation.java | 2 +- .../storage/utils/implementation/StorageErrorResponse.java | 2 +- .../core/storage/utils/implementation/StorageOperation.java | 2 +- .../storage/utils/implementation/TableLiteCanonicalizer.java | 2 +- .../windowsazure/services/core/utils/CommaStringBuilder.java | 2 +- .../windowsazure/services/core/utils/DateFactory.java | 2 +- .../windowsazure/services/core/utils/DefaultDateFactory.java | 2 +- .../microsoft/windowsazure/services/core/utils/Exports.java | 2 +- .../services/core/utils/ServiceExceptionFactory.java | 2 +- .../services/core/utils/pipeline/Base64StringAdapter.java | 2 +- .../services/core/utils/pipeline/ClientConfigSettings.java | 2 +- .../services/core/utils/pipeline/ClientFilterAdapter.java | 2 +- .../services/core/utils/pipeline/EntityStreamingListener.java | 2 +- .../windowsazure/services/core/utils/pipeline/Exports.java | 2 +- .../services/core/utils/pipeline/HttpURLConnectionClient.java | 2 +- .../core/utils/pipeline/HttpURLConnectionClientHandler.java | 2 +- .../services/core/utils/pipeline/PipelineHelpers.java | 2 +- .../com/microsoft/windowsazure/services/queue/Exports.java | 2 +- .../windowsazure/services/queue/QueueConfiguration.java | 2 +- .../microsoft/windowsazure/services/queue/QueueContract.java | 2 +- .../microsoft/windowsazure/services/queue/QueueService.java | 2 +- .../windowsazure/services/queue/client/CloudQueue.java | 2 +- .../windowsazure/services/queue/client/CloudQueueClient.java | 2 +- .../windowsazure/services/queue/client/CloudQueueMessage.java | 2 +- .../services/queue/client/ListQueuesResponse.java | 2 +- .../services/queue/client/MessageUpdateFields.java | 2 +- .../services/queue/client/QueueAccessPolicyResponse.java | 2 +- .../windowsazure/services/queue/client/QueueConstants.java | 2 +- .../services/queue/client/QueueDeserializationHelper.java | 2 +- .../services/queue/client/QueueListingDetails.java | 2 +- .../windowsazure/services/queue/client/QueueMessageType.java | 2 +- .../windowsazure/services/queue/client/QueuePermissions.java | 4 ++-- .../windowsazure/services/queue/client/QueueRequest.java | 2 +- .../services/queue/client/QueueRequestOptions.java | 2 +- .../windowsazure/services/queue/client/QueueResponse.java | 2 +- .../services/queue/client/SharedAccessQueuePermissions.java | 2 +- .../services/queue/client/SharedAccessQueuePolicy.java | 2 +- .../queue/implementation/QueueExceptionProcessor.java | 2 +- .../services/queue/implementation/QueueMessage.java | 2 +- .../services/queue/implementation/QueueRestProxy.java | 2 +- .../services/queue/implementation/SharedKeyFilter.java | 2 +- .../services/queue/implementation/SharedKeyLiteFilter.java | 2 +- .../services/queue/models/CreateMessageOptions.java | 2 +- .../services/queue/models/CreateQueueOptions.java | 2 +- .../services/queue/models/GetQueueMetadataResult.java | 2 +- .../services/queue/models/GetServicePropertiesResult.java | 2 +- .../services/queue/models/ListMessagesOptions.java | 2 +- .../services/queue/models/ListMessagesResult.java | 2 +- .../windowsazure/services/queue/models/ListQueuesOptions.java | 2 +- .../windowsazure/services/queue/models/ListQueuesResult.java | 2 +- .../services/queue/models/PeekMessagesOptions.java | 2 +- .../services/queue/models/PeekMessagesResult.java | 2 +- .../services/queue/models/QueueServiceOptions.java | 2 +- .../windowsazure/services/queue/models/ServiceProperties.java | 2 +- .../services/queue/models/UpdateMessageResult.java | 2 +- .../microsoft/windowsazure/services/serviceBus/Exports.java | 2 +- .../services/serviceBus/ServiceBusConfiguration.java | 2 +- .../windowsazure/services/serviceBus/ServiceBusContract.java | 2 +- .../windowsazure/services/serviceBus/ServiceBusService.java | 2 +- .../com/microsoft/windowsazure/services/serviceBus/Util.java | 2 +- .../services/serviceBus/implementation/BrokerProperties.java | 2 +- .../serviceBus/implementation/BrokerPropertiesMapper.java | 2 +- .../serviceBus/implementation/CustomPropertiesMapper.java | 2 +- .../services/serviceBus/implementation/EntryModel.java | 2 +- .../serviceBus/implementation/EntryModelProvider.java | 2 +- .../services/serviceBus/implementation/Exports.java | 2 +- .../serviceBus/implementation/MarshallerProvider.java | 2 +- .../serviceBus/implementation/NamespacePrefixMapperImpl.java | 2 +- .../implementation/ServiceBusExceptionProcessor.java | 2 +- .../serviceBus/implementation/ServiceBusRestProxy.java | 2 +- .../serviceBus/implementation/WrapAccessTokenResult.java | 2 +- .../services/serviceBus/implementation/WrapContract.java | 2 +- .../services/serviceBus/implementation/WrapFilter.java | 2 +- .../services/serviceBus/implementation/WrapRestProxy.java | 2 +- .../services/serviceBus/implementation/WrapTokenManager.java | 2 +- .../services/serviceBus/models/AbstractListOptions.java | 2 +- .../services/serviceBus/models/BrokeredMessage.java | 2 +- .../services/serviceBus/models/CreateQueueResult.java | 2 +- .../services/serviceBus/models/CreateRuleResult.java | 2 +- .../services/serviceBus/models/CreateSubscriptionResult.java | 2 +- .../services/serviceBus/models/CreateTopicResult.java | 2 +- .../services/serviceBus/models/GetQueueResult.java | 2 +- .../services/serviceBus/models/GetRuleResult.java | 2 +- .../services/serviceBus/models/GetSubscriptionResult.java | 2 +- .../services/serviceBus/models/GetTopicResult.java | 2 +- .../services/serviceBus/models/ListQueuesOptions.java | 2 +- .../services/serviceBus/models/ListQueuesResult.java | 2 +- .../services/serviceBus/models/ListRulesOptions.java | 2 +- .../services/serviceBus/models/ListRulesResult.java | 2 +- .../services/serviceBus/models/ListSubscriptionsOptions.java | 2 +- .../services/serviceBus/models/ListSubscriptionsResult.java | 2 +- .../services/serviceBus/models/ListTopicsOptions.java | 2 +- .../services/serviceBus/models/ListTopicsResult.java | 2 +- .../windowsazure/services/serviceBus/models/QueueInfo.java | 2 +- .../services/serviceBus/models/ReceiveMessageOptions.java | 2 +- .../services/serviceBus/models/ReceiveMessageResult.java | 2 +- .../windowsazure/services/serviceBus/models/ReceiveMode.java | 2 +- .../services/serviceBus/models/ReceiveQueueMessageResult.java | 2 +- .../serviceBus/models/ReceiveSubscriptionMessageResult.java | 2 +- .../windowsazure/services/serviceBus/models/RuleInfo.java | 2 +- .../services/serviceBus/models/SubscriptionInfo.java | 2 +- .../windowsazure/services/serviceBus/models/TopicInfo.java | 2 +- .../windowsazure/services/table/EdmValueConverter.java | 2 +- .../com/microsoft/windowsazure/services/table/Exports.java | 2 +- .../windowsazure/services/table/TableConfiguration.java | 2 +- .../microsoft/windowsazure/services/table/TableContract.java | 2 +- .../microsoft/windowsazure/services/table/TableService.java | 2 +- .../windowsazure/services/table/client/AtomPubParser.java | 2 +- .../windowsazure/services/table/client/CloudTable.java | 2 +- .../windowsazure/services/table/client/CloudTableClient.java | 2 +- .../services/table/client/DynamicTableEntity.java | 2 +- .../microsoft/windowsazure/services/table/client/EdmType.java | 2 +- .../windowsazure/services/table/client/EntityProperty.java | 2 +- .../windowsazure/services/table/client/EntityResolver.java | 2 +- .../microsoft/windowsazure/services/table/client/Ignore.java | 2 +- .../windowsazure/services/table/client/MimeHeader.java | 2 +- .../windowsazure/services/table/client/MimeHelper.java | 2 +- .../windowsazure/services/table/client/MimePart.java | 2 +- .../windowsazure/services/table/client/ODataConstants.java | 2 +- .../windowsazure/services/table/client/ODataPayload.java | 2 +- .../windowsazure/services/table/client/PropertyPair.java | 2 +- .../services/table/client/QueryTableOperation.java | 2 +- .../services/table/client/SharedAccessTablePermissions.java | 2 +- .../services/table/client/SharedAccessTablePolicy.java | 2 +- .../microsoft/windowsazure/services/table/client/StoreAs.java | 2 +- .../services/table/client/TableAccessPolicyResponse.java | 2 +- .../services/table/client/TableBatchOperation.java | 2 +- .../windowsazure/services/table/client/TableConstants.java | 2 +- .../windowsazure/services/table/client/TableEntity.java | 2 +- .../windowsazure/services/table/client/TableOperation.java | 2 +- .../services/table/client/TableOperationType.java | 2 +- .../windowsazure/services/table/client/TablePermissions.java | 4 ++-- .../windowsazure/services/table/client/TableQuery.java | 2 +- .../windowsazure/services/table/client/TableRequest.java | 2 +- .../services/table/client/TableRequestOptions.java | 2 +- .../windowsazure/services/table/client/TableResponse.java | 2 +- .../windowsazure/services/table/client/TableResult.java | 2 +- .../services/table/client/TableServiceEntity.java | 2 +- .../services/table/client/TableServiceException.java | 2 +- .../windowsazure/services/table/client/TableUpdateType.java | 2 +- .../services/table/implementation/AtomReaderWriter.java | 2 +- .../table/implementation/DefaultEdmValueConterter.java | 2 +- .../table/implementation/DefaultXMLStreamFactory.java | 2 +- .../services/table/implementation/HttpReaderWriter.java | 2 +- .../services/table/implementation/InputStreamDataSource.java | 4 ++-- .../services/table/implementation/MimeReaderWriter.java | 2 +- .../services/table/implementation/SharedKeyFilter.java | 2 +- .../services/table/implementation/SharedKeyLiteFilter.java | 2 +- .../table/implementation/TableExceptionProcessor.java | 2 +- .../services/table/implementation/TableRestProxy.java | 2 +- .../services/table/implementation/XMLStreamFactory.java | 2 +- .../windowsazure/services/table/models/BatchOperations.java | 2 +- .../windowsazure/services/table/models/BatchResult.java | 2 +- .../windowsazure/services/table/models/BinaryFilter.java | 2 +- .../windowsazure/services/table/models/ConstantFilter.java | 2 +- .../services/table/models/DeleteEntityOptions.java | 2 +- .../microsoft/windowsazure/services/table/models/EdmType.java | 4 ++-- .../microsoft/windowsazure/services/table/models/Entity.java | 2 +- .../microsoft/windowsazure/services/table/models/Filter.java | 2 +- .../windowsazure/services/table/models/GetEntityResult.java | 2 +- .../services/table/models/GetServicePropertiesResult.java | 2 +- .../windowsazure/services/table/models/GetTableResult.java | 2 +- .../services/table/models/InsertEntityResult.java | 2 +- .../windowsazure/services/table/models/Property.java | 4 ++-- .../services/table/models/PropertyNameFilter.java | 2 +- .../services/table/models/QueryEntitiesOptions.java | 2 +- .../services/table/models/QueryEntitiesResult.java | 2 +- .../windowsazure/services/table/models/QueryStringFilter.java | 2 +- .../services/table/models/QueryTablesOptions.java | 2 +- .../windowsazure/services/table/models/QueryTablesResult.java | 2 +- .../windowsazure/services/table/models/ServiceProperties.java | 2 +- .../windowsazure/services/table/models/TableEntry.java | 2 +- .../services/table/models/TableServiceOptions.java | 2 +- .../windowsazure/services/table/models/UnaryFilter.java | 2 +- .../services/table/models/UpdateEntityResult.java | 2 +- .../configuration/builder/AlterClassWithProperties.java | 2 +- .../builder/ClassWithMultipleCtorMultipleInject.java | 2 +- .../configuration/builder/ClassWithMultipleCtorNoInject.java | 2 +- .../configuration/builder/ClassWithNamedParameter.java | 2 +- .../configuration/builder/ClassWithProperties.java | 2 +- .../configuration/builder/ClassWithSingleCtorNoInject.java | 2 +- .../configuration/builder/DefaultBuilderTest.java | 2 +- .../windowsazure/serviceruntime/FileInputChannelTests.java | 2 +- .../windowsazure/serviceruntime/MockInputChannel.java | 2 +- .../Protocol1RuntimeCurrentStateClientTests.java | 2 +- .../serviceruntime/Protocol1RuntimeGoalStateClientTests.java | 2 +- .../windowsazure/serviceruntime/RoleEnvironmentTests.java | 2 +- .../serviceruntime/RuntimeVersionManagerTests.java | 2 +- .../serviceruntime/XmlGoalStateDeserializerTests.java | 2 +- .../services/blob/BlobServiceIntegrationTest.java | 2 +- .../windowsazure/services/blob/IntegrationTestBase.java | 2 +- .../windowsazure/services/blob/client/BlobTestBase.java | 2 +- .../services/blob/client/CloudBlobContainerTests.java | 2 +- .../blob/implementation/ISO8601DateConverterTests.java | 2 +- .../services/core/IdempotentClientFilterTest.java | 2 +- .../services/core/utils/pipeline/PipelineHelpersTest.java | 2 +- .../windowsazure/services/queue/IntegrationTestBase.java | 2 +- .../services/queue/QueueServiceIntegrationTest.java | 2 +- .../services/queue/client/CloudQueueClientTests.java | 2 +- .../windowsazure/services/queue/client/CloudQueueTests.java | 2 +- .../windowsazure/services/queue/client/QueueTestBase.java | 2 +- .../services/scenarios/MediaServiceScenarioTest.java | 2 +- .../services/scenarios/MediaServiceValidation.java | 2 +- .../windowsazure/services/scenarios/MediaServiceWrapper.java | 4 ++-- .../windowsazure/services/scenarios/ScenarioTestBase.java | 2 +- .../services/serviceBus/BrokerPropertiesMapperTest.java | 2 +- .../windowsazure/services/serviceBus/IntegrationTestBase.java | 2 +- .../services/serviceBus/ServiceBusConfigurationTest.java | 2 +- .../services/serviceBus/ServiceBusCreationTest.java | 2 +- .../services/serviceBus/ServiceBusIntegrationTest.java | 2 +- .../serviceBus/implementation/CustomPropertiesMapperTest.java | 2 +- .../implementation/WrapRestProxyIntegrationTest.java | 2 +- .../implementation/WrapTokenManagerIntegrationTest.java | 2 +- .../serviceBus/implementation/WrapTokenManagerTest.java | 2 +- .../windowsazure/services/table/IntegrationTestBase.java | 2 +- .../services/table/TableServiceIntegrationTest.java | 2 +- .../services/table/client/TableBatchOperationTests.java | 2 +- .../windowsazure/services/table/client/TableClientTests.java | 2 +- .../services/table/client/TableEscapingTests.java | 2 +- .../services/table/client/TableOperationTests.java | 2 +- .../windowsazure/services/table/client/TableQueryTests.java | 2 +- .../services/table/client/TableSerializerTests.java | 2 +- .../windowsazure/services/table/client/TableTestBase.java | 2 +- .../services/table/implementation/AtomReaderWriterTests.java | 2 +- .../services/table/implementation/MimeMultipartTests.java | 2 +- .../windowsazure/utils/ServiceExceptionFactoryTest.java | 2 +- 467 files changed, 475 insertions(+), 475 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java index 2dd6e66b18581..075bafcad08b7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireCurrentState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java index 7030db4332b2b..981433e5ccca8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/AcquireLeaseInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java index 3b35f8d0463e7..f6ffdd6ff61ff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Adapter1.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java index 4d5d2f468fe44..38ed6c4a4812c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ChunkedGoalStateDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java index 3c52c56eb5688..3dc242264b4c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java index 152228cced1bb..c649e156bc8d5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ConfigurationSettingsInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java index 78ae4283605f0..2e2e0cab510ee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentRoleInstanceInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java index a297210f77e46..1a94780bec991 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java index e9ae55b96a160..d1a510648d227 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java index b972bc6c4f516..a49ea402dd49e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStateSerializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java index 4117871ddac56..581ae06130d82 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatus.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java index 01ce61f3ae834..47ccf5fe608a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/CurrentStatusEnum.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java index 90b28659fa77a..bf718ae02a45e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/DeploymentInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java index 38a846701d74c..27080ec5e080e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java index 208070113082d..c7fec0149f8c9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/EndpointsInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java index c341d8630e501..12c3c2574fb38 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java index 9f07267449bb1..84dc6e399cf6a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ExpectedStateEnum.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java index 75c85fb7e05b8..3d4d2ee09ef3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileInputChannel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java index a377a8f42b729..19d28d97d8593 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/FileOutputChannel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java index 963b1e88abaf8..5dce2f4fc9fb3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java index 68af2418ea7c3..1ce379942f891 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateChangedListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java index c255037d4393b..71bea2022a6c3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java index fa26a21d40464..8cdab9ef1035d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/GoalStateInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java index 9623dfd83541f..287281391853b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/InputChannel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java index c62ff4aaf8667..aadc32b1c0e03 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResource.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java index 524a072ca85a3..2f835312652b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourceInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java index e4c1f724e57c7..fe827403e6105 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/LocalResourcesInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java index 043b15c7dc373..9f1fdc395fba0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ObjectFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java index 02588c1bbd76f..10afcce3714a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/OutputChannel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java index 145fd690c46ba..bc64390fa745b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java index 5629f11bcf2c6..50386d173b70f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java index 5ad4692c4352f..0f159c54eb7bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java index db453e64c4fc6..c48227e85de77 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ProtocolEnum.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java index a1f55f0c57e14..31d36f1907d1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/ReleaseCurrentState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java index aacdb7393c327..32674087109be 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/Role.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java index d34d5bcef11fc..5d8f04727b042 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironment.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java index 25f1471358ef3..4d0016f92f8fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChange.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java index 9dceff6aaa21e..9f24a1ba276e4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java index f97f3254bf799..a70a6c2073c34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangedListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java index 165c01ae04453..47ea45eaddc5d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java index d23826c7636d5..128216aff7b17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentChangingListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java index 8cacec8f39369..98cb83df93714 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentConfigurationSettingChange.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java index 28d7583ec2dd1..77cd512331652 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentData.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java index acb58d29d2139..a551898a69166 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentDataDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java index d12e8be57331b..8c14d2406b326 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java index 5d677fc39c4b5..bf0155fe25f4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentNotAvailableException.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java index e226db05b84b0..d00d8081c77d6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentStoppingListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java index b6e93c6f2defd..f7709f3da541a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTopologyChange.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java index a658b35195ef7..98e36249cfcd2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java index e43948abd8b3b..4f7a470f2f209 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstance.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java index 2e13e5fb7b09c..3efe3eefb54c2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceEndpoint.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java index 16f5d51cdd256..ef81ccbcf049b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java index f1dd9d12e3d92..89e62e8e51a10 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstanceStatus.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java index 128754996001b..ce1e0a1b36ae9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RoleInstancesInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java index 75c91dd919307..cf0d27cff09e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RolesInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java index 8e628daccffb1..db615c19f24e5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java index 5e08d97c63291..23934f16847b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeClientFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java index 253dbe5432640..aa07d24e26152 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeCurrentStateClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java index 74f1166990e69..8ae17edc65a45 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeGoalStateClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java index 58bc3927ad723..2189b14c8a625 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeKernel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java index df4dac6e76ed1..95d8d15c81b41 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerDiscoveryInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java index 071da2b2710d0..70813f42b9fcf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java index 13dfdd6359893..4de26b3436725 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeServerEndpointsInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java index 272cc36f59a26..09931c8a5f854 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java index 4bea2131f367c..1895b03ac9144 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionProtocolClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java index 3d4b1e55bc71f..8c67f9c094ab6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/StatusLeaseInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java index b947685e5c855..2c3b741c6e0c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlCurrentStateSerializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java index 8499f43b7dd0b..700e9e33d1863 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java index 8f27d2a1e3469..6304825adc8cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/serviceruntime/XmlRoleEnvironmentDataDeserializer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java index a8191bce65ae1..80c3896d33a3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java index 367d3b311d935..2cac537f9456f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/BlobContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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/BlobService.java index 0e48a3033dfb5..f09cb8e888da5 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/BlobService.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 8d9d63bc8972d..57a7cd87cc5f9 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAccessPolicyResponse.java index 66313bc04ebf1..a4bccf20ddb4c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAccessPolicyResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java index 64f83ee08e53a..0fd33658c8627 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobAttributes.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java index 8f3acd35234bd..0c56cc1f93775 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobConstants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java index f0db3fad5b0fd..fb6481bee0019 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerAttributes.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java index c5eabded38126..3838342e0873b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java index 599687b285d76..2b781912d584b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java index 554dd7bfd40cd..51c6cdcbafad7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobContainerPublicAccessType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java index 785eed98292d3..290d529b6a21c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobDeserializationHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java index 55a8ca520e873..a31526a40e008 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobInputStream.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java index 16fea0fbe2bca..d697d0a69ba8c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingContext.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java index 1ea25afa820e3..db0b7f9a2dbd7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobListingDetails.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java index c3509df1f0c6d..dae6409998617 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobOutputStream.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java index 9bb09d0b23f64..9fc4475b052da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java index 52e9cca26ae60..97dd33e6b9e66 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java index 3cd3c219d4eff..8c1b5e055a51f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobRequestOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java index ea4f9ab2f974a..24c3d5eb9ff60 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java index 11e5fc2506212..5cef258dde152 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlobType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java index 06a588e22776f..5e01358333def 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockEntry.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java index fac52b1038956..78295959d61c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockListingFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java index f7dee4b652976..e96875f9ac376 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/BlockSearchMode.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java index 6fc3821409256..49ae8c7366fa7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlob.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java index ed74ed27450c8..181549a8d5750 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java index 6cd9752c046e7..ff67b888bfe33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java index 622ce08f40dcc..6f5d16588cbc0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlobDirectory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java index 350cf65c52674..b28a54a6affd6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudBlockBlob.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java index f5ce8f06f4c8b..e31eb5aff1961 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CloudPageBlob.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java index 12c3d8f7b27de..366ef2f8215a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerListingDetails.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java index 4c00cef60effa..4dfad857b93c1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java index f03144533da8c..1dbaec6bb4ee2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ContainerResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyState.java index b109528b14965..10c25597d0821 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyStatus.java index 33809c15c10c8..3358e040115de 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/CopyStatus.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java index 596d43f5afea9..ce7a5b5750c6f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/DeleteSnapshotsOption.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java index 7bb03d294fe1a..4b2f8f2eeec91 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetBlockListResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java index 412c863a0f9f5..63ce73d7c0ae6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/GetPageRangesResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java index 10f1b232fbd6a..790aa46034635 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobItem.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java index 5d01e4a14832f..fad732e4e49b0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListBlobsResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java index e70aa7ad5e4d4..2aa51ccfc7e25 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/ListContainersResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java index f41ba443a7386..e9d49b5739489 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageOperationType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java index 334c9aaa5f294..1e76174d74747 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java index 3827eca7897e3..92b03228ebc0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/PageRange.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPermissions.java index 5475705a29fd6..003153c6338ab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPolicy.java index 8d9c708aa56c9..c4ebe80b713c4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/client/SharedAccessBlobPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java index 26cefa304d708..9be65bdcb88f6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/core/storage/SharedAccessSignatureHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java index 157dbd9737cb8..8bae36798a8c7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 53dd40f5ed7ea..b07f42f63f29d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1009,4 +1009,4 @@ private String createPathFromContainer(String containerName) { return path; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java index 8bd98f0f850da..bb628ea9d72fc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 f1ea12dbaa76f..06ef3c975a264 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 395d7d9cd393a..71a68bd061ccd 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverter.java index 34444b858a039..cac734d4dc6e2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java index fb07884c72a3e..b174cf5f5f493 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/MetadataAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 79387438534b3..aff36b78c73e7 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 67d1738a3889d..91d2acda79bb9 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java index 9072ead435645..b3ab2cd850cef 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 37ff1321d5d96..696c73cd6d901 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java index b3cfcecbf5451..f54dcc1707422 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/SharedKeyUtils.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java index 90791bacfeb21..f9a24919bdc01 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AccessCondition.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 34966982a9da4..ecfea0b1da5af 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java index fe6e69ed87132..dce54430b5386 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java index 785d10473f081..044833ada7ba8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/AcquireLeaseResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index f5231d28254a2..630e1a9fb2696 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/BlobProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java index 3fc56c6d1ab60..1abb7d1984af5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlobServiceOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java index 320066d06f80f..71b1ef0f31a44 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/BlockList.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java index 9aa632f80f60d..477c4b4bc0e16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CommitBlobBlocksOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java index 4fb40c1285537..1668ff5fef8a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ContainerACL.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java index 484829480329d..dd5524eaba212 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobResult.java index d8dd1b665847d..9d3395c2a722e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CopyBlobResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 98bdb31d5d99a..24661cdbd6d5e 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java index e3afa134df8a2..644f5e7b4718f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java index e87466dd35c0c..6d25af5908e74 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java index 20e98bd3f3cc0..5c7711cc2500f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobPagesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java index 4ab963e269006..6181e7c7278f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java index 4df9b3b1f7c57..76b41429f1c12 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java index 7965e60deedd1..a35964af62d6e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/CreateBlobSnapshotResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 b128296b61aab..42bc57b029fdf 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 f678c6625aec2..281f0d14979b4 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 fc5c922de7566..64bf97b199a5a 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 0c8cbbbc88f07..4471ddf1a3f50 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java index 14aa9fb13e624..272547f5d7e0c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetBlobMetadataResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 2edeca6dc264d..eb944c04f1d93 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 1e93569b8a77f..6d1c433ca5fd8 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 725ce6d3c78ae..6bc1830d487d4 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 dcdc580a79eab..850d509f48eb7 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index 97597f8dbc016..68d2f677f1cd2 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java index 6a5cf9495ab06..09dbc31e85fe4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/GetContainerPropertiesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 c3773a69c6712..a37e55400a08f 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 13e7c9fe9e8e0..ddd560c352a94 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java index 216322e4dd212..9dc09239113b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListBlobBlocksResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 c944d19e596c7..a16c5a6be5d82 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 c18ccb70c38b9..a9b3fff40103f 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 ed46f9f717727..091d829076765 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 5245eea924277..fb55ed889d725 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,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 71a5a868c5ca8..d1dcb76c3fd34 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java index 3b6508eb4a8ae..17c6d23aea2b4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/ListContainersResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index 44a6fe568ca75..57fb592e24afe 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 24f92c559b2f6..f9ee9985e50c8 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -409,4 +409,4 @@ public RetentionPolicy setEnabled(boolean enabled) { return this; } } -} \ No newline at end of file +} 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 8c15e4c5c5ef3..4baca8d1dc342 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java index c00f3d67d981c..4fe30c077d1e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobMetadataResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 2dabb15421bc3..c002057c15a70 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java index 599a9576b9eed..8180dd21db398 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/models/SetBlobPropertiesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 0830b04e3d049..25933e8a3e6f7 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java index 5b7459507322c..f6a194e3349db 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Builder.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java index 4eb524c6e10b2..764db7bab9b34 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/Configuration.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java index 90fae9f80a1b5..b1787a6663277 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ConfigurationException.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java index 9db58f6417612..f72f4c935c37e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/DefaultBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java index a5ff7c5bbae4a..a03c811eaf47d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ExponentialRetryPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java index 0e9563b0131ba..53f8efe2d1fd5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/FilterableService.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java index 3a178302f7a27..f929716eec169 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/IdempotentClientFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java index 26c6fbd0ca507..a3e1a6ac74187 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java index 72686dcb2e200..7c0a56a69ff40 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/RetryPolicyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java index e9f292f180f94..2ea554ad89d17 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceException.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java index 552202540bc36..b1e0029f567e0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceTimeoutException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceTimeoutException.java index 9c3c5f7fcd134..4e67f7b214622 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceTimeoutException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/ServiceTimeoutException.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java index c2a741ef3ed2d..47397ee0ac676 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessCondition.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java index 9e513711cdb31..7d03cb86b6776 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/AccessPolicyResponseBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java index 8beb56163e4cc..7cd92741ca6a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/CloudStorageAccount.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java index 58e4d2bc8beca..2d94294658d20 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java index 705075775610e..db537f5414f7b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/Credentials.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java index 38a746f0058c4..5bdcef196e7b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/DoesServiceRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseDuration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseDuration.java index 8e795b831374f..aef43c07da4b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseDuration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseDuration.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseState.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseState.java index 9bbd28f83ecd3..39d192bffaffa 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseState.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseState.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java index b82ab088f0bc3..15907a936e628 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LeaseStatus.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java index 026ac1bb7dd2e..c862b68985185 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingOperations.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java index 6bd41e128ac10..5051456009104 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/LoggingProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java index 34d60db56b97d..b702b05e4f0c1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsLevel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java index 1021376db0385..e703379a73c0e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/MetricsProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java index 59106461ea272..97818ba6b9fb5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/OperationContext.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java index 9e6eb39b93c79..3dab216190a70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java index 3a7e01045d6bf..a6da602f8f4da 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RequestResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java index 3e8b028ad3de7..f0b8419d1ab5b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResponseReceivedEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java index 618b05cf420ca..13f4119312e29 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java index 8e6497fae08f7..02f564344f75d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultContinuationType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java index 39d2c8b737068..47f9648dc8e8d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ResultSegment.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java index be5e2e96d37ee..36b801ffb873b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryExponentialRetry.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java index 27dc7184dbc32..7f6a5f312dac5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryLinearRetry.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java index 4fb976b0d8762..b89c22e1aceee 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryNoRetry.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java index 8174c303b420b..ade5dd23b56a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java index bda29486c9be9..919c04d35a836 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryPolicyFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java index 30c3de7d38eb9..92941950b3fa1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/RetryResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java index baa4c1db04659..02f0322b2808d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java index be0000a83643b..6325e1af75ca2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/ServiceProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java index 84b4c194ac8fb..009a716557465 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentials.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java index 3406fc76c38b6..2881295c1f26a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAccountAndKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java index e40a012049a53..baf4e16dd16d6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsAnonymous.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java index 2f3e44a380ed1..4702824027ff7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageCredentialsSharedAccessSignature.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java index 2482119f82bfc..dabdb60691078 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCode.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java index 624a31467311d..3dee5cfadaea2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageErrorCodeStrings.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java index 26dc212a185c5..e6ecffbedadff 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java index 844c7a04e8998..f187a7ceb9c6d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageEventMultiCaster.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java index c01b13fbfdb97..a0a6f0f7349a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageException.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java index 0f261fa3d6b86..b70ced8c48a1e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageExtendedErrorInformation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java index 915d8537828e3..e2c2663069ebe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/StorageKey.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java index 8062504e21c76..8e8c79aaaa2fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Base64.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java index 7783f7e29548d..b43d3144223c8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/PathUtility.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java index 6df461d6df827..aac9c08199480 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/StreamMd5AndLength.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java index 60662b71c437c..43b1865b1580d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/UriQueryBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java index d290b1ec3a47e..37c099517e7d9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/Utility.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java index 910fb9f8958c4..e5273db93f60b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java index e47b64181ac97..e0412b996cdab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BaseResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java index ecd15ebc93e38..40bd6c1481716 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueFullCanonicalizer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java index 0f795725f43c7..5d36b8b7a1691 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/BlobQueueLiteCanonicalizer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java index d12785cbb8af5..b78e9c258cd3a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/Canonicalizer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java index eb9cca300c044..54ae1d41fe3ec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/CanonicalizerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java index 18b561a6665f7..99e9efae7d48c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/DeserializationHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java index e30d5f1e45440..cdffbc809ecfc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ExecutionEngine.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterable.java index d57bb296fe284..02d2c76e3f09a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterable.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java index e1f9f6ab116f4..f43f0a41b8d52 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LazySegmentedIterator.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java index b17a657c029d5..91a1f7b95c08d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/LeaseAction.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java index fffe4ba5c296f..6e28a1cddb5e6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/ListingContext.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java index abdbc987ccc32..349428f12a723 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/SegmentedStorageOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java index 90a2713c57935..6a1cda8d4c223 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageErrorResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java index 52d693f638dd2..32ff5a00459a0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/StorageOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java index d28fa2d96db41..913ed76d908af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/utils/implementation/TableLiteCanonicalizer.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/CommaStringBuilder.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/CommaStringBuilder.java index ac8b9f45c519c..55558ed7fd30a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/CommaStringBuilder.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/CommaStringBuilder.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java index 10db79d098ce8..219a08a45ac94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DateFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java index 77e779fcf10b5..b7fa4f4447dfb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/DefaultDateFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java index c9960912fb974..179dafb31dccb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java index d11feceb6d20b..2efac14c00b04 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/ServiceExceptionFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index 7a28be44bed93..975bc675e4bbd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java index 75cfa5ef47828..b7421b9ed6564 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientConfigSettings.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java index f486cbbf14015..4af39301fccfd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/ClientFilterAdapter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java index c3366788b5de7..f0a2b98cfe684 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/EntityStreamingListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java index fc565c3dde132..23b7ae8215268 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java index f996e5edc6421..a5751d7480b5f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java index 83e0822264e45..4cd755578a75d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/HttpURLConnectionClientHandler.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java index 7f117707aafcc..c022ab06a7993 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpers.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 14850f379862e..3d57a69f82c7a 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index 1fad44dfe643f..73da72170a043 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java index aa86eaf4ffcdc..41e408d2dde6f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/QueueContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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/QueueService.java index a610b75007065..b60aacd417907 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/QueueService.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java index 93c3aa98203c4..93771ce03de9e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueue.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java index 8971ba9120323..0ca46aaf25bc3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java index 66f7328e35a0c..496002375947a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/CloudQueueMessage.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java index 83409abb03f2b..2d0d4c0d3b97f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/ListQueuesResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java index 4e2efb1d3d6b9..d01b1cf268635 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/MessageUpdateFields.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueAccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueAccessPolicyResponse.java index 457113684d9d1..3c3a7d56dae9f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueAccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueAccessPolicyResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java index 4f9bc6438af8e..d82fb09e4d05c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueConstants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java index 0bee5eaa15fca..22c01e64a4926 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueDeserializationHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java index 6f7064e0ee532..0a17cda55bc1f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueListingDetails.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java index dd96957596cc0..6712d9e62e946 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueMessageType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueuePermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueuePermissions.java index 35649a0fdf364..958968cb0b912 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueuePermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueuePermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,4 +55,4 @@ public HashMap<String, SharedAccessQueuePolicy> getSharedAccessPolicies() { public void setSharedAccessPolicies(final HashMap<String, SharedAccessQueuePolicy> sharedAccessPolicies) { this.sharedAccessPolicies = sharedAccessPolicies; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java index cf0c6316a0c60..c00315de54436 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java index d4291a35160de..7df4d6a48b49d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueRequestOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java index 281e7760df300..05f041690d98e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/QueueResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePermissions.java index 10daa8af1f721..6ab135fd8c98a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java index 6e952ae00a424..cd6b9085b4de7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/client/SharedAccessQueuePolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java index 751cac8338b8a..c1ef1e075d19c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index cffc724549ac4..aaaef3576e141 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java index 5816a1bec264d..4b038a023b20d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/QueueRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java index 3707a3f119118..da9a6d15658a2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/implementation/SharedKeyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 351d6ed8f62f6..bd1cecd8aec2c 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java index 1ce3ba2a191b9..6dd5941aed8b1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateMessageOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java index 81ff8debedf30..d9ea78c12d6e9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/CreateQueueOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java index b522a7c589e90..a6d69b660306e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/GetQueueMetadataResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 index 4dff09479acf2..0ee5567e9a71f 100644 --- 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java index 0fb34021981c2..ffb13754185b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/ListMessagesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 facfb73283440..04f85095706dc 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,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 7d4d346570b82..d3a6b30b47661 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,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 144dddada23c2..22b92b40444b2 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,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java index eff229bf1657c..50fbe5ab288e3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/PeekMessagesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 602f2bee8e8c9..34fc7f725ffaf 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,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java index 9f22a1f5fa1bc..a0836fa64f091 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/QueueServiceOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 a914ac2279975..e83c9ff5bf044 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java index 7c81179931e43..b75fa54659d44 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/queue/models/UpdateMessageResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java index 053d3b7fcff51..b335a9f9106f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java index 24592204de197..87202a8b22542 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java index 4459ba1308d82..6d6d373b11048 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java index e7d12cf2dd06b..b36011b789033 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusService.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java index f2d6ce0404bec..026cb9c517718 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/Util.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java index 0ccbc406d66ae..2db84273def96 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index e7892b7116f83..5a8dda45f9bae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index 1dd76f10af730..a12fbb4ee8199 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java index 2edab43e9419d..71f11d9e6e463 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java index 46b47db0d93ce..04ba3dce58b9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/EntryModelProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java index 728e70dc4273c..d0f454a255179 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java index 7654604e20fd1..fbda9c3f7f5e1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/MarshallerProvider.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java index 5af2ccf6f6df1..2cf8396485af1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/NamespacePrefixMapperImpl.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java index e29297bbb22c0..567ae5cedd0b6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java index 7fc710b76d00a..b2007513afb2f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/ServiceBusRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java index 9732c0741c571..ee6e919010cf8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapAccessTokenResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java index 8514686db4329..2e8389774679d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java index 5758ac151d004..ac3c15b3a7d08 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java index d73638329561d..ec124f718c2a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java index 48e28220249a2..407b839ddbb81 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManager.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java index b7695de3aa72c..5970d10fc96f7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/AbstractListOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index 7f7e5caac0175..a2518f45afd97 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java index bf617d161f245..8b0a7eceb6c7d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateQueueResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java index 4477a1a242d27..bc72c6da29025 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateRuleResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java index 477e1abb50e31..1580bc79005a8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateSubscriptionResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java index 91c5f30d20e84..8c0baaca9afeb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/CreateTopicResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java index 9e3e5da19a070..0fff663cc9653 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetQueueResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java index 222ae08d8463b..c940040fc064e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetRuleResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java index 4649f6f2e4b03..ff8f5ee9e471f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetSubscriptionResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java index d546630c39b52..2254759074403 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/GetTopicResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java index db1d3a1d41c13..71e71a3ff767b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java index c06b5b3e27341..b7c72147b1f15 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListQueuesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java index 5ba5ed561814e..0e7beca7478ca 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java index b12c3e65bb88a..3b08d444b95d4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListRulesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java index 472b25a35e6e9..c9c2efbbedb70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java index 4b6c6cc5fbe86..14dbbff145451 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListSubscriptionsResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java index 54ffa6f364d55..9363c7a902664 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java index b5539a870055b..e43a27ccd8143 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ListTopicsResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java index 65e08b395acd8..676cb1bfd3181 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/QueueInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java index 4e7ffcd2328d1..3e304ad343306 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java index e9ca05b07570d..7c092119e52f2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMessageResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java index 99c7e3e02d394..67e2f3bfc9c3c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveMode.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java index 46a0c4a1ac5ca..5a5185491d4cd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveQueueMessageResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java index 0436a5a873f16..4d32488b6e399 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/ReceiveSubscriptionMessageResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java index 7889fdc900a35..c5e862bbc1df3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/RuleInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java index e8490870583c2..fd65bedd66b7c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java index 76ac97d68196f..d53474146682a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/TopicInfo.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/EdmValueConverter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/EdmValueConverter.java index 48b0859ba92f5..0f96ce3852eb5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/EdmValueConverter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/EdmValueConverter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java index ad0334ab03de4..39fea9c07eb1b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableConfiguration.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableConfiguration.java index 5d0d696061d10..b516e80d4128f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableConfiguration.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableContract.java index e4a448f0f7ff6..e752d667d0346 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableContract.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableService.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableService.java index 51bf07c43bd3f..71c95a11ea971 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableService.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/TableService.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/AtomPubParser.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/AtomPubParser.java index c258badfc3ff2..8ea633c39a869 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/AtomPubParser.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/AtomPubParser.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java index 6fe819975c215..536b3adfb5821 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTable.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java index 4420c2d375180..e49f6e3fdfca6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/CloudTableClient.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/DynamicTableEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/DynamicTableEntity.java index cfe58e086f67e..e4d8afccca744 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/DynamicTableEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/DynamicTableEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EdmType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EdmType.java index bf246941e4ce5..44e8d7d8ab6fd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EdmType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EdmType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityProperty.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityProperty.java index b449c874abb87..5c166251b561f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityProperty.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityProperty.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityResolver.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityResolver.java index 1f7d95d3a812a..013e0cdd1da7b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityResolver.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/EntityResolver.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/Ignore.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/Ignore.java index 53653dc951505..d014927db13b3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/Ignore.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/Ignore.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHeader.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHeader.java index bffc95cdd4276..65b3bed132e70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHeader.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHeader.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHelper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHelper.java index 143a4022e3740..53c5e1f605805 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHelper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimeHelper.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimePart.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimePart.java index 254581502e2b8..b8751b5e23fab 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimePart.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/MimePart.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataConstants.java index ed89049797d11..e2dfc5d373752 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataConstants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataPayload.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataPayload.java index 9f0f5c573becb..9fbf3cb0a0626 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataPayload.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/ODataPayload.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/PropertyPair.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/PropertyPair.java index 24da5f2adc585..aed9941b8c8f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/PropertyPair.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/PropertyPair.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java index a79824446fc29..bc5c112c31876 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/QueryTableOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePermissions.java index 649f4208e6f19..6ed1e001e94dc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java index d5fc4c780104a..fbeb55dae5be7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/SharedAccessTablePolicy.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/StoreAs.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/StoreAs.java index 7918530c85f34..1f80c27122fdc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/StoreAs.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/StoreAs.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableAccessPolicyResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableAccessPolicyResponse.java index 3333e2b3c54f1..31b35dc81bf29 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableAccessPolicyResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableAccessPolicyResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java index 162edd2bdab23..4f81296856b6f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableBatchOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableConstants.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableConstants.java index 48d3f3d56ea09..2822c5e47856e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableConstants.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableConstants.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableEntity.java index 85dc20a8c37bf..702a42bb86f9c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java index 3bffd84a306b6..130d59fe9914d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperation.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperationType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperationType.java index a1ceccabd3320..ccfd867a98085 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperationType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableOperationType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TablePermissions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TablePermissions.java index d981a820d6b42..15b9ad5d3f118 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TablePermissions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TablePermissions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,4 +56,4 @@ public HashMap<String, SharedAccessTablePolicy> getSharedAccessPolicies() { public void setSharedAccessPolicies(final HashMap<String, SharedAccessTablePolicy> sharedAccessPolicies) { this.sharedAccessPolicies = sharedAccessPolicies; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java index 90a9bfa3501d3..6b5e126951015 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableQuery.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequest.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequest.java index 782aa98ef84e7..171d8cbc254fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequest.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequestOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequestOptions.java index 1a4d210526f20..030eee752beec 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequestOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableRequestOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResponse.java index 848e7b2afc0bc..6f2d7d9c8d861 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResponse.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResult.java index 95e0621b63ed9..6ede801908f5b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceEntity.java index 04f26b84a3002..fe8efb7ec1f76 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceEntity.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceException.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceException.java index 04f065a4407df..494a304abcc4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceException.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableServiceException.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableUpdateType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableUpdateType.java index 3fbf519729c44..94e63a882be3f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableUpdateType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/client/TableUpdateType.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriter.java index 4691215478308..01fbab3a870f4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java index d35293670c1b8..8d1aff2334cb4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultXMLStreamFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultXMLStreamFactory.java index 6202250942d4f..9447472f8cb2a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultXMLStreamFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultXMLStreamFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java index 347538853151a..48f4b40d85309 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/InputStreamDataSource.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/InputStreamDataSource.java index a15d80844155d..02c5fd31bb477 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/InputStreamDataSource.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/InputStreamDataSource.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,4 +49,4 @@ public String getName() { public OutputStream getOutputStream() throws IOException { return null; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/MimeReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/MimeReaderWriter.java index 30aa13ec6bfe8..efcc33f78b2cc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/MimeReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/MimeReaderWriter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java index 7e2e95bb88f9a..d14843554216f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyLiteFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyLiteFilter.java index 6f9990616a822..cc048c5c8d3d2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyLiteFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/SharedKeyLiteFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableExceptionProcessor.java index 29e8bd6dd8129..3642189a8168f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableExceptionProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java index 7da2c6a1b4905..72379bb2582bd 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/TableRestProxy.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/XMLStreamFactory.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/XMLStreamFactory.java index 064becc8b8650..cd61e66a59771 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/XMLStreamFactory.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/XMLStreamFactory.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchOperations.java index f59811f33f6f1..849d69c28e537 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchOperations.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchResult.java index 47496057fb25e..288ced7d29875 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BatchResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BinaryFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BinaryFilter.java index 96a1a6a71b570..b5502542ffc1e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BinaryFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/BinaryFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ConstantFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ConstantFilter.java index 888901e840417..ee90440d312fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ConstantFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ConstantFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/DeleteEntityOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/DeleteEntityOptions.java index 2be63a3d9e6bb..846407dd9fb74 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/DeleteEntityOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/DeleteEntityOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/EdmType.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/EdmType.java index a104fdc549e5e..153d0bc035ddb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/EdmType.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/EdmType.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,4 +131,4 @@ public class EdmType { * <strong>Edm.String</strong> Represents fixed- or variable-length character data. */ public static final String STRING = "Edm.String"; -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Entity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Entity.java index 8377a645fa8c5..94fd36448c257 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Entity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Entity.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Filter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Filter.java index 612c8c40d0270..b8aecc0f87099 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Filter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Filter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetEntityResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetEntityResult.java index 982a8d55b028c..c2326aa379050 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetEntityResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetEntityResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetServicePropertiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetServicePropertiesResult.java index 7f4780fd3c156..2f374d787d1ed 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetServicePropertiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetServicePropertiesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetTableResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetTableResult.java index a5f3e843966ba..59e7eaee303d0 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetTableResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/GetTableResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/InsertEntityResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/InsertEntityResult.java index 1c786f9b4b084..e6fcf6b0202e7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/InsertEntityResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/InsertEntityResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Property.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Property.java index 19b7492ec5c94..1f54bf907681d 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Property.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/Property.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,4 +138,4 @@ public Property setValue(Object value) { this.value = value; return this; } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/PropertyNameFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/PropertyNameFilter.java index 9594b838e74e6..c31b1552a2bbb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/PropertyNameFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/PropertyNameFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesOptions.java index fcc04a34d5104..71d6442a1a531 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesResult.java index 6d050f96843d1..b58f2eeccdda6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryEntitiesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryStringFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryStringFilter.java index 84db88c276ae4..0238b57d083f1 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryStringFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryStringFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java index e7c89aeb759ef..e553a15bb8d33 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesResult.java index 3cfa1768ea814..4937d830a3515 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/QueryTablesResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ServiceProperties.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ServiceProperties.java index 6f8a4f11c0c0b..bc09dbce91b1f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ServiceProperties.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/ServiceProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableEntry.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableEntry.java index cc65eff4e1d40..f166b04166284 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableEntry.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableEntry.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableServiceOptions.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableServiceOptions.java index 0eb1b91b27aa3..55d2d818dca1f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableServiceOptions.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/TableServiceOptions.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UnaryFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UnaryFilter.java index 190437d27b530..d01cedea3512c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UnaryFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UnaryFilter.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UpdateEntityResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UpdateEntityResult.java index 53dc66738944e..d8496a35f70b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UpdateEntityResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/models/UpdateEntityResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java index 2fa253cd5fc8c..4c208fd7932b2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/AlterClassWithProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java index bab655d1c9a74..9ba40b3f15043 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorMultipleInject.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java index 9522d97ad251f..e0568c1a118ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithMultipleCtorNoInject.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java index cef547f4078c4..329ef2977c421 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithNamedParameter.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java index 2c2005676163f..acb256a9aa9ba 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithProperties.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java index 19ed61a0a021a..82dc255982b55 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/ClassWithSingleCtorNoInject.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java index 6646276997378..0b164cd91178b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/configuration/builder/DefaultBuilderTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java index 12f9656c17550..25f95aa4759fa 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/FileInputChannelTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java index 804022b81da6f..2cf8df32691ff 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/MockInputChannel.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java index b18feab92e441..27979f239fc3b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeCurrentStateClientTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java index c460f04cc62bb..42f4d4acab31f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/Protocol1RuntimeGoalStateClientTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java index 3ebd677771ca0..5e34f5d49e85c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RoleEnvironmentTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java index 2e8c72b0beda1..da58a7bd1e25b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/RuntimeVersionManagerTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java index 4222faf05b1fd..8fafbe9ef8fad 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/serviceruntime/XmlGoalStateDeserializerTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 d1fbb29871d6b..01040883db402 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java index 4275e212fb8c0..fc7b2c07ac808 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/IntegrationTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java index 938db64c06d4a..81ac9334d8dc3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/BlobTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index d7602c93d75bc..d7af93771feb5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverterTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverterTests.java index c69d18d8f1ebb..669b1a29fb88d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverterTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/implementation/ISO8601DateConverterTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java index b81a19e8d27ff..82963a885e9cc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/IdempotentClientFilterTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpersTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpersTest.java index 670b3e7ae0a23..39ecf8029822b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpersTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/core/utils/pipeline/PipelineHelpersTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 a854804bde36d..d682fd2f3fba1 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. 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 db8ca0f130c1e..0380a7be8942e 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 @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java index 68c238dcc9539..b3c266fac5aed 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueClientTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java index b107e30527419..d97bb4bdc7b45 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/CloudQueueTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java index 8144378d8577b..ead279ce3dbdb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/queue/client/QueueTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 2491a44ceda37..b7b29be4f5fef 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 56c20a7ec6d26..0e4587cbe77c3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 0ad9ea9fa68b7..a94c44a3d7f29 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -397,4 +397,4 @@ public void removeAllAccessPoliciesWithPrefix() throws ServiceException { } } } -} \ No newline at end of file +} diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java index 6875d11095297..ee4c89e662704 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/ScenarioTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java index 0efb1b72e03dd..cef5f5f3b42b4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/BrokerPropertiesMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java index 13956e3de931a..1d57ed6fbb814 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/IntegrationTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java index 70c3f97963a02..2bffd260cf64a 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusConfigurationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java index ca6c0ebed64e6..9cc4d707c900e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusCreationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java index 9a53628503e4f..bd86d9b7abf9f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/ServiceBusIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index 6366937c63bf9..2ab3572c34db7 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java index 154ab259ff2cf..016de94febc64 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapRestProxyIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java index 1b49d7af47656..3eb2fd952a7a4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java index 58536f5a41a76..11d2abfbd9bdd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/WrapTokenManagerTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/IntegrationTestBase.java index 8b7b18382d59d..94030b5188cfc 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/IntegrationTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java index 74fdd4d911499..485c239890a33 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/TableServiceIntegrationTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableBatchOperationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableBatchOperationTests.java index cab99fc44c303..55c230921a3f8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableBatchOperationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableBatchOperationTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java index bbb63de1d514f..3f9bf6fa9a757 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableClientTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableEscapingTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableEscapingTests.java index 3926fd49aea6d..c09011a908258 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableEscapingTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableEscapingTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java index 10a6b4734e3a0..3421fcbe2b6f2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableOperationTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java index 75740c9fff23f..7bec262714c07 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableQueryTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableSerializerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableSerializerTests.java index e3d19000d7481..9370879504af6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableSerializerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableSerializerTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java index 7ba57b75322c8..b5c68c6df8765 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/client/TableTestBase.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java index aa14a71f8597c..17578984f68c5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/MimeMultipartTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/MimeMultipartTests.java index c01fdeaebc3cf..13f20b528b5b0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/MimeMultipartTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/MimeMultipartTests.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java index 54c5b84aab75a..6245cedfce676 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/utils/ServiceExceptionFactoryTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2011 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 2330429aacd353ef1a02c1cab6f230a9330d9b3e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 12:42:19 -0800 Subject: [PATCH 637/664] Restructure try-catches to have only one catch. --- .../media/implementation/StatusLine.java | 35 ++++++++----------- .../implementation/HttpReaderWriter.java | 34 +++++++----------- 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index 749166fe21ace..094a2a2db1b16 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -32,34 +32,27 @@ public static StatusLine create(DataSource dataSource) { InputStream inputStream; try { inputStream = dataSource.getInputStream(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - LineInputStream stream = new LineInputStream(inputStream); - try { - String line = stream.readLine(); - StringReader lineReader = new StringReader(line); + LineInputStream stream = new LineInputStream(inputStream); + try { + String line = stream.readLine(); + StringReader lineReader = new StringReader(line); - expect(lineReader, "HTTP/1.1"); - expect(lineReader, " "); - String statusString = extractInput(lineReader, ' '); - String reason = extractInput(lineReader, -1); + expect(lineReader, "HTTP/1.1"); + expect(lineReader, " "); + String statusString = extractInput(lineReader, ' '); + String reason = extractInput(lineReader, -1); - return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); + return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); + } + finally { + stream.close(); + } } catch (IOException e) { throw new RuntimeException(e); } - finally { - try { - stream.close(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } + } private static void expect(Reader reader, String string) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java index 63b5b07d611a3..905f3565519df 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java @@ -41,35 +41,27 @@ public StatusLine parseStatusLine(DataSource ds) { InputStream inputStream; try { inputStream = ds.getInputStream(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - LineInputStream stream = new LineInputStream(inputStream); + LineInputStream stream = new LineInputStream(inputStream); - try { - String line = stream.readLine(); - StringReader lineReader = new StringReader(line); + try { + String line = stream.readLine(); + StringReader lineReader = new StringReader(line); - expect(lineReader, "HTTP/1.1"); - expect(lineReader, " "); - String statusString = extractInput(lineReader, ' '); - String reason = extractInput(lineReader, -1); + expect(lineReader, "HTTP/1.1"); + expect(lineReader, " "); + String statusString = extractInput(lineReader, ' '); + String reason = extractInput(lineReader, -1); - return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); + return new StatusLine().setStatus(Integer.parseInt(statusString)).setReason(reason); + } + finally { + stream.close(); + } } catch (IOException e) { throw new RuntimeException(e); } - finally { - try { - stream.close(); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } } public InternetHeaders parseHeaders(DataSource ds) { From c31e52e4a73783253b1058feae171c8bb9fcdfb1 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 12:46:27 -0800 Subject: [PATCH 638/664] Reverting some now unneeded changes --- .../services/media/implementation/StatusLine.java | 7 +------ .../services/table/implementation/HttpReaderWriter.java | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java index 094a2a2db1b16..65492834d6e3e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/StatusLine.java @@ -16,7 +16,6 @@ package com.microsoft.windowsazure.services.media.implementation; import java.io.IOException; -import java.io.InputStream; import java.io.Reader; import java.io.StringReader; @@ -29,11 +28,8 @@ public class StatusLine { private String reason; public static StatusLine create(DataSource dataSource) { - InputStream inputStream; try { - inputStream = dataSource.getInputStream(); - - LineInputStream stream = new LineInputStream(inputStream); + LineInputStream stream = new LineInputStream(dataSource.getInputStream()); try { String line = stream.readLine(); StringReader lineReader = new StringReader(line); @@ -52,7 +48,6 @@ public static StatusLine create(DataSource dataSource) { catch (IOException e) { throw new RuntimeException(e); } - } private static void expect(Reader reader, String string) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java index 905f3565519df..81f1f1c9bee18 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/HttpReaderWriter.java @@ -38,12 +38,8 @@ public HttpReaderWriter() { } public StatusLine parseStatusLine(DataSource ds) { - InputStream inputStream; try { - inputStream = ds.getInputStream(); - - LineInputStream stream = new LineInputStream(inputStream); - + LineInputStream stream = new LineInputStream(ds.getInputStream()); try { String line = stream.readLine(); StringReader lineReader = new StringReader(line); From 5b1f1042b2f680f447f4f05e28e472cf788905a0 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 13:09:00 -0800 Subject: [PATCH 639/664] update remove date from pom file. --- microsoft-azure-api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index b2a77405955dd..6953b1d4dfcfb 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -1,5 +1,5 @@ <!-- - Copyright 2011 Microsoft Corporation + Copyright Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From c66d567112478f509105561c4cc6b55cbcee5186 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Wed, 9 Jan 2013 14:03:17 -0800 Subject: [PATCH 640/664] Code review feedback. Removed todo, removed getLinks method. --- .../media/implementation/ODataEntity.java | 19 ------------------- .../services/media/models/AssetInfo.java | 3 +-- .../implementation/LinkRetrievalTest.java | 11 ----------- 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java index 4223758765747..c9baeda483d50 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ODataEntity.java @@ -17,8 +17,6 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; import javax.xml.bind.JAXBElement; @@ -110,23 +108,6 @@ public <U extends ODataEntity<?>> LinkInfo<U> getRelationLink(String relationNam return this.<U> getLink(Constants.ODATA_DATA_NS + "/related/" + relationName); } - /** - * Return the links from this entry - * - * @return List of the links. - */ - @SuppressWarnings("rawtypes") - public List<LinkInfo> getLinks() { - ArrayList<LinkInfo> links = new ArrayList<LinkInfo>(); - for (Object child : entry.getEntryChildren()) { - LinkType link = LinkFromChild(child); - if (link != null) { - links.add(new LinkInfo(link)); - } - } - return links; - } - @SuppressWarnings("rawtypes") private static LinkType LinkFromChild(Object child) { if (child instanceof JAXBElement) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java index 549ad8e6cb85b..36eb15fdddd09 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java @@ -130,12 +130,11 @@ public LinkInfo<LocatorInfo> getLocatorsLink() { } /** - * Get a link to the asset's locators + * Get a link to this asset's parents * * @return the link */ public LinkInfo<AssetInfo> getParentAssetsLink() { - // TODO: NEEDS TESTS once we figure out how to create assets with parents return this.<AssetInfo> getRelationLink("ParentAssets"); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 6b050376bc04c..a4674c9438f58 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -17,8 +17,6 @@ import static org.junit.Assert.*; -import java.util.List; - import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -96,15 +94,6 @@ public void getNullWhenLinkIsntThere() { assertNull(info.getLink("noSuchLink")); } - @Test - public void getLinksReturnsTwoExpectedLinksInOrder() { - List<LinkInfo> links = info.getLinks(); - - assertEquals(2, links.size()); - assertLinksEqual(link1, links.get(0)); - assertLinksEqual(link2, links.get(1)); - } - private static void assertLinksEqual(LinkType expected, LinkInfo actual) { assertEquals(expected.getHref(), actual.getHref()); } From f5c36ad1abfa6d75b98bafbfc80643ba49424707 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Wed, 9 Jan 2013 15:43:59 -0800 Subject: [PATCH 641/664] update tests for linkinfo --- .../windowsazure/services/media/AssetIntegrationTest.java | 2 +- .../services/media/EncryptionIntegrationTest.java | 7 +++---- .../windowsazure/services/media/JobIntegrationTest.java | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index f4008661a5992..7d3ac22c8d09c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -349,7 +349,7 @@ public void canGetParentBackFromAsset() throws ServiceException, InterruptedExce assertEquals(1, outputAssets.size()); AssetInfo childAsset = outputAssets.get(0); - LinkInfo parentAssetLink = childAsset.getParentAssetsLink(); + LinkInfo<AssetInfo> parentAssetLink = childAsset.getParentAssetsLink(); AssetInfo parentAsset = service.get(Asset.get(parentAssetLink)); // Assert diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 3b71c7d8e0210..7713b82f1cb9e 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -96,7 +96,7 @@ public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { JobInfo jobInfo = decodeAsset("uploadAesProtectedAssetSuccess", assetInfo.getId()); // assert - LinkInfo taskLinkInfo = jobInfo.getTasksLink(); + LinkInfo<TaskInfo> taskLinkInfo = jobInfo.getTasksLink(); List<TaskInfo> taskInfos = service.list(Task.list(taskLinkInfo)); for (TaskInfo taskInfo : taskInfos) { assertEquals(TaskState.Completed, taskInfo.getState()); @@ -139,9 +139,8 @@ private JobInfo decodeAsset(String name, String inputAssetId) throws ServiceExce } private String makeContentKeyId(byte[] aesKey) throws ServiceException, Exception { - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); - String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); String contentKeyIdUuid = UUID.randomUUID().toString(); String contentKeyId = String.format("nb:kid:UUID:%s", contentKeyIdUuid); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 59d16612acbf5..486647a56874d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -67,7 +67,7 @@ private void verifyJobProperties(String message, String testName, Integer priori assertDateApproxEquals(message + " EndTime", endTime, actualJob.getEndTime()); if (expectedTaskCount != null) { - LinkInfo tasksLink = actualJob.getTasksLink(); + LinkInfo<TaskInfo> tasksLink = actualJob.getTasksLink(); ListResult<TaskInfo> actualTasks = service.list(Task.list(tasksLink)); assertEquals(message + " tasks size", expectedTaskCount.intValue(), actualTasks.size()); } From 81c583168c6c4ceedd2846f76289d0771809d596 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 17:02:22 -0800 Subject: [PATCH 642/664] Remove unneeded casts to string from action See #577 --- .../services/media/ProtectionKeyIntegrationTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java index 972c11f6f20d4..7749249e66a88 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/ProtectionKeyIntegrationTest.java @@ -30,8 +30,7 @@ public void canGetProtectionKeyId() throws ServiceException { // Arrange // Act - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.CommonEncryption)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.CommonEncryption)); // Assert assertNotNull(protectionKeyId); @@ -40,11 +39,10 @@ public void canGetProtectionKeyId() throws ServiceException { @Test public void canGetProtectionKey() throws ServiceException { // Arrange - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.CommonEncryption)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.CommonEncryption)); // Act - String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); // Assert assertNotNull(protectionKey); From 11e5830f126b75fa2108dbcac182b05e9afd1a43 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 17:03:08 -0800 Subject: [PATCH 643/664] Fix test warnings Related to the fix for #561 --- .../services/media/implementation/LinkRetrievalTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java index 6921efde0edee..6e8c9e0483277 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/implementation/LinkRetrievalTest.java @@ -84,7 +84,7 @@ public void getFalseWhenLinkIsntThere() { @Test public void canRetrieveEntireLinkByRel() { - LinkInfo link = info.getLink(link2.getRel()); + LinkInfo<?> link = info.getLink(link2.getRel()); assertLinksEqual(link2, link); } @@ -94,7 +94,7 @@ public void getNullWhenLinkIsntThere() { assertNull(info.getLink("noSuchLink")); } - private static void assertLinksEqual(LinkType expected, LinkInfo actual) { + private static void assertLinksEqual(LinkType expected, LinkInfo<?> actual) { assertEquals(expected.getHref(), actual.getHref()); } } From 97fe6534525502482b44584da267261ba28201c5 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 8 Jan 2013 22:59:03 -0800 Subject: [PATCH 644/664] Fix TODOs in scenario tests. * Verify the tasks in a job * Set task options Remove spurious `println`s in tests Make scenario tests that wait for jobs to complete to wait for 30 iterations (like the other tests), instead of 10 iterations. Copy and refactor some parts of the encryption tests, to validate that `AssetFile`s can propertly store encryption information --- .../media/EncryptionIntegrationTest.java | 2 +- .../scenarios/MediaServiceScenarioTest.java | 43 ++++++ .../scenarios/MediaServiceValidation.java | 76 +++++++--- .../scenarios/MediaServiceWrapper.java | 142 ++++++++++++++++-- 4 files changed, 228 insertions(+), 35 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 7713b82f1cb9e..3a84c0267d122 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -130,7 +130,7 @@ private JobInfo decodeAsset(String name, String inputAssetId) throws ServiceExce JobInfo currentJobInfo = jobInfo; int retryCounter = 0; - while (currentJobInfo.getState().getCode() < 3 && retryCounter < 10) { + while (currentJobInfo.getState().getCode() < 3 && retryCounter < 30) { Thread.sleep(10000); currentJobInfo = service.get(Job.get(jobInfo.getId())); retryCounter++; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index b7b29be4f5fef..f8c09011438fd 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Random; import java.util.UUID; import org.junit.AfterClass; @@ -88,6 +89,20 @@ public void uploadFiles() throws Exception { validator.validateAssetFiles(asset, getTestAssetFiles()); } + @Test + public void uploadEncryptedFiles() throws Exception { + signalSetupStarting(); + // Media Services requires 256-bit (32-byte) keys for AES encryption. + Random random = new Random(); + byte[] aesKey = new byte[32]; + random.nextBytes(aesKey); + AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadEncryptedFiles", AssetOption.StorageEncrypted); + signalSetupFinished(); + + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); + validator.validateAssetFiles(asset, getTestAssetFiles()); + } + @Test public void downloadFiles() throws Exception { signalSetupStarting(); @@ -125,6 +140,34 @@ public void transformAsset() throws Exception { validator.validateOutputAssets(outputAssets, getTestAssetFiles().keys()); } + @Test + public void transformEncryptedAsset() throws Exception { + signalSetupStarting(); + // Media Services requires 256-bit (32-byte) keys for AES encryption. + Random random = new Random(); + byte[] aesKey = new byte[32]; + random.nextBytes(aesKey); + AssetInfo asset = wrapper + .createAsset(testAssetPrefix + "transformEncryptedAsset", AssetOption.StorageEncrypted); + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); + String jobName = "my job transformEncryptedAsset" + UUID.randomUUID().toString(); + JobInfo job = wrapper.createJob(jobName, asset, wrapper.createTaskOptionsDecodeAsset("Decode", 0, 0)); + signalSetupFinished(); + + waitForJobToFinish(job); + List<AssetInfo> outputAssets = wrapper.getJobOutputMediaAssets(job); + validator.validateOutputAssets(outputAssets, getTestAssetFiles().keys()); + + // Verify output asset files. + assertEquals("output assets count", 1, outputAssets.size()); + AssetInfo outputAsset = outputAssets.get(0); + validator.validateAssetFiles(outputAsset, getTestAssetFiles()); + + // Verify assets were decoded. + List<URL> fileUrls = wrapper.createFileURLsFromAsset(outputAsset, 10); + validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); + } + private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { for (int counter = 0; !wrapper.isJobFinished(job); counter++) { if (counter > 30) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 0e4587cbe77c3..4b814761e7a58 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -35,6 +35,8 @@ import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetOption; import com.microsoft.windowsazure.services.media.models.AssetState; +import com.microsoft.windowsazure.services.media.models.ContentKey; +import com.microsoft.windowsazure.services.media.models.ContentKeyInfo; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; @@ -96,15 +98,30 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i assertNotNull("assetFiles", assetFiles); assertEquals("assetFiles.size", inputFiles.size(), assetFiles.size()); - // More general verifications: - // * Verify that the asset count on the server increments for each asset added. - // * Verify that the file count on the server increments for each file added. - // * Verify that can query the server for assets matching - // * The created asset ID, and get only that one item - // * The created asset name, get only that one. - // * If Encrypted, verify file and content key - // * Get the asset encryption info and compare with the file's encryption info - // * Compare these properties: IsEncrypted, InitializationVector, EncryptionKeyId, EncryptionScheme, EncryptionVersion + ContentKeyInfo contentKey = null; + if (asset.getOptions() == AssetOption.StorageEncrypted) { + ListResult<ContentKeyInfo> contentKeys = service.list(ContentKey.list(asset.getContentKeysLink())); + assertEquals("contentKeys size", 1, contentKeys.size()); + contentKey = contentKeys.get(0); + } + + // Compare encryption info for asset files + for (AssetFileInfo assetFile : assetFiles) { + if (asset.getOptions() == AssetOption.StorageEncrypted) { + assertEquals("assetFile.getIsEncrypted", true, assetFile.getIsEncrypted()); + assertEquals("assetFile.getEncryptionKeyId", contentKey.getId(), assetFile.getEncryptionKeyId()); + assertNotNullOrEmpty("assetFile.getEncryptionScheme", assetFile.getEncryptionScheme()); + assertNotNullOrEmpty("assetFile.getEncryptionVersion", assetFile.getEncryptionVersion()); + assertNotNullOrEmpty("assetFile.getInitializationVector", assetFile.getInitializationVector()); + } + else { + assertEquals("assetFile.getIsEncrypted", false, assetFile.getIsEncrypted()); + assertNullOrEmpty("assetFile.getEncryptionKeyId", assetFile.getEncryptionKeyId()); + assertNullOrEmpty("assetFile.getEncryptionScheme", assetFile.getEncryptionScheme()); + assertNullOrEmpty("assetFile.getEncryptionVersion", assetFile.getEncryptionVersion()); + assertNullOrEmpty("assetFile.getInitializationVector", assetFile.getInitializationVector()); + } + } // Compare the asset files with all files List<AssetFileInfo> allFiles = service.list(AssetFile.list()); @@ -132,26 +149,24 @@ public void validateAssetFileUrls(List<URL> fileUrls, Hashtable<String, InputStr } } - public void validateJob(JobInfo job, String name, AssetInfo asset, List<Task.CreateBatchOperation> createTasks) { + public void validateJob(JobInfo job, String name, AssetInfo asset, List<Task.CreateBatchOperation> createTasks) + throws ServiceException { assertDateApproxEquals("getEndTime", new Date(), job.getCreated()); assertEquals("job.getName", name, job.getName()); - // TODO: Uncomment when fixed: - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/508 - // List<String> inputAssets = job.getInputMediaAssets(); - // assertNotNull("inputAssets", inputAssets); - // assertEquals("inputAssets.size()", 1, inputAssets.size()); - // assertEquals("inputAssets.get(0)", asset.getId(), inputAssets.get(0)); - // - // List<String> outputAssets = job.getOutputMediaAssets(); - // assertNotNull("outputAssets", outputAssets); - // assertEquals("outputAssets.size()", createTasks.size(), outputAssets.size()); + List<AssetInfo> inputAssets = service.list(Asset.list(job.getInputAssetsLink())); + assertNotNull("inputAssets", inputAssets); + assertEquals("inputAssets.size()", 1, inputAssets.size()); + assertEquals("inputAssets.get(0)", asset.getId(), inputAssets.get(0).getId()); + + List<AssetInfo> outputAssets = service.list(Asset.list(job.getOutputAssetsLink())); + assertNotNull("outputAssets", outputAssets); + assertEquals("outputAssets.size()", createTasks.size(), outputAssets.size()); } public void validateOutputAssets(List<AssetInfo> outputAssets, Enumeration<String> enumeration) { assertNotNull("outputAssets", outputAssets); for (AssetInfo asset : outputAssets) { - assertNotNull("asset", asset); assertNotNull("asset.getId", asset.getId()); assertFalse("asset.getId != ''", "".equals(asset.getId())); @@ -239,4 +254,23 @@ private void assertStreamsEqual(InputStream inputStream1, InputStream inputStrea inputStream2.close(); } } + + private void assertNullOrEmpty(String message, String actual) { + if (actual == null) { + assertNull(message, actual); + } + else { + assertEquals(message, "", actual); + } + } + + private void assertNotNullOrEmpty(String message, String actual) { + if (actual == null) { + assertNotNull(message, actual); + } + else { + assertTrue(message + ": expect " + actual + " to be null or empty", actual.length() > 0); + } + } + } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index a94c44a3d7f29..506f1febec22d 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -15,17 +15,29 @@ package com.microsoft.windowsazure.services.scenarios; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; import java.security.DigestInputStream; +import java.security.Key; import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; import java.util.ArrayList; import java.util.EnumSet; import java.util.Hashtable; import java.util.List; +import java.util.Random; +import java.util.UUID; + +import javax.crypto.Cipher; +import javax.crypto.CipherInputStream; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; @@ -38,9 +50,12 @@ import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; import com.microsoft.windowsazure.services.media.models.Asset; import com.microsoft.windowsazure.services.media.models.AssetFile; +import com.microsoft.windowsazure.services.media.models.AssetFile.Updater; import com.microsoft.windowsazure.services.media.models.AssetFileInfo; import com.microsoft.windowsazure.services.media.models.AssetInfo; import com.microsoft.windowsazure.services.media.models.AssetOption; +import com.microsoft.windowsazure.services.media.models.ContentKey; +import com.microsoft.windowsazure.services.media.models.ContentKeyType; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.Job.Creator; import com.microsoft.windowsazure.services.media.models.JobInfo; @@ -50,14 +65,16 @@ import com.microsoft.windowsazure.services.media.models.LocatorType; import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; +import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.media.models.TaskOption; class MediaServiceWrapper { private final MediaContract service; private static final String accessPolicyPrefix = "scenarioTestPrefix"; - // private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption"; + private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption"; private final String MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER = "Windows Azure Media Encoder"; private final String MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS = "MP4 to Smooth Streams Task"; private final String MEDIA_PROCESSOR_PLAYREADY_PROTECTION = "PlayReady Protection Task"; @@ -131,20 +148,65 @@ public List<ListResult<AssetInfo>> getAssetSortedPagedResults(String rootName, i // Ingest public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hashtable<String, InputStream> inputFiles) - throws ServiceException, IOException, NoSuchAlgorithmException { + throws Exception { + uploadFilesToAsset(asset, uploadWindowInMinutes, inputFiles, null); + } + + public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, + Hashtable<String, InputStream> inputFiles, byte[] aesKey) throws Exception { AccessPolicyInfo accessPolicy = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); LocatorInfo locator = service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS)); + String contentKeyId = null; + if (aesKey != null) { + String protectionKeyId = (String) service.action(ProtectionKey + .getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + + String contentKeyIdUuid = UUID.randomUUID().toString(); + contentKeyId = "nb:kid:UUID:" + contentKeyIdUuid; + + byte[] encryptedContentKey = EncryptionHelper.encryptSymmetricKey(protectionKey, aesKey); + String encryptedContentKeyString = Base64.encode(encryptedContentKey); + String checksum = EncryptionHelper.calculateContentKeyChecksum(contentKeyIdUuid, aesKey); + + service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKeyString) + .setChecksum(checksum).setProtectionKeyId(protectionKeyId)); + service.action(Asset.linkContentKey(asset.getId(), contentKeyId)); + } + WritableBlobContainerContract uploader = service.createBlobWriter(locator); Hashtable<String, AssetFileInfo> infoToUpload = new Hashtable<String, AssetFileInfo>(); boolean isFirst = true; for (String fileName : inputFiles.keySet()) { + MessageDigest digest = MessageDigest.getInstance("MD5"); InputStream inputStream = inputFiles.get(fileName); + + String initializationVector = null; + if (aesKey != null) { + // Media Services requires 128-bit (16-byte) initialization vectors (IV) + // for AES encryption, but also that only the first 8 bytes are filled. + Random random = new Random(); + byte[] effectiveIv = new byte[8]; + random.nextBytes(effectiveIv); + byte[] iv = new byte[16]; + System.arraycopy(effectiveIv, 0, iv, 0, effectiveIv.length); + + byte[] sub = new byte[9]; + // Offset the bytes to ensure that the sign-bit is not set. + // Media Services expects unsigned Int64 values. + System.arraycopy(iv, 0, sub, 1, 8); + BigInteger longIv = new BigInteger(sub); + initializationVector = longIv.toString(); + + inputStream = EncryptionHelper.encryptFile(inputStream, aesKey, iv); + } + InputStream digestStream = new DigestInputStream(inputStream, digest); CountingStream countingStream = new CountingStream(digestStream); @@ -153,11 +215,10 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht inputStream.close(); byte[] md5hash = digest.digest(); String md5 = Base64.encode(md5hash); - System.out.println("md5: " + md5); AssetFileInfo fi = new AssetFileInfo(null, new AssetFileType().setContentChecksum(md5) .setContentFileSize(new Long(countingStream.getCount())).setIsPrimary(isFirst).setName(fileName) - .setParentAssetId(asset.getAlternateId())); + .setParentAssetId(asset.getAlternateId()).setInitializationVector(initializationVector)); infoToUpload.put(fileName, fi); isFirst = false; @@ -165,11 +226,16 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, Hasht service.action(AssetFile.createFileInfos(asset.getId())); for (AssetFileInfo assetFile : service.list(AssetFile.list(asset.getAssetFilesLink()))) { + AssetFileInfo fileInfo = infoToUpload.get(assetFile.getName()); + Updater updateOp = AssetFile.update(assetFile.getId()).setContentChecksum(fileInfo.getContentChecksum()) + .setContentFileSize(fileInfo.getContentFileSize()).setIsPrimary(fileInfo.getIsPrimary()); - AssetFileInfo x = infoToUpload.get(assetFile.getName()); - System.out.println(x); - service.update(AssetFile.update(assetFile.getId()).setContentChecksum(x.getContentChecksum()) - .setContentFileSize(x.getContentFileSize()).setIsPrimary(x.getIsPrimary())); + if (aesKey != null) { + updateOp.setIsEncrypted(true).setEncryptionKeyId(contentKeyId).setEncryptionScheme("StorageEncryption") + .setEncryptionVersion("1.0").setInitializationVector(fileInfo.getInitializationVector()); + } + + service.update(updateOp); } service.list(AssetFile.list(asset.getAssetFilesLink())); @@ -199,6 +265,13 @@ public int getCount() { } // Process + public JobInfo createJob(String jobName, AssetInfo inputAsset, Task.CreateBatchOperation task) + throws ServiceException { + List<Task.CreateBatchOperation> tasks = new ArrayList<Task.CreateBatchOperation>(); + tasks.add(task); + return createJob(jobName, inputAsset, tasks); + } + public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateBatchOperation> tasks) throws ServiceException { Creator jobCreator = Job.create().setName(jobName).addInputMediaAsset(inputAsset.getId()).setPriority(2); @@ -227,10 +300,7 @@ public Task.CreateBatchOperation createTaskOptionsPlayReadyProtection(String tas String taskBody = getTaskBody(inputAssetId, outputAssetId); Task.CreateBatchOperation taskCreate = Task .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION), taskBody).setName(taskName) - // TODO: Re-enable - // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/499 - // .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration) - .setConfiguration(playReadyConfiguration); + .setOptions(TaskOption.ProtectedConfiguration).setConfiguration(playReadyConfiguration); return taskCreate; } @@ -257,6 +327,16 @@ public Task.CreateBatchOperation createTaskOptionsSmoothStreamsToHls(String task return taskCreate; } + // Process + public Task.CreateBatchOperation createTaskOptionsDecodeAsset(String taskName, int inputAssetId, int outputAssetId) + throws ServiceException { + String taskBody = getTaskBody(inputAssetId, outputAssetId); + Task.CreateBatchOperation taskCreate = Task.create( + getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION), taskBody).setName(taskName); + + return taskCreate; + } + private String getTaskBody(int inputAssetId, int outputAssetId) { return "<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>" + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>"; @@ -397,4 +477,40 @@ public void removeAllAccessPoliciesWithPrefix() throws ServiceException { } } } + + private static class EncryptionHelper { + public static byte[] encryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + byte[] protectionKeyBytes = Base64.decode(protectionKey); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(protectionKeyBytes); + Certificate certificate = certificateFactory.generateCertificate(byteArrayInputStream); + Key publicKey = certificate.getPublicKey(); + SecureRandom secureRandom = new SecureRandom(); + cipher.init(Cipher.ENCRYPT_MODE, publicKey, secureRandom); + byte[] cipherText = cipher.doFinal(inputData); + return cipherText; + } + + public static String calculateContentKeyChecksum(String uuid, byte[] aesKey) throws Exception { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey, "AES"); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + byte[] encryptionResult = cipher.doFinal(uuid.getBytes("UTF8")); + byte[] checksumByteArray = new byte[8]; + System.arraycopy(encryptionResult, 0, checksumByteArray, 0, 8); + String checksum = Base64.encode(checksumByteArray); + return checksum; + } + + public static InputStream encryptFile(InputStream inputStream, byte[] key, byte[] iv) throws Exception { + Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding"); + SecretKeySpec keySpec = new SecretKeySpec(key, "AES"); + IvParameterSpec ivParameterSpec = new IvParameterSpec(iv); + cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivParameterSpec); + CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher); + return cipherInputStream; + } + } + } From 509942b034bc16f48c2d2368a4ec5bbb80d49dc7 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Wed, 9 Jan 2013 12:26:08 -0800 Subject: [PATCH 645/664] Simplifying the wrapper somewhat. --- .../scenarios/MediaServiceScenarioTest.java | 8 +- .../scenarios/MediaServiceWrapper.java | 114 +++++------------- 2 files changed, 38 insertions(+), 84 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index f8c09011438fd..f206f1f8dd238 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -37,6 +37,7 @@ import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.Task; +import com.microsoft.windowsazure.services.scenarios.MediaServiceWrapper.EncoderType; public class MediaServiceScenarioTest extends ScenarioTestBase { private static final String rootTestAssetPrefix = "testAssetPrefix-"; @@ -151,7 +152,8 @@ public void transformEncryptedAsset() throws Exception { .createAsset(testAssetPrefix + "transformEncryptedAsset", AssetOption.StorageEncrypted); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); String jobName = "my job transformEncryptedAsset" + UUID.randomUUID().toString(); - JobInfo job = wrapper.createJob(jobName, asset, wrapper.createTaskOptionsDecodeAsset("Decode", 0, 0)); + JobInfo job = wrapper.createJob(jobName, asset, + wrapper.createTaskOptions("Decode", 0, 0, EncoderType.StorageDecryption)); signalSetupFinished(); waitForJobToFinish(job); @@ -180,8 +182,8 @@ private void waitForJobToFinish(JobInfo job) throws InterruptedException, Servic private List<Task.CreateBatchOperation> createTasks() throws ServiceException { List<Task.CreateBatchOperation> tasks = new ArrayList<Task.CreateBatchOperation>(); - tasks.add(wrapper.createTaskOptionsMp4ToSmoothStreams("MP4 to SS", 0, 0)); - tasks.add(wrapper.createTaskOptionsSmoothStreamsToHls("SS to HLS", 0, 1)); + tasks.add(wrapper.createTaskOptions("MP4 to SS", 0, 0, EncoderType.Mp4ToSmoothStream)); + tasks.add(wrapper.createTaskOptions("SS to HLS", 0, 1, EncoderType.SmoothStreamsToHls)); return tasks; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 506f1febec22d..5c77ff76e67c0 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -67,7 +67,6 @@ import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.microsoft.windowsazure.services.media.models.ProtectionKey; import com.microsoft.windowsazure.services.media.models.Task; -import com.microsoft.windowsazure.services.media.models.TaskOption; class MediaServiceWrapper { private final MediaContract service; @@ -77,7 +76,6 @@ class MediaServiceWrapper { private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption"; private final String MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER = "Windows Azure Media Encoder"; private final String MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS = "MP4 to Smooth Streams Task"; - private final String MEDIA_PROCESSOR_PLAYREADY_PROTECTION = "PlayReady Protection Task"; private final String MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS = "Smooth Streams to HLS Task"; // From http://msdn.microsoft.com/en-us/library/windowsazure/hh973635.aspx @@ -119,6 +117,10 @@ class MediaServiceWrapper { + " <type>Microsoft.Web.Media.TransformManager.SmoothToHLS.SmoothToHLSTask, Microsoft.Web.Media.TransformManager.SmoothToHLS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" + " </taskCode>" + "</taskDefinition>"; + public static enum EncoderType { + WindowsAzureMediaEncoder, Mp4ToSmoothStream, SmoothStreamsToHls, StorageDecryption + } + public MediaServiceWrapper(MediaContract service) { this.service = service; } @@ -284,55 +286,35 @@ public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateB } // Process - public Task.CreateBatchOperation createTaskOptionsWindowsAzureMediaEncoder(String taskName, int inputAssetId, - int outputAssetId) throws ServiceException { - String taskBody = getTaskBody(inputAssetId, outputAssetId); - Task.CreateBatchOperation taskCreate = Task - .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER), taskBody) - .setName(taskName).setConfiguration("H.264 256k DSL CBR"); - - return taskCreate; - } - - // Process - public Task.CreateBatchOperation createTaskOptionsPlayReadyProtection(String taskName, - String playReadyConfiguration, int inputAssetId, int outputAssetId) throws ServiceException { - String taskBody = getTaskBody(inputAssetId, outputAssetId); - Task.CreateBatchOperation taskCreate = Task - .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION), taskBody).setName(taskName) - .setOptions(TaskOption.ProtectedConfiguration).setConfiguration(playReadyConfiguration); - - return taskCreate; - } - - // Process - public Task.CreateBatchOperation createTaskOptionsMp4ToSmoothStreams(String taskName, int inputAssetId, - int outputAssetId) throws ServiceException { + public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAssetId, int outputAssetId, + EncoderType encoderType) throws ServiceException { String taskBody = getTaskBody(inputAssetId, outputAssetId); - Task.CreateBatchOperation taskCreate = Task - .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS), taskBody).setName(taskName) - .setConfiguration(configMp4ToSmoothStreams); - - return taskCreate; - } - // Process - public Task.CreateBatchOperation createTaskOptionsSmoothStreamsToHls(String taskName, int inputAssetId, - int outputAssetId) throws ServiceException { - String taskBody = getTaskBody(inputAssetId, outputAssetId); - Task.CreateBatchOperation taskCreate = Task - .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS), taskBody).setName(taskName) - .setConfiguration(configSmoothStreamsToAppleHttpLiveStreams); - - return taskCreate; - } + String processor = null; + String configuration = null; + switch (encoderType) { + case Mp4ToSmoothStream: + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS); + configuration = configMp4ToSmoothStreams; + break; + case SmoothStreamsToHls: + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS); + configuration = configSmoothStreamsToAppleHttpLiveStreams; + break; + case WindowsAzureMediaEncoder: + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER); + configuration = "H.264 256k DSL CBR"; + break; + case StorageDecryption: + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION); + configuration = null; + break; + default: + break; + } - // Process - public Task.CreateBatchOperation createTaskOptionsDecodeAsset(String taskName, int inputAssetId, int outputAssetId) - throws ServiceException { - String taskBody = getTaskBody(inputAssetId, outputAssetId); - Task.CreateBatchOperation taskCreate = Task.create( - getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION), taskBody).setName(taskName); + Task.CreateBatchOperation taskCreate = Task.create(processor, taskBody).setName(taskName) + .setConfiguration(configuration); return taskCreate; } @@ -372,49 +354,19 @@ public void cancelJob(JobInfo job) throws ServiceException { service.action(Job.cancel(job.getId())); } - // Deliver - public List<URL> createOriginUrlsForStreamingContent(AssetInfo asset, int availabilityWindowInMinutes) - throws ServiceException, MalformedURLException { - return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, "", - LocatorType.OnDemandOrigin); - } - - // Deliver - public List<URL> createOriginUrlsForAppleHLSContent(AssetInfo asset, int availabilityWindowInMinutes) - throws ServiceException, MalformedURLException { - return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, true, - "(format=m3u8-aapl)", LocatorType.OnDemandOrigin); - } - // Deliver public List<URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, MalformedURLException { - return createOriginUrlsForStreamingContentWorker(asset, availabilityWindowInMinutes, false, null, - LocatorType.SAS); - } - - private List<URL> createOriginUrlsForStreamingContentWorker(AssetInfo asset, int availabilityWindowInMinutes, - boolean isSmooth, String suffix, LocatorType locatorType) throws ServiceException, MalformedURLException { List<URL> ret = new ArrayList<URL>(); AccessPolicyInfo readAP = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); - LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), locatorType)); + LocatorInfo readLocator = service.create(Locator.create(readAP.getId(), asset.getId(), LocatorType.SAS)); List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); for (AssetFileInfo fi : publishedFiles) { - if (isSmooth) { - // Smooth Streaming format ends with ".ism*" - int index = fi.getName().lastIndexOf('.'); - boolean isSmoothSteamFile = fi.getName().regionMatches(true, index + 1, "ism", 0, 3); - if (isSmoothSteamFile) { - ret.add(constructUrlFromLocatorAndFileName(readLocator, fi.getName() + "/manifest")); - } - } - else { - URL file = constructUrlFromLocatorAndFileName(readLocator, fi.getName()); - ret.add(file); - } + URL file = constructUrlFromLocatorAndFileName(readLocator, fi.getName()); + ret.add(file); } return ret; From ef728d073cfbcb9c2359968ffce060db4b3fb36e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 10 Jan 2013 09:14:46 -0800 Subject: [PATCH 646/664] Update to return file names with the asset file info. Add method to wrapper to get streams for asset files --- .../scenarios/MediaServiceScenarioTest.java | 4 +- .../scenarios/MediaServiceValidation.java | 10 ++-- .../scenarios/MediaServiceWrapper.java | 52 ++++++++++++++++--- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index f206f1f8dd238..7c948324efd3f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -111,7 +111,7 @@ public void downloadFiles() throws Exception { wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); - List<URL> fileUrls = wrapper.createFileURLsFromAsset(asset, 10); + Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(asset, 10); validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); } @@ -166,7 +166,7 @@ public void transformEncryptedAsset() throws Exception { validator.validateAssetFiles(outputAsset, getTestAssetFiles()); // Verify assets were decoded. - List<URL> fileUrls = wrapper.createFileURLsFromAsset(outputAsset, 10); + Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(outputAsset, 10); validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index 4b814761e7a58..de29d978150a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -139,12 +139,12 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i } } - public void validateAssetFileUrls(List<URL> fileUrls, Hashtable<String, InputStream> inputFiles) + public void validateAssetFileUrls(Hashtable<String, URL> fileUrls, Hashtable<String, InputStream> inputFiles) throws IOException, InterruptedException { - assertEquals("fileUrls count", inputFiles.size(), fileUrls.size()); - for (URL file : fileUrls) { - InputStream expected = inputFiles.get(inputFiles.keySet().toArray()[0]); - InputStream actual = getInputStreamWithRetry(file); + assertEquals("fileUrls count", inputFiles.size(), fileUrls.keySet().size()); + for (String fileName : fileUrls.keySet()) { + InputStream expected = inputFiles.get(fileName); + InputStream actual = getInputStreamWithRetry(fileUrls.get(fileName)); assertStreamsEqual(expected, actual); } } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 5c77ff76e67c0..fc6a2e924af99 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -162,9 +162,8 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, String contentKeyId = null; if (aesKey != null) { - String protectionKeyId = (String) service.action(ProtectionKey - .getProtectionKeyId(ContentKeyType.StorageEncryption)); - String protectionKey = (String) service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); String contentKeyIdUuid = UUID.randomUUID().toString(); contentKeyId = "nb:kid:UUID:" + contentKeyIdUuid; @@ -355,9 +354,9 @@ public void cancelJob(JobInfo job) throws ServiceException { } // Deliver - public List<URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, - MalformedURLException { - List<URL> ret = new ArrayList<URL>(); + public Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) + throws ServiceException, MalformedURLException { + Hashtable<String, URL> ret = new Hashtable<String, URL>(); AccessPolicyInfo readAP = service.create(AccessPolicy.create(accessPolicyPrefix + "tempAccessPolicy", availabilityWindowInMinutes, EnumSet.of(AccessPolicyPermission.READ))); @@ -366,12 +365,51 @@ public List<URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindow List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); for (AssetFileInfo fi : publishedFiles) { URL file = constructUrlFromLocatorAndFileName(readLocator, fi.getName()); - ret.add(file); + ret.put(fi.getName(), file); } return ret; } + // Ingest + public Hashtable<String, InputStream> downloadFilesFromAsset(AssetInfo asset, int downloadWindowInMinutes) + throws Exception { + Hashtable<String, URL> urls = createFileURLsFromAsset(asset, downloadWindowInMinutes); + Hashtable<String, InputStream> ret = new Hashtable<String, InputStream>(); + + for (String fileName : urls.keySet()) { + URL url = urls.get(fileName); + InputStream stream = getInputStreamWithRetry(url); + ret.put(fileName, stream); + } + + return ret; + } + + // This method is needed because there can be a delay before a new read locator + // is applied for the asset files. + private InputStream getInputStreamWithRetry(URL file) throws IOException, InterruptedException { + InputStream reader = null; + for (int counter = 0; true; counter++) { + try { + reader = file.openConnection().getInputStream(); + break; + } + catch (IOException e) { + System.out.println("Got error, wait a bit and try again"); + if (counter < 6) { + Thread.sleep(10000); + } + else { + // No more retries. + throw e; + } + } + } + + return reader; + } + private URL constructUrlFromLocatorAndFileName(LocatorInfo locator, String fileName) throws MalformedURLException { String locatorPath = locator.getPath(); int startOfSas = locatorPath.indexOf("?"); From 0077ba059c0c472f382af9cdd04008e28e14a00c Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 10 Jan 2013 09:20:12 -0800 Subject: [PATCH 647/664] Update tests to not rely on intermediate asset file URLs --- .../scenarios/MediaServiceScenarioTest.java | 9 +++-- .../scenarios/MediaServiceValidation.java | 35 +++---------------- .../scenarios/MediaServiceWrapper.java | 4 +-- 3 files changed, 11 insertions(+), 37 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 7c948324efd3f..e5640b02f8507 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.*; import java.io.InputStream; -import java.net.URL; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; @@ -111,8 +110,8 @@ public void downloadFiles() throws Exception { wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); signalSetupFinished(); - Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(asset, 10); - validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); + Hashtable<String, InputStream> actualFileStreams = wrapper.downloadFilesFromAsset(asset, 10); + validator.validateAssetFiles(getTestAssetFiles(), actualFileStreams); } @Test @@ -166,8 +165,8 @@ public void transformEncryptedAsset() throws Exception { validator.validateAssetFiles(outputAsset, getTestAssetFiles()); // Verify assets were decoded. - Hashtable<String, URL> fileUrls = wrapper.createFileURLsFromAsset(outputAsset, 10); - validator.validateAssetFileUrls(fileUrls, getTestAssetFiles()); + Hashtable<String, InputStream> actualFileStreams = wrapper.downloadFilesFromAsset(outputAsset, 10); + validator.validateAssetFiles(getTestAssetFiles(), actualFileStreams); } private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java index de29d978150a3..45c8611da58c5 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceValidation.java @@ -19,7 +19,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URL; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Date; @@ -139,12 +138,12 @@ public void validateAssetFiles(AssetInfo asset, Hashtable<String, InputStream> i } } - public void validateAssetFileUrls(Hashtable<String, URL> fileUrls, Hashtable<String, InputStream> inputFiles) - throws IOException, InterruptedException { - assertEquals("fileUrls count", inputFiles.size(), fileUrls.keySet().size()); - for (String fileName : fileUrls.keySet()) { + public void validateAssetFiles(Hashtable<String, InputStream> inputFiles, + Hashtable<String, InputStream> actualFileStreams) throws IOException, InterruptedException { + assertEquals("fileUrls count", inputFiles.size(), actualFileStreams.size()); + for (String fileName : actualFileStreams.keySet()) { InputStream expected = inputFiles.get(fileName); - InputStream actual = getInputStreamWithRetry(fileUrls.get(fileName)); + InputStream actual = actualFileStreams.get(fileName); assertStreamsEqual(expected, actual); } } @@ -175,30 +174,6 @@ public void validateOutputAssets(List<AssetInfo> outputAssets, Enumeration<Strin } } - // This method is needed because there can be a delay before a new read locator - // is applied for the asset files. - private InputStream getInputStreamWithRetry(URL file) throws InterruptedException, IOException { - InputStream reader = null; - for (int counter = 0; true; counter++) { - try { - reader = file.openConnection().getInputStream(); - break; - } - catch (IOException e) { - System.out.println("Got error, wait a bit and try again"); - if (counter < 6) { - Thread.sleep(10000); - } - else { - // No more retries. - throw e; - } - } - } - - return reader; - } - public void assertFileInfosEqual(String message, AssetFileInfo fi, AssetFileInfo match) { assertNotNull(message + ":fi", fi); assertNotNull(message + ":match", match); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index fc6a2e924af99..0e88fed190538 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -354,7 +354,7 @@ public void cancelJob(JobInfo job) throws ServiceException { } // Deliver - public Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) + private Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int availabilityWindowInMinutes) throws ServiceException, MalformedURLException { Hashtable<String, URL> ret = new Hashtable<String, URL>(); @@ -371,7 +371,7 @@ public Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int avail return ret; } - // Ingest + // Deliver public Hashtable<String, InputStream> downloadFilesFromAsset(AssetInfo asset, int downloadWindowInMinutes) throws Exception { Hashtable<String, URL> urls = createFileURLsFromAsset(asset, downloadWindowInMinutes); From 0a36968430e35dc8d9b3dc5d552d0f469a4a6180 Mon Sep 17 00:00:00 2001 From: Chris Tavares <ctavares@microsoft.com> Date: Thu, 10 Jan 2013 11:47:49 -0800 Subject: [PATCH 648/664] Renamed ...media.implementation.entities to ...media.entityoperations --- .../services/media/MediaContract.java | 2 +- .../DefaultActionOperation.java | 18 +++++------ .../DefaultDeleteOperation.java | 4 +-- .../DefaultEntityTypeActionOperation.java | 26 ++++++++-------- .../DefaultGetOperation.java | 2 +- .../DefaultListOperation.java | 4 +-- .../EntityActionOperation.java | 2 +- .../EntityBatchOperation.java | 2 +- .../EntityContract.java | 2 +- .../EntityCreateOperation.java | 2 +- .../EntityDeleteOperation.java | 2 +- .../EntityGetOperation.java | 2 +- .../EntityLinkOperation.java | 6 ++-- .../EntityListOperation.java | 2 +- .../EntityOperation.java | 2 +- .../EntityOperationBase.java | 6 ++-- .../EntityOperationSingleResult.java | 2 +- .../EntityOperationSingleResultBase.java | 2 +- .../EntityProxyData.java | 2 +- .../EntityRestProxy.java | 16 +++++----- .../EntityTypeActionOperation.java | 2 +- .../EntityUpdateOperation.java | 2 +- .../implementation/MediaBatchOperations.java | 2 +- .../MediaExceptionProcessor.java | 28 ++++++++--------- .../media/implementation/MediaRestProxy.java | 6 ++-- .../services/media/models/AccessPolicy.java | 14 ++++----- .../services/media/models/Asset.java | 28 ++++++++--------- .../services/media/models/AssetFile.java | 26 ++++++++-------- .../services/media/models/ContentKey.java | 16 +++++----- .../services/media/models/Job.java | 30 +++++++++---------- .../services/media/models/Locator.java | 26 ++++++++-------- .../services/media/models/MediaProcessor.java | 2 +- .../services/media/models/ProtectionKey.java | 8 ++--- .../services/media/models/Task.java | 4 +-- .../media/models/AccessPolicyEntityTest.java | 6 ++-- .../media/models/AssetEntityTest.java | 8 ++--- .../media/models/AssetFileEntityTest.java | 12 ++++---- .../media/models/ContentKeyEntityTest.java | 6 ++-- .../services/media/models/JobEntityTest.java | 4 +-- .../media/models/LocatorEntityTest.java | 8 ++--- .../models/MediaProcessorEntityTest.java | 2 +- .../scenarios/MediaServiceWrapper.java | 2 +- 42 files changed, 174 insertions(+), 174 deletions(-) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/DefaultActionOperation.java (78%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/DefaultDeleteOperation.java (85%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/DefaultEntityTypeActionOperation.java (68%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/DefaultGetOperation.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/DefaultListOperation.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityActionOperation.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityBatchOperation.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityContract.java (97%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityCreateOperation.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityDeleteOperation.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityGetOperation.java (90%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityLinkOperation.java (93%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityListOperation.java (94%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityOperation.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityOperationBase.java (91%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityOperationSingleResult.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityOperationSingleResultBase.java (95%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityProxyData.java (92%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityRestProxy.java (83%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityTypeActionOperation.java (96%) rename microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/{implementation/entities => entityoperations}/EntityUpdateOperation.java (91%) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java index edfb0e4704086..a6affe44503d3 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/MediaContract.java @@ -16,7 +16,7 @@ package com.microsoft.windowsazure.services.media; import com.microsoft.windowsazure.services.core.FilterableService; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityContract; +import com.microsoft.windowsazure.services.media.entityoperations.EntityContract; import com.microsoft.windowsazure.services.media.models.LocatorInfo; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultActionOperation.java similarity index 78% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultActionOperation.java index 39e9a41eea059..df08ea0e749a7 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultActionOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; @@ -62,7 +62,7 @@ public DefaultActionOperation() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { @@ -87,7 +87,7 @@ public String getUri() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getQueryParameters() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation#getQueryParameters() */ @Override public MultivaluedMap<String, String> getQueryParameters() { @@ -95,7 +95,7 @@ public MultivaluedMap<String, String> getQueryParameters() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation#addQueryParameter(java.lang.String, java.lang.String) */ @Override public DefaultActionOperation addQueryParameter(String key, String value) { @@ -104,7 +104,7 @@ public DefaultActionOperation addQueryParameter(String key, String value) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#getContentType() */ @Override public MediaType getContentType() { @@ -125,7 +125,7 @@ public DefaultActionOperation setContentType(MediaType contentType) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#getAcceptType() */ @Override public MediaType getAcceptType() { @@ -145,7 +145,7 @@ public DefaultActionOperation setAcceptType(MediaType acceptType) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getVerb() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation#getVerb() */ @Override public String getVerb() { @@ -153,7 +153,7 @@ public String getVerb() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -161,7 +161,7 @@ public Object getRequestContents() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#processResponse(java.lang.Object) */ @Override public Object processResponse(Object rawResponse) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultDeleteOperation.java similarity index 85% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultDeleteOperation.java index 86c19e48ce891..352e4b362d113 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultDeleteOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; /** * Generic implementation of Delete operation usable by most entities @@ -31,7 +31,7 @@ public DefaultDeleteOperation(String entityUri, String entityId) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultEntityTypeActionOperation.java similarity index 68% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultEntityTypeActionOperation.java index f27e8bcb84de2..d5e480a3bf9d8 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultEntityTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultEntityTypeActionOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; @@ -64,7 +64,7 @@ public DefaultEntityTypeActionOperation() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#processTypeResponse(com.sun.jersey.api.client.ClientResponse) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#processTypeResponse(com.sun.jersey.api.client.ClientResponse) */ @Override public T processTypeResponse(ClientResponse clientResponse) { @@ -72,7 +72,7 @@ public T processTypeResponse(ClientResponse clientResponse) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getQueryParameters() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#getQueryParameters() */ @Override public MultivaluedMap<String, String> getQueryParameters() { @@ -80,7 +80,7 @@ public MultivaluedMap<String, String> getQueryParameters() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getVerb() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#getVerb() */ @Override public String getVerb() { @@ -88,7 +88,7 @@ public String getVerb() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -96,7 +96,7 @@ public Object getRequestContents() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { @@ -104,7 +104,7 @@ public void setProxyData(EntityProxyData proxyData) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getUri() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#getUri() */ @Override public String getUri() { @@ -112,7 +112,7 @@ public String getUri() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getContentType() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#getContentType() */ @Override public MediaType getContentType() { @@ -120,7 +120,7 @@ public MediaType getContentType() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#getAcceptType() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#getAcceptType() */ @Override public MediaType getAcceptType() { @@ -128,7 +128,7 @@ public MediaType getAcceptType() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#processResponse(java.lang.Object) */ @Override public Object processResponse(Object rawResponse) throws ServiceException { @@ -136,7 +136,7 @@ public Object processResponse(Object rawResponse) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#addQueryParameter(java.lang.String, java.lang.String) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#addQueryParameter(java.lang.String, java.lang.String) */ @Override public DefaultEntityTypeActionOperation<T> addQueryParameter(String key, String value) { @@ -145,7 +145,7 @@ public DefaultEntityTypeActionOperation<T> addQueryParameter(String key, String } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#setContentType(javax.ws.rs.core.MediaType) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#setContentType(javax.ws.rs.core.MediaType) */ @Override public EntityTypeActionOperation<T> setContentType(MediaType contentType) { @@ -154,7 +154,7 @@ public EntityTypeActionOperation<T> setContentType(MediaType contentType) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation#setAcceptType(javax.ws.rs.core.MediaType) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation#setAcceptType(javax.ws.rs.core.MediaType) */ @Override public EntityTypeActionOperation<T> setAcceptType(MediaType acceptType) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultGetOperation.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultGetOperation.java index 5261caf45d669..29a5f2650207e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultGetOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; /** * Generic implementation of the get operation usable for most entities diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultListOperation.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultListOperation.java index 6236d2ffc64a4..0aa1ab4eec677 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/DefaultListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/DefaultListOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MultivaluedMap; @@ -97,7 +97,7 @@ public GenericType<ListResult<T>> getResponseGenericType() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase#processResponse(java.lang.Object) */ @Override public Object processResponse(Object rawResponse) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityActionOperation.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityActionOperation.java index 639985ab2fc5d..25e272ca82699 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityActionOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityBatchOperation.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityBatchOperation.java index 323de86a27040..ec29588bd6495 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityBatchOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityBatchOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java similarity index 97% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java index 61b5b908b36bb..d42fcdc14d30a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityContract.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityContract.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.models.ListResult; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityCreateOperation.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityCreateOperation.java index 45c5a174b9d15..f4bae23cf56c6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityCreateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityCreateOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityDeleteOperation.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityDeleteOperation.java index a0446c897f157..c0203287e094e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityDeleteOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityDeleteOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; public interface EntityDeleteOperation { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityGetOperation.java similarity index 90% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityGetOperation.java index 221757ef0884b..b39759add5f3b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityGetOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityGetOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityLinkOperation.java similarity index 93% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityLinkOperation.java index 525869759c5c2..19503c49548fb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityLinkOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityLinkOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -120,7 +120,7 @@ public String getUri() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#getVerb() + * @see com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation#getVerb() */ @Override public String getVerb() { @@ -128,7 +128,7 @@ public String getVerb() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation#getRequestContents() */ @Override public Object getRequestContents() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityListOperation.java similarity index 94% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityListOperation.java index aceec3e0ffa63..80d0d146a89b9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityListOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityListOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MultivaluedMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java index 355da9602f6cf..6ac4b38c6f08f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationBase.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationBase.java index 88303b350631d..013181e32de4e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationBase.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -62,7 +62,7 @@ protected EntityOperationBase(EntityUriBuilder uriBuilder) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { @@ -103,7 +103,7 @@ public MediaType getAcceptType() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#processResponse(java.lang.Object) */ @Override public Object processResponse(Object rawResponse) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java index 40fa6464895ac..f3eeb0141d637 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResult.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResult.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; public interface EntityOperationSingleResult<T> extends EntityOperation { /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResultBase.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResultBase.java index 894e786c7295b..65b82a98b36b2 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityOperationSingleResultBase.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityOperationSingleResultBase.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import com.microsoft.windowsazure.services.core.ServiceException; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityProxyData.java similarity index 92% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityProxyData.java index 3e480f9683439..d0c21b9ec01a4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityProxyData.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityProxyData.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import java.net.URI; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityRestProxy.java similarity index 83% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityRestProxy.java index e880263b9efd4..c99273aaabf35 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityRestProxy.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; @@ -104,7 +104,7 @@ private Builder getResource(EntityOperation operation) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#create(com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation) */ @SuppressWarnings("unchecked") @Override @@ -116,7 +116,7 @@ public <T> T create(EntityCreateOperation<T> creator) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#get(com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation) */ @SuppressWarnings("unchecked") @Override @@ -128,7 +128,7 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#list(com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation) */ @SuppressWarnings("unchecked") @Override @@ -142,7 +142,7 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#update(com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#update(com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation) */ @Override public void update(EntityUpdateOperation updater) throws ServiceException { @@ -154,7 +154,7 @@ public void update(EntityUpdateOperation updater) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#delete(com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#delete(com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation) */ @Override public void delete(EntityDeleteOperation deleter) throws ServiceException { @@ -163,7 +163,7 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#action(com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation) */ @Override public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) throws ServiceException { @@ -177,7 +177,7 @@ public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) thro } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#action(com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation) */ @Override public void action(EntityActionOperation entityActionOperation) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityTypeActionOperation.java similarity index 96% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityTypeActionOperation.java index 526f4c4268218..d089aaff24c32 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityTypeActionOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityTypeActionOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityUpdateOperation.java similarity index 91% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityUpdateOperation.java index 3a4db445cda60..89e474bc8e41a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/entities/EntityUpdateOperation.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/entityoperations/EntityUpdateOperation.java @@ -13,7 +13,7 @@ * limitations under the License. */ -package com.microsoft.windowsazure.services.media.implementation.entities; +package com.microsoft.windowsazure.services.media.entityoperations; /** * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java index 0827cda6219d2..85a9dce36971b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaBatchOperations.java @@ -44,8 +44,8 @@ import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.entityoperations.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.microsoft.windowsazure.services.media.models.Job; import com.microsoft.windowsazure.services.media.models.JobInfo; import com.microsoft.windowsazure.services.media.models.Task; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java index ddd5c3da168b5..cc2808e7bdc69 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaExceptionProcessor.java @@ -25,13 +25,13 @@ import com.microsoft.windowsazure.services.core.utils.ServiceExceptionFactory; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.models.ListResult; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.sun.jersey.api.client.ClientHandlerException; @@ -93,7 +93,7 @@ private ServiceException processCatch(ServiceException e) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#create(com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#create(com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation) */ @Override public <T> T create(EntityCreateOperation<T> creator) throws ServiceException { @@ -109,7 +109,7 @@ public <T> T create(EntityCreateOperation<T> creator) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#get(com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#get(com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation) */ @Override public <T> T get(EntityGetOperation<T> getter) throws ServiceException { @@ -125,7 +125,7 @@ public <T> T get(EntityGetOperation<T> getter) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#list(com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#list(com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation) */ @Override public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceException { @@ -141,7 +141,7 @@ public <T> ListResult<T> list(EntityListOperation<T> lister) throws ServiceExcep } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#update(com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#update(com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation) */ @Override public void update(EntityUpdateOperation updater) throws ServiceException { @@ -158,7 +158,7 @@ public void update(EntityUpdateOperation updater) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#delete(com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#delete(com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation) */ @Override public void delete(EntityDeleteOperation deleter) throws ServiceException { @@ -174,7 +174,7 @@ public void delete(EntityDeleteOperation deleter) throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#action(com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation) */ @Override public void action(EntityActionOperation entityActionOperation) throws ServiceException { @@ -190,7 +190,7 @@ public void action(EntityActionOperation entityActionOperation) throws ServiceEx } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityContract#action(com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityContract#action(com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation) */ @Override public <T> T action(EntityTypeActionOperation<T> entityTypeActionOperation) throws ServiceException { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java index fdee1c89571ff..cb8480f28920b 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/MediaRestProxy.java @@ -27,8 +27,8 @@ import com.microsoft.windowsazure.services.core.utils.pipeline.ClientConfigSettings; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy; +import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; +import com.microsoft.windowsazure.services.media.entityoperations.EntityRestProxy; import com.microsoft.windowsazure.services.media.models.LocatorInfo; import com.microsoft.windowsazure.services.media.models.LocatorType; import com.sun.jersey.api.client.Client; @@ -101,7 +101,7 @@ public MediaContract withFilter(ServiceFilter filter) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityRestProxy#createProxyData() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityRestProxy#createProxyData() */ @Override protected EntityProxyData createProxyData() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index 98dc725cf9bab..3c1c9e4beccbe 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -19,14 +19,14 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index be8df8fca8b79..cd87fc8b19878 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -22,18 +22,18 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityLinkOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityLinkOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; /** @@ -87,7 +87,7 @@ public Creator() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -242,7 +242,7 @@ protected Updater(String assetId) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { @@ -250,7 +250,7 @@ public void setProxyData(EntityProxyData proxyData) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation#getRequestContents() */ @Override public Object getRequestContents() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java index be7e23af86bf0..b8406b208dc70 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetFile.java @@ -19,19 +19,19 @@ import java.net.URLEncoder; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; public class AssetFile { @@ -240,7 +240,7 @@ public Object getRequestContents() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 62617e8e91d5a..4817b3930e6cf 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -17,14 +17,14 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.GenericType; /** @@ -103,7 +103,7 @@ public Creator(String id, ContentKeyType contentKeyType, String encryptedContent } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index e73940980b0ef..0254d950cf2a9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -28,18 +28,18 @@ import javax.xml.parsers.ParserConfigurationException; import com.microsoft.windowsazure.services.core.ServiceException; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityBatchOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; import com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations; import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.GenericType; @@ -152,7 +152,7 @@ public Creator() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() throws ServiceException { @@ -163,7 +163,7 @@ public Object getRequestContents() throws ServiceException { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase#getResponseClass() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase#getResponseClass() */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override @@ -172,7 +172,7 @@ public Class getResponseClass() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#processResponse(java.lang.Object) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation#processResponse(java.lang.Object) */ @Override public Object processResponse(Object clientResponse) throws ServiceException { @@ -282,7 +282,7 @@ public Creator addInputMediaAsset(String assetId) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getContentType() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase#getContentType() */ @Override public MediaType getContentType() { @@ -293,7 +293,7 @@ public MediaType getContentType() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase#getUri() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase#getUri() */ @Override public String getUri() { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index 9ee170d8d61a4..ada4deeeb2e8c 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -18,17 +18,17 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase; +import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityOperationSingleResultBase; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.api.client.GenericType; /** @@ -108,7 +108,7 @@ protected Creator(String accessPolicyId, String assetId, LocatorType locatorType } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -253,7 +253,7 @@ public Updater(String locatorId) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation#getRequestContents() + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation#getRequestContents() */ @Override public Object getRequestContents() { @@ -261,7 +261,7 @@ public Object getRequestContents() { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData) + * @see com.microsoft.windowsazure.services.media.entityoperations.EntityOperation#setProxyData(com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData) */ @Override public void setProxyData(EntityProxyData proxyData) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index ffd017e7f0bae..fe8c3898d4d87 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -17,7 +17,7 @@ import javax.ws.rs.core.MultivaluedMap; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; import com.sun.jersey.api.client.GenericType; /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java index a07b655f360f5..7b9a6bb15d1c5 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ProtectionKey.java @@ -25,10 +25,10 @@ import javax.xml.transform.stream.StreamSource; import com.microsoft.windowsazure.services.core.utils.pipeline.PipelineHelpers; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultEntityTypeActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityTypeActionOperation; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyIdType; import com.microsoft.windowsazure.services.media.implementation.content.ProtectionKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultEntityTypeActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityTypeActionOperation; import com.sun.jersey.api.client.ClientResponse; /** @@ -98,7 +98,7 @@ public GetProtectionKeyIdActionOperation(String name) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + * @see com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override public String processTypeResponse(ClientResponse clientResponse) { @@ -169,7 +169,7 @@ public GetProtectionKeyActionOperation(String name) { } /* (non-Javadoc) - * @see com.microsoft.windowsazure.services.media.implementation.entities.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) + * @see com.microsoft.windowsazure.services.media.entityoperations.DefaultActionOperation#processResponse(com.sun.jersey.api.client.ClientResponse) */ @Override public String processTypeResponse(ClientResponse clientResponse) { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index dfb06c79573e4..03042d2be4deb 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -17,9 +17,9 @@ import javax.ws.rs.core.MultivaluedMap; +import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; -import com.microsoft.windowsazure.services.media.implementation.entities.DefaultListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityBatchOperation; import com.sun.jersey.api.client.GenericType; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index 7cc3019ad1e51..b70d7e7976b20 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -24,10 +24,10 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 455b86a81deea..61c9a3e41b1a3 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -25,16 +25,16 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.atom.ContentType; import com.microsoft.windowsazure.services.media.implementation.atom.EntryType; import com.microsoft.windowsazure.services.media.implementation.atom.LinkType; import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java index 2b3ec596127e6..5e7607ea309ba 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetFileEntityTest.java @@ -19,13 +19,13 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.entityoperations.EntityActionOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityActionOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; public class AssetFileEntityTest { private final String exampleAssetId = "nb:cid:UUID:bfe1c840-36c3-4a78-9b63-38e6eebd94c2"; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index 2e46980b2003f..a07169ff3fb17 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -23,10 +23,10 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index e3cf221464938..fbd079168472c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -25,8 +25,8 @@ import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityProxyData; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; import com.sun.jersey.core.util.MultivaluedMapImpl; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index ea09585143069..a1b5f0a2b6c06 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -24,11 +24,11 @@ import org.junit.Test; +import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityCreateOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation; import com.sun.jersey.core.util.MultivaluedMapImpl; /** diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index df381cc73b281..c317dc04ccba6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -21,7 +21,7 @@ import org.junit.Test; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.models.MediaProcessor; import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.sun.jersey.core.util.MultivaluedMapImpl; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index a94c44a3d7f29..5d46c4c5fdc73 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -31,8 +31,8 @@ import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.media.MediaContract; import com.microsoft.windowsazure.services.media.WritableBlobContainerContract; +import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.content.AssetFileType; -import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation; import com.microsoft.windowsazure.services.media.models.AccessPolicy; import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo; import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission; From 75e4a8086e8ca7682c7a19103a633fd0dbe889c4 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 10 Jan 2013 18:11:59 -0800 Subject: [PATCH 649/664] Updating task to change type of file from MP4 to WMV Updating tests that use encryption to check if the JVM supports 256-bit AES, to give a better error message --- .../services/media/EncryptionHelper.java | 13 +++++++++++ .../media/EncryptionIntegrationTest.java | 5 +++++ .../scenarios/MediaServiceScenarioTest.java | 15 ++++++++++++- .../scenarios/MediaServiceWrapper.java | 22 ++++++++++++++++++- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index aa5ecd55c13c1..7f77502a0a1a8 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -30,6 +30,19 @@ import com.microsoft.windowsazure.services.core.storage.utils.Base64; class EncryptionHelper { + public static boolean canUseStrongCrypto() { + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + SecretKeySpec secretKeySpec = new SecretKeySpec(new byte[32], "AES"); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + public static byte[] encryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 3a84c0267d122..4fcdafb3aa9c4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -26,6 +26,8 @@ import java.util.Random; import java.util.UUID; +import junit.framework.Assert; + import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; @@ -62,6 +64,9 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { @Test public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange + if (!EncryptionHelper.canUseStrongCrypto()) { + Assert.fail("JVM does not appear support the required encryption"); + } // Media Services requires 256-bit (32-byte) keys and // 128-bit (16-byte) initialization vectors (IV) for AES encryption, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index e5640b02f8507..634c3df298565 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -24,6 +24,8 @@ import java.util.Random; import java.util.UUID; +import junit.framework.Assert; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -97,6 +99,10 @@ public void uploadEncryptedFiles() throws Exception { byte[] aesKey = new byte[32]; random.nextBytes(aesKey); AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadEncryptedFiles", AssetOption.StorageEncrypted); + if (asset == null) { + Assert.fail("JVM does not appear support the required encryption"); + } + signalSetupFinished(); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); @@ -132,11 +138,14 @@ public void transformAsset() throws Exception { AssetInfo asset = wrapper.createAsset(testAssetPrefix + "transformAsset", AssetOption.None); wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles()); String jobName = "my job transformAsset" + UUID.randomUUID().toString(); - JobInfo job = wrapper.createJob(jobName, asset, createTasks()); + + JobInfo job = wrapper.createJob(jobName, asset, + wrapper.createTaskOptions("Transform", 0, 0, EncoderType.WindowsAzureMediaEncoder)); signalSetupFinished(); waitForJobToFinish(job); List<AssetInfo> outputAssets = wrapper.getJobOutputMediaAssets(job); + validator.validateOutputAssets(outputAssets, getTestAssetFiles().keys()); } @@ -149,6 +158,10 @@ public void transformEncryptedAsset() throws Exception { random.nextBytes(aesKey); AssetInfo asset = wrapper .createAsset(testAssetPrefix + "transformEncryptedAsset", AssetOption.StorageEncrypted); + if (asset == null) { + Assert.fail("JVM does not appear support the required encryption"); + } + wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); String jobName = "my job transformEncryptedAsset" + UUID.randomUUID().toString(); JobInfo job = wrapper.createJob(jobName, asset, diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 0e88fed190538..03c988ddb9027 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -127,6 +127,10 @@ public MediaServiceWrapper(MediaContract service) { // Manage public AssetInfo createAsset(String name, AssetOption encryption) throws ServiceException { + if (encryption == AssetOption.StorageEncrypted && !EncryptionHelper.canUseStrongCrypto()) { + return null; + } + // Create asset. The SDK's top-level method is the simplest way to do that. return service.create(Asset.create().setName(name).setAlternateId("altId").setOptions(encryption)); } @@ -302,7 +306,9 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss break; case WindowsAzureMediaEncoder: processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER); - configuration = "H.264 256k DSL CBR"; + // Can get the full list of available configurations strings from + // http://msdn.microsoft.com/en-us/library/microsoft.expression.encoder.presets_members(v=Expression.30).aspx + configuration = "VC-1 256k DSL CBR"; break; case StorageDecryption: processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION); @@ -333,6 +339,7 @@ private String getMediaProcessorIdByName(String processorName) throws ServiceExc // Process public boolean isJobFinished(JobInfo initialJobInfo) throws ServiceException { JobInfo currentJob = service.get(Job.get(initialJobInfo.getId())); + System.out.println(currentJob.getState()); switch (currentJob.getState()) { case Finished: case Canceled: @@ -469,6 +476,19 @@ public void removeAllAccessPoliciesWithPrefix() throws ServiceException { } private static class EncryptionHelper { + public static boolean canUseStrongCrypto() { + try { + Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); + SecretKeySpec secretKeySpec = new SecretKeySpec(new byte[32], "AES"); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + } + catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + public static byte[] encryptSymmetricKey(String protectionKey, byte[] inputData) throws Exception { Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding"); CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); From 5702ea8fe08e696a43d36f6d88206bbc0b54b89e Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 10 Jan 2013 23:13:20 -0800 Subject: [PATCH 650/664] Remove hacky `constructUrlFromLocatorAndFileName` in favor of using locator's BaseUri and ContentAccessToken --- .../services/scenarios/MediaServiceWrapper.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 03c988ddb9027..f5bd0769963a2 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -371,8 +371,8 @@ private Hashtable<String, URL> createFileURLsFromAsset(AssetInfo asset, int avai List<AssetFileInfo> publishedFiles = service.list(AssetFile.list(asset.getAssetFilesLink())); for (AssetFileInfo fi : publishedFiles) { - URL file = constructUrlFromLocatorAndFileName(readLocator, fi.getName()); - ret.put(fi.getName(), file); + ret.put(fi.getName(), + new URL(readLocator.getBaseUri() + "/" + fi.getName() + readLocator.getContentAccessToken())); } return ret; @@ -417,17 +417,6 @@ private InputStream getInputStreamWithRetry(URL file) throws IOException, Interr return reader; } - private URL constructUrlFromLocatorAndFileName(LocatorInfo locator, String fileName) throws MalformedURLException { - String locatorPath = locator.getPath(); - int startOfSas = locatorPath.indexOf("?"); - String blobPath = locatorPath + fileName; - if (startOfSas >= 0) { - blobPath = locatorPath.substring(0, startOfSas) + "/" + fileName + locatorPath.substring(startOfSas); - } - - return new URL(blobPath); - } - public void removeAllAssetsWithPrefix(String assetPrefix) throws ServiceException { ListResult<LocatorInfo> locators = service.list(Locator.list()); EntityListOperation<AssetInfo> operation = Asset.list(); From 2f81d3ef539f908c3b8809a30e5376089fc1b84f Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Thu, 10 Jan 2013 23:46:58 -0800 Subject: [PATCH 651/664] Adding version ot the `getMediaProcessorIdByName` method, because processors of different versions take different configurations. --- .../scenarios/MediaServiceWrapper.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index f5bd0769963a2..b7ef93897c6cb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -297,21 +297,21 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss String configuration = null; switch (encoderType) { case Mp4ToSmoothStream: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS, "2.1.0.0"); configuration = configMp4ToSmoothStreams; break; case SmoothStreamsToHls: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS, "2.1.0.0"); configuration = configSmoothStreamsToAppleHttpLiveStreams; break; case WindowsAzureMediaEncoder: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER); - // Can get the full list of available configurations strings from - // http://msdn.microsoft.com/en-us/library/microsoft.expression.encoder.presets_members(v=Expression.30).aspx - configuration = "VC-1 256k DSL CBR"; + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.1.1.0"); + // Full list of configurations strings for version 2.1 is at: + // http://msdn.microsoft.com/en-us/library/jj129582.aspx + configuration = "VC1 Broadband SD 4x3"; break; case StorageDecryption: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_STORAGE_DECRYPTION, "1.5.3"); configuration = null; break; default: @@ -329,9 +329,10 @@ private String getTaskBody(int inputAssetId, int outputAssetId) { + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>"; } - private String getMediaProcessorIdByName(String processorName) throws ServiceException { + private String getMediaProcessorIdByName(String processorName, String version) throws ServiceException { EntityListOperation<MediaProcessorInfo> operation = MediaProcessor.list(); - operation.getQueryParameters().putSingle("$filter", "Name eq '" + processorName + "'"); + operation.getQueryParameters().putSingle("$filter", + "(Name eq '" + processorName + "') and (Version eq '" + version + "')"); MediaProcessorInfo processor = service.list(operation).get(0); return processor.getId(); } From a7df73a68b000b1946fb6006244536c35cf8cab7 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 11 Jan 2013 10:43:04 -0800 Subject: [PATCH 652/664] Updating copyright section for parity with the rest of the code. --- .../windowsazure/services/core/storage/SendingRequestEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java index 2e86fbe6166d6..8b61f7e092ff9 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/storage/SendingRequestEvent.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 Microsoft Corporation + * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From d3ac77b78a42ea43cd9bc0d0570cf5af995550aa Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 11 Jan 2013 11:48:52 -0800 Subject: [PATCH 653/664] get rid of the multivalued map overload for list. --- .../services/media/models/AccessPolicy.java | 14 -------------- .../windowsazure/services/media/models/Asset.java | 14 -------------- .../services/media/models/ContentKey.java | 14 -------------- .../windowsazure/services/media/models/Job.java | 13 ------------- .../services/media/models/Locator.java | 14 -------------- .../services/media/models/MediaProcessor.java | 14 -------------- .../windowsazure/services/media/models/Task.java | 14 -------------- .../services/media/TaskIntegrationTest.java | 13 ++++--------- .../media/models/AccessPolicyEntityTest.java | 2 +- .../services/media/models/AssetEntityTest.java | 2 +- .../media/models/ContentKeyEntityTest.java | 2 +- .../services/media/models/JobEntityTest.java | 2 +- .../services/media/models/LocatorEntityTest.java | 2 +- .../media/models/MediaProcessorEntityTest.java | 4 +--- 14 files changed, 10 insertions(+), 114 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java index 3c1c9e4beccbe..200d571abb72a 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AccessPolicy.java @@ -17,8 +17,6 @@ import java.util.EnumSet; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; @@ -111,18 +109,6 @@ public static DefaultListOperation<AccessPolicyInfo> list() { }); } - /** - * Create an operation that will retrieve all access policies that match the given query parameters - * - * @param queryParameters - * query parameters to add to the request - * @return the operation - */ - public static DefaultListOperation<AccessPolicyInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<AccessPolicyInfo>(ENTITY_SET, new GenericType<ListResult<AccessPolicyInfo>>() { - }, queryParameters); - } - /** * Create an operation to delete the given access policy * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java index cd87fc8b19878..3606cc7fc669e 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Asset.java @@ -20,8 +20,6 @@ import java.net.URLEncoder; import java.security.InvalidParameterException; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; @@ -185,18 +183,6 @@ public static DefaultListOperation<AssetInfo> list() { }); } - /** - * Create an operation that will list all the assets which match the given query parameters. - * - * @param queryParameters - * query parameters to pass to the server. - * @return the list operation. - */ - public static DefaultListOperation<AssetInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<AssetInfo>(ENTITY_SET, new GenericType<ListResult<AssetInfo>>() { - }, queryParameters); - } - /** * Create an operation that will list all the assets at the given link. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java index 4817b3930e6cf..4d93a5e773567 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/ContentKey.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.models; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; @@ -192,18 +190,6 @@ public static DefaultListOperation<ContentKeyInfo> list() { }); } - /** - * Create an operation that will retrieve all access policies that match the given query parameters. - * - * @param queryParameters - * query parameters to add to the request - * @return the operation - */ - public static DefaultListOperation<ContentKeyInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<ContentKeyInfo>(ENTITY_SET, new GenericType<ListResult<ContentKeyInfo>>() { - }, queryParameters); - } - /** * Create an operation that will list all the content keys at the given link. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java index 0254d950cf2a9..ca7bf086105ad 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Job.java @@ -23,7 +23,6 @@ import javax.mail.MessagingException; import javax.mail.internet.MimeMultipart; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBException; import javax.xml.parsers.ParserConfigurationException; @@ -399,18 +398,6 @@ public static DefaultListOperation<JobInfo> list() { }); } - /** - * Create an operation that will list all the jobs which match the given query parameters. - * - * @param queryParameters - * query parameters to pass to the server. - * @return the list operation. - */ - public static DefaultListOperation<JobInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<JobInfo>(ENTITY_SET, new GenericType<ListResult<JobInfo>>() { - }, queryParameters); - } - /** * Create an operation to delete the given job. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java index ada4deeeb2e8c..a565db206d7af 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Locator.java @@ -16,8 +16,6 @@ import java.util.Date; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultDeleteOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultGetOperation; import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; @@ -199,18 +197,6 @@ public static DefaultListOperation<LocatorInfo> list() { }); } - /** - * Create an operation to list all locators matching the given query parameters. - * - * @param queryParameters - * query parameters to send with the request - * @return the list operation - */ - public static DefaultListOperation<LocatorInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<LocatorInfo>(ENTITY_SET, new GenericType<ListResult<LocatorInfo>>() { - }, queryParameters); - } - /** * Create an operation that will list all the locators at the given link. * diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java index fe8c3898d4d87..9be60e4ee3bd6 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessor.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.models; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; import com.sun.jersey.api.client.GenericType; @@ -42,16 +40,4 @@ public static DefaultListOperation<MediaProcessorInfo> list() { }); } - /** - * Create an operation to list all media processors that satisfy the given query parameters - * - * @param queryParameters - * query parameters to pass with the request - * @return the list operation - */ - public static DefaultListOperation<MediaProcessorInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<MediaProcessorInfo>(ENTITY_SET, - new GenericType<ListResult<MediaProcessorInfo>>() { - }, queryParameters); - } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java index 03042d2be4deb..707970b7b7e83 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/Task.java @@ -15,8 +15,6 @@ package com.microsoft.windowsazure.services.media.models; -import javax.ws.rs.core.MultivaluedMap; - import com.microsoft.windowsazure.services.media.entityoperations.DefaultListOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityBatchOperation; import com.microsoft.windowsazure.services.media.implementation.content.TaskType; @@ -61,18 +59,6 @@ public static DefaultListOperation<TaskInfo> list() { }); } - /** - * Create an operation that will list all the tasks which match the given query parameters. - * - * @param queryParameters - * query parameters to pass to the server. - * @return the list operation. - */ - public static DefaultListOperation<TaskInfo> list(MultivaluedMap<String, String> queryParameters) { - return new DefaultListOperation<TaskInfo>(ENTITY_SET, new GenericType<ListResult<TaskInfo>>() { - }, queryParameters); - } - /** * Create an operation that will list the tasks pointed to by the given link. * diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index 5ee702540f042..60e4cc787b9fb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -23,8 +23,6 @@ import java.util.List; import java.util.UUID; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -43,7 +41,6 @@ import com.microsoft.windowsazure.services.media.models.TaskOption; import com.microsoft.windowsazure.services.media.models.TaskState; import com.sun.jersey.core.util.Base64; -import com.sun.jersey.core.util.MultivaluedMapImpl; public class TaskIntegrationTest extends IntegrationTestBase { private static AssetInfo assetInfo; @@ -153,12 +150,10 @@ public void canListTasksWithOptions() throws ServiceException { service.create(jobCreator); // Act - MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl(); - queryParameters.add("$filter", "startswith(Name, '" + baseName + "') eq true"); - ListResult<TaskInfo> listTaskResult1 = service.list(Task.list(queryParameters)); - - queryParameters.add("$top", "2"); - ListResult<TaskInfo> listTaskResult2 = service.list(Task.list(queryParameters)); + ListResult<TaskInfo> listTaskResult1 = service.list(Task.list().set("$filter", + "startswith(Name, '" + baseName + "') eq true")); + ListResult<TaskInfo> listTaskResult2 = service.list(Task.list() + .set("$filter", "startswith(Name, '" + baseName + "') eq true").setTop(2)); // Assert assertEquals("listTaskResult1.size", 4, listTaskResult1.size()); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index b70d7e7976b20..1685c2461d947 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -78,7 +78,7 @@ public void listWithQueryParametersReturnsThem() throws Exception { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list(queryParams); + EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 61c9a3e41b1a3..1cf45220d7db6 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -103,7 +103,7 @@ public void assetListCanTakeQueryParameters() { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<AssetInfo> lister = Asset.list(queryParams); + EntityListOperation<AssetInfo> lister = Asset.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index a07169ff3fb17..dbfb0c9304b20 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -88,7 +88,7 @@ public void listContentKeyCanTakeQueryParameters() { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<ContentKeyInfo> lister = ContentKey.list(queryParams); + EntityListOperation<ContentKeyInfo> lister = ContentKey.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index fbd079168472c..42c392ea70053 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -69,7 +69,7 @@ public void JobListCanTakeQueryParameters() { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<JobInfo> lister = Job.list(queryParams); + EntityListOperation<JobInfo> lister = Job.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index a1b5f0a2b6c06..93390f8bf03e1 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -143,7 +143,7 @@ public void listLocatorCanTakeQueryParameters() { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<LocatorInfo> lister = Locator.list(queryParams); + EntityListOperation<LocatorInfo> lister = Locator.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index c317dc04ccba6..ae2edf2a3b629 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -22,8 +22,6 @@ import org.junit.Test; import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; -import com.microsoft.windowsazure.services.media.models.MediaProcessor; -import com.microsoft.windowsazure.services.media.models.MediaProcessorInfo; import com.sun.jersey.core.util.MultivaluedMapImpl; /** @@ -43,7 +41,7 @@ public void listMediaProcessorsCanTakeQueryParmeters() { queryParams.add("$top", "10"); queryParams.add("$skip", "2"); - EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list(queryParams); + EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); assertEquals("2", lister.getQueryParameters().getFirst("$skip")); From e98243806c87ba301d451cae0b7d035fa8ca65ef Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Fri, 11 Jan 2013 11:55:01 -0800 Subject: [PATCH 654/664] update tests to remove redundant variables --- .../services/media/models/AccessPolicyEntityTest.java | 2 -- .../services/media/models/ContentKeyEntityTest.java | 6 ------ .../windowsazure/services/media/models/JobEntityTest.java | 6 ------ .../services/media/models/LocatorEntityTest.java | 6 ------ .../services/media/models/MediaProcessorEntityTest.java | 6 ------ 5 files changed, 26 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index 1685c2461d947..0fe3d493fcd80 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -75,8 +75,6 @@ public void listReturnsExpectedUri() throws Exception { @Test public void listWithQueryParametersReturnsThem() throws Exception { MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list().setTop(10).setSkip(2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java index dbfb0c9304b20..bd7f4362246ae 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/ContentKeyEntityTest.java @@ -19,15 +19,12 @@ import java.net.URLEncoder; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the ContentKey entity @@ -84,9 +81,6 @@ public void listContentKeyReturnsExpectedUri() { @Test public void listContentKeyCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); EntityListOperation<ContentKeyInfo> lister = ContentKey.list().setTop(10).setSkip(2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java index 42c392ea70053..361aec9ffa659 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/JobEntityTest.java @@ -20,14 +20,12 @@ import java.net.URI; import javax.mail.internet.MimeMultipart; -import javax.ws.rs.core.MultivaluedMap; import org.junit.Test; import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityProxyData; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the methods and factories of the Job entity. @@ -65,10 +63,6 @@ public void JobListReturnsExpectedUri() { @Test public void JobListCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); - EntityListOperation<JobInfo> lister = Job.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java index 93390f8bf03e1..80881ea3c7841 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/LocatorEntityTest.java @@ -20,8 +20,6 @@ import java.net.URLEncoder; import java.util.Date; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; @@ -29,7 +27,6 @@ import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; import com.microsoft.windowsazure.services.media.implementation.content.LocatorRestType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the Locator entity @@ -139,9 +136,6 @@ public void listLocatorReturnsExpectedUri() { @Test public void listLocatorCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); EntityListOperation<LocatorInfo> lister = Locator.list().setTop(10).setSkip(2); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java index ae2edf2a3b629..33de16847679f 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/MediaProcessorEntityTest.java @@ -17,12 +17,9 @@ import static org.junit.Assert.*; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the MediaProcessor entity @@ -37,9 +34,6 @@ public void listMediaProcessorsReturnsExpectedUri() { @Test public void listMediaProcessorsCanTakeQueryParmeters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); EntityListOperation<MediaProcessorInfo> lister = MediaProcessor.list().setTop(10).setSkip(2); From e827e138ec3e4386361824d230f4aae91d08d681 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Fri, 11 Jan 2013 12:20:07 -0800 Subject: [PATCH 655/664] Fix code review feedback. --- .../services/media/EncryptionHelper.java | 1 - .../media/EncryptionIntegrationTest.java | 2 +- .../scenarios/MediaServiceScenarioTest.java | 26 ++--- .../scenarios/MediaServiceWrapper.java | 95 +++++++++++-------- 4 files changed, 66 insertions(+), 58 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java index 7f77502a0a1a8..5954e6a8cdc4b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionHelper.java @@ -37,7 +37,6 @@ public static boolean canUseStrongCrypto() { cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); } catch (Exception e) { - e.printStackTrace(); return false; } return true; diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java index 4fcdafb3aa9c4..964bafa5072ea 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/EncryptionIntegrationTest.java @@ -65,7 +65,7 @@ public class EncryptionIntegrationTest extends IntegrationTestBase { public void uploadAesProtectedAssetAndDownloadSuccess() throws Exception { // Arrange if (!EncryptionHelper.canUseStrongCrypto()) { - Assert.fail("JVM does not appear support the required encryption"); + Assert.fail("JVM does not support the required encryption"); } // Media Services requires 256-bit (32-byte) keys and diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 634c3df298565..9c3b2d787c86c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -24,8 +24,6 @@ import java.util.Random; import java.util.UUID; -import junit.framework.Assert; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -94,14 +92,8 @@ public void uploadFiles() throws Exception { @Test public void uploadEncryptedFiles() throws Exception { signalSetupStarting(); - // Media Services requires 256-bit (32-byte) keys for AES encryption. - Random random = new Random(); - byte[] aesKey = new byte[32]; - random.nextBytes(aesKey); + byte[] aesKey = getNewAesKey(); AssetInfo asset = wrapper.createAsset(testAssetPrefix + "uploadEncryptedFiles", AssetOption.StorageEncrypted); - if (asset == null) { - Assert.fail("JVM does not appear support the required encryption"); - } signalSetupFinished(); @@ -152,15 +144,9 @@ public void transformAsset() throws Exception { @Test public void transformEncryptedAsset() throws Exception { signalSetupStarting(); - // Media Services requires 256-bit (32-byte) keys for AES encryption. - Random random = new Random(); - byte[] aesKey = new byte[32]; - random.nextBytes(aesKey); + byte[] aesKey = getNewAesKey(); AssetInfo asset = wrapper .createAsset(testAssetPrefix + "transformEncryptedAsset", AssetOption.StorageEncrypted); - if (asset == null) { - Assert.fail("JVM does not appear support the required encryption"); - } wrapper.uploadFilesToAsset(asset, 10, getTestAssetFiles(), aesKey); String jobName = "my job transformEncryptedAsset" + UUID.randomUUID().toString(); @@ -182,6 +168,14 @@ public void transformEncryptedAsset() throws Exception { validator.validateAssetFiles(getTestAssetFiles(), actualFileStreams); } + private byte[] getNewAesKey() { + // Media Services requires 256-bit (32-byte) keys for AES encryption. + Random random = new Random(); + byte[] aesKey = new byte[32]; + random.nextBytes(aesKey); + return aesKey; + } + private void waitForJobToFinish(JobInfo job) throws InterruptedException, ServiceException { for (int counter = 0; !wrapper.isJobFinished(job); counter++) { if (counter > 30) { diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index b7ef93897c6cb..3f5d36d5bd12b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -39,6 +39,8 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import junit.framework.Assert; + import com.microsoft.windowsazure.services.core.ServiceException; import com.microsoft.windowsazure.services.core.storage.utils.Base64; import com.microsoft.windowsazure.services.media.MediaContract; @@ -128,7 +130,7 @@ public MediaServiceWrapper(MediaContract service) { // Manage public AssetInfo createAsset(String name, AssetOption encryption) throws ServiceException { if (encryption == AssetOption.StorageEncrypted && !EncryptionHelper.canUseStrongCrypto()) { - return null; + Assert.fail("JVM does not support the required encryption"); } // Create asset. The SDK's top-level method is the simplest way to do that. @@ -164,22 +166,7 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, uploadWindowInMinutes, EnumSet.of(AccessPolicyPermission.WRITE))); LocatorInfo locator = service.create(Locator.create(accessPolicy.getId(), asset.getId(), LocatorType.SAS)); - String contentKeyId = null; - if (aesKey != null) { - String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); - String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); - - String contentKeyIdUuid = UUID.randomUUID().toString(); - contentKeyId = "nb:kid:UUID:" + contentKeyIdUuid; - - byte[] encryptedContentKey = EncryptionHelper.encryptSymmetricKey(protectionKey, aesKey); - String encryptedContentKeyString = Base64.encode(encryptedContentKey); - String checksum = EncryptionHelper.calculateContentKeyChecksum(contentKeyIdUuid, aesKey); - - service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKeyString) - .setChecksum(checksum).setProtectionKeyId(protectionKeyId)); - service.action(Asset.linkContentKey(asset.getId(), contentKeyId)); - } + String contentKeyId = createAssetContentKey(asset, aesKey); WritableBlobContainerContract uploader = service.createBlobWriter(locator); @@ -187,34 +174,18 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, boolean isFirst = true; for (String fileName : inputFiles.keySet()) { - MessageDigest digest = MessageDigest.getInstance("MD5"); InputStream inputStream = inputFiles.get(fileName); - String initializationVector = null; + byte[] iv = null; if (aesKey != null) { - // Media Services requires 128-bit (16-byte) initialization vectors (IV) - // for AES encryption, but also that only the first 8 bytes are filled. - Random random = new Random(); - byte[] effectiveIv = new byte[8]; - random.nextBytes(effectiveIv); - byte[] iv = new byte[16]; - System.arraycopy(effectiveIv, 0, iv, 0, effectiveIv.length); - - byte[] sub = new byte[9]; - // Offset the bytes to ensure that the sign-bit is not set. - // Media Services expects unsigned Int64 values. - System.arraycopy(iv, 0, sub, 1, 8); - BigInteger longIv = new BigInteger(sub); - initializationVector = longIv.toString(); - + iv = createIV(); inputStream = EncryptionHelper.encryptFile(inputStream, aesKey, iv); } InputStream digestStream = new DigestInputStream(inputStream, digest); CountingStream countingStream = new CountingStream(digestStream); - uploader.createBlockBlob(fileName, countingStream); inputStream.close(); @@ -222,8 +193,8 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, String md5 = Base64.encode(md5hash); AssetFileInfo fi = new AssetFileInfo(null, new AssetFileType().setContentChecksum(md5) - .setContentFileSize(new Long(countingStream.getCount())).setIsPrimary(isFirst).setName(fileName) - .setParentAssetId(asset.getAlternateId()).setInitializationVector(initializationVector)); + .setContentFileSize(countingStream.getCount()).setIsPrimary(isFirst).setName(fileName) + .setInitializationVector(getIVString(iv))); infoToUpload.put(fileName, fi); isFirst = false; @@ -249,9 +220,54 @@ public void uploadFilesToAsset(AssetInfo asset, int uploadWindowInMinutes, service.delete(AccessPolicy.delete(accessPolicy.getId())); } + private String getIVString(byte[] iv) { + if (iv == null) { + return null; + } + + // Offset the bytes to ensure that the sign-bit is not set. + // Media Services expects unsigned Int64 values. + byte[] sub = new byte[9]; + System.arraycopy(iv, 0, sub, 1, 8); + BigInteger longIv = new BigInteger(sub); + return longIv.toString(); + } + + private byte[] createIV() { + // Media Services requires 128-bit (16-byte) initialization vectors (IV) + // for AES encryption, but also that only the first 8 bytes are filled. + Random random = new Random(); + byte[] effectiveIv = new byte[8]; + random.nextBytes(effectiveIv); + byte[] iv = new byte[16]; + System.arraycopy(effectiveIv, 0, iv, 0, effectiveIv.length); + return iv; + } + + private String createAssetContentKey(AssetInfo asset, byte[] aesKey) throws Exception { + if (aesKey == null) { + return null; + } + + String protectionKeyId = service.action(ProtectionKey.getProtectionKeyId(ContentKeyType.StorageEncryption)); + String protectionKey = service.action(ProtectionKey.getProtectionKey(protectionKeyId)); + + String contentKeyIdUuid = UUID.randomUUID().toString(); + String contentKeyId = "nb:kid:UUID:" + contentKeyIdUuid; + + byte[] encryptedContentKey = EncryptionHelper.encryptSymmetricKey(protectionKey, aesKey); + String encryptedContentKeyString = Base64.encode(encryptedContentKey); + String checksum = EncryptionHelper.calculateContentKeyChecksum(contentKeyIdUuid, aesKey); + + service.create(ContentKey.create(contentKeyId, ContentKeyType.StorageEncryption, encryptedContentKeyString) + .setChecksum(checksum).setProtectionKeyId(protectionKeyId)); + service.action(Asset.linkContentKey(asset.getId(), contentKeyId)); + return contentKeyId; + } + private static class CountingStream extends InputStream { private final InputStream wrappedStream; - private int count; + private long count; public CountingStream(InputStream wrapped) { wrappedStream = wrapped; @@ -264,7 +280,7 @@ public int read() throws IOException { return wrappedStream.read(); } - public int getCount() { + public long getCount() { return count; } } @@ -473,7 +489,6 @@ public static boolean canUseStrongCrypto() { cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); } catch (Exception e) { - e.printStackTrace(); return false; } return true; From 650034860ae1ef0976222f5e545a7c0ae8b77ada Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Mon, 14 Jan 2013 07:59:36 -0800 Subject: [PATCH 656/664] Removing unused MultivaluedMap references in tests See #609 --- .../services/media/models/AccessPolicyEntityTest.java | 5 ----- .../windowsazure/services/media/models/AssetEntityTest.java | 6 ------ 2 files changed, 11 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java index 0fe3d493fcd80..6c7ec9b6b604b 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AccessPolicyEntityTest.java @@ -20,15 +20,12 @@ import java.net.URLEncoder; import java.util.EnumSet; -import javax.ws.rs.core.MultivaluedMap; - import org.junit.Test; import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation; import com.microsoft.windowsazure.services.media.entityoperations.EntityListOperation; import com.microsoft.windowsazure.services.media.implementation.content.AccessPolicyType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for access policy entity @@ -74,8 +71,6 @@ public void listReturnsExpectedUri() throws Exception { @Test public void listWithQueryParametersReturnsThem() throws Exception { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - EntityListOperation<AccessPolicyInfo> lister = AccessPolicy.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java index 1cf45220d7db6..a60c58ca06ddb 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/models/AssetEntityTest.java @@ -19,7 +19,6 @@ import java.net.URLEncoder; -import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; @@ -35,7 +34,6 @@ import com.microsoft.windowsazure.services.media.implementation.content.AssetType; import com.microsoft.windowsazure.services.media.implementation.content.Constants; import com.microsoft.windowsazure.services.media.implementation.content.JobType; -import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Tests for the methods and factories of the Asset entity. @@ -99,10 +97,6 @@ public void assetListReturnsExpectedUri() { @Test public void assetListCanTakeQueryParameters() { - MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl(); - queryParams.add("$top", "10"); - queryParams.add("$skip", "2"); - EntityListOperation<AssetInfo> lister = Asset.list().setTop(10).setSkip(2); assertEquals("10", lister.getQueryParameters().getFirst("$top")); From 4e49db07e814205a2dc869620462de243519439d Mon Sep 17 00:00:00 2001 From: Joe Giardino <joegiard@microsoft.com> Date: Mon, 14 Jan 2013 11:00:02 -0800 Subject: [PATCH 657/664] Fix testCurrentOperationByteCount test race condition --- .../services/blob/client/CloudBlobContainerTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java index 9d945f61a53a9..89c983c3852ad 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/blob/client/CloudBlobContainerTests.java @@ -748,21 +748,21 @@ public void testCurrentOperationByteCount() throws URISyntaxException, StorageEx OperationContext operationContext = new OperationContext(); BlobRequestOptions options = new BlobRequestOptions(); - options.setTimeoutIntervalInMs(1000); + options.setTimeoutIntervalInMs(2000); options.setRetryPolicyFactory(new RetryNoRetry()); + ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); try { - final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); blobRef.download(downloadedDataStream, null, options, operationContext); } catch (Exception e) { - Assert.assertEquals(0, operationContext.getCurrentOperationByteCount()); + Assert.assertEquals(downloadedDataStream.size(), operationContext.getCurrentOperationByteCount()); } operationContext = new OperationContext(); options = new BlobRequestOptions(); options.setTimeoutIntervalInMs(90000); - final ByteArrayOutputStream downloadedDataStream = new ByteArrayOutputStream(); + downloadedDataStream = new ByteArrayOutputStream(); blobRef.download(downloadedDataStream, null, options, operationContext); Assert.assertEquals(blockLength * numberOfBlocks, operationContext.getCurrentOperationByteCount()); From 182b551b36fbdca716b7fa077920b774cc4ce0d2 Mon Sep 17 00:00:00 2001 From: Joost de Nijs <joostden@microsoft.com> Date: Mon, 14 Jan 2013 11:05:54 -0800 Subject: [PATCH 658/664] updating Changelog, pom and Readme for 0.4.0 release --- ChangeLog.txt | 4 ++++ README.md | 4 ++++ microsoft-azure-api/pom.xml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 78ac7b32bfa1d..b2f3fc8eba024 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2013.1.18 Version 0.4.0 + * Added support for Java Media Services + * Updated dependencies to non-beta stable versions + 2012.10.29 Version 0.3.3 * In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference * Updated the URL parse method in storage client libraries, to allow users to pass a URL ending with "/" diff --git a/README.md b/README.md index 94ab4da4a363b..6c3d5a83f7386 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ For documentation please see the [Windows Azure Java Developer Center](http://ww * Create/Delete Queues * Insert/Peek Queue Messages * Advanced Queue Operations +* Media Services + * Upload Media Files to Media Services + * Change the encoding on uploaded Media Services + * Provide streaming or download access to uploaded Media Files * Service Bus * Use either the Queue or Topic/Subscription Model * Service Runtime diff --git a/microsoft-azure-api/pom.xml b/microsoft-azure-api/pom.xml index 6953b1d4dfcfb..45fbc390a65ef 100644 --- a/microsoft-azure-api/pom.xml +++ b/microsoft-azure-api/pom.xml @@ -17,7 +17,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.microsoft.windowsazure</groupId> <artifactId>microsoft-windowsazure-api</artifactId> - <version>0.3.3</version> + <version>0.4.0</version> <packaging>jar</packaging> <name>Microsoft Windows Azure Client API</name> From feac891ad485ba0bf22938f01cc48f7d1b338469 Mon Sep 17 00:00:00 2001 From: Albert Cheng <gongchen@microsoft.com> Date: Mon, 14 Jan 2013 11:32:52 -0800 Subject: [PATCH 659/664] remove author from the headers of the file. --- .../windowsazure/services/media/implementation/ActiveToken.java | 2 -- .../windowsazure/services/media/implementation/OAuthFilter.java | 2 -- .../services/media/implementation/OAuthRestProxy.java | 2 -- .../services/media/implementation/OAuthTokenManager.java | 2 -- .../services/media/implementation/OAuthTokenResponse.java | 2 -- 5 files changed, 10 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java index 78efb77135225..062fa73b09c37 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/ActiveToken.java @@ -20,8 +20,6 @@ /** * A class representing active token. * - * @author azurejava@microsoft.com - * */ public class ActiveToken { diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java index c5083aeeae375..81d50e6a6bfc4 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthFilter.java @@ -25,8 +25,6 @@ /** * The Jersey filter for OAuth. * - * @author azurejava@microsoft.com - * */ public class OAuthFilter extends IdempotentClientFilter { private final OAuthTokenManager oAuthTokenManager; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java index 4f17ae38fb961..ecf179072bc59 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthRestProxy.java @@ -37,8 +37,6 @@ /** * The OAuth rest proxy. * - * @author azurejava@microsoft.com - * */ public class OAuthRestProxy implements OAuthContract { Client channel; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java index d0d082c5fb21f..7e80474ed2b37 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenManager.java @@ -29,8 +29,6 @@ /** * An OAuth token manager class. * - * @author azurejava@microsoft.com - * */ public class OAuthTokenManager { private final DateFactory dateFactory; diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java index 29131300ac3c5..bc8d3622e0688 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/implementation/OAuthTokenResponse.java @@ -20,8 +20,6 @@ /** * A class representing OAuth token response. * - * @author azurejava@microsoft.com - * */ public class OAuthTokenResponse { From 9077d148fb1d020eaeead9cf3c3f8cf00a905747 Mon Sep 17 00:00:00 2001 From: Joost de Nijs <joostden@microsoft.com> Date: Mon, 14 Jan 2013 15:43:33 -0800 Subject: [PATCH 660/664] updating Changelog, pom and Readme for 0.4.0 release with storage team changelog updates --- ChangeLog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index b2f3fc8eba024..a0232d82dc6ae 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ 2013.1.18 Version 0.4.0 * Added support for Java Media Services * Updated dependencies to non-beta stable versions + * Add a Sending Request Event to OperationContext in Storage Client code + * Fix a bug in the STorage client in blob download resume for blobs greater than 2GB 2012.10.29 Version 0.3.3 * In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference From ae3d4685cff3963ed2757e79a715a5d9cd182dbd Mon Sep 17 00:00:00 2001 From: Joost de Nijs <joostden@microsoft.com> Date: Mon, 14 Jan 2013 15:47:41 -0800 Subject: [PATCH 661/664] fixing issues on the pull request --- ChangeLog.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index a0232d82dc6ae..8fe478e4a635c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,5 @@ 2013.1.18 Version 0.4.0 - * Added support for Java Media Services + * Added support for Windows Azure Media Services * Updated dependencies to non-beta stable versions * Add a Sending Request Event to OperationContext in Storage Client code * Fix a bug in the STorage client in blob download resume for blobs greater than 2GB diff --git a/README.md b/README.md index 6c3d5a83f7386..e987ce514e3b5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ For documentation please see the [Windows Azure Java Developer Center](http://ww * Media Services * Upload Media Files to Media Services * Change the encoding on uploaded Media Services - * Provide streaming or download access to uploaded Media Files + * Provide streaming or download access to uploaded/transformed Media Files * Service Bus * Use either the Queue or Topic/Subscription Model * Service Runtime From 44f12ed07c9c438a5fee7f7250d1f490ca3f888d Mon Sep 17 00:00:00 2001 From: Joost de Nijs <joostden@microsoft.com> Date: Tue, 15 Jan 2013 14:53:23 -0800 Subject: [PATCH 662/664] fixing version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e987ce514e3b5..87ce6e7e7bbae 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ within your project you can also have them installed by the Java package manager <dependency> <groupId>com.microsoft.windowsazure</groupId> <artifactId>microsoft-windowsazure-api</artifactId> - <version>0.3.3</version> + <version>0.4.0</version> </dependency> ##Minimum Requirements From fdfdaed8b2e64e17a38d308edbe914a986ccbebb Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 15 Jan 2013 16:38:36 -0800 Subject: [PATCH 663/664] Replace "magic" ids with a named constant Update constant to current id value Update version number from "2.1" to "2.2" --- .../services/media/AssetIntegrationTest.java | 2 +- .../windowsazure/services/media/IntegrationTestBase.java | 2 ++ .../windowsazure/services/media/JobIntegrationTest.java | 2 +- .../windowsazure/services/media/TaskIntegrationTest.java | 9 ++++----- .../services/scenarios/MediaServiceWrapper.java | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java index 7d3ac22c8d09c..2c012d168f514 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java @@ -337,7 +337,7 @@ public void canGetParentBackFromAsset() throws ServiceException, InterruptedExce String jobName = testJobPrefix + "createJobSuccess"; CreateBatchOperation taskCreator = Task - .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5", + .create(MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID, "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>") .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java index e2e893b86b1f2..ffa12bb064fa4 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java @@ -63,6 +63,8 @@ public abstract class IntegrationTestBase { protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:38dcb3a0-ef64-4ad0-bbb5-67a14c6df2f7"; protected static final String validButNonexistLocatorId = "nb:lid:UUID:92a70402-fca9-4aa3-80d7-d4de3792a27a"; + protected static final String MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID = "nb:mpid:UUID:70bdc2c3-ebf4-42a9-8542-5afc1e55d217"; + protected static final String invalidId = "notAValidId"; @Rule diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index 486647a56874d..d93041f2c5330 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java @@ -80,7 +80,7 @@ private JobInfo createJob(String name) throws ServiceException { private CreateBatchOperation getTaskCreator(int outputAssetPosition) { return Task - .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5", + .create(MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID, "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset(" + outputAssetPosition + ")</outputAsset>" + "</taskBody>") .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task"); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java index 60e4cc787b9fb..ad9ca21b6750c 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java @@ -46,7 +46,6 @@ public class TaskIntegrationTest extends IntegrationTestBase { private static AssetInfo assetInfo; private Creator jobCreator; - private static final String commonMediaProcessorId = "nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5"; private static final String commonConfiguration = "H.264 256k DSL CBR"; @BeforeClass @@ -66,7 +65,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce // Arrange // Required - String mediaProcessorId = commonMediaProcessorId; + String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID; String taskBody = constructTaskBody(0); // Optional parameters @@ -102,7 +101,7 @@ public void createTwoTasksSuccess() throws ServiceException { // Arrange // Required - String mediaProcessorId = commonMediaProcessorId; + String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID; String[] taskBodies = new String[] { constructTaskBody(0), constructTaskBody(1) }; // Optional parameters @@ -136,7 +135,7 @@ public void createTwoTasksSuccess() throws ServiceException { @Test public void canListTasksWithOptions() throws ServiceException { // Arrange - String mediaProcessorId = commonMediaProcessorId; + String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID; String configuration = commonConfiguration; String[] taskNameSuffixes = new String[] { "A", "B", "C", "D" }; String baseName = "My encoding Task " + UUID.randomUUID().toString(); @@ -163,7 +162,7 @@ public void canListTasksWithOptions() throws ServiceException { @Test public void cancelTaskSuccess() throws ServiceException, InterruptedException { // Arrange - String mediaProcessorId = commonMediaProcessorId; + String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID; String taskBody = constructTaskBody(0); String configuration = commonConfiguration; String name = "My encoding Task " + UUID.randomUUID().toString(); diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 897b57b99277f..2ebfb7aa12231 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -313,15 +313,15 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss String configuration = null; switch (encoderType) { case Mp4ToSmoothStream: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS, "2.1.0.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS, "2.2.0.0"); configuration = configMp4ToSmoothStreams; break; case SmoothStreamsToHls: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS, "2.1.0.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS, "2.2.0.0"); configuration = configSmoothStreamsToAppleHttpLiveStreams; break; case WindowsAzureMediaEncoder: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.1.1.0"); + processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.2.0.0"); // Full list of configurations strings for version 2.1 is at: // http://msdn.microsoft.com/en-us/library/jj129582.aspx configuration = "VC1 Broadband SD 4x3"; From b0d834e1d23fbe73792bcefd8036f7ab93e92886 Mon Sep 17 00:00:00 2001 From: "Jason Cooke (MSFT)" <jcooke@microsoft.com> Date: Tue, 15 Jan 2013 17:20:37 -0800 Subject: [PATCH 664/664] Remove wrapper code that corresponds to non-existant processors Rework dependencies on that code. --- .../scenarios/MediaServiceScenarioTest.java | 4 +- .../scenarios/MediaServiceWrapper.java | 51 +------------------ 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java index 9c3b2d787c86c..41bc23269daba 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceScenarioTest.java @@ -188,8 +188,8 @@ private void waitForJobToFinish(JobInfo job) throws InterruptedException, Servic private List<Task.CreateBatchOperation> createTasks() throws ServiceException { List<Task.CreateBatchOperation> tasks = new ArrayList<Task.CreateBatchOperation>(); - tasks.add(wrapper.createTaskOptions("MP4 to SS", 0, 0, EncoderType.Mp4ToSmoothStream)); - tasks.add(wrapper.createTaskOptions("SS to HLS", 0, 1, EncoderType.SmoothStreamsToHls)); + tasks.add(wrapper.createTaskOptions("Decryptor", 0, 0, EncoderType.StorageDecryption)); + tasks.add(wrapper.createTaskOptions("Processor", 0, 1, EncoderType.WindowsAzureMediaEncoder)); return tasks; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java index 2ebfb7aa12231..16ba0ddcdf920 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/scenarios/MediaServiceWrapper.java @@ -77,50 +77,9 @@ class MediaServiceWrapper { private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption"; private final String MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER = "Windows Azure Media Encoder"; - private final String MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS = "MP4 to Smooth Streams Task"; - private final String MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS = "Smooth Streams to HLS Task"; - - // From http://msdn.microsoft.com/en-us/library/windowsazure/hh973635.aspx - private final String configMp4ToSmoothStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" - + " <name>MP4 to Smooth Streams</name>" - + " <id>5e1e1a1c-bba6-11df-8991-0019d1916af0</id>" - + " <description xml:lang='en'>Converts MP4 files encoded with H.264 (AVC) video and AAC-LC audio codecs to Smooth Streams.</description>" - + " <inputFolder />" - + " <properties namespace='http://schemas.microsoft.com/iis/media/V4/TM/MP4ToSmooth#' prefix='mp4'>" - + " <property name='keepSourceNames' required='false' value='true' helpText='This property tells the MP4 to Smooth task to keep the original file name rather than add the bitrate bitrate information.' />" - + " </properties>" - + " <taskCode>" - + " <type>Microsoft.Web.Media.TransformManager.MP4toSmooth.MP4toSmooth_Task, Microsoft.Web.Media.TransformManager.MP4toSmooth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" - + " </taskCode>" + "</taskDefinition>"; - - // From http://msdn.microsoft.com/en-us/library/windowsazure/hh973636.aspx - private final String configSmoothStreamsToAppleHttpLiveStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>" - + " <name>Smooth Streams to Apple HTTP Live Streams</name>" - + " <id>A72D7A5D-3022-45f2-89B4-1DDC5457C111</id>" - + " <description xml:lang='en'>Converts on-demand Smooth Streams encoded with H.264 (AVC) video and AAC-LC audio codecs to Apple HTTP Live Streams (MPEG-2 TS) and creates an Apple HTTP Live Streaming playlist (.m3u8) file for the converted presentation.</description>" - + " <inputDirectory></inputDirectory>" - + " <outputFolder>TS_Out</outputFolder>" - + " <properties namespace='http://schemas.microsoft.com/iis/media/AppleHTTP#' prefix='hls'>" - + " <property name='maxbitrate' required='true' value='8500000' helpText='The maximum bit rate, in bits per second (bps), to be converted to MPEG-2 TS. On-demand Smooth Streams at or below this value are converted to MPEG-2 TS segments. Smooth Streams above this value are not converted. Most Apple devices can play media encoded at bit rates up to 8,500 Kbps.'/>" - + " <property name='manifest' required='false' value='' helpText='The file name to use for the converted Apple HTTP Live Streaming playlist file (a file with an .m3u8 file name extension). If no value is specified, the following default value is used: <ISM_file_name>-m3u8-aapl.m3u8'/>" - + " <property name='segment' required='false' value='10' helpText='The duration of each MPEG-2 TS segment, in seconds. 10 seconds is the Apple-recommended setting for most Apple mobile digital devices.'/>" - + " <property name='log' required='false' value='' helpText='The file name to use for a log file (with a .log file name extension) that records the conversion activity. If you specify a log file name, the file is stored in the task output folder.' /> " - + " <property name='encrypt' required='false' value='false' helpText='Enables encryption of MPEG-2 TS segments by using the Advanced Encryption Standard (AES) with a 128-bit key (AES-128).' />" - + " <property name='pid' required='false' value='' helpText='The program ID of the MPEG-2 TS presentation. Different encodings of MPEG-2 TS streams in the same presentation use the same program ID so that clients can easily switch between bit rates.' />" - + " <property name='codecs' required='false' value='false' helpText='Enables codec format identifiers, as defined by RFC 4281, to be included in the Apple HTTP Live Streaming playlist (.m3u8) file.' />" - + " <property name='backwardcompatible' required='false' value='false' helpText='Enables playback of the MPEG-2 TS presentation on devices that use the Apple iOS 3.0 mobile operating system.' />" - + " <property name='allowcaching' required='false' value='true' helpText='Enables the MPEG-2 TS segments to be cached on Apple devices for later playback.' />" - + " <property name='passphrase' required='false' value='' helpText='A passphrase that is used to generate the content key identifier.' />" - + " <property name='key' required='false' value='' helpText='The hexadecimal representation of the 16-octet content key value that is used for encryption.' />" - + " <property name='keyuri' required='false' value='' helpText='An alternate URI to be used by clients for downloading the key file. If no value is specified, it is assumed that the Live Smooth Streaming publishing point provides the key file.' />" - + " <property name='overwrite' required='false' value='true' helpText='Enables existing files in the output folder to be overwritten if converted output files have identical file names.' />" - + " </properties>" - + " <taskCode>" - + " <type>Microsoft.Web.Media.TransformManager.SmoothToHLS.SmoothToHLSTask, Microsoft.Web.Media.TransformManager.SmoothToHLS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>" - + " </taskCode>" + "</taskDefinition>"; public static enum EncoderType { - WindowsAzureMediaEncoder, Mp4ToSmoothStream, SmoothStreamsToHls, StorageDecryption + WindowsAzureMediaEncoder, StorageDecryption } public MediaServiceWrapper(MediaContract service) { @@ -312,14 +271,6 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss String processor = null; String configuration = null; switch (encoderType) { - case Mp4ToSmoothStream: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS, "2.2.0.0"); - configuration = configMp4ToSmoothStreams; - break; - case SmoothStreamsToHls: - processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS, "2.2.0.0"); - configuration = configSmoothStreamsToAppleHttpLiveStreams; - break; case WindowsAzureMediaEncoder: processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.2.0.0"); // Full list of configurations strings for version 2.1 is at: